nice-elements 1.4.4 → 1.4.5
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 +5 -0
- package/README.md +1 -1
- package/bower.json +1 -1
- package/dist/nice.js +183 -83
- package/dist/nice.min.js +1 -1
- package/dist/style.css +44 -49
- 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 +23 -1
- package/src/components/nice-date/nice-date.scss +4 -4
- 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 +5 -6
- package/src/components/nice-dropdown/nice-dropdown.html +18 -16
- package/src/components/nice-dropdown/nice-dropdown.js +72 -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 +38 -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,18 @@
|
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
.nice-daterange-picker-wrapper {
|
|
23
|
+
z-index: 900;
|
|
24
|
+
max-width: 700px;
|
|
25
|
+
}
|
|
22
26
|
|
|
23
27
|
.dtp-wrapper {
|
|
24
28
|
border-radius: $nice-border-radius;
|
|
25
29
|
box-shadow: $nice-box-shadow;
|
|
26
|
-
|
|
27
|
-
margin-top: 0.5rem;
|
|
28
|
-
left: 15px;
|
|
29
|
-
top: 100%;
|
|
30
|
-
width: 700px;
|
|
30
|
+
|
|
31
31
|
padding: 15px;
|
|
32
32
|
background-color: white;
|
|
33
33
|
border: 1px solid $nice-border-color;
|
|
34
|
-
z-index: 900;
|
|
35
34
|
display: flex;
|
|
36
35
|
|
|
37
36
|
.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,47 @@ 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: ({ state }) => {
|
|
93
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
94
|
+
},
|
|
95
|
+
effect: ({ state }) => {
|
|
96
|
+
state.elements.popper.style.width = `${
|
|
97
|
+
state.elements.reference.offsetWidth
|
|
98
|
+
}px`;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
],
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
$scope.setupPopper();
|
|
105
|
+
|
|
71
106
|
// -----------------------------------Open -----------------------------------
|
|
72
107
|
$scope.toggle = function () {
|
|
73
108
|
if ($scope.isOpen) {
|
|
@@ -82,10 +117,10 @@ angular.module('niceElements')
|
|
|
82
117
|
};
|
|
83
118
|
|
|
84
119
|
$scope.open = function () {
|
|
85
|
-
$scope.focusInput();
|
|
86
120
|
$scope.isOpen = true;
|
|
87
|
-
|
|
88
|
-
|
|
121
|
+
$timeout(function () {
|
|
122
|
+
$scope.popper.update();
|
|
123
|
+
$scope.focusInput();
|
|
89
124
|
$scope.scrollToHover(true);
|
|
90
125
|
}, 100);
|
|
91
126
|
};
|
|
@@ -103,18 +138,18 @@ angular.module('niceElements')
|
|
|
103
138
|
|
|
104
139
|
|
|
105
140
|
// ----------------------------------- Scroll to hover -----------------------------------
|
|
106
|
-
$scope.scrollToHover = function(notSmooth) {
|
|
107
|
-
var dropdownMenu = $element[0].getElementsByClassName("dropdown-menu")[0];
|
|
108
|
-
|
|
141
|
+
$scope.scrollToHover = function (notSmooth) {
|
|
142
|
+
var dropdownMenu = $element[0].getElementsByClassName("nice-dropdown-menu")[0];
|
|
143
|
+
if (!dropdownMenu) return;
|
|
144
|
+
var dorpdownList = dropdownMenu.getElementsByClassName("nice-dropdown-items")[0];
|
|
109
145
|
var hoverItem = dorpdownList.getElementsByClassName("hover")[0];
|
|
110
|
-
if (hoverItem)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
}
|
|
146
|
+
if (!hoverItem) return
|
|
147
|
+
var topPos = hoverItem.offsetTop;
|
|
148
|
+
dorpdownList.scroll({
|
|
149
|
+
top: topPos - 120,
|
|
150
|
+
left: 0,
|
|
151
|
+
behavior: notSmooth ? 'auto' : 'smooth'
|
|
152
|
+
});
|
|
118
153
|
};
|
|
119
154
|
|
|
120
155
|
|
|
@@ -149,11 +184,11 @@ angular.module('niceElements')
|
|
|
149
184
|
|
|
150
185
|
|
|
151
186
|
// ----------------------------------- Handle multiple select -----------------------------------
|
|
152
|
-
$scope.handleMultipleSelect = function(item, index) {
|
|
187
|
+
$scope.handleMultipleSelect = function (item, index) {
|
|
153
188
|
if (!$scope.selected) $scope.selected = [];
|
|
154
189
|
|
|
155
|
-
if(item._selected) {
|
|
156
|
-
$scope.selected = $scope.selected.filter(function(s) {
|
|
190
|
+
if (item._selected) {
|
|
191
|
+
$scope.selected = $scope.selected.filter(function (s) {
|
|
157
192
|
return s[$scope.objKey] != item[$scope.objKey];
|
|
158
193
|
});
|
|
159
194
|
} else {
|
|
@@ -165,7 +200,7 @@ angular.module('niceElements')
|
|
|
165
200
|
|
|
166
201
|
|
|
167
202
|
// ----------------------------------- Handle single slect -----------------------------------
|
|
168
|
-
$scope.handleSingleSelect = function(item, index) {
|
|
203
|
+
$scope.handleSingleSelect = function (item, index) {
|
|
169
204
|
$scope.selected = item;
|
|
170
205
|
$scope.close();
|
|
171
206
|
$scope.handleSetModel();
|
|
@@ -173,13 +208,13 @@ angular.module('niceElements')
|
|
|
173
208
|
|
|
174
209
|
|
|
175
210
|
// ----------------------------------- Handle set model -----------------------------------
|
|
176
|
-
$scope.handleSetModel = function() {
|
|
211
|
+
$scope.handleSetModel = function () {
|
|
177
212
|
var obj = angular.copy($scope.selected);
|
|
178
213
|
|
|
179
214
|
if ($scope.selected != null) {
|
|
180
215
|
// Remove selected flag
|
|
181
216
|
if ($scope.multiple) {
|
|
182
|
-
angular.forEach(obj, function(o) {
|
|
217
|
+
angular.forEach(obj, function (o) {
|
|
183
218
|
o._selected = undefined;
|
|
184
219
|
});
|
|
185
220
|
} else {
|
|
@@ -189,7 +224,7 @@ angular.module('niceElements')
|
|
|
189
224
|
// Selected is object
|
|
190
225
|
if ($scope.selectedIsKey) {
|
|
191
226
|
if ($scope.multiple) {
|
|
192
|
-
angular.forEach(obj, function(o) {
|
|
227
|
+
angular.forEach(obj, function (o) {
|
|
193
228
|
o = o[$scope.objKey];
|
|
194
229
|
});
|
|
195
230
|
} else {
|
|
@@ -197,7 +232,7 @@ angular.module('niceElements')
|
|
|
197
232
|
}
|
|
198
233
|
}
|
|
199
234
|
}
|
|
200
|
-
|
|
235
|
+
|
|
201
236
|
if ($scope.clearOnSelect) {
|
|
202
237
|
// Clear on select
|
|
203
238
|
$scope.model = null;
|
|
@@ -214,7 +249,7 @@ angular.module('niceElements')
|
|
|
214
249
|
|
|
215
250
|
|
|
216
251
|
// ----------------------------------- Handle default -----------------------------------
|
|
217
|
-
$scope.handleDefault = function() {
|
|
252
|
+
$scope.handleDefault = function () {
|
|
218
253
|
if ($scope.model) $scope.handleModelChange();
|
|
219
254
|
if (!$scope.nullable && !$scope.model && !$scope.clearOnSelect && $scope.internalList && $scope.internalList.length > 0) {
|
|
220
255
|
$scope.handleSelected($scope.internalList[0], 0);
|
|
@@ -233,16 +268,16 @@ angular.module('niceElements')
|
|
|
233
268
|
$scope.handleModelChange();
|
|
234
269
|
});
|
|
235
270
|
|
|
236
|
-
$scope.handleModelChange = function() {
|
|
271
|
+
$scope.handleModelChange = function () {
|
|
237
272
|
$scope.selected = angular.copy($scope.model);
|
|
238
|
-
angular.forEach($scope.internalList, function(i, index) {
|
|
273
|
+
angular.forEach($scope.internalList, function (i, index) {
|
|
239
274
|
i._selected = false;
|
|
240
275
|
|
|
241
276
|
if ($scope.selectedIsKey) {
|
|
242
277
|
// Not object
|
|
243
278
|
if ($scope.multiple) {
|
|
244
279
|
// Multiple
|
|
245
|
-
angular.forEach($scope.selected, function(s) {
|
|
280
|
+
angular.forEach($scope.selected, function (s) {
|
|
246
281
|
if (i[$scope.objKey] == s) {
|
|
247
282
|
i._selected = true;
|
|
248
283
|
// $scope.selected.push(i);
|
|
@@ -257,12 +292,12 @@ angular.module('niceElements')
|
|
|
257
292
|
$scope.selectedIndex = index;
|
|
258
293
|
$scope.scrollToHover();
|
|
259
294
|
}
|
|
260
|
-
}
|
|
295
|
+
}
|
|
261
296
|
} else {
|
|
262
297
|
// Is object
|
|
263
298
|
if ($scope.multiple) {
|
|
264
299
|
// Multiple
|
|
265
|
-
angular.forEach($scope.selected, function(s) {
|
|
300
|
+
angular.forEach($scope.selected, function (s) {
|
|
266
301
|
if (i[$scope.objKey] == s[$scope.objKey]) {
|
|
267
302
|
i._selected = true;
|
|
268
303
|
// $scope.selected.push(i);
|
|
@@ -281,41 +316,16 @@ angular.module('niceElements')
|
|
|
281
316
|
}
|
|
282
317
|
});
|
|
283
318
|
}
|
|
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
319
|
|
|
310
320
|
// ----------------------------------- Watch for keydown and keypress -----------------------------------
|
|
311
321
|
$element.bind("keydown keypress", function (event) {
|
|
312
322
|
// Arrow Up
|
|
313
323
|
if (event.keyCode == 38) {
|
|
314
324
|
event.preventDefault();
|
|
315
|
-
$timeout(function() {
|
|
316
|
-
if (
|
|
325
|
+
$timeout(function () {
|
|
326
|
+
if ($scope.selectedIndex > 0) {
|
|
317
327
|
$scope.selectedIndex -= 1;
|
|
318
|
-
$timeout(function() {
|
|
328
|
+
$timeout(function () {
|
|
319
329
|
$scope.scrollToHover();
|
|
320
330
|
});
|
|
321
331
|
}
|
|
@@ -325,10 +335,10 @@ angular.module('niceElements')
|
|
|
325
335
|
// Arrow Down
|
|
326
336
|
if (event.keyCode == 40) {
|
|
327
337
|
event.preventDefault();
|
|
328
|
-
$timeout(function() {
|
|
338
|
+
$timeout(function () {
|
|
329
339
|
if ($scope.internalList && $scope.selectedIndex < $scope.internalList.length - 1) {
|
|
330
340
|
$scope.selectedIndex += 1;
|
|
331
|
-
$timeout(function() {
|
|
341
|
+
$timeout(function () {
|
|
332
342
|
$scope.scrollToHover();
|
|
333
343
|
});
|
|
334
344
|
}
|
|
@@ -338,14 +348,14 @@ angular.module('niceElements')
|
|
|
338
348
|
// Enter
|
|
339
349
|
if (event.keyCode == 13) {
|
|
340
350
|
event.preventDefault();
|
|
341
|
-
$timeout(function() {
|
|
351
|
+
$timeout(function () {
|
|
342
352
|
$scope.handleSelected($scope.internalList[$scope.selectedIndex], $scope.selectedIndex);
|
|
343
353
|
});
|
|
344
354
|
}
|
|
345
355
|
|
|
346
356
|
// Escape
|
|
347
357
|
if (event.keyCode == 27) {
|
|
348
|
-
$timeout(function() {
|
|
358
|
+
$timeout(function () {
|
|
349
359
|
$scope.close();
|
|
350
360
|
});
|
|
351
361
|
}
|
|
@@ -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,40 @@ 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: ({ state }) => {
|
|
66
|
+
state.styles.popper.width = `${state.rects.reference.width}px`;
|
|
67
|
+
},
|
|
68
|
+
effect: ({ state }) => {
|
|
69
|
+
state.elements.popper.style.width = `${
|
|
70
|
+
state.elements.reference.offsetWidth
|
|
71
|
+
}px`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
$scope.setupPopper();
|
|
44
78
|
|
|
45
79
|
// ------------------- On focus -------------------
|
|
46
80
|
$scope.onFocus = function() {
|
|
@@ -67,6 +101,10 @@ angular.module('niceElements')
|
|
|
67
101
|
|
|
68
102
|
var input = $element[0].getElementsByTagName('input')[0];
|
|
69
103
|
if (input) input.blur();
|
|
104
|
+
|
|
105
|
+
$timeout(function() {
|
|
106
|
+
$scope.popper.update();
|
|
107
|
+
})
|
|
70
108
|
};
|
|
71
109
|
|
|
72
110
|
|
|
@@ -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;
|