afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-07-04 01:06 am

[dw-free] crossposter showing multiple checkboxes unnecessarily

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

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

Allow crosspost to be enabled/disabled with one click (requires Javascript)

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/weblib.pl
  • htdocs/js/xpost.js
--------------------------------------------------------------------------------
diff -r deffdb467fa7 -r 570c66cd219c cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Sat Jul 04 00:48:29 2009 +0000
+++ b/cgi-bin/weblib.pl	Sat Jul 04 01:04:01 2009 +0000
@@ -1588,7 +1588,8 @@ MOODS
                             'class'    => 'check xpost_acct_checkbox',
                             'value'    => '1',
                             'selected' => $selected,
-                            'tabindex'  => $tabindex->(),
+                            'tabindex' => $tabindex->(),
+                            'onchange' => 'LiveJournal.xpostAcctUpdated();',
                                                              }) . "</td>\n";
                         $xpostbydefault = 1 if $selected;
                         
@@ -1641,8 +1642,8 @@ MOODS
                 $out .= "</div>\n";
                 # disable choices if no xpost selected by default.
                 $out .= qq [ 
-              <script type="javascript">
-                LiveJournal.xpostButtonUpdated();
+              <script type="text/javascript">
+                LiveJournal.xpostAcctUpdated();
               </script>
               <p class='pkg'>
               <span class='inputgroup-left'></span>
diff -r deffdb467fa7 -r 570c66cd219c htdocs/js/xpost.js
--- a/htdocs/js/xpost.js	Sat Jul 04 00:48:29 2009 +0000
+++ b/htdocs/js/xpost.js	Sat Jul 04 01:04:01 2009 +0000
@@ -6,16 +6,29 @@ LiveJournal.xpostButtonUpdated = functio
   }
 }
 
+LiveJournal.xpostAcctUpdated = function () {
+  var xpost_button = document.getElementById("prop_xpost_check");
+  var xpost_checkboxes = DOM.getElementsByTagAndClassName(document, "input", "xpost_acct_checkbox") || [];
+  var allunchecked = true;
+  for (var i=0; i < xpost_checkboxes.length; i++) {
+    allunchecked = allunchecked && ! xpost_checkboxes[i].checked;
+  }
+  xpost_button.checked = ! allunchecked;
+  xpost_button.disabled = allunchecked;
+}
+
 LiveJournal.updateXpostFromJournal = function (user) {
   // only allow crossposts to the user's own journal
   var journal = document.updateForm.usejournal.value;
   var allowXpost = (journal == '' || user == journal);
 
   var xpost_button = document.getElementById("prop_xpost_check");
-  xpost_button.disabled = ! allowXpost;
+  // preserve existing disabled state if xpost allowed
+  xpost_button.disabled = (! allowXpost) || xpost_button.disabled;
   var xpost_checkboxes = DOM.getElementsByTagAndClassName(document, "input", "xpost_acct_checkbox") || [];
   for (var i=0; i < xpost_checkboxes.length; i++) {
-    xpost_checkboxes[i].disabled = ! allowXpost;
+    // preserve existing disabled state if xpost allowed
+    xpost_checkboxes[i].disabled = (! allowXpost) || xpost_checkboxes[i].disabled;
   }
 
   var xpostdiv = document.getElementById('xpostdiv');
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org