nice-elements 1.15.1 → 1.16.0
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 +14 -0
- package/CLAUDE.md +1 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +573 -468
- package/dist/nice.min.js +1 -1
- package/dist/style.css +122 -104
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +2 -2
- package/package.json +5 -6
- package/src/components/nice-calendar/nice-calendar.html +3 -4
- package/src/components/nice-calendar/nice-calendar.scss +0 -9
- package/src/components/nice-date/nice-date-picker.html +60 -0
- package/src/components/nice-date/nice-date.html +29 -86
- package/src/components/nice-date/nice-date.js +7 -35
- package/src/components/nice-date/nice-date.scss +6 -15
- package/src/components/nice-datetime-picker/nice-datetime-picker.html +1 -4
- package/src/components/nice-datetime-picker/nice-datetime-picker.scss +9 -12
- package/src/components/nice-datetimerange-picker/nice-datetimerange-picker.html +1 -3
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +32 -30
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +1 -33
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +7 -12
- package/src/components/nice-dropdown/nice-dropdown.html +42 -40
- package/src/components/nice-dropdown/nice-dropdown.js +52 -54
- package/src/components/nice-dropdown/nice-dropdown.scss +25 -4
- package/src/components/nice-dropdown-old/nice-dropdown-old.html +1 -1
- package/src/components/nice-dropdown-old/nice-dropdown-old.scss +8 -2
- package/src/components/nice-dtp/nice-dtp.html +7 -7
- package/src/components/nice-options/nice-options.scss +4 -0
- package/src/components/nice-popup/nice-popup.html +4 -4
- package/src/components/nice-popup/nice-popup.js +61 -75
- package/src/components/nice-popup/nice-popup.scss +10 -31
- package/src/components/nice-search/nice-search.html +0 -3
- package/src/components/nice-search2/nice-search2.html +22 -18
- package/src/components/nice-search2/nice-search2.js +1 -56
- package/src/components/nice-search2/nice-search2.scss +3 -2
- package/src/components/nice-svgs/nice-svgs.html +8 -0
- package/src/components/nice-time-picker/nice-time-picker.html +1 -3
- package/src/components/nice-time-picker/nice-time-picker.scss +0 -8
- package/src/directives/nice-tooltip/_nice-tooltip.scss +7 -28
- package/src/directives/nice-tooltip/nice-tooltip.js +16 -29
- package/src/services/nice-service.js +236 -1
- package/src/styles/_nice-anchored.scss +75 -0
- package/src/styles/_nice.scss +1 -0
|
@@ -6,50 +6,52 @@
|
|
|
6
6
|
<!------------------------- Field ------------------------->
|
|
7
7
|
<div class="nice-field col-xs-12" ng-class="[ fieldWidth ? fieldWidth : 'col-sm-8', { 'open': isOpen, 'nice-disabled': isDisabled || emptyList } ]" click-outside="close()" is-open="{{ isOpen }}">
|
|
8
8
|
<div class="nice-field-wrapper">
|
|
9
|
-
<!------------------------- Button ------------------------->
|
|
10
|
-
<
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
<!------------------------- Button + menu ------------------------->
|
|
10
|
+
<nice-popup trigger="manual" is-open="isOpen" placement="{{ placement }}" offset-distance="{{ dropdownDistance }}" same-width="true">
|
|
11
|
+
<nice-popup-target>
|
|
12
|
+
<button type="button" class="btn btn-dropdown" type="button" ng-ref="dropdown-button" ng-click="toggle()" ng-disabled="isDisabled || emptyList" aria-expanded="{{ isOpen }}" aria-haspopup="true" aria-controls="menu" id="nice-dropdown-{{ id }}">
|
|
13
|
+
<input class="hidden-input" ng-model="model" ng-required="required" ng-disabled="disabled" tabindex="-1" />
|
|
14
|
+
<div class="btn-dropdown-inside" ng-transclude="button" ng-if="selected != null">
|
|
15
|
+
<span ng-if="!multiple">{{ selected[objValue] }}</span>
|
|
16
|
+
<span ng-if="multiple" class="multiple-selected" ng-class="{ 'has-more': selected.length > maxSelectedShown }">
|
|
17
|
+
<span ng-if="selected.length > 0" class="multiple-selected-values"><span ng-repeat="item in selected | limitTo: maxSelectedShown">{{ item[objValue] }}{{ $last ? '' : ', ' }}</span></span>
|
|
18
|
+
<span ng-if="selected.length > maxSelectedShown" class="multiple-selected-more">+{{ selected.length - maxSelectedShown }} {{ moreText }}</span>
|
|
19
|
+
<span ng-if="selected.length == 0" class="not-selected">{{ nullableText }}</span>
|
|
20
|
+
</span>
|
|
21
|
+
</div>
|
|
20
22
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<span class="caret" ng-show="!loading"></span>
|
|
24
|
-
<nice-loader ng-if="loading"></nice-loader>
|
|
25
|
-
</button>
|
|
23
|
+
<div class="not-selected" ng-if="selected == null">{{ selectText }}</div>
|
|
26
24
|
|
|
25
|
+
<span class="caret" ng-show="!loading"></span>
|
|
26
|
+
<nice-loader ng-if="loading"></nice-loader>
|
|
27
|
+
</button>
|
|
28
|
+
</nice-popup-target>
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
</
|
|
30
|
+
<nice-popup-content>
|
|
31
|
+
<div class="nice-dropdown-menu" ng-if="isOpen">
|
|
32
|
+
<div class="search-bar" ng-if="!noSearch && searchFunction">
|
|
33
|
+
<input class="search-bar-input" ng-model="internal.search" ng-model-options="{ debounce: 500 }" ng-change="handleSearch()" placeholder="{{ searchText }}" />
|
|
34
|
+
<div class="count" ng-if="internalList && internalList._metadata && enableLoadMore">{{ internalList.length }}/{{ internalList._metadata.count }}</div>
|
|
35
|
+
<nice-icon ng-if="!internal.search" class="icon" icon="icon-search"></nice-icon>
|
|
36
|
+
<nice-icon ng-if="internal.search" class="icon" icon="icon-x" ng-click="clearSearch()"></nice-icon>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="nice-dropdown-actions" ng-if="multiple">
|
|
39
|
+
<button type="button" class="btn btn-default btn-sm" ng-click="selectAll()" translate translate-context="Nice">All</button>
|
|
40
|
+
<button type="button" class="btn btn-default btn-sm" ng-click="selectNone()">{{ nullableText }}</button>
|
|
41
|
+
</div>
|
|
42
|
+
<div class="nice-dropdown-items" aria-labelledby="nice-dropdown-{{ id }}" role="listbox">
|
|
43
|
+
<div role="none" type="button" class="nice-no-data" ng-if="internalList && internalList.length == 0">{{ noDataText }}</div>
|
|
44
|
+
<button type="button" role="option" class="nice-dropdown-item null-item" ng-if="!multiple && nullable && internalList.length != 0" ng-click="handleSelected(null, -1)" ng-disabled="isDisabled">
|
|
45
|
+
{{ nullableText }}
|
|
46
|
+
</button>
|
|
47
|
+
<button type="button" role="option" class="nice-dropdown-item" ng-repeat="item in internalList" ng-click="handleSelected(item, $index)" ng-class="{ 'selected': item._selected }" ng-disabled="isDisabled">
|
|
48
|
+
<div class="choice-checkbox" ng-if="multiple" role="menuitemcheckbox"><nice-icon icon="icon-check"></nice-icon></div>
|
|
49
|
+
<div class="choice-option" ng-transclude="option" ng-class="{ 'multiple-item': multiple }">{{ item[objValue] }}</div>
|
|
50
|
+
</button>
|
|
51
|
+
</div>
|
|
50
52
|
</div>
|
|
51
|
-
</
|
|
52
|
-
</
|
|
53
|
+
</nice-popup-content>
|
|
54
|
+
</nice-popup>
|
|
53
55
|
|
|
54
56
|
|
|
55
57
|
<!------------------------- Add button ------------------------->
|
|
@@ -51,12 +51,13 @@ angular.module('niceElements')
|
|
|
51
51
|
dropdownDistance: '@',
|
|
52
52
|
searchFunction: '=?',
|
|
53
53
|
filterFunction: '=?',
|
|
54
|
+
selectedFunction: '=?', // Loads selected options missing from the list: function(keys) → promise of objects
|
|
54
55
|
isInline: '=',
|
|
55
56
|
clearOnSelect: '@',
|
|
56
57
|
enableLoadMore: '@', // Enable load more
|
|
57
|
-
placement: '@', //
|
|
58
|
+
placement: '@', // Preferred placement of the menu
|
|
58
59
|
},
|
|
59
|
-
controller: function ($scope, $attrs, $http, $element, $timeout, gettextCatalog, NiceService) {
|
|
60
|
+
controller: function ($scope, $attrs, $http, $q, $element, $timeout, gettextCatalog, NiceService) {
|
|
60
61
|
NiceService.bindFlag($scope, $attrs, 'selectedIsKey');
|
|
61
62
|
NiceService.bindFlag($scope, $attrs, 'enableLoadMore');
|
|
62
63
|
|
|
@@ -81,7 +82,6 @@ angular.module('niceElements')
|
|
|
81
82
|
$scope.isOpen = false;
|
|
82
83
|
$scope.selected = null;
|
|
83
84
|
// $scope.selectedIndex = 0;
|
|
84
|
-
$scope.popper = null;
|
|
85
85
|
|
|
86
86
|
$scope.internal = {
|
|
87
87
|
search: ""
|
|
@@ -91,52 +91,9 @@ angular.module('niceElements')
|
|
|
91
91
|
$scope.originalList = angular.copy($scope.list);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
//
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const button = $element[0].getElementsByClassName('btn-dropdown')[0];
|
|
98
|
-
const tooltip = $element[0].getElementsByClassName('nice-dropdown-menu-wrapper')[0];
|
|
99
|
-
$scope.popper = Popper.createPopper(button, tooltip, {
|
|
100
|
-
strategy: 'fixed',
|
|
101
|
-
placement: $scope.placement,
|
|
102
|
-
modifiers: [
|
|
103
|
-
{
|
|
104
|
-
name: 'offset',
|
|
105
|
-
options: {
|
|
106
|
-
offset: [0, $scope.dropdownDistance],
|
|
107
|
-
},
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
name: "sameWidth",
|
|
111
|
-
enabled: true,
|
|
112
|
-
phase: "beforeWrite",
|
|
113
|
-
requires: ["computeStyles"],
|
|
114
|
-
fn: function (e) {
|
|
115
|
-
const state = e.state;
|
|
116
|
-
let width = state.rects.reference.width;
|
|
117
|
-
if (width < 200) width = 200;
|
|
118
|
-
state.styles.popper.width = width + "px";
|
|
119
|
-
},
|
|
120
|
-
effect: function (e) {
|
|
121
|
-
const state = e.state;
|
|
122
|
-
let width = state.elements.reference.width;
|
|
123
|
-
if (width < 200) width = 200;
|
|
124
|
-
state.elements.popper.style.width = width + "px";
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
],
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
const setupTimer = $timeout(function () {
|
|
132
|
-
$scope.setupPopper();
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
136
|
-
$scope.$on('$destroy', function () {
|
|
137
|
-
$timeout.cancel(setupTimer);
|
|
138
|
-
if ($scope.popper) $scope.popper.destroy();
|
|
139
|
-
$scope.popper = null;
|
|
94
|
+
// The menu is a nice-popup (positioning, Escape); on-close fires on every close
|
|
95
|
+
$scope.$watch('isOpen', function (isOpen, wasOpen) {
|
|
96
|
+
if (wasOpen && !isOpen && $scope.onClose) $scope.onClose();
|
|
140
97
|
});
|
|
141
98
|
|
|
142
99
|
|
|
@@ -151,18 +108,13 @@ angular.module('niceElements')
|
|
|
151
108
|
|
|
152
109
|
$scope.close = function () {
|
|
153
110
|
$scope.isOpen = false;
|
|
154
|
-
if ($scope.onClose) $scope.onClose();
|
|
155
111
|
};
|
|
156
112
|
|
|
157
113
|
$scope.open = function () {
|
|
158
|
-
if ($scope.popper) $scope.popper.update();
|
|
159
114
|
if ($scope.filterFunction) $scope.internalList = $scope.filterFunction($scope.originalList, $scope.model);
|
|
160
115
|
$timeout(function () {
|
|
161
116
|
$scope.isOpen = true;
|
|
162
117
|
if ($scope.onOpen) $scope.onOpen();
|
|
163
|
-
$timeout(function () {
|
|
164
|
-
if ($scope.popper) $scope.popper.update();
|
|
165
|
-
});
|
|
166
118
|
});
|
|
167
119
|
$timeout(function () {
|
|
168
120
|
$scope.focusInput();
|
|
@@ -408,10 +360,17 @@ angular.module('niceElements')
|
|
|
408
360
|
$scope.handleModelChange();
|
|
409
361
|
});
|
|
410
362
|
|
|
363
|
+
// Options seen so far by key (lists, search results, loaded with selected-function),
|
|
364
|
+
// so selected keys keep their label when they are not in the current list
|
|
365
|
+
const knownItems = {};
|
|
366
|
+
// Keys already passed to selected-function (load each one only once)
|
|
367
|
+
const requestedKeys = {};
|
|
368
|
+
|
|
411
369
|
$scope.handleModelChange = function () {
|
|
412
370
|
$scope.selected = angular.copy($scope.model);
|
|
413
371
|
angular.forEach($scope.internalList, function (i, index) {
|
|
414
372
|
i._selected = false;
|
|
373
|
+
knownItems[i[$scope.objKey]] = i;
|
|
415
374
|
|
|
416
375
|
if ($scope.selectedIsKey) {
|
|
417
376
|
// Not object
|
|
@@ -457,10 +416,49 @@ angular.module('niceElements')
|
|
|
457
416
|
}
|
|
458
417
|
});
|
|
459
418
|
|
|
419
|
+
// Selected keys that are not in the list are still raw keys here
|
|
420
|
+
if ($scope.selectedIsKey && $scope.selected != null) {
|
|
421
|
+
if ($scope.multiple) $scope.selected = $scope.selected.map($scope.resolveKey);
|
|
422
|
+
else $scope.selected = $scope.resolveKey($scope.selected);
|
|
423
|
+
$scope.loadMissingSelected();
|
|
424
|
+
}
|
|
425
|
+
|
|
460
426
|
// Handle required
|
|
461
427
|
$timeout($scope.checkRequired);
|
|
462
428
|
}
|
|
463
429
|
|
|
430
|
+
// ----------------------------------- Selected keys missing from the list -----------------------------------
|
|
431
|
+
// Turn a selected key into an option: one from the list, one seen before,
|
|
432
|
+
// or a placeholder that shows the key (until selected-function loads it)
|
|
433
|
+
$scope.resolveKey = function (key) {
|
|
434
|
+
if (angular.isObject(key)) return key; // already an option from the list
|
|
435
|
+
if (knownItems[key]) return knownItems[key];
|
|
436
|
+
const placeholder = { _missing: true };
|
|
437
|
+
placeholder[$scope.objKey] = key;
|
|
438
|
+
placeholder[$scope.objValue] = String(key);
|
|
439
|
+
return placeholder;
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
// Ask selected-function for the options of placeholder keys, then show them
|
|
443
|
+
$scope.loadMissingSelected = function () {
|
|
444
|
+
if (!$scope.selectedFunction) return;
|
|
445
|
+
const selected = $scope.multiple ? $scope.selected : [$scope.selected];
|
|
446
|
+
const keys = selected.filter(function (s) {
|
|
447
|
+
return s._missing && !requestedKeys[s[$scope.objKey]];
|
|
448
|
+
}).map(function (s) {
|
|
449
|
+
return s[$scope.objKey];
|
|
450
|
+
});
|
|
451
|
+
if (keys.length == 0) return;
|
|
452
|
+
|
|
453
|
+
keys.forEach(function (key) { requestedKeys[key] = true; });
|
|
454
|
+
$q.when($scope.selectedFunction(keys)).then(function (items) {
|
|
455
|
+
angular.forEach(items, function (item) {
|
|
456
|
+
knownItems[item[$scope.objKey]] = item;
|
|
457
|
+
});
|
|
458
|
+
$scope.handleModelChange();
|
|
459
|
+
});
|
|
460
|
+
};
|
|
461
|
+
|
|
464
462
|
// ----------------------------------- Required -----------------------------------
|
|
465
463
|
// Form is invalid when required and nothing is selected
|
|
466
464
|
$scope.checkRequired = function () {
|
|
@@ -32,8 +32,23 @@
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
// Menu is a nice-popup, as wide as the button but at least 200px.
|
|
36
|
+
// The <nice-popup> element is the flex item next to the add button.
|
|
37
|
+
nice-popup {
|
|
38
|
+
flex-grow: 1;
|
|
39
|
+
min-width: 0;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.nice-popup-target {
|
|
43
|
+
display: block;
|
|
44
|
+
|
|
45
|
+
.btn-dropdown {
|
|
46
|
+
width: 100%;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.nice-popup-content {
|
|
51
|
+
min-width: 200px;
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
.nice-dropdown-menu {
|
|
@@ -138,14 +153,20 @@
|
|
|
138
153
|
transition: all 0.2s;
|
|
139
154
|
background: $nice-choice-bg;
|
|
140
155
|
color: $nice-choice-bg;
|
|
141
|
-
line-height: 22px;
|
|
142
156
|
width: 25px;
|
|
143
157
|
height: 25px;
|
|
144
158
|
border: 1px solid $nice-border-color;
|
|
145
159
|
margin-right: 1rem;
|
|
146
160
|
border-radius: $nice-border-radius;
|
|
147
|
-
|
|
161
|
+
display: flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
148
164
|
flex-shrink: 0;
|
|
165
|
+
|
|
166
|
+
.nice-icon {
|
|
167
|
+
width: 16px;
|
|
168
|
+
height: 16px;
|
|
169
|
+
}
|
|
149
170
|
}
|
|
150
171
|
|
|
151
172
|
.choice-option {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<ul id="{{id}}" class="dropdown-menu" role="menu">
|
|
26
26
|
<li id="{{id}}-{{$index}}" ng-repeat="item in internalList" ng-click="clicked(item)">
|
|
27
27
|
<a href>
|
|
28
|
-
<span class="choice-checkbox" ng-if="multiple" ng-class="{ 'selected' : isItemSelected(item) }"><
|
|
28
|
+
<span class="choice-checkbox" ng-if="multiple" ng-class="{ 'selected' : isItemSelected(item) }"><nice-icon icon="icon-check"></nice-icon></span>
|
|
29
29
|
<span ng-if="item.color_hex_code" class="dropdown-color" ng-style="{'background': item.color_hex_code}"></span>
|
|
30
30
|
<span ng-class="{'multiple-item': multiple}">{{ getLabel(item) }}</span>
|
|
31
31
|
<!--<span ng-if="showTax && item.value">{{ item.value * 100 }}%</span>-->
|
|
@@ -43,13 +43,19 @@
|
|
|
43
43
|
|
|
44
44
|
background: $nice-choice-bg;
|
|
45
45
|
color: $nice-choice-bg;
|
|
46
|
-
line-height: 22px;
|
|
47
46
|
width: 25px;
|
|
48
47
|
height: 25px;
|
|
49
48
|
border: 2px solid $nice-border-color;
|
|
50
49
|
position: absolute;
|
|
51
50
|
border-radius: 2px;
|
|
52
|
-
|
|
51
|
+
display: flex;
|
|
52
|
+
align-items: center;
|
|
53
|
+
justify-content: center;
|
|
54
|
+
|
|
55
|
+
.nice-icon {
|
|
56
|
+
width: 16px;
|
|
57
|
+
height: 16px;
|
|
58
|
+
}
|
|
53
59
|
|
|
54
60
|
&.selected {
|
|
55
61
|
border-color: $nice-choice-selected-bg;
|
|
@@ -4,27 +4,27 @@
|
|
|
4
4
|
<div class="dtp-date-view">
|
|
5
5
|
<div class="dtp-header" ng-if="!inline">
|
|
6
6
|
<div class="dtp-actual-day">{{actualDay}}</div>
|
|
7
|
-
<div class="dtp-close" ng-if="!inline"><a href="javascript:void(0);" ng-click="onCloseClick()"><
|
|
7
|
+
<div class="dtp-close" ng-if="!inline"><a href="javascript:void(0);" ng-click="onCloseClick()"><nice-icon icon="icon-x"></nice-icon></a></div>
|
|
8
8
|
</div>
|
|
9
9
|
<div class="dtp-date" ng-if="!inline" ng-class="{'hidden': !showDateHeader}">
|
|
10
10
|
<div>
|
|
11
11
|
<div class="left center p10">
|
|
12
|
-
<a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><
|
|
12
|
+
<a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><nice-icon icon="icon-chevron-left"></nice-icon></a>
|
|
13
13
|
</div>
|
|
14
14
|
<div class="dtp-actual-month p80" ng-click="initDate()">{{actualMonth}}</div>
|
|
15
15
|
<div class="right center p10">
|
|
16
|
-
<a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><
|
|
16
|
+
<a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><nice-icon icon="icon-chevron-right"></nice-icon></a>
|
|
17
17
|
</div>
|
|
18
18
|
<div class="clearfix"></div>
|
|
19
19
|
</div>
|
|
20
20
|
<div class="dtp-actual-num" ng-click="initDate()">{{actualNum}}</div>
|
|
21
21
|
<div>
|
|
22
22
|
<div class="left center p10">
|
|
23
|
-
<a href="javascript:void(0);" class="dtp-select-year-before" ng-click="onYearBeforeClick()" ng-class="{'disabled': !btnYearBeforeEnabled}"
|
|
23
|
+
<a href="javascript:void(0);" class="dtp-select-year-before" ng-click="onYearBeforeClick()" ng-class="{'disabled': !btnYearBeforeEnabled}"><nice-icon icon="icon-chevron-left"></nice-icon></a>
|
|
24
24
|
</div>
|
|
25
25
|
<div class="dtp-actual-year p80" ng-click="initDate()">{{actualYear}}</div>
|
|
26
26
|
<div class="right center p10">
|
|
27
|
-
<a href="javascript:void(0);" class="dtp-select-year-after" ng-click="onYearAfterClick()" ng-class="{'disabled': !btnYearAfterEnabled}"><
|
|
27
|
+
<a href="javascript:void(0);" class="dtp-select-year-after" ng-click="onYearAfterClick()" ng-class="{'disabled': !btnYearAfterEnabled}"><nice-icon icon="icon-chevron-right"></nice-icon></a>
|
|
28
28
|
</div>
|
|
29
29
|
<div class="clearfix"></div>
|
|
30
30
|
</div>
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
<div class="dtp-picker-calendar" ng-class="{'hidden': !showCalendar}">
|
|
39
39
|
<div>
|
|
40
40
|
<div ng-if="inline" class="left center p10">
|
|
41
|
-
<a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><
|
|
41
|
+
<a href="javascript:void(0);" class="dtp-select-month-before" ng-click="onMonthBeforeClick()" ng-class="{'disabled': !btnMonthBeforeEnabled}"><nice-icon icon="icon-chevron-left"></nice-icon></a>
|
|
42
42
|
</div>
|
|
43
43
|
<div class="dtp-picker-month" ng-class="{'p80': inline}">{{monthAndYear}}</div>
|
|
44
44
|
<div class="right center p10" ng-if="inline">
|
|
45
|
-
<a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><
|
|
45
|
+
<a href="javascript:void(0);" class="dtp-select-month-after" ng-click="onMonthAfterClick()" ng-class="{'disabled': !btnMonthAfterEnabled}"><nice-icon icon="icon-chevron-right"></nice-icon></a>
|
|
46
46
|
</div>
|
|
47
47
|
</div>
|
|
48
48
|
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
display: flex;
|
|
12
12
|
flex-direction: column;
|
|
13
13
|
gap: 3px;
|
|
14
|
+
// Text wraps inside the cell (.btn is nowrap), also in transcluded content
|
|
15
|
+
white-space: normal;
|
|
16
|
+
overflow-wrap: anywhere;
|
|
17
|
+
min-width: 0;
|
|
14
18
|
|
|
15
19
|
.nice-options-wrapper-icon {
|
|
16
20
|
height: 20px;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
<div class="nice-popup" click-outside="
|
|
2
|
-
<div class="nice-popup-target" ng-transclude="target" ng-click="
|
|
1
|
+
<div class="nice-popup" click-outside="clickedOutside()">
|
|
2
|
+
<div class="nice-popup-target" ng-transclude="target" ng-click="targetClicked()"></div>
|
|
3
3
|
<div class="nice-popup-content">
|
|
4
|
-
<div class="nice-popup-arrow"
|
|
4
|
+
<div class="nice-popup-arrow" ng-show="isOpen && showArrow"></div>
|
|
5
5
|
<div ng-transclude="content" ng-if="isOpen"></div>
|
|
6
6
|
</div>
|
|
7
|
-
</div>
|
|
7
|
+
</div>
|
|
@@ -5,6 +5,12 @@
|
|
|
5
5
|
* @name niceElements.directive:nicePopup
|
|
6
6
|
* @description
|
|
7
7
|
* # nicePopup
|
|
8
|
+
* Shows content next to a target. Positioned with NiceService.anchor()
|
|
9
|
+
* (native popover + CSS anchor positioning, Popper fallback).
|
|
10
|
+
*
|
|
11
|
+
* trigger="click" (default): clicking the target toggles it, clicking outside closes it.
|
|
12
|
+
* trigger="manual": the parent opens and closes it through is-open.
|
|
13
|
+
* Escape always closes it (also in "manual", is-open is set to false).
|
|
8
14
|
*/
|
|
9
15
|
angular.module('niceElements')
|
|
10
16
|
.directive('nicePopup', function () {
|
|
@@ -16,92 +22,69 @@ angular.module('niceElements')
|
|
|
16
22
|
'content': '?nicePopupContent'
|
|
17
23
|
},
|
|
18
24
|
scope: {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
25
|
+
isOpen: '=?', // two-way open state
|
|
26
|
+
trigger: '@', // "click" (default) or "manual"
|
|
27
|
+
offsetDistance: '@', // gap in px between the target and the content
|
|
28
|
+
offsetSkidding: '@', // shift in px along the target
|
|
29
|
+
placement: '@', // preferred placement, e.g. "bottom-start"
|
|
30
|
+
strategy: '@', // Popper strategy (fallback only)
|
|
23
31
|
showArrow: '@',
|
|
32
|
+
sameWidth: '@', // content as wide as the target
|
|
24
33
|
onChange: '&?',
|
|
25
34
|
},
|
|
26
|
-
controller: function ($scope, $element, $timeout) {
|
|
27
|
-
$scope
|
|
28
|
-
|
|
29
|
-
if (!$scope.
|
|
30
|
-
if (!$scope.
|
|
31
|
-
if (!$scope.offsetSkidding) { $scope.offsetSkidding = 0; }
|
|
35
|
+
controller: function ($scope, $element, $attrs, $timeout, NiceService) {
|
|
36
|
+
NiceService.bindFlag($scope, $attrs, 'showArrow');
|
|
37
|
+
NiceService.bindFlag($scope, $attrs, 'sameWidth');
|
|
38
|
+
if (!$scope.isOpen) { $scope.isOpen = false; }
|
|
39
|
+
if (!$scope.trigger) { $scope.trigger = "click"; }
|
|
32
40
|
if (!$scope.placement) { $scope.placement = "auto"; }
|
|
33
|
-
if (!$scope.
|
|
41
|
+
if (!$scope.offsetDistance) { $scope.offsetDistance = $scope.showArrow ? 8 : 5; }
|
|
42
|
+
if (!$scope.offsetSkidding) { $scope.offsetSkidding = 0; }
|
|
34
43
|
|
|
35
|
-
// Placements
|
|
36
|
-
//
|
|
37
|
-
// 'auto',
|
|
38
|
-
// 'auto-start',
|
|
39
|
-
// 'auto-end',
|
|
40
|
-
// 'top',
|
|
41
|
-
// 'top-start',
|
|
42
|
-
// 'top-end',
|
|
43
|
-
// 'bottom',
|
|
44
|
-
// 'bottom-start',
|
|
45
|
-
// 'bottom-end',
|
|
46
|
-
// 'right',
|
|
47
|
-
// 'right-start',
|
|
48
|
-
// 'right-end',
|
|
49
|
-
// 'left',
|
|
50
|
-
// 'left-start',
|
|
51
|
-
// 'left-end'
|
|
52
|
-
// ]
|
|
44
|
+
// Placements: auto, auto-start, auto-end, top, top-start, top-end, bottom, bottom-start,
|
|
45
|
+
// bottom-end, right, right-start, right-end, left, left-start, left-end
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
let anchored = null;
|
|
48
|
+
|
|
49
|
+
// Template is in the DOM after the first digest
|
|
50
|
+
const setupTimer = $timeout(function () {
|
|
57
51
|
const target = $element[0].getElementsByClassName('nice-popup-target')[0];
|
|
58
52
|
const content = $element[0].getElementsByClassName('nice-popup-content')[0];
|
|
59
|
-
|
|
53
|
+
const arrow = $element[0].getElementsByClassName('nice-popup-arrow')[0];
|
|
54
|
+
anchored = NiceService.anchor(target, content, {
|
|
60
55
|
placement: $scope.placement,
|
|
56
|
+
offset: parseInt($scope.offsetDistance),
|
|
57
|
+
skidding: parseInt($scope.offsetSkidding),
|
|
58
|
+
sameWidth: $scope.sameWidth,
|
|
61
59
|
strategy: $scope.strategy,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
offset: [$scope.offsetSkidding, $scope.offsetDistance],
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
name: 'arrow',
|
|
71
|
-
options: {
|
|
72
|
-
padding: 5, // 5px from the edges of the popper
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
// {
|
|
76
|
-
// name: "sameWidth",
|
|
77
|
-
// enabled: true,
|
|
78
|
-
// phase: "beforeWrite",
|
|
79
|
-
// requires: ["computeStyles"],
|
|
80
|
-
// fn: function (e) {
|
|
81
|
-
// var state = e.state;
|
|
82
|
-
// state.styles.popper.width = state.rects.reference.width + "px";
|
|
83
|
-
// },
|
|
84
|
-
// effect: function (e) {
|
|
85
|
-
// var state = e.state;
|
|
86
|
-
// state.elements.popper.style.width = state.elements.reference.offsetWidth + "px";
|
|
87
|
-
// }
|
|
88
|
-
// }
|
|
89
|
-
],
|
|
60
|
+
arrow: arrow,
|
|
61
|
+
onEscape: function () {
|
|
62
|
+
$timeout(function () { $scope.close(); });
|
|
63
|
+
}
|
|
90
64
|
});
|
|
91
|
-
|
|
65
|
+
if ($scope.isOpen) anchored.open();
|
|
66
|
+
});
|
|
92
67
|
|
|
93
|
-
|
|
94
|
-
|
|
68
|
+
// Show or hide the content when the state changes
|
|
69
|
+
$scope.$watch('isOpen', function (isOpen, wasOpen) {
|
|
70
|
+
if (!anchored) return;
|
|
71
|
+
if (isOpen) {
|
|
72
|
+
anchored.open();
|
|
73
|
+
// Content is rendered with ng-if, update once it's there
|
|
74
|
+
$timeout(function () { if (anchored) anchored.update(); });
|
|
75
|
+
} else {
|
|
76
|
+
anchored.close();
|
|
77
|
+
}
|
|
78
|
+
if (isOpen !== wasOpen && $scope.onChange) $scope.onChange({ isOpen: isOpen });
|
|
95
79
|
});
|
|
96
80
|
|
|
97
|
-
// Popper adds scroll/resize listeners to window; remove them with the component
|
|
98
81
|
$scope.$on('$destroy', function () {
|
|
99
82
|
$timeout.cancel(setupTimer);
|
|
100
|
-
if (
|
|
101
|
-
|
|
83
|
+
if (anchored) anchored.destroy();
|
|
84
|
+
anchored = null;
|
|
102
85
|
});
|
|
103
86
|
|
|
104
|
-
// -----------------------------------Open -----------------------------------
|
|
87
|
+
// ----------------------------------- Open -----------------------------------
|
|
105
88
|
$scope.toggle = function () {
|
|
106
89
|
if ($scope.isOpen) {
|
|
107
90
|
$scope.close();
|
|
@@ -112,17 +95,20 @@ angular.module('niceElements')
|
|
|
112
95
|
|
|
113
96
|
$scope.close = function () {
|
|
114
97
|
$scope.isOpen = false;
|
|
115
|
-
if ($scope.onChange) $scope.onChange({ isOpen: $scope.isOpen });
|
|
116
98
|
};
|
|
117
99
|
|
|
118
100
|
$scope.open = function () {
|
|
119
|
-
if ($scope.popper) $scope.popper.update();
|
|
120
101
|
$scope.isOpen = true;
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Click on target / outside only does something in "click" mode
|
|
105
|
+
$scope.targetClicked = function () {
|
|
106
|
+
if ($scope.trigger != 'manual') $scope.toggle();
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
$scope.clickedOutside = function () {
|
|
110
|
+
if ($scope.trigger != 'manual') $scope.close();
|
|
125
111
|
};
|
|
126
112
|
}
|
|
127
113
|
};
|
|
128
|
-
});
|
|
114
|
+
});
|