fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2012-01-06 09:51 am

[dw-free] Make choosing random icon a button

[commit: http://hg.dwscoalition.org/dw-free/rev/d7b44a73ad87]

http://bugs.dwscoalition.org/show_bug.cgi?id=4177

Make it a button.

Patch by [personal profile] fu.

Files modified:
  • bin/upgrading/deadphrases.dat
  • cgi-bin/LJ/Talk.pm
  • cgi-bin/LJ/Web.pm
  • htdocs/js/talkpost.js
  • htdocs/talkpost.bml.text
--------------------------------------------------------------------------------
diff -r 0535f87dbd1e -r d7b44a73ad87 bin/upgrading/deadphrases.dat
--- a/bin/upgrading/deadphrases.dat	Fri Jan 06 17:28:21 2012 +0800
+++ b/bin/upgrading/deadphrases.dat	Fri Jan 06 17:51:43 2012 +0800
@@ -1497,3 +1497,5 @@
 general esn.comm_invite.subject
 
 general error.security.noarg
+
+general /talkpost.bml.userpic.random
diff -r 0535f87dbd1e -r d7b44a73ad87 cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm	Fri Jan 06 17:28:21 2012 +0800
+++ b/cgi-bin/LJ/Talk.pm	Fri Jan 06 17:51:43 2012 +0800
@@ -2121,7 +2121,7 @@
         }
 
         # random icon button - hidden for non-JS
-        $ret .= "<a href='javascript:void(0)' onclick='randomicon();' class='ljhidden' id='randomicon'>" . BML::ml('/talkpost.bml.userpic.random') ."</a>";
+        $ret .= "<button class='ljhidden' id='randomicon'>" . BML::ml('/talkpost.bml.userpic.random2') ."</button>";
 
         $ret .= LJ::help_icon_html("userpics", " ");
     }
diff -r 0535f87dbd1e -r d7b44a73ad87 cgi-bin/LJ/Web.pm
--- a/cgi-bin/LJ/Web.pm	Fri Jan 06 17:28:21 2012 +0800
+++ b/cgi-bin/LJ/Web.pm	Fri Jan 06 17:51:43 2012 +0800
@@ -949,7 +949,7 @@
                 } if $remote->can_use_userpic_select;
 
             my $onclick = $beta_jquery ? "" : "onclick='randomicon();'";
-            $qrhtml .= "<a href='javascript:void(0)' $onclick id='randomicon'>" . BML::ml('/talkpost.bml.userpic.random') . "</a>";
+            $qrhtml .= "<button $onclick id='randomicon'>" . BML::ml('/talkpost.bml.userpic.random2') . "</button>";
 
             $qrhtml .= LJ::help_icon_html("userpics", " ");
         }
diff -r 0535f87dbd1e -r d7b44a73ad87 htdocs/js/talkpost.js
--- a/htdocs/js/talkpost.js	Fri Jan 06 17:28:21 2012 +0800
+++ b/htdocs/js/talkpost.js	Fri Jan 06 17:51:43 2012 +0800
@@ -230,17 +230,20 @@
 }
 
 function showRandomIcon() {
-    var randomicon = document.getElementById("randomicon");
-    if (randomicon)
-        randomicon.setAttribute("class", "randomicon");
+    var ele = document.getElementById("randomicon");
+    if (ele) {
+        ele.setAttribute("class", "randomicon");
+        ele.onclick = randomicon;
+    }
 }
 
-function randomicon() {
+function randomicon(e) {
     var icons_list = document.getElementById('prop_picture_keyword');
     // we need to ignore the "(default)" option for this code
     var numberoficons = icons_list.length-1;
     var randomnumber=Math.floor(Math.random()*numberoficons) +1;
     icons_list.selectedIndex = randomnumber;
+    e.preventDefault();
 }
 
 function subjectNoHTML(e) {
diff -r 0535f87dbd1e -r d7b44a73ad87 htdocs/talkpost.bml.text
--- a/htdocs/talkpost.bml.text	Fri Jan 06 17:28:21 2012 +0800
+++ b/htdocs/talkpost.bml.text	Fri Jan 06 17:51:43 2012 +0800
@@ -109,4 +109,4 @@
 Please clear the textbox or select the correct posting mode and try again.
 .
 
-.userpic.random=Choose random icon
+.userpic.random2=Random icon
--------------------------------------------------------------------------------

[personal profile] boundbooks 2012-01-19 07:12 pm (UTC)(link)
For some reason, I am extremely pleased by this change. Now my comment buttons will match! XD