diff --git a/dist/css/ionic.css b/dist/css/ionic.css index 4019a22dc2..3243f51b84 100644 --- a/dist/css/ionic.css +++ b/dist/css/ionic.css @@ -5079,6 +5079,20 @@ a.button { -ms-flex: 1; flex: 1; width: 100%; } + .button-bar.button-bar-inline { + display: block; + width: auto; + *zoom: 1; } + .button-bar.button-bar-inline:before, .button-bar.button-bar-inline:after { + display: table; + content: ""; + line-height: 0; } + .button-bar.button-bar-inline:after { + clear: both; } + .button-bar.button-bar-inline > .button { + width: auto; + display: inline-block; + float: left; } .button-bar > .button { -webkit-box-flex: 1; diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 12193a16e8..944cc95f75 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -1475,6 +1475,73 @@ angular.module('ionic.ui.radio', []) } } }; +}) + +// The radio button is a radio powered element with only +// one possible selection in a set of options. +.directive('radioButtons', function() { + return { + restrict: 'E', + replace: true, + require: '?ngModel', + scope: { + value: '@' + }, + transclude: true, + template: '
', + + link: function($scope, $element, $attr, ngModel) { + var radio; + + + if(ngModel) { + //$element.bind('tap', tapHandler); + + ngModel.$render = function() { + var val = $scope.$eval($attr.ngValue); + if(val === ngModel.$viewValue) { + } else { + } + }; + $scope.$parent.$on('button.toggled', function(e, element) { + var c, children = $element.children(); + for(var i = 0; i < children.length; i++) { + c = children[i]; + if(c != element[0]) { + c.classList.remove('active'); + } + } + }); + } + } + }; +}) + +.directive('button', function() { + return { + restrict: 'E', + require: '?^ngModel', + link: function($scope, $element, $attr, ngModel) { + if(!ngModel) { return; } + + var setIt = function() { + $element.addClass('active'); + ngModel.$setViewValue($scope.$eval($attr.ngValue)); + $scope.$emit('button.toggled', $element); + }; + + $scope.tapHandler = function(e) { + setIt(); + e.alreadyHandled = true; + }; + + var clickHandler = function(e) { + setIt(); + }; + + $element.bind('click', clickHandler); + } + } }); })(window.ionic); diff --git a/js/ext/angular/src/directive/ionicRadio.js b/js/ext/angular/src/directive/ionicRadio.js index 2e359417e5..ae50cec33c 100644 --- a/js/ext/angular/src/directive/ionicRadio.js +++ b/js/ext/angular/src/directive/ionicRadio.js @@ -55,6 +55,73 @@ angular.module('ionic.ui.radio', []) } } }; +}) + +// The radio button is a radio powered element with only +// one possible selection in a set of options. +.directive('radioButtons', function() { + return { + restrict: 'E', + replace: true, + require: '?ngModel', + scope: { + value: '@' + }, + transclude: true, + template: '', + + link: function($scope, $element, $attr, ngModel) { + var radio; + + + if(ngModel) { + //$element.bind('tap', tapHandler); + + ngModel.$render = function() { + var val = $scope.$eval($attr.ngValue); + if(val === ngModel.$viewValue) { + } else { + } + }; + $scope.$parent.$on('button.toggled', function(e, element) { + var c, children = $element.children(); + for(var i = 0; i < children.length; i++) { + c = children[i]; + if(c != element[0]) { + c.classList.remove('active'); + } + } + }); + } + } + }; +}) + +.directive('button', function() { + return { + restrict: 'E', + require: '?^ngModel', + link: function($scope, $element, $attr, ngModel) { + if(!ngModel) { return; } + + var setIt = function() { + $element.addClass('active'); + ngModel.$setViewValue($scope.$eval($attr.ngValue)); + $scope.$emit('button.toggled', $element); + }; + + $scope.tapHandler = function(e) { + setIt(); + e.alreadyHandled = true; + }; + + var clickHandler = function(e) { + setIt(); + }; + + $element.bind('click', clickHandler); + } + } }); })(window.ionic); diff --git a/js/ext/angular/test/radioButton.html b/js/ext/angular/test/radioButton.html new file mode 100644 index 0000000000..ee17aa2f24 --- /dev/null +++ b/js/ext/angular/test/radioButton.html @@ -0,0 +1,54 @@ + + + +