diff --git a/dist/css/ionic-ios7.css b/dist/css/ionic-ios7.css index d6c46fe274..2cb8251fec 100644 --- a/dist/css/ionic-ios7.css +++ b/dist/css/ionic-ios7.css @@ -181,7 +181,7 @@ sub { fieldset { margin: 0 2px; padding: 0.35em 0.625em 0.75em; - border: 1px solid #c0c0c0; } + border: 1px solid silver; } /** * 1. Correct `color` not being inherited in IE 8/9. @@ -1381,7 +1381,7 @@ select:focus, input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { - outline: thin dotted #333; + outline: thin dotted #333333; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } @@ -1468,7 +1468,7 @@ input[type="checkbox"][readonly] { right: 20px; transition: 0.2s ease; transition-property: left, right; - transition-delay: 0s, .05s; } + transition-delay: 0s, 0.05s; } .toggle :checked + .track { /* When the toggle is "on" */ @@ -1483,7 +1483,7 @@ input[type="checkbox"][readonly] { right: 0; left: 20px; -webkit-transform: none; - transition-delay: .05s, 0s; } + transition-delay: 0.05s, 0s; } /* hide a radio button's icon by default */ .radio-item [class^="icon-"], @@ -1708,7 +1708,7 @@ input[type="checkbox"][readonly] { border: none; background: none; } .button.button-icon:active, .button.button-icon.active { - text-shadow: 0px 0px 10px #fff; + text-shadow: 0px 0px 10px white; box-shadow: none; background: none; } @@ -1891,7 +1891,7 @@ a.button { width: 100%; background-color: white; border-radius: 2px; - border: 1px solid #ddd; } + border: 1px solid #dddddd; } .card-header { padding: 10px; diff --git a/dist/css/ionic.css b/dist/css/ionic.css index 7bee43b4b8..ece124c893 100644 --- a/dist/css/ionic.css +++ b/dist/css/ionic.css @@ -1245,7 +1245,7 @@ sub { fieldset { margin: 0 2px; padding: 0.35em 0.625em 0.75em; - border: 1px solid #c0c0c0; } + border: 1px solid silver; } /** * 1. Correct `color` not being inherited in IE 8/9. @@ -2468,7 +2468,7 @@ select:focus, input[type="file"]:focus, input[type="radio"]:focus, input[type="checkbox"]:focus { - outline: thin dotted #333; + outline: thin dotted #333333; outline: 5px auto -webkit-focus-ring-color; outline-offset: -2px; } @@ -2515,6 +2515,18 @@ input[type="radio"][readonly], input[type="checkbox"][readonly] { background-color: transparent; } +.checkbox { + /* what the checkbox looks like when its not checked */ + /* what it looks like when it is checked */ } + .checkbox input { + display: none; } + .checkbox .handle { + width: 30px; + height: 30px; + background: red; } + .checkbox input:checked + .handle { + background: green; } + /* the overall container of the toggle */ .toggle { display: inline-block; } @@ -2790,7 +2802,7 @@ input[type="checkbox"][readonly] { border: none; background: none; } .button.button-icon:active, .button.button-icon.active { - text-shadow: 0px 0px 10px #fff; + text-shadow: 0px 0px 10px white; box-shadow: none; background: none; } @@ -2973,7 +2985,7 @@ a.button { width: 100%; background-color: white; border-radius: 2px; - border: 1px solid #ddd; } + border: 1px solid #dddddd; } .card-header { padding: 10px; diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index 582c3ba185..8b0b55e89a 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -7,6 +7,7 @@ angular.module('ionic.ui', ['ionic.ui.content', 'ionic.ui.nav', 'ionic.ui.sideMenu', 'ionic.ui.list', + 'ionic.ui.checkbox', 'ionic.ui.toggle' ]); @@ -154,6 +155,46 @@ angular.module('ionic.ui.actionSheet', []) } }); ; +angular.module('ionic.ui.checkbox', []) + + +.directive('checkbox', function() { + return { + restrict: 'E', + replace: true, + require: '?ngModel', + scope: true, + template: '
', + + link: function($scope, $element, $attr, ngModel) { + var checkbox, handle; + + if(!ngModel) { return; } + + checkbox = $element.children().eq(0); + handle = $element.children().eq(1); + + if(!checkbox.length || !handle.length) { return; } + + $scope.checkbox = new ionic.views.Checkbox({ + el: $element[0], + checkbox: checkbox[0], + handle: handle[0] + }); + + $element.bind('click', function(e) { + $scope.checkbox.tap(e); + $scope.$apply(function() { + ngModel.$setViewValue(checkbox[0].checked); + }); + }); + + ngModel.$render = function() { + $scope.checkbox.val(ngModel.$viewValue); + }; + } + } +}); angular.module('ionic.ui.content', []) // The content directive is a core scrollable content area diff --git a/dist/js/ionic.js b/dist/js/ionic.js index 50202c47c9..7f74b32b3e 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -1750,6 +1750,32 @@ window.ionic = { })(ionic); ; +(function(ionic) { + + ionic.views.Checkbox = function(opts) { + this.el = opts.el; + this.checkbox = opts.checkbox; + this.handle = opts.handle; + }; + + ionic.views.Checkbox.prototype = { + + tap: function(e) { + this.val( !this.checkbox.checked ); + }, + + val: function(value) { + if(value === true || value === false) { + this.checkbox.checked = value; + } + return this.checkbox.checked; + } + + }; + +})(ionic); +; + (function(ionic) { ionic.views.HeaderBar = function(opts) { diff --git a/js/ext/angular/src/directive/ionicCheckbox.js b/js/ext/angular/src/directive/ionicCheckbox.js new file mode 100644 index 0000000000..9d277a4445 --- /dev/null +++ b/js/ext/angular/src/directive/ionicCheckbox.js @@ -0,0 +1,40 @@ +angular.module('ionic.ui.checkbox', []) + + +.directive('checkbox', function() { + return { + restrict: 'E', + replace: true, + require: '?ngModel', + scope: true, + template: '
', + + link: function($scope, $element, $attr, ngModel) { + var checkbox, handle; + + if(!ngModel) { return; } + + checkbox = $element.children().eq(0); + handle = $element.children().eq(1); + + if(!checkbox.length || !handle.length) { return; } + + $scope.checkbox = new ionic.views.Checkbox({ + el: $element[0], + checkbox: checkbox[0], + handle: handle[0] + }); + + $element.bind('click', function(e) { + $scope.checkbox.tap(e); + $scope.$apply(function() { + ngModel.$setViewValue(checkbox[0].checked); + }); + }); + + ngModel.$render = function() { + $scope.checkbox.val(ngModel.$viewValue); + }; + } + } +}) \ No newline at end of file diff --git a/js/ext/angular/src/ionicAngular.js b/js/ext/angular/src/ionicAngular.js index 553e67229d..444a54c634 100644 --- a/js/ext/angular/src/ionicAngular.js +++ b/js/ext/angular/src/ionicAngular.js @@ -7,6 +7,7 @@ angular.module('ionic.ui', ['ionic.ui.content', 'ionic.ui.nav', 'ionic.ui.sideMenu', 'ionic.ui.list', + 'ionic.ui.checkbox', 'ionic.ui.toggle' ]); diff --git a/js/ext/angular/test/checkbox.html b/js/ext/angular/test/checkbox.html new file mode 100644 index 0000000000..265e7fee26 --- /dev/null +++ b/js/ext/angular/test/checkbox.html @@ -0,0 +1,45 @@ + + + + Checkbox + + + + + + + + + + + +

+ + + +
+ + + + + + + diff --git a/js/views/checkboxView.js b/js/views/checkboxView.js new file mode 100644 index 0000000000..651c433acd --- /dev/null +++ b/js/views/checkboxView.js @@ -0,0 +1,25 @@ + +(function(ionic) { + + ionic.views.Checkbox = function(opts) { + this.el = opts.el; + this.checkbox = opts.checkbox; + this.handle = opts.handle; + }; + + ionic.views.Checkbox.prototype = { + + tap: function(e) { + this.val( !this.checkbox.checked ); + }, + + val: function(value) { + if(value === true || value === false) { + this.checkbox.checked = value; + } + return this.checkbox.checked; + } + + }; + +})(ionic); diff --git a/scss/ionic/_checkbox.scss b/scss/ionic/_checkbox.scss new file mode 100644 index 0000000000..7dd96573a5 --- /dev/null +++ b/scss/ionic/_checkbox.scss @@ -0,0 +1,20 @@ + +.checkbox { + + input { + display: none; + } + + /* what the checkbox looks like when its not checked */ + .handle { + width: 30px; + height: 30px; + background: red; + } + + /* what it looks like when it is checked */ + input:checked + .handle { + background: green; + } + +} \ No newline at end of file diff --git a/scss/ionic/ionic.scss b/scss/ionic/ionic.scss index 283c011635..9fb7e42e7e 100644 --- a/scss/ionic/ionic.scss +++ b/scss/ionic/ionic.scss @@ -25,6 +25,7 @@ // Forms "form", + "checkbox", "toggle", "radio",