bobjoll 1.0.3
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 +35 -0
- package/package.json +25 -0
- package/scss/layout/_footer.scss +10 -0
- package/scss/layout/_header.scss +10 -0
- package/scss/modules/_fonts.scss +26 -0
- package/scss/modules/_reset.scss +219 -0
- package/scss/modules/bourbon/addons/_clearfix.scss +25 -0
- package/scss/modules/bourbon/addons/_ellipsis.scss +30 -0
- package/scss/modules/bourbon/addons/_position.scss +48 -0
- package/scss/modules/bourbon/addons/_prefixer.scss +66 -0
- package/scss/modules/bourbon/addons/_size.scss +51 -0
- package/scss/modules/bourbon/addons/_timing-functions.scss +34 -0
- package/scss/modules/bourbon/addons/_triangle.scss +63 -0
- package/scss/modules/bourbon/css3/_calc.scss +4 -0
- package/scss/modules/bourbon/css3/_flex-box.scss +287 -0
- package/scss/modules/bourbon/css3/_keyframes.scss +36 -0
- package/scss/modules/bourbon/css3/_linear-gradient.scss +38 -0
- package/scss/modules/bourbon/css3/_placeholder.scss +8 -0
- package/scss/modules/bourbon/css3/_selection.scss +42 -0
- package/scss/modules/bourbon/css3/_transition.scss +71 -0
- package/scss/modules/mixins/_component.scss +9 -0
- package/scss/modules/mixins/_grid.scss +75 -0
- package/scss/modules/mixins/_helpers.scss +224 -0
- package/scss/modules/variables/_colors.scss +447 -0
- package/scss/modules/variables/_general.scss +235 -0
- package/scss/partials/_accordion-v1-0.scss +165 -0
- package/scss/partials/_autocomplete-v1-0.scss +55 -0
- package/scss/partials/_general-v1-0.scss +51 -0
- package/scss/partials/_grid-v1-0.scss +109 -0
- package/scss/partials/_helper-v1-0.scss +299 -0
- package/scss/partials/_icon-v2-0.scss +323 -0
- package/scss/partials/_list-v1-0.scss +100 -0
- package/scss/partials/_modal-v1-0.scss +159 -0
- package/scss/partials/_notification-v1-1.scss +297 -0
- package/scss/partials/_progress-bar-v1.0.scss +25 -0
- package/scss/partials/_range-v1.0.scss +75 -0
- package/scss/partials/_tooltipFixed-v1.0.scss +128 -0
- package/scss/partials/_typography-v1-0.scss +201 -0
- package/scss/partials/animations/_fade.scss +23 -0
- package/scss/partials/animations/_rotate.scss +11 -0
- package/scss/partials/animations/_scale.scss +23 -0
- package/scss/partials/animations/_slide.scss +31 -0
- package/scss/partials/button-v4-0/_component.scss +304 -0
- package/scss/partials/form/_checkbox-and-radio-v1-0.scss +187 -0
- package/scss/partials/form/_dropdowns-v1-0.scss +323 -0
- package/scss/partials/form/_general-v1-0.scss +166 -0
- package/scss/partials/form/_group-v1-0.scss +157 -0
- package/scss/partials/form/_password-v1-0.scss +28 -0
- package/scss/partials/form/_switch-v1-0.scss +128 -0
- package/scss/partials/form/_upload-v1-0.scss +91 -0
- package/ts/library/common.ts +30 -0
- package/ts/library/cookie.ts +47 -0
- package/ts/library/delegate.ts +122 -0
- package/ts/library/dom.ts +124 -0
- package/ts/library/event.ts +138 -0
- package/ts/library/extend.js +32 -0
- package/ts/library/gr/dom.q.ts +12 -0
- package/ts/library/gr/social/dependency/twitter_pu.js +66 -0
- package/ts/library/gr/social/facebook.ts +154 -0
- package/ts/library/gr/social/google.ts +127 -0
- package/ts/library/gr/social/index.ts +35 -0
- package/ts/library/gr/social/twitter.ts +65 -0
- package/ts/library/helpers.ts +9 -0
- package/ts/library/number-abbreviate.js +57 -0
- package/ts/library/settings.ts +7 -0
- package/ts/library/storage.ts +131 -0
- package/ts/library/svg4everybody.legacy.js +122 -0
- package/ts/partials/accordion-v1.0.ts +104 -0
- package/ts/partials/accordionTabs-v1.0.ts +27 -0
- package/ts/partials/alert-v1.0.ts +51 -0
- package/ts/partials/copy-v1.0.ts +17 -0
- package/ts/partials/countdown-v1.0.ts +119 -0
- package/ts/partials/dropdown-v1.0.ts +247 -0
- package/ts/partials/hbs-v1.0.ts +9 -0
- package/ts/partials/modal-v1.0.ts +213 -0
- package/ts/partials/notifications-v1.1.ts +376 -0
- package/ts/partials/notify-v1.0.ts +746 -0
- package/ts/partials/password-v1.0.ts +19 -0
- package/ts/partials/popover-v1.0.ts +125 -0
- package/ts/partials/progress-bar-v1.0.ts +29 -0
- package/ts/partials/scroll-v1.0.ts +169 -0
- package/ts/partials/scrollable-v1.0.ts +90 -0
- package/ts/partials/tabs-v1.0.ts +79 -0
- package/ts/partials/tags-v1.0.ts +21 -0
- package/ts/partials/trigger-v2.0.ts +155 -0
- package/ts/partials/upload-v1.0.ts +17 -0
- package/ts/views/hbs/alert-v1.0/element.html.hbs +35 -0
- package/ts/views/hbs/countdown-v1.0/countdown-inner.hbs +39 -0
- package/ts/views/hbs/countdown-v1.0/countdown.hbs +4 -0
- package/ts/views/hbs/dropdown-v1.0/element.html.hbs +70 -0
- package/ts/views/hbs/helpers.js +58 -0
- package/ts/views/hbs/modal-v1.0/element.html.hbs +17 -0
- package/ts/views/hbs/notification-v1.1/element-disable.html.hbs +26 -0
- package/ts/views/hbs/notification-v1.1/element.html.hbs +43 -0
- package/ts/views/hbs/notification-v1.1/wrapper.html.hbs +4 -0
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
import { Cookie } from 'bobjoll/ts/library/cookie';
|
|
2
|
+
import { KEvent, KEventTarget } from 'bobjoll/ts/library/event';
|
|
3
|
+
import { modal, Modal, ModalPrintSettings } from 'BobjollModal';
|
|
4
|
+
import { q, ww } from 'bobjoll/ts/library/dom';
|
|
5
|
+
import { qq } from 'bobjoll/ts/library/gr/dom.q';
|
|
6
|
+
import { Settings } from 'bobjoll/ts/library/settings';
|
|
7
|
+
import Notification from 'BobjollNotifications';
|
|
8
|
+
|
|
9
|
+
export class Notify extends KEventTarget {
|
|
10
|
+
private static readonly cookieNamespace = 'notify';
|
|
11
|
+
private static readonly bodyPaddingBottom = window.getComputedStyle(document.body).getPropertyValue('padding-bottom');
|
|
12
|
+
private static readonly methods: NotifyMethods = {
|
|
13
|
+
banner: new Notification({
|
|
14
|
+
fixed: true,
|
|
15
|
+
recurrent: true,
|
|
16
|
+
}),
|
|
17
|
+
popup: modal,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
private static User: NotifyUser;
|
|
21
|
+
private static History: NotifyHistory;
|
|
22
|
+
private static active: string | null;
|
|
23
|
+
private static instance: Notify;
|
|
24
|
+
private static containerBottom: HTMLElement;
|
|
25
|
+
private static containerTop: HTMLElement;
|
|
26
|
+
private static queue: (DialogBannerSettings | DialogPopupSettings | DialogNotificationSettings | DialogCustomSettings | DialogQuechuaSettings)[] = [];
|
|
27
|
+
|
|
28
|
+
constructor(options: NotifyOptions) {
|
|
29
|
+
if (!Notify.instance) {
|
|
30
|
+
super();
|
|
31
|
+
Notify.User = options.User;
|
|
32
|
+
Notify.History = options.History;
|
|
33
|
+
Notify.instance = this;
|
|
34
|
+
Notify.setup();
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return Notify.instance;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
private static setup() {
|
|
41
|
+
Notify.addBaseElements();
|
|
42
|
+
Notify.addEventListeners();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private static preload(settings: DialogBannerSettings | DialogPopupSettings | DialogNotificationSettings | DialogQuechuaSettings) {
|
|
46
|
+
const images = [...(settings.preloadAdditional || [])];
|
|
47
|
+
const dom = document.createElement('div');
|
|
48
|
+
|
|
49
|
+
dom.innerHTML = settings.html + settings.getPathValue('globalVariables.containerHtml');
|
|
50
|
+
|
|
51
|
+
(qq('img', dom) as HTMLImageElement[]).forEach(img => images.push(img.src));
|
|
52
|
+
|
|
53
|
+
return new Promise(resolve => {
|
|
54
|
+
let completeCounter = 0;
|
|
55
|
+
let total = images.length;
|
|
56
|
+
|
|
57
|
+
function completeCallback() {
|
|
58
|
+
completeCounter++;
|
|
59
|
+
if (completeCounter === total) resolve();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
images.forEach(src => {
|
|
63
|
+
const image = new Image();
|
|
64
|
+
image.src = src;
|
|
65
|
+
image.onabort = image.onerror = image.onload = completeCallback;
|
|
66
|
+
if (image.complete) completeCallback();
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
private static preloadDependencies(dependencies: DependenciesObject[]) {
|
|
72
|
+
return new Promise(resolve => {
|
|
73
|
+
let completed = 0;
|
|
74
|
+
let dependencyIntervalCounter: { [id: string]: number } = {};
|
|
75
|
+
let dependencyIntervals: { [id: string]: any } = {};
|
|
76
|
+
|
|
77
|
+
function completeCallback() {
|
|
78
|
+
completed++;
|
|
79
|
+
if (completed === dependencies.length) resolve();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function cleanupCallback(id: string) {
|
|
83
|
+
clearInterval(dependencyIntervals[id]);
|
|
84
|
+
delete dependencyIntervals[id];
|
|
85
|
+
delete dependencyIntervalCounter[id];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
dependencies.forEach(dependency => {
|
|
89
|
+
if (!document.getElementById(dependency.id)) {
|
|
90
|
+
(function(d, s, id) {
|
|
91
|
+
var js,
|
|
92
|
+
fjs = d.getElementsByTagName(s)[0];
|
|
93
|
+
if (d.getElementById(id)) return;
|
|
94
|
+
js = d.createElement(s) as HTMLScriptElement;
|
|
95
|
+
js.id = id;
|
|
96
|
+
js.src = dependency.url;
|
|
97
|
+
if (fjs.parentNode) fjs.parentNode.insertBefore(js, fjs);
|
|
98
|
+
})(document, 'script', dependency.id);
|
|
99
|
+
|
|
100
|
+
dependencyIntervalCounter[dependency.id] = 0;
|
|
101
|
+
dependencyIntervals[dependency.id] = setInterval(function() {
|
|
102
|
+
if (ww[dependency.variable]) {
|
|
103
|
+
completeCallback();
|
|
104
|
+
cleanupCallback(dependency.id);
|
|
105
|
+
}
|
|
106
|
+
dependencyIntervalCounter[dependency.id]++;
|
|
107
|
+
}, 100);
|
|
108
|
+
|
|
109
|
+
setTimeout(() => cleanupCallback(dependency.id), 10000);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
private static addBaseElements() {
|
|
116
|
+
if (!q('.notify-wrapper--top')) {
|
|
117
|
+
Notify.containerTop = document.createElement('div');
|
|
118
|
+
Notify.containerTop.classList.add('notify-wrapper', 'notify-wrapper--top');
|
|
119
|
+
document.body.insertAdjacentElement('afterbegin', Notify.containerTop);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!q('.notify-wrapper--bottom')) {
|
|
123
|
+
Notify.containerBottom = document.createElement('div');
|
|
124
|
+
Notify.containerBottom.classList.add('notify-wrapper', 'notify-wrapper--bottom');
|
|
125
|
+
document.body.insertAdjacentElement('beforeend', Notify.containerBottom);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private static addEventListeners() {
|
|
130
|
+
Notify.instance.addEventListener('show', () => Notify.resize());
|
|
131
|
+
window.addEventListener('resize', () => Notify.resize());
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
private static pushQueue(settings: DialogBannerSettings | DialogPopupSettings | DialogNotificationSettings | DialogCustomSettings | DialogQuechuaSettings) {
|
|
135
|
+
Notify.queue.push(settings);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
private static printMethodBanner(settings: DialogBannerSettings) {
|
|
139
|
+
Notify.containerTop.innerHTML = '';
|
|
140
|
+
Notify.containerBottom.innerHTML = '';
|
|
141
|
+
|
|
142
|
+
Notify.methods.banner.insert({
|
|
143
|
+
id: settings.id,
|
|
144
|
+
class: `notify notify--banner notification--static notification--no-shadow notification--no-border notification--hide-disable mg-none-i ${settings.class ||
|
|
145
|
+
''}`,
|
|
146
|
+
html: settings.html,
|
|
147
|
+
insert: {
|
|
148
|
+
element: 'top' === settings.position ? Notify.containerTop : Notify.containerBottom,
|
|
149
|
+
position: 'beforeend',
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
Notify.printMethodDone(settings);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
private static printMethodPopup(settings: DialogPopupSettings) {
|
|
157
|
+
let options: ModalPrintSettings = {
|
|
158
|
+
name: settings.id,
|
|
159
|
+
html: settings.html,
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
if (settings.globalVariables) {
|
|
163
|
+
options = { ...options, ...settings.globalVariables };
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
Notify.methods.popup.add(options);
|
|
167
|
+
|
|
168
|
+
setTimeout(() => Notify.methods.popup.show(`modal-${settings.id}`), 50);
|
|
169
|
+
|
|
170
|
+
Notify.printMethodDone(settings);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
private static printMethodQuechua(settings: DialogQuechuaSettings) {
|
|
174
|
+
Notify.containerTop.innerHTML = '';
|
|
175
|
+
Notify.containerBottom.innerHTML = '';
|
|
176
|
+
|
|
177
|
+
Notify.methods.banner.insert({
|
|
178
|
+
id: settings.id,
|
|
179
|
+
class: `notify notify--banner notification--static notification--no-shadow notification--no-border notification--hide-disable mg-none-i ${settings.class ||
|
|
180
|
+
''}`,
|
|
181
|
+
html: settings.html,
|
|
182
|
+
insert: {
|
|
183
|
+
element: settings.container,
|
|
184
|
+
position: 'beforeend',
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
Notify.printMethodDone(settings);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
private static printMethodCustom(settings: DialogCustomSettings) {
|
|
192
|
+
settings.callback();
|
|
193
|
+
settings.closeCallback(() => Notify.printMethodClose(settings));
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
private static printMethodNotification(settings: DialogNotificationSettings) {
|
|
197
|
+
Notify.containerTop.innerHTML = '';
|
|
198
|
+
Notify.containerBottom.innerHTML = '';
|
|
199
|
+
|
|
200
|
+
Notify.methods.banner.insert({
|
|
201
|
+
id: settings.id,
|
|
202
|
+
class: `notify notify--banner notification--hide-disable ${settings.class || ''}`,
|
|
203
|
+
html: settings.html,
|
|
204
|
+
position: settings.position,
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
Notify.printMethodDone(settings);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
private static printMethodClose(settings: DialogBannerSettings | DialogPopupSettings | DialogCustomSettings | DialogNotificationSettings | DialogQuechuaSettings) {
|
|
211
|
+
Notify.active = null;
|
|
212
|
+
Notify.instance.dispatchEvent(new KEventHide(settings));
|
|
213
|
+
|
|
214
|
+
Notify.instance.hide(settings.id);
|
|
215
|
+
|
|
216
|
+
if (settings.type.match(/popup/)) {
|
|
217
|
+
setTimeout(() => window.dispatchEvent(new Event('resize')), 50);
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
setTimeout(Notify.resize, 50);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
private static printMethodDone(settings: DialogBannerSettings | DialogPopupSettings | DialogNotificationSettings | DialogQuechuaSettings) {
|
|
224
|
+
const notifyElement = document.getElementById(settings.id) || document.getElementById(`modal-${settings.id}`);
|
|
225
|
+
const expires =
|
|
226
|
+
settings.schedule && settings.schedule.dateExpire
|
|
227
|
+
? settings.schedule.dateExpire
|
|
228
|
+
: settings.expires
|
|
229
|
+
? settings.expires(new Date())
|
|
230
|
+
: new Date(new Date().getTime() + 1 * 60 * 60 * 1000);
|
|
231
|
+
|
|
232
|
+
Notify.active = settings.id;
|
|
233
|
+
Notify.instance.dispatchEvent(new KEventShow(settings));
|
|
234
|
+
|
|
235
|
+
if (notifyElement) {
|
|
236
|
+
if (settings.type.match(/notification|banner|quechua/)) {
|
|
237
|
+
const bannerClose = q('.notification__close', notifyElement);
|
|
238
|
+
|
|
239
|
+
if (bannerClose) {
|
|
240
|
+
bannerClose.addEventListener('click', () => Notify.printMethodClose(settings));
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (settings.type.match(/popup/)) {
|
|
245
|
+
notifyElement.classList.add(settings.class || '');
|
|
246
|
+
|
|
247
|
+
notifyElement.addEventListener('hide', () => Notify.printMethodClose(settings));
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
if (settings.count) {
|
|
251
|
+
const count = parseFloat(Cookie.getItem(`${Notify.cookieNamespace}--${settings.id}--count`) || '1');
|
|
252
|
+
|
|
253
|
+
Cookie.setItem(`${Notify.cookieNamespace}--${settings.id}--count`, (count + 1).toString(), {
|
|
254
|
+
expires: expires,
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
if (settings.callback) {
|
|
260
|
+
settings.callback(notifyElement, settings);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
private static resize() {
|
|
265
|
+
const currentPaddingTop = parseFloat(Notify.bodyPaddingBottom || '0');
|
|
266
|
+
const height = qq('.notify', Notify.containerBottom).reduce((acc: number, element) => {
|
|
267
|
+
acc += element.clientHeight;
|
|
268
|
+
return acc;
|
|
269
|
+
}, currentPaddingTop);
|
|
270
|
+
|
|
271
|
+
if (height) {
|
|
272
|
+
document.body.style.paddingBottom = `${height || 0}px`;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
if (!height && currentPaddingTop > 0) {
|
|
276
|
+
document.body.style.paddingBottom = '0px';
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
public static checkDebugEnviroment() {
|
|
281
|
+
return 'debug' === (Cookie.getItem('notify') || '') ? true : false;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
public static checkDisabledEnviroment() {
|
|
285
|
+
return 'disabled' === (Cookie.getItem('notify') || '') ? true : false;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
public addEventListener(t: 'show', listener: (ev: KEvent) => any, useCapture?: boolean): void;
|
|
289
|
+
public addEventListener(t: 'hide', listener: (ev: KEvent) => any, useCapture?: boolean): void;
|
|
290
|
+
public addEventListener(t: string, listener: (ev: KEvent) => any, useCapture: boolean = true): void {
|
|
291
|
+
super.addEventListener(t, listener, useCapture);
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
public addBanner(settings: DialogBannerOptions) {
|
|
295
|
+
Notify.pushQueue({ showMobile: true, ...settings, type: 'banner' });
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
public addNotification(settings: DialogNotificationOptions) {
|
|
299
|
+
Notify.pushQueue({ showMobile: true, ...settings, type: 'notification' });
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
public addPopup(settings: DialogPopupOptions) {
|
|
303
|
+
Notify.pushQueue({ showMobile: true, ...settings, type: 'popup' });
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
public addCustom(settings: DialogCustomOptions) {
|
|
307
|
+
Notify.pushQueue({ showMobile: true, ...settings, type: 'custom' });
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
public addQuechua(settings: DialogQuechuaOptions) {
|
|
311
|
+
Notify.pushQueue({ showMobile: true, ...settings, type: 'quechua' });
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
public async printQueue() {
|
|
315
|
+
if (Notify.active || Notify.checkDisabledEnviroment()) return;
|
|
316
|
+
|
|
317
|
+
const date = new Date();
|
|
318
|
+
const isDebugEnviroment = Notify.checkDebugEnviroment();
|
|
319
|
+
const queue = Notify.queue
|
|
320
|
+
.sort((a, b) => a.priority - b.priority)
|
|
321
|
+
.filter(dialog => {
|
|
322
|
+
if (!Cookie.getItem(`${Notify.cookieNamespace}--${dialog.id}`)) {
|
|
323
|
+
const booleanArr: {
|
|
324
|
+
name: string;
|
|
325
|
+
show: boolean;
|
|
326
|
+
}[] = [];
|
|
327
|
+
const debugIgnore = dialog.schedule ? (dialog.schedule.dateIgnoreOnDebug ? isDebugEnviroment : false) : false;
|
|
328
|
+
|
|
329
|
+
if ('undefined' !== typeof dialog.showPremiumFlaticon) {
|
|
330
|
+
booleanArr.push({
|
|
331
|
+
name: 'dialog.showPremiumFlaticon',
|
|
332
|
+
show: Notify.User.isPremiumFlaticon() ? dialog.showPremiumFlaticon : !dialog.showPremiumFlaticon,
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if ('undefined' !== typeof dialog.showPremiumFreepik) {
|
|
337
|
+
booleanArr.push({
|
|
338
|
+
name: 'dialog.showPremiumFreepik',
|
|
339
|
+
show: Notify.User.isPremiumFreepik() ? dialog.showPremiumFreepik : !dialog.showPremiumFreepik,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if ('undefined' !== typeof dialog.showPremiumFreepikAnnual) {
|
|
344
|
+
booleanArr.push({
|
|
345
|
+
name: 'dialog.showPremiumFreepikAnnual',
|
|
346
|
+
show: Notify.User.isPremiumFreepikAnnual() ? dialog.showPremiumFreepikAnnual : !dialog.showPremiumFreepikAnnual,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if ('undefined' !== typeof dialog.showPremiumFreepikMonthly) {
|
|
351
|
+
booleanArr.push({
|
|
352
|
+
name: 'dialog.showPremiumFreepikMonthly',
|
|
353
|
+
show: Notify.User.isPremiumFreepikMonthly() ? dialog.showPremiumFreepikMonthly : !dialog.showPremiumFreepikMonthly,
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
if ('undefined' !== typeof dialog.showPremiumFlaticonAnnual) {
|
|
358
|
+
booleanArr.push({
|
|
359
|
+
name: 'dialog.showPremiumFlaticonAnnual',
|
|
360
|
+
show: Notify.User.isPremiumFlaticonAnnual() ? dialog.showPremiumFlaticonAnnual : !dialog.showPremiumFlaticonAnnual,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if ('undefined' !== typeof dialog.showPremiumFlaticonMonthly) {
|
|
365
|
+
booleanArr.push({
|
|
366
|
+
name: 'dialog.showPremiumFlaticonMonthly',
|
|
367
|
+
show: Notify.User.isPremiumFlaticonMonthly() ? dialog.showPremiumFlaticonMonthly : !dialog.showPremiumFlaticonMonthly,
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
if ('undefined' !== typeof dialog.showRenewalCanceledFlaticon) {
|
|
372
|
+
booleanArr.push({
|
|
373
|
+
name: 'dialog.showRenewalCanceledFlaticon',
|
|
374
|
+
show: Notify.User.isRenewalCanceledFlaticon() ? dialog.showRenewalCanceledFlaticon : !dialog.showRenewalCanceledFlaticon,
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
if ('undefined' !== typeof dialog.showRenewalCanceledFreepik) {
|
|
379
|
+
booleanArr.push({
|
|
380
|
+
name: 'dialog.showRenewalCanceledFreepik',
|
|
381
|
+
show: Notify.User.isRenewalCanceledFreepik() ? dialog.showRenewalCanceledFreepik : !dialog.showRenewalCanceledFreepik,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
if ('undefined' !== typeof dialog.showRenewalCanceledPlus) {
|
|
386
|
+
booleanArr.push({
|
|
387
|
+
name: 'dialog.showCanceledk',
|
|
388
|
+
show: Notify.User.isRenewalCanceledPlus() ? dialog.showRenewalCanceledPlus : !dialog.showRenewalCanceledPlus,
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if ('undefined' !== typeof dialog.showFree) {
|
|
393
|
+
booleanArr.push({
|
|
394
|
+
name: 'dialog.showFree',
|
|
395
|
+
show: Notify.User.type().match(/free|guest/gi) ? !!dialog.showFree : true,
|
|
396
|
+
});
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
if ('undefined' !== typeof dialog.showInterestedInSponsor) {
|
|
400
|
+
booleanArr.push({
|
|
401
|
+
name: 'dialog.showInterestedInSponsor',
|
|
402
|
+
show: Notify.User.isInterestedInSponsor() ? dialog.showInterestedInSponsor : !dialog.showInterestedInSponsor,
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
if ('function' === typeof dialog.showCallback) {
|
|
407
|
+
booleanArr.push({
|
|
408
|
+
name: 'dialog.showCallback',
|
|
409
|
+
show: dialog.showCallback(),
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
if ('undefined' !== typeof dialog.showGuestOnly) {
|
|
414
|
+
booleanArr.push({
|
|
415
|
+
name: 'dialog.showGuestOnly',
|
|
416
|
+
show: Notify.User.isLogged() ? !dialog.showGuestOnly : dialog.showGuestOnly,
|
|
417
|
+
});
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
booleanArr.push({
|
|
421
|
+
name: 'dialog.schedule',
|
|
422
|
+
show: dialog.schedule ? (date >= dialog.schedule.dateStart && date <= dialog.schedule.dateEnd) || debugIgnore : true,
|
|
423
|
+
});
|
|
424
|
+
|
|
425
|
+
if (dialog.count) {
|
|
426
|
+
const count = parseFloat(Cookie.getItem(`${Notify.cookieNamespace}--${dialog.id}--count`) || '1');
|
|
427
|
+
booleanArr.push({
|
|
428
|
+
name: 'dialog.count',
|
|
429
|
+
show: count <= dialog.count.max,
|
|
430
|
+
});
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
if (dialog.hideOnNavigation && Notify.History.getHistoryLength() > 1) {
|
|
434
|
+
Notify.instance.hide(dialog.id);
|
|
435
|
+
booleanArr.push({
|
|
436
|
+
name: 'dialog.hideOnNavigation',
|
|
437
|
+
show: false,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if ('undefined' !== typeof dialog.showMobile && !dialog.showMobile) {
|
|
442
|
+
if (window.innerWidth <= parseFloat(Settings.breakpoints.sm)) {
|
|
443
|
+
booleanArr.push({
|
|
444
|
+
name: 'dialog.showMobile',
|
|
445
|
+
show: false,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
if (dialog.disableOnScheduledPriorities) {
|
|
451
|
+
dialog.disableOnScheduledPriorities.forEach(priority => {
|
|
452
|
+
Notify.queue.forEach(dialog => {
|
|
453
|
+
if (dialog.priority == priority) {
|
|
454
|
+
if (dialog.schedule) {
|
|
455
|
+
if (date >= dialog.schedule.dateStart && date <= dialog.schedule.dateEnd) {
|
|
456
|
+
booleanArr.push({
|
|
457
|
+
name: 'dialog.disableOnScheduledPriorities && dialog.schedule',
|
|
458
|
+
show: false,
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
booleanArr.push({
|
|
463
|
+
name: 'dialog.disableOnScheduledPriorities',
|
|
464
|
+
show: false,
|
|
465
|
+
});
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
if (isDebugEnviroment) {
|
|
473
|
+
qq('.debug').forEach(debugBarElement => debugBarElement.classList.add('hide'));
|
|
474
|
+
console.log(`Show ${dialog.id}: ${0 === booleanArr.filter(argument => !argument.show).length ? true : false}`, booleanArr);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
return 0 === booleanArr.filter(argument => !argument.show).length;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
return false;
|
|
481
|
+
});
|
|
482
|
+
const settings = queue.shift();
|
|
483
|
+
|
|
484
|
+
if (settings) {
|
|
485
|
+
if ('custom' !== settings.type && settings.preload) {
|
|
486
|
+
await Notify.preload(settings);
|
|
487
|
+
|
|
488
|
+
if (settings.preloadDependencies) {
|
|
489
|
+
await Notify.preloadDependencies(settings.preloadDependencies);
|
|
490
|
+
|
|
491
|
+
let dependencyLoaded: boolean[] = [];
|
|
492
|
+
|
|
493
|
+
settings.preloadDependencies.forEach(dependency => {
|
|
494
|
+
dependencyLoaded.push(ww[dependency.variable] ? true : false);
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
if (dependencyLoaded.indexOf(false) !== -1) {
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
if ('notification' === settings.type) {
|
|
504
|
+
Notify.printMethodNotification(settings);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
if ('banner' === settings.type) {
|
|
508
|
+
Notify.printMethodBanner(settings);
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if ('popup' === settings.type) {
|
|
512
|
+
Notify.printMethodPopup(settings);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
if ('custom' === settings.type) {
|
|
516
|
+
Notify.printMethodCustom(settings);
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
if ('quechua' == settings.type) {
|
|
520
|
+
Notify.printMethodQuechua(settings);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
public hide(id: string) {
|
|
526
|
+
const element = document.getElementById(`modal-${id}`) || document.getElementById(`notification-${id}`) || document.getElementById(id);
|
|
527
|
+
const settings = Notify.queue.filter(dialog => dialog.id === id).shift();
|
|
528
|
+
|
|
529
|
+
if (settings) {
|
|
530
|
+
const expires =
|
|
531
|
+
settings.schedule && settings.schedule.dateExpire
|
|
532
|
+
? settings.schedule.dateExpire
|
|
533
|
+
: settings.expires
|
|
534
|
+
? settings.expires(new Date())
|
|
535
|
+
: new Date(new Date().getTime() + 1 * 60 * 60 * 1000);
|
|
536
|
+
|
|
537
|
+
Cookie.setItem(`${Notify.cookieNamespace}--${settings.id}`, '0', {
|
|
538
|
+
expires: expires,
|
|
539
|
+
});
|
|
540
|
+
} else {
|
|
541
|
+
const expires = new Date(new Date().getTime() + 3 * 60 * 60 * 1000);
|
|
542
|
+
|
|
543
|
+
Cookie.setItem(`${Notify.cookieNamespace}--${id}`, '0', {
|
|
544
|
+
expires: expires,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
if (element && element.parentElement) {
|
|
549
|
+
element.parentElement.removeChild(element);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
type DialogType = 'popup' | 'banner' | 'notification' | 'custom' | 'quechua';
|
|
555
|
+
export type SettingsTypes = DialogBannerSettings | DialogPopupSettings | DialogNotificationSettings | DialogQuechuaSettings;
|
|
556
|
+
|
|
557
|
+
interface DialogSettings {
|
|
558
|
+
id: string;
|
|
559
|
+
class?: string;
|
|
560
|
+
extra?: { [name: string]: any };
|
|
561
|
+
html: string;
|
|
562
|
+
type?: DialogType;
|
|
563
|
+
schedule?: {
|
|
564
|
+
dateStart: Date;
|
|
565
|
+
dateEnd: Date;
|
|
566
|
+
dateExpire?: Date;
|
|
567
|
+
dateIgnoreOnDebug?: boolean;
|
|
568
|
+
};
|
|
569
|
+
showFree?: boolean;
|
|
570
|
+
showGuestOnly?: boolean;
|
|
571
|
+
showInterestedInSponsor?: boolean;
|
|
572
|
+
showPremium?: boolean;
|
|
573
|
+
showPremiumFreepik?: boolean;
|
|
574
|
+
showPremiumFlaticon?: boolean;
|
|
575
|
+
showPremiumFreepikAnnual?: boolean;
|
|
576
|
+
showPremiumFreepikMonthly?: boolean;
|
|
577
|
+
showPremiumFlaticonAnnual?: boolean;
|
|
578
|
+
showPremiumFlaticonMonthly?: boolean;
|
|
579
|
+
showRenewalCanceledFlaticon?: boolean;
|
|
580
|
+
showRenewalCanceledFreepik?: boolean;
|
|
581
|
+
showRenewalCanceledPlus?: boolean;
|
|
582
|
+
showMobile?: boolean;
|
|
583
|
+
showCallback?: () => boolean;
|
|
584
|
+
expires?: (date: Date) => Date;
|
|
585
|
+
count?: {
|
|
586
|
+
max: number;
|
|
587
|
+
};
|
|
588
|
+
callback?: Function;
|
|
589
|
+
hideOnNavigation?: boolean;
|
|
590
|
+
priority: number;
|
|
591
|
+
preload?: boolean;
|
|
592
|
+
preloadAdditional?: string[];
|
|
593
|
+
preloadDependencies?: DependenciesObject[];
|
|
594
|
+
disableOnScheduledPriorities?: number[];
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export interface DialogBannerOptions extends DialogSettings {
|
|
598
|
+
position: 'top' | 'bottom';
|
|
599
|
+
template?: Function;
|
|
600
|
+
}
|
|
601
|
+
export interface DialogBannerSettings extends DialogBannerOptions {
|
|
602
|
+
type: 'banner';
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
export interface DialogQuechuaOptions extends DialogSettings {
|
|
606
|
+
template?: Function;
|
|
607
|
+
container: HTMLElement;
|
|
608
|
+
}
|
|
609
|
+
export interface DialogQuechuaSettings extends DialogQuechuaOptions {
|
|
610
|
+
type: 'quechua';
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
export interface DialogNotificationOptions extends DialogSettings {
|
|
614
|
+
position: 'bottom-center' | 'bottom-left' | 'bottom-right' | 'center' | 'top-center' | 'top-left' | 'top-right';
|
|
615
|
+
template?: Function;
|
|
616
|
+
}
|
|
617
|
+
export interface DialogNotificationSettings extends DialogNotificationOptions {
|
|
618
|
+
type: 'notification';
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
export interface DialogPopupOptions extends DialogSettings {
|
|
622
|
+
globalVariables?: { [name: string]: any };
|
|
623
|
+
}
|
|
624
|
+
export interface DialogPopupSettings extends DialogSettings {
|
|
625
|
+
type: 'popup';
|
|
626
|
+
globalVariables?: { [name: string]: any };
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
export interface DialogCustomOptions {
|
|
630
|
+
id: string;
|
|
631
|
+
callback: Function;
|
|
632
|
+
schedule?: {
|
|
633
|
+
dateStart: Date;
|
|
634
|
+
dateEnd: Date;
|
|
635
|
+
dateExpire?: Date;
|
|
636
|
+
dateIgnoreOnDebug?: boolean;
|
|
637
|
+
};
|
|
638
|
+
showFree?: boolean;
|
|
639
|
+
showGuestOnly?: boolean;
|
|
640
|
+
showInterestedInSponsor?: boolean;
|
|
641
|
+
showPremium?: boolean;
|
|
642
|
+
showPremiumFreepik?: boolean;
|
|
643
|
+
showPremiumFlaticon?: boolean;
|
|
644
|
+
showPremiumFreepikAnnual?: boolean;
|
|
645
|
+
showPremiumFreepikMonthly?: boolean;
|
|
646
|
+
showPremiumFlaticonAnnual?: boolean;
|
|
647
|
+
showPremiumFlaticonMonthly?: boolean;
|
|
648
|
+
showRenewalCanceledFlaticon?: boolean;
|
|
649
|
+
showRenewalCanceledFreepik?: boolean;
|
|
650
|
+
showRenewalCanceledPlus?: boolean;
|
|
651
|
+
showMobile?: boolean;
|
|
652
|
+
showCallback?: () => boolean;
|
|
653
|
+
expires?: (date: Date) => Date;
|
|
654
|
+
count?: {
|
|
655
|
+
max: number;
|
|
656
|
+
};
|
|
657
|
+
hideOnNavigation?: boolean;
|
|
658
|
+
priority: number;
|
|
659
|
+
disableOnScheduledPriorities?: number[];
|
|
660
|
+
closeCallback: (closeCallback: Function) => void;
|
|
661
|
+
}
|
|
662
|
+
export interface DialogCustomSettings {
|
|
663
|
+
id: string;
|
|
664
|
+
type: 'custom';
|
|
665
|
+
callback: Function;
|
|
666
|
+
schedule?: {
|
|
667
|
+
dateStart: Date;
|
|
668
|
+
dateEnd: Date;
|
|
669
|
+
dateExpire?: Date;
|
|
670
|
+
dateIgnoreOnDebug?: boolean;
|
|
671
|
+
};
|
|
672
|
+
showFree?: boolean;
|
|
673
|
+
showGuestOnly?: boolean;
|
|
674
|
+
showInterestedInSponsor?: boolean;
|
|
675
|
+
showPremium?: boolean;
|
|
676
|
+
showPremiumFreepik?: boolean;
|
|
677
|
+
showPremiumFlaticon?: boolean;
|
|
678
|
+
showPremiumFreepikAnnual?: boolean;
|
|
679
|
+
showPremiumFreepikMonthly?: boolean;
|
|
680
|
+
showPremiumFlaticonAnnual?: boolean;
|
|
681
|
+
showPremiumFlaticonMonthly?: boolean;
|
|
682
|
+
showRenewalCanceledFlaticon?: boolean;
|
|
683
|
+
showRenewalCanceledFreepik?: boolean;
|
|
684
|
+
showRenewalCanceledPlus?: boolean;
|
|
685
|
+
showMobile?: boolean;
|
|
686
|
+
showCallback?: () => boolean;
|
|
687
|
+
expires?: (date: Date) => Date;
|
|
688
|
+
count?: {
|
|
689
|
+
max: number;
|
|
690
|
+
};
|
|
691
|
+
hideOnNavigation?: boolean;
|
|
692
|
+
priority: number;
|
|
693
|
+
disableOnScheduledPriorities?: number[];
|
|
694
|
+
closeCallback: (closeCallback: Function) => void;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
export class KEventShow extends KEvent {
|
|
698
|
+
constructor(public settings: DialogBannerSettings | DialogNotificationSettings | DialogPopupSettings | DialogQuechuaSettings) {
|
|
699
|
+
super();
|
|
700
|
+
this.type = `show`;
|
|
701
|
+
this.extra = settings;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
export class KEventHide extends KEvent {
|
|
706
|
+
constructor(public settings: DialogBannerSettings | DialogCustomSettings | DialogNotificationSettings | DialogPopupSettings | DialogQuechuaSettings) {
|
|
707
|
+
super();
|
|
708
|
+
this.type = `hide`;
|
|
709
|
+
this.extra = settings;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
export interface DependenciesObject {
|
|
714
|
+
id: string;
|
|
715
|
+
url: string;
|
|
716
|
+
variable: string;
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
export interface NotifyMethods {
|
|
720
|
+
banner: Notification;
|
|
721
|
+
popup: Modal;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
export interface NotifyUser {
|
|
725
|
+
isInterestedInSponsor(): boolean;
|
|
726
|
+
isLogged(): boolean;
|
|
727
|
+
isPremiumFreepik(): boolean;
|
|
728
|
+
isPremiumFlaticon(): boolean;
|
|
729
|
+
isPremiumFreepikAnnual(): boolean;
|
|
730
|
+
isPremiumFreepikMonthly(): boolean;
|
|
731
|
+
isPremiumFlaticonAnnual(): boolean;
|
|
732
|
+
isPremiumFlaticonMonthly(): boolean;
|
|
733
|
+
isRenewalCanceledFlaticon(): boolean;
|
|
734
|
+
isRenewalCanceledFreepik(): boolean;
|
|
735
|
+
isRenewalCanceledPlus(): boolean;
|
|
736
|
+
type(): 'Premium' | 'Free' | 'Anonymous';
|
|
737
|
+
}
|
|
738
|
+
|
|
739
|
+
export interface NotifyHistory {
|
|
740
|
+
getHistoryLength(): number;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
export interface NotifyOptions {
|
|
744
|
+
User: NotifyUser;
|
|
745
|
+
History: NotifyHistory;
|
|
746
|
+
}
|