nice-elements 1.13.8 → 1.14.1
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 +24 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +233 -169
- package/dist/nice.min.js +1 -1
- package/dist/style.css +391 -1002
- package/dist/style.css.map +1 -59
- package/dist/style.min.css +2 -2
- package/package.json +6 -6
- package/src/components/nice-alert/nice-alert.scss +5 -0
- package/src/components/nice-comment/nice-comment.js +11 -11
- package/src/components/nice-comment/nice-comment.scss +0 -2
- package/src/components/nice-date/nice-date.js +8 -1
- package/src/components/nice-date/nice-date.scss +1 -0
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +9 -2
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +1 -0
- package/src/components/nice-dropdown/nice-dropdown.html +3 -3
- package/src/components/nice-dropdown/nice-dropdown.js +21 -15
- package/src/components/nice-dropdown/nice-dropdown.scss +20 -0
- package/src/components/nice-help/nice-help.html +3 -4
- package/src/components/nice-help/nice-help.js +10 -37
- package/src/components/nice-help/nice-help.scss +59 -27
- package/src/components/nice-input/nice-input.html +3 -0
- package/src/components/nice-input/nice-input.js +4 -4
- package/src/components/nice-input/nice-input.scss +1 -1
- package/src/components/nice-notification/nice-notification.html +9 -4
- package/src/components/nice-notification/nice-notification.js +66 -46
- package/src/components/nice-notification/nice-notification.scss +99 -19
- package/src/components/nice-percent/nice-percent.html +5 -5
- package/src/components/nice-popup/nice-popup.js +10 -5
- package/src/components/nice-search2/nice-search2.js +15 -5
- package/src/components/nice-toggle/nice-toggle.html +1 -1
- package/src/components/nice-toggle/nice-toggle.scss +15 -1
- package/src/components/nice-upload/nice-upload.html +1 -1
- package/src/components/nice-upload/nice-upload.scss +3 -0
- package/src/components/nice-virtual-scroll/nice-virtual-scroll.js +15 -3
- package/src/directives/nice-click-outside.js +24 -18
- package/src/directives/nice-tooltip/nice-tooltip.js +14 -4
- package/src/services/nice-service.js +1 -1
|
@@ -10,12 +10,35 @@ angular.module('niceElements')
|
|
|
10
10
|
.factory('NiceNotification', function ($timeout, $http, $compile, $templateCache, $rootScope, $sce) {
|
|
11
11
|
|
|
12
12
|
let startTop = 10;
|
|
13
|
-
let startRight = 10;
|
|
14
13
|
let verticalSpacing = 10;
|
|
15
|
-
let horizontalSpacing = 10;
|
|
16
14
|
let delay = 5000;
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
// Default icon per type (primary has none). Override with notify.config({ icons: { ... } })
|
|
17
|
+
const icons = {
|
|
18
|
+
success: 'icon-check-circle',
|
|
19
|
+
error: 'icon-alert-triangle',
|
|
20
|
+
warning: 'icon-alert-circle',
|
|
21
|
+
info: 'icon-info',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// All notifications live in one fixed container; CSS (flexbox) does the stacking
|
|
25
|
+
let container = null;
|
|
26
|
+
|
|
27
|
+
const applyConfig = function () {
|
|
28
|
+
if (!container) return;
|
|
29
|
+
container.style.setProperty('--nice-notification-top', startTop + 'px');
|
|
30
|
+
container.style.setProperty('--nice-notification-spacing', verticalSpacing + 'px');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const getContainer = function () {
|
|
34
|
+
if (!container || !document.body.contains(container)) {
|
|
35
|
+
container = document.createElement('div');
|
|
36
|
+
container.className = 'nice-notifications';
|
|
37
|
+
applyConfig();
|
|
38
|
+
document.body.appendChild(container);
|
|
39
|
+
}
|
|
40
|
+
return container;
|
|
41
|
+
};
|
|
19
42
|
|
|
20
43
|
const notify = function (args, t) {
|
|
21
44
|
|
|
@@ -33,6 +56,8 @@ angular.module('niceElements')
|
|
|
33
56
|
scope.message = $sce.trustAsHtml(args.message);
|
|
34
57
|
scope.title = $sce.trustAsHtml(args.title);
|
|
35
58
|
scope.t = args.type.substr(0, 1);
|
|
59
|
+
// icon: undefined → type default, false/null/'' → no icon, string → that icon id
|
|
60
|
+
scope.icon = angular.isUndefined(args.icon) ? icons[args.type] : args.icon;
|
|
36
61
|
scope.delay = args.delay;
|
|
37
62
|
|
|
38
63
|
if (typeof args.scope === 'object') {
|
|
@@ -41,54 +66,42 @@ angular.module('niceElements')
|
|
|
41
66
|
}
|
|
42
67
|
}
|
|
43
68
|
|
|
44
|
-
const reposite = function () {
|
|
45
|
-
let j = 0;
|
|
46
|
-
let k = 0;
|
|
47
|
-
let lastTop = startTop;
|
|
48
|
-
let top = 0;
|
|
49
|
-
// const lastRight = startRight;
|
|
50
|
-
for (let i = messageElements.length - 1; i >= 0; i--) {
|
|
51
|
-
const element = messageElements[i];
|
|
52
|
-
const elHeight = parseInt(element[0].offsetHeight);
|
|
53
|
-
const elWidth = parseInt(element[0].offsetWidth);
|
|
54
|
-
if ((top + elHeight) > window.innerHeight) {
|
|
55
|
-
lastTop = startTop;
|
|
56
|
-
k++;
|
|
57
|
-
j = 0;
|
|
58
|
-
}
|
|
59
|
-
top = lastTop + (j === 0 ? 0 : verticalSpacing);
|
|
60
|
-
const right = startRight + (k * (horizontalSpacing + elWidth));
|
|
61
|
-
|
|
62
|
-
element.css('top', top + 'px');
|
|
63
|
-
element.css('right', right + 'px');
|
|
64
|
-
|
|
65
|
-
lastTop = top + elHeight;
|
|
66
|
-
j++;
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
69
|
const templateElement = $compile(template)(scope);
|
|
71
70
|
templateElement.addClass(args.type);
|
|
72
|
-
templateElement.bind('transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd click', function (e) {
|
|
73
|
-
e = e.originalEvent || e;
|
|
74
|
-
if (e.type === 'click' || (e.propertyName === 'opacity' && e.elapsedTime >= 0.4)) {
|
|
75
|
-
templateElement.remove();
|
|
76
|
-
messageElements.splice(messageElements.indexOf(templateElement), 1);
|
|
77
|
-
reposite();
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
71
|
|
|
81
|
-
|
|
72
|
+
let closed = false;
|
|
73
|
+
let closeTimer = null;
|
|
74
|
+
|
|
75
|
+
// Single exit path: safe to call any number of times (click + timer)
|
|
76
|
+
const close = function () {
|
|
77
|
+
if (closed) return;
|
|
78
|
+
closed = true;
|
|
79
|
+
if (closeTimer) $timeout.cancel(closeTimer);
|
|
80
|
+
|
|
81
|
+
// Mark as closed; the leave animation is defined entirely in CSS (.killed).
|
|
82
|
+
// Remove the element once whatever CSS animations it has are done
|
|
83
|
+
// (resolves right away if there are none, e.g. a custom template).
|
|
84
|
+
const el = templateElement[0];
|
|
82
85
|
templateElement.addClass('killed');
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
const running = el.getAnimations ? el.getAnimations() : [];
|
|
87
|
+
// An interrupted enter animation rejects its promise; treat that as done
|
|
88
|
+
// so it doesn't cut the leave transitions short.
|
|
89
|
+
Promise.all(running.map(function (a) { return a.finished.catch(angular.noop); }))
|
|
90
|
+
.then(function () {
|
|
91
|
+
templateElement.remove();
|
|
92
|
+
scope.$destroy();
|
|
93
|
+
});
|
|
94
|
+
};
|
|
87
95
|
|
|
88
|
-
|
|
89
|
-
messageElements.push(templateElement);
|
|
96
|
+
templateElement.on('click', close);
|
|
90
97
|
|
|
91
|
-
|
|
98
|
+
// Newest on top; the CSS enter animation runs on insertion
|
|
99
|
+
const list = getContainer();
|
|
100
|
+
list.insertBefore(templateElement[0], list.firstChild);
|
|
101
|
+
|
|
102
|
+
if (args.delay > 0) {
|
|
103
|
+
closeTimer = $timeout(close, args.delay);
|
|
104
|
+
}
|
|
92
105
|
|
|
93
106
|
}).error(function (data) {
|
|
94
107
|
throw new Error('Template (' + args.template + ') could not be loaded. ' + data);
|
|
@@ -98,6 +111,13 @@ angular.module('niceElements')
|
|
|
98
111
|
notify.config = function (args) {
|
|
99
112
|
startTop = args.top ? args.top : startTop;
|
|
100
113
|
verticalSpacing = args.verticalSpacing ? args.verticalSpacing : verticalSpacing;
|
|
114
|
+
applyConfig();
|
|
115
|
+
if (args.icons) {
|
|
116
|
+
// Use 'primary' as the key for the default type
|
|
117
|
+
angular.forEach(args.icons, function (icon, type) {
|
|
118
|
+
icons[type === 'primary' ? '' : type] = icon;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
101
121
|
};
|
|
102
122
|
|
|
103
123
|
notify.primary = function (args) {
|
|
@@ -122,4 +142,4 @@ angular.module('niceElements')
|
|
|
122
142
|
|
|
123
143
|
|
|
124
144
|
return notify;
|
|
125
|
-
});
|
|
145
|
+
});
|
|
@@ -1,32 +1,116 @@
|
|
|
1
|
-
.
|
|
1
|
+
// Stack container: newest on top, top-right corner. When a column fills the
|
|
2
|
+
// viewport height, older notifications wrap into a new column to the left.
|
|
3
|
+
.nice-notifications {
|
|
4
|
+
--nice-notification-top: 10px;
|
|
5
|
+
--nice-notification-spacing: 10px;
|
|
2
6
|
position: fixed;
|
|
7
|
+
top: var(--nice-notification-top);
|
|
3
8
|
right: 10px;
|
|
4
|
-
top: -100px;
|
|
5
9
|
z-index: 99999;
|
|
6
|
-
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
flex-wrap: wrap-reverse;
|
|
13
|
+
align-items: flex-end;
|
|
14
|
+
align-content: flex-start;
|
|
15
|
+
column-gap: 10px;
|
|
16
|
+
max-height: calc(100vh - var(--nice-notification-top));
|
|
17
|
+
pointer-events: none; // clicks pass through the empty container area
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@keyframes nice-notification-in {
|
|
21
|
+
from {
|
|
22
|
+
grid-template-rows: minmax(0, 0fr);
|
|
23
|
+
margin-bottom: 0;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
transform: translateX(40px) scale(0.96);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Slide out and fade, then collapse so the cards below close the gap
|
|
30
|
+
@keyframes nice-notification-out {
|
|
31
|
+
40% {
|
|
32
|
+
grid-template-rows: minmax(0, 1fr);
|
|
33
|
+
margin-bottom: var(--nice-notification-spacing, 10px);
|
|
34
|
+
opacity: 0;
|
|
35
|
+
transform: translateX(60px) scale(0.96);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
to {
|
|
39
|
+
grid-template-rows: minmax(0, 0fr);
|
|
40
|
+
margin-bottom: 0;
|
|
41
|
+
opacity: 0;
|
|
42
|
+
transform: translateX(60px) scale(0.96);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@keyframes nice-notification-fade-out {
|
|
47
|
+
to {
|
|
48
|
+
opacity: 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.notification {
|
|
53
|
+
// Single grid row animated between 0fr and 1fr: lets the card collapse/expand
|
|
54
|
+
// to its natural height so the cards below slide smoothly, without JS
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template-rows: minmax(0, 1fr);
|
|
57
|
+
overflow: hidden; // clip content while the row is collapsed
|
|
58
|
+
margin-bottom: var(--nice-notification-spacing, 10px);
|
|
59
|
+
pointer-events: auto;
|
|
7
60
|
border-radius: $border-radius-base;
|
|
8
61
|
cursor: pointer;
|
|
9
62
|
font-weight: normal;
|
|
10
63
|
min-width: 300px;
|
|
11
|
-
padding: 10px 15px;
|
|
12
64
|
color: $nice-notification-color;
|
|
13
65
|
background: $nice-notification-bg;
|
|
14
|
-
|
|
66
|
+
box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
|
|
67
|
+
animation: nice-notification-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
|
|
68
|
+
transition: opacity 0.2s ease;
|
|
15
69
|
|
|
70
|
+
// Leave. A keyframe animation (not a transition) so it also plays when the
|
|
71
|
+
// enter animation is interrupted. JS removes the element when it finishes,
|
|
72
|
+
// so the duration lives only here.
|
|
16
73
|
&.killed {
|
|
17
|
-
|
|
18
|
-
|
|
74
|
+
animation: nice-notification-out 0.4s ease forwards;
|
|
75
|
+
pointer-events: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@media (prefers-reduced-motion: reduce) {
|
|
79
|
+
animation-name: none;
|
|
80
|
+
|
|
81
|
+
&.killed {
|
|
82
|
+
animation: nice-notification-fade-out 0.2s ease forwards;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.notification-inner {
|
|
87
|
+
min-height: 0; // required for the 0fr collapse
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
padding: 1rem;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Icon sits left of the title/message, aligned with the first line
|
|
95
|
+
.notification-icon {
|
|
96
|
+
flex: 0 0 auto;
|
|
97
|
+
width: 20px;
|
|
98
|
+
height: 20px;
|
|
99
|
+
margin-right: 1rem;
|
|
100
|
+
flex-shrink: 0;
|
|
19
101
|
}
|
|
20
102
|
|
|
21
|
-
|
|
103
|
+
.notification-content {
|
|
104
|
+
flex: 1 1 auto;
|
|
105
|
+
min-width: 0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.notification-title {
|
|
22
109
|
display: block;
|
|
23
|
-
margin: 10px 10px 0 10px;
|
|
24
|
-
padding: 0 0 5px 0;
|
|
25
110
|
text-align: left;
|
|
26
|
-
font-size:
|
|
27
|
-
font-style: normal;
|
|
28
|
-
color: white;
|
|
111
|
+
font-size: 1em;
|
|
29
112
|
font-weight: bold;
|
|
113
|
+
margin-bottom: 3px;
|
|
30
114
|
}
|
|
31
115
|
|
|
32
116
|
& a {
|
|
@@ -37,10 +121,6 @@
|
|
|
37
121
|
}
|
|
38
122
|
}
|
|
39
123
|
|
|
40
|
-
&>.message {
|
|
41
|
-
margin: 10px 10px 10px 10px;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
124
|
&.warning {
|
|
45
125
|
color: $nice-notification-warning-color;
|
|
46
126
|
background: $nice-notification-warning-bg;
|
|
@@ -61,7 +141,7 @@
|
|
|
61
141
|
background: $nice-notification-info-bg;
|
|
62
142
|
}
|
|
63
143
|
|
|
64
|
-
&:hover {
|
|
65
|
-
opacity: 0.
|
|
144
|
+
&:hover:not(.killed) {
|
|
145
|
+
opacity: 0.85;
|
|
66
146
|
}
|
|
67
147
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<ng-form class="nice-component nice-input" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }" name="form">
|
|
1
|
+
<ng-form class="nice-component nice-percent nice-input nice-input-type-number" ng-class="{ 'margin-bottom-0' : noMargin, 'nice-component-inline': isInline }" name="form">
|
|
2
2
|
<div class="row">
|
|
3
3
|
<!------------------------- Title ------------------------->
|
|
4
4
|
<nice-title text="title || niceTitle" help="help" required="required" description="description" label-width="labelWidth"></nice-title>
|
|
@@ -6,10 +6,10 @@
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="fieldWidth ? fieldWidth : 'col-sm-8'">
|
|
8
8
|
<div class="input-group has-feedback symbol" ng-class="{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
'has-warning': !isDisabled && form.$invalid && form.$dirty && !hideValid,
|
|
10
|
+
'has-success': !isDisabled && form.$valid && form.$dirty && showValid,
|
|
11
|
+
'disabled': isDisabled
|
|
12
|
+
}">
|
|
13
13
|
<input class="form-control" type="text" max="100" min="0" ng-model="internalModel" placeholder="{{ placeholder }}" ng-required="required" ng-keypress="keypress($event)" ng-change="change()" ng-disabled="isDisabled">
|
|
14
14
|
<span class="input-group-addon">%</span>
|
|
15
15
|
<!--<span ng-if="!disabled && showValid && form.$valid && form.$dirty" class="glyphicon glyphicon-ok form-control-feedback feedback-valid" aria-hidden="true"></span>-->
|
|
@@ -59,8 +59,6 @@ angular.module('niceElements')
|
|
|
59
59
|
$scope.popper = Popper.createPopper(target, content, {
|
|
60
60
|
placement: $scope.placement,
|
|
61
61
|
strategy: $scope.strategy,
|
|
62
|
-
scroll: true,
|
|
63
|
-
resize: true,
|
|
64
62
|
modifiers: [
|
|
65
63
|
{
|
|
66
64
|
name: 'offset',
|
|
@@ -92,10 +90,17 @@ angular.module('niceElements')
|
|
|
92
90
|
});
|
|
93
91
|
};
|
|
94
92
|
|
|
95
|
-
$timeout(function () {
|
|
93
|
+
const setupTimer = $timeout(function () {
|
|
96
94
|
$scope.setupPopper();
|
|
97
95
|
});
|
|
98
96
|
|
|
97
|
+
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
98
|
+
$scope.$on('$destroy', function () {
|
|
99
|
+
$timeout.cancel(setupTimer);
|
|
100
|
+
if ($scope.popper) $scope.popper.destroy();
|
|
101
|
+
$scope.popper = null;
|
|
102
|
+
});
|
|
103
|
+
|
|
99
104
|
// -----------------------------------Open -----------------------------------
|
|
100
105
|
$scope.toggle = function () {
|
|
101
106
|
if ($scope.isOpen) {
|
|
@@ -111,11 +116,11 @@ angular.module('niceElements')
|
|
|
111
116
|
};
|
|
112
117
|
|
|
113
118
|
$scope.open = function () {
|
|
114
|
-
$scope.popper.update();
|
|
119
|
+
if ($scope.popper) $scope.popper.update();
|
|
115
120
|
$scope.isOpen = true;
|
|
116
121
|
if ($scope.onChange) $scope.onChange($scope.isOpen);
|
|
117
122
|
$timeout(function () {
|
|
118
|
-
$scope.popper.update();
|
|
123
|
+
if ($scope.popper) $scope.popper.update();
|
|
119
124
|
});
|
|
120
125
|
};
|
|
121
126
|
}
|
|
@@ -80,10 +80,17 @@ angular.module('niceElements')
|
|
|
80
80
|
});
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
$timeout(function () {
|
|
83
|
+
const setupTimer = $timeout(function () {
|
|
84
84
|
$scope.setupPopper();
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
88
|
+
$scope.$on('$destroy', function () {
|
|
89
|
+
$timeout.cancel(setupTimer);
|
|
90
|
+
if ($scope.popper) $scope.popper.destroy();
|
|
91
|
+
$scope.popper = null;
|
|
92
|
+
});
|
|
93
|
+
|
|
87
94
|
|
|
88
95
|
// ------------------- On focus -------------------
|
|
89
96
|
$scope.onFocus = function () {
|
|
@@ -121,7 +128,7 @@ angular.module('niceElements')
|
|
|
121
128
|
// if (input) input.blur();
|
|
122
129
|
|
|
123
130
|
$timeout(function () {
|
|
124
|
-
$scope.popper.update();
|
|
131
|
+
if ($scope.popper) $scope.popper.update();
|
|
125
132
|
});
|
|
126
133
|
};
|
|
127
134
|
|
|
@@ -220,8 +227,9 @@ angular.module('niceElements')
|
|
|
220
227
|
};
|
|
221
228
|
|
|
222
229
|
|
|
223
|
-
// ----------------------------------- Watch for keydown
|
|
224
|
-
|
|
230
|
+
// ----------------------------------- Watch for keydown -----------------------------------
|
|
231
|
+
// keydown only: Enter also fires keypress, which used to select the item twice
|
|
232
|
+
$element.bind("keydown", function (event) {
|
|
225
233
|
// Arrow Up
|
|
226
234
|
if (event.keyCode == 38) {
|
|
227
235
|
event.preventDefault();
|
|
@@ -252,7 +260,9 @@ angular.module('niceElements')
|
|
|
252
260
|
if (event.keyCode == 13) {
|
|
253
261
|
event.preventDefault();
|
|
254
262
|
$timeout(function () {
|
|
255
|
-
|
|
263
|
+
// Only select a result that exists (no results → no onSelect(undefined))
|
|
264
|
+
const item = $scope.results ? $scope.results[$scope.selectedIndex] : undefined;
|
|
265
|
+
if (item !== undefined) $scope.selectItem(item);
|
|
256
266
|
});
|
|
257
267
|
}
|
|
258
268
|
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<button type="button" class="nice-toggle-field" ng-click="toggle()" ng-disabled="isDisabled">
|
|
22
22
|
<div class="nice-toggle-field-handle">
|
|
23
23
|
<nice-icon ng-if="showIcons && model" icon="icon-check"></nice-icon>
|
|
24
|
-
<nice-icon ng-if="showIcons && !model" icon="icon-x"></nice-icon>
|
|
24
|
+
<!-- <nice-icon ng-if="showIcons && !model" icon="icon-x"></nice-icon> -->
|
|
25
25
|
</div>
|
|
26
26
|
</button>
|
|
27
27
|
</div>
|
|
@@ -81,9 +81,16 @@
|
|
|
81
81
|
cursor: not-allowed;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
// &:active {
|
|
85
|
+
// .nice-toggle-field-handle {
|
|
86
|
+
// transform: scale(1);
|
|
87
|
+
// }
|
|
88
|
+
// }
|
|
89
|
+
|
|
84
90
|
&:hover {
|
|
85
91
|
.nice-toggle-field-handle {
|
|
86
92
|
background: var(--nice-border-color-darker);
|
|
93
|
+
transform: scale(0.8);
|
|
87
94
|
}
|
|
88
95
|
}
|
|
89
96
|
|
|
@@ -95,7 +102,8 @@
|
|
|
95
102
|
height: 19px;
|
|
96
103
|
background: var(--nice-border-color);
|
|
97
104
|
border-radius: 50%;
|
|
98
|
-
transition: all 0.
|
|
105
|
+
transition: all 0.20s ease;
|
|
106
|
+
transform: scale(0.7);
|
|
99
107
|
|
|
100
108
|
display: flex;
|
|
101
109
|
flex-direction: column;
|
|
@@ -117,12 +125,18 @@
|
|
|
117
125
|
.nice-toggle-field-handle {
|
|
118
126
|
background: var(--nice-input-bg);
|
|
119
127
|
left: calc(100% - 22px);
|
|
128
|
+
transform: scale(1);
|
|
120
129
|
|
|
121
130
|
.nice-icon {
|
|
122
131
|
color: var(--nice-primary-color);
|
|
123
132
|
}
|
|
124
133
|
}
|
|
125
134
|
|
|
135
|
+
&:hover {
|
|
136
|
+
.nice-toggle-field-handle {
|
|
137
|
+
transform: scale(0.8);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
126
140
|
}
|
|
127
141
|
|
|
128
142
|
&.nice-toggle-success {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<div class="text text-placeholder" ng-if="dragging" translate translate-group="Nice">Drop file here</div>
|
|
15
15
|
<div class="error" ng-if="error">{{ error }}</div>
|
|
16
16
|
</div>
|
|
17
|
-
<div ng-if="imageSource" ng-transclude>
|
|
17
|
+
<div ng-if="imageSource && !(loading && uploadProgress != null)" ng-transclude>
|
|
18
18
|
<img data-ng-src="{{ imageSource }}" />
|
|
19
19
|
</div>
|
|
20
20
|
</div>
|
|
@@ -25,7 +25,8 @@ angular.module('niceElements')
|
|
|
25
25
|
|
|
26
26
|
// ------------------------- Prepare data -------------------------
|
|
27
27
|
$scope.prepareData = function() {
|
|
28
|
-
|
|
28
|
+
// data is often loaded asynchronously, so it can still be undefined/null here
|
|
29
|
+
$scope.items = Array.from($scope.data || [], (data, index) => ({
|
|
29
30
|
id: index + 1,
|
|
30
31
|
height: Number($scope.rowHeight), // Default placeholder height
|
|
31
32
|
offsetTop: index * Number($scope.rowHeight), // Approximate offset
|
|
@@ -39,6 +40,12 @@ angular.module('niceElements')
|
|
|
39
40
|
|
|
40
41
|
// ------------------------- On scroll -------------------------
|
|
41
42
|
$scope.onScroll = function() {
|
|
43
|
+
// Can run (e.g. from the ResizeObserver) before prepareData has built items
|
|
44
|
+
if (!$scope.items || $scope.items.length === 0) {
|
|
45
|
+
$scope.visibleItems = [];
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
42
49
|
const container = $element[0].getBoundingClientRect();
|
|
43
50
|
const scrollTop = $element[0].scrollTop;
|
|
44
51
|
const viewportHeight = container.height;
|
|
@@ -58,11 +65,16 @@ angular.module('niceElements')
|
|
|
58
65
|
});
|
|
59
66
|
|
|
60
67
|
// ------------------------- Watch for element resize -------------------------
|
|
61
|
-
new ResizeObserver(function() {
|
|
68
|
+
const resizeObserver = new ResizeObserver(function() {
|
|
62
69
|
$timeout(function() {
|
|
63
70
|
$scope.onScroll();
|
|
64
71
|
});
|
|
65
|
-
})
|
|
72
|
+
});
|
|
73
|
+
resizeObserver.observe($element[0]);
|
|
74
|
+
|
|
75
|
+
$scope.$on('$destroy', function () {
|
|
76
|
+
resizeObserver.disconnect();
|
|
77
|
+
});
|
|
66
78
|
|
|
67
79
|
// Initial render
|
|
68
80
|
$scope.prepareData();
|
|
@@ -18,12 +18,16 @@ angular.module('niceElements')
|
|
|
18
18
|
$scope.isOpen = value == 'true';
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
let eventHandler = null;
|
|
22
|
+
|
|
23
|
+
// Registered up front (not inside the timeout) so cleanup still happens
|
|
24
|
+
// when the element is destroyed before the listeners are attached.
|
|
25
|
+
const setupTimer = $timeout(function () {
|
|
22
26
|
// postpone linking to next digest to allow for unique id generation
|
|
23
27
|
const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
|
|
24
28
|
let fn;
|
|
25
29
|
|
|
26
|
-
function
|
|
30
|
+
eventHandler = function (e) {
|
|
27
31
|
if ($scope.isOpen) {
|
|
28
32
|
let i, element, r, id, classNames, l;
|
|
29
33
|
|
|
@@ -72,7 +76,7 @@ angular.module('niceElements')
|
|
|
72
76
|
fn($scope, { event: e });
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
|
-
}
|
|
79
|
+
};
|
|
76
80
|
|
|
77
81
|
|
|
78
82
|
// if the devices has a touchscreen, listen for this event
|
|
@@ -82,25 +86,27 @@ angular.module('niceElements')
|
|
|
82
86
|
|
|
83
87
|
// still listen for the click event even if there is touch to cater for touchscreen laptops
|
|
84
88
|
$document.on('click', eventHandler);
|
|
89
|
+
});
|
|
85
90
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
91
|
+
// when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
|
|
92
|
+
$scope.$on('$destroy', function () {
|
|
93
|
+
$timeout.cancel(setupTimer);
|
|
94
|
+
if (eventHandler) {
|
|
95
|
+
// off() is a no-op for events that were never bound, so no touch check needed
|
|
96
|
+
$document.off('touchstart', eventHandler);
|
|
92
97
|
$document.off('click', eventHandler);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* @description Private function to attempt to figure out if we are on a touch device
|
|
97
|
-
* @private
|
|
98
|
-
**/
|
|
99
|
-
function _hasTouch() {
|
|
100
|
-
// works on most browsers, IE10/11 and Surface
|
|
101
|
-
return 'ontouchstart' in window || navigator.maxTouchPoints;
|
|
98
|
+
eventHandler = null;
|
|
102
99
|
}
|
|
103
100
|
});
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @description Private function to attempt to figure out if we are on a touch device
|
|
104
|
+
* @private
|
|
105
|
+
**/
|
|
106
|
+
function _hasTouch() {
|
|
107
|
+
// works on most browsers, IE10/11 and Surface
|
|
108
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints;
|
|
109
|
+
}
|
|
104
110
|
}
|
|
105
111
|
};
|
|
106
112
|
});
|
|
@@ -10,7 +10,7 @@ angular.module('niceElements')
|
|
|
10
10
|
.directive('niceTooltip', function () {
|
|
11
11
|
return {
|
|
12
12
|
restrict: 'A',
|
|
13
|
-
controller: function ($scope, $element, $attrs, $
|
|
13
|
+
controller: function ($scope, $element, $attrs, $injector) {
|
|
14
14
|
const id = Math.random().toString(36).substring(7);
|
|
15
15
|
const showEvents = ['mouseenter', 'focus'];
|
|
16
16
|
const hideEvents = ['mouseleave', 'blur'];
|
|
@@ -22,9 +22,19 @@ angular.module('niceElements')
|
|
|
22
22
|
tooltipWindow.className = 'nice-tooltip-window';
|
|
23
23
|
tooltipWindow.id = 'nice-tooltip-window-' + id;
|
|
24
24
|
|
|
25
|
-
// Popper body
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
// Popper body. The attribute's {{ }} is interpolated by Angular, but the
|
|
26
|
+
// resulting text is never compiled, so user data can't run as a template.
|
|
27
|
+
// Safe HTML is kept when the app loads ngSanitize; otherwise it's plain text.
|
|
28
|
+
const content = document.createElement('div');
|
|
29
|
+
content.className = 'nice-tooltip-body';
|
|
30
|
+
tooltipWindow.append(content);
|
|
31
|
+
|
|
32
|
+
const $sanitize = $injector.has('$sanitize') ? $injector.get('$sanitize') : null;
|
|
33
|
+
$attrs.$observe('niceTooltip', function (value) {
|
|
34
|
+
value = value == null ? '' : String(value);
|
|
35
|
+
if ($sanitize) content.innerHTML = $sanitize(value);
|
|
36
|
+
else content.textContent = value;
|
|
37
|
+
});
|
|
28
38
|
|
|
29
39
|
// Popper arrow
|
|
30
40
|
const tooltipWindowArrow = document.createElement('div');
|