@finqu/cool 1.0.0
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/README.md +1 -0
- package/build/.eslintrc.json +10 -0
- package/build/banner.js +14 -0
- package/build/build-plugins.js +92 -0
- package/build/rollup.config.js +78 -0
- package/dist/css/cool-grid.css +3672 -0
- package/dist/css/cool-grid.css.map +30 -0
- package/dist/css/cool-grid.min.css +7 -0
- package/dist/css/cool-grid.min.css.map +1 -0
- package/dist/css/cool-reboot.css +281 -0
- package/dist/css/cool-reboot.css.map +58 -0
- package/dist/css/cool-reboot.min.css +7 -0
- package/dist/css/cool-reboot.min.css.map +1 -0
- package/dist/css/cool.css +14841 -0
- package/dist/css/cool.css.map +144 -0
- package/dist/css/cool.min.css +7 -0
- package/dist/css/cool.min.css.map +1 -0
- package/dist/js/cool.bundle.js +15304 -0
- package/dist/js/cool.bundle.js.map +1 -0
- package/dist/js/cool.bundle.min.js +45 -0
- package/dist/js/cool.bundle.min.js.map +1 -0
- package/dist/js/cool.esm.js +4766 -0
- package/dist/js/cool.esm.js.map +1 -0
- package/dist/js/cool.esm.min.js +7 -0
- package/dist/js/cool.esm.min.js.map +1 -0
- package/dist/js/cool.js +4948 -0
- package/dist/js/cool.js.map +1 -0
- package/dist/js/cool.min.js +7 -0
- package/dist/js/cool.min.js.map +1 -0
- package/html/index.html +892 -0
- package/js/dist/collapse.js +321 -0
- package/js/dist/collapse.js.map +1 -0
- package/js/dist/common.js +1474 -0
- package/js/dist/common.js.map +1 -0
- package/js/dist/cooldropdown.js +467 -0
- package/js/dist/cooldropdown.js.map +1 -0
- package/js/dist/coolpopover.js +391 -0
- package/js/dist/coolpopover.js.map +1 -0
- package/js/dist/coolsectiontabs.js +256 -0
- package/js/dist/coolsectiontabs.js.map +1 -0
- package/js/dist/coolselect.js +796 -0
- package/js/dist/coolselect.js.map +1 -0
- package/js/dist/cooltooltip.js +360 -0
- package/js/dist/cooltooltip.js.map +1 -0
- package/js/dist/coolui.js +73 -0
- package/js/dist/coolui.js.map +1 -0
- package/js/dist/dropdown.js +1716 -0
- package/js/dist/dropdown.js.map +1 -0
- package/js/dist/popover.js +587 -0
- package/js/dist/popover.js.map +1 -0
- package/js/dist/sectiontabs.js +263 -0
- package/js/dist/sectiontabs.js.map +1 -0
- package/js/dist/select.js +2029 -0
- package/js/dist/select.js.map +1 -0
- package/js/dist/tooltip.js +555 -0
- package/js/dist/tooltip.js.map +1 -0
- package/js/index.esm.js +21 -0
- package/js/index.umd.js +21 -0
- package/js/src/abstract-ui-component.js +70 -0
- package/js/src/collapse.js +258 -0
- package/js/src/common.js +280 -0
- package/js/src/dialog.js +570 -0
- package/js/src/dropdown.js +443 -0
- package/js/src/popover.js +615 -0
- package/js/src/section-tabs.js +204 -0
- package/js/src/select.js +832 -0
- package/js/src/toast.js +581 -0
- package/js/src/tooltip.js +575 -0
- package/js/src/util/animate-css.js +22 -0
- package/js/src/util/index.js +112 -0
- package/js/src/util/perfect-scrollbar.js +1316 -0
- package/less/alert.less +345 -0
- package/less/badge.less +38 -0
- package/less/bootstrap-noconflict.less +23 -0
- package/less/bootstrap.less +23 -0
- package/less/button-group.less +153 -0
- package/less/buttons.less +287 -0
- package/less/dialog-noconflict.less +174 -0
- package/less/dialog.less +203 -0
- package/less/dropdown.less +209 -0
- package/less/forms.less +770 -0
- package/less/images.less +242 -0
- package/less/input-group.less +163 -0
- package/less/list-group.less +73 -0
- package/less/mixins/aspect-ratio.less +23 -0
- package/less/mixins/border-radius.less +24 -0
- package/less/mixins/box-shadow.less +4 -0
- package/less/mixins/buttons.less +17 -0
- package/less/mixins/caret.less +51 -0
- package/less/mixins/clearfix.less +10 -0
- package/less/mixins/gradients.less +34 -0
- package/less/mixins/nav-divider.less +7 -0
- package/less/mixins/object-fit.less +13 -0
- package/less/mixins/reset-text.less +16 -0
- package/less/mixins.less +11 -0
- package/less/package.json +11 -0
- package/less/pagination.less +69 -0
- package/less/popover.less +143 -0
- package/less/project.sublime-workspace +774 -0
- package/less/reboot.less +235 -0
- package/less/section.less +793 -0
- package/less/select.less +150 -0
- package/less/tables.less +737 -0
- package/less/tabs.less +162 -0
- package/less/tooltip.less +87 -0
- package/less/type.less +71 -0
- package/less/utilities/align.less +27 -0
- package/less/utilities/animate.less +3512 -0
- package/less/utilities/background.less +70 -0
- package/less/utilities/borders.less +16 -0
- package/less/utilities/color.less +70 -0
- package/less/utilities/cursor.less +8 -0
- package/less/utilities/display.less +38 -0
- package/less/utilities/embed.less +61 -0
- package/less/utilities/flex.less +76 -0
- package/less/utilities/jquery-ui.less +116 -0
- package/less/utilities/lazyload.less +29 -0
- package/less/utilities/overflow.less +11 -0
- package/less/utilities/pace.less +25 -0
- package/less/utilities/placeholder.less +60 -0
- package/less/utilities/position.less +42 -0
- package/less/utilities/scrollbar.less +152 -0
- package/less/utilities/spacing.less +197 -0
- package/less/utilities/text.less +68 -0
- package/less/utilities/transform.less +7 -0
- package/less/utilities.less +21 -0
- package/less/variables.less +343 -0
- package/package.json +71 -0
- package/scss/LISENCE +15 -0
- package/scss/_alert.scss +125 -0
- package/scss/_badge.scss +58 -0
- package/scss/_button-group.scss +124 -0
- package/scss/_buttons.scss +206 -0
- package/scss/_custom-forms.scss +423 -0
- package/scss/_dialog.scss +149 -0
- package/scss/_dropdown.scss +234 -0
- package/scss/_forms.scss +257 -0
- package/scss/_frame.scss +523 -0
- package/scss/_functions.scss +114 -0
- package/scss/_grid.scss +35 -0
- package/scss/_images.scss +312 -0
- package/scss/_input-group.scss +245 -0
- package/scss/_list-group.scss +82 -0
- package/scss/_mixins.scss +32 -0
- package/scss/_navbar.scss +214 -0
- package/scss/_pagination.scss +79 -0
- package/scss/_popover.scss +165 -0
- package/scss/_reboot.scss +279 -0
- package/scss/_root.scss +15 -0
- package/scss/_section.scss +851 -0
- package/scss/_select.scss +166 -0
- package/scss/_tables.scss +707 -0
- package/scss/_tabs.scss +175 -0
- package/scss/_toast.scss +182 -0
- package/scss/_tooltip.scss +101 -0
- package/scss/_type.scss +90 -0
- package/scss/_utilities.scss +21 -0
- package/scss/_variables.scss +697 -0
- package/scss/cool-grid.scss +29 -0
- package/scss/cool-reboot.scss +11 -0
- package/scss/cool.scss +36 -0
- package/scss/mixins/_alert-variant.scss +40 -0
- package/scss/mixins/_aspect-ratio.scss +29 -0
- package/scss/mixins/_background-variant.scss +25 -0
- package/scss/mixins/_badge-variant.scss +13 -0
- package/scss/mixins/_breakpoints.scss +102 -0
- package/scss/mixins/_buttons.scss +104 -0
- package/scss/mixins/_caret.scss +80 -0
- package/scss/mixins/_clearfix.scss +10 -0
- package/scss/mixins/_float.scss +14 -0
- package/scss/mixins/_forms.scss +51 -0
- package/scss/mixins/_gradients.scss +40 -0
- package/scss/mixins/_grid-framework.scss +72 -0
- package/scss/mixins/_grid.scss +60 -0
- package/scss/mixins/_nav-divider.scss +9 -0
- package/scss/mixins/_object-fit.scss +16 -0
- package/scss/mixins/_reset-text.scss +19 -0
- package/scss/mixins/_text-emphasis.scss +21 -0
- package/scss/mixins/_text-hide.scss +10 -0
- package/scss/mixins/_text-truncate.scss +8 -0
- package/scss/project.sublime-workspace +491 -0
- package/scss/utilities/_align.scss +41 -0
- package/scss/utilities/_animate.scss +3512 -0
- package/scss/utilities/_background.scss +14 -0
- package/scss/utilities/_borders.scss +146 -0
- package/scss/utilities/_clearfix.scss +6 -0
- package/scss/utilities/_collapse.scss +33 -0
- package/scss/utilities/_cursor.scss +10 -0
- package/scss/utilities/_display.scss +16 -0
- package/scss/utilities/_embed.scss +78 -0
- package/scss/utilities/_flex.scss +50 -0
- package/scss/utilities/_lazyload.scss +31 -0
- package/scss/utilities/_overflow.scss +6 -0
- package/scss/utilities/_perfect-scrollbar.scss +154 -0
- package/scss/utilities/_placeholder.scss +76 -0
- package/scss/utilities/_position.scss +30 -0
- package/scss/utilities/_sizing.scss +32 -0
- package/scss/utilities/_spacing.scss +92 -0
- package/scss/utilities/_text.scss +97 -0
package/js/index.umd.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import Common from './src/common';
|
|
2
|
+
import Popover from './src/popover.js';
|
|
3
|
+
import Select from './src/select';
|
|
4
|
+
import Dropdown from './src/dropdown';
|
|
5
|
+
import Tooltip from './src/tooltip';
|
|
6
|
+
import SectionTabs from './src/section-tabs';
|
|
7
|
+
import Collapse from './src/collapse';
|
|
8
|
+
import Toast from './src/toast';
|
|
9
|
+
import Dialog from './src/dialog';
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
Common,
|
|
13
|
+
Popover,
|
|
14
|
+
Select,
|
|
15
|
+
Dropdown,
|
|
16
|
+
Tooltip,
|
|
17
|
+
SectionTabs,
|
|
18
|
+
Collapse,
|
|
19
|
+
Toast,
|
|
20
|
+
Dialog
|
|
21
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
export default class AbstractUIComponent {
|
|
2
|
+
|
|
3
|
+
// Init callback
|
|
4
|
+
onInit() {
|
|
5
|
+
|
|
6
|
+
let onInit = this.opts.onInit;
|
|
7
|
+
|
|
8
|
+
if (typeof onInit === 'function') {
|
|
9
|
+
|
|
10
|
+
onInit.call(this.el);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// Update callback
|
|
15
|
+
onUpdate() {
|
|
16
|
+
|
|
17
|
+
let onUpdate = this.opts.onUpdate;
|
|
18
|
+
|
|
19
|
+
if (typeof onUpdate === 'function') {
|
|
20
|
+
|
|
21
|
+
onUpdate.call(this.el);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Destroy callback
|
|
26
|
+
onDestroy() {
|
|
27
|
+
|
|
28
|
+
let onDestroy = this.opts.onDestroy;
|
|
29
|
+
|
|
30
|
+
if (typeof onDestroy === 'function') {
|
|
31
|
+
|
|
32
|
+
onDestroy.call(this.el);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Show callback
|
|
37
|
+
onShow() {
|
|
38
|
+
|
|
39
|
+
let onShow = this.opts.onShow;
|
|
40
|
+
|
|
41
|
+
if (typeof onShow === 'function') {
|
|
42
|
+
|
|
43
|
+
onShow.call(this.el);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Close callback
|
|
48
|
+
onClose() {
|
|
49
|
+
|
|
50
|
+
let onClose = this.opts.onClose;
|
|
51
|
+
|
|
52
|
+
if (typeof onClose === 'function') {
|
|
53
|
+
|
|
54
|
+
onClose.call(this.el);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Debug log
|
|
59
|
+
log(...args) {
|
|
60
|
+
|
|
61
|
+
if (this.debug) {
|
|
62
|
+
|
|
63
|
+
if (typeof this.debug === 'function') {
|
|
64
|
+
this.debug(...args);
|
|
65
|
+
} else {
|
|
66
|
+
console.log(...args);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import 'jquery';
|
|
2
|
+
import { debounce } from './util/index';
|
|
3
|
+
import AbstractUIComponent from './abstract-ui-component';
|
|
4
|
+
|
|
5
|
+
const NAME = 'coolCollapse';
|
|
6
|
+
const DATA_KEY = 'plugin_coolCollapse';
|
|
7
|
+
|
|
8
|
+
class Collapse extends AbstractUIComponent {
|
|
9
|
+
|
|
10
|
+
constructor(el, opts) {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.opts = {};
|
|
15
|
+
|
|
16
|
+
if (window.Cool.settings.collapse) {
|
|
17
|
+
|
|
18
|
+
$.extend(true, this.opts, $.fn[NAME].defaults, window.Cool.settings.dialog, opts);
|
|
19
|
+
|
|
20
|
+
} else {
|
|
21
|
+
|
|
22
|
+
$.extend(true, this.opts, $.fn[NAME].defaults, opts);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
this.el = el;
|
|
26
|
+
this.debug = this.opts.debug;
|
|
27
|
+
this.init();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Init plugin
|
|
31
|
+
init() {
|
|
32
|
+
|
|
33
|
+
this.buildCache()
|
|
34
|
+
this.bindEvents();
|
|
35
|
+
this.onInit();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Remove plugin instance completely
|
|
39
|
+
destroy() {
|
|
40
|
+
|
|
41
|
+
this.unbindEvents();
|
|
42
|
+
this.$el.removeData(DATA_KEY);
|
|
43
|
+
this.onDestroy();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Update plugin data
|
|
47
|
+
update() {
|
|
48
|
+
|
|
49
|
+
this.buildCache();
|
|
50
|
+
this.onUpdate();
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Cache DOM nodes for performance
|
|
54
|
+
buildCache() {
|
|
55
|
+
|
|
56
|
+
this.$el = $(this.el);
|
|
57
|
+
this.$target = this.$el.data('target') ? $(document).find(this.$el.data('target')) : $(document).find(this.opts.target);
|
|
58
|
+
this.expanded = this.$el.attr('aria-expanded') == 'true' ? true : false;
|
|
59
|
+
|
|
60
|
+
if (this.$target.length) {
|
|
61
|
+
|
|
62
|
+
this.targetHeight = this.$target.height();
|
|
63
|
+
this.$container = this.$target.closest('.section-collapse');
|
|
64
|
+
this.$indicator = $(document).find('[data-collapse-indicator="' + this.$el.data('target') + '"]');
|
|
65
|
+
|
|
66
|
+
} else {
|
|
67
|
+
|
|
68
|
+
this.$target = $(this.$el).parent().find('.collapse');
|
|
69
|
+
this.targetHeight = this.$target.height();
|
|
70
|
+
this.$container = this.$target.closest('.section-collapse');
|
|
71
|
+
this.$indicator = $(this.$el).parent().find('[data-collapse-indicator]');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this.log(this.$el);
|
|
75
|
+
this.log(this.$target);
|
|
76
|
+
this.log(this.$container);
|
|
77
|
+
this.log(this.$indicator);
|
|
78
|
+
this.log('Expanded: '+this.expanded);
|
|
79
|
+
this.log('Target height: '+this.targetHeight+'px');
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// Bind events that trigger methods
|
|
83
|
+
bindEvents() {
|
|
84
|
+
|
|
85
|
+
this.$el.on('click'+'.'+this.name, (e) => {
|
|
86
|
+
|
|
87
|
+
if (this.expanded) {
|
|
88
|
+
this.close();
|
|
89
|
+
} else {
|
|
90
|
+
this.show();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
$(window).on('resize', debounce(() => {
|
|
95
|
+
|
|
96
|
+
if (this.$target.length) {
|
|
97
|
+
|
|
98
|
+
this.targetHeight = this.$target.height();
|
|
99
|
+
this.log('Target height: '+this.targetHeight+'px');
|
|
100
|
+
}
|
|
101
|
+
}, 250));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Unbind events that trigger methods
|
|
105
|
+
unbindEvents() {
|
|
106
|
+
|
|
107
|
+
this.$el.off('.'+this.name);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Which transition
|
|
111
|
+
whichTransitionEvent() {
|
|
112
|
+
|
|
113
|
+
let el = document.createElement('text-transition');
|
|
114
|
+
let transEndEventNames = {
|
|
115
|
+
'WebkitTransition': 'webkitTransitionEnd', // Saf 6, Android Browser
|
|
116
|
+
'MozTransition': 'transitionend', // only for FF < 15
|
|
117
|
+
'transition': 'transitionend' // IE10, Opera, Chrome, FF 15+, Saf 7+
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
for (let t in transEndEventNames) {
|
|
121
|
+
|
|
122
|
+
if (el.style[t] !== undefined) {
|
|
123
|
+
return transEndEventNames[t];
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Show
|
|
129
|
+
show() {
|
|
130
|
+
|
|
131
|
+
this.$target.removeClass('collapse visible');
|
|
132
|
+
this.$target.addClass('collapsing');
|
|
133
|
+
|
|
134
|
+
if (this.$el.is('button')) {
|
|
135
|
+
this.$el.attr('disabled', true);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.$container.length) {
|
|
139
|
+
this.$container.addClass('visible');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
this.$target.css('height');
|
|
143
|
+
this.$target.css('height', this.targetHeight);
|
|
144
|
+
|
|
145
|
+
if (this.$indicator.length) {
|
|
146
|
+
this.$indicator.addClass('visible');
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
this.$target.one(this.whichTransitionEvent(), () => {
|
|
150
|
+
|
|
151
|
+
this.$target.removeClass('collapsing');
|
|
152
|
+
|
|
153
|
+
if (this.$el.is('button')) {
|
|
154
|
+
this.$el.attr('disabled', false);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
this.$target.removeAttr('style');
|
|
158
|
+
this.$target.addClass('collapse visible');
|
|
159
|
+
this.$el.attr('aria-expanded', true);
|
|
160
|
+
this.$target.css('height', 'auto');
|
|
161
|
+
this.expanded = true;
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
this.onShow();
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Close
|
|
168
|
+
close() {
|
|
169
|
+
|
|
170
|
+
this.$target.removeClass('collapse visible');
|
|
171
|
+
this.$target.addClass('collapsing');
|
|
172
|
+
|
|
173
|
+
if (this.$el.is('button')) {
|
|
174
|
+
this.$el.attr('disabled', true);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (this.$container.length) {
|
|
178
|
+
this.$container.removeClass('visible');
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
this.$target.css('height', this.$target.height());
|
|
182
|
+
|
|
183
|
+
setTimeout(() => {
|
|
184
|
+
this.$target.css('height', 0);
|
|
185
|
+
}, 10);
|
|
186
|
+
|
|
187
|
+
if (this.$indicator.length && this.$indicator.hasClass('visible')) {
|
|
188
|
+
this.$indicator.removeClass('visible');
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
this.$target.one(this.whichTransitionEvent(), () => {
|
|
192
|
+
|
|
193
|
+
this.$target.removeClass('collapsing');
|
|
194
|
+
|
|
195
|
+
if (this.$el.is('button')) {
|
|
196
|
+
this.$el.attr('disabled', false);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
this.$target.removeAttr('style');
|
|
200
|
+
this.$target.addClass('collapse');
|
|
201
|
+
this.$el.attr('aria-expanded', false);
|
|
202
|
+
this.expanded = false;
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
this.onClose();
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
static _jQueryInterface(config) {
|
|
209
|
+
|
|
210
|
+
return this.each(function() {
|
|
211
|
+
|
|
212
|
+
let data = $(this).data(DATA_KEY);
|
|
213
|
+
const _config = typeof config === 'object' && config;
|
|
214
|
+
|
|
215
|
+
if (!data) {
|
|
216
|
+
data = new Collapse(this, _config);
|
|
217
|
+
$(this).data(DATA_KEY, data);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (typeof config === 'string') {
|
|
221
|
+
|
|
222
|
+
if (typeof data[config] === 'undefined') {
|
|
223
|
+
throw new TypeError(`No method named "${config}"`)
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
data[config]()
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (typeof $ !== 'undefined') {
|
|
233
|
+
|
|
234
|
+
// jQuery
|
|
235
|
+
const JQUERY_NO_CONFLICT = $.fn[NAME];
|
|
236
|
+
|
|
237
|
+
$.fn[NAME] = Collapse._jQueryInterface;
|
|
238
|
+
$.fn[NAME].Constructor = Collapse;
|
|
239
|
+
|
|
240
|
+
$.fn[NAME].noConflict = () => {
|
|
241
|
+
|
|
242
|
+
$.fn[NAME] = JQUERY_NO_CONFLICT
|
|
243
|
+
|
|
244
|
+
return Collapse._jQueryInterface
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
$.fn[NAME].defaults = {
|
|
248
|
+
target: null,
|
|
249
|
+
onInit: null,
|
|
250
|
+
onUpdate: null,
|
|
251
|
+
onDestroy: null,
|
|
252
|
+
onShow: null,
|
|
253
|
+
onClose: null,
|
|
254
|
+
debug: false
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
export default Collapse;
|
package/js/src/common.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import 'jquery';
|
|
2
|
+
import PerfectScrollbar from './util/perfect-scrollbar';
|
|
3
|
+
import './util/animate-css';
|
|
4
|
+
|
|
5
|
+
window.Cool = window.Cool || {};
|
|
6
|
+
window.Cool.settings = window.Cool.settings || {};
|
|
7
|
+
|
|
8
|
+
class Common {
|
|
9
|
+
|
|
10
|
+
static initialize(opts) {
|
|
11
|
+
|
|
12
|
+
// There's an error if opts is not defined
|
|
13
|
+
opts = opts || {};
|
|
14
|
+
|
|
15
|
+
// Save settings for later use
|
|
16
|
+
window.Cool.settings = opts;
|
|
17
|
+
|
|
18
|
+
// Init plugins
|
|
19
|
+
$('[data-toggle="popover"]').coolPopover(opts.popover);
|
|
20
|
+
$('[data-toggle="select"]').coolSelect(opts.select);
|
|
21
|
+
$('[data-toggle="dropdown"]').coolDropdown(opts.dropdown);
|
|
22
|
+
$('[data-toggle="tooltip"]').coolTooltip(opts.tooltip);
|
|
23
|
+
$('[data-toggle="collapse"]').coolCollapse(opts.collapse);
|
|
24
|
+
$('[data-toggle="section-tabs"]').coolSectionTabs(opts.sectionTabs);
|
|
25
|
+
$('body').coolToast(opts.toast);
|
|
26
|
+
$('body').coolDialog(opts.dialog);
|
|
27
|
+
|
|
28
|
+
// Dom ready
|
|
29
|
+
$('html').addClass('dom-ready');
|
|
30
|
+
|
|
31
|
+
// Input group focus in
|
|
32
|
+
$(document).on('focus', '.form-control', function () {
|
|
33
|
+
|
|
34
|
+
if (!$(this).hasClass('disabled') && $(this).not(':disabled') && !$(this).attr('readonly')) {
|
|
35
|
+
|
|
36
|
+
let $inputGroup = $(this).closest('.input-group');
|
|
37
|
+
|
|
38
|
+
if (!$inputGroup.hasClass('input-group-focus')) {
|
|
39
|
+
$inputGroup.addClass('input-group-focus');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
// Input group focus out
|
|
45
|
+
$(document).on('blur', '.form-control', function () {
|
|
46
|
+
|
|
47
|
+
if (!$(this).hasClass('disabled') && $(this).not(':disabled') && !$(this).attr('readonly')) {
|
|
48
|
+
|
|
49
|
+
let $inputGroup = $(this).closest('.input-group');
|
|
50
|
+
|
|
51
|
+
if ($inputGroup.hasClass('input-group-focus')) {
|
|
52
|
+
$inputGroup.removeClass('input-group-focus');
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
// Custom Form group
|
|
58
|
+
$('.form-label-group').each(function(i, formLabelGroup) {
|
|
59
|
+
|
|
60
|
+
let $formLabelGroup = $(formLabelGroup);
|
|
61
|
+
|
|
62
|
+
$formLabelGroup.find('input').on('blur input change', function () {
|
|
63
|
+
|
|
64
|
+
let val = $(this).val();
|
|
65
|
+
|
|
66
|
+
if (val) {
|
|
67
|
+
$(formLabelGroup).addClass('label-on-top');
|
|
68
|
+
} else {
|
|
69
|
+
$(formLabelGroup).removeClass('label-on-top');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
}).trigger('change');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Table actions
|
|
76
|
+
$.each($('.table'), function() {
|
|
77
|
+
|
|
78
|
+
if ($(this).find('[data-table-link], [data-table-btn]').length && !$(this).hasClass('table-hover')) {
|
|
79
|
+
$(this).addClass('table-hover');
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
$(document).on('click', '[data-table-link]', function(e) {
|
|
84
|
+
|
|
85
|
+
let $container = $(this).parents('table, .table');
|
|
86
|
+
let href = $(this).data('tableLink');
|
|
87
|
+
let target = $(e.target);
|
|
88
|
+
let exceptions = ['input', 'button', 'a', 'label', 'td.col-select'];
|
|
89
|
+
let linkDisabled = false;
|
|
90
|
+
|
|
91
|
+
$.each(exceptions, function(item) {
|
|
92
|
+
|
|
93
|
+
if (target.is(item) || (item == 'a' && target.parent().is(item))) {
|
|
94
|
+
linkDisabled = true;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
if ($container.hasClass('bulk-actions-active')) {
|
|
99
|
+
linkDisabled = true;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (target.is('td, .td, img') && !linkDisabled) {
|
|
103
|
+
|
|
104
|
+
if (e.ctrlKey || e.metaKey) {
|
|
105
|
+
|
|
106
|
+
window.open(href, '_blank');
|
|
107
|
+
|
|
108
|
+
} else {
|
|
109
|
+
|
|
110
|
+
window.location.href = href;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
} else {
|
|
114
|
+
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
$(document).on('click', '[data-table-btn]', function(e) {
|
|
120
|
+
|
|
121
|
+
let $container = $(this).parents('table, .table');
|
|
122
|
+
let $self = $(this);
|
|
123
|
+
let btn = $(this).data('tableButton');
|
|
124
|
+
let target = $(e.target);
|
|
125
|
+
let exceptions = ['input', 'button', 'a', 'label', 'td.col-select'];
|
|
126
|
+
let btnDisabled = false;
|
|
127
|
+
|
|
128
|
+
if (!btn) {
|
|
129
|
+
|
|
130
|
+
btn = $self.find('button')[0];
|
|
131
|
+
|
|
132
|
+
if (!btn) {
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
$.each(exceptions, function(item) {
|
|
138
|
+
|
|
139
|
+
if (target.is(item) || (item == 'a' && target.parent().is(item))) {
|
|
140
|
+
btnDisabled = true;
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
if ($container.hasClass('bulk-actions-active')) {
|
|
145
|
+
btnDisabled = true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (target.is('td, .td, img') && !btnDisabled) {
|
|
149
|
+
|
|
150
|
+
$(btn).click();
|
|
151
|
+
|
|
152
|
+
} else {
|
|
153
|
+
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// Force select element unfocus after change
|
|
159
|
+
$('select').on('change', function() {
|
|
160
|
+
$(this).blur();
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// Tabs
|
|
164
|
+
$('.tab-toggler').on('click', function(e) {
|
|
165
|
+
|
|
166
|
+
e.stopPropagation();
|
|
167
|
+
|
|
168
|
+
$(this).parent().toggleClass('open');
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
$(document).on('click', function() {
|
|
172
|
+
|
|
173
|
+
$('.tabs-container').removeClass('open');
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// Sidebar togglers
|
|
177
|
+
$('.sidebar-left-toggler').on('click', function(e) {
|
|
178
|
+
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
|
|
181
|
+
$(this).toggleClass('open');
|
|
182
|
+
$('body').toggleClass('sidebar-left-open');
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
$('.sidebar-right-toggler').on('click', function(e) {
|
|
186
|
+
|
|
187
|
+
e.stopPropagation();
|
|
188
|
+
|
|
189
|
+
$(this).toggleClass('open');
|
|
190
|
+
$('body').toggleClass('sidebar-right-open');
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// Sidebar scroll
|
|
194
|
+
$('.sidebar-content .ps__thumb-y').mousedown(function() {
|
|
195
|
+
$(this).parent().parent().addClass('ps-mousedown-scroll');
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
$(document).mouseup(function() {
|
|
199
|
+
|
|
200
|
+
if ($('.sidebar-content').hasClass('ps-mousedown-scroll')) {
|
|
201
|
+
$('.sidebar-content').removeClass('ps-mousedown-scroll');
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
|
|
205
|
+
// Sidebar left scroll
|
|
206
|
+
let $sidebarLeft = $('.sidebar-left');
|
|
207
|
+
let $sidebarLeftContent = $sidebarLeft.find('.sidebar-content');
|
|
208
|
+
|
|
209
|
+
if ($sidebarLeftContent.length) {
|
|
210
|
+
|
|
211
|
+
let sidebarLeftScroll = new PerfectScrollbar($sidebarLeftContent[0], {
|
|
212
|
+
wheelSpeed: 2,
|
|
213
|
+
wheelPropagation: true,
|
|
214
|
+
minScrollbarLength: 20,
|
|
215
|
+
suppressScrollX: true
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Sidebar tabs
|
|
220
|
+
let $sidebarTabs = $(document).find('.sidebar-tab');
|
|
221
|
+
|
|
222
|
+
if ($sidebarTabs.length) {
|
|
223
|
+
|
|
224
|
+
$.each($sidebarTabs, function(i, el) {
|
|
225
|
+
|
|
226
|
+
let scrollContainer = $(el).find('.tab-content');
|
|
227
|
+
|
|
228
|
+
const sidebarTabsScroll = new PerfectScrollbar(scrollContainer[0], {
|
|
229
|
+
wheelSpeed: 2,
|
|
230
|
+
wheelPropagation: true,
|
|
231
|
+
minScrollbarLength: 20,
|
|
232
|
+
suppressScrollX: true
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
$('[name="sidebar-tab-select"]').on('click', function() {
|
|
237
|
+
|
|
238
|
+
let val = $(this).val();
|
|
239
|
+
let $tab = $('#sidebar-tab-'+val);
|
|
240
|
+
|
|
241
|
+
$sidebarTabs.not($tab).removeClass('active');
|
|
242
|
+
$tab.addClass('active');
|
|
243
|
+
|
|
244
|
+
$('[name="sidebar-tab-select"]').not($(this)).removeClass('active');
|
|
245
|
+
$(this).addClass('active');
|
|
246
|
+
|
|
247
|
+
if ($tab[0] == $sidebarTabs.first()[0]) {
|
|
248
|
+
|
|
249
|
+
$sidebarTabs.not($tab).find('.tab-content').css({
|
|
250
|
+
'transform': 'translate3d(100%, 0px, 0px)'
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
} else if ($tab[0] == $sidebarTabs.last()[0]) {
|
|
254
|
+
|
|
255
|
+
$sidebarTabs.not($tab).find('.tab-content').css({
|
|
256
|
+
'transform': 'translate3d(-100%, 0px, 0px)'
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
} else {
|
|
260
|
+
|
|
261
|
+
$sidebarTabs.first().not($tab).find('.tab-content').css({
|
|
262
|
+
'transform': 'translate3d(-100%, 0px, 0px)'
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
$sidebarTabs.last().not($tab).find('.tab-content').css({
|
|
266
|
+
'transform': 'translate3d(100%, 0px, 0px)'
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
$tab.find('.tab-content').css({
|
|
271
|
+
'transform': 'none'
|
|
272
|
+
});
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
window.Cool.initialize = Common.initialize;
|
|
279
|
+
|
|
280
|
+
export default Common;
|