Skip to content
Browse files

Remove all references to unbind() methods. Use off() instead

  • Loading branch information...
1 parent cb874bb commit 7da705a8563b39f152bad3c58d85260cafe5ff0c @juandopazo committed
View
4 src/anim/js/Tween.js
@@ -196,7 +196,7 @@ var Tween = Base.create('tween', Base, [], {
this.set('playing', false);
var timeframe = jet.TimeFrame;
timeframe.removeTween(this);
- timeframe.unbind(ENTER_FRAME, this._enterFrame);
+ timeframe.off(ENTER_FRAME, this._enterFrame);
this.set('previousTime', 0);
return this.set('startTime', 0);
},
@@ -209,7 +209,7 @@ var Tween = Base.create('tween', Base, [], {
this.set('playing', false)
var timeframe = jet.TimeFrame;
timeframe.removeTween(this);
- timeframe.unbind(ENTER_FRAME, this._enterFrame);
+ timeframe.off(ENTER_FRAME, this._enterFrame);
return this.set('previousTime', (new Date()).getTime() - this.get('startTime'));
},
/**
View
2 src/base/js/Base.js
@@ -73,7 +73,7 @@ $.extend(Base, Attribute, {
}
});
- this.unbind();
+ this.off();
}
}
View
6 src/base/js/Mouse.js
@@ -149,7 +149,9 @@ $.Mouse = $.Base.create('mouse', $.Utility, [], {
context.on(MOUSEMOVE, this._onMouseMove, this);
context.on(MOUSEUP, this._onMouseUp, this);
- this.on('destroy', shim.unbindAll, shim);
+ this.on('destroy', function () {
+ this.off();
+ }, shim);
},
/**
@@ -197,7 +199,7 @@ $.Mouse = $.Base.create('mouse', $.Utility, [], {
}
});
- $Array.each(['on', 'once', 'fire', 'unbind'], function (eventMethod) {
+ $Array.each(['on', 'once', 'fire', 'off'], function (eventMethod) {
$[eventMethod] = $.bind($_event[eventMethod], $_event);
});
View
33 src/jet/js/ArrayHelper.js
@@ -1,5 +1,17 @@
+var indexOf = AP.indexOf ? function (haystack, needle) {
+ return haystack.indexOf(needle);
+} : function (haystack, needle) {
+ var i,
+ length = haystack.length;
+ for (i = 0; i < length; i = i + 1) {
+ if (haystack[i] == needle) {
+ return i;
+ }
+ }
+ return -1;
+}
-function mix(a, b, overwrite, clonefirst) {
+function mix(a, b, overwrite, clonefirst, blacklist) {
a = a || {};
b = b || {};
if (clonefirst) {
@@ -7,13 +19,13 @@ function mix(a, b, overwrite, clonefirst) {
}
if (b.hasOwnProperty) {
for (var x in b) {
- if (b.hasOwnProperty(x) && (!a.hasOwnProperty(x) || overwrite)) {
+ if (b.hasOwnProperty(x) && (!a.hasOwnProperty(x) || overwrite) && (!blacklist || indexOf(blacklist, x) === -1)) {
a[x] = b[x];
}
}
}
return a;
-};
+}
/**
* Utilities for working with Arrays
@@ -81,20 +93,7 @@ mix(_Array, {
* @param {Object} needle
* @return {Number}
*/
- indexOf: AP.indexOf ? function (haystack, needle) {
-
- return haystack.indexOf(needle);
-
- } : function (haystack, needle) {
- var i,
- length = haystack.length;
- for (i = 0; i < length; i = i + 1) {
- if (haystack[i] == needle) {
- return i;
- }
- }
- return -1;
- },
+ indexOf: indexOf,
/**
* Calls a given function on all items of an array and returns a new array with the return value of each call
* @param {Array} array Array to map
View
4 src/jet/js/Core.js
@@ -207,11 +207,11 @@ function buildJet(config) {
// add prototype overrides
if (px) {
- $.mix(rp, px, true);
+ $.mix(rp, px, true, false, ['constructor']);
}
// add attributes
if (ax) {
- $.mix(r, ax, true);
+ $.mix(r, ax, true, false, ['prototype']);
}
return r;
View
4 src/progressbar/js/ProgressBar.js
@@ -149,8 +149,8 @@ $.ProgressBar = $.Base.create('progressbar', $.Widget, [], {
this._text.html(Math.round(newSize * 100) + '%');
if (this.get('animate')) {
if (this._tween) {
- this._tween.unbind('tween', this._onTween);
- this._tween.unbind('end', this._onTweenEnd);
+ this._tween.off('tween', this._onTween);
+ this._tween.off('end', this._onTweenEnd);
this._tween.destroy();
}
var tween = this._tween = new $.Tween({
View
2 src/tabview/js/Tab.js
@@ -91,7 +91,7 @@ $.Tab = Base.create('tab', Widget, [$.WidgetChild], {
PANEL_TEMPLATE: DIV,
_uiTriggerEventChange: function (e) {
- this.unbind(e.prevVal, this._selectHandler).on(e.newVal, this._selectHandler);
+ this.off(e.prevVal, this._selectHandler).on(e.newVal, this._selectHandler);
},
_uiTabLabelContentChange: function (e) {
View
12 src/vector/js/Vector.js
@@ -306,7 +306,7 @@ var Vector = $.Vector = Base.create('vector', $.Attribute, [], {
if (node.parentNode) {
node.parentNode.removeChild(node);
}
- $(node).unbindAll();
+ $(node).off();
return this;
},
/**
@@ -453,19 +453,13 @@ var Vector = $.Vector = Base.create('vector', $.Attribute, [], {
* @chainable
*/
/**
- * @method unbind
+ * @method off
* @description Remove an event listeners from the vector node
* @param {String} eventType
* @param {Function} callback
* @chainable
*/
-/**
- * @method unbindAll
- * @description Removes all event listeners of a certain type from the vector node
- * @param {String} eventType
- * @chainable
- */
-A.each(['on', 'unbind', 'unbindAll'], function (method) {
+A.each(['on', 'off'], function (method) {
Vector.prototype[method] = function (type, fn) {
$(this.get('node'))[method](type, fn);
return this;
View
2 src/widget-sandbox/js/Frame.js
@@ -312,7 +312,7 @@ var Frame = $.Frame = $.Base.create('frame', $.Base, [], {
destructor: function() {
var inst = this.getInstance();
- inst(inst.config.doc).unbind();
+ inst(inst.config.doc).off();
inst = null;
this._iframe.remove(true);
},
View
4 src/widget-stack/js/WidgetStack.js
@@ -97,7 +97,7 @@ $.WidgetStack = $.mix(WidgetStack, {
$.on(RESIZE, this.syncShim, this);
} else {
shim.remove();
- $.unbind(RESIZE, this.syncShim);
+ $.off(RESIZE, this.syncShim);
}
},
@@ -114,7 +114,7 @@ $.WidgetStack = $.mix(WidgetStack, {
},
destroy: function () {
- //$.unbind(RESIZE, this.syncShim);
+ //$.off(RESIZE, this.syncShim);
}
},

0 comments on commit 7da705a

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