Skip to content

Instantly share code, notes, and snippets.

@BlaM
Created October 4, 2017 13:50
Show Gist options
  • Save BlaM/4b2b584c1de51699896f2d098bab8f62 to your computer and use it in GitHub Desktop.
Save BlaM/4b2b584c1de51699896f2d098bab8f62 to your computer and use it in GitHub Desktop.
var autoset = null;
var isMoved = false;
$(document).on('mouseup', function() {
autoset = null;
isMoved = false;
});
$('#campaign-list').on('mousedown', 'input[type=checkbox]', function(e) {
autoset = !$(this).prop('checked');
$(this).prop('checked', autoset);
});
$('#campaign-list').on('mouseup', 'input[type=checkbox]', function(e) {
if (!isMoved) {
$(this).prop('checked', !autoset);
}
});
$('#campaign-list').on('mouseover', 'div.checkbox', function() {
if (autoset === null) {
return;
}
isMoved = true;
$(this).find('input[type=checkbox]').prop('checked', autoset);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment