Skip to content
Browse files

Change bind/unbind to on/off and wrapping some selectors around quotes

  • Loading branch information...
1 parent 786d7fb commit 4f3f3f14e83b0ff276a795e9f45400930904adff @duclet duclet committed with default_git_name Feb 26, 2012
View
22 src/dateinput/dateinput.js
@@ -332,7 +332,7 @@
ev.type = "onShow";
fire.trigger(ev);
- $(document).bind("keydown.d", function(e) {
+ $(document).on("keydown.d", function(e) {
if (e.ctrlKey) { return true; }
var key = e.keyCode;
@@ -399,7 +399,7 @@
// click outside dateinput
- $(document).bind("click.d", function(e) {
+ $(document).on("click.d", function(e) {
var el = e.target;
if (!$(el).parents("#" + css.root).length && el != input[0] && (!trigger || el != trigger[0])) {
@@ -435,24 +435,24 @@
opened = true;
// month selector
- monthSelector.unbind("change").change(function() {
+ monthSelector.off("change").change(function() {
self.setValue(integer(yearSelector.val()), integer($(this).val()));
});
// year selector
- yearSelector.unbind("change").change(function() {
+ yearSelector.off("change").change(function() {
self.setValue(integer($(this).val()), integer(monthSelector.val()));
});
// prev / next month
- pm = root.find("#" + css.prev).unbind("click").click(function(e) {
+ pm = root.find("#" + css.prev).off("click").click(function(e) {
if (!pm.hasClass(css.disabled)) {
self.addMonth(-1);
}
return false;
});
- nm = root.find("#" + css.next).unbind("click").click(function(e) {
+ nm = root.find("#" + css.next).off("click").click(function(e) {
if (!nm.hasClass(css.disabled)) {
self.addMonth();
}
@@ -669,7 +669,7 @@
},
destroy: function() {
- input.add(document).unbind("click.d").unbind("keydown.d");
+ input.add(document).off("click.d keydown.d");
root.add(trigger).remove();
input.removeData("dateinput").removeClass(css.input);
if (original) { input.replaceWith(original); }
@@ -687,7 +687,7 @@
// cancelled ?
if (e.isDefaultPrevented()) { return; }
- $(document).unbind("click.d").unbind("keydown.d");
+ $(document).off("click.d keydown.d");
// do the hide
root.hide();
@@ -728,20 +728,20 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API methods
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
if (!conf.editable) {
// show dateinput & assign keyboard shortcuts
- input.bind("focus.d click.d", self.show).keydown(function(e) {
+ input.on("focus.d click.d", self.show).keydown(function(e) {
var key = e.keyCode;
View
10 src/overlay/overlay.js
@@ -163,7 +163,7 @@
// when window is clicked outside overlay, we close
if (conf.closeOnClick) {
- $(document).bind("click." + uid, function(e) {
+ $(document).on("click." + uid, function(e) {
if (!$(e.target).parents(overlay).length) {
self.close(e);
}
@@ -174,7 +174,7 @@
if (conf.closeOnEsc) {
// one callback is enough if multiple instances are loaded simultaneously
- $(document).bind("keydown." + uid, function(e) {
+ $(document).on("keydown." + uid, function(e) {
if (e.keyCode == 27) {
self.close(e);
}
@@ -203,7 +203,7 @@
});
// unbind the keyboard / clicking actions
- $(document).unbind("click." + uid).unbind("keydown." + uid);
+ $(document).off("click." + uid + " keydown." + uid);
if (maskConf) {
$.mask.close();
@@ -240,12 +240,12 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
View
25 src/rangeinput/rangeinput.js
@@ -46,7 +46,7 @@
FULL featured drag and drop. 0.7 kb minified, 0.3 gzipped. done.
Who told d'n'd is rocket science? Usage:
- $(".myelement").drag({y: false}).bind("drag", function(event, x, y) {
+ $(".myelement").drag({y: false}).on("drag", function(event, x, y) {
// do your custom thing
});
@@ -66,7 +66,7 @@
conf = $.extend({x: true, y: true, drag: true}, conf);
- doc = doc || $(document).bind("mousedown mouseup", function(e) {
+ doc = doc || $(document).on("mousedown mouseup", function(e) {
var el = $(e.target);
@@ -78,7 +78,7 @@
y0 = e.pageY - offset.top,
start = true;
- doc.bind("mousemove.drag", function(e) {
+ doc.on("mousemove.drag", function(e) {
var x = e.pageX -x0,
y = e.pageY -y0,
props = {};
@@ -104,7 +104,7 @@
draggable.trigger("dragEnd");
}
} finally {
- doc.unbind("mousemove.drag");
+ doc.off("mousemove.drag");
draggable = null;
}
}
@@ -167,11 +167,8 @@
precision = conf.precision;
if (precision === undefined) {
- try {
- precision = step.toString().split(".")[1].length;
- } catch (err) {
- precision = 0;
- }
+ precision = step.toString().split(".");
+ precision = precision.length === 2 ? precision[1].length : 0;
}
// Replace built-in range input (type attribute cannot be changed)
@@ -330,19 +327,19 @@
// from configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API methods
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
// dragging
- handle.drag({drag: false}).bind("dragStart", function() {
+ handle.drag({drag: false}).on("dragStart", function() {
/* do some pre- calculations for seek() function. improves performance */
init();
@@ -351,12 +348,12 @@
fireOnSlide = hasEvent($(self)) || hasEvent(input);
- }).bind("drag", function(e, y, x) {
+ }).on("drag", function(e, y, x) {
if (input.is(":disabled")) { return false; }
slide(e, vertical ? y : x);
- }).bind("dragEnd", function(e) {
+ }).on("dragEnd", function(e) {
if (!e.isDefaultPrevented()) {
e.type = "change";
fire.trigger(e, [value]);
View
7 src/scrollable/scrollable.autoscroll.js
@@ -59,14 +59,13 @@
if (timer) { return; }
stopped = false;
-
- root.bind('onSeek', scroll);
- scroll();
+ root.on('onSeek', scroll);
+ scroll();
};
api.pause = function() {
timer = clearTimeout(timer); // clear any queued items immediately
- root.unbind('onSeek', scroll);
+ root.off('onSeek', scroll);
};
// resume playing if not stopped
View
6 src/scrollable/scrollable.js
@@ -190,11 +190,11 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
@@ -314,7 +314,7 @@
if (conf.keyboard) {
- $(document).bind("keydown.scrollable", function(evt) {
+ $(document).on("keydown.scrollable", function(evt) {
// skip certain conditions
if (!conf.keyboard || evt.altKey || evt.ctrlKey || evt.metaKey || $(evt.target).is(":input")) {
View
2 src/scrollable/scrollable.navigator.js
@@ -62,7 +62,7 @@
if (hashed) {
history.pushState({i: 0}, '');
- $(window).bind("popstate", function(evt) {
+ $(window).on("popstate", function(evt) {
var s = evt.originalEvent.state;
if (s) { api.seekTo(s.i); }
});
View
16 src/tabs/tabs.js
@@ -163,7 +163,7 @@
firstRender = !root.data('tabs');
if (typeof i == 'string' && i.replace("#", "")) {
- tab = tabs.filter("[href*=" + i.replace("#", "") + "]");
+ tab = tabs.filter("[href*=\"" + i.replace("#", "") + "\"]");
i = Math.max(tabs.index(tab), 0);
}
@@ -239,8 +239,8 @@
},
destroy: function() {
- tabs.unbind(conf.event).removeClass(conf.current);
- panes.find("a[href^=#]").unbind("click.T");
+ tabs.off(conf.event).removeClass(conf.current);
+ panes.find("a[href^=\"#\"]").off("click.T");
return self;
}
@@ -251,12 +251,12 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
@@ -269,19 +269,19 @@
// setup click actions for each tab
tabs.each(function(i) {
- $(this).bind(conf.event, function(e) {
+ $(this).on(conf.event, function(e) {
self.click(i, e);
return e.preventDefault();
});
});
// cross tab anchor link
- panes.find("a[href^=#]").bind("click.T", function(e) {
+ panes.find("a[href^=\"#\"]").on("click.T", function(e) {
self.click($(this).attr("href"), e);
});
// open initial tab
- if (location.hash && conf.tabs == "a" && root.find("[href=" +location.hash+ "]").length) {
+ if (location.hash && conf.tabs == "a" && root.find("[href=\"" +location.hash+ "\"]").length) {
self.click(location.hash);
} else {
View
8 src/tabs/tabs.slideshow.js
@@ -86,7 +86,7 @@
// onPlay
fire.trigger("onPlay");
- fire.bind('onClick', next);
+ fire.on('onClick', next);
next();
return self;
@@ -106,7 +106,7 @@
// onPause
fire.trigger("onPause");
- fire.unbind('onClick', next);
+ fire.off('onClick', next);
return self;
},
@@ -129,12 +129,12 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API methods
self[name] = function(fn) {
- return $(self).bind(name, fn);
+ return $(self).on(name, fn);
};
});
View
12 src/toolbox/toolbox.expose.js
@@ -116,7 +116,7 @@
// esc button
if (conf.closeOnEsc) {
- $(document).bind("keydown.mask", function(e) {
+ $(document).on("keydown.mask", function(e) {
if (e.keyCode == 27) {
$.mask.close(e);
}
@@ -125,13 +125,13 @@
// mask click closes
if (conf.closeOnClick) {
- mask.bind("click.mask", function(e) {
+ mask.on("click.mask", function(e) {
$.mask.close(e);
});
}
// resize mask when window is resized
- $(window).bind("resize.mask", function() {
+ $(window).on("resize.mask", function() {
$.mask.fit();
});
@@ -178,9 +178,9 @@
});
// unbind various event listeners
- $(document).unbind("keydown.mask");
- mask.unbind("click.mask");
- $(window).unbind("resize.mask");
+ $(document).off("keydown.mask");
+ mask.off("click.mask");
+ $(window).off("resize.mask");
}
return this;
View
4 src/toolbox/toolbox.history.js
@@ -80,7 +80,7 @@
}
// global histroy change listener
- $(window).bind("hash", function(e, h) {
+ $(window).on("hash", function(e, h) {
if (h) {
links.filter(function() {
var href = $(this).attr("href");
@@ -101,7 +101,7 @@
$.tools.history.init(this);
// return jQuery
- return this.bind("history", fn);
+ return this.on("history", fn);
};
})(jQuery);
View
2 src/toolbox/toolbox.mousewheel.js
@@ -16,7 +16,7 @@
(function($) {
$.fn.mousewheel = function( fn ){
- return this[ fn ? "bind" : "trigger" ]( "wheel", fn );
+ return this[ fn ? "on" : "trigger" ]( "wheel", fn );
};
// special event config
View
12 src/tooltip/tooltip.js
@@ -152,7 +152,7 @@
// trigger --> show
- trigger.bind(evt[0], function(e) {
+ trigger.on(evt[0], function(e) {
clearTimeout(timer);
if (conf.predelay) {
@@ -163,7 +163,7 @@
}
// trigger --> hide
- }).bind(evt[1], function(e) {
+ }).on(evt[1], function(e) {
clearTimeout(pretimer);
if (conf.delay) {
timer = setTimeout(function() { self.hide(e); }, conf.delay);
@@ -251,13 +251,13 @@
if (!tip.data("__set")) {
- tip.unbind(event[0]).bind(event[0], function() {
+ tip.off(event[0]).on(event[0], function() {
clearTimeout(timer);
clearTimeout(pretimer);
});
if (event[1] && !trigger.is("input:not(:checkbox, :radio), textarea")) {
- tip.unbind(event[1]).bind(event[1], function(e) {
+ tip.off(event[1]).on(event[1], function(e) {
// being moved to the trigger element
if (e.relatedTarget != trigger[0]) {
@@ -316,12 +316,12 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
View
30 src/validator/validator.js
@@ -136,7 +136,7 @@
function fn() {
return this.getAttribute("type") == type;
}
- fn.key = "[type=" + type + "]";
+ fn.key = "[type=\"" + type + "\"]";
return fn;
}
@@ -213,7 +213,7 @@
Usage: $("input:eq(2)").oninvalid(function() { ... });
*/
$.fn.oninvalid = function( fn ){
- return this[fn ? "bind" : "trigger"]("OI", fn);
+ return this[fn ? "on" : "trigger"]("OI", fn);
};
@@ -381,13 +381,13 @@
msg.remove();
$(this).data("msg.el", null);
}
- }).unbind(conf.errorInputEvent + '.v' || '');
+ }).off(conf.errorInputEvent + '.v' || '');
return self;
},
destroy: function() {
- form.unbind(conf.formEvent + ".V").unbind("reset.V");
- inputs.unbind(conf.inputEvent + ".V").unbind("change.V");
+ form.off(conf.formEvent + ".V reset.V");
+ inputs.off(conf.inputEvent + ".V change.V");
return self.reset();
},
@@ -431,7 +431,7 @@
event = dateInput && el.is(":date") ? "onHide.v" : conf.errorInputEvent + ".v";
// cleanup previous validation event
- el.unbind(event);
+ el.off(event);
// loop all validator functions
@@ -474,7 +474,7 @@
// begin validating upon error event type (such as keyup)
if (conf.errorInputEvent) {
- el.bind(event, function(e) {
+ el.on(event, function(e) {
self.checkValidity(el, e);
});
}
@@ -504,7 +504,7 @@
e.type = "onSuccess";
fire.trigger(e, [els]);
- els.unbind(conf.errorInputEvent + ".v");
+ els.off(conf.errorInputEvent + ".v");
}
return true;
@@ -518,20 +518,20 @@
// configuration
if ($.isFunction(conf[name])) {
- $(self).bind(name, conf[name]);
+ $(self).on(name, conf[name]);
}
// API methods
self[name] = function(fn) {
- if (fn) { $(self).bind(name, fn); }
+ if (fn) { $(self).on(name, fn); }
return self;
};
});
// form validation
if (conf.formEvent) {
- form.bind(conf.formEvent + ".V", function(e) {
+ form.on(conf.formEvent + ".V", function(e) {
if (!self.checkValidity(null, e)) {
return e.preventDefault();
}
@@ -542,7 +542,7 @@
}
// form reset
- form.bind("reset.V", function() {
+ form.on("reset.V", function() {
self.reset();
});
@@ -562,21 +562,21 @@
// input validation
if (conf.inputEvent) {
- inputs.bind(conf.inputEvent + ".V", function(e) {
+ inputs.on(conf.inputEvent + ".V", function(e) {
self.checkValidity($(this), e);
});
}
// checkboxes and selects are checked separately
- inputs.filter(":checkbox, select").filter("[required]").bind("change.V", function(e) {
+ inputs.filter(":checkbox, select").filter("[required]").on("change.V", function(e) {
var el = $(this);
if (this.checked || (el.is("select") && $(this).val())) {
effects[conf.effect][1].call(self, el, e);
}
});
// get radio groups by name
- inputs.filter(":radio[required]").bind("change.V", function(e) {
+ inputs.filter(":radio[required]").on("change.V", function(e) {
var els = $("[name='" + $(e.srcElement).attr("name") + "']");
if ((els != null) && (els.length != 0)) {
self.checkValidity(els, e);

0 comments on commit 4f3f3f1

Please sign in to comment.
Something went wrong with that request. Please try again.