mirror of
https://github.com/zhigang1992/angular.js.git
synced 2026-05-16 10:29:37 +08:00
refactor(jqLite): change leftover element.bind/unbind to element.on/off
This commit is contained in:
@@ -215,7 +215,7 @@ directive.ngEmbedApp = ['$templateCache', '$browser', '$rootScope', '$location',
|
||||
}
|
||||
});
|
||||
|
||||
element.bind('$destroy', function() {
|
||||
element.on('$destroy', function() {
|
||||
deregisterEmbedRootScope();
|
||||
embedRootScope.$destroy();
|
||||
});
|
||||
|
||||
@@ -274,13 +274,13 @@ var popoverElement = function() {
|
||||
this.contentElement = angular.element(inner.childNodes[1]);
|
||||
|
||||
//stop the click on the tooltip
|
||||
this.element.bind('click', function(event) {
|
||||
this.element.on('click', function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
});
|
||||
|
||||
var self = this;
|
||||
angular.element(document.body).bind('click',function(event) {
|
||||
angular.element(document.body).on('click',function(event) {
|
||||
if(self.visible()) self.hide();
|
||||
});
|
||||
},
|
||||
@@ -359,7 +359,7 @@ directive.popover = ['popoverElement', function(popover) {
|
||||
restrict: 'A',
|
||||
priority : 500,
|
||||
link: function(scope, element, attrs) {
|
||||
element.bind('click',function(event) {
|
||||
element.on('click',function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if(popover.isSituatedAt(element) && popover.visible()) {
|
||||
@@ -396,7 +396,7 @@ directive.foldout = ['$http', '$animate','$window', function($http, $animate, $w
|
||||
if(/\/build\//.test($window.location.href)) {
|
||||
url = '/build/docs' + url;
|
||||
}
|
||||
element.bind('click',function() {
|
||||
element.on('click',function() {
|
||||
scope.$apply(function() {
|
||||
if(!container) {
|
||||
if(loading) return;
|
||||
|
||||
@@ -35,8 +35,8 @@ angular.module('ui.bootstrap.dropdown', [])
|
||||
|
||||
this.open = function( dropdownScope ) {
|
||||
if ( !openScope ) {
|
||||
$document.bind('click', closeDropdown);
|
||||
$document.bind('keydown', escapeKeyBind);
|
||||
$document.on('click', closeDropdown);
|
||||
$document.on('keydown', escapeKeyBind);
|
||||
}
|
||||
|
||||
if ( openScope && openScope !== dropdownScope ) {
|
||||
@@ -49,8 +49,8 @@ angular.module('ui.bootstrap.dropdown', [])
|
||||
this.close = function( dropdownScope ) {
|
||||
if ( openScope === dropdownScope ) {
|
||||
openScope = null;
|
||||
$document.unbind('click', closeDropdown);
|
||||
$document.unbind('keydown', escapeKeyBind);
|
||||
$document.off('click', closeDropdown);
|
||||
$document.off('keydown', escapeKeyBind);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -124,7 +124,7 @@ angular.module('ui.bootstrap.dropdown', [])
|
||||
return;
|
||||
}
|
||||
|
||||
element.bind('click', function(event) {
|
||||
element.on('click', function(event) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ angular.module('search', [])
|
||||
return function(scope, element, attrs) {
|
||||
var ESCAPE_KEY_KEYCODE = 27,
|
||||
FORWARD_SLASH_KEYCODE = 191;
|
||||
angular.element($document[0].body).bind('keydown', function(event) {
|
||||
angular.element($document[0].body).on('keydown', function(event) {
|
||||
var input = element[0];
|
||||
if(event.keyCode == FORWARD_SLASH_KEYCODE && document.activeElement != input) {
|
||||
event.stopPropagation();
|
||||
@@ -140,7 +140,7 @@ angular.module('search', [])
|
||||
}
|
||||
});
|
||||
|
||||
element.bind('keydown', function(event) {
|
||||
element.on('keydown', function(event) {
|
||||
if(event.keyCode == ESCAPE_KEY_KEYCODE) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
|
||||
@@ -271,7 +271,7 @@ making calls to it when needed.
|
||||
```js
|
||||
myModule.directive('my-directive', ['$animate', function($animate) {
|
||||
return function(element, scope, attrs) {
|
||||
element.bind('click', function() {
|
||||
element.on('click', function() {
|
||||
if(element.hasClass('clicked')) {
|
||||
$animate.removeClass(element, 'clicked');
|
||||
} else {
|
||||
|
||||
@@ -105,8 +105,8 @@ Here is a directive which makes any element draggable. Notice the `draggable` at
|
||||
}
|
||||
|
||||
function mouseup() {
|
||||
$document.unbind('mousemove', mousemove);
|
||||
$document.unbind('mouseup', mouseup);
|
||||
$document.off('mousemove', mousemove);
|
||||
$document.off('mouseup', mouseup);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
@@ -798,8 +798,8 @@ element?
|
||||
}
|
||||
|
||||
function mouseup() {
|
||||
$document.unbind('mousemove', mousemove);
|
||||
$document.unbind('mouseup', mouseup);
|
||||
$document.off('mousemove', mousemove);
|
||||
$document.off('mouseup', mouseup);
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
@@ -107,7 +107,7 @@ function $IntervalProvider() {
|
||||
*
|
||||
* // listen on DOM destroy (removal) event, and cancel the next UI update
|
||||
* // to prevent updating time ofter the DOM element was removed.
|
||||
* element.bind('$destroy', function() {
|
||||
* element.on('$destroy', function() {
|
||||
* $interval.cancel(stopTime);
|
||||
* });
|
||||
* }
|
||||
|
||||
@@ -71,8 +71,8 @@ if (window.jQuery) {
|
||||
spy1 = jasmine.createSpy('span1.$destroy');
|
||||
spy2 = jasmine.createSpy('span2.$destroy');
|
||||
doc = $('<div><span class=first>abc</span><span class=second>xyz</span></div>');
|
||||
doc.find('span.first').bind('$destroy', spy1);
|
||||
doc.find('span.second').bind('$destroy', spy2);
|
||||
doc.find('span.first').on('$destroy', spy1);
|
||||
doc.find('span.second').on('$destroy', spy2);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
|
||||
Reference in New Issue
Block a user