From 12d461a65ef6342c53945b07e1951eaaf03f5b9d Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Wed, 13 Nov 2013 10:18:34 -0600 Subject: [PATCH] Added action sheet thing back --- dist/js/ionic-angular.js | 42 ++++++++++++++----- .../angular/src/directive/ionicActionSheet.js | 42 ++++++++++++++----- 2 files changed, 62 insertions(+), 22 deletions(-) diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 4952dbf113..bc3b81c618 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -416,26 +416,46 @@ angular.module('ionic.service.templateLoad', []) angular.module('ionic.ui.actionSheet', []) -.directive('actionSheet', function() { +.directive('actionSheet', function($document) { return { restrict: 'E', scope: true, replace: true, link: function($scope, $element){ + var keyUp = function(e) { + if(e.which == 27) { + $scope.cancel(); + $scope.$apply(); + } + }; + + var backdropClick = function(e) { + if(e.target == $element[0]) { + $scope.cancel(); + $scope.$apply(); + } + }; $scope.$on('$destroy', function() { $element.remove(); + $document.unbind('keyup', keyUp); + $element.unbind('click', backdropClick); }); + + $document.bind('keyup', keyUp); + $element.bind('click', backdropClick); }, - template: '
' + - '
' + - '
{{titleText}}
' + - '' + - '
' + - '
' + - '' + - '
' + - '
' + - '' + + template: '
' + + '
' + + '
' + + '
{{titleText}}
' + + '' + + '
' + + '
' + + '' + + '
' + + '
' + + '' + + '
' + '
' + '
' }; diff --git a/js/ext/angular/src/directive/ionicActionSheet.js b/js/ext/angular/src/directive/ionicActionSheet.js index 756a05dfcb..11fd4ab077 100644 --- a/js/ext/angular/src/directive/ionicActionSheet.js +++ b/js/ext/angular/src/directive/ionicActionSheet.js @@ -3,26 +3,46 @@ angular.module('ionic.ui.actionSheet', []) -.directive('actionSheet', function() { +.directive('actionSheet', function($document) { return { restrict: 'E', scope: true, replace: true, link: function($scope, $element){ + var keyUp = function(e) { + if(e.which == 27) { + $scope.cancel(); + $scope.$apply(); + } + }; + + var backdropClick = function(e) { + if(e.target == $element[0]) { + $scope.cancel(); + $scope.$apply(); + } + }; $scope.$on('$destroy', function() { $element.remove(); + $document.unbind('keyup', keyUp); + $element.unbind('click', backdropClick); }); + + $document.bind('keyup', keyUp); + $element.bind('click', backdropClick); }, - template: '
' + - '
' + - '
{{titleText}}
' + - '' + - '
' + - '
' + - '' + - '
' + - '
' + - '' + + template: '
' + + '
' + + '
' + + '
{{titleText}}
' + + '' + + '
' + + '
' + + '' + + '
' + + '
' + + '' + + '
' + '
' + '
' };