summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Lang <mail@adrianlang.de>2011-06-21 14:30:47 +0200
committerAdrian Lang <mail@adrianlang.de>2011-06-21 14:30:47 +0200
commit2e5fe8c36b4c40fa6c96a09e234ce922182a761d (patch)
tree152101e62569e6c04916d71e6ee1aed1822c7d40
parentcd06d16faa924afeb14f864b058e01ce8867057c (diff)
downloadrpg-2e5fe8c36b4c40fa6c96a09e234ce922182a761d.tar.gz
rpg-2e5fe8c36b4c40fa6c96a09e234ce922182a761d.tar.bz2
Rework subscription.js
* Remove jQuery to $ wrapper function * Add $ prefix for jQuery variables * Make some jQuery calls faster * Use slide animation
-rw-r--r--lib/scripts/subscriptions.js56
1 files changed, 28 insertions, 28 deletions
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 <lang@cosmocode.de>
* @author Pierre Spring <pierre.spring@caillou.ch>
*/
-(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();
+});