mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
Merge branch 'tap-refactor'
This commit is contained in:
9
js/angular/directive/navBackButton.js
vendored
9
js/angular/directive/navBackButton.js
vendored
@@ -62,9 +62,8 @@
|
||||
*/
|
||||
IonicModule
|
||||
.directive('ionNavBackButton', [
|
||||
'$ionicNgClick',
|
||||
'$animate',
|
||||
function($ionicNgClick, $animate) {
|
||||
function($animate) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
require: '^ionNavBar',
|
||||
@@ -73,7 +72,11 @@ function($ionicNgClick, $animate) {
|
||||
return function($scope, $element, $attr, navBarCtrl) {
|
||||
if (!$attr.ngClick) {
|
||||
$scope.$navBack = navBarCtrl.back;
|
||||
$ionicNgClick($scope, $element, '$navBack($event)');
|
||||
$element.on('click', function(event){
|
||||
$scope.$apply(function() {
|
||||
$scope.$navBack(event);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
//If the current viewstate does not allow a back button,
|
||||
|
||||
13
js/angular/directive/ngClick.js
vendored
13
js/angular/directive/ngClick.js
vendored
@@ -1,6 +1,3 @@
|
||||
// Similar to Angular's ngTouch, however it uses Ionic's tap detection
|
||||
// and click simulation. ngClick
|
||||
|
||||
IonicModule
|
||||
|
||||
.config(['$provide', function($provide) {
|
||||
@@ -15,10 +12,6 @@ IonicModule
|
||||
* @private
|
||||
*/
|
||||
.factory('$ionicNgClick', ['$parse', function($parse) {
|
||||
function onRelease(e) {
|
||||
// wire this up to Ionic's tap/click simulation
|
||||
ionic.tap.simulateClick(e.target, e);
|
||||
}
|
||||
return function(scope, element, clickExpr) {
|
||||
var clickHandler = $parse(clickExpr);
|
||||
|
||||
@@ -28,15 +21,9 @@ IonicModule
|
||||
});
|
||||
});
|
||||
|
||||
ionic.on("release", onRelease, element[0]);
|
||||
|
||||
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
|
||||
// something else nearby.
|
||||
element.onclick = function(event) { };
|
||||
|
||||
scope.$on('$destroy', function () {
|
||||
ionic.off("release", onRelease, element[0]);
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
|
||||
8
js/angular/directive/tabNav.js
vendored
8
js/angular/directive/tabNav.js
vendored
@@ -1,5 +1,5 @@
|
||||
IonicModule
|
||||
.directive('ionTabNav', ['$ionicNgClick', function($ionicNgClick) {
|
||||
.directive('ionTabNav', [function() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
replace: true,
|
||||
@@ -33,7 +33,11 @@ IonicModule
|
||||
tabsCtrl.select(tabCtrl.$scope, true);
|
||||
};
|
||||
if (!$attrs.ngClick) {
|
||||
$ionicNgClick($scope, $element, 'selectTab($event)');
|
||||
$element.on('click', function(event) {
|
||||
$scope.$apply(function() {
|
||||
$scope.selectTab(event);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
$scope.getIconOn = function() {
|
||||
|
||||
65
js/angular/directive/touch.js
vendored
65
js/angular/directive/touch.js
vendored
@@ -1,65 +0,0 @@
|
||||
|
||||
// Similar to Angular's ngTouch, however it uses Ionic's tap detection
|
||||
// and click simulation. ngClick
|
||||
|
||||
(function(angular, ionic) {'use strict';
|
||||
|
||||
angular.module('ionic.ui.touch', [])
|
||||
|
||||
.config(['$provide', function($provide) {
|
||||
$provide.decorator('ngClickDirective', ['$delegate', function($delegate) {
|
||||
// drop the default ngClick directive
|
||||
$delegate.shift();
|
||||
return $delegate;
|
||||
}]);
|
||||
}])
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
.factory('$ionicNgClick', ['$parse', function($parse) {
|
||||
function onRelease(e) {
|
||||
// wire this up to Ionic's tap/click simulation
|
||||
ionic.tap.simulateClick(e.target, e);
|
||||
}
|
||||
return function(scope, element, clickExpr) {
|
||||
var clickHandler = $parse(clickExpr);
|
||||
|
||||
element.on('click', function(event) {
|
||||
scope.$apply(function() {
|
||||
clickHandler(scope, {$event: (event)});
|
||||
});
|
||||
});
|
||||
|
||||
ionic.on("release", onRelease, element[0]);
|
||||
|
||||
// Hack for iOS Safari's benefit. It goes searching for onclick handlers and is liable to click
|
||||
// something else nearby.
|
||||
element.onclick = function(event) { };
|
||||
|
||||
scope.$on('$destroy', function () {
|
||||
ionic.off("release", onRelease, element[0]);
|
||||
});
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('ngClick', ['$ionicNgClick', function($ionicNgClick) {
|
||||
return function(scope, element, attr) {
|
||||
$ionicNgClick(scope, element, attr.ngClick);
|
||||
};
|
||||
}])
|
||||
|
||||
.directive('ionStopEvent', function () {
|
||||
function stopEvent(e) {
|
||||
e.stopPropagation();
|
||||
}
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function (scope, element, attr) {
|
||||
element.bind(attr.ionStopEvent, stopEvent);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
})(window.angular, window.ionic);
|
||||
Reference in New Issue
Block a user