@finqu/cool 1.2.6 → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI tooltip.js v1.2.5 (https://finqu.fi)
3
- * Copyright 2011-2019 Finqu Oy
2
+ * Cool UI tooltip.js v1.2.6 (https://finqu.fi)
3
+ * Copyright 2011-2020 Finqu Oy
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  */
6
6
  (function (global, factory) {
package/js/src/popover.js CHANGED
@@ -55,6 +55,7 @@ class Popover extends AbstractUIComponent {
55
55
 
56
56
  this.$el = $(this.el);
57
57
  this.$container = this.$el.data('container') ? $(this.$el.data('container')) : $(this.opts.container);
58
+ this.containerAutoDetect = this.$el.data('containerAutoDetect') ? this.$el.data('containerAutoDetect') : this.opts.containerAutoDetect;
58
59
  this.id = 'popover-'+this.generateUUID();
59
60
  this.animation = this.$el.data('animation') ? this.$el.data('animation') : this.opts.animation;
60
61
  this.animationIn = this.$el.data('animationIn') ? this.$el.data('animationIn') : this.opts.animationIn;
@@ -65,6 +66,10 @@ class Popover extends AbstractUIComponent {
65
66
  this.placementChanged = false;
66
67
  this.title = this.$el.data('title') ? this.$el.data('title') : this.opts.title;
67
68
  this.content = this.$el.data('content') ? this.$el.data('content') : this.opts.content;
69
+
70
+ if (this.containerAutoDetect) {
71
+ this.$container = this.$el.offsetParent();
72
+ }
68
73
  }
69
74
 
70
75
  // Bind events that trigger methods
@@ -595,6 +600,7 @@ if (typeof $ !== 'undefined') {
595
600
 
596
601
  $.fn[NAME].defaults = {
597
602
  container: '.content-inner',
603
+ containerAutoDetect: false,
598
604
  trigger: 'focus',
599
605
  placement: 'bottom',
600
606
  animation: true,
package/js/src/select.js CHANGED
@@ -145,13 +145,15 @@ class Select extends AbstractUIComponent {
145
145
  this.data = this.$el.data('setData');
146
146
  }
147
147
 
148
- if (typeof this.data[this.name].filter !== 'undefined' && self.itemsToExclude) {
148
+ if (this.data[this.name] !== 'undefined' && this.data[this.name].length > 0 && self.itemsToExclude) {
149
+
149
150
  this.data[this.name] = this.data[this.name].filter(function(item) {
150
151
  return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
151
152
  });
152
153
  }
153
154
 
154
- if (typeof this.items.filter !== 'undefined' && self.itemsToExclude) {
155
+ if (this.items !== 'undefined' && this.items.lengths > 0 && self.itemsToExclude) {
156
+
155
157
  this.items = this.items.filter(function(item) {
156
158
  return self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1;
157
159
  });
@@ -182,7 +184,7 @@ class Select extends AbstractUIComponent {
182
184
 
183
185
  ${this._renderSearch()}
184
186
 
185
- <div class="select-scrollable-content">${items}</div>
187
+ <div class="select-scrollable-content"></div>
186
188
 
187
189
  ${this._renderFooter()}
188
190
 
@@ -190,6 +192,7 @@ class Select extends AbstractUIComponent {
190
192
  `);
191
193
 
192
194
  this.$el.append(this.$select);
195
+ this.$select.find('.select-scrollable-content').append(items);
193
196
 
194
197
  secondaryResolve();
195
198
 
@@ -574,14 +577,29 @@ class Select extends AbstractUIComponent {
574
577
  return item;
575
578
  });
576
579
 
580
+ let itemIds = items.map(item => {
581
+ return parseInt(item.id, 10);
582
+ });
583
+
584
+ // Remove value from data if it doesn't exist anymore
585
+ self.data[self.name] = self.data[self.name].filter(function(value) {
586
+ return itemIds.indexOf(parseInt(value, 10)) > -1;
587
+ });
588
+
589
+ if (self.data[self.name].length == 0) {
590
+ self.$selectIconContainer.html(self.selectIconDefault);
591
+ }
592
+
577
593
  items = items.filter(function(item) {
578
594
  return self.data[self.name].indexOf(item.id) > -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
579
595
  });
580
596
 
581
- let result = $(self._renderItemList(items));
597
+ let result = self._renderItemList(items);
582
598
 
583
599
  $.when(self.$scrollableContent.append(result)).then(function() {
584
600
 
601
+ let $inputs = self.$scrollableContent.find(':input');
602
+
585
603
  if (self.$scrollableContent[0].offsetHeight < self.$scrollableContent[0].scrollHeight) {
586
604
 
587
605
  self.scroll.update();
@@ -595,9 +613,9 @@ class Select extends AbstractUIComponent {
595
613
  self.$scrollableContent.removeClass('ps-show-rail-y');
596
614
  }
597
615
 
598
- if (self.$select.find(':input[type="checkbox"]').length) {
616
+ if (self.$scrollableContent.find(':input[type="checkbox"]').length) {
599
617
  self.type = 'checkbox';
600
- } else if (self.$select.find(':input[type="radio"]').length) {
618
+ } else if (self.$scrollableContent.find(':input[type="radio"]').length) {
601
619
  self.type = 'radio';
602
620
  }
603
621
 
@@ -605,7 +623,7 @@ class Select extends AbstractUIComponent {
605
623
 
606
624
  self.data[self.name].forEach(function(value) {
607
625
 
608
- let $input = self.$select.find(':input').filter(function() { return this.value == value });
626
+ let $input = $inputs.filter(function() { return this.value == value });
609
627
 
610
628
  $input.prop('checked', true);
611
629
 
@@ -614,7 +632,7 @@ class Select extends AbstractUIComponent {
614
632
 
615
633
  } else if (self.type == 'radio') {
616
634
 
617
- let $input = self.$select.find(':input').filter(function() { return this.value == self.data[self.name] });
635
+ let $input = $inputs.filter(function() { return this.value == self.data[self.name] });
618
636
 
619
637
  $input.prop('checked', true);
620
638
  $input.addClass('checked');
@@ -630,9 +648,23 @@ class Select extends AbstractUIComponent {
630
648
 
631
649
  } else {
632
650
 
633
- if (this.$select.find(':input[type="checkbox"]').length) {
651
+ // Remove value from data if it doesn't exist anymore
652
+ let $inputs = this.$scrollableContent.find(':input');
653
+ let inputValues = $inputs.length > 0 ? $inputs.map(function() {
654
+ return parseInt(this.value, 10);
655
+ }).get() : [];
656
+
657
+ this.data[this.name] = this.data[this.name].filter(function(value) {
658
+ return inputValues.indexOf(parseInt(value, 10)) > -1;
659
+ });
660
+
661
+ if (this.data[this.name].length == 0) {
662
+ this.$selectIconContainer.html(this.selectIconDefault);
663
+ }
664
+
665
+ if (this.$scrollableContent.find(':input[type="checkbox"]').length) {
634
666
  this.type = 'checkbox';
635
- } else if (this.$select.find(':input[type="radio"]').length) {
667
+ } else if (this.$scrollableContent.find(':input[type="radio"]').length) {
636
668
  this.type = 'radio';
637
669
  }
638
670
 
@@ -640,7 +672,9 @@ class Select extends AbstractUIComponent {
640
672
 
641
673
  this.data[this.name].forEach(function(value) {
642
674
 
643
- let $input = self.$select.find(':input').filter(function() { return this.value == value });
675
+ let $input = $inputs.filter(function() {
676
+ return this.value == value
677
+ });
644
678
 
645
679
  $input.prop('checked', true);
646
680
 
@@ -649,7 +683,9 @@ class Select extends AbstractUIComponent {
649
683
 
650
684
  } else if (this.type == 'radio') {
651
685
 
652
- let $input = this.$select.find(':input').filter(function() { return this.value == self.data[self.name] });
686
+ let $input = $inputs.filter(function() {
687
+ return this.value == self.data[self.name]
688
+ });
653
689
 
654
690
  $input.prop('checked', true);
655
691
  $input.addClass('checked');
@@ -691,7 +727,7 @@ class Select extends AbstractUIComponent {
691
727
  return self.data[self.name].indexOf(item.id) === -1 && self.itemsToExclude.indexOf(parseInt(item.id, 10)) === -1 && parseInt(item.id, 10) > 0;
692
728
  });
693
729
 
694
- let result = $(self._renderItemList(items));
730
+ let result = self._renderItemList(items);
695
731
 
696
732
  $.when(self.$scrollableContent.append(result)).then(function() {
697
733
 
@@ -833,11 +869,23 @@ class Select extends AbstractUIComponent {
833
869
  // On select
834
870
  onSelect(el) {
835
871
 
872
+ let self = this;
836
873
  let onSelect = this.opts.onSelect;
874
+ let data = $(el).parents('.select-item').data();
837
875
 
838
- if (typeof onSelect === 'function') {
876
+ if (this.searchApi.length && !$.isEmptyObject(data)) {
877
+
878
+ if ($(el).length && el.checked) {
839
879
 
840
- let data = this.getItem('id', el.value);
880
+ this.items.push(data);
881
+
882
+ } else {
883
+
884
+ this.items = $.grep(this.items, function(item) { return item[self.primaryKeyword] != data.id });
885
+ }
886
+ }
887
+
888
+ if (typeof onSelect === 'function') {
841
889
 
842
890
  onSelect.call(el, data, this);
843
891
  }
@@ -1048,7 +1096,7 @@ class Select extends AbstractUIComponent {
1048
1096
 
1049
1097
  _renderItemList(items) {
1050
1098
 
1051
- let result = '';
1099
+ let result = [];
1052
1100
 
1053
1101
  for (let i = 0; i < items.length; ++i) {
1054
1102
 
@@ -1070,7 +1118,7 @@ class Select extends AbstractUIComponent {
1070
1118
  }
1071
1119
  }
1072
1120
 
1073
- result += `
1121
+ result.push($(`
1074
1122
 
1075
1123
  <div class="select-item">
1076
1124
 
@@ -1100,7 +1148,7 @@ class Select extends AbstractUIComponent {
1100
1148
 
1101
1149
  </div>
1102
1150
 
1103
- `;
1151
+ `).data(item));
1104
1152
  }
1105
1153
 
1106
1154
  return result;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finqu/cool",
3
- "version": "1.2.6",
3
+ "version": "1.2.7",
4
4
  "description": "Finqu UI package",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/scss/LISENCE CHANGED
@@ -1,6 +1,6 @@
1
1
  ISC License
2
2
 
3
- Copyright (c) 2019, Finqu Oy
3
+ Copyright (c) 2020, Finqu Oy
4
4
 
5
5
  Permission to use, copy, modify, and/or distribute this software for any
6
6
  purpose with or without fee is hereby granted, provided that the above
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI - Grid v1.2.6 (https://finqu.fi)
3
- * Copyright 2019 Finqu Oy.
2
+ * Cool UI - Grid v1.2.7 (https://finqu.fi)
3
+ * Copyright 2020 Finqu Oy.
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  * Forked from Bootstrap, licensed MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6
6
  */
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI - Reboot v1.2.6 (https://finqu.fi)
3
- * Copyright 2019 Finqu Oy.
2
+ * Cool UI - Reboot v1.2.7 (https://finqu.fi)
3
+ * Copyright 2020 Finqu Oy.
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  * Forked from Bootstrap, licensed MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6
6
  */
package/scss/cool.scss CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * Cool UI v1.2.6 (https://finqu.fi)
3
- * Copyright 2019 Finqu Oy.
2
+ * Cool UI v1.2.7 (https://finqu.fi)
3
+ * Copyright 2020 Finqu Oy.
4
4
  * Licensed under the ISC license - (http://opensource.org/licenses/ISC)
5
5
  * Forked from Bootstrap, licensed MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6
6
  */