diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 9b83827c3f..77d02e4549 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -20,6 +20,7 @@ angular.module('ionic.ui', [ 'ionic.ui.list', 'ionic.ui.checkbox', 'ionic.ui.toggle', + 'ionic.ui.radio' ]); angular.module('ionic', [ @@ -752,7 +753,7 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges * Push a template onto the navigation stack. * @param {string} templateUrl the URL of the template to load. */ - this.pushFromTemplate = ionic.debounce(function(templateUrl) { + this.pushFromTemplate = ionic.throttle(function(templateUrl) { var childScope = $scope.$new(); childScope.isVisible = true; @@ -765,12 +766,16 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges $animate.enter(cloned, angular.element(content)); }); }); - }, 300, true); + }, 300, { + trailing: false + }); - // Pop function, debounced - this.popController = ionic.debounce(function() { + // Pop function, throttled + this.popController = ionic.throttle(function() { _this.pop(); - }, 300, true); + }, 300, { + trailing: false + }); ionic.controllers.NavController.call(this, { @@ -931,6 +936,12 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges $scope.visibilityChanged = function(direction) { lastDirection = direction; + if($scope.isVisible) { + $scope.$broadcast('navContent.shown'); + } else { + $scope.$broadcast('navContent.hidden'); + } + if(!childElement) { return; } @@ -993,6 +1004,58 @@ angular.module('ionic.ui.nav', ['ionic.service.templateLoad', 'ionic.service.ges })(); ; +(function(ionic) { +'use strict'; + +angular.module('ionic.ui.radio', []) + +// The radio button is a radio powered element with only +// one possible selection in a set of options. +.directive('radio', function() { + return { + restrict: 'E', + replace: true, + require: '?ngModel', + scope: { + value: '@' + }, + transclude: true, + template: '', + + link: function($scope, $element, $attr, ngModel) { + var radio; + + if(!ngModel) { return; } + + radio = $element.children().eq(0); + + if(!radio.length) { return; } + + radio.bind('click', function(e) { + $scope.$apply(function() { + ngModel.$setViewValue($scope.$eval($attr.ngValue)); + }); + }); + + ngModel.$render = function() { + var val = $scope.$eval($attr.ngValue); + if(val === ngModel.$viewValue) { + radio.attr('checked', 'checked'); + } else { + radio.removeAttr('checked'); + } + }; + } + }; +}); + +})(window.ionic); +; (function() { 'use strict'; @@ -1397,10 +1460,13 @@ angular.module('ionic.ui.tabs', ['ngAnimate']) }); ; +(function(ionic) { +'use strict'; + angular.module('ionic.ui.toggle', []) -// The content directive is a core scrollable content area -// that is part of many View hierarchies +// The Toggle directive is a toggle switch that can be tapped to change +// its value .directive('toggle', function() { return { restrict: 'E', @@ -1438,6 +1504,8 @@ angular.module('ionic.ui.toggle', []) } }; }); + +})(window.ionic); ; (function() { 'use strict'; diff --git a/js/ext/angular/src/directive/ionicRadio.js b/js/ext/angular/src/directive/ionicRadio.js new file mode 100644 index 0000000000..f4b93c20e2 --- /dev/null +++ b/js/ext/angular/src/directive/ionicRadio.js @@ -0,0 +1,51 @@ +(function(ionic) { +'use strict'; + +angular.module('ionic.ui.radio', []) + +// The radio button is a radio powered element with only +// one possible selection in a set of options. +.directive('radio', function() { + return { + restrict: 'E', + replace: true, + require: '?ngModel', + scope: { + value: '@' + }, + transclude: true, + template: '', + + link: function($scope, $element, $attr, ngModel) { + var radio; + + if(!ngModel) { return; } + + radio = $element.children().eq(0); + + if(!radio.length) { return; } + + radio.bind('click', function(e) { + $scope.$apply(function() { + ngModel.$setViewValue($scope.$eval($attr.ngValue)); + }); + }); + + ngModel.$render = function() { + var val = $scope.$eval($attr.ngValue); + if(val === ngModel.$viewValue) { + radio.attr('checked', 'checked'); + } else { + radio.removeAttr('checked'); + } + }; + } + }; +}); + +})(window.ionic); diff --git a/js/ext/angular/src/directive/ionicToggle.js b/js/ext/angular/src/directive/ionicToggle.js index 809bf08a02..c859ed6e5b 100644 --- a/js/ext/angular/src/directive/ionicToggle.js +++ b/js/ext/angular/src/directive/ionicToggle.js @@ -1,7 +1,10 @@ +(function(ionic) { +'use strict'; + angular.module('ionic.ui.toggle', []) -// The content directive is a core scrollable content area -// that is part of many View hierarchies +// The Toggle directive is a toggle switch that can be tapped to change +// its value .directive('toggle', function() { return { restrict: 'E', @@ -39,3 +42,5 @@ angular.module('ionic.ui.toggle', []) } }; }); + +})(window.ionic); diff --git a/js/ext/angular/src/ionicAngular.js b/js/ext/angular/src/ionicAngular.js index 52fd3812aa..98a56c8fd9 100644 --- a/js/ext/angular/src/ionicAngular.js +++ b/js/ext/angular/src/ionicAngular.js @@ -20,6 +20,7 @@ angular.module('ionic.ui', [ 'ionic.ui.list', 'ionic.ui.checkbox', 'ionic.ui.toggle', + 'ionic.ui.radio' ]); angular.module('ionic', [ diff --git a/js/ext/angular/test/radio.html b/js/ext/angular/test/radio.html new file mode 100644 index 0000000000..383aa75245 --- /dev/null +++ b/js/ext/angular/test/radio.html @@ -0,0 +1,51 @@ + + + + Radio + + + + + + + + + + + +
+

Beans

+
+ +
+
+ Magical + Black + Pinto + + +
+
+
+ + + + + + +