From c647065b490667a6691a1c358d471def9ad72b60 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 16 May 2012 13:32:53 -0500 Subject: [PATCH 1/4] Make sure these functions don't bleed into the global scope This makes sure that all of these functions are assigned to variables assigned to the current scope, rather than the global scope. It also adds a trailing semi-colon to make sure various linters are happy. --- django/contrib/admin/static/admin/js/actions.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/django/contrib/admin/static/admin/js/actions.js b/django/contrib/admin/static/admin/js/actions.js index 94aa6db934..8e46eb187c 100644 --- a/django/contrib/admin/static/admin/js/actions.js +++ b/django/contrib/admin/static/admin/js/actions.js @@ -3,7 +3,7 @@ var options = $.extend({}, $.fn.actions.defaults, opts); var actionCheckboxes = $(this); var list_editable_changed = false; - checker = function(checked) { + var checker = function(checked) { if (checked) { showQuestion(); } else { @@ -11,7 +11,7 @@ } $(actionCheckboxes).attr("checked", checked) .parent().parent().toggleClass(options.selectedClass, checked); - } + }, updateCounter = function() { var sel = $(actionCheckboxes).filter(":checked").length; $(options.counterContainer).html(interpolate( @@ -29,30 +29,30 @@ } return value; }); - } + }, showQuestion = function() { $(options.acrossClears).hide(); $(options.acrossQuestions).show(); $(options.allContainer).hide(); - } + }, showClear = function() { $(options.acrossClears).show(); $(options.acrossQuestions).hide(); $(options.actionContainer).toggleClass(options.selectedClass); $(options.allContainer).show(); $(options.counterContainer).hide(); - } + }, reset = function() { $(options.acrossClears).hide(); $(options.acrossQuestions).hide(); $(options.allContainer).hide(); $(options.counterContainer).show(); - } + }, clearAcross = function() { reset(); $(options.acrossInput).val(0); $(options.actionContainer).removeClass(options.selectedClass); - } + }; // Show counter by default $(options.counterContainer).show(); // Check state of checkboxes and reinit state if needed From 67fd30e9abdf0ad0fc95fd4d2d5bd7ba35a74038 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 16 May 2012 13:38:02 -0500 Subject: [PATCH 2/4] Remove `var` declaration---this variable is already delcared as an argument --- django/contrib/admin/static/admin/js/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/contrib/admin/static/admin/js/actions.js b/django/contrib/admin/static/admin/js/actions.js index 8e46eb187c..1c34a8ee70 100644 --- a/django/contrib/admin/static/admin/js/actions.js +++ b/django/contrib/admin/static/admin/js/actions.js @@ -81,7 +81,7 @@ }); lastChecked = null; $(actionCheckboxes).click(function(event) { - if (!event) { var event = window.event; } + if (!event) { event = window.event; } var target = event.target ? event.target : event.srcElement; if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey == true) { var inrange = false; From 6e3b9962cce022a611fb84fbde11ad274d29a341 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 16 May 2012 13:38:23 -0500 Subject: [PATCH 3/4] Add missing semi-colons --- django/contrib/admin/static/admin/js/actions.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/django/contrib/admin/static/admin/js/actions.js b/django/contrib/admin/static/admin/js/actions.js index 1c34a8ee70..91baa1d822 100644 --- a/django/contrib/admin/static/admin/js/actions.js +++ b/django/contrib/admin/static/admin/js/actions.js @@ -124,7 +124,7 @@ } } }); - } + }; /* Setup plugin defaults */ $.fn.actions.defaults = { actionContainer: "div.actions", @@ -135,5 +135,5 @@ acrossClears: "div.actions span.clear", allToggle: "#action-toggle", selectedClass: "selected" - } + }; })(django.jQuery); From f92c7c5df2f6f09e3c5d4112d950c60738dea7f8 Mon Sep 17 00:00:00 2001 From: Travis Swicegood Date: Wed, 16 May 2012 13:40:24 -0500 Subject: [PATCH 4/4] Swap out to === for the true comparison to avoid possible coercion issues --- django/contrib/admin/static/admin/js/actions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/django/contrib/admin/static/admin/js/actions.js b/django/contrib/admin/static/admin/js/actions.js index 91baa1d822..8494970aa1 100644 --- a/django/contrib/admin/static/admin/js/actions.js +++ b/django/contrib/admin/static/admin/js/actions.js @@ -83,7 +83,7 @@ $(actionCheckboxes).click(function(event) { if (!event) { event = window.event; } var target = event.target ? event.target : event.srcElement; - if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey == true) { + if (lastChecked && $.data(lastChecked) != $.data(target) && event.shiftKey === true) { var inrange = false; $(lastChecked).attr("checked", target.checked) .parent().parent().toggleClass(options.selectedClass, target.checked);