Merge branch 'tap-refactor'

This commit is contained in:
Adam Bradley
2014-04-17 15:23:58 -05:00
17 changed files with 2239 additions and 960 deletions

View File

@@ -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,

View File

@@ -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]);
});
};
}])

View File

@@ -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() {

View File

@@ -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);