nice-elements 1.4.4 → 1.4.7
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/.vscode/settings.json +1 -1
- package/CHANGELOG.md +14 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +195 -83
- package/dist/nice.min.js +1 -1
- package/dist/style.css +46 -50
- package/dist/style.css.map +1 -1
- package/dist/style.min.css +2 -2
- package/package.json +2 -1
- package/src/components/nice-date/nice-date.html +63 -61
- package/src/components/nice-date/nice-date.js +28 -1
- package/src/components/nice-date/nice-date.scss +5 -5
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html +20 -18
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.js +23 -1
- package/src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.scss +6 -6
- package/src/components/nice-dropdown/nice-dropdown.html +18 -16
- package/src/components/nice-dropdown/nice-dropdown.js +74 -62
- package/src/components/nice-dropdown/nice-dropdown.scss +10 -12
- package/src/components/nice-search2/nice-search2.html +4 -2
- package/src/components/nice-search2/nice-search2.js +43 -0
- package/src/components/nice-search2/nice-search2.scss +4 -8
|
@@ -27,7 +27,7 @@ angular.module('niceElements')
|
|
|
27
27
|
onChange: '&?'
|
|
28
28
|
},
|
|
29
29
|
templateUrl: 'src/components/nice-datetimerange-picker-2/nice-datetimerange-picker-2.html',
|
|
30
|
-
controller: function ($
|
|
30
|
+
controller: function ($element, $scope) {
|
|
31
31
|
$scope.isOpen = false;
|
|
32
32
|
|
|
33
33
|
|
|
@@ -57,6 +57,27 @@ angular.module('niceElements')
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
// Setup popper
|
|
61
|
+
// https://popper.js.org/docs/v2/constructors/
|
|
62
|
+
$scope.setupPopper = function() {
|
|
63
|
+
var button = $element[0].getElementsByClassName('nice-daterange-picker-button')[0];
|
|
64
|
+
var tooltip = $element[0].getElementsByClassName('nice-daterange-picker-wrapper')[0];
|
|
65
|
+
$scope.popper = Popper.createPopper(button, tooltip, {
|
|
66
|
+
strategy: 'fixed',
|
|
67
|
+
placement: 'bottom-start',
|
|
68
|
+
modifiers: [
|
|
69
|
+
{
|
|
70
|
+
name: 'offset',
|
|
71
|
+
options: {
|
|
72
|
+
offset: [0, 5],
|
|
73
|
+
},
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
$scope.setupPopper();
|
|
79
|
+
|
|
80
|
+
|
|
60
81
|
$scope.format = function(){
|
|
61
82
|
$scope.modelFormat = $scope.startDate.format($scope.formatString) + " - " + $scope.endDate.format($scope.formatString);
|
|
62
83
|
};
|
|
@@ -65,6 +86,7 @@ angular.module('niceElements')
|
|
|
65
86
|
$scope.open = function() {
|
|
66
87
|
if (!$scope.isDisabled) {
|
|
67
88
|
$scope.isOpen = true;
|
|
89
|
+
$scope.popper.update();
|
|
68
90
|
}
|
|
69
91
|
};
|
|
70
92
|
|
|
@@ -19,19 +19,19 @@
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
.nice-daterange-picker-wrapper {
|
|
23
|
+
z-index: 900;
|
|
24
|
+
width: 700px;
|
|
25
|
+
max-width: 80%;
|
|
26
|
+
}
|
|
22
27
|
|
|
23
28
|
.dtp-wrapper {
|
|
24
29
|
border-radius: $nice-border-radius;
|
|
25
30
|
box-shadow: $nice-box-shadow;
|
|
26
|
-
|
|
27
|
-
margin-top: 0.5rem;
|
|
28
|
-
left: 15px;
|
|
29
|
-
top: 100%;
|
|
30
|
-
width: 700px;
|
|
31
|
+
|
|
31
32
|
padding: 15px;
|
|
32
33
|
background-color: white;
|
|
33
34
|
border: 1px solid $nice-border-color;
|
|
34
|
-
z-index: 900;
|
|
35
35
|
display: flex;
|
|
36
36
|
|
|
37
37
|
.dtp-buttons-left {
|
|
@@ -29,23 +29,25 @@
|
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
<!------------------------- Dropdown menu ------------------------->
|
|
32
|
-
<div class="
|
|
33
|
-
<div class="
|
|
34
|
-
<
|
|
35
|
-
|
|
32
|
+
<div class="nice-dropdown-menu-wrapper">
|
|
33
|
+
<div class="nice-dropdown-menu" ng-if="isOpen">
|
|
34
|
+
<div class="search-bar" ng-if="searchFunction">
|
|
35
|
+
<input ng-model="internal.search" ng-model-options="{ debounce: 500 }" ng-change="handleSearch()" placeholder="{{ searchText }}" />
|
|
36
|
+
<span class="icon"><i class="fa fa-search"></i></span>
|
|
37
|
+
</div>
|
|
38
|
+
<div class="nice-dropdown-items">
|
|
39
|
+
<div class="nice-no-data" ng-if="internalList && internalList.length == 0">{{ noDataText }}</div>
|
|
40
|
+
<div class="nice-dropdown-item null-item" ng-if="nullable && internalList.length != 0" ng-click="handleSelected(null, -1)">
|
|
41
|
+
{{ nullableText }}
|
|
42
|
+
</div>
|
|
43
|
+
<div class="nice-dropdown-item" ng-repeat="item in internalList" ng-click="handleSelected(item, $index)" ng-class="{ 'selected': item._selected, 'hover': $index == selectedIndex }">
|
|
44
|
+
<span class="choice-checkbox" ng-if="multiple"><i class="fa fa-check"></i></span>
|
|
45
|
+
<span ng-transclude="option">
|
|
46
|
+
<span ng-class="{ 'multiple-item': multiple }">{{ item[objValue] }}</span>
|
|
47
|
+
</span>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
36
50
|
</div>
|
|
37
|
-
<div class="nice-no-data" ng-if="internalList && internalList.length == 0">{{ noDataText }}</div>
|
|
38
|
-
<ul>
|
|
39
|
-
<li class="null-item" ng-if="nullable && internalList.length != 0" ng-click="handleSelected(null, -1)">
|
|
40
|
-
{{ nullableText }}
|
|
41
|
-
</li>
|
|
42
|
-
<li ng-repeat="item in internalList" ng-click="handleSelected(item, $index)" ng-class="{ 'selected': item._selected, 'hover': $index == selectedIndex }">
|
|
43
|
-
<span class="choice-checkbox" ng-if="multiple"><i class="fa fa-check"></i></span>
|
|
44
|
-
<span ng-transclude="option">
|
|
45
|
-
<span ng-class="{ 'multiple-item': multiple }">{{ item[objValue] }}</span>
|
|
46
|
-
</span>
|
|
47
|
-
</li>
|
|
48
|
-
</ul>
|
|
49
51
|
</div>
|
|
50
52
|
|
|
51
53
|
|
|
@@ -41,8 +41,7 @@ angular.module('niceElements')
|
|
|
41
41
|
selectedText: '@',
|
|
42
42
|
searchFunction: '=?',
|
|
43
43
|
isInline: '=',
|
|
44
|
-
clearOnSelect: '@'
|
|
45
|
-
positionFixed: '=' // Dropdown menu will be fixed to page
|
|
44
|
+
clearOnSelect: '@'
|
|
46
45
|
},
|
|
47
46
|
controller: function ($scope, $element, $timeout, gettextCatalog) {
|
|
48
47
|
if (!$scope.objValue) { $scope.objValue = 'value'; }
|
|
@@ -63,11 +62,49 @@ angular.module('niceElements')
|
|
|
63
62
|
$scope.isOpen = false;
|
|
64
63
|
$scope.selected = null;
|
|
65
64
|
$scope.selectedIndex = 0;
|
|
65
|
+
$scope.popper = null;
|
|
66
66
|
|
|
67
67
|
$scope.internal = {
|
|
68
68
|
search: ""
|
|
69
69
|
};
|
|
70
70
|
|
|
71
|
+
// Setup popper
|
|
72
|
+
// https://popper.js.org/docs/v2/constructors/
|
|
73
|
+
$scope.setupPopper = function() {
|
|
74
|
+
var button = $element[0].getElementsByClassName('btn-dropdown')[0];
|
|
75
|
+
var tooltip = $element[0].getElementsByClassName('nice-dropdown-menu-wrapper')[0];
|
|
76
|
+
$scope.popper = Popper.createPopper(button, tooltip, {
|
|
77
|
+
strategy: 'fixed',
|
|
78
|
+
scroll: true,
|
|
79
|
+
resize: true,
|
|
80
|
+
modifiers: [
|
|
81
|
+
{
|
|
82
|
+
name: 'offset',
|
|
83
|
+
options: {
|
|
84
|
+
offset: [0, 5],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
name: "sameWidth",
|
|
89
|
+
enabled: true,
|
|
90
|
+
phase: "beforeWrite",
|
|
91
|
+
requires: ["computeStyles"],
|
|
92
|
+
fn: function(e) {
|
|
93
|
+
var state = e.state;
|
|
94
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
95
|
+
},
|
|
96
|
+
effect: function(e) {
|
|
97
|
+
var state = e.state;
|
|
98
|
+
state.elements.popper.style.width = `${
|
|
99
|
+
state.elements.reference.offsetWidth
|
|
100
|
+
}px`;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
],
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
$scope.setupPopper();
|
|
107
|
+
|
|
71
108
|
// -----------------------------------Open -----------------------------------
|
|
72
109
|
$scope.toggle = function () {
|
|
73
110
|
if ($scope.isOpen) {
|
|
@@ -82,10 +119,10 @@ angular.module('niceElements')
|
|
|
82
119
|
};
|
|
83
120
|
|
|
84
121
|
$scope.open = function () {
|
|
85
|
-
$scope.focusInput();
|
|
86
122
|
$scope.isOpen = true;
|
|
87
|
-
|
|
88
|
-
|
|
123
|
+
$timeout(function () {
|
|
124
|
+
$scope.popper.update();
|
|
125
|
+
$scope.focusInput();
|
|
89
126
|
$scope.scrollToHover(true);
|
|
90
127
|
}, 100);
|
|
91
128
|
};
|
|
@@ -103,18 +140,18 @@ angular.module('niceElements')
|
|
|
103
140
|
|
|
104
141
|
|
|
105
142
|
// ----------------------------------- Scroll to hover -----------------------------------
|
|
106
|
-
$scope.scrollToHover = function(notSmooth) {
|
|
107
|
-
var dropdownMenu = $element[0].getElementsByClassName("dropdown-menu")[0];
|
|
108
|
-
|
|
143
|
+
$scope.scrollToHover = function (notSmooth) {
|
|
144
|
+
var dropdownMenu = $element[0].getElementsByClassName("nice-dropdown-menu")[0];
|
|
145
|
+
if (!dropdownMenu) return;
|
|
146
|
+
var dorpdownList = dropdownMenu.getElementsByClassName("nice-dropdown-items")[0];
|
|
109
147
|
var hoverItem = dorpdownList.getElementsByClassName("hover")[0];
|
|
110
|
-
if (hoverItem)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
148
|
+
if (!hoverItem) return
|
|
149
|
+
var topPos = hoverItem.offsetTop;
|
|
150
|
+
dorpdownList.scroll({
|
|
151
|
+
top: topPos - 120,
|
|
152
|
+
left: 0,
|
|
153
|
+
behavior: notSmooth ? 'auto' : 'smooth'
|
|
154
|
+
});
|
|
118
155
|
};
|
|
119
156
|
|
|
120
157
|
|
|
@@ -149,11 +186,11 @@ angular.module('niceElements')
|
|
|
149
186
|
|
|
150
187
|
|
|
151
188
|
// ----------------------------------- Handle multiple select -----------------------------------
|
|
152
|
-
$scope.handleMultipleSelect = function(item, index) {
|
|
189
|
+
$scope.handleMultipleSelect = function (item, index) {
|
|
153
190
|
if (!$scope.selected) $scope.selected = [];
|
|
154
191
|
|
|
155
|
-
if(item._selected) {
|
|
156
|
-
$scope.selected = $scope.selected.filter(function(s) {
|
|
192
|
+
if (item._selected) {
|
|
193
|
+
$scope.selected = $scope.selected.filter(function (s) {
|
|
157
194
|
return s[$scope.objKey] != item[$scope.objKey];
|
|
158
195
|
});
|
|
159
196
|
} else {
|
|
@@ -165,7 +202,7 @@ angular.module('niceElements')
|
|
|
165
202
|
|
|
166
203
|
|
|
167
204
|
// ----------------------------------- Handle single slect -----------------------------------
|
|
168
|
-
$scope.handleSingleSelect = function(item, index) {
|
|
205
|
+
$scope.handleSingleSelect = function (item, index) {
|
|
169
206
|
$scope.selected = item;
|
|
170
207
|
$scope.close();
|
|
171
208
|
$scope.handleSetModel();
|
|
@@ -173,13 +210,13 @@ angular.module('niceElements')
|
|
|
173
210
|
|
|
174
211
|
|
|
175
212
|
// ----------------------------------- Handle set model -----------------------------------
|
|
176
|
-
$scope.handleSetModel = function() {
|
|
213
|
+
$scope.handleSetModel = function () {
|
|
177
214
|
var obj = angular.copy($scope.selected);
|
|
178
215
|
|
|
179
216
|
if ($scope.selected != null) {
|
|
180
217
|
// Remove selected flag
|
|
181
218
|
if ($scope.multiple) {
|
|
182
|
-
angular.forEach(obj, function(o) {
|
|
219
|
+
angular.forEach(obj, function (o) {
|
|
183
220
|
o._selected = undefined;
|
|
184
221
|
});
|
|
185
222
|
} else {
|
|
@@ -189,7 +226,7 @@ angular.module('niceElements')
|
|
|
189
226
|
// Selected is object
|
|
190
227
|
if ($scope.selectedIsKey) {
|
|
191
228
|
if ($scope.multiple) {
|
|
192
|
-
angular.forEach(obj, function(o) {
|
|
229
|
+
angular.forEach(obj, function (o) {
|
|
193
230
|
o = o[$scope.objKey];
|
|
194
231
|
});
|
|
195
232
|
} else {
|
|
@@ -197,7 +234,7 @@ angular.module('niceElements')
|
|
|
197
234
|
}
|
|
198
235
|
}
|
|
199
236
|
}
|
|
200
|
-
|
|
237
|
+
|
|
201
238
|
if ($scope.clearOnSelect) {
|
|
202
239
|
// Clear on select
|
|
203
240
|
$scope.model = null;
|
|
@@ -214,7 +251,7 @@ angular.module('niceElements')
|
|
|
214
251
|
|
|
215
252
|
|
|
216
253
|
// ----------------------------------- Handle default -----------------------------------
|
|
217
|
-
$scope.handleDefault = function() {
|
|
254
|
+
$scope.handleDefault = function () {
|
|
218
255
|
if ($scope.model) $scope.handleModelChange();
|
|
219
256
|
if (!$scope.nullable && !$scope.model && !$scope.clearOnSelect && $scope.internalList && $scope.internalList.length > 0) {
|
|
220
257
|
$scope.handleSelected($scope.internalList[0], 0);
|
|
@@ -233,16 +270,16 @@ angular.module('niceElements')
|
|
|
233
270
|
$scope.handleModelChange();
|
|
234
271
|
});
|
|
235
272
|
|
|
236
|
-
$scope.handleModelChange = function() {
|
|
273
|
+
$scope.handleModelChange = function () {
|
|
237
274
|
$scope.selected = angular.copy($scope.model);
|
|
238
|
-
angular.forEach($scope.internalList, function(i, index) {
|
|
275
|
+
angular.forEach($scope.internalList, function (i, index) {
|
|
239
276
|
i._selected = false;
|
|
240
277
|
|
|
241
278
|
if ($scope.selectedIsKey) {
|
|
242
279
|
// Not object
|
|
243
280
|
if ($scope.multiple) {
|
|
244
281
|
// Multiple
|
|
245
|
-
angular.forEach($scope.selected, function(s) {
|
|
282
|
+
angular.forEach($scope.selected, function (s) {
|
|
246
283
|
if (i[$scope.objKey] == s) {
|
|
247
284
|
i._selected = true;
|
|
248
285
|
// $scope.selected.push(i);
|
|
@@ -257,12 +294,12 @@ angular.module('niceElements')
|
|
|
257
294
|
$scope.selectedIndex = index;
|
|
258
295
|
$scope.scrollToHover();
|
|
259
296
|
}
|
|
260
|
-
}
|
|
297
|
+
}
|
|
261
298
|
} else {
|
|
262
299
|
// Is object
|
|
263
300
|
if ($scope.multiple) {
|
|
264
301
|
// Multiple
|
|
265
|
-
angular.forEach($scope.selected, function(s) {
|
|
302
|
+
angular.forEach($scope.selected, function (s) {
|
|
266
303
|
if (i[$scope.objKey] == s[$scope.objKey]) {
|
|
267
304
|
i._selected = true;
|
|
268
305
|
// $scope.selected.push(i);
|
|
@@ -281,41 +318,16 @@ angular.module('niceElements')
|
|
|
281
318
|
}
|
|
282
319
|
});
|
|
283
320
|
}
|
|
284
|
-
|
|
285
|
-
// ----------------------------------- Handle fixed position -----------------------------------
|
|
286
|
-
if ($scope.positionFixed) {
|
|
287
|
-
$scope.dropdownButton = $element[0].getElementsByClassName('btn-dropdown')[0]
|
|
288
|
-
$scope.dropdownMenu = $element[0].getElementsByClassName('dropdown-menu')[0]
|
|
289
|
-
$scope.updateStyle = function () {
|
|
290
|
-
if (this.isOpen) {
|
|
291
|
-
var buttonPos = $scope.dropdownButton.getBoundingClientRect();
|
|
292
|
-
$scope.dropdownMenu.style.top = (buttonPos.top + buttonPos.height) + "px";
|
|
293
|
-
$scope.dropdownMenu.style.left = buttonPos.left + "px";
|
|
294
|
-
$scope.dropdownMenu.style.width = buttonPos.width + "px";
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
$scope.updateStyle();
|
|
299
|
-
|
|
300
|
-
angular.element($window).on("resize", function () {
|
|
301
|
-
$scope.updateStyle();
|
|
302
|
-
})
|
|
303
|
-
|
|
304
|
-
angular.element($window).on("scroll", function () {
|
|
305
|
-
$scope.updateStyle();
|
|
306
|
-
})
|
|
307
|
-
}
|
|
308
|
-
|
|
309
321
|
|
|
310
322
|
// ----------------------------------- Watch for keydown and keypress -----------------------------------
|
|
311
323
|
$element.bind("keydown keypress", function (event) {
|
|
312
324
|
// Arrow Up
|
|
313
325
|
if (event.keyCode == 38) {
|
|
314
326
|
event.preventDefault();
|
|
315
|
-
$timeout(function() {
|
|
316
|
-
if (
|
|
327
|
+
$timeout(function () {
|
|
328
|
+
if ($scope.selectedIndex > 0) {
|
|
317
329
|
$scope.selectedIndex -= 1;
|
|
318
|
-
$timeout(function() {
|
|
330
|
+
$timeout(function () {
|
|
319
331
|
$scope.scrollToHover();
|
|
320
332
|
});
|
|
321
333
|
}
|
|
@@ -325,10 +337,10 @@ angular.module('niceElements')
|
|
|
325
337
|
// Arrow Down
|
|
326
338
|
if (event.keyCode == 40) {
|
|
327
339
|
event.preventDefault();
|
|
328
|
-
$timeout(function() {
|
|
340
|
+
$timeout(function () {
|
|
329
341
|
if ($scope.internalList && $scope.selectedIndex < $scope.internalList.length - 1) {
|
|
330
342
|
$scope.selectedIndex += 1;
|
|
331
|
-
$timeout(function() {
|
|
343
|
+
$timeout(function () {
|
|
332
344
|
$scope.scrollToHover();
|
|
333
345
|
});
|
|
334
346
|
}
|
|
@@ -338,14 +350,14 @@ angular.module('niceElements')
|
|
|
338
350
|
// Enter
|
|
339
351
|
if (event.keyCode == 13) {
|
|
340
352
|
event.preventDefault();
|
|
341
|
-
$timeout(function() {
|
|
353
|
+
$timeout(function () {
|
|
342
354
|
$scope.handleSelected($scope.internalList[$scope.selectedIndex], $scope.selectedIndex);
|
|
343
355
|
});
|
|
344
356
|
}
|
|
345
357
|
|
|
346
358
|
// Escape
|
|
347
359
|
if (event.keyCode == 27) {
|
|
348
|
-
$timeout(function() {
|
|
360
|
+
$timeout(function () {
|
|
349
361
|
$scope.close();
|
|
350
362
|
});
|
|
351
363
|
}
|
|
@@ -13,10 +13,6 @@
|
|
|
13
13
|
border-color: $nice-focus-border !important;
|
|
14
14
|
color: $nice-font-color !important;
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
.dropdown-menu {
|
|
18
|
-
display: flex;
|
|
19
|
-
}
|
|
20
16
|
}
|
|
21
17
|
|
|
22
18
|
.not-selected {
|
|
@@ -36,20 +32,22 @@
|
|
|
36
32
|
border-radius: $nice-border-radius;
|
|
37
33
|
}
|
|
38
34
|
}
|
|
35
|
+
.nice-dropdown-menu-wrapper {
|
|
36
|
+
z-index: 1000;
|
|
37
|
+
}
|
|
39
38
|
|
|
40
|
-
.dropdown-menu {
|
|
39
|
+
.nice-dropdown-menu {
|
|
41
40
|
min-width: 200px;
|
|
42
|
-
width: 100%;
|
|
43
|
-
padding: 0;
|
|
44
41
|
max-height: 300px;
|
|
42
|
+
padding: 0;
|
|
45
43
|
border: 1px solid $nice-border-color;
|
|
46
44
|
flex-direction: column;
|
|
47
45
|
border-radius: $nice-border-radius;
|
|
48
46
|
overflow: hidden;
|
|
49
47
|
box-shadow: $nice-box-shadow;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
display: flex;
|
|
49
|
+
background: white;
|
|
50
|
+
display: flex;
|
|
53
51
|
|
|
54
52
|
.null-item {
|
|
55
53
|
color: #ccc;
|
|
@@ -94,7 +92,7 @@
|
|
|
94
92
|
color: #ccc;
|
|
95
93
|
}
|
|
96
94
|
|
|
97
|
-
|
|
95
|
+
.nice-dropdown-items {
|
|
98
96
|
overflow-y: auto;
|
|
99
97
|
overflow-x: hidden;
|
|
100
98
|
flex-grow: 1;
|
|
@@ -103,7 +101,7 @@
|
|
|
103
101
|
margin: 0;
|
|
104
102
|
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
.nice-dropdown-item {
|
|
107
105
|
padding: 10px;
|
|
108
106
|
position: relative;
|
|
109
107
|
cursor: pointer;
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
<!------------------------- Field ------------------------->
|
|
10
10
|
<div class="nice-field col-xs-12" ng-class="[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]" click-outside="close()">
|
|
11
|
-
<div class="input-group" ng-class="{ 'disabled': isDisabled, 'has-warning': !isDisabled && form.$invalid && form.$dirty, 'has-success': !isDisabled && form.$valid && form.$dirty}">
|
|
11
|
+
<div class="nice-search-button input-group" ng-class="{ 'disabled': isDisabled, 'has-warning': !isDisabled && form.$invalid && form.$dirty, 'has-success': !isDisabled && form.$valid && form.$dirty}">
|
|
12
12
|
<input
|
|
13
13
|
class="form-control"
|
|
14
14
|
type="text"
|
|
@@ -25,8 +25,10 @@
|
|
|
25
25
|
<i ng-show="!loading" class="fa fa-search"></i>
|
|
26
26
|
<i ng-show="loading" class="fa fa-refresh fa-spin"></i>
|
|
27
27
|
</span>
|
|
28
|
+
</div>
|
|
28
29
|
|
|
29
|
-
|
|
30
|
+
<div class="nice-search-dropdown-wrapper">
|
|
31
|
+
<div class="nice-search-dropdown" ng-if="showDropdown && isOpen">
|
|
30
32
|
<div class="nice-search-row nice-search-row-loading" ng-if="loading && results.length == 0">
|
|
31
33
|
<nice-loader visible-when="!loading"></nice-loader>
|
|
32
34
|
</div>
|
|
@@ -41,6 +41,42 @@ angular.module('niceElements')
|
|
|
41
41
|
|
|
42
42
|
if (!$scope.debounceTime) $scope.debounceTime = 500;
|
|
43
43
|
if (!$scope.model) $scope.model = "";
|
|
44
|
+
|
|
45
|
+
// Setup popper
|
|
46
|
+
// https://popper.js.org/docs/v2/constructors/
|
|
47
|
+
$scope.setupPopper = function() {
|
|
48
|
+
var button = $element[0].getElementsByClassName('nice-search-button')[0];
|
|
49
|
+
var tooltip = $element[0].getElementsByClassName('nice-search-dropdown-wrapper')[0];
|
|
50
|
+
$scope.popper = Popper.createPopper(button, tooltip, {
|
|
51
|
+
strategy: 'fixed',
|
|
52
|
+
placement: 'bottom-start',
|
|
53
|
+
modifiers: [
|
|
54
|
+
{
|
|
55
|
+
name: 'offset',
|
|
56
|
+
options: {
|
|
57
|
+
offset: [0, 5],
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "sameWidth",
|
|
62
|
+
enabled: true,
|
|
63
|
+
phase: "beforeWrite",
|
|
64
|
+
requires: ["computeStyles"],
|
|
65
|
+
fn: function(e) {
|
|
66
|
+
var state = e.state;
|
|
67
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
68
|
+
},
|
|
69
|
+
effect: function(e) {
|
|
70
|
+
var state = e.state;
|
|
71
|
+
state.elements.popper.style.width = `${
|
|
72
|
+
state.elements.reference.offsetWidth
|
|
73
|
+
}px`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
$scope.setupPopper();
|
|
44
80
|
|
|
45
81
|
// ------------------- On focus -------------------
|
|
46
82
|
$scope.onFocus = function() {
|
|
@@ -58,6 +94,9 @@ angular.module('niceElements')
|
|
|
58
94
|
// ------------------- On focus -------------------
|
|
59
95
|
$scope.open = function() {
|
|
60
96
|
$scope.isOpen = true;
|
|
97
|
+
$timeout(function() {
|
|
98
|
+
if ($scope.popper) $scope.popper.update();
|
|
99
|
+
});
|
|
61
100
|
};
|
|
62
101
|
|
|
63
102
|
|
|
@@ -67,6 +106,10 @@ angular.module('niceElements')
|
|
|
67
106
|
|
|
68
107
|
var input = $element[0].getElementsByTagName('input')[0];
|
|
69
108
|
if (input) input.blur();
|
|
109
|
+
|
|
110
|
+
$timeout(function() {
|
|
111
|
+
$scope.popper.update();
|
|
112
|
+
})
|
|
70
113
|
};
|
|
71
114
|
|
|
72
115
|
|
|
@@ -14,22 +14,18 @@
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.nice-dropdown {
|
|
18
|
-
position: absolute;
|
|
17
|
+
.nice-search-dropdown-wrapper {
|
|
19
18
|
z-index: 999;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.nice-search-dropdown {
|
|
23
22
|
max-height: 300px;
|
|
24
23
|
background-color: white;
|
|
25
24
|
border-radius: $nice-border-radius;
|
|
26
25
|
border: 1px solid $nice-border-color;
|
|
27
26
|
overflow-x: auto;
|
|
28
27
|
box-shadow: $nice-box-shadow;
|
|
29
|
-
margin-top: .5rem;
|
|
30
|
-
margin-bottom: 2rem;
|
|
31
28
|
|
|
32
|
-
|
|
33
29
|
.nice-search-row {
|
|
34
30
|
padding: 10px 15px;
|
|
35
31
|
z-index: 1000;
|