Merge pull request #70 from tswicegood/fix-js-scope
Cleaned up various JavaScript in admin JS.
This commit is contained in:
commit
4b75546b45
|
@ -3,7 +3,7 @@
|
||||||
var options = $.extend({}, $.fn.actions.defaults, opts);
|
var options = $.extend({}, $.fn.actions.defaults, opts);
|
||||||
var actionCheckboxes = $(this);
|
var actionCheckboxes = $(this);
|
||||||
var list_editable_changed = false;
|
var list_editable_changed = false;
|
||||||
checker = function(checked) {
|
var checker = function(checked) {
|
||||||
if (checked) {
|
if (checked) {
|
||||||
showQuestion();
|
showQuestion();
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@
|
||||||
}
|
}
|
||||||
$(actionCheckboxes).attr("checked", checked)
|
$(actionCheckboxes).attr("checked", checked)
|
||||||
.parent().parent().toggleClass(options.selectedClass, checked);
|
.parent().parent().toggleClass(options.selectedClass, checked);
|
||||||
}
|
},
|
||||||
updateCounter = function() {
|
updateCounter = function() {
|
||||||
var sel = $(actionCheckboxes).filter(":checked").length;
|
var sel = $(actionCheckboxes).filter(":checked").length;
|
||||||
$(options.counterContainer).html(interpolate(
|
$(options.counterContainer).html(interpolate(
|
||||||
|
@ -29,30 +29,30 @@
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
showQuestion = function() {
|
showQuestion = function() {
|
||||||
$(options.acrossClears).hide();
|
$(options.acrossClears).hide();
|
||||||
$(options.acrossQuestions).show();
|
$(options.acrossQuestions).show();
|
||||||
$(options.allContainer).hide();
|
$(options.allContainer).hide();
|
||||||
}
|
},
|
||||||
showClear = function() {
|
showClear = function() {
|
||||||
$(options.acrossClears).show();
|
$(options.acrossClears).show();
|
||||||
$(options.acrossQuestions).hide();
|
$(options.acrossQuestions).hide();
|
||||||
$(options.actionContainer).toggleClass(options.selectedClass);
|
$(options.actionContainer).toggleClass(options.selectedClass);
|
||||||
$(options.allContainer).show();
|
$(options.allContainer).show();
|
||||||
$(options.counterContainer).hide();
|
$(options.counterContainer).hide();
|
||||||
}
|
},
|
||||||
reset = function() {
|
reset = function() {
|
||||||
$(options.acrossClears).hide();
|
$(options.acrossClears).hide();
|
||||||
$(options.acrossQuestions).hide();
|
$(options.acrossQuestions).hide();
|
||||||
$(options.allContainer).hide();
|
$(options.allContainer).hide();
|
||||||
$(options.counterContainer).show();
|
$(options.counterContainer).show();
|
||||||
}
|
},
|
||||||
clearAcross = function() {
|
clearAcross = function() {
|
||||||
reset();
|
reset();
|
||||||
$(options.acrossInput).val(0);
|
$(options.acrossInput).val(0);
|
||||||
$(options.actionContainer).removeClass(options.selectedClass);
|
$(options.actionContainer).removeClass(options.selectedClass);
|
||||||
}
|
};
|
||||||
// Show counter by default
|
// Show counter by default
|
||||||
$(options.counterContainer).show();
|
$(options.counterContainer).show();
|
||||||
// Check state of checkboxes and reinit state if needed
|
// Check state of checkboxes and reinit state if needed
|
||||||
|
@ -81,9 +81,9 @@
|
||||||
});
|
});
|
||||||
lastChecked = null;
|
lastChecked = null;
|
||||||
$(actionCheckboxes).click(function(event) {
|
$(actionCheckboxes).click(function(event) {
|
||||||
if (!event) { var event = window.event; }
|
if (!event) { event = window.event; }
|
||||||
var target = event.target ? event.target : event.srcElement;
|
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;
|
var inrange = false;
|
||||||
$(lastChecked).attr("checked", target.checked)
|
$(lastChecked).attr("checked", target.checked)
|
||||||
.parent().parent().toggleClass(options.selectedClass, target.checked);
|
.parent().parent().toggleClass(options.selectedClass, target.checked);
|
||||||
|
@ -124,7 +124,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
/* Setup plugin defaults */
|
/* Setup plugin defaults */
|
||||||
$.fn.actions.defaults = {
|
$.fn.actions.defaults = {
|
||||||
actionContainer: "div.actions",
|
actionContainer: "div.actions",
|
||||||
|
@ -135,5 +135,5 @@
|
||||||
acrossClears: "div.actions span.clear",
|
acrossClears: "div.actions span.clear",
|
||||||
allToggle: "#action-toggle",
|
allToggle: "#action-toggle",
|
||||||
selectedClass: "selected"
|
selectedClass: "selected"
|
||||||
}
|
};
|
||||||
})(django.jQuery);
|
})(django.jQuery);
|
||||||
|
|
Loading…
Reference in New Issue