diff --git a/.gitignore b/.gitignore index 76a84fa..328d185 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules bower_components .DS_Store +.idea/ \ No newline at end of file diff --git a/README.md b/README.md index c7400e3..4a10312 100644 --- a/README.md +++ b/README.md @@ -79,6 +79,46 @@ You can completely change the design. All the magic is hidden inside two CSS cla } ``` +## Sizes + +You can change the sizes of the switch element via size. Giving it a value of small or large will result in adding switchery-small or switchery-large classes respectively, which will change the switch size. + +Not using this property will render the default sized switch element. + +```html +
+ +
{{ enabled }} +
+``` + +```html +
+ +
{{ enabled }} +
+``` + +Alternatively you could just use a class attribute of `class="sm"` or `class="lg"`, which will change the switch size. + +Again, not using size element or class attributes property will render the default sized switch element. + +```html +
+ +
{{ enabled }} +
+``` + +```html +
+ +
{{ enabled }} +
+``` + +![YoomJS](https://raw.githubusercontent.com/EskoCruz/angular-ui-switch/master/switch-size.png) + ## Publishing 1. Update version in `package.json` and `bower.json`. diff --git a/angular-ui-switch.css b/angular-ui-switch.css index d5bcdf2..f8085b6 100644 --- a/angular-ui-switch.css +++ b/angular-ui-switch.css @@ -80,3 +80,37 @@ opacity: .50; cursor: not-allowed; } + + +/* Switchery sizes. */ +/* Switchery size shorthand classes */ + +.switchery-small, .sm { + border-radius: 20px; + height: 20px; + width: 33px; +} + +.switchery-small > small, .sm > small { + height: 20px; + width: 20px; +} + +.switch.switchery-small.checked small, .switch.sm.checked small { + left: 13px; +} + +.switchery-large, .lg { + border-radius: 40px; + height: 40px; + width: 66px; +} + +.switchery-large > small, .lg > small { + height: 40px; + width: 40px; +} + +.switch.switchery-large.checked small, .switch.lg.checked small { + left: 26px; +} \ No newline at end of file diff --git a/angular-ui-switch.js b/angular-ui-switch.js index 9a6b591..1dc0e90 100644 --- a/angular-ui-switch.js +++ b/angular-ui-switch.js @@ -8,7 +8,9 @@ angular.module('uiSwitch', []) , template: function(element, attrs) { var html = ''; html += 'small,.switchery-small>small{height:20px;width:20px}.switch.sm.checked small,.switch.switchery-small.checked small{left:13px}.lg,.switchery-large{border-radius:40px;height:40px;width:66px}.lg>small,.switchery-large>small{height:40px;width:40px}.switch.lg.checked small,.switch.switchery-large.checked small{left:26px} \ No newline at end of file diff --git a/angular-ui-switch.min.js b/angular-ui-switch.min.js index 6f6da0f..22dcb8b 100644 --- a/angular-ui-switch.min.js +++ b/angular-ui-switch.min.js @@ -1 +1 @@ -angular.module("uiSwitch",[]).directive("switch",function(){return{restrict:"AE",replace:!0,transclude:!0,template:function(n,e){var s="";return s+="'+e.on+"":"",s+=e.off?''+e.off+"":" ",s+=""}}}); \ No newline at end of file +angular.module("uiSwitch",[]).directive("switch",function(){return{restrict:"AE",replace:!0,transclude:!0,template:function(n,e){var s="";return s+="'+e.on+"":"",s+=e.off?''+e.off+"":" ",s+=""}}}); \ No newline at end of file diff --git a/example/app.js b/example/app.js index 3d12135..c06fefe 100644 --- a/example/app.js +++ b/example/app.js @@ -5,6 +5,10 @@ angular.module('app', ['uiSwitch']) $scope.onOff = true; $scope.yesNo = true; $scope.disabled = true; + $scope.sizeSmall = true; + $scope.sizeLarge = true; + $scope.sizeClassSmall = true; + $scope.sizeClassLarge = true; $scope.changeCallback = function() { diff --git a/example/index.html b/example/index.html index 6adb029..fbbdf1b 100644 --- a/example/index.html +++ b/example/index.html @@ -46,6 +46,38 @@

Enabled: {{ disabled }}

+ + +

+ +

+

+ Enabled: {{ sizeSmall }} +

+ + +

+ +

+

+ Enabled: {{ sizeLarge }} +

+ + +

+ +

+

+ Enabled: {{ sizeClassSmall }} +

+ + +

+ +

+

+ Enabled: {{ sizeClassLarge }} +

diff --git a/switch-size.png b/switch-size.png new file mode 100644 index 0000000..5efbede Binary files /dev/null and b/switch-size.png differ