nice-elements 1.7.10 → 1.7.12

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 CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.7.12 (13.3.2023)
4
+
5
+ - fixed build for services
6
+
7
+ ## v1.7.11 (13.3.2023)
8
+
9
+ - fixed button types,
10
+ - added replace to nice-icon,
11
+ - added load more to nice-dropdown,
12
+ - create nice-service
13
+
3
14
  ## v1.7.10 (10.3.2023)
4
15
 
5
16
  - fixed yesno for firefox,
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ![Nice elements](https://github.com/Klemen1337/angularjs-nice-elements/raw/master/demo/assets/logo.png)
2
2
 
3
- # Nice elements v1.7.10
3
+ # Nice elements v1.7.12
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
 
@@ -53,6 +53,10 @@ Nice elements is an AngularJS v1.5.8 module that contains nice form elements lik
53
53
  - nice-date
54
54
  - nice-highlight
55
55
 
56
+ ## Services
57
+
58
+ - nice-service
59
+
56
60
  ## How to build
57
61
 
58
62
  ```bash
package/bower.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.7.10",
3
+ "version": "1.7.12",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -2339,9 +2339,10 @@ angular.module('niceElements')
2339
2339
  dropdownDistance: '@',
2340
2340
  searchFunction: '=?',
2341
2341
  isInline: '=',
2342
- clearOnSelect: '@'
2342
+ clearOnSelect: '@',
2343
+ enableLoadMore: '@' // Enable load more
2343
2344
  },
2344
- controller: function ($scope, $element, $timeout, gettextCatalog) {
2345
+ controller: function ($scope, $http, $element, $timeout, gettextCatalog, NiceService) {
2345
2346
  if (!$scope.dropdownDistance) { $scope.dropdownDistance = 5; }
2346
2347
  if (!$scope.objValue) { $scope.objValue = 'value'; }
2347
2348
  if (!$scope.objKey) { $scope.objKey = 'id'; }
@@ -2403,7 +2404,8 @@ angular.module('niceElements')
2403
2404
  $scope.setupPopper();
2404
2405
  });
2405
2406
 
2406
- // -----------------------------------Open -----------------------------------
2407
+
2408
+ // ----------------------------------- Open -----------------------------------
2407
2409
  $scope.toggle = function () {
2408
2410
  if ($scope.isOpen) {
2409
2411
  $scope.close();
@@ -2427,10 +2429,55 @@ angular.module('niceElements')
2427
2429
  $timeout(function () {
2428
2430
  $scope.focusInput();
2429
2431
  $scope.scrollToHover(true);
2432
+ if ($scope.enableLoadMore) $scope.handleScrollToBottom();
2430
2433
  }, 100);
2431
2434
  };
2432
2435
 
2433
2436
 
2437
+ // ----------------------------------- Handle scroll to bottom -----------------------------------
2438
+ var lastScrollPosition = Infinity;
2439
+ $scope.handleScrollToBottom = function () {
2440
+ lastScrollPosition = Infinity;
2441
+ var element = angular.element($element[0].getElementsByClassName("nice-dropdown-items")[0]);
2442
+ element.bind("scroll mousewheel", function (e) {
2443
+ var scrollPosition = element[0].scrollHeight - element[0].scrollTop;
2444
+ if (scrollPosition === element[0].clientHeight && lastScrollPosition != scrollPosition) {
2445
+ $scope.loadMore();
2446
+ }
2447
+ if (scrollPosition <= lastScrollPosition) lastScrollPosition = scrollPosition;
2448
+ });
2449
+ }
2450
+
2451
+
2452
+ // ----------------------------------- Load more -----------------------------------
2453
+ $scope.loadMore = function () {
2454
+ if (!$scope.internalList || !$scope.internalList._metadata || !$scope.internalList._metadata.next) return;
2455
+ $scope.loading = true;
2456
+ $http({
2457
+ method: 'GET',
2458
+ url: $scope.internalList._metadata.next,
2459
+ headers: NiceService.getHeader()
2460
+ }).then(function (response) {
2461
+ response = response.data;
2462
+ var metadata = {
2463
+ count: response.count,
2464
+ previous: response.previous,
2465
+ next: response.next,
2466
+ };
2467
+ $scope.internalList._metadata = metadata;
2468
+ angular.forEach(response.results, function (item) {
2469
+ $scope.internalList.push(item);
2470
+ });
2471
+ lastScrollPosition = Infinity;
2472
+ $scope.loading = false;
2473
+ return response;
2474
+ }, function (error) {
2475
+ $scope.loading = false;
2476
+ return error;
2477
+ });
2478
+ }
2479
+
2480
+
2434
2481
  // ----------------------------------- Focus input -----------------------------------
2435
2482
  $scope.focusInput = function () {
2436
2483
  var input = $element[0].getElementsByTagName('input')[0];
@@ -2441,6 +2488,7 @@ angular.module('niceElements')
2441
2488
  }
2442
2489
  };
2443
2490
 
2491
+
2444
2492
  // ------------------- On blur -------------------
2445
2493
  $scope.onBlur = function () {
2446
2494
  $scope.close();
@@ -3589,6 +3637,7 @@ angular.module('niceElements')
3589
3637
  return {
3590
3638
  templateUrl: 'src/components/nice-icon/nice-icon.html',
3591
3639
  restrict: 'E',
3640
+ replace: true,
3592
3641
  scope: {
3593
3642
  icon: '@'
3594
3643
  },
@@ -5456,6 +5505,26 @@ angular.module('niceElements').filter('niceHighlight', function () {
5456
5505
  };
5457
5506
  });
5458
5507
 
5508
+ /**
5509
+ * @ngdoc date
5510
+ * @name niceElements.service:NiceService
5511
+ * @function
5512
+ * @description
5513
+ * # NiceService
5514
+ * Service in the niceElements.
5515
+ */
5516
+ angular.module('niceElements')
5517
+ .service('NiceService', function () {
5518
+ var service = {
5519
+ name: "Nice elements",
5520
+ version: "1.7.11",
5521
+ getHeader: function () {
5522
+ return {};
5523
+ }
5524
+ };
5525
+
5526
+ return service;
5527
+ })
5459
5528
  angular.module('niceElements').run(['$templateCache', function($templateCache) {
5460
5529
  'use strict';
5461
5530
 
@@ -5491,9 +5560,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5491
5560
  "<div class=\"nice-calendar-wrapper\">\n" +
5492
5561
  "<div class=\"nice-calendar-weeks\">\n" +
5493
5562
  "<div class=\"header\">\n" +
5494
- "<button class=\"btn\" ng-click=\"previous()\" title=\"{{ 'Previous month' | translate:'Nice' }}\" ng-disabled=\"isDisabled\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5563
+ "<button class=\"btn\" type=\"button\" ng-click=\"previous()\" title=\"{{ 'Previous month' | translate:'Nice' }}\" ng-disabled=\"isDisabled\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5495
5564
  "<span title=\"{{ month.format('M.YYYY' )}}\">{{ month.format(\"MMMM, YYYY\" )}}</span>\n" +
5496
- "<button class=\"btn\" ng-click=\"next()\" title=\"{{ 'Next month' | translate:'Nice' }}\" ng-disabled=\"isDisabled\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5565
+ "<button class=\"btn\" type=\"button\" ng-click=\"next()\" title=\"{{ 'Next month' | translate:'Nice' }}\" ng-disabled=\"isDisabled\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5497
5566
  "</div>\n" +
5498
5567
  "<div class=\"week names\">\n" +
5499
5568
  "<span class=\"day\" translate translate-context=\"Nice\">Mon</span>\n" +
@@ -5505,7 +5574,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5505
5574
  "<span class=\"day weekend\" translate translate-context=\"Nice\">Sun</span>\n" +
5506
5575
  "</div>\n" +
5507
5576
  "<div class=\"week\" ng-repeat=\"week in weeks\">\n" +
5508
- "<button class=\"day\" title=\"{{ day.date.format('D.M.YYYY') }}\" ng-class=\"{\n" +
5577
+ "<button class=\"day\" type=\"button\" title=\"{{ day.date.format('D.M.YYYY') }}\" ng-class=\"{\n" +
5509
5578
  " today: day.isToday,\n" +
5510
5579
  " 'different-month': !day.isCurrentMonth,\n" +
5511
5580
  " 'start-selected': isSameDay(day.date, startDate),\n" +
@@ -5565,7 +5634,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5565
5634
 
5566
5635
  $templateCache.put('src/components/nice-checkbox/nice-checkbox.html',
5567
5636
  "<div class=\"nice-component nice-checkbox\" ng-class=\"{ 'checked': model, 'margin-bottom-0' : noMargin, 'nice-checkbox-disabled': isDisabled }\" ng-click=\"toggle()\">\n" +
5568
- "<button class=\"btn checkbox\" ng-disabled=\"isDisabled\">\n" +
5637
+ "<button class=\"btn checkbox\" type=\"button\" ng-disabled=\"isDisabled\">\n" +
5569
5638
  "<nice-icon class=\"check\" icon=\"icon-check\"></nice-icon>\n" +
5570
5639
  "</button>\n" +
5571
5640
  "<div ng-if=\"title\" class=\"message\" ng-class=\"{ 'nice-disabled': isDisabled }\">{{ title }}</div>\n" +
@@ -5580,7 +5649,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5580
5649
  "<div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
5581
5650
  "<ul class=\"list-unstyled\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
5582
5651
  "<li ng-repeat=\"item in internalList\" ng-class=\"{ 'selected' : isItemSelected(item) }\" ng-click=\"toggle(item)\">\n" +
5583
- "<button class=\"choice-checkbox\" ng-class=\"{'circle' : !multiple }\" ng-disabled=\"isDisabled\">\n" +
5652
+ "<button class=\"choice-checkbox\" type=\"button\" ng-class=\"{'circle' : !multiple }\" ng-disabled=\"isDisabled\">\n" +
5584
5653
  "<nice-icon ng-if=\"multiple\" icon=\"icon-check\"></nice-icon>\n" +
5585
5654
  "<div ng-if=\"!multiple\" class=\"multiple-circle\"></div>\n" +
5586
5655
  "</button>\n" +
@@ -5614,7 +5683,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5614
5683
  "<input type=\"text\" class=\"form-control\" ng-model=\"modelDate\" ng-blur=\"dateBlur($event)\" ng-disabled=\"isDisabled\">\n" +
5615
5684
  "<nice-popup placement=\"bottom\">\n" +
5616
5685
  "<nice-popup-target>\n" +
5617
- "<button class=\"input-group-addon btn btn-default\" tabindex=\"-1\">\n" +
5686
+ "<button class=\"input-group-addon btn btn-default\" type=\"button\" tabindex=\"-1\">\n" +
5618
5687
  "<nice-icon icon=\"icon-calendar\"></nice-icon>\n" +
5619
5688
  "</button>\n" +
5620
5689
  "</nice-popup-target>\n" +
@@ -5627,7 +5696,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5627
5696
  "<input type=\"text\" class=\"form-control\" ng-model=\"modelTime\" ng-blur=\"timeBlur($event)\" ng-disabled=\"isDisabled\">\n" +
5628
5697
  "<nice-popup placement=\"bottom\">\n" +
5629
5698
  "<nice-popup-target>\n" +
5630
- "<button class=\"input-group-addon btn btn-default\" tabindex=\"-1\">\n" +
5699
+ "<button class=\"input-group-addon btn btn-default\" type=\"button\" tabindex=\"-1\">\n" +
5631
5700
  "<nice-icon icon=\"icon-clock\"></nice-icon>\n" +
5632
5701
  "</button>\n" +
5633
5702
  "</nice-popup-target>\n" +
@@ -5682,15 +5751,15 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5682
5751
  "<select class=\"month-picker\" ng-model=\"innerDate.month\" ng-change=\"handleDateChange()\" ng-options=\"month.value as month.name for month in months\" ng-disabled=\"isDisabled\">\n" +
5683
5752
  "</select>\n" +
5684
5753
  "</span>\n" +
5685
- "<button class=\"btn btn-default-naked\" ng-disabled=\"isDisabled\" ng-click=\"previous()\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5686
- "<button class=\"btn btn-default-naked\" ng-disabled=\"isDisabled\" ng-click=\"today()\"><i class=\"fa fa-circle\"></i></button>\n" +
5687
- "<button class=\"btn btn-default-naked\" ng-disabled=\"isDisabled\" ng-click=\"next()\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5754
+ "<button class=\"btn btn-default-naked\" type=\"button\" ng-disabled=\"isDisabled\" ng-click=\"previous()\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5755
+ "<button class=\"btn btn-default-naked\" type=\"button\" ng-disabled=\"isDisabled\" ng-click=\"today()\"><i class=\"fa fa-circle\"></i></button>\n" +
5756
+ "<button class=\"btn btn-default-naked\" type=\"button\" ng-disabled=\"isDisabled\" ng-click=\"next()\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5688
5757
  "</div>\n" +
5689
5758
  "<div class=\"nice-date-week names\">\n" +
5690
5759
  "<span class=\"nice-date-day\" ng-class=\"{ 'weekend': $index == 6 || $index == 5 }\" ng-repeat=\"day in weekdays\">{{ day }}</span>\n" +
5691
5760
  "</div>\n" +
5692
5761
  "<div class=\"nice-date-week\" role=\"row\" ng-repeat=\"week in weeks\">\n" +
5693
- "<button class=\"nice-date-day\" role=\"gridcell\" title=\"{{ day.value }}\" ng-class=\"{\n" +
5762
+ "<button class=\"nice-date-day\" type=\"button\" role=\"gridcell\" title=\"{{ day.value }}\" ng-class=\"{\n" +
5694
5763
  " 'today': day.isToday,\n" +
5695
5764
  " 'different-month': !day.isCurrentMonth,\n" +
5696
5765
  " 'selected': isSameDay(model, day.date),\n" +
@@ -5899,7 +5968,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5899
5968
  "<nice-title title=\"title\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
5900
5969
  "<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 }}\">\n" +
5901
5970
  "<div class=\"nice-field-wrapper\">\n" +
5902
- "<button type=\"button\" class=\"btn btn-dropdown\" ng-ref=\"dropdown-button\" ng-click=\"toggle()\" ng-disabled=\"isDisabled || emptyList\">\n" +
5971
+ "<button class=\"btn btn-dropdown\" type=\"button\" ng-ref=\"dropdown-button\" ng-click=\"toggle()\" ng-disabled=\"isDisabled || emptyList\">\n" +
5903
5972
  "<div class=\"btn-dropdown-inside\" ng-transclude=\"button\" ng-if=\"selected != null\">\n" +
5904
5973
  "<span ng-if=\"!multiple\">{{ selected[objValue] }}</span>\n" +
5905
5974
  "<span ng-if=\"multiple\">\n" +
@@ -5916,7 +5985,8 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5916
5985
  "<div class=\"nice-dropdown-menu\" ng-if=\"isOpen\">\n" +
5917
5986
  "<div class=\"search-bar\" ng-if=\"searchFunction\">\n" +
5918
5987
  "<input ng-model=\"internal.search\" ng-model-options=\"{ debounce: 500 }\" ng-change=\"handleSearch()\" placeholder=\"{{ searchText }}\">\n" +
5919
- "<span class=\"icon\"><i class=\"fa fa-search\"></i></span>\n" +
5988
+ "<div class=\"count\" ng-if=\"internalList && internalList._metadata && enableLoadMore\">{{ internalList.length }}/{{ internalList._metadata.count }}</div>\n" +
5989
+ "<nice-icon class=\"icon\" icon=\"icon-search\"></nice-icon>\n" +
5920
5990
  "</div>\n" +
5921
5991
  "<div class=\"nice-dropdown-items\">\n" +
5922
5992
  "<div class=\"nice-no-data\" ng-if=\"internalList && internalList.length == 0\">{{ noDataText }}</div>\n" +
@@ -7190,20 +7260,20 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7190
7260
  "</div>\n" +
7191
7261
  "<div class=\"nice-time-picker-dropdown\" ng-if=\"open\">\n" +
7192
7262
  "<div>\n" +
7193
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(true)\">\n" +
7263
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(true)\">\n" +
7194
7264
  "<nice-icon icon=\"icon-chevron-up\"></nice-icon>\n" +
7195
7265
  "</button>\n" +
7196
7266
  "<div class=\"numbers\">{{ hours }}</div>\n" +
7197
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(false)\">\n" +
7267
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(false)\">\n" +
7198
7268
  "<nice-icon icon=\"icon-chevron-down\"></nice-icon>\n" +
7199
7269
  "</button>\n" +
7200
7270
  "</div>\n" +
7201
7271
  "<div>\n" +
7202
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(true)\">\n" +
7272
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(true)\">\n" +
7203
7273
  "<nice-icon icon=\"icon-chevron-up\"></nice-icon>\n" +
7204
7274
  "</button>\n" +
7205
7275
  "<div class=\"numbers\">{{ minutes }}</div>\n" +
7206
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(false)\">\n" +
7276
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(false)\">\n" +
7207
7277
  "<nice-icon icon=\"icon-chevron-down\"></nice-icon>\n" +
7208
7278
  "</button>\n" +
7209
7279
  "</div>\n" +
@@ -7260,9 +7330,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7260
7330
  "<nice-title title=\"title\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
7261
7331
  "<div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
7262
7332
  "<div class=\"yesno-wrapper noselect\">\n" +
7263
- "<button class=\"yesno-yes-bg\" ng-click=\"switch()\" tabindex=\"-1\">{{ yes }}</button>\n" +
7264
- "<button class=\"yesno-no-bg\" ng-click=\"switch()\" tabindex=\"-1\">{{ no }}</button>\n" +
7265
- "<button class=\"yesno-button btn btn-primary\" ng-class=\"buttonClass\" ng-click=\"switch()\" ng-disabled=\"isDisabled\">{{ state }}</button>\n" +
7333
+ "<button class=\"yesno-yes-bg\" ng-click=\"switch()\" tabindex=\"-1\" type=\"button\">{{ yes }}</button>\n" +
7334
+ "<button class=\"yesno-no-bg\" ng-click=\"switch()\" tabindex=\"-1\" type=\"button\">{{ no }}</button>\n" +
7335
+ "<button class=\"yesno-button btn btn-primary\" ng-class=\"buttonClass\" ng-click=\"switch()\" ng-disabled=\"isDisabled\" type=\"button\">{{ state }}</button>\n" +
7266
7336
  "</div>\n" +
7267
7337
  "</div>\n" +
7268
7338
  "</div>\n" +