Skip to content

Commit

Permalink
Fixed: 'ready' event is deprecated
Browse files Browse the repository at this point in the history
Fixes #23
  • Loading branch information
jengjeng authored and rmariuzzo committed Oct 12, 2017
1 parent 79654c3 commit 91bec66
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 36 deletions.
60 changes: 26 additions & 34 deletions dist/jquery.checkboxes-1.2.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,16 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}, {
key: 'max',
value: function max(_max) {
var _this = this;

if (_max > 0) {
(function () {
// Enable max.
var instance = _this;
_this.$context.on('click.checkboxes.max', ':checkbox', function () {
if (instance.$context.find(':checked').length === _max) {
instance.$context.find(':checkbox:not(:checked)').prop('disabled', true);
} else {
instance.$context.find(':checkbox:not(:checked)').prop('disabled', false);
}
});
})();
// Enable max.
var instance = this;
this.$context.on('click.checkboxes.max', ':checkbox', function () {
if (instance.$context.find(':checked').length === _max) {
instance.$context.find(':checkbox:not(:checked)').prop('disabled', true);
} else {
instance.$context.find(':checkbox:not(:checked)').prop('disabled', false);
}
});
} else {
// Disable max.
this.$context.off('click.checkboxes.max');
Expand All @@ -94,27 +90,23 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
}, {
key: 'range',
value: function range(enable) {
var _this2 = this;

if (enable) {
(function () {
var instance = _this2;

_this2.$context.on('click.checkboxes.range', ':checkbox', function (event) {
var $checkbox = $(event.target);

if (event.shiftKey && instance.$last) {
var $checkboxes = instance.$context.find(':checkbox:visible');
var from = $checkboxes.index(instance.$last);
var to = $checkboxes.index($checkbox);
var start = Math.min(from, to);
var end = Math.max(from, to) + 1;

$checkboxes.slice(start, end).filter(':not(:disabled)').prop('checked', $checkbox.prop('checked')).trigger('change');
}
instance.$last = $checkbox;
});
})();
var instance = this;

this.$context.on('click.checkboxes.range', ':checkbox', function (event) {
var $checkbox = $(event.target);

if (event.shiftKey && instance.$last) {
var $checkboxes = instance.$context.find(':checkbox:visible');
var from = $checkboxes.index(instance.$last);
var to = $checkboxes.index($checkbox);
var start = Math.min(from, to);
var end = Math.max(from, to) + 1;

$checkboxes.slice(start, end).filter(':not(:disabled)').prop('checked', $checkbox.prop('checked')).trigger('change');
}
instance.$last = $checkbox;
});
} else {
this.$context.off('click.checkboxes.range');
}
Expand Down Expand Up @@ -208,5 +200,5 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons

// Register data-api listeners.
$(document).on('click.checkboxes.data-api', '[data-toggle^=checkboxes]', dataApiClickHandler);
$(document).on('ready.checkboxes.data-api', dataApiDomReadyHandler);
$(dataApiDomReadyHandler);
})(window.jQuery);
2 changes: 1 addition & 1 deletion dist/jquery.checkboxes-1.2.0.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/jquery.checkboxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,6 @@

// Register data-api listeners.
$(document).on('click.checkboxes.data-api', '[data-toggle^=checkboxes]', dataApiClickHandler);
$(document).on('ready.checkboxes.data-api', dataApiDomReadyHandler);
$(dataApiDomReadyHandler);

})(window.jQuery);

0 comments on commit 91bec66

Please sign in to comment.