From b256527a2a3500ac4c94e2472c2ebe928377bb37 Mon Sep 17 00:00:00 2001 From: Pierre Spring Date: Sun, 10 Oct 2010 20:05:45 +0200 Subject: subscriptions.js jQueryfied --- lib/scripts/subscriptions.js | 67 ++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 36 deletions(-) (limited to 'lib/scripts/subscriptions.js') 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 + * @author Pierre Spring */ +(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 -- cgit v1.2.3 From 2e5fe8c36b4c40fa6c96a09e234ce922182a761d Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Tue, 21 Jun 2011 14:30:47 +0200 Subject: Rework subscription.js * Remove jQuery to $ wrapper function * Add $ prefix for jQuery variables * Make some jQuery calls faster * Use slide animation --- lib/scripts/subscriptions.js | 56 ++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'lib/scripts/subscriptions.js') diff --git a/lib/scripts/subscriptions.js b/lib/scripts/subscriptions.js index 79b1caf1a..565ea33eb 100644 --- a/lib/scripts/subscriptions.js +++ b/lib/scripts/subscriptions.js @@ -1,41 +1,41 @@ +/*jslint sloppy: true */ +/*global jQuery */ /** * Hide list subscription style if target is a page * * @author Adrian Lang * @author Pierre Spring */ -(function ($) { - $(function () { - var form, list, digest; +jQuery(function () { + var $form, $list, $digest; - form = $('#subscribe__form'); + $form = jQuery('#subscribe__form'); - if (0 === form.size()) { - return; - } + if (0 === $form.length) { + return; + } - list = form.find("input[name='sub_style'][value='list']"); - digest = form.find("input[name='sub_style'][value='digest']"); + $list = $form.find("input[name='sub_style'][value='list']"); + $digest = $form.find("input[name='sub_style'][value='digest']"); - form.find("input[name='sub_target']") - .click( - function () { - var input = $(this); - if (!input.is(':checked')) { - return; - } + $form.find("input[name='sub_target']") + .click( + function () { + var $input = jQuery(this); + if (!$input.prop('checked')) { + return; + } - if (input.val().match(/:$/)) { - list.parent().show(); - } else { - list.parent().hide(); - if (list.is(':checked')) { - digest.attr('checked', 'checked'); - } + if ($input.val().match(/:$/)) { + $list.parent().slideDown('fast'); + } else { + $list.parent().slideUp('fast'); + if ($list.prop('checked')) { + $digest.prop('checked', 'checked'); } } - ) - .filter(':checked') - .click(); - }); -}(jQuery)); + } + ) + .filter(':checked') + .click(); +}); -- cgit v1.2.3 From d10c9a7424d1ef0aace2fd34e1008196d111a88c Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 7 Jul 2011 16:08:05 +0200 Subject: Rewrite mediamanager JavaScript Make it faster, prettier, less wrong, add UI effects, use jQuery UI Dialog, Abstract tree view stuff away into jQuery.dw_tree --- lib/scripts/subscriptions.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib/scripts/subscriptions.js') diff --git a/lib/scripts/subscriptions.js b/lib/scripts/subscriptions.js index 565ea33eb..b7bffb158 100644 --- a/lib/scripts/subscriptions.js +++ b/lib/scripts/subscriptions.js @@ -21,18 +21,15 @@ jQuery(function () { $form.find("input[name='sub_target']") .click( function () { - var $input = jQuery(this); - if (!$input.prop('checked')) { + var $this = jQuery(this), show_list; + if (!$this.prop('checked')) { return; } - if ($input.val().match(/:$/)) { - $list.parent().slideDown('fast'); - } else { - $list.parent().slideUp('fast'); - if ($list.prop('checked')) { - $digest.prop('checked', 'checked'); - } + show_list = $this.val().match(/:$/); + $list.parent().dw_toggle(show_list); + if (!show_list && $list.prop('checked')) { + $digest.prop('checked', 'checked'); } } ) -- cgit v1.2.3 From 02782d1287173f3981a008755958543c178de296 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 18 Aug 2011 12:24:43 +0200 Subject: moved subscription javascript into behaviour --- lib/scripts/subscriptions.js | 38 -------------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 lib/scripts/subscriptions.js (limited to 'lib/scripts/subscriptions.js') diff --git a/lib/scripts/subscriptions.js b/lib/scripts/subscriptions.js deleted file mode 100644 index b7bffb158..000000000 --- a/lib/scripts/subscriptions.js +++ /dev/null @@ -1,38 +0,0 @@ -/*jslint sloppy: true */ -/*global jQuery */ -/** - * Hide list subscription style if target is a page - * - * @author Adrian Lang - * @author Pierre Spring - */ -jQuery(function () { - var $form, $list, $digest; - - $form = jQuery('#subscribe__form'); - - if (0 === $form.length) { - return; - } - - $list = $form.find("input[name='sub_style'][value='list']"); - $digest = $form.find("input[name='sub_style'][value='digest']"); - - $form.find("input[name='sub_target']") - .click( - function () { - var $this = jQuery(this), show_list; - if (!$this.prop('checked')) { - return; - } - - show_list = $this.val().match(/:$/); - $list.parent().dw_toggle(show_list); - if (!show_list && $list.prop('checked')) { - $digest.prop('checked', 'checked'); - } - } - ) - .filter(':checked') - .click(); -}); -- cgit v1.2.3