Allow crosspost to be enabled/disabled with one click (requires
Javascript)
Patch by kareila.
diffs (59 lines):
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');
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog