aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng
diff options
context:
space:
mode:
authorMichał Gołębiowski2013-06-19 20:52:50 +0100
committerPete Bacon Darwin2013-06-19 20:53:24 +0100
commitf1b94b4b599ab701bc75b55bbbbb73c5ef329a93 (patch)
tree033c39426a25c8ac86dc7dc4efb1b4d05fe05272 /src/ng
parent0bfa29377d7a77b360ecd3209d56eeb4f68a5043 (diff)
downloadangular.js-f1b94b4b599ab701bc75b55bbbbb73c5ef329a93.tar.bz2
feat(jqLite): switch bind/unbind to more recent jQuery on/off
jQuery switched to a completely new event binding implementation as of 1.7.0, centering around on/off methods instead of previous bind/unbind. This patch makes jqLite match this implementation while still supporting previous bind/unbind methods.
Diffstat (limited to 'src/ng')
-rw-r--r--src/ng/browser.js4
-rw-r--r--src/ng/compile.js2
-rw-r--r--src/ng/directive/a.js2
-rw-r--r--src/ng/directive/form.js4
-rw-r--r--src/ng/directive/input.js16
-rw-r--r--src/ng/directive/ngEventDirs.js4
-rw-r--r--src/ng/directive/select.js8
-rw-r--r--src/ng/location.js2
8 files changed, 21 insertions, 21 deletions
diff --git a/src/ng/browser.js b/src/ng/browser.js
index 7a32993f..f1f80bdf 100644
--- a/src/ng/browser.js
+++ b/src/ng/browser.js
@@ -212,9 +212,9 @@ function Browser(window, document, $log, $sniffer) {
// changed by push/replaceState
// html5 history api - popstate event
- if ($sniffer.history) jqLite(window).bind('popstate', fireUrlChange);
+ if ($sniffer.history) jqLite(window).on('popstate', fireUrlChange);
// hashchange event
- if ($sniffer.hashchange) jqLite(window).bind('hashchange', fireUrlChange);
+ if ($sniffer.hashchange) jqLite(window).on('hashchange', fireUrlChange);
// polling
else self.addPollFn(fireUrlChange);
diff --git a/src/ng/compile.js b/src/ng/compile.js
index faef4772..851f2404 100644
--- a/src/ng/compile.js
+++ b/src/ng/compile.js
@@ -471,7 +471,7 @@ function $CompileProvider($provide) {
transcludeScope.$$transcluded = true;
return transcludeFn(transcludeScope, cloneFn).
- bind('$destroy', bind(transcludeScope, transcludeScope.$destroy));
+ on('$destroy', bind(transcludeScope, transcludeScope.$destroy));
};
})(childTranscludeFn || transcludeFn)
);
diff --git a/src/ng/directive/a.js b/src/ng/directive/a.js
index 7ee8f572..8213afb9 100644
--- a/src/ng/directive/a.js
+++ b/src/ng/directive/a.js
@@ -33,7 +33,7 @@ var htmlAnchorDirective = valueFn({
}
return function(scope, element) {
- element.bind('click', function(event){
+ element.on('click', function(event){
// if we have no href url, then don't navigate anywhere.
if (!element.attr('href')) {
event.preventDefault();
diff --git a/src/ng/directive/form.js b/src/ng/directive/form.js
index ca055cb1..5eec23f1 100644
--- a/src/ng/directive/form.js
+++ b/src/ng/directive/form.js
@@ -324,7 +324,7 @@ var formDirectiveFactory = function(isNgForm) {
// unregister the preventDefault listener so that we don't not leak memory but in a
// way that will achieve the prevention of the default action.
- formElement.bind('$destroy', function() {
+ formElement.on('$destroy', function() {
$timeout(function() {
removeEventListenerFn(formElement[0], 'submit', preventDefaultListener);
}, 0, false);
@@ -338,7 +338,7 @@ var formDirectiveFactory = function(isNgForm) {
scope[alias] = controller;
}
if (parentFormCtrl) {
- formElement.bind('$destroy', function() {
+ formElement.on('$destroy', function() {
parentFormCtrl.$removeControl(controller);
if (alias) {
scope[alias] = undefined;
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 31a3ba5d..dfa52e85 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -411,7 +411,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
// if the browser does support "input" event, we are fine - except on IE9 which doesn't fire the
// input event on backspace, delete or cut
if ($sniffer.hasEvent('input')) {
- element.bind('input', listener);
+ element.on('input', listener);
} else {
var timeout;
@@ -424,7 +424,7 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
}
};
- element.bind('keydown', function(event) {
+ element.on('keydown', function(event) {
var key = event.keyCode;
// ignore
@@ -435,11 +435,11 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
});
// if user paste into input using mouse, we need "change" event to catch it
- element.bind('change', listener);
+ element.on('change', listener);
// if user modifies input value using context menu in IE, we need "paste" and "cut" events to catch it
if ($sniffer.hasEvent('paste')) {
- element.bind('paste cut', deferListener);
+ element.on('paste cut', deferListener);
}
}
@@ -624,7 +624,7 @@ function radioInputType(scope, element, attr, ctrl) {
element.attr('name', nextUid());
}
- element.bind('click', function() {
+ element.on('click', function() {
if (element[0].checked) {
scope.$apply(function() {
ctrl.$setViewValue(attr.value);
@@ -647,7 +647,7 @@ function checkboxInputType(scope, element, attr, ctrl) {
if (!isString(trueValue)) trueValue = true;
if (!isString(falseValue)) falseValue = false;
- element.bind('click', function() {
+ element.on('click', function() {
scope.$apply(function() {
ctrl.$setViewValue(element[0].checked);
});
@@ -876,7 +876,7 @@ var VALID_CLASS = 'ng-valid',
};
// Listen for change events to enable binding
- element.bind('blur keyup change', function() {
+ element.on('blur keyup change', function() {
scope.$apply(read);
});
read(); // initialize
@@ -1138,7 +1138,7 @@ var ngModelDirective = function() {
formCtrl.$addControl(modelCtrl);
- element.bind('$destroy', function() {
+ element.on('$destroy', function() {
formCtrl.$removeControl(modelCtrl);
});
}
diff --git a/src/ng/directive/ngEventDirs.js b/src/ng/directive/ngEventDirs.js
index 43047ad9..9420f720 100644
--- a/src/ng/directive/ngEventDirs.js
+++ b/src/ng/directive/ngEventDirs.js
@@ -43,7 +43,7 @@ forEach(
ngEventDirectives[directiveName] = ['$parse', function($parse) {
return function(scope, element, attr) {
var fn = $parse(attr[directiveName]);
- element.bind(lowercase(name), function(event) {
+ element.on(lowercase(name), function(event) {
scope.$apply(function() {
fn(scope, {$event:event});
});
@@ -265,7 +265,7 @@ forEach(
</doc:example>
*/
var ngSubmitDirective = ngDirective(function(scope, element, attrs) {
- element.bind('submit', function() {
+ element.on('submit', function() {
scope.$apply(attrs.ngSubmit);
});
});
diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js
index 0d5221fb..a62f706c 100644
--- a/src/ng/directive/select.js
+++ b/src/ng/directive/select.js
@@ -257,7 +257,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
}
};
- selectElement.bind('change', function() {
+ selectElement.on('change', function() {
scope.$apply(function() {
if (unknownOption.parent()) unknownOption.remove();
ngModelCtrl.$setViewValue(selectElement.val());
@@ -283,7 +283,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
}
});
- selectElement.bind('change', function() {
+ selectElement.on('change', function() {
scope.$apply(function() {
var array = [];
forEach(selectElement.find('option'), function(option) {
@@ -334,7 +334,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
// clear contents, we'll add what's needed based on the model
selectElement.html('');
- selectElement.bind('change', function() {
+ selectElement.on('change', function() {
scope.$apply(function() {
var optionGroup,
collection = valuesFn(scope) || [],
@@ -598,7 +598,7 @@ var optionDirective = ['$interpolate', function($interpolate) {
selectCtrl.addOption(attr.value);
}
- element.bind('$destroy', function() {
+ element.on('$destroy', function() {
selectCtrl.removeOption(attr.value);
});
};
diff --git a/src/ng/location.js b/src/ng/location.js
index de629d42..ba3901b2 100644
--- a/src/ng/location.js
+++ b/src/ng/location.js
@@ -511,7 +511,7 @@ function $LocationProvider(){
$location = new LocationMode(appBase, '#' + hashPrefix);
$location.$$parse($location.$$rewrite(initialUrl));
- $rootElement.bind('click', function(event) {
+ $rootElement.on('click', function(event) {
// TODO(vojta): rewrite link when opening in new tab/window (in legacy browser)
// currently we open nice url link and redirect then