Created
January 6, 2012 04:01
-
-
Save PureForm/1568900 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CM.CheckboxRangeCheck = function (formID,checkboxIdPrefix,checkboxIdRegex) { | |
var lastCheckboxClickedID = ""; | |
$("#" + formID + " input[type=checkbox]").on("click",function(e) { | |
if (e.shiftKey && (lastCheckboxClickedID !== "") && $(this).prop("checked") && $("#" + lastCheckboxClickedID).prop("checked")) { | |
var startIndex = parseInt(checkboxIdRegex.exec(lastCheckboxClickedID)[1],10); | |
var endIndex = parseInt(checkboxIdRegex.exec($(this).prop("id"))[1],10); | |
if (endIndex < startIndex) { | |
var tmp = startIndex; | |
startIndex = endIndex; | |
endIndex = tmp; | |
} | |
var i = startIndex; | |
while (true) { | |
++i; | |
if (i > endIndex) { | |
break; | |
} | |
$("#" + checkboxIdPrefix + i.toString()).prop("checked",true); | |
} | |
} | |
lastCheckboxClickedID = $(this).attr("id"); | |
}); | |
return { | |
method: function() { | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you wanted... you could change it up a tiny smidge for it to be easier to use. Totally untested:
In theoryyyy... you could then do: