Skip to content

Commit

Permalink
feat(popup): Added popup support
Browse files Browse the repository at this point in the history
  • Loading branch information
mlynch committed Mar 13, 2014
1 parent 53a426f commit a30b0b7
Show file tree
Hide file tree
Showing 12 changed files with 1,040 additions and 89 deletions.
1 change: 0 additions & 1 deletion config/build.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ module.exports = {
'js/views/loadingView.js',
'js/views/modalView.js',
'js/views/navBarView.js',
'js/views/popupView.js',
'js/views/sideMenuView.js',
'js/views/sliderView.js',
'js/views/tabBarView.js',
Expand Down
63 changes: 63 additions & 0 deletions js/ext/angular/src/directive/ionicPopup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
(function() {
'use strict';

angular.module('ionic.ui.popup', [])

/**
* @private
*/
.directive('ionPopupBackdrop', function() {
return {
restrict: 'E',
replace: true,
template: '<div class="popup-backdrop"></div>'
}
})

/**
* @private
*/
.directive('ionPopup', ['$ionicBind', function($ionicBind) {
return {
restrict: 'E',
replace: true,
transclude: true,
scope: true,
link: function($scope, $element, $attr) {
$ionicBind($scope, $attr, {
title: '@',
buttons: '=',
$onButtonTap: '&onButtonTap',
$onClose: '&onClose'
});

$scope._buttonTapped = function(button, event) {
var result = button.onTap && button.onTap(event);

// A way to return false
if(event.defaultPrevented) {
return $scope.$onClose({button: button, result: false, event: event });
}

// Truthy test to see if we should close the window
if(result) {
return $scope.$onClose({button: button, result: result, event: event });
}
$scope.$onButtonTap({button: button, event: event});
}
},
template: '<div class="popup">' +
'<div class="popup-head">' +
'<h3 class="popup-title" ng-bind-html="title"></h3>' +
'<h5 class="popup-sub-title" ng-bind-html="subTitle" ng-if="subTitle"></h5>' +
'</div>' +
'<div class="popup-body" ng-transclude>' +
'</div>' +
'<div class="popup-buttons row">' +
'<button ng-repeat="button in buttons" ng-click="_buttonTapped(button, $event)" class="button col" ng-class="button.type || \'button-default\'" ng-bind-html="button.text"></button>' +
'</div>' +
'</div>'
};
}]);

})();
3 changes: 2 additions & 1 deletion js/ext/angular/src/ionicAngular.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ angular.module('ionic.ui', [
'ionic.ui.checkbox',
'ionic.ui.toggle',
'ionic.ui.radio',
'ionic.ui.touch'
'ionic.ui.touch',
'ionic.ui.popup'
]);


Expand Down
Loading

0 comments on commit a30b0b7

Please sign in to comment.