PageSourceSearch

https://sabangkota.go.id/themes/ceudah/assets/js/rf-component/rf.window-modal.min.js

js sabangkota.go.id collected 2026-10-02 18:08:49 UTC 18,424 bytes, 552 lines download raw bytes

1/**
2 * ModalWindow wrapper.
3 *
4 * @author RFVenom Design SIAT Dev (Ryan Fitra -- RFV --)
5 *
6 * @version 1.2.5 -- 13 Mei 2019 -- Update -- 25 Sep 2019
7 *
8 * @requires appear.js (v1.0.3), custombox.js (v4.0.1)
9 *
10 */
11
12;(function($){
13    'use strict';
14
15    $.RFVCore.components.RFVModalWindow = {
16
17        /**
18         *
19         *
20         * @var Object _baseConfig
21         */
22        _baseConfig : {
23            bounds: 100,
24            debounce: 50,
25            overlayOpacity: .48,
26            overlayColor: '#000000',
27            speed: 400,
28            sleep: false,
29            sleepSpeed: 5000,
30            type: 'onscroll', // onscroll, beforeunload, hashlink, ontarget, aftersometime
31            effect: 'fadein',
32            sessionStorageModal: false,
33            sessionStorageCountDefaultLimit: 5,
34            onOpen: function() {},
35            onClose: function() {},
36            onComplete: function() {}
37        },
38
39        /**
40         *
41         *
42         * @var jQuery _pageCollection
43         */
44        _pageCollection : $(),
45
46        /**
47         * Initialization of ModalWindow wrapper.
48         *
49         * @param String selector (optional)
50         * @param Object config (optional)
51         *
52         * @return jQuery - collection of initialized items.
53         */
54        init: function(selector, config) {
55
56            var collection = $(selector);
57            if(!collection.length) return;
58
59
60            config = config && $.isPlainObject(config) ? $.extend({}, this._baseConfig, config) : this._baseConfig;
61            config.selector = selector;
62
63            this._pageCollection = this._pageCollection.add( collection.not(this._pageCollection) );
64
65            if(config.autonomous) {
66
67                if(config.sessionStorageModal) {
68
69                    this.intiCounterLimitSessionStorage(collection, config);
70
71                    if (sessionStorage.storageWMisLoaded) {
72
73                        if (sessionStorage.storageWMCounter >= sessionStorage.storageWMLimit){
74
75                            sessionStorage.storageWMCounter = 0;
76                            sessionStorage.removeItem('storageWMisLoaded');
77
78                        }
79                        else
80                            return ;
81
82                    }
83
84                }
85
86                if(!config.sessionStorageModal && sessionStorage) {
87
88                    //sessionStorage.clear();
89                    sessionStorage.removeItem('storageWMName');
90                    sessionStorage.removeItem('storageWMLimit');
91                    sessionStorage.removeItem('storageWMCounter');
92                    sessionStorage.removeItem('storageWMisLoaded');
93
94                }
95
96                return this.initAutonomousModalWindows(collection, config);
97
98            }
99
100            return this.initBaseModalWindows(collection, config);
101
102        },
103
104        /**
105         * Initialization of  counter limit to show Modal Window of the page.
106         *
107         * @param jQuery collection
108         * @param Object config
109         *
110         * @return jQuery collection
111         */
112        intiCounterLimitSessionStorage: function(collection, config){
113
114            collection.each(function(i, el) {
115
116                var $this = $(el),
117                    localLimit = $this.data('session-show-limit') ? $this.data('session-show-limit') : config.sessionStorageCountDefaultLimit;
118
119                sessionStorage.storageWMName = "Window Modal";
120                sessionStorage.storageWMLimit = localLimit;
121
122                if(sessionStorage.storageWMisLoaded)
123                    sessionStorage.storageWMCounter = parseInt(sessionStorage.storageWMCounter)+1;
124                else
125                    sessionStorage.storageWMCounter = parseInt(0);
126
127                var obj = Object.keys(sessionStorage).reduce(function (obj, key) {
128                    obj[key] = sessionStorage.getItem(key);
129                    return obj
130                }, {});
131
132                //console.log(obj);
133            });
134
135        },
136
137        /**
138         * Initialization of each Autonomous Modal Window of the page.
139         *
140         * @param jQuery collection
141         * @param Object config
142         *
143         * @return jQuery collection
144         */
145        initBaseModalWindows: function(collection, config){
146
147            return collection.on('click', function(e){
148
149                if(!('Custombox' in window)) return;
150
151                var $this = $(this),
152                    target = $this.data('modal-target'),
153                    effect = $this.data('modal-effect') || config['effect'];
154
155                if(!target || !$(target).length) return;
156
157                new Custombox.modal(
158                    {
159                        content: {
160                            target: target,
161                            effect: effect,
162                            onOpen: function() {
163                                config['onOpen'].call($(target));
164                            },
165                            onClose: function() {
166                                config['onClose'].call($(target));
167                            },
168                            onComplete: function() {
169                                config['onComplete'].call($(target));
170                            }
171                        },
172                        overlay: {
173                            color: $this.data('overlay-color') || config['overlayColor'],
174                            opacity: $this.data('overlay-opacity') || config['overlayOpacity'],
175                            speedIn: $this.data('speed') || config['speed'],
176                            speedOut: $this.data('speed') || config['speed']
177                        }
178                    }
179                ).open();
180
181                e.preventDefault();
182
183            });
184
185        },
186
187        /**
188         * Initialization of each Autonomous Modal Window of the page.
189         *
190         * @param jQuery collection
191         * @param Object config
192         *
193         * @return jQuery collection
194         */
195        initAutonomousModalWindows: function(collection, config) {
196
197            var self = this;
198
199            return collection.each(function(i, el) {
200
201                var $this = $(el),
202                    type = $this.data('modal-type');
203
204                switch(type) {
205
206                    case 'hashlink' :
207
208                        self.initHashLinkPopup($this, config);
209
210                        break;
211
212                    case 'onscroll' :
213
214                        self.initOnScrollPopup($this, config);
215
216                        break;
217
218                    case 'beforeunload' :
219
220                        self.initBeforeUnloadPopup($this, config);
221
222                        break;
223
224                    case 'ontarget' :
225
226                        self.initOnTargetPopup($this, config);
227
228                        break;
229
230                    case 'aftersometime' :
231
232                        self.initAfterSomeTimePopup($this, config);
233
234                        break;
235
236                }
237
238            });
239
240        },
241
242        /**
243         *
244         *
245         * @param jQuery popup
246         *
247         * @return undefined
248         */
249        initHashLinkPopup: function(popup, config) {
250
251            var self = this,
252                hashItem = $(window.location.hash),
253                target = $('#' + popup.attr('id'));
254
255            if(hashItem.length && hashItem.attr('id') ==  popup.attr('id')){
256
257                new Custombox.modal(
258                    {
259                        content: {
260                            target: '#' + popup.attr('id'),
261                            effect: popup.data('effect') || config['effect'],
262                            onOpen: function() {
263                                config['onOpen'].call($(target));
264                            },
265                            onClose: function() {
266                                config['onClose'].call($(target));
267                            },
268                            onComplete: function() {
269                                config['onComplete'].call($(target));
270                            }
271                        },
272                        overlay: {
273                            color: popup.data('overlay-color') || config['overlayColor'],
274                            opacity: popup.data('overlay-opacity') || config['overlayOpacity'],
275                            speedIn: popup.data('speed') || config['speed'],
276                            speedOut: popup.data('speed') || config['speed']
277                        }
278                    }
279                ).open();
280
281                sessionStorage.storageWMisLoaded = true;
282
283                /**
284                 *  set timeout, auto close box
285                 */
286                if(popup.data('sleep-timeout') ? popup.data('sleep-timeout') : config['sleep'])
287                {
288                    setTimeout( function () {
289                        Custombox.modal.close();
290                    }, popup.data('sleep-timeout-speed') ? popup.data('sleep-timeout-speed') : config['sleepSpeed']);
291                }
292
293            }
294
295        },
296
297        /**
298         *
299         *
300         * @param jQuery popup
301         *
302         * @return undefined
303         */
304        initOnScrollPopup: function(popup, config) {
305
306            var self = this,
307                $window = $(window),
308                breakpoint = popup.data('breakpoint') ? popup.data('breakpoint') : 0,
309                target = $('#' + popup.attr('id'));
310
311
312            $window.on('scroll.popup', function() {
313
314                var scrolled = $window.scrollTop() + $window.height();
315
316                if(scrolled >= breakpoint) {
317
318                    new Custombox.modal(
319                        {
320                            content: {
321                                target: '#' + popup.attr('id'),
322                                effect: popup.data('effect') || config['effect'],
323                                onOpen: function() {
324                                    config['onOpen'].call($(target));
325                                },
326                                onClose: function() {
327                                    config['onClose'].call($(target));
328                                },
329                                onComplete: function() {
330                                    config['onComplete'].call($(target));
331                                }
332                            },
333                            overlay: {
334                                color: popup.data('overlay-color') || config['overlayColor'],
335                                opacity: popup.data('overlay-opacity') || config['overlayOpacity'],
336                                speedIn: popup.data('speed') || config['speed'],
337                                speedOut: popup.data('speed') || config['speed']
338                            }
339                        }
340                    ).open();
341
342                    $window.off('scroll.popup');
343
344                    sessionStorage.storageWMisLoaded = true;
345
346                    /**
347                     *  set timeout, auto close box
348                     */
349                    if(popup.data('sleep-timeout') ? popup.data('sleep-timeout') : config['sleep'])
350                    {
351                        setTimeout( function () {
352                            Custombox.modal.close();
353                        }, popup.data('sleep-timeout-speed') ? popup.data('sleep-timeout-speed') : config['sleepSpeed']);
354                    }
355
356                }
357
358            });
359
360            $window.trigger('scroll.popup');
361
362        },
363
364        /**
365         *
366         *
367         * @param jQuery popup
368         *
369         * @return undefined
370         */
371        initBeforeUnloadPopup: function(popup, config) {
372
373            var self = this,
374                count = 0,
375                target = $('#' + popup.attr('id')),
376                timeoutId;
377
378            window.addEventListener('mousemove', function(e) {
379
380                if(timeoutId) clearTimeout(timeoutId);
381
382                timeoutId = setTimeout(function() {
383
384                    if (e.clientY < 10 && !count) {
385
386                        count++;
387
388                        new Custombox.modal(
389                            {
390                                content: {
391                                    target: '#' + popup.attr('id'),
392                                    effect: popup.data('effect') || config['effect'],
393                                    onOpen: function() {
394                                        config['onOpen'].call($(target));
395                                    },
396                                    onClose: function() {
397                                        config['onClose'].call($(target));
398                                    },
399                                    onComplete: function() {
400                                        config['onComplete'].call($(target));
401                                    }
402                                },
403                                overlay: {
404                                    color: popup.data('overlay-color') || config['overlayColor'],
405                                    opacity: popup.data('overlay-opacity') || config['overlayOpacity'],
406                                    speedIn: popup.data('speed') || config['speed'],
407                                    speedOut: popup.data('speed') || config['speed']
408                                }
409                            }
410                        ).open();
411
412                    }
413
414                    sessionStorage.storageWMisLoaded = true;
415
416                    /**
417                     *  set timeout, auto close box
418                     */
419                    if(popup.data('sleep-timeout') ? popup.data('sleep-timeout') : config['sleep'])
420                    {
421                        setTimeout( function () {
422                            Custombox.modal.close();
423                        }, popup.data('sleep-timeout-speed') ? popup.data('sleep-timeout-speed') : config['sleepSpeed']);
424                    }
425
426                }, 10);
427
428            });
429
430
431        },
432
433        /**
434         *
435         *
436         * @param jQuery popup
437         *
438         * @return undefined
439         */
440        initOnTargetPopup: function(popup, config) {
441
442            var self = this,
443                target = popup.data('target');
444
445            if(!target || !$(target).length) return;
446
447            appear({
448                bounds: config['bounds'],
449                debounce: config['debounce'],
450                elements: function() {
451                    return document.querySelectorAll(target);
452                },
453                appear: function(element) {
454
455                    new Custombox.modal(
456                        {
457                            content: {
458                                target: '#' + popup.attr('id'),
459                                effect: popup.data('effect') || config['effect'],
460                                onOpen: function() {
461                                    config['onOpen'].call($(target));
462                                },
463                                onClose: function() {
464                                    config['onClose'].call($(target));
465                                },
466                                onComplete: function() {
467                                    config['onComplete'].call($(target));
468                                }
469                            },
470                            overlay: {
471                                color: popup.data('overlay-color') || config['overlayColor'],
472                                opacity: popup.data('overlay-opacity') || config['overlayOpacity'],
473                                speedIn: popup.data('speed') || config['speed'],
474                                speedOut: popup.data('speed') || config['speed']
475                            }
476                        }
477                    ).open();
478
479                    sessionStorage.storageWMisLoaded = true;
480
481                }
482            });
483
484            /**
485             *  set timeout, auto close box
486             */
487            if(popup.data('sleep-timeout') ? popup.data('sleep-timeout') : config['sleep'])
488            {
489                setTimeout( function () {
490                    Custombox.modal.close();
491                }, popup.data('sleep-timeout-speed') ? popup.data('sleep-timeout-speed') : config['sleepSpeed']);
492            }
493
494        },
495
496        /**
497         *
498         *
499         * @param jQuery popup
500         *
501         * @return undefined
502         */
503        initAfterSomeTimePopup: function(popup, config) {
504
505            var self = this,
506                target = $('#' + popup.attr('id'));
507
508            setTimeout(function() {
509
510                new Custombox.modal(
511                    {
512                        content: {
513                            target: '#' + popup.attr('id'),
514                            effect: popup.data('effect') || config['effect'],
515                            onOpen: function() {
516                                config['onOpen'].call($(target));
517                            },
518                            onClose: function() {
519                                config['onClose'].call($(target));
520                            },
521                            onComplete: function() {
522                                config['onComplete'].call($(target));
523                            }
524                        },
525                        overlay: {
526                            color: popup.data('overlay-color') || config['overlayColor'],
527                            opacity: popup.data('overlay-opacity') || config['overlayOpacity'],
528                            speedIn: popup.data('speed') || config['speed'],
529                            speedOut: popup.data('speed') || config['speed']
530                        }
531                    }
532                ).open();
533
534                sessionStorage.storageWMisLoaded = true;
535
536            }, popup.data('delay') ? popup.data('delay') : 10)
537
538            /**
539             *  set timeout, auto close box
540             */
541            if(popup.data('sleep-timeout') ? popup.data('sleep-timeout') : config['sleep'])
542            {
543                setTimeout( function () {
544                      Custombox.modal.close();
545                }, popup.data('sleep-timeout-speed') ? popup.data('sleep-timeout-speed') : config['sleepSpeed']);
546            }
547
548        }
549
550    };
551
552})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.