nice-elements 1.7.9 → 1.7.11

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,17 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.7.11 (13.3.2023)
4
+
5
+ - fixed button types,
6
+ - added replace to nice-icon,
7
+ - added load more to nice-dropdown,
8
+ - create nice-service
9
+
10
+ ## v1.7.10 (10.3.2023)
11
+
12
+ - fixed yesno for firefox,
13
+ - added onSelect callback to nice-dropdown
14
+
3
15
  ## v1.7.9 (17.2.2023)
4
16
 
5
17
  - worked on nice dropdown transclude
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.9
3
+ # Nice elements v1.7.11
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.9",
3
+ "version": "1.7.11",
4
4
  "authors": [
5
5
  "Klemen Kastelic <klemen@olaii.com>"
6
6
  ],
package/dist/nice.js CHANGED
@@ -2316,6 +2316,7 @@ angular.module('niceElements')
2316
2316
  model: '=', // Aka model
2317
2317
  list: '=', // List of options
2318
2318
  onChange: '&?',
2319
+ onSelect: '&?', // Like onChange but always return objects
2319
2320
  isDisabled: '=',
2320
2321
  fieldWidth: '@',
2321
2322
  labelWidth: '@',
@@ -2338,9 +2339,10 @@ angular.module('niceElements')
2338
2339
  dropdownDistance: '@',
2339
2340
  searchFunction: '=?',
2340
2341
  isInline: '=',
2341
- clearOnSelect: '@'
2342
+ clearOnSelect: '@',
2343
+ enableLoadMore: '@' // Enable load more
2342
2344
  },
2343
- controller: function ($scope, $element, $timeout, gettextCatalog) {
2345
+ controller: function ($scope, $http, $element, $timeout, gettextCatalog, NiceService) {
2344
2346
  if (!$scope.dropdownDistance) { $scope.dropdownDistance = 5; }
2345
2347
  if (!$scope.objValue) { $scope.objValue = 'value'; }
2346
2348
  if (!$scope.objKey) { $scope.objKey = 'id'; }
@@ -2402,7 +2404,8 @@ angular.module('niceElements')
2402
2404
  $scope.setupPopper();
2403
2405
  });
2404
2406
 
2405
- // -----------------------------------Open -----------------------------------
2407
+
2408
+ // ----------------------------------- Open -----------------------------------
2406
2409
  $scope.toggle = function () {
2407
2410
  if ($scope.isOpen) {
2408
2411
  $scope.close();
@@ -2426,10 +2429,55 @@ angular.module('niceElements')
2426
2429
  $timeout(function () {
2427
2430
  $scope.focusInput();
2428
2431
  $scope.scrollToHover(true);
2432
+ if ($scope.enableLoadMore) $scope.handleScrollToBottom();
2429
2433
  }, 100);
2430
2434
  };
2431
2435
 
2432
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
+
2433
2481
  // ----------------------------------- Focus input -----------------------------------
2434
2482
  $scope.focusInput = function () {
2435
2483
  var input = $element[0].getElementsByTagName('input')[0];
@@ -2440,6 +2488,7 @@ angular.module('niceElements')
2440
2488
  }
2441
2489
  };
2442
2490
 
2491
+
2443
2492
  // ------------------- On blur -------------------
2444
2493
  $scope.onBlur = function () {
2445
2494
  $scope.close();
@@ -2553,6 +2602,7 @@ angular.module('niceElements')
2553
2602
  // Trigger on change
2554
2603
  $timeout(function () {
2555
2604
  if ($scope.onChange) $scope.onChange({ model: obj });
2605
+ if ($scope.onSelect) $scope.onSelect({ model: angular.copy($scope.selected) });
2556
2606
  })
2557
2607
  };
2558
2608
 
