PageSourceSearch

https://vietnamtravel.com/wp-content/plugins/vietnamtravel-require…/frontend/js/bas-lazyload.js?ver=4942

js vietnamtravel.com collected 2026-09-29 12:11:47 UTC 20,872 bytes, 451 lines download raw bytes

1var BAS_VNTV_LAZYLOAD;
2(function (BAS_VNTV_LAZYLOAD) {
3    var VNTV_LAZYLOAD = /** @class */ (function () {
4        function VNTV_LAZYLOAD() {
5            this.$ = jQuery;
6            this.loadStatus = false;
7            this.hasBlockLoad = 0;
8            // End lazyload single cruise
9        }
10        VNTV_LAZYLOAD.prototype.init = function () {
11            // Auto created nonce key
12            this.autoCreateNonceKey();
13            var pageType = window.vntv_client_data.pageType, pageLazyloadStatus = window.vntv_client_data.pageLazyload;
14            switch (pageType) {
15                case 'page':
16                    this.pageContentLazyLoad();
17                    break;
18                case 'post':
19                    this.blogContentLazyLoad();
20                    break;
21                case 'bookawesome_tour':
22                    this.tourContentLazy();
23                    break;
24                case 'bookawesome_cruise':
25                    this.cruiseContentLazy();
26                    break;
27                default:
28                    this.$(".bas_lazyload_footer_js").show();
29                    break;
30            }
31            this.layzyloadImage();
32        };
33        VNTV_LAZYLOAD.prototype.autoCreateNonceKey = function () {
34            this.$.ajax({
35                url: bas_admin.admin_url + 'admin-ajax.php',
36                type: 'post',
37                data: {
38                    action: 'bas_get_nonce_security'
39                },
40                success: function (data) {
41                    window.ATL_NONCE_SECURITY = data;
42                }
43            });
44        };
45        /**
46         * Lazyload image
47         * @param wrap
48         */
49        VNTV_LAZYLOAD.prototype.layzyloadImage = function (wrap) {
50            if (wrap === void 0) { wrap = null; }
51            this.$('.vntv_lazy', wrap).Lazy({
52                scrollDirection: 'vertical',
53                effect: 'fadeIn',
54                visibleOnly: true
55            });
56        };
57        /**
58         * First load page
59         * @return string
60         */
61        VNTV_LAZYLOAD.prototype.waitLoadPageTemplate = function () {
62            return "\n            <div class=\"las_page_load__image_bg\"/>\n                <div class=\"las_page_load__image\">\n                    <img src=\"" + window.vntv_client_data.theme + "/assets/images/page-loading.gif\" alt=\"Vietnam Travel\"/>\n                </div>\n            </div>\n            ";
63        };
64        /**
65         * Template for state load content
66         * @return string
67         */
68        VNTV_LAZYLOAD.prototype.waitLoadContentTemplate = function () {
69            return "\n            <section class=\"las_page_load\">\n                <div class=\"las_page_load__title\">\n                    <div class=\"animated\"><div class=\"masker\"></div></div>\n                </div>\n                <div class=\"las_page_load__subtitle\">\n                    <div class=\"animated\"><div class=\"masker\"></div></div>\n                </div>\n                <div class=\"las_page_load__subtitle2\">\n                    <div class=\"animated\"><div class=\"masker\"></div></div>\n                </div>\n                <div class=\"las_page_load__search\">\n                    <div class=\"animated\"><div class=\"masker\"></div></div>\n                </div>\n            </section>\n            ";
70        };
71        // Handle lazyload page
72        VNTV_LAZYLOAD.prototype.pageContentLazyLoad = function () {
73            var self = this;
74            if (0 === this.$(".bas_lazyload_content_js").length) {
75                this.$(".bas_lazyload_footer_js").show();
76                return false;
77            }
78            // Load auto
79            this.autoLoadContent(this.$(".bas_lazyload_content_js"));
80            // if( 0 === this.$(window).scrollTop() ) {
81            //     this.loadContent(this.$( this.$(".bas_lazyload_content_js")[0]), true);
82            //     this.loadContent(this.$( this.$(".bas_lazyload_content_js")[1]));
83            // }
84            // Load with scroll
85            // var nextCount = 2;
86            // this.$(window).scroll(function() {
87            //     if( !self.loadStatus ) {
88            //         return false;
89            //     }
90            //     let position = self.$(window).scrollTop(),
91            //         bottom = self.$(document).height() - self.$(window).height();
92            //
93            //     if(position == bottom ) {
94            //         if( self.$(".bas_lazyload_content_js")[nextCount] ) {
95            //             self.loadStatus = false;
96            //             self.loadContent(self.$( self.$(".bas_lazyload_content_js")[nextCount]));
97            //             nextCount++;
98            //         }
99            //
100            //         if( nextCount === self.$(".bas_lazyload_content_js").length) {
101            //             self.$(".bas_lazyload_footer_js").show();
102            //         }
103            //     }
104            // });
105        };
106        VNTV_LAZYLOAD.prototype.autoLoadContent = function (element, firstLoad) {
107            if (firstLoad === void 0) { firstLoad = false; }
108            var self = this, wrapBlock = this.$(element[this.hasBlockLoad]), contentOption = wrapBlock.find('.bas_lazyload_content_data_js').val();
109            if (0 === contentOption.length) {
110                return false;
111            }
112            if (0 === this.hasBlockLoad) {
113                // wrapBlock.html(this.waitLoadPageTemplate());
114            }
115            else {
116                wrapBlock.html(this.waitLoadContentTemplate());
117            }
118            self.hasBlockLoad = self.hasBlockLoad + 1;
119            this.$.ajax({
120                url: window.bas_admin.admin_url + 'admin-ajax.php',
121                type: 'post',
122                data: {
123                    action: 'bas_frontend_page_infinite_scroll',
124                    option: JSON.parse(contentOption)
125                },
126                success: function (data) {
127                    wrapBlock.html(data.content);
128                    self.layzyloadImage(wrapBlock);
129                    if (data.scriptInit) {
130                        eval(data.scriptInit);
131                    }
132                    if (element[self.hasBlockLoad]) {
133                        self.autoLoadContent(element);
134                    }
135                    if (self.hasBlockLoad === element.length) {
136                        self.$(".bas_lazyload_footer_js").show();
137                    }
138                }
139            });
140        };
141        VNTV_LAZYLOAD.prototype.loadContent = function (wrapcontent, firstLoad) {
142            if (firstLoad === void 0) { firstLoad = false; }
143            var self = this, contentOption = wrapcontent.find('.bas_lazyload_content_data_js').val();
144            if (0 === wrapcontent.find('.bas_lazyload_content_data_js').length) {
145                return false;
146            }
147            if (firstLoad) {
148                // wrapcontent.html(this.waitLoadPageTemplate());
149            }
150            else {
151                wrapcontent.html(this.waitLoadContentTemplate());
152            }
153            this.$.ajax({
154                url: window.bas_admin.admin_url + 'admin-ajax.php',
155                type: 'post',
156                data: {
157                    action: 'bas_frontend_page_infinite_scroll',
158                    option: JSON.parse(contentOption)
159                },
160                success: function (data) {
161                    wrapcontent.html(data.content);
162                    self.layzyloadImage(wrapcontent);
163                    if (data.scriptInit) {
164                        eval(data.scriptInit);
165                    }
166                    self.loadStatus = true;
167                }
168            });
169        };
170        // End lazyload page
171        // Handle lazyload page
172        VNTV_LAZYLOAD.prototype.blogContentLazyLoad = function () {
173            var self = this;
174            this.$(".bas_lazyload_footer_js").show();
175            if (0 === this.$(".bas_lazyload_blog_content_js").length) {
176                return false;
177            }
178            this.$(".bas_lazyload_blog_content_js").each(function (key, el) {
179                self.loadBlogContent(self.$(el));
180            });
181        };
182        VNTV_LAZYLOAD.prototype.loadBlogContent = function (wrapcontent, firstLoad) {
183            if (firstLoad === void 0) { firstLoad = false; }
184            var self = this, contentOption = wrapcontent.find('.bas_lazyload_content_data_js').val(), post_id = this.$('#vntv_object_lazyload_id').val(), optionsSection = {};
185            if (0 !== contentOption.length) {
186                optionsSection = JSON.parse(contentOption);
187            }
188            if (0 === wrapcontent.find('.bas_lazyload_content_data_js').length) {
189                return false;
190            }
191            if (firstLoad) {
192                // wrapcontent.html(this.waitLoadPageTemplate());
193            }
194            wrapcontent.html(this.waitLoadContentTemplate());
195            this.$.ajax({
196                url: window.bas_admin.admin_url + 'admin-ajax.php',
197                type: 'post',
198                data: {
199                    action: 'bas_frontend_blog_infinite_scroll',
200                    option: JSON.parse(contentOption),
201                    post_id: post_id
202                },
203                success: function (data) {
204                    wrapcontent.html(data.content);
205                    self.layzyloadImage(wrapcontent);
206                    if (optionsSection.scriptInit) {
207                        eval(optionsSection.scriptInit);
208                    }
209                }
210            });
211        };
212        // End lazyload page
213        // Handle lazyload single tour
214        VNTV_LAZYLOAD.prototype.tourContentLazy = function () {
215            var _this = this;
216            var self = this, targetElement = '.bas_lazyload_tour_content_js', firstLoad = 0, nextCount = 0, elements = [];
217            if (0 === this.$(targetElement).length) {
218                this.$(".bas_lazyload_footer_js").show();
219                return false;
220            }
221            this.$(targetElement).each(function (key, el) {
222                if (self.$(el).hasClass('first')) {
223                    var firstStatus = (0 === key) ? true : false;
224                    _this.loadTourContent(_this.$(el), firstStatus);
225                    firstLoad++;
226                }
227                else {
228                    elements.push(el);
229                }
230            });
231            // Load auto
232            this.autoLoadTourContent(elements);
233            // if( 0 === this.$(window).scrollTop() ) {
234            //     this.$(targetElement).each((key, el) => {
235            //         if( self.$(el).hasClass('first') ) {
236            //             let firstStatus = (0 === key) ? true : false;
237            //             this.loadTourContent(this.$(el), firstStatus);
238            //             firstLoad++;
239            //         }
240            //     })
241            // }
242            //
243            // this.$(window).scroll(function() {
244            //     if( !self.loadStatus ) {
245            //         return false;
246            //     }
247            //     let position = self.$(window).scrollTop(),
248            //         bottom = self.$(document).height() - self.$(window).height();
249            //
250            //     if(position == bottom ) {
251            //         if( self.$(".bas_lazyload_tour_content_js").not('.first')[nextCount] ) {
252            //             self.loadStatus = false;
253            //             self.loadTourContent(self.$( self.$(".bas_lazyload_tour_content_js").not('.first')[nextCount]));
254            //             nextCount++;
255            //         }
256            //
257            //         if( nextCount === self.$(".bas_lazyload_tour_content_js").not('.first').length) {
258            //             self.$(".bas_lazyload_footer_js").show();
259            //         }
260            //     }
261            // });
262        };
263        VNTV_LAZYLOAD.prototype.autoLoadTourContent = function (element) {
264            var self = this, wrapBlock = this.$(element[this.hasBlockLoad]), contentOption = wrapBlock.find('.bas_lazyload_content_data_js').val(), post_id = this.$('#vntv_object_lazyload_id').val(), optionsSection = {};
265            if (0 === contentOption.length) {
266                return false;
267            }
268            optionsSection = JSON.parse(contentOption);
269            wrapBlock.html(this.waitLoadContentTemplate());
270            self.hasBlockLoad = self.hasBlockLoad + 1;
271            this.$.ajax({
272                url: window.bas_admin.admin_url + 'admin-ajax.php',
273                type: 'post',
274                data: {
275                    action: 'bas_frontend_tour_infinite_scroll',
276                    option: JSON.parse(contentOption),
277                    post_id: post_id
278                },
279                success: function (data) {
280                    wrapBlock.html(data.content);
281                    self.layzyloadImage(wrapBlock);
282                    window.VNTV_APP_SCRIPT.blockTourMenuScrollspy();
283                    if (optionsSection.scriptInit) {
284                        eval(optionsSection.scriptInit);
285                    }
286                    if (element[self.hasBlockLoad]) {
287                        self.autoLoadTourContent(element);
288                    }
289                    if (self.hasBlockLoad === element.length) {
290                        self.$(".bas_lazyload_footer_js").show();
291                    }
292                }
293            });
294        };
295        VNTV_LAZYLOAD.prototype.loadTourContent = function (wrapcontent, firstLoad) {
296            if (firstLoad === void 0) { firstLoad = false; }
297            var self = this, contentOption = wrapcontent.find('.bas_lazyload_content_data_js').val(), post_id = this.$('#vntv_object_lazyload_id').val(), optionsSection = {};
298            if (0 !== contentOption.length) {
299                optionsSection = JSON.parse(contentOption);
300            }
301            if (firstLoad) {
302                // this.$("#bas_page_lazyload_wait").html(this.waitLoadPageTemplate());
303            }
304            wrapcontent.html(this.waitLoadContentTemplate());
305            this.$.ajax({
306                url: window.bas_admin.admin_url + 'admin-ajax.php',
307                type: 'post',
308                data: {
309                    action: 'bas_frontend_tour_infinite_scroll',
310                    post_id: post_id,
311                    option: optionsSection
312                },
313                success: function (data) {
314                    wrapcontent.html(data.content);
315                    self.layzyloadImage(wrapcontent);
316                    window.VNTV_APP_SCRIPT.blockTourMenuScrollspy();
317                    if (optionsSection.scriptInit) {
318                        eval(optionsSection.scriptInit);
319                    }
320                    if (firstLoad) {
321                        self.$("#bas_dt_menu").show();
322                        self.$("#bas_page_lazyload_wait").html('');
323                    }
324                    self.loadStatus = true;
325                }
326            });
327        };
328        // End lazyload single tour
329        // Handle lazyload single cruise
330        VNTV_LAZYLOAD.prototype.cruiseContentLazy = function () {
331            var _this = this;
332            var self = this, targetElement = '.bas_lazyload_cruise_content_js', firstLoad = 0, nextCount = 0, elements = [];
333            if (0 === this.$(targetElement).length) {
334                this.$(".bas_lazyload_footer_js").show();
335                return false;
336            }
337            this.$(targetElement).each(function (key, el) {
338                if (self.$(el).hasClass('first')) {
339                    var firstStatus = (0 === key) ? true : false;
340                    _this.loadCruiseContent(_this.$(el), firstStatus);
341                    firstLoad++;
342                }
343                else {
344                    elements.push(el);
345                }
346            });
347            // Load auto
348            this.autoLoadCruiseContent(elements);
349            // if( 0 === this.$(window).scrollTop() ) {
350            //     this.$(targetElement).each((key, el) => {
351            //         if( self.$(el).hasClass('first') ) {
352            //             let firstStatus = (0 === key) ? true : false;
353            //             this.loadCruiseContent(this.$(el), firstStatus);
354            //             firstLoad++;
355            //         }
356            //     })
357            // }
358            //
359            // this.$(window).scroll(function() {
360            //     if( !self.loadStatus ) {
361            //         return false;
362            //     }
363            //     let position = self.$(window).scrollTop(),
364            //         bottom = self.$(document).height() - self.$(window).height();
365            //
366            //     if(position == bottom ) {
367            //         if( self.$(".bas_lazyload_cruise_content_js").not('.first')[nextCount] ) {
368            //             self.loadStatus = false;
369            //             self.loadCruiseContent(self.$( self.$(".bas_lazyload_cruise_content_js").not('.first')[nextCount]));
370            //             nextCount++;
371            //         }
372            //
373            //         if( nextCount === self.$(".bas_lazyload_cruise_content_js").not('.first').length) {
374            //             self.$(".bas_lazyload_footer_js").show();
375            //         }
376            //     }
377            // });
378        };
379        VNTV_LAZYLOAD.prototype.autoLoadCruiseContent = function (element) {
380            var self = this, wrapBlock = this.$(element[this.hasBlockLoad]), contentOption = wrapBlock.find('.bas_lazyload_content_data_js').val(), post_id = this.$('#vntv_object_lazyload_id').val(), optionsSection = {};
381            if (0 === contentOption.length) {
382                return false;
383            }
384            optionsSection = JSON.parse(contentOption);
385            wrapBlock.html(this.waitLoadContentTemplate());
386            self.hasBlockLoad = self.hasBlockLoad + 1;
387            this.$.ajax({
388                url: window.bas_admin.admin_url + 'admin-ajax.php',
389                type: 'post',
390                data: {
391                    action: 'bas_frontend_cruise_infinite_scroll',
392                    option: JSON.parse(contentOption),
393                    post_id: post_id
394                },
395                success: function (data) {
396                    wrapBlock.html(data.content);
397                    window.VNTV_APP_SCRIPT.blockTourMenuScrollspy();
398                    window.VNTV_APP_SCRIPT.blockToggleBox();
399                    if (optionsSection.scriptInit) {
400                        eval(optionsSection.scriptInit);
401                    }
402                    self.layzyloadImage(wrapBlock);
403                    if (element[self.hasBlockLoad]) {
404                        self.autoLoadCruiseContent(element);
405                    }
406                    if (self.hasBlockLoad === element.length) {
407                        self.$(".bas_lazyload_footer_js").show();
408                    }
409                }
410            });
411        };
412        VNTV_LAZYLOAD.prototype.loadCruiseContent = function (wrapcontent, firstLoad) {
413            if (firstLoad === void 0) { firstLoad = false; }
414            var self = this, contentOption = wrapcontent.find('.bas_lazyload_content_data_js').val(), post_id = this.$('#vntv_object_lazyload_id').val(), optionsSection = {};
415            if (0 !== contentOption.length) {
416                optionsSection = JSON.parse(contentOption);
417            }
418            if (firstLoad) {
419                // this.$("#bas_page_lazyload_wait").html(this.waitLoadPageTemplate());
420            }
421            wrapcontent.html(this.waitLoadContentTemplate());
422            this.$.ajax({
423                url: window.bas_admin.admin_url + 'admin-ajax.php',
424                type: 'post',
425                data: {
426                    action: 'bas_frontend_cruise_infinite_scroll',
427                    post_id: post_id,
428                    option: optionsSection
429                },
430                success: function (data) {
431                    wrapcontent.html(data.content);
432                    window.VNTV_APP_SCRIPT.blockTourMenuScrollspy();
433                    window.VNTV_APP_SCRIPT.blockToggleBox();
434                    if (optionsSection.scriptInit) {
435                        eval(optionsSection.scriptInit);
436                    }
437                    self.layzyloadImage(wrapcontent);
438                    if (firstLoad) {
439                        self.$("#bas_dt_menu").show();
440                        self.$("#bas_page_lazyload_wait").html('');
441                    }
442                    self.loadStatus = true;
443                }
444            });
445        };
446        return VNTV_LAZYLOAD;
447    }());
448    BAS_VNTV_LAZYLOAD.VNTV_LAZYLOAD = VNTV_LAZYLOAD;
449    var DELACRE_VNTV_LAZYLOAD = new VNTV_LAZYLOAD;
450    DELACRE_VNTV_LAZYLOAD.init();
451})(BAS_VNTV_LAZYLOAD || (BAS_VNTV_LAZYLOAD = {}));

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.