diff --git a/src/app/pages/form/inputs/inputs.html b/src/app/pages/form/inputs/inputs.html
index c7fb0be..e1e4fbf 100644
--- a/src/app/pages/form/inputs/inputs.html
+++ b/src/app/pages/form/inputs/inputs.html
@@ -26,9 +26,15 @@
ba-panel-class="with-scroll">
';
+ },
+ link: function (scope, elem, attr) {
+ $timeout(function(){
+ var input = $(elem).find('input');
+ input.bootstrapSwitch({
+ size: 'small',
+ onColor: attr.color
+ });
+ input.on('switchChange.bootstrapSwitch', function(event, state) {
+ scope.ngModel = state;
+ scope.$apply();
+ });
+
+ });
+ }
+ };
+ }
+})();
diff --git a/src/app/pages/form/inputs/widgets/oldSwitch/switch.html b/src/app/pages/form/inputs/widgets/oldSwitch/switch.html
new file mode 100644
index 0000000..c8b0034
--- /dev/null
+++ b/src/app/pages/form/inputs/widgets/oldSwitch/switch.html
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/app/pages/form/inputs/widgets/switch.html b/src/app/pages/form/inputs/widgets/switch.html
new file mode 100644
index 0000000..c4f8e53
--- /dev/null
+++ b/src/app/pages/form/inputs/widgets/switch.html
@@ -0,0 +1,51 @@
+
+
+
+
+
+
diff --git a/src/app/pages/form/inputs/widgets/switch/switch.directive.js b/src/app/pages/form/inputs/widgets/switch/switch.directive.js
index 7b2937c..a15301f 100644
--- a/src/app/pages/form/inputs/widgets/switch/switch.directive.js
+++ b/src/app/pages/form/inputs/widgets/switch/switch.directive.js
@@ -1,37 +1,24 @@
/**
- * @author v.lugovksy
- * created on 16.12.2015
+ * @author p.maslava
+ * created on 30.11.2016
+ * @deprecated
*/
(function () {
'use strict';
angular.module('BlurAdmin.pages.form')
- .directive('switch', switchDirective);
+ .directive('switchInput', switchDirective);
/** @ngInject */
- function switchDirective($timeout) {
+ function switchDirective() {
return {
- restrict: 'EA',
- replace: true,
- scope: {
- ngModel: '='
- },
- template: function(el, attrs) {
- return '
';
- },
- link: function (scope, elem, attr) {
- $timeout(function(){
- var input = $(elem).find('input');
- input.bootstrapSwitch({
- size: 'small',
- onColor: attr.color
- });
- input.on('switchChange.bootstrapSwitch', function(event, state) {
- scope.ngModel = state;
- scope.$apply();
- });
-
- });
+ restrict: 'A',
+ template: function(el, attr) {
+ var switcher = '
';
+ return switcher
}
};
}
diff --git a/src/app/pages/form/inputs/widgets/switch/switch.html b/src/app/pages/form/inputs/widgets/switch/switch.html
index c8b0034..840f2da 100644
--- a/src/app/pages/form/inputs/widgets/switch/switch.html
+++ b/src/app/pages/form/inputs/widgets/switch/switch.html
@@ -1,7 +1,7 @@
-
-
-
-
-
-
-
\ No newline at end of file
+
+
+
+
+
+
+
diff --git a/src/sass/app/_form.scss b/src/sass/app/_form.scss
index d08e78f..5e1cac0 100644
--- a/src/sass/app/_form.scss
+++ b/src/sass/app/_form.scss
@@ -88,6 +88,78 @@ textarea.form-control {
}
}
+@mixin setSwitcherColor($color) {
+ border: solid 1px $color;
+ .handle.handle-on {
+ background-color: $color;
+ }
+}
+
+.switcher-container {
+ margin-right: 10px;
+ input {
+ display: none;
+ }
+ .switcher {
+ &.primary {
+ @include setSwitcherColor($primary);
+ }
+ &.success {
+ @include setSwitcherColor($success);
+ }
+ &.warning {
+ @include setSwitcherColor($warning);
+ }
+ &.danger {
+ @include setSwitcherColor($danger);
+ }
+ &.info {
+ @include setSwitcherColor($primary-light);
+ }
+ position: relative;
+ display: inline-block;
+ width: 84px;
+ overflow: hidden;
+ border-radius: 6px;
+ box-sizing: border-box;
+
+ /* this fixes the overflow:hidden in Chrome */
+ -webkit-transform: translateZ(0);
+ /* Hide default HTML checkbox */
+ input {
+ display: none;
+ }
+ .handle-container {
+ position: relative;
+ margin-left: 0px;
+ width: 126px;
+ cursor: pointer;
+ transition: .2s;
+ .handle {
+ width: 42px;
+ float: left;
+ line-height: 28px;
+ height: 28px;
+ font-size: 12px;
+ text-align: center;
+ color: white;
+ &.handle-off {
+ background: $border;
+ color: black;
+ }
+ }
+ }
+ }
+ input:checked + .switcher {
+ border: solid 1px $border;
+ .handle-container {
+ margin-left: -42px;
+ }
+ }
+
+}
+
+
.switch-container {
display: inline-block;
&.primary {
@@ -562,3 +634,4 @@ label.custom-input-danger {
.sub-little-text {
font-size: 12px;
}
+