@@ -3587,6 +3637,7 @@ angular.module('niceElements')
3587
3637
  return {
3588
3638
  templateUrl: 'src/components/nice-icon/nice-icon.html',
3589
3639
  restrict: 'E',
3640
+ replace: true,
3590
3641
  scope: {
3591
3642
  icon: '@'
3592
3643
  },
@@ -5489,9 +5540,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5489
5540
  "<div class=\"nice-calendar-wrapper\">\n" +
5490
5541
  "<div class=\"nice-calendar-weeks\">\n" +
5491
5542
  "<div class=\"header\">\n" +
5492
- "<button class=\"btn\" ng-click=\"previous()\" title=\"{{ 'Previous month' | translate:'Nice' }}\" ng-disabled=\"isDisabled\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5543
+ "<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" +
5493
5544
  "<span title=\"{{ month.format('M.YYYY' )}}\">{{ month.format(\"MMMM, YYYY\" )}}</span>\n" +
5494
- "<button class=\"btn\" ng-click=\"next()\" title=\"{{ 'Next month' | translate:'Nice' }}\" ng-disabled=\"isDisabled\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5545
+ "<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" +
5495
5546
  "</div>\n" +
5496
5547
  "<div class=\"week names\">\n" +
5497
5548
  "<span class=\"day\" translate translate-context=\"Nice\">Mon</span>\n" +
@@ -5503,7 +5554,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5503
5554
  "<span class=\"day weekend\" translate translate-context=\"Nice\">Sun</span>\n" +
5504
5555
  "</div>\n" +
5505
5556
  "<div class=\"week\" ng-repeat=\"week in weeks\">\n" +
5506
- "<button class=\"day\" title=\"{{ day.date.format('D.M.YYYY') }}\" ng-class=\"{\n" +
5557
+ "<button class=\"day\" type=\"button\" title=\"{{ day.date.format('D.M.YYYY') }}\" ng-class=\"{\n" +
5507
5558
  " today: day.isToday,\n" +
5508
5559
  " 'different-month': !day.isCurrentMonth,\n" +
5509
5560
  " 'start-selected': isSameDay(day.date, startDate),\n" +
@@ -5563,7 +5614,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5563
5614
 
5564
5615
  $templateCache.put('src/components/nice-checkbox/nice-checkbox.html',
5565
5616
  "<div class=\"nice-component nice-checkbox\" ng-class=\"{ 'checked': model, 'margin-bottom-0' : noMargin, 'nice-checkbox-disabled': isDisabled }\" ng-click=\"toggle()\">\n" +
5566
- "<button class=\"btn checkbox\" ng-disabled=\"isDisabled\">\n" +
5617
+ "<button class=\"btn checkbox\" type=\"button\" ng-disabled=\"isDisabled\">\n" +
5567
5618
  "<nice-icon class=\"check\" icon=\"icon-check\"></nice-icon>\n" +
5568
5619
  "</button>\n" +
5569
5620
  "<div ng-if=\"title\" class=\"message\" ng-class=\"{ 'nice-disabled': isDisabled }\">{{ title }}</div>\n" +
@@ -5578,7 +5629,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5578
5629
  "<div class=\"nice-field col-xs-12\" ng-class=\"fieldWidth ? fieldWidth : 'col-sm-8'\">\n" +
5579
5630
  "<ul class=\"list-unstyled\" ng-class=\"{ 'disabled': isDisabled }\">\n" +
5580
5631
  "<li ng-repeat=\"item in internalList\" ng-class=\"{ 'selected' : isItemSelected(item) }\" ng-click=\"toggle(item)\">\n" +
5581
- "<button class=\"choice-checkbox\" ng-class=\"{'circle' : !multiple }\" ng-disabled=\"isDisabled\">\n" +
5632
+ "<button class=\"choice-checkbox\" type=\"button\" ng-class=\"{'circle' : !multiple }\" ng-disabled=\"isDisabled\">\n" +
5582
5633
  "<nice-icon ng-if=\"multiple\" icon=\"icon-check\"></nice-icon>\n" +
5583
5634
  "<div ng-if=\"!multiple\" class=\"multiple-circle\"></div>\n" +
5584
5635
  "</button>\n" +
@@ -5612,7 +5663,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5612
5663
  "<input type=\"text\" class=\"form-control\" ng-model=\"modelDate\" ng-blur=\"dateBlur($event)\" ng-disabled=\"isDisabled\">\n" +
5613
5664
  "<nice-popup placement=\"bottom\">\n" +
5614
5665
  "<nice-popup-target>\n" +
5615
- "<button class=\"input-group-addon btn btn-default\" tabindex=\"-1\">\n" +
5666
+ "<button class=\"input-group-addon btn btn-default\" type=\"button\" tabindex=\"-1\">\n" +
5616
5667
  "<nice-icon icon=\"icon-calendar\"></nice-icon>\n" +
5617
5668
  "</button>\n" +
5618
5669
  "</nice-popup-target>\n" +
@@ -5625,7 +5676,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5625
5676
  "<input type=\"text\" class=\"form-control\" ng-model=\"modelTime\" ng-blur=\"timeBlur($event)\" ng-disabled=\"isDisabled\">\n" +
5626
5677
  "<nice-popup placement=\"bottom\">\n" +
5627
5678
  "<nice-popup-target>\n" +
5628
- "<button class=\"input-group-addon btn btn-default\" tabindex=\"-1\">\n" +
5679
+ "<button class=\"input-group-addon btn btn-default\" type=\"button\" tabindex=\"-1\">\n" +
5629
5680
  "<nice-icon icon=\"icon-clock\"></nice-icon>\n" +
5630
5681
  "</button>\n" +
5631
5682
  "</nice-popup-target>\n" +
@@ -5680,15 +5731,15 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5680
5731
  "<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" +
5681
5732
  "</select>\n" +
5682
5733
  "</span>\n" +
5683
- "<button class=\"btn btn-default-naked\" ng-disabled=\"isDisabled\" ng-click=\"previous()\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5684
- "<button class=\"btn btn-default-naked\" ng-disabled=\"isDisabled\" ng-click=\"today()\"><i class=\"fa fa-circle\"></i></button>\n" +
5685
- "<button class=\"btn btn-default-naked\" ng-disabled=\"isDisabled\" ng-click=\"next()\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5734
+ "<button class=\"btn btn-default-naked\" type=\"button\" ng-disabled=\"isDisabled\" ng-click=\"previous()\"><i class=\"fa fa-angle-left\"></i></button>\n" +
5735
+ "<button class=\"btn btn-default-naked\" type=\"button\" ng-disabled=\"isDisabled\" ng-click=\"today()\"><i class=\"fa fa-circle\"></i></button>\n" +
5736
+ "<button class=\"btn btn-default-naked\" type=\"button\" ng-disabled=\"isDisabled\" ng-click=\"next()\"><i class=\"fa fa-angle-right\"></i></button>\n" +
5686
5737
  "</div>\n" +
5687
5738
  "<div class=\"nice-date-week names\">\n" +
5688
5739
  "<span class=\"nice-date-day\" ng-class=\"{ 'weekend': $index == 6 || $index == 5 }\" ng-repeat=\"day in weekdays\">{{ day }}</span>\n" +
5689
5740
  "</div>\n" +
5690
5741
  "<div class=\"nice-date-week\" role=\"row\" ng-repeat=\"week in weeks\">\n" +
5691
- "<button class=\"nice-date-day\" role=\"gridcell\" title=\"{{ day.value }}\" ng-class=\"{\n" +
5742
+ "<button class=\"nice-date-day\" type=\"button\" role=\"gridcell\" title=\"{{ day.value }}\" ng-class=\"{\n" +
5692
5743
  " 'today': day.isToday,\n" +
5693
5744
  " 'different-month': !day.isCurrentMonth,\n" +
5694
5745
  " 'selected': isSameDay(model, day.date),\n" +
@@ -5897,7 +5948,7 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5897
5948
  "<nice-title title=\"title\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
5898
5949
  "<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" +
5899
5950
  "<div class=\"nice-field-wrapper\">\n" +
5900
- "<button type=\"button\" class=\"btn btn-dropdown\" ng-ref=\"dropdown-button\" ng-click=\"toggle()\" ng-disabled=\"isDisabled || emptyList\">\n" +
5951
+ "<button class=\"btn btn-dropdown\" type=\"button\" ng-ref=\"dropdown-button\" ng-click=\"toggle()\" ng-disabled=\"isDisabled || emptyList\">\n" +
5901
5952
  "<div class=\"btn-dropdown-inside\" ng-transclude=\"button\" ng-if=\"selected != null\">\n" +
5902
5953
  "<span ng-if=\"!multiple\">{{ selected[objValue] }}</span>\n" +
5903
5954
  "<span ng-if=\"multiple\">\n" +
@@ -5914,7 +5965,8 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
5914
5965
  "<div class=\"nice-dropdown-menu\" ng-if=\"isOpen\">\n" +
5915
5966
  "<div class=\"search-bar\" ng-if=\"searchFunction\">\n" +
5916
5967
  "<input ng-model=\"internal.search\" ng-model-options=\"{ debounce: 500 }\" ng-change=\"handleSearch()\" placeholder=\"{{ searchText }}\">\n" +
5917
- "<span class=\"icon\"><i class=\"fa fa-search\"></i></span>\n" +
5968
+ "<div class=\"count\" ng-if=\"internalList && internalList._metadata && enableLoadMore\">{{ internalList.length }}/{{ internalList._metadata.count }}</div>\n" +
5969
+ "<nice-icon class=\"icon\" icon=\"icon-search\"></nice-icon>\n" +
5918
5970
  "</div>\n" +
5919
5971
  "<div class=\"nice-dropdown-items\">\n" +
5920
5972
  "<div class=\"nice-no-data\" ng-if=\"internalList && internalList.length == 0\">{{ noDataText }}</div>\n" +
@@ -7188,20 +7240,20 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7188
7240
  "</div>\n" +
7189
7241
  "<div class=\"nice-time-picker-dropdown\" ng-if=\"open\">\n" +
7190
7242
  "<div>\n" +
7191
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(true)\">\n" +
7243
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(true)\">\n" +
7192
7244
  "<nice-icon icon=\"icon-chevron-up\"></nice-icon>\n" +
7193
7245
  "</button>\n" +
7194
7246
  "<div class=\"numbers\">{{ hours }}</div>\n" +
7195
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(false)\">\n" +
7247
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeHour(false)\">\n" +
7196
7248
  "<nice-icon icon=\"icon-chevron-down\"></nice-icon>\n" +
7197
7249
  "</button>\n" +
7198
7250
  "</div>\n" +
7199
7251
  "<div>\n" +
7200
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(true)\">\n" +
7252
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(true)\">\n" +
7201
7253
  "<nice-icon icon=\"icon-chevron-up\"></nice-icon>\n" +
7202
7254
  "</button>\n" +
7203
7255
  "<div class=\"numbers\">{{ minutes }}</div>\n" +
7204
- "<button class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(false)\">\n" +
7256
+ "<button type=\"button\" class=\"btn btn-sm btn-block btn-default\" ng-click=\"changeMinutes(false)\">\n" +
7205
7257
  "<nice-icon icon=\"icon-chevron-down\"></nice-icon>\n" +
7206
7258
  "</button>\n" +
7207
7259
  "</div>\n" +
@@ -7258,9 +7310,9 @@ angular.module('niceElements').run(['$templateCache', function($templateCache) {
7258
7310
  "<nice-title title=\"title\" help=\"help\" required=\"required\" label-width=\"labelWidth\"></nice-title>\n" +
7259
7311
  "<div class=\"nice-field col-xs-12\" ng-class=\"[fieldWidth ? fieldWidth : 'col-sm-8', { 'nice-disabled': isDisabled }]\">\n" +
7260
7312
  "<div class=\"yesno-wrapper noselect\">\n" +
7261
- "<button class=\"yesno-yes-bg\" ng-click=\"switch()\" tabindex=\"-1\">{{ yes }}</button>\n" +
7262
- "<button class=\"yesno-no-bg\" ng-click=\"switch()\" tabindex=\"-1\">{{ no }}</button>\n" +
7263
- "<button class=\"yesno-button btn btn-primary\" ng-class=\"buttonClass\" ng-click=\"switch()\" ng-disabled=\"isDisabled\">{{ state }}</button>\n" +
7313
+ "<button class=\"yesno-yes-bg\" ng-click=\"switch()\" tabindex=\"-1\" type=\"button\">{{ yes }}</button>\n" +
7314
+ "<button class=\"yesno-no-bg\" ng-click=\"switch()\" tabindex=\"-1\" type=\"button\">{{ no }}</button>\n" +
7315
+ "<button class=\"yesno-button btn btn-primary\" ng-class=\"buttonClass\" ng-click=\"switch()\" ng-disabled=\"isDisabled\" type=\"button\">{{ state }}</button>\n" +
7264
7316
  "</div>\n" +
7265
7317
  "</div>\n" +
7266
7318
  "</div>\n" +