nice-elements 1.9.7 → 1.9.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +2 -1
- package/bower.json +1 -1
- package/dist/nice.js +209 -90
- package/dist/nice.min.js +1 -1
- package/dist/style.css +55 -1
- package/dist/style.css.map +2 -1
- package/dist/style.min.css +2 -2
- package/package.json +1 -1
- package/src/components/nice-input/nice-input.html +1 -1
- package/src/components/nice-input/nice-input.js +10 -1
- package/src/components/nice-toggle/nice-toggle.html +13 -0
- package/src/components/nice-toggle/nice-toggle.js +95 -0
- package/src/components/nice-toggle/nice-toggle.scss +68 -0
- package/src/services/nice-service.js +1 -1
- package/src/styles/_nice.scss +1 -0
- package/src/styles/_variables.scss +3 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @ngdoc directive
|
|
5
|
+
* @name niceElements.directive:niceToggle
|
|
6
|
+
* @description
|
|
7
|
+
* # niceToggle
|
|
8
|
+
*/
|
|
9
|
+
angular.module('niceElements')
|
|
10
|
+
.directive('niceToggle', function () {
|
|
11
|
+
return {
|
|
12
|
+
templateUrl: 'src/components/nice-toggle/nice-toggle.html',
|
|
13
|
+
restrict: 'E',
|
|
14
|
+
scope: {
|
|
15
|
+
model: '=',
|
|
16
|
+
title: '@',
|
|
17
|
+
isDisabled: '=',
|
|
18
|
+
fieldWidth: '@',
|
|
19
|
+
labelWidth: '@',
|
|
20
|
+
defaultFalse: '@',
|
|
21
|
+
noMargin: '@',
|
|
22
|
+
onChange: '&?',
|
|
23
|
+
isInline: '=',
|
|
24
|
+
help: '@'
|
|
25
|
+
},
|
|
26
|
+
controller: function ($scope) {
|
|
27
|
+
if (!$scope.title) { $scope.title = ''; }
|
|
28
|
+
if (!$scope.fieldWidth) { $scope.fieldWidth = 'col-sm-8'; }
|
|
29
|
+
if (!$scope.labelWidth) { $scope.labelWidth = 'col-sm-4'; }
|
|
30
|
+
|
|
31
|
+
// ------------------------- Set overlay button position based on passed state in $scope.model -------------------------
|
|
32
|
+
$scope.setButtonPosition = function (state) {
|
|
33
|
+
if (state) {
|
|
34
|
+
$scope.buttonClass = "yesno-button-yes";
|
|
35
|
+
} else {
|
|
36
|
+
$scope.buttonClass = "yesno-button-no";
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// ------------------------- Watch for changes from outside -------------------------
|
|
41
|
+
$scope.$watch('model', function (value_new, value_old) {
|
|
42
|
+
if (angular.isDefined($scope.model)) {
|
|
43
|
+
$scope.setButtonLabel($scope.model);
|
|
44
|
+
$scope.setButtonPosition($scope.model);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// ------------------------- Watch for model value -------------------------
|
|
49
|
+
$scope.$watch('modelValue', function (value_new, value_old) {
|
|
50
|
+
if ($scope.options) {
|
|
51
|
+
$scope.model = $scope.modelValue == $scope.options[0];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// ------------------------- Set button label -------------------------
|
|
56
|
+
$scope.setButtonLabel = function (state) {
|
|
57
|
+
if (state) {
|
|
58
|
+
$scope.state = $scope.yes;
|
|
59
|
+
} else {
|
|
60
|
+
$scope.state = $scope.no;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// ------------------------- Set width -------------------------
|
|
65
|
+
$scope.setWidth = function (width, el) {
|
|
66
|
+
el.style.width = width;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
// ------------------------- Switch -------------------------
|
|
71
|
+
$scope.switch = function () {
|
|
72
|
+
if (!$scope.isDisabled) {
|
|
73
|
+
$scope.model = !$scope.model;
|
|
74
|
+
|
|
75
|
+
if ($scope.options) {
|
|
76
|
+
if ($scope.model) {
|
|
77
|
+
$scope.modelValue = $scope.options[0];
|
|
78
|
+
} else {
|
|
79
|
+
$scope.modelValue = $scope.options[1];
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if ($scope.onChange) $scope.onChange({ model: $scope.model });
|
|
84
|
+
$scope.formYesno.$setDirty();
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
// Call it first time
|
|
89
|
+
$scope.setButtonPosition($scope.model);
|
|
90
|
+
|
|
91
|
+
// Set label based on state passed in $scope.model
|
|
92
|
+
$scope.setButtonLabel($scope.model);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
.nice-toggle {
|
|
2
|
+
&:focus-within {
|
|
3
|
+
.nice-toggle-field {
|
|
4
|
+
@extend .nice-focus;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.nice-title {
|
|
9
|
+
min-height: 27px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&.nice-component-inline {
|
|
13
|
+
.row {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
margin: 0;
|
|
17
|
+
|
|
18
|
+
nice-title {
|
|
19
|
+
order: 2;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.nice-title {
|
|
23
|
+
margin: 0;
|
|
24
|
+
padding: 0;
|
|
25
|
+
margin-left: 1rem;
|
|
26
|
+
line-height: 25px;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.nice-field {
|
|
30
|
+
margin: 0;
|
|
31
|
+
padding: 0;
|
|
32
|
+
width: auto;
|
|
33
|
+
order: 1;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.nice-toggle-field {
|
|
39
|
+
border: 1px solid var(--nice-border-color);
|
|
40
|
+
background: var(--nice-input-bg);
|
|
41
|
+
border-radius: 1rem;
|
|
42
|
+
position: relative;
|
|
43
|
+
width: 50px;
|
|
44
|
+
height: 25px;
|
|
45
|
+
|
|
46
|
+
// &:hover {
|
|
47
|
+
// .nice-toggle-field-handle {
|
|
48
|
+
// background: var(--nice-primary-color-darker);
|
|
49
|
+
// }
|
|
50
|
+
// }
|
|
51
|
+
|
|
52
|
+
.nice-toggle-field-handle {
|
|
53
|
+
position: absolute;
|
|
54
|
+
top: 2px;
|
|
55
|
+
left: 2px;
|
|
56
|
+
width: 19px;
|
|
57
|
+
height: 19px;
|
|
58
|
+
background: var(--nice-border-color);
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
transition: left 0.3s ease-in-out;
|
|
61
|
+
|
|
62
|
+
&.active {
|
|
63
|
+
background: var(--nice-primary-color);
|
|
64
|
+
left: calc(100% - 22px);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
package/src/styles/_nice.scss
CHANGED
|
@@ -62,4 +62,5 @@
|
|
|
62
62
|
@import "../components/nice-date-input/nice-date-input";
|
|
63
63
|
@import "../components/nice-wrapper/nice-wrapper";
|
|
64
64
|
@import "../components/nice-pill/nice-pill";
|
|
65
|
+
@import "../components/nice-toggle/nice-toggle";
|
|
65
66
|
@import "../modals/nice-multilangual-modal/nice-multilangual-modal";
|