diff options
author | Pierre Spring <pierre.spring@caillou.ch> | 2010-10-10 20:05:45 +0200 |
---|---|---|
committer | Pierre Spring <pierre.spring@caillou.ch> | 2010-10-10 20:05:45 +0200 |
commit | b256527a2a3500ac4c94e2472c2ebe928377bb37 (patch) | |
tree | abef7ae7a612f7604d993ab18ae545137372856c | |
parent | 67a0ce7861f65736f36a8dd392c70c9c2d235977 (diff) | |
download | dokuwiki-b256527a2a3500ac4c94e2472c2ebe928377bb37.tar.gz dokuwiki-b256527a2a3500ac4c94e2472c2ebe928377bb37.zip |
subscriptions.js jQueryfied
-rw-r--r-- | lib/scripts/subscriptions.js | 67 |
1 files changed, 31 insertions, 36 deletions
diff --git a/lib/scripts/subscriptions.js b/lib/scripts/subscriptions.js index d701f258f..144f31881 100644 --- a/lib/scripts/subscriptions.js +++ b/lib/scripts/subscriptions.js @@ -2,45 +2,40 @@ * Hide list subscription style if target is a page * * @author Adrian Lang <lang@cosmocode.de> + * @author Pierre Spring <pierre.spring@caillou.ch> */ +(function ($) { + $(function () { + var form, list, digest; + + form = $('#subscribe__form'); -addInitEvent(function () { - var form = $('subscribe__form'); - if (!form) { - return; - } - - var styleradios = {}; - - function update_state() { - if (!this.checked) { + if (0 === form.size()) { return; } - if (this.value.match(/:$/)) { - styleradios.list.parentNode.style.display = ''; - } else { - styleradios.list.parentNode.style.display = 'none'; - if (styleradios.list.checked) { - styleradios.digest.checked = 'checked'; - } - } - } + + list = form.find("input[name='sub_style'][value='list']"); + digest = form.find("input[name='sub_style'][value='digest']"); - var cur_sel = null; + form.find("input[name='sub_target']") + .click( + function () { + var input = $(this); + if (!input.is(':checked')) { + return; + } - var inputs = form.getElementsByTagName('input'); - for (var i = 0; i < inputs.length ; ++i) { - switch (inputs[i].name) { - case 'sub_target': - addEvent(inputs[i], 'click', update_state); - if (inputs[i].checked) { - cur_sel = inputs[i]; - } - break; - case 'sub_style': - styleradios[inputs[i].value] = inputs[i]; - break; - } - } - update_state.call(cur_sel); -}); + if (input.val().match(/:$/)) { + list.parent().show(); + } else { + list.parent().hide(); + if (list.is(':checked')) { + digest.attr('checked', 'checked'); + } + } + } + ) + .filter(':checked') + .click(); + }); +}(jQuery));
\ No newline at end of file |