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') 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