36 lines
No EOL
1,006 B
JavaScript
36 lines
No EOL
1,006 B
JavaScript
/*global jQuery:false*/
|
|
'use strict';
|
|
/* Puts the included jQuery into our own namespace using noConflict and passing
|
|
* it 'true'. This ensures that the included jQuery doesn't pollute the global
|
|
* namespace (i.e. this preserves pre-existing values for both window.$ and
|
|
* window.jQuery).
|
|
*/
|
|
window.django = {jQuery: jQuery};
|
|
|
|
// jquery toggle whole attribute
|
|
$.fn.toggleAttr = function (attr, val) {
|
|
var test = $(this).attr(attr);
|
|
if (test) {
|
|
// if attrib exists with ANY value, still remove it
|
|
$(this).removeAttr(attr);
|
|
} else {
|
|
$(this).attr(attr, val);
|
|
}
|
|
return this;
|
|
};
|
|
|
|
// jquery toggle just the attribute value
|
|
$.fn.toggleAttrVal = function (attr, val1, val2) {
|
|
var test = $(this).attr(attr);
|
|
if (test === val1) {
|
|
$(this).attr(attr, val2);
|
|
return this;
|
|
}
|
|
if (test === val2) {
|
|
$(this).attr(attr, val1);
|
|
return this;
|
|
}
|
|
// default to val1 if neither
|
|
$(this).attr(attr, val1);
|
|
return this;
|
|
}; |