nice-elements 1.12.8 → 1.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +5 -0
- package/README.md +7 -3
- package/bower.json +1 -1
- package/dist/nice.js +137 -194
- package/dist/nice.min.js +1 -1
- package/dist/style.css +52 -52
- package/dist/style.css.map +3 -3
- package/dist/style.min.css +1 -1
- package/package.json +1 -1
- package/src/directives/nice-infinite-loader.js +28 -0
- package/src/filters/nice-date.js +1 -1
- package/src/filters/nice-highlight.js +1 -1
- package/src/services/nice-service.js +2 -2
- package/src/styles/_nice.scss +4 -1
- /package/src/{components/nice-click-outside → directives}/nice-click-outside.js +0 -0
- /package/src/{components → directives}/nice-tooltip/_nice-tooltip.scss +0 -0
- /package/src/{components → directives}/nice-tooltip/nice-tooltip.js +0 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
-
# Nice elements v1.12.
|
|
3
|
+
# Nice elements v1.12.9
|
|
4
4
|
|
|
5
5
|
Nice elements is an AngularJS v1.5.8 module that contains nice form elements like inputs, choice fields, search, toggle, dropdown, etc.
|
|
6
6
|
|
|
@@ -14,7 +14,6 @@ Nice elements is an AngularJS v1.5.8 module that contains nice form elements lik
|
|
|
14
14
|
- nice-calendar
|
|
15
15
|
- nice-checkbox
|
|
16
16
|
- nice-choice
|
|
17
|
-
- nice-click-outside
|
|
18
17
|
- nice-comment
|
|
19
18
|
- nice-date
|
|
20
19
|
- nice-date-input
|
|
@@ -42,7 +41,6 @@ Nice elements is an AngularJS v1.5.8 module that contains nice form elements lik
|
|
|
42
41
|
- nice-time-picker
|
|
43
42
|
- nice-title
|
|
44
43
|
- nice-toast
|
|
45
|
-
- nice-tooltip
|
|
46
44
|
- nice-upload
|
|
47
45
|
- nice-yesno
|
|
48
46
|
- nice-pill
|
|
@@ -65,6 +63,12 @@ Nice elements is an AngularJS v1.5.8 module that contains nice form elements lik
|
|
|
65
63
|
|
|
66
64
|
- nice-service
|
|
67
65
|
|
|
66
|
+
## Directives
|
|
67
|
+
|
|
68
|
+
- nice-click-outside
|
|
69
|
+
- nice-tooltip
|
|
70
|
+
- nice-infinite-loader
|
|
71
|
+
|
|
68
72
|
## How to build
|
|
69
73
|
|
|
70
74
|
```bash
|
package/bower.json
CHANGED
package/dist/nice.js
CHANGED
|
@@ -819,112 +819,6 @@ angular.module('niceElements')
|
|
|
819
819
|
|
|
820
820
|
'use strict';
|
|
821
821
|
|
|
822
|
-
/**
|
|
823
|
-
* @ngdoc directive
|
|
824
|
-
* @name niceElements.directive:clickOutside
|
|
825
|
-
* @description
|
|
826
|
-
* # clickOutside
|
|
827
|
-
*/
|
|
828
|
-
angular.module('niceElements')
|
|
829
|
-
.directive('clickOutside', function ($document, $parse, $timeout) {
|
|
830
|
-
return {
|
|
831
|
-
restrict: 'A',
|
|
832
|
-
link: function ($scope, elem, attr) {
|
|
833
|
-
$scope.isOpen = false;
|
|
834
|
-
|
|
835
|
-
// watch for is open
|
|
836
|
-
attr.$observe('isOpen', function (value) {
|
|
837
|
-
$scope.isOpen = value == 'true';
|
|
838
|
-
});
|
|
839
|
-
|
|
840
|
-
$timeout(function () {
|
|
841
|
-
// postpone linking to next digest to allow for unique id generation
|
|
842
|
-
const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
|
|
843
|
-
let fn;
|
|
844
|
-
|
|
845
|
-
function eventHandler(e) {
|
|
846
|
-
if ($scope.isOpen) {
|
|
847
|
-
let i, element, r, id, classNames, l;
|
|
848
|
-
|
|
849
|
-
// if there is no click target, no point going on
|
|
850
|
-
if (!e || !e.target) {
|
|
851
|
-
return;
|
|
852
|
-
}
|
|
853
|
-
|
|
854
|
-
// loop through the available elements, looking for classes in the class list that might match and so will eat
|
|
855
|
-
for (element = e.target; element; element = element.parentNode) {
|
|
856
|
-
// check if the element is the same element the directive is attached to and exit if so (props @CosticaPuntaru)
|
|
857
|
-
if (element === elem[0]) {
|
|
858
|
-
return;
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
// now we have done the initial checks, start gathering id's and classes
|
|
862
|
-
id = element.id;
|
|
863
|
-
classNames = element.className;
|
|
864
|
-
l = classList.length;
|
|
865
|
-
|
|
866
|
-
// Unwrap SVGAnimatedString classes
|
|
867
|
-
if (classNames && classNames.baseVal !== undefined) {
|
|
868
|
-
classNames = classNames.baseVal;
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
// if there are no class names on the element clicked, skip the check
|
|
872
|
-
if (classNames || id) {
|
|
873
|
-
|
|
874
|
-
// loop through the elements id's and classnames looking for exceptions
|
|
875
|
-
for (i = 0; i < l; i++) {
|
|
876
|
-
//prepare regex for class word matching
|
|
877
|
-
r = new RegExp('\\b' + classList[i] + '\\b');
|
|
878
|
-
|
|
879
|
-
// check for exact matches on id's or classes, but only if they exist in the first place
|
|
880
|
-
if ((id !== undefined && id === classList[i]) || (classNames && r.test(classNames))) {
|
|
881
|
-
// now let's exit out as it is an element that has been defined as being ignored for clicking outside
|
|
882
|
-
return;
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
// if we have got this far, then we are good to go with processing the command passed in via the click-outside attribute
|
|
889
|
-
$timeout(function () {
|
|
890
|
-
fn = $parse(attr['clickOutside']);
|
|
891
|
-
fn($scope, { event: e });
|
|
892
|
-
});
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
// if the devices has a touchscreen, listen for this event
|
|
898
|
-
if (_hasTouch()) {
|
|
899
|
-
$document.on('touchstart', eventHandler);
|
|
900
|
-
}
|
|
901
|
-
|
|
902
|
-
// still listen for the click event even if there is touch to cater for touchscreen laptops
|
|
903
|
-
$document.on('click', eventHandler);
|
|
904
|
-
|
|
905
|
-
// when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
|
|
906
|
-
$scope.$on('$destroy', function () {
|
|
907
|
-
if (_hasTouch()) {
|
|
908
|
-
$document.off('touchstart', eventHandler);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
$document.off('click', eventHandler);
|
|
912
|
-
});
|
|
913
|
-
|
|
914
|
-
/**
|
|
915
|
-
* @description Private function to attempt to figure out if we are on a touch device
|
|
916
|
-
* @private
|
|
917
|
-
**/
|
|
918
|
-
function _hasTouch() {
|
|
919
|
-
// works on most browsers, IE10/11 and Surface
|
|
920
|
-
return 'ontouchstart' in window || navigator.maxTouchPoints;
|
|
921
|
-
}
|
|
922
|
-
});
|
|
923
|
-
}
|
|
924
|
-
};
|
|
925
|
-
});
|
|
926
|
-
'use strict';
|
|
927
|
-
|
|
928
822
|
/**
|
|
929
823
|
* @ngdoc directive
|
|
930
824
|
* @name niceElements.directive:niceComment
|
|
@@ -5853,91 +5747,6 @@ angular.module('niceElements')
|
|
|
5853
5747
|
|
|
5854
5748
|
'use strict';
|
|
5855
5749
|
|
|
5856
|
-
/**
|
|
5857
|
-
* @ngdoc directive
|
|
5858
|
-
* @name niceElements.directive:niceTooltip
|
|
5859
|
-
* @description
|
|
5860
|
-
* # niceTooltip
|
|
5861
|
-
*/
|
|
5862
|
-
angular.module('niceElements')
|
|
5863
|
-
.directive('niceTooltip', function () {
|
|
5864
|
-
return {
|
|
5865
|
-
restrict: 'A',
|
|
5866
|
-
controller: function ($scope, $element, $attrs, $compile) {
|
|
5867
|
-
const id = Math.random().toString(36).substring(7);
|
|
5868
|
-
const showEvents = ['mouseenter', 'focus'];
|
|
5869
|
-
const hideEvents = ['mouseleave', 'blur'];
|
|
5870
|
-
const placement = $attrs.niceTooltipPlacement || "top";
|
|
5871
|
-
|
|
5872
|
-
// Create popper window
|
|
5873
|
-
$element.addClass("nice-tooltip");
|
|
5874
|
-
const tooltipWindow = document.createElement('div');
|
|
5875
|
-
tooltipWindow.className = 'nice-tooltip-window';
|
|
5876
|
-
tooltipWindow.id = 'nice-tooltip-window-' + id;
|
|
5877
|
-
|
|
5878
|
-
// Popper body
|
|
5879
|
-
const content = $compile("<div class='nice-tooltip-body'>" + $attrs.niceTooltip + "</div>")($scope);
|
|
5880
|
-
tooltipWindow.append(content[0]);
|
|
5881
|
-
|
|
5882
|
-
// Popper arrow
|
|
5883
|
-
const tooltipWindowArrow = document.createElement('div');
|
|
5884
|
-
tooltipWindowArrow.className = 'nice-tooltip-window-arrow';
|
|
5885
|
-
tooltipWindowArrow.setAttribute("data-popper-arrow", "");
|
|
5886
|
-
tooltipWindow.append(tooltipWindowArrow);
|
|
5887
|
-
|
|
5888
|
-
// Add to body
|
|
5889
|
-
document.body.append(tooltipWindow);
|
|
5890
|
-
|
|
5891
|
-
// Setup popper
|
|
5892
|
-
const popper = Popper.createPopper($element[0], tooltipWindow, {
|
|
5893
|
-
placement: placement,
|
|
5894
|
-
strategy: 'fixed',
|
|
5895
|
-
modifiers: [
|
|
5896
|
-
{
|
|
5897
|
-
name: 'offset',
|
|
5898
|
-
options: {
|
|
5899
|
-
offset: [0, 8],
|
|
5900
|
-
},
|
|
5901
|
-
},
|
|
5902
|
-
{
|
|
5903
|
-
name: 'arrow',
|
|
5904
|
-
options: {
|
|
5905
|
-
element: tooltipWindowArrow,
|
|
5906
|
-
padding: 3
|
|
5907
|
-
},
|
|
5908
|
-
},
|
|
5909
|
-
],
|
|
5910
|
-
});
|
|
5911
|
-
|
|
5912
|
-
function show() {
|
|
5913
|
-
if ($attrs.niceTooltipDisabled == true || $attrs.niceTooltipDisabled == "true") return;
|
|
5914
|
-
tooltipWindow.setAttribute('data-show', '');
|
|
5915
|
-
popper.update();
|
|
5916
|
-
}
|
|
5917
|
-
|
|
5918
|
-
function hide() {
|
|
5919
|
-
tooltipWindow.removeAttribute('data-show');
|
|
5920
|
-
}
|
|
5921
|
-
|
|
5922
|
-
showEvents.forEach((event) => {
|
|
5923
|
-
$element[0].addEventListener(event, show);
|
|
5924
|
-
});
|
|
5925
|
-
|
|
5926
|
-
hideEvents.forEach((event) => {
|
|
5927
|
-
$element[0].addEventListener(event, hide);
|
|
5928
|
-
});
|
|
5929
|
-
|
|
5930
|
-
// On destroy
|
|
5931
|
-
$scope.$on('$destroy', function () {
|
|
5932
|
-
tooltipWindow.remove();
|
|
5933
|
-
if (popper) popper.destroy();
|
|
5934
|
-
});
|
|
5935
|
-
}
|
|
5936
|
-
};
|
|
5937
|
-
});
|
|
5938
|
-
|
|
5939
|
-
'use strict';
|
|
5940
|
-
|
|
5941
5750
|
/**
|
|
5942
5751
|
* @ngdoc directive
|
|
5943
5752
|
* @name niceElements.directive:niceUpload
|
|
@@ -6356,7 +6165,7 @@ angular.module('niceElements')
|
|
|
6356
6165
|
});
|
|
6357
6166
|
|
|
6358
6167
|
/**
|
|
6359
|
-
* @ngdoc
|
|
6168
|
+
* @ngdoc filter
|
|
6360
6169
|
* @name niceElements.filter:niceDate
|
|
6361
6170
|
* @function
|
|
6362
6171
|
* @description
|
|
@@ -6374,7 +6183,7 @@ angular.module('niceElements').filter('niceDate', function () {
|
|
|
6374
6183
|
};
|
|
6375
6184
|
});
|
|
6376
6185
|
/**
|
|
6377
|
-
* @ngdoc
|
|
6186
|
+
* @ngdoc filter
|
|
6378
6187
|
* @name niceElements.filter:niceHighlight
|
|
6379
6188
|
* @function
|
|
6380
6189
|
* @description
|
|
@@ -6390,8 +6199,142 @@ angular.module('niceElements').filter('niceHighlight', function () {
|
|
|
6390
6199
|
};
|
|
6391
6200
|
});
|
|
6392
6201
|
|
|
6202
|
+
'use strict';
|
|
6203
|
+
|
|
6204
|
+
/**
|
|
6205
|
+
* @ngdoc directive
|
|
6206
|
+
* @name niceElements.directive:clickOutside
|
|
6207
|
+
* @description
|
|
6208
|
+
* # clickOutside
|
|
6209
|
+
*/
|
|
6210
|
+
angular.module('niceElements')
|
|
6211
|
+
.directive('clickOutside', function ($document, $parse, $timeout) {
|
|
6212
|
+
return {
|
|
6213
|
+
restrict: 'A',
|
|
6214
|
+
link: function ($scope, elem, attr) {
|
|
6215
|
+
$scope.isOpen = false;
|
|
6216
|
+
|
|
6217
|
+
// watch for is open
|
|
6218
|
+
attr.$observe('isOpen', function (value) {
|
|
6219
|
+
$scope.isOpen = value == 'true';
|
|
6220
|
+
});
|
|
6221
|
+
|
|
6222
|
+
$timeout(function () {
|
|
6223
|
+
// postpone linking to next digest to allow for unique id generation
|
|
6224
|
+
const classList = (attr.outsideIfNot !== undefined) ? attr.outsideIfNot.split(/[ ,]+/) : [];
|
|
6225
|
+
let fn;
|
|
6226
|
+
|
|
6227
|
+
function eventHandler(e) {
|
|
6228
|
+
if ($scope.isOpen) {
|
|
6229
|
+
let i, element, r, id, classNames, l;
|
|
6230
|
+
|
|
6231
|
+
// if there is no click target, no point going on
|
|
6232
|
+
if (!e || !e.target) {
|
|
6233
|
+
return;
|
|
6234
|
+
}
|
|
6235
|
+
|
|
6236
|
+
// loop through the available elements, looking for classes in the class list that might match and so will eat
|
|
6237
|
+
for (element = e.target; element; element = element.parentNode) {
|
|
6238
|
+
// check if the element is the same element the directive is attached to and exit if so (props @CosticaPuntaru)
|
|
6239
|
+
if (element === elem[0]) {
|
|
6240
|
+
return;
|
|
6241
|
+
}
|
|
6242
|
+
|
|
6243
|
+
// now we have done the initial checks, start gathering id's and classes
|
|
6244
|
+
id = element.id;
|
|
6245
|
+
classNames = element.className;
|
|
6246
|
+
l = classList.length;
|
|
6247
|
+
|
|
6248
|
+
// Unwrap SVGAnimatedString classes
|
|
6249
|
+
if (classNames && classNames.baseVal !== undefined) {
|
|
6250
|
+
classNames = classNames.baseVal;
|
|
6251
|
+
}
|
|
6252
|
+
|
|
6253
|
+
// if there are no class names on the element clicked, skip the check
|
|
6254
|
+
if (classNames || id) {
|
|
6255
|
+
|
|
6256
|
+
// loop through the elements id's and classnames looking for exceptions
|
|
6257
|
+
for (i = 0; i < l; i++) {
|
|
6258
|
+
//prepare regex for class word matching
|
|
6259
|
+
r = new RegExp('\\b' + classList[i] + '\\b');
|
|
6260
|
+
|
|
6261
|
+
// check for exact matches on id's or classes, but only if they exist in the first place
|
|
6262
|
+
if ((id !== undefined && id === classList[i]) || (classNames && r.test(classNames))) {
|
|
6263
|
+
// now let's exit out as it is an element that has been defined as being ignored for clicking outside
|
|
6264
|
+
return;
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
}
|
|
6268
|
+
}
|
|
6269
|
+
|
|
6270
|
+
// if we have got this far, then we are good to go with processing the command passed in via the click-outside attribute
|
|
6271
|
+
$timeout(function () {
|
|
6272
|
+
fn = $parse(attr['clickOutside']);
|
|
6273
|
+
fn($scope, { event: e });
|
|
6274
|
+
});
|
|
6275
|
+
}
|
|
6276
|
+
}
|
|
6277
|
+
|
|
6278
|
+
|
|
6279
|
+
// if the devices has a touchscreen, listen for this event
|
|
6280
|
+
if (_hasTouch()) {
|
|
6281
|
+
$document.on('touchstart', eventHandler);
|
|
6282
|
+
}
|
|
6283
|
+
|
|
6284
|
+
// still listen for the click event even if there is touch to cater for touchscreen laptops
|
|
6285
|
+
$document.on('click', eventHandler);
|
|
6286
|
+
|
|
6287
|
+
// when the scope is destroyed, clean up the documents event handlers as we don't want it hanging around
|
|
6288
|
+
$scope.$on('$destroy', function () {
|
|
6289
|
+
if (_hasTouch()) {
|
|
6290
|
+
$document.off('touchstart', eventHandler);
|
|
6291
|
+
}
|
|
6292
|
+
|
|
6293
|
+
$document.off('click', eventHandler);
|
|
6294
|
+
});
|
|
6295
|
+
|
|
6296
|
+
/**
|
|
6297
|
+
* @description Private function to attempt to figure out if we are on a touch device
|
|
6298
|
+
* @private
|
|
6299
|
+
**/
|
|
6300
|
+
function _hasTouch() {
|
|
6301
|
+
// works on most browsers, IE10/11 and Surface
|
|
6302
|
+
return 'ontouchstart' in window || navigator.maxTouchPoints;
|
|
6303
|
+
}
|
|
6304
|
+
});
|
|
6305
|
+
}
|
|
6306
|
+
};
|
|
6307
|
+
});
|
|
6308
|
+
/**
|
|
6309
|
+
* @ngdoc directive
|
|
6310
|
+
* @name niceElements.directive:niceInfiniteLoader
|
|
6311
|
+
* @function
|
|
6312
|
+
* @description
|
|
6313
|
+
* # niceInfiniteLoader
|
|
6314
|
+
* Directive in the niceElements.
|
|
6315
|
+
*/
|
|
6316
|
+
angular.module('niceElements')
|
|
6317
|
+
.directive('niceInfiniteLoader', function () {
|
|
6318
|
+
return {
|
|
6319
|
+
restrict: 'A',
|
|
6320
|
+
replace: true,
|
|
6321
|
+
link: function (scope, element, attrs) {
|
|
6322
|
+
const isScrolledToBottom = (el) => {
|
|
6323
|
+
const tolerance = 5;
|
|
6324
|
+
return (el.scrollTop + el.clientHeight) >= (el.scrollHeight - tolerance);
|
|
6325
|
+
};
|
|
6326
|
+
|
|
6327
|
+
// Scroll Event Listener
|
|
6328
|
+
element[0].addEventListener('scroll', () => {
|
|
6329
|
+
if (isScrolledToBottom(element[0]) && !scope.$eval(attrs.infiniteLoaderDisabled)) {
|
|
6330
|
+
scope.$eval(attrs.infiniteLoader);
|
|
6331
|
+
}
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6334
|
+
};
|
|
6335
|
+
});
|
|
6393
6336
|
/**
|
|
6394
|
-
* @ngdoc
|
|
6337
|
+
* @ngdoc service
|
|
6395
6338
|
* @name niceElements.service:NiceService
|
|
6396
6339
|
* @function
|
|
6397
6340
|
* @description
|