PageSourceSearch

https://www.themillsfabrica.com/wp-content/themes/themillsfabrica/assets/js/my.js?ver=1790348819

js themillsfabrica.com collected 2026-09-25 15:08:19 UTC 92,088 bytes, 2,150 lines download raw bytes

1$(document).ready(function () {
2
3    $(document).on("click", ".s-header .btn-menu", function (e) {
4        // $(".s-header .btn-menu").click(function(e){
5        $(this).toggleClass("active");
6        $(this).hasClass("active") ? $("html").addClass("_open_menu") : $("html").removeClass("_open_menu");
7        $("html").removeClass("_open_search _open_filter");
8    });
9
10
11    $(document).on("DOMSubtreeModified", ".mec-gateway-message", function () {
12        if ($(".mec-gateway-message:visible").length < 1 && $(".mec-click-pay button.mec-book-form-next-button").attr("disabled") == "disabled" && !$(".mec-click-pay button.mec-book-form-next-button").hasClass("loading")) {
13            $(".mec-click-pay button.mec-book-form-next-button").removeAttr('disabled');
14        }
15    });
16
17    if ($("#cookie-law-info-bar").is(":visible")) {
18        $(".b-sticky .is-sticky").addClass("has_cookie");
19        $(".box-fix").addClass("has_cookie");
20    }
21
22    $(document).on("click", "#wt-cli-accept-all-btn,#cookie_action_close_header_reject", function () {
23        $(".b-sticky .is-sticky").removeClass("has_cookie");
24    });
25
26    $(".b-search .btn-search").click(function (e) {
27
28        if (!$(this).parent().hasClass("min") && ($(".b-search .form-input").val().length > 0))
29            //window.location.href = 'search.html';
30            $("form#search_form").submit();
31        else
32            $(this).parent().toggleClass("min");
33
34    });
35
36    $(document).on("click", ".member_list_pop", function (e) {
37        e.preventDefault();
38		change_ppl(this);
39		// $('#popup_ppl')
40		// alert($(this).find('.img-ppl-logo img').attr('src'));
41        return false;
42    });
43
44
45    $(document).on("change", ".member_list_section .select-filter", function () {
46        var filter_val = $(this).val();
47        $(this).parents(".member_list_section").find(".member_item").hide();
48        if (filter_val == "ALL") {
49            $(this).parents(".member_list_section").find(".member_item").show();
50        } else {
51            $(this).parents(".member_list_section").find(".member_item[data-location='" + filter_val + "']").show();
52        }
53    });
54    
55    $(document).on("change",".member_list_section .select-submenu",function(){
56        var filter_val = $(this).val();
57        $('.member_list_section .select-filter').val(filter_val).change();
58    });
59    
60    $(document).on("click",".nav-team-filter-link",function(){
61        var filter_val = $(this).data('value');
62        $('.member_list_section .select-filter').val(filter_val).change();
63        $(".nav-team-filter-link.active").removeClass("active");
64        $(this).addClass("active");
65    });
66
67    $(document).on("click", "#popup_ppl .btn-prev,#popup_ppl .btn-next", function () {
68        var section_id = $("#popup_ppl").attr("data-section");
69        var item_id = parseInt($("#popup_ppl").attr("data-item"));
70        var has_result = $(this).hasClass("btn-prev") ?
71            $(".member_list_section[data-section='" + section_id + "']").find(".member_item[data-item='" + item_id + "']").prevAll(":visible:first").find(".member_list_pop") :
72            $(".member_list_section[data-section='" + section_id + "']").find(".member_item[data-item='" + item_id + "']").nextAll(":visible:first").find(".member_list_pop");
73
74        if (has_result.length > 0) {
75            change_ppl(has_result);
76        }
77    });
78
79    function check_prev(ele) {
80        $("#popup_ppl .btn-prev,#popup_ppl .btn-next").removeClass("swiper-button-disabled");
81    }
82
83    function change_ppl(ele) {
84        var section_id = $(ele).parents("section").attr("data-section");
85        var item_id = parseInt($(ele).parents(".member_item").attr("data-item"));
86
87        var txt_ppl = $(ele).find(".txt-ppl").html();
88        var txt_post = $(ele).find(".txt-post").html();
89        var txt_intro = $(ele).find(".txt-details-desc").val();
90        var img_ppl = $(ele).find(".img-ppl").css('background-image');
91		var logo_ppl = $(ele).find('.img-ppl-logo img').attr('src');
92        var facebook_url = $(ele).parents(".member_item").attr("data-facebook");
93        var linkedin_url = $(ele).parents(".member_item").attr("data-linkedin");
94        var twitter_url = $(ele).parents(".member_item").attr("data-twitter");
95        var instagram_url = $(ele).parents(".member_item").attr("data-instagram");
96        var website_url = $(ele).parents(".member_item").attr("data-website");
97
98
99        $("#popup_ppl").attr("data-section", section_id);
100        $("#popup_ppl").attr("data-item", item_id);
101
102
103        $("#popup_ppl .img-ppl").css('background-image', img_ppl);
104		$("#popup_ppl .img-ppl-logo img").attr('src', logo_ppl);  
105        $("#popup_ppl .txt-ppl").html(txt_ppl);
106        $("#popup_ppl .txt-post").html(txt_post); 
107        $("#popup_ppl .txt-intro").html(txt_intro);
108
109
110
111        $("#popup_ppl .pop_facebook_url").attr("href", facebook_url);
112        if (facebook_url != "") {
113            $("#popup_ppl .pop_facebook_url").parents("li").show();
114        } else {
115            $("#popup_ppl .pop_facebook_url").parents("li").hide();
116        }
117
118
119        $("#popup_ppl .pop_linkedin_url").attr("href", linkedin_url);
120        if (linkedin_url != "") {
121            $("#popup_ppl .pop_linkedin_url").parents("li").show();
122        } else {
123            $("#popup_ppl .pop_linkedin_url").parents("li").hide();
124        }
125
126        $("#popup_ppl .pop_twitter_url").attr("href", twitter_url);
127        if (twitter_url != "") {
128            $("#popup_ppl .pop_twitter_url").parents("li").show();
129        } else {
130            $("#popup_ppl .pop_twitter_url").parents("li").hide();
131        }
132
133
134        $("#popup_ppl .pop_instagram_url").attr("href", instagram_url);
135        if (instagram_url != "") {
136            $("#popup_ppl .pop_instagram_url").parents("li").show();
137        } else {
138            $("#popup_ppl .pop_instagram_url").parents("li").hide();
139        }
140
141
142        $("#popup_ppl .pop_website_url").attr("href", website_url);
143        if (website_url != "") {
144            $("#popup_ppl .pop_website_url").parents("li").show();
145        } else {
146            $("#popup_ppl .pop_website_url").parents("li").hide();
147        }
148
149
150        $("#popup_ppl .btn-prev,#popup_ppl .btn-next").removeClass("swiper-button-disabled");
151        var has_prev = $(".member_list_section[data-section='" + section_id + "']").find(".member_item[data-item='" + item_id + "']").prevAll(":visible:first").find(".member_list_pop").length;
152
153        var has_next = $(".member_list_section[data-section='" + section_id + "']").find(".member_item[data-item='" + item_id + "']").nextAll(":visible:first").find(".member_list_pop").length;
154        if (has_prev < 1) {
155            $("#popup_ppl .btn-prev").addClass("swiper-button-disabled");
156        }
157        if (has_next < 1) {
158            $("#popup_ppl .btn-next").addClass("swiper-button-disabled");
159        }
160    }
161
162    $(document).on("click", ".event_list .load_more_btn", function () {
163        var event_section = $(this).parents(".event_list");
164        var current_page = event_section.attr("data-page");
165        get_event_list(event_section, parseInt(current_page) + 1);
166    });
167	
168	$(document).on("click", ".exhibition_list .load_more_btn", function () {
169        var event_section = $(this).parents(".exhibition_list");
170        var current_page = event_section.attr("data-page");
171        get_exhibition_list(event_section, parseInt(current_page) + 1);
172    });
173
174    $(".pop_booking_btn").click(function (e) {
175        $("html").addClass("_open_booking");
176    });
177
178    $(document).on('lity:close', function (event, instance) {
179        if ($("#popup_forgot_password").hasClass("success")) {
180            location.reload();
181        } else if ($("#popup_form .nf-response-msg").length > 0) {
182            if ($("#popup_form .nf-response-msg").html() != "") {
183                location.reload();
184            }
185        }
186    });
187
188    $(document).on("click", ".txt-forget-pw a", function () {
189        $("#popup_login").parents(".lity-container").find(".lity-close").click();
190    });
191
192    $(document).on("click", ".txt-register a", function () {
193        $("#popup_login").parents(".lity-container").find(".lity-close").click();
194    });
195
196    $(document).on("click", ".txt-login a", function () {
197        $("#popup_register").parents(".lity-container").find(".lity-close").click();
198    });
199
200    $(".b-popup-booking .btn-close, .b-popup-booking .bg-overlay").click(function (e) {
201        if ($(".mec-gateway-message.mec-success").length > 0) {
202            location.reload();
203        } else {
204            $("html").removeClass("_open_booking");
205        }
206
207    });
208
209    $(document).on("change", ".event_list .select-filter", function () {
210        $(".event_list").each(function () {
211            get_event_list($(this));
212        });
213    });
214
215    $(document).on("change", ".event_list .select-filter-location", function () {
216        $(".event_list").each(function () {
217            get_event_list($(this));
218        });
219    });
220	
221	$(document).on("change", ".exhibition_list .select-filter", function () {
222        $(".exhibition_list").each(function () {
223            get_exhibition_list($(this));
224        });
225    });
226
227    $(document).on("click", ".post_list .load_more_btn", function () {
228        var post_section = $(this).parents(".post_list");
229        var current_page = post_section.attr("data-page");
230        get_post_list(post_section, parseInt(current_page) + 1);
231    });
232
233    $(document).on("click", ".post_list .post_pagination a.page_num", function () {
234        if (!$(this).hasClass("selected")) {
235            var post_section = $(this).parents(".post_list");
236            var current_page = $(this).html();
237            get_post_list(post_section, parseInt(current_page));
238        }
239    });
240
241    $(document).on("click", ".post_list .post_pagination .btn-prev,.post_list .post_pagination .btn-next", function () {
242        if (!$(this).hasClass("disabled")) {
243            var post_section = $(this).parents(".post_list");
244            var current_page = post_section.attr("data-page");
245            if ($(this).hasClass("btn-prev")) {
246                get_post_list(post_section, parseInt(current_page) - 1);
247            } else {
248                get_post_list(post_section, parseInt(current_page) + 1);
249            }
250        }
251    });
252
253    $(document).on("click", ".btn-next-post:not(.swiper-button-disabled)", function () {
254        var post_id = $(this).attr('data-id');
255        $(".portfolio_item[data-id='" + post_id + "']").next(".portfolio_item").click();
256    });
257
258    $(document).on("click", ".btn-prev-post:not(.swiper-button-disabled)", function () {
259        console.log('test');
260        var post_id = $(this).attr('data-id');
261        $(".portfolio_item[data-id='" + post_id + "']").prev(".portfolio_item").click();
262    });
263     $(document).on("click", ".portfolio_item_v2", function () {
264            var p = $('.b-popup-portfolio');
265            var is_show_popup_icon = $('.data_show_popup_icon').text();
266            var img = $(this).find('.data_img').text();
267            var logo = $(this).find('.data_logo').text();
268            var title = $(this).find('.data_title').text();
269            var des = $(this).find('.data_des').text();
270            var url = $(this).find('.data_url').text();
271            var category_1 = $(this).find('.data_category_1').text();
272            var category_2 = $(this).find('.data_category_2').text();
273            var category_3 = $(this).find('.data_category_3').text();
274            var category_4 = $(this).find('.data_category_4').text();
275            var category_5 = $(this).find('.data_category_5').text();
276            var info_title_1 = $(this).find('.data-info-title-1').text();
277            var info_title_2 = $(this).find('.data-info-title-2').text();
278            var info_title_3 = $(this).find('.data-info-title-3').text();
279            var info_title_4 = $(this).find('.data-info-title-4').text();
280            var info_detail_1 = $(this).find('.data-info-datail-1').text();
281            var info_detail_2 = $(this).find('.data-info-datail-2').text();
282            var info_detail_3 = $(this).find('.data-info-datail-3').text();
283            var info_detail_4 = $(this).find('.data-info-datail-4').text();
284            $('.info-1').text();
285            $('.info-2').text();
286            $('.info-3').text();
287            $('.info-4').text();
288            $('.info-detail-1').text();
289            $('.info-detail-2').text();
290            $('.info-detail-3').text();
291            $('.info-detail-4').text();
292
293            $('.txt_category_v1').text('');
294            $('.txt_category_v2').text('');
295            $('.txt_category_v3').text('');
296            $('.txt_category_v4').text('');
297            $('.txt_category_v5').text('');
298            $('.read_more_url').attr('src','');
299
300            $('.info-1').text(info_title_1);
301            $('.info-2').text(info_title_2);
302            $('.info-3').text(info_title_3);
303            $('.info-4').text(info_title_4);
304            $('.info-detail-1').text(info_detail_1);
305            $('.info-detail-2').text(info_detail_2);
306            $('.info-detail-3').text(info_detail_3);
307            $('.info-detail-4').text(info_detail_4);
308
309            $('.col-gallery').html('<img class="w-100 ga-img" src="'+img+'">');
310            $('.txt-portfolio-name').text(title);
311            $('.col-intro.content_body').text(des);
312            if(is_show_popup_icon == 'both_show' || is_show_popup_icon == 'popup_show'){
313                $('.img-logo-v2').css('background-image', 'url("'+logo+'")');
314            }
315            $("html").addClass("_open_portfolio");
316            $('.txt_category_v1').text(category_1);
317            $('.txt_category_v5').text(category_5);
318            $('.ico_slash_v1').css('display','inline-block');
319            $('.ico_slash_v2').css('display','inline-block');
320            $('.ico_slash_v3').css('display','inline-block');
321            if(category_2 !=''){
322                $('.txt_category_v2').text(category_2);
323            }else{
324                $('.ico_slash_v1').css('display','none');
325            }
326            if(category_3 !=''){
327                $('.txt_category_v3').text(category_3);
328            }else{
329                $('.ico_slash_v2').css('display','none');
330            }
331            if(category_4 !=''){
332                $('.txt_category_v4').text(category_4);
333            }else{
334                $('.ico_slash_v3').css('display','none');
335            }
336            if(category_5 ==''){
337                $('.ico_slash_v4').css('display','none');
338            }
339            if(url != ''){
340                $('.read_more_url').show();
341                $('.read_more_url').attr('src',url);
342            }else{
343                $('.read_more_url').hide();
344            }
345           
346    });
347
348    $(document).on("click", ".portfolio_item", function () {
349        // console.log("click portfolio_item");
350        var d = $(this).find('.popup-data');
351        var p = $('.b-popup-portfolio');
352
353        var post_id = $(this).attr('data-id');
354        var title = $(this).find('.txt-brand').html();
355        var category = $(this).find('.txt-category').html();
356        var status = $(this).find('.txt-status').html();
357        var company_logo = $(this).find('.img-logo').css("background-image");
358
359        var popup_logo_background = d.find('.popup_logo_background').val();
360
361        var founding_year = d.find('.founding_year').val();
362
363        var headquarter = d.find('.headquarter').val();
364        var business_stage = d.find('.business_stage').val();
365
366        var funding_stage = d.find('.funding_stage').val();
367        var content_body = d.find('.content_body').val();
368        var read_more_url = d.find('.read_more_url').val();
369
370        var website_url = d.find('.website_url').val();
371        var linkedin_url = d.find('.linkedin_url').val();
372        var youtube_url = d.find('.youtube_url').val();
373        var twitter_url = d.find('.twitter_url').val();
374        var instagram_url = d.find('.instagram_url').val();
375        var facebook_url = d.find('.facebook_url').val();
376
377        if (d.find('.key_milestones').val() != "") {
378            var key_milestones = JSON.parse(d.find('.key_milestones').val());
379        }
380
381        if (d.find('.job_openings').val() != "") {
382            var job_openings = JSON.parse(d.find('.job_openings').val());
383        }
384        if (d.find('.key_investors').val() != "") {
385            var key_investors = JSON.parse(d.find('.key_investors').val());
386        }
387        if (d.find('.image_slider').val() != "") {
388            var image_slider = JSON.parse(d.find('.image_slider').val());
389        }
390        if (d.find('.custom_section').val() != "") {
391            var custom_section = JSON.parse(d.find('.custom_section').val());
392        }
393
394
395        p.find(".btn-next-post").attr('data-id', post_id);
396        p.find(".btn-prev-post").attr('data-id', post_id);
397        p.find(".txt-portfolio-name").html(title);
398        p.find(".txt-category").html(category);
399        p.find(".txt-status").html(status);
400
401
402
403        if (company_logo !== undefined) {
404            p.find(".img-logo").css({ "opacity": 1 });
405            p.find(".txt-portfolio-name").css({ "position": "static" });
406            p.find(".txt-portfolio-name").addClass("icon_margin");
407            p.find(".txt-portfolio-name").removeClass("icon_style");
408            p.find(".txt-subtitle").show();
409        } else {
410            p.find(".img-logo").css({ "opacity": 0 });
411            p.find(".txt-portfolio-name").css({ "position": "relative", "bottom": "113px" });
412            //  p.find(".txt-portfolio-name").css({"position": "relative" });
413            p.find(".txt-portfolio-name").removeClass("icon_margin");
414            p.find(".txt-portfolio-name").addClass("icon_style");
415            p.find(".txt-subtitle").hide();
416        }
417        p.find(".img-logo").css({ "background-image": company_logo });
418
419        //var old_content_html = p.find(".content_body").html();
420        var pn_btn = p.find(".content_body .btn-pn-post").html();
421        console.log(pn_btn);
422        p.find(".content_body").html(content_body + '<div class="btn-pn-post">' + pn_btn + '</div>');
423
424
425        if (popup_logo_background != "" && popup_logo_background == "white") {
426            p.find(".img-logo").addClass("bg-white");
427        } else {
428            p.find(".img-logo").removeClass("bg-white");
429        }
430
431        p.find(".founding_year").html(founding_year);
432        if (founding_year != "") {
433            p.find(".founding_year").show();
434            p.find(".founding_year_title").show();
435        } else {
436            p.find(".founding_year_title").hide();
437            p.find(".founding_year").hide();
438        }
439
440        p.find(".headquarter").html(headquarter);
441        if (headquarter != "") {
442            p.find(".headquarter").show();
443            p.find(".headquarter_title").show();
444        } else {
445            p.find(".headquarter_title").hide();
446            p.find(".headquarter").hide();
447        }
448
449        p.find(".business_stage").html(business_stage);
450        if (business_stage != "") {
451            p.find(".business_stage").show();
452            p.find(".business_stage_title").show();
453        } else {
454            p.find(".business_stage_title").hide();
455            p.find(".business_stage").hide();
456        }
457
458
459
460        p.find(".funding_stage").html(funding_stage);
461        if (funding_stage != "") {
462            p.find(".funding_stage").show();
463            p.find(".funding_stage_title").show();
464        } else {
465            p.find(".funding_stage_title").hide();
466            p.find(".funding_stage").hide();
467        }
468
469
470        p.find(".read_more_url").attr("href", read_more_url);
471        if (read_more_url != "") {
472            p.find(".read_more_url").show();
473        } else {
474            p.find(".read_more_url").hide();
475        }
476
477
478        p.find(".website_url").attr("href", website_url);
479        if (website_url != "") {
480            p.find(".website_url").parents("li").show();
481        } else {
482            p.find(".website_url").parents("li").hide();
483        }
484
485        p.find(".linkedin_url").attr("href", linkedin_url);
486        if (linkedin_url != "") {
487            p.find(".linkedin_url").parents("li").show();
488        } else {
489            p.find(".linkedin_url").parents("li").hide();
490        }
491
492
493        p.find(".youtube_url").attr("href", youtube_url);
494        if (youtube_url != "") {
495            p.find(".youtube_url").parents("li").show();
496        } else {
497            p.find(".youtube_url").parents("li").hide();
498        }
499
500        p.find(".twitter_url").attr("href", twitter_url);
501        if (twitter_url != "") {
502            p.find(".twitter_url").parents("li").show();
503        } else {
504            p.find(".twitter_url").parents("li").hide();
505        }
506
507        p.find(".instagram_url").attr("href", instagram_url);
508        if (instagram_url != "") {
509            p.find(".instagram_url").parents("li").show();
510        } else {
511            p.find(".instagram_url").parents("li").hide();
512        }
513
514        p.find(".facebook_url").attr("href", facebook_url);
515        if (facebook_url != "") {
516            p.find(".facebook_url").parents("li").show();
517        } else {
518            p.find(".facebook_url").parents("li").hide();
519        }
520
521
522        p.find(".key_milestones .list-yellow").html("");
523        if (key_milestones !== null && key_milestones !== undefined && key_milestones !== false) {
524            for (var value of key_milestones) {
525                p.find(".key_milestones .list-yellow").append("<li>" + value.milestones_name + "</li>");
526            }
527            p.find(".key_milestones_title").show();
528            p.find(".key_milestones").show();
529        } else {
530            p.find(".key_milestones_title").hide();
531            p.find(".key_milestones").hide();
532        }
533
534        p.find(".job_openings .list-yellow").html("");
535        if (job_openings !== null && job_openings !== undefined && job_openings !== false) {
536            for (var value of job_openings) {
537                p.find(".job_openings .list-yellow").append("<li>" + value.item + "</li>");
538            }
539            p.find(".job_openings_title").show();
540            p.find(".job_openings").show();
541        } else {
542            p.find(".job_openings_title").hide();
543            p.find(".job_openings").hide();
544        }
545
546
547
548        p.find(".key_investors .list-yellow").html("");
549        if (key_investors !== null && key_investors !== undefined && key_investors !== false) {
550            for (var value of key_investors) {
551                p.find(".key_investors .list-yellow").append("<li>" + value.investor_name + "</li>");
552            }
553            p.find(".key_investors_title").show();
554            p.find(".key_investors").show();
555        } else {
556            p.find(".key_investors_title").hide();
557            p.find(".key_investors").hide();
558        }
559
560        p.find(".image_slider").html("");
561        if (image_slider !== null && image_slider !== undefined && image_slider !== false) {
562            for (var value of image_slider) {
563                p.find(".image_slider").append('<div class="swiper-slide"><div class="img-gallery" style="background-image: url(' + value.url + ')"></div></div>');
564            }
565            init_slider();
566            p.find(".image_slider").show();
567        } else {
568            p.find(".image_slider").hide();
569        }
570
571        var custom_html = "";
572        if (custom_section !== null && custom_section !== undefined && custom_section !== false) {
573            for (var value of custom_section) {
574                custom_html += '<div class="txt-info-title">' + value.section_title + '</div><div class="txt-info-detail">' + value.section_content + '</div>';
575            }
576        }
577
578        p.find(".custom_item").html(custom_html);
579
580        if ($(this).prev(".portfolio_item").length > 0) {
581            p.find(".btn-pn-post .btn-prev-post").removeClass("swiper-button-disabled");
582            var prev_name = $(this).prev(".portfolio_item").find(".txt-brand").html();
583            p.find(".btn-prev-post").html("<p class='prev_name'>" + prev_name + "</p>");
584        } else {
585            p.find(".btn-prev-post").html("");
586            p.find(".btn-prev-post").addClass("swiper-button-disabled");
587        }
588
589        if ($(this).next(".portfolio_item").length > 0) {
590            var next_name = $(this).next(".portfolio_item").find(".txt-brand").html();
591            p.find(".btn-next-post").removeClass("swiper-button-disabled");
592            p.find(".btn-next-post").html("<p class='next_name'>" + next_name + "</p>");
593        } else {
594            p.find(".btn-next-post").html("");
595            p.find(".btn-next-post").addClass("swiper-button-disabled");
596        }
597
598        $("html").addClass("_open_portfolio");
599    });
600
601
602    $(document).on("change", ".post_list .select-filter", function () {
603        $(".post_list").each(function () {
604            get_post_list($(this));
605        });
606    });
607
608    $(document).on("click", ".report_list .post_pagination a.page_num", function () {
609        if (!$(this).hasClass("selected")) {
610            var post_section = $(this).parents(".report_list");
611            var current_page = $(this).html();
612            get_report_list(post_section, parseInt(current_page));
613        }
614    });
615
616    $(document).on("click", ".report_list .post_pagination .btn-prev,.report_list .post_pagination .btn-next", function () {
617        if (!$(this).hasClass("disabled")) {
618            var post_section = $(this).parents(".report_list");
619            var current_page = post_section.attr("data-page");
620            if ($(this).hasClass("btn-prev")) {
621                get_report_list(post_section, parseInt(current_page) - 1);
622            } else {
623                get_report_list(post_section, parseInt(current_page) + 1);
624            }
625        }
626    });
627
628    $(document).on("click", ".report_list .load_more_btn", function () {
629        var post_section = $(this).parents(".report_list");
630        var current_page = post_section.attr("data-page");
631        get_report_list(post_section, parseInt(current_page) + 1);
632    });
633
634    $(document).on("change", ".report_list .select-filter", function () {
635        $(".report_list").each(function () {
636            get_report_list($(this));
637        });
638    });
639
640    /* 2022-08-04 hide
641    $(document).on("click",".s-my-event a.event_detail",function(){
642      var event_name = $(this).find(".txt-event-name").html();
643      var event_date = $(this).find(".txt-event-date").html();
644      var event_time = $(this).find(".txt-event-time").html();
645      var event_location = $(this).find(".txt-event-location").html();
646      var event_total = $(this).find(".txt-event-total").html();
647      var transaction_id = $(this).find(".txt-event-transaction-id").html();
648      var booking_time = $(this).find(".txt-event-purchase-date").html();
649      var event_thumbnail = $(this).find(".img-ticket").css("background-image");
650      var ticket_info = $(this).find(".ticket_info").html();
651      var event_target_url = $(this).find(".event_target_url").val();
652
653      var popup = $("#popup_payment");
654      popup.find(".img-ticket").css("background-image",event_thumbnail);
655      popup.find(".txt-event-transaction-id").html(transaction_id);
656      popup.find(".txt-event-purchase-date").html(booking_time);
657      popup.find(".txt-event-name").html(event_name);
658      popup.find(".txt-event-name").attr("href",event_target_url);
659      popup.find(".txt-event-date").html(event_date);
660      popup.find(".txt-event-time").html(event_time);
661      popup.find(".txt-event-location").html(event_location);
662      popup.find(".txt-num-sum").html(event_total);
663      popup.find(".ticket_info").html(ticket_info);
664
665      popup.find(".btn-status").hide();
666      if ($(this).parents(".b-card-ticket").find(".event_active").length > 0) {
667        popup.find(".event_active").show();
668      }else if($(this).parents(".b-card-ticket").find(".event_canceled").length > 0) {
669        popup.find(".event_canceled").show();
670      }else if($(this).parents(".b-card-ticket").find(".event_pending_to_cancele").length > 0) {
671        popup.find(".event_pending_to_cancele").show();
672      }else{
673        popup.find(".event_expired").show();
674      }
675    });
676    */
677
678    /*2022-08-04 new popup menu detail start */
679    $(document).on("click", ".s-my-event a.event_detail", function () {
680        var event_name = $(this).parents('.popup-content').find(".txt-event-name").html();
681        var event_date = $(this).parents('.popup-content').find(".txt-event-date").html();
682        var event_time = $(this).parents('.popup-content').find(".txt-event-time").html();
683        var event_location = $(this).parents('.popup-content').find(".txt-event-location").html();
684        var event_total = $(this).parents('.popup-content').find(".txt-event-total").html();
685        var transaction_id = $(this).parents('.popup-content').find(".txt-event-transaction-id").html();
686        var booking_time = $(this).parents('.popup-content').find(".txt-event-purchase-date").html();
687        var event_thumbnail = $(this).parents('.popup-content').find(".img-ticket").css("background-image");
688        var ticket_info = $(this).parents('.popup-content').find(".ticket_info").html();
689        var event_target_url = $(this).parents('.popup-content').find(".event_target_url").val();
690
691        var popup = $("#popup_payment");
692        popup.find(".img-ticket").css("background-image", event_thumbnail);
693        popup.find(".txt-event-transaction-id").html(transaction_id);
694        popup.find(".txt-event-purchase-date").html(booking_time);
695        popup.find(".txt-event-name").html(event_name);
696        popup.find(".txt-event-name").attr("href", event_target_url);
697        popup.find(".txt-event-date").html(event_date);
698        popup.find(".txt-event-time").html(event_time);
699        popup.find(".txt-event-location").html(event_location);
700        popup.find(".txt-num-sum").html(event_total);
701        popup.find(".ticket_info").html(ticket_info);
702
703        popup.find(".btn-status").hide();
704        if ($(this).parents(".b-card-ticket").find(".event_active").length > 0) {
705            popup.find(".event_active").show();
706        } else if ($(this).parents(".b-card-ticket").find(".event_canceled").length > 0) {
707            popup.find(".event_canceled").show();
708        } else if ($(this).parents(".b-card-ticket").find(".event_pending_to_cancele").length > 0) {
709            popup.find(".event_pending_to_cancele").show();
710        } else {
711            popup.find(".event_expired").show();
712        }
713    });
714    /*2022-08-04 new popup menu detail end */
715
716    $(document).on("click", ".s-my-event .nav-submenu li a", function () {
717        var post_type = $(this).attr("data-value");
718        $("#my-event-form input[name='post_type']").val(post_type).change();
719        $("#my-event-form input[name='current_page']").val(1).change();
720        $("#my-event-form").submit();
721    });
722
723    $(document).on("click", ".s-my-event .b-pagination .page_num", function () {
724        var current_page = $(this).html();
725        $("#my-event-form input[name='current_page']").val(current_page).change();
726        $("#my-event-form").submit();
727    });
728
729    $(document).on("click", ".s-my-event .b-pagination .btn-prev,.s-my-event .b-pagination .btn-next", function () {
730        if (!$(this).hasClass("disabled")) {
731            var current_page = $("#my-event-form input[name='current_page']").val();
732            if ($(this).hasClass("btn-prev")) {
733                $("#my-event-form input[name='current_page']").val(parseInt(current_page) - 1).change();
734            } else {
735                $("#my-event-form input[name='current_page']").val(parseInt(current_page) + 1).change();
736            }
737            $("#my-event-form").submit();
738        }
739    });
740
741
742    $(document).on("click", ".s-search .b-pagination .page_num", function () {
743        var current_page = $(this).html();
744        $("#search_form input[name='current_page']").val(current_page).change();
745        $("#search_form").submit();
746    });
747
748    $(document).on("click", ".s-search .b-pagination .btn-prev,.s-search .b-pagination .btn-next", function () {
749        if (!$(this).hasClass("disabled")) {
750            var current_page = $("#search_form input[name='current_page']").val();
751            if ($(this).hasClass("btn-prev")) {
752                $("#search_form input[name='current_page']").val(parseInt(current_page) - 1).change();
753            } else {
754                $("#search_form input[name='current_page']").val(parseInt(current_page) + 1).change();
755            }
756            $("#search_form").submit();
757        }
758    });
759
760
761
762
763
764    $(document).on("change", ".user_profile input[name='change_password']", function () {
765        console.log(1);
766        if ($(".user_profile input[name='change_password']").is(":checked")) {
767            var clone = $(".change_password_template .change_password_col").clone();
768            $(".user_profile .row-form").append(clone);
769        } else {
770            $(".user_profile .row-form .change_password_col").remove();
771        }
772    });
773
774    $(document).on("change", ".user_profile .edit_account input", function () {
775        $(this).removeClass("error");
776    });
777
778
779    $(document).on("change", ".edit_account #company_category", function () {
780        if ($(this).val() == "Public") {
781            $(".edit_account .public_row").hide();
782            $(".edit_account #company_title").prop('required', false).val("");
783            $(".edit_account #company_name").prop('required', false).val("");
784        } else {
785            $(".edit_account .public_row").show();
786            $(".edit_account #company_title").prop('required', true).val("");
787            $(".edit_account #company_name").prop('required', true).val("");
788        }
789    });
790
791
792    $('.user_profile .edit_account .submit_btn').on('click', function (e) {
793        $(".user_profile .error_message").remove();
794
795        var check_empty = false;
796        $(".user_profile .edit_account input[required]").each(function () {
797            if ($(this).val() == "") {
798                check_empty = true;
799                $(this).after('<h3 class="error_message txt-red">Cannot be empty</h3>');
800                $(this).addClass("error");
801            }
802        });
803
804        if (check_empty) {
805            return;
806        }
807        var ajaxurl = $("form.edit_account").attr("data-ajaxurl");
808        var last_name = $(".user_profile input[name='last_name']").val();
809        var first_name = $(".user_profile input[name='first_name']").val();
810        var email = $(".user_profile input[name='email']").val();
811        var current_password = $(".user_profile input[name='current_password']").val();
812        var isChange = $(".user_profile input[name='change_password']").is(":checked");
813        var new_password = $(".user_profile .edit_account input[name='new_password']").val();
814        var confirm_password = $(".user_profile .edit_account input[name='confirm_password']").val();
815
816        //editing
817        age = $(".user_profile select[name='age']").val();
818        gender = $(".user_profile select[name='gender']").val();
819        mobile_number = $(".user_profile input[name='mobile_number']").val();
820
821        country = $(".user_profile select[name='country']").val();
822        company_category = $(".user_profile select[name='company_category']").val();
823        company_name = $(".user_profile input[name='company_name']").val();
824        company_title = $(".user_profile input[name='company_title']").val();
825        company_address = $(".user_profile input[name='company_address']").val();
826        company_street = $(".user_profile input[name='company_street']").val();
827        company_city = $(".user_profile input[name='company_city']").val();
828        company_state = $(".user_profile input[name='company_state']").val();
829        company_postal = $(".user_profile input[name='company_postal']").val();
830        company_number = $(".user_profile input[name='company_number']").val();
831
832        if (isChange) {
833
834
835            if (new_password !== confirm_password) {
836                $(".user_profile .edit_account input[name='confirm_password']").after('<h3 class="error_message txt-red">Confirm password not match</h3>');
837                return;
838            } else if (validatePassword(new_password)) {
839                $(".user_profile .edit_account input[name='new_password']").after('<h3 class="error_message txt-red">' + validatePassword(new_password) + '</h3>');
840                return;
841            }
842        }
843        $(".user_profile .loader-inner").show();
844        jQuery.ajax({
845            url: ajaxurl,
846            data: {
847                action: 'edit_user_profile',
848                last_name: last_name,
849                first_name: first_name,
850                email: email,
851                current_password: current_password,
852                isChange: isChange,
853                new_password: new_password,
854
855                age: age,
856                gender: gender,
857                mobile_number: mobile_number,
858                country: country,
859                company_category: company_category,
860                company_name: company_name,
861                company_title: company_title,
862                company_number: company_number,
863                company_address: company_address,
864                company_street: company_street,
865                company_city: company_city,
866                company_state: company_state,
867                company_postal: company_postal,
868            },
869            dataType: 'JSON',
870            type: 'POST',
871            success: function (result) {
872                console.log(result);
873                if (result.status == 200) {
874                    location.reload();
875                } else if (result.status == 300) {
876                    alert("Your password was updated, please login again.");
877                    location.reload();
878                } else {
879                    $("html, body").animate({ scrollTop: 0 }, "slow");
880                    $(".user_profile .box-profile").prepend('<h3 class="error_message txt-red">' + result.error + '</h3>');
881                    $(".user_profile .loader-inner").hide();
882                }
883            },
884            error: function (result) {
885                console.log('error from edit_user_profile', result);
886                $(".user_profile .loader-inner").hide();
887            }
888        });
889    });
890
891
892    $(document).on("click", ".magazine_list .load_more_btn", function () {
893        var post_section = $(this).parents(".magazine_list");
894        var current_page = post_section.attr("data-page");
895        get_magazine_list(post_section, parseInt(current_page) + 1);
896    });
897
898    $(document).on("click", ".magazine_list .post_pagination a.page_num", function () {
899        if (!$(this).hasClass("selected")) {
900            var post_section = $(this).parents(".magazine_list");
901            var current_page = $(this).html();
902            get_magazine_list(post_section, parseInt(current_page));
903        }
904    });
905
906    $(document).on("click", ".magazine_list .post_pagination .btn-prev,.magazine_list .post_pagination .btn-next", function () {
907        if (!$(this).hasClass("disabled")) {
908            var post_section = $(this).parents(".magazine_list");
909            var current_page = post_section.attr("data-page");
910            if ($(this).hasClass("btn-prev")) {
911                get_magazine_list(post_section, parseInt(current_page) - 1);
912            } else {
913                get_magazine_list(post_section, parseInt(current_page) + 1);
914            }
915        }
916    });
917
918
919    $(document).on("click", ".chain_popup", function () {
920        var logo = $(this).find(".img-logo").css("background-image");
921        logo = logo.replace('url(', '').replace(')', '').replace(/\"/gi, "");
922        var desc = $(this).find(".img-desc").val();
923        $("#popup_company .img-logo").attr("src", logo);
924        $("#popup_company .txt-logo").html(desc);
925        $("#chain_popup").click();
926    });
927
928
929    $(document).on("change", ".gallery_list .select-filter", function () {
930        $(".gallery_list").each(function () {
931            get_gallery_list($(this));
932        });
933    });
934
935    $(document).on("click", ".gallery_list .load_more_btn", function () {
936        var post_section = $(this).parents(".gallery_list");
937        var current_page = post_section.attr("data-page");
938        get_gallery_list(post_section, parseInt(current_page) + 1);
939    });
940
941    $(document).on("click", ".gallery_list .post_pagination a.page_num", function () {
942        if (!$(this).hasClass("selected")) {
943            var post_section = $(this).parents(".gallery_list");
944            var current_page = $(this).html();
945            get_gallery_list(post_section, parseInt(current_page));
946        }
947    });
948
949    $(document).on("click", ".gallery_list .post_pagination .btn-prev,.gallery_list .post_pagination .btn-next", function () {
950        if (!$(this).hasClass("disabled")) {
951            var post_section = $(this).parents(".gallery_list");
952            var current_page = post_section.attr("data-page");
953            if ($(this).hasClass("btn-prev")) {
954                get_gallery_list(post_section, parseInt(current_page) - 1);
955            } else {
956                get_gallery_list(post_section, parseInt(current_page) + 1);
957            }
958        }
959    });
960
961
962    $(document).on("click", ".exc_list_pop", function (e) {
963        e.preventDefault();
964        change_exc(this);
965        return false;
966    });
967
968
969    $(document).on("click", "#popup_exc .btn-prev,#popup_exc .btn-next", function () {
970        var section_id = $("#popup_exc").attr("data-section");
971        var item_id = parseInt($("#popup_exc").attr("data-item"));
972        var has_result = $(this).hasClass("btn-prev") ?
973            $(".exc_list_section[data-section='" + section_id + "']").find(".exc_item[data-item='" + item_id + "']").prevAll(":visible:first").find(".exc_list_pop") :
974            $(".exc_list_section[data-section='" + section_id + "']").find(".exc_item[data-item='" + item_id + "']").nextAll(":visible:first").find(".exc_list_pop");
975
976        if (has_result.length > 0) {
977            change_exc(has_result);
978        }
979    });
980
981
982
983    function change_exc(ele) {
984        var section_id = $(ele).parents("section").attr("data-section");
985        var item_id = parseInt($(ele).parents(".exc_item").attr("data-item"));
986        ele = $(ele).parents(".exc_item");
987        var txt_ppl = $(ele).find(".txt-circle").html();
988        var txt_post = $(ele).find(".txt-desc").html();
989        var txt_intro = $(ele).find(".txt-details-desc").html();
990        var img_ppl = $(ele).find(".img-circle").css('background-image');
991
992        $("#popup_exc").attr("data-section", section_id);
993        $("#popup_exc").attr("data-item", item_id);
994
995
996        $("#popup_exc .img-ppl").css('background-image', img_ppl);
997        $("#popup_exc .txt-ppl").html(txt_ppl);
998        $("#popup_exc .txt-post").html(txt_post);
999        $("#popup_exc .txt-intro").html(txt_intro);
1000
1001
1002        $("#popup_exc .btn-prev,#popup_exc .btn-next").removeClass("swiper-button-disabled");
1003        var has_prev = $(".exc_list_section[data-section='" + section_id + "']").find(".exc_item[data-item='" + item_id + "']").prevAll(":visible:first").find(".exc_list_pop").length;
1004        var has_next = $(".exc_list_section[data-section='" + section_id + "']").find(".exc_item[data-item='" + item_id + "']").nextAll(":visible:first").find(".exc_list_pop").length;
1005        console.log('p' + has_prev);
1006        console.log('n' + has_next);
1007        if (has_prev < 1) {
1008            console.log('has:' + has_prev);
1009            $("#popup_exc .btn-prev").addClass("swiper-button-disabled");
1010        }
1011        if (has_next < 1) {
1012            console.log('hasn:' + has_next);
1013            $("#popup_exc .btn-next").addClass("swiper-button-disabled");
1014        }
1015    }
1016
1017});
1018
1019function validatePassword(p) {
1020    var errors = [];
1021    if (p.length < 8) {
1022        errors.push("Your password must be at least 8 characters");
1023    }
1024    if (p.search(/[a-z]/i) < 0) {
1025        errors.push("Your password must contain at least one letter.");
1026    }
1027    if (p.search(/[0-9]/) < 0) {
1028        errors.push("Your password must contain at least one digit.");
1029    }
1030    if (errors.length > 0) {
1031        return "<span class='txt-red'>" + errors.join("\n") + "</span>";
1032    }
1033    return false;
1034}
1035
1036function updateUrlParams(urlData) {
1037    // 獲取當前的 URL
1038    var currentUrl = new URL(window.location.href);
1039
1040    // 遍歷 urlData,將每個 key-value 添加到 URL 查詢參數中
1041    for (var key in urlData) {
1042        if (urlData.hasOwnProperty(key)) {
1043            currentUrl.searchParams.set(key, urlData[key]); // 添加或更新查詢參數
1044        }
1045    }
1046
1047    // 更新 URL,而不刷新頁面
1048    window.history.replaceState(null, "", currentUrl.toString());
1049}
1050
1051var monthNames = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
1052
1053function get_event_list(event_section, current_page = 1) {
1054    var ajaxurl = event_section.attr("data-ajaxurl");
1055    var loading_type = event_section.attr("data-loading");
1056    var event_type = event_section.attr("data-event");
1057    var per_page = event_section.attr("data-perpage");
1058    var template_div = event_section.find(".template_div").html();
1059    event_section.find(".loader-inner").show();
1060
1061    var filter_data = [];
1062    var location_filter = [];
1063    var url_data = {};
1064    event_section.find(".select-filter:not(.select-filter-location)").each(function () {
1065        var value = $(this).val();
1066        var label = $(this).find("option:selected").data('label');
1067        var label_key = $(this).parents(".txt-select").find(".txt").data('label');
1068        if (value != "") {
1069            if(label == undefined && label_key == undefined){
1070                filter_data.push(value);
1071                value = 'all';
1072            }else{
1073                filter_data.push(value);
1074                url_data[label_key] = label;
1075            }
1076        }else{
1077            value = 'all';
1078            url_data[label_key] = label;
1079        }
1080    });
1081    event_section.find(".select-filter-location").each(function () {
1082        var value = $(this).val();
1083        var label = $(this).find("option:selected").data('label');
1084        var label_key = $(this).parents(".txt-select").find(".txt").data('label');
1085        if (value != "") {
1086            if(label == undefined && label_key == undefined){
1087                location_filter.push(value);
1088            }else{
1089                location_filter.push(value);
1090                url_data[label_key] = label;
1091            }
1092        }else if (label_key !== undefined) {
1093            url_data[label_key] = 'all';
1094        }
1095    });
1096    updateUrlParams(url_data);
1097    jQuery.ajax({
1098        url: ajaxurl,
1099        data: {
1100            action: 'get_event_list',
1101            isPastEvent: event_type,
1102            current_page: current_page,
1103            loading_type: loading_type,
1104            per_page: per_page,
1105            filter_data: filter_data,
1106            location_filter: location_filter,
1107            current_lang: check_cookie_name("wp-wpml_current_language"),
1108        },
1109        dataType: 'JSON',
1110        type: 'POST',
1111        success: function (result) {
1112            console.log(result);
1113            if (loading_type == "pager" || current_page == 1) {
1114                event_section.find(".row-card").html("");
1115            }
1116
1117            if (current_page == 1 && result.data.length < 1) {
1118                event_section.find(".row-card").append("<h3 class='not_find_message'>Event Not Found</h3>");
1119            }
1120            for (var item of result.data) {
1121                var clone = $(template_div).clone();
1122                $(clone).find('.img-event').css({ "background-image": "url(" + item.thumbnail_url + ")" });
1123                if (item.location_1 != "Uncategorized" && item.location_1 != "Uncategorized @tc" && item.location_1 != "Uncategorized @sc" && item.location_1 != "") {
1124                    $(clone).find('.txt-event-loc .txt').html(item.location_1);
1125                } else {
1126                    $(clone).find('.txt-event-loc').css("opacity", 0);
1127                }
1128
1129                $(clone).find('.txt-event-title').html(item.title);
1130
1131                $(clone).find('.event-link').attr("href", item.targetUrl);
1132                if(item.checkTargetUrl == true){
1133                    $(clone).find('.event-link').attr("target", '_blank');
1134                }
1135
1136                var start_date = new Date(item.start_date);
1137                $(clone).find('.start_datetime .txt-event-day').html(start_date.getDate());
1138                $(clone).find('.start_datetime .txt-event-month').html(monthNames[start_date.getMonth()]);
1139                $(clone).find('.start_datetime .txt-event-year').html(start_date.getFullYear());
1140
1141                if (item.start_date == item.end_date) {
1142                    $(clone).find('.showDate').hide();
1143                    $(clone).find('.end_datetime .start_time .txt-event-num').html(item.start_time);
1144                    $(clone).find('.end_datetime .start_time .txt-event-ampm').html(item.start_time_ap);
1145                    $(clone).find('.end_datetime .end_time .txt-event-num').html(item.end_time);
1146                    $(clone).find('.end_datetime .end_time .txt-event-ampm').html(item.end_time_ap);
1147                } else {
1148                    $(clone).find('.showTime').hide();
1149                    var end_date = new Date(item.end_date);
1150                    $(clone).find('.end_datetime .txt-event-day').html(end_date.getDate());
1151                    $(clone).find('.end_datetime .txt-event-month').html(monthNames[end_date.getMonth()]);
1152                    $(clone).find('.end_datetime .txt-event-year').html(end_date.getFullYear());
1153                }
1154
1155                event_section.find(".row-card").append(clone);
1156            }
1157
1158            event_section.attr("data-page", result.current_page);
1159            if (loading_type == "load_more" && parseInt(result.current_page) != parseInt(result.max_num_pages) && parseInt(result.max_num_pages) != 0) {
1160                event_section.find(".load_more_btn").show();
1161            } else {
1162                event_section.find(".load_more_btn").hide();
1163            }
1164            event_section.find(".loader-inner").hide();
1165        },
1166        error: function (result) {
1167            console.log('error from admin-ajax.js', result);
1168            event_section.find(".loader-inner").hide();
1169        }
1170    })
1171}
1172
1173
1174function get_exhibition_list(exhibition_section, current_page = 1) {
1175    var ajaxurl = exhibition_section.attr("data-ajaxurl");
1176    var loading_type = exhibition_section.attr("data-loading");
1177    var exhibition_type = exhibition_section.attr("data-event");
1178    var per_page = exhibition_section.attr("data-perpage");
1179    var template_div = exhibition_section.find(".template_div").html();
1180    exhibition_section.find(".loader-inner").show();
1181
1182    var filter_data = [];
1183    var url_data = {};
1184    exhibition_section.find(".select-filter").each(function () {
1185        var value = $(this).val();
1186        var label = $(this).find("option:selected").data('label');
1187        var label_key = $(this).parents(".txt-select").find(".txt").data('label');
1188        if (value != "") {
1189            if(label == undefined && label_key == undefined){
1190                filter_data.push(value);
1191                value = 'all';
1192            }else{
1193                filter_data.push(value);
1194                url_data[label_key] = label;
1195            }
1196            //filter_data.push(value);
1197            //url_data[label_key] = label;
1198        }else{ 
1199            value = 'all';
1200            url_data[label_key] = label;
1201        }
1202    });
1203    updateUrlParams(url_data);
1204	console.log(filter_data);
1205    jQuery.ajax({
1206        url: ajaxurl,
1207        data: {
1208            action: 'get_exhibition_list',
1209            isPastExhibition: exhibition_type,
1210            current_page: current_page,
1211            loading_type: loading_type,
1212            per_page: per_page,
1213            filter_data: filter_data,
1214            current_lang: check_cookie_name("wp-wpml_current_language"),
1215        },
1216        dataType: 'JSON',
1217        type: 'POST',
1218        success: function (result) {
1219            console.log(result);
1220            if (loading_type == "pager" || current_page == 1) {
1221                exhibition_section.find(".row-card").html("");
1222            }
1223
1224            if (current_page == 1 && result.data.length < 1) {
1225                exhibition_section.find(".row-card").append("<h3 class='not_find_message'>Event Not Found</h3>");
1226            }
1227            for (var item of result.data) {
1228                var clone = $(template_div).clone();
1229                $(clone).find('.img-event').css({ "background-image": "url(" + item.thumbnail_url + ")" });
1230                if (item.location_1 != "Uncategorized" && item.location_1 != "Uncategorized @tc" && item.location_1 != "Uncategorized @sc" && item.location_1 != "") {
1231                    $(clone).find('.txt-event-loc .txt').html(item.location_1);
1232                } else {
1233                    $(clone).find('.txt-event-loc').css("opacity", 0);
1234                }
1235
1236                $(clone).find('.txt-event-title').html(item.title);
1237
1238                $(clone).find('.event-link').attr("href", item.targetUrl);
1239                if(item.checkTargetUrl == true){
1240                    $(clone).find('.event-link').attr("target", '_blank');
1241                }
1242
1243                var start_date = new Date(item.start_date);
1244                $(clone).find('.start_datetime .txt-event-day').html(start_date.getDate());
1245                $(clone).find('.start_datetime .txt-event-month').html(monthNames[start_date.getMonth()]);
1246                $(clone).find('.start_datetime .txt-event-year').html(start_date.getFullYear());
1247
1248                if (item.start_date == item.end_date) {
1249                    $(clone).find('.showDate').hide();
1250                    $(clone).find('.end_datetime .start_time .txt-event-num').html(item.start_time);
1251                    $(clone).find('.end_datetime .start_time .txt-event-ampm').html(item.start_time_ap);
1252                    $(clone).find('.end_datetime .end_time .txt-event-num').html(item.end_time);
1253                    $(clone).find('.end_datetime .end_time .txt-event-ampm').html(item.end_time_ap);
1254                } else {
1255                    $(clone).find('.showTime').hide();
1256                    var end_date = new Date(item.end_date);
1257                    $(clone).find('.end_datetime .txt-event-day').html(end_date.getDate());
1258                    $(clone).find('.end_datetime .txt-event-month').html(monthNames[end_date.getMonth()]);
1259                    $(clone).find('.end_datetime .txt-event-year').html(end_date.getFullYear());
1260                }
1261
1262                exhibition_section.find(".row-card").append(clone);
1263            }
1264
1265            exhibition_section.attr("data-page", result.current_page);
1266            if (loading_type == "load_more" && parseInt(result.current_page) != parseInt(result.max_num_pages) && parseInt(result.max_num_pages) != 0) {
1267                exhibition_section.find(".load_more_btn").show();
1268            } else {
1269                exhibition_section.find(".load_more_btn").hide();
1270            }
1271            exhibition_section.find(".loader-inner").hide();
1272        },
1273        error: function (result) {
1274            console.log('error from admin-ajax.js', result);
1275            exhibition_section.find(".loader-inner").hide();
1276        }
1277    })
1278}
1279
1280function get_post_list(post_section, current_page = 1) {
1281
1282    var ajaxurl = post_section.attr("data-ajaxurl");
1283    var loading_type = post_section.attr("data-loading");
1284    var per_page = post_section.attr("data-perpage");
1285    var post_type = post_section.attr("data-type");
1286    var template_div = post_section.find(".template_div").html();
1287    post_section.find(".loader-inner").show();
1288
1289    var filter_data = [];
1290    post_section.find(".select-filter").each(function () {
1291        var value = $(this).val();
1292        if (value != "") {
1293            filter_data.push(value);
1294        }
1295    });
1296
1297    jQuery.ajax({
1298        url: ajaxurl,
1299        data: {
1300            action: 'get_post_list',
1301            current_page: current_page,
1302            post_type: post_type,
1303            loading_type: loading_type,
1304            per_page: per_page,
1305            filter_data: filter_data,
1306            current_lang: check_cookie_name("wp-wpml_current_language"),
1307        },
1308        dataType: 'JSON',
1309        type: 'POST',
1310        success: function (result) {
1311            console.log(result);
1312
1313            if (loading_type == "pager" || current_page == 1) {
1314                post_section.find(".row-card").html("");
1315            }
1316
1317
1318
1319
1320            for (var item of result.data) {
1321                var clone = $(template_div).clone();
1322
1323
1324                $(clone).find('.img-card').css({ "background-image": "url(" + item.thumbnail_url + ")" });
1325                if (post_type == "portfolio_incubatees" || post_type == "store" || post_type == "winner") {
1326                    $(clone).attr("data-id", item.id);
1327                    $(clone).find('.txt-brand').html(item.title);
1328                    $(clone).find('.txt-category').html(item.industry);
1329                    $(clone).find('.txt-status').html(item.stage);
1330                    if (item.industry == "" || item.stage == "") {
1331                        $(clone).find('.ico-slash').hide();
1332                    }
1333
1334
1335
1336
1337                    if (!item.company_logo) {
1338                        $(clone).find('.img-logo').remove();
1339                        $(clone).find('.img-mask').remove();
1340                    } else {
1341                        $(clone).find('.img-logo').css({ "background-image": "url(" + item.company_logo + ")" });
1342                    }
1343
1344
1345
1346                    $(clone).find('.popup-data .popup_logo_background').val(item.popup_logo_background);
1347
1348                    $(clone).find('.popup-data .founding_year').val(item.founding_year);
1349                    $(clone).find('.popup-data .headquarter').val(item.headquarter);
1350                    $(clone).find('.popup-data .business_stage').val(item.business_stage);
1351                    $(clone).find('.popup-data .funding_stage').val(item.funding_stage);
1352                    $(clone).find('.popup-data .content_body').val(item.content_body);
1353                    $(clone).find('.popup-data .read_more_url').val(item.read_more_url);
1354
1355                    $(clone).find('.popup-data .website_url').val(item.website_url);
1356                    $(clone).find('.popup-data .linkedin_url').val(item.linkedin_url);
1357                    $(clone).find('.popup-data .youtube_url').val(item.youtube_url);
1358                    $(clone).find('.popup-data .twitter_url').val(item.twitter_url);
1359                    $(clone).find('.popup-data .instagram_url').val(item.instagram_url);
1360                    $(clone).find('.popup-data .facebook_url').val(item.facebook_url);
1361
1362                    $(clone).find('.popup-data .key_milestones').val(JSON.stringify(item.key_milestones));
1363                    $(clone).find('.popup-data .job_openings').val(JSON.stringify(item.job_openings));
1364                    $(clone).find('.popup-data .key_investors').val(JSON.stringify(item.key_investors));
1365                    $(clone).find('.popup-data .image_slider').val(JSON.stringify(item.image_slider));
1366                    $(clone).find('.popup-data .custom_section').val(JSON.stringify(item.custom_section));
1367
1368                } else {
1369                    if (item.location == "hk") {
1370                        $(clone).find('.txt-with-ico').addClass("theme-hkg");
1371                        $(clone).find('.txt-with-ico .txt').html("Hong Kong");
1372                    } else if (item.location == "uk") {
1373                        $(clone).find('.txt-with-ico').addClass("theme-lon");
1374                        $(clone).find('.txt-with-ico .txt').html("London");
1375                    }
1376                    if (post_type == "blogs") {
1377                        if (item.industry !== undefined && item.industry != "") {
1378                            $(clone).find('.txt-with-ico.display_none').removeClass("display_none");
1379                            $(clone).find('.txt-with-ico .txt').html(item.industry);
1380                        }
1381                    }
1382
1383                    if (post_type == "press") {
1384                        if (item.media_logo !== undefined && item.media_logo != "" && item.media_logo != null) {
1385                            $(clone).find('.media_logo').removeClass("display_none");
1386                            $(clone).find('.media_logo').css("background-image", "url('" + item.media_logo + "')");
1387                        }
1388                    }
1389                    $(clone).find('.txt-blog-title').html(item.title);
1390                    $(clone).find('.post-link').attr("href", item.targetUrl);
1391                    if(item.checkTargetUrl == true){
1392                      $(clone).find('.post-link').attr("target", '_blank');
1393                    }
1394
1395                    $(clone).find('.txt-blog-date').html(item.date);
1396                }
1397
1398                post_section.find(".row-card").append(clone);
1399
1400
1401            }
1402
1403
1404
1405
1406
1407            if (current_page == 1 && result.data.length < 1) {
1408                post_section.find(".row-card").append("<h3 class='not_find_message'>Post Not Found</h3>");
1409            }
1410
1411            post_section.attr("data-page", result.current_page);
1412            if (loading_type == "load_more" && parseInt(result.current_page) != parseInt(result.max_num_pages) && parseInt(result.max_num_pages) != 0) {
1413                post_section.find(".load_more_btn").show();
1414            } else {
1415                post_section.find(".load_more_btn").hide();
1416            }
1417
1418            if (loading_type == "pager" && parseInt(result.max_num_pages) != 1) {
1419                post_section.find(".post_pagination").html(result.pagination_html);
1420                post_section.find(".post_pagination").css("display", "flex");
1421            } else {
1422                post_section.find(".post_pagination").hide();
1423            }
1424
1425            post_section.find(".loader-inner").hide();
1426
1427        },
1428        error: function (result) {
1429            console.log('error from admin-ajax.js', result);
1430            post_section.find(".loader-inner").hide();
1431        }
1432    });
1433}
1434
1435
1436
1437
1438function get_report_list(post_section, current_page = 1) {
1439    var ajaxurl = post_section.attr("data-ajaxurl");
1440    var loading_type = post_section.attr("data-loading");
1441    var per_page = post_section.attr("data-perpage");
1442    var post_type = post_section.attr("data-type");
1443    var template_div = post_section.find(".template_div").html();
1444    post_section.find(".loader-inner").show();
1445
1446    var filter_data = [];
1447    post_section.find(".select-filter").each(function () {
1448        var value = $(this).val();
1449        if (value != "") {
1450            filter_data.push(value);
1451        }
1452    });
1453    jQuery.ajax({
1454        url: ajaxurl,
1455        data: {
1456            action: 'get_post_list',
1457            current_page: current_page,
1458            post_type: post_type,
1459            loading_type: loading_type,
1460            per_page: per_page,
1461            filter_data: filter_data,
1462            current_lang: check_cookie_name("wp-wpml_current_language"),
1463        },
1464        dataType: 'JSON',
1465        type: 'POST',
1466        success: function (result) {
1467            console.log(result);
1468            if (loading_type == "pager" || current_page == 1) {
1469                post_section.find(".row-card").html("");
1470            }
1471            var years = [];
1472            for (var item of result.data) {
1473                var clone = $(template_div).clone();
1474
1475                $(clone).find('.img-card').attr({ "src": item.thumbnail_url });
1476                $(clone).find('.txt-report-title').html(item.title);
1477                $(clone).find('.txt-wrapper').html(item.description);
1478                $(clone).find('.txt-with-ico').attr('data-id', item.id);
1479                $(clone).find('.txt-with-ico').attr('target', '_blank');
1480                if (item.hide_preview) {
1481                    $(clone).find('.txt-preview').remove();
1482                } else {
1483                    $(clone).find('.txt-preview').attr("href", item.targetUrl);
1484                }
1485
1486                if (item.pdf_file != "" && item.pdf_file != null && item.pdf_file != false) {
1487                    $(clone).find('.txt-download.logged_in').attr("href", item.pdf_file);
1488                } else {
1489                    $(clone).find('.txt-download').remove();
1490                }
1491
1492
1493                if (!years.includes(item.year)) {
1494                    post_section.find(".row-card").append('<div class="txt-slash p-default-title"><div class="txt report_year">' + item.year + '</div></div>');
1495                    years.push(item.year);
1496                }
1497                /*
1498                $(clone).find('.post-link').attr("href",item.targetUrl);
1499                */
1500                post_section.find(".row-card").append(clone);
1501            }
1502
1503            if (current_page == 1 && result.data.length < 1) {
1504                post_section.find(".row-card").append("<h3 class='not_find_message'>Post Not Found</h3>");
1505            }
1506
1507            post_section.attr("data-page", result.current_page);
1508            if (loading_type == "load_more" && parseInt(result.current_page) != parseInt(result.max_num_pages) && parseInt(result.max_num_pages) != 0) {
1509                post_section.find(".load_more_btn").show();
1510            } else {
1511                post_section.find(".load_more_btn").hide();
1512            }
1513
1514            if (loading_type == "pager" && parseInt(result.max_num_pages) != 1) {
1515                post_section.find(".post_pagination").html(result.pagination_html);
1516                post_section.find(".post_pagination").css("display", "flex");
1517            } else {
1518                post_section.find(".post_pagination").hide();
1519            }
1520
1521            post_section.find(".loader-inner").hide();
1522
1523        },
1524        error: function (result) {
1525            console.log('error from admin-ajax.js', result);
1526            post_section.find(".loader-inner").hide();
1527        }
1528    })
1529}
1530
1531
1532
1533$(document).on("click", ".b-download .txt-with-ico", function () {
1534    var report_list_id = $(this).attr("data-id");
1535    // console.log(report_list_id);
1536
1537    var ajaxurl = $(this).parents("section.report_list").attr("data-ajaxurl");
1538    jQuery.ajax({
1539        url: ajaxurl,
1540        data: {
1541            action: 'download_count',
1542            report_list_id: report_list_id,
1543
1544        },
1545        dataType: 'JSON',
1546        type: 'POST',
1547        success: function (result) {
1548
1549            console.log(result);
1550
1551        },
1552        error: function (result) {
1553            console.log('error from admin-ajax.js', result);
1554            post_section.find(".loader-inner").hide();
1555        }
1556    });
1557
1558});
1559
1560
1561
1562function get_magazine_list(post_section, current_page = 1) {
1563    var ajaxurl = post_section.attr("data-ajaxurl");
1564    var loading_type = post_section.attr("data-loading");
1565    var per_page = post_section.attr("data-perpage");
1566    var post_type = post_section.attr("data-type");
1567    var template_div = post_section.find(".template_div").html();
1568    post_section.find(".loader-inner").show();
1569    jQuery.ajax({
1570        url: ajaxurl,
1571        data: {
1572            action: 'get_post_list',
1573            current_page: current_page,
1574            post_type: post_type,
1575            loading_type: loading_type,
1576            per_page: per_page,
1577            offset_start: 1,
1578            current_lang: check_cookie_name("wp-wpml_current_language"),
1579        },
1580        dataType: 'JSON',
1581        type: 'POST',
1582        success: function (result) {
1583            console.log(result);
1584            if (loading_type == "pager") {
1585                post_section.find(".row-card").html('<div class="loader-inner ball-pulse" style="display:block;"></div>');
1586            }
1587            var years = [];
1588            for (var item of result.data) {
1589                var clone = $(template_div).clone();
1590
1591                $(clone).find('.img-card').attr({ "src": item.thumbnail_url });
1592                $(clone).find('.txt-title').html(item.title);
1593                $(clone).find('.txt-year-season .txt-num').html(item.year);
1594                $(clone).find('.txt-year-season .txt-page').html(item.season);
1595                $(clone).find('.txt-year-season').addClass("theme-" + item.season);
1596
1597                if (item.hide_preview) {
1598                    $(clone).find('.txt-preview').remove();
1599                } else {
1600                    $(clone).find('.txt-preview').attr("href", item.targetUrl);
1601                }
1602
1603
1604                if (item.pdf_file != "" && item.pdf_file != null && item.pdf_file != false) {
1605                    $(clone).find('.txt-download.logged_in').attr("href", item.pdf_file);
1606                } else {
1607                    $(clone).find('.txt-download').remove();
1608                }
1609
1610                post_section.find(".row-card").append(clone);
1611            }
1612
1613            if (current_page == 1 && result.data.length < 1) {
1614                post_section.find(".row-card").append("<h3 class='not_find_message'>Magazine Not Found</h3>");
1615            }
1616
1617            post_section.attr("data-page", result.current_page);
1618            if (loading_type == "load_more" && parseInt(result.current_page) != parseInt(result.max_num_pages) && parseInt(result.max_num_pages) != 0) {
1619                post_section.find(".load_more_btn").show();
1620            } else {
1621                post_section.find(".load_more_btn").hide();
1622            }
1623
1624            if (loading_type == "pager" && parseInt(result.max_num_pages) != 1) {
1625                post_section.find(".post_pagination").html(result.pagination_html);
1626                post_section.find(".post_pagination").css("display", "flex");
1627            } else {
1628                post_section.find(".post_pagination").hide();
1629            }
1630
1631            post_section.find(".loader-inner").hide();
1632
1633        },
1634        error: function (result) {
1635            console.log('error from admin-ajax.js', result);
1636            post_section.find(".loader-inner").hide();
1637        }
1638    });
1639}
1640
1641
1642function get_gallery_list(post_section, current_page = 1) {
1643    var ajaxurl = post_section.attr("data-ajaxurl");
1644    var loading_type = post_section.attr("data-loading");
1645    var per_page = post_section.attr("data-perpage");
1646    var post_type = post_section.attr("data-type");
1647    var template_div = post_section.find(".template_div").html();
1648    post_section.find(".loader-inner").show();
1649
1650    var filter_type = post_section.find(".select-filter.filter_type").val();
1651    var filter_date = post_section.find(".select-filter.filter_date").val();
1652
1653    jQuery.ajax({
1654        url: ajaxurl,
1655        data: {
1656            action: 'get_gallery_list',
1657            current_page: current_page,
1658            loading_type: loading_type,
1659            per_page: per_page,
1660            filter_type: filter_type,
1661            filter_date: filter_date,
1662            current_lang: check_cookie_name("wp-wpml_current_language"),
1663        },
1664        dataType: 'JSON',
1665        type: 'POST',
1666        success: function (result) {
1667            console.log(result);
1668
1669            if (loading_type == "pager" || current_page == 1) {
1670                post_section.find(".row-card").html("");
1671            }
1672            for (var item of result.data) {
1673                var clone = $(template_div).clone();
1674                $(clone).find('.txt-brand').html(item.title);
1675                $(clone).find('.txt-category').html(item.post_type);
1676                $(clone).find('.txt-status').html(item.publish_date);
1677                $(clone).find('.img-card').css({ "background-image": "url(" + item.thumbnail_url + ")" });
1678                $(clone).find('.img-card-href').attr("href", item.thumbnail_url).attr("data-gallery", "gallery_list_" + item.id);
1679                for (var image of item.gallery) {
1680                    $(clone).find('.gallery_list').append('<div data-toggle="lightbox" data-gallery="gallery_list_' + item.id + '" data-remote="' + image 
1680+ '"></div>');
1681                }
1682
1683                post_section.find(".row-card").append(clone);
1684            }
1685
1686            if (current_page == 1 && result.data.length < 1) {
1687                post_section.find(".row-card").append("<h3 class='not_find_message'>Image Not Found</h3>");
1688            }
1689
1690            post_section.attr("data-page", result.current_page);
1691            if (loading_type == "load_more" && parseInt(result.current_page) != parseInt(result.max_num_pages) && parseInt(result.max_num_pages) != 0) {
1692                post_section.find(".load_more_btn").show();
1693            } else {
1694                post_section.find(".load_more_btn").hide();
1695            }
1696
1697            if (loading_type == "pager" && parseInt(result.max_num_pages) != 1) {
1698                post_section.find(".post_pagination").html(result.pagination_html);
1699                post_section.find(".post_pagination").css("display", "flex");
1700            } else {
1701                post_section.find(".post_pagination").hide();
1702            }
1703
1704            post_section.find(".loader-inner").hide();
1705
1706        },
1707        error: function (result) {
1708            console.log('error from admin-ajax.js', result);
1709            post_section.find(".loader-inner").hide();
1710        }
1711    });
1712
1713}
1714
1715
1716
1717function check_cookie_name(name) {
1718    var match = document.cookie.match(new RegExp('(^| )' + name + '=([^;]+)'));
1719    if (match) {
1720        return match[2];
1721    } else {
1722        return "";
1723    }
1724}
1725
1726
1727$(document).on('click.lity', '[data-lity]', '[data-lity=""]', function () {
1728    if (window.history.replaceState) {
1729        var popup_id = $(this).attr("href");
1730        popup_id = popup_id.replace(popup_id.charAt(0), "");
1731        var ori_url = window.location.href;
1732        var url_ary = ori_url.split("?");
1733        var nextURL = url_ary[0] + '?popup=' + popup_id;
1734        var nextTitle = document.title + ' - Popup';
1735        var nextState = { additionalInformation: '' };
1736        window.history.replaceState(nextState, nextTitle, nextURL);
1737    }
1738});
1739
1740$(document).on('lity:close', function (event, instance) {
1741    var ori_url = window.location.href;
1742    var url_ary = ori_url.split("?");
1743    var nextURL = url_ary[0];
1744    var nextTitle = document.title;
1745    var nextState = { additionalInformation: '' };
1746    window.history.replaceState(nextState, nextTitle, nextURL);
1747});
1748
1749
1750
1751function get_related_events(event_section) {
1752    var ajaxurl = event_section.attr("data-ajaxurl");
1753    var event_type = "upcoming";
1754    var per_page = event_section.attr("data-perpage");
1755    var template_div = event_section.find(".template_div").html();
1756    var postId = event_section.attr("data-post");
1757    event_section.find(".loader-inner").show();
1758    jQuery.ajax({
1759        url: ajaxurl,
1760        data: {
1761            action: 'get_event_list',
1762            isPastEvent: event_type,
1763            current_page: 1,
1764            per_page: per_page,
1765            event_id: postId,
1766            current_lang: check_cookie_name("wp-wpml_current_language"),
1767        },
1768        dataType: 'JSON',
1769        type: 'POST',
1770        success: function (result) {
1771            console.log(result);
1772
1773            event_section.find(".row-card").html("");
1774
1775
1776            if (result.data.length > 0) {
1777                for (var item of result.data) {
1778                    var clone = $(template_div).clone();
1779                    $(clone).find('.img-event').css({ "background-image": "url(" + item.thumbnail_url + ")" });
1780                    $(clone).find('.txt-event-loc .txt').html(item.location_1);
1781                    $(clone).find('.txt-event-title').html(item.title);
1782
1783                    $(clone).find('.event-link').attr("href", item.targetUrl);
1784
1785                    var start_date = new Date(item.start_date);
1786                    $(clone).find('.start_datetime .txt-event-day').html(start_date.getDate());
1787                    $(clone).find('.start_datetime .txt-event-month').html(monthNames[start_date.getMonth()]);
1788                    $(clone).find('.start_datetime .txt-event-year').html(start_date.getFullYear());
1789
1790                    if (item.start_date == item.end_date) {
1791                        $(clone).find('.showDate').hide();
1792                        $(clone).find('.end_datetime .start_time .txt-event-num').html(item.start_time);
1793                        $(clone).find('.end_datetime .start_time .txt-event-ampm').html(item.start_time_ap);
1794                        $(clone).find('.end_datetime .end_time .txt-event-num').html(item.end_time);
1795                        $(clone).find('.end_datetime .end_time .txt-event-ampm').html(item.end_time_ap);
1796                    } else {
1797                        $(clone).find('.showTime').hide();
1798                        var end_date = new Date(item.end_date);
1799                        $(clone).find('.end_datetime .txt-event-day').html(end_date.getDate());
1800                        $(clone).find('.end_datetime .txt-event-month').html(monthNames[end_date.getMonth()]);
1801                        $(clone).find('.end_datetime .txt-event-year').html(end_date.getFullYear());
1802                    }
1803
1804                    event_section.find(".swiper-wrapper").append(clone);
1805                }
1806                init_slider();
1807            } else {
1808                event_section.hide();
1809            }
1810            event_section.find(".loader-inner").hide();
1811        },
1812        error: function (result) {
1813            console.log('error from admin-ajax.js', result);
1814            event_section.find(".loader-inner").hide();
1815        }
1816    })
1817}
1818
1819
1820
1821$(document).ready(function () {
1822    if ($(".mec-custom-nice-select[name='book[date]']").length > 0) {
1823        $(".mec-custom-nice-select[name='book[date]']").parents(".mec-book-first").hide();
1824        var date_time = [];
1825        $(".mec-custom-nice-select[name='book[date]'] option").each(function () {
1826            var optionEle = $(this);
1827            var option_ary = optionEle.val().split(':');
1828            var startDate = timestamp_to_date(option_ary[0], 'date');
1829            var startTime = timestamp_to_date(option_ary[0], 'time');
1830
1831            var endDate = timestamp_to_date(option_ary[1], 'date');
1832            var endTime = timestamp_to_date(option_ary[1], 'time');
1833
1834            if (date_time.filter(function (item) { return item.startDate == startDate }).length < 1) {
1835                var item = {};
1836                item.startDate = startDate;
1837                item.times = [];
1838                if (startDate == endDate)
1839                    var optionLabel = startTime + " - " + endTime;
1840                else
1841                    var optionLabel = startDate + " " + startTime + " - " + endDate + " " + endTime;
1842
1843                item.times.push({
1844                    optionLabel: optionLabel,
1845                    optionVal: optionEle.val()
1846                });
1847                date_time.push(item);
1848            } else {
1849                date_time.filter(function (item) {
1850                    if (item.startDate == startDate) {
1851                        if (startDate == endDate)
1852                            var optionLabel = startTime + " - " + endTime;
1853                        else
1854                            var optionLabel = startDate + " " + startTime + " - " + endDate + " " + endTime;
1855
1856                        item.times.push({
1857                            optionLabel: optionLabel,
1858                            optionVal: optionEle.val()
1859                        });
1860                    }
1861                });
1862            }
1863        });
1864        console.log(date_time);
1865
1866        $('<div class="mec-book-first custom_date"><label>Date: </label><select class="custom_date_select"></select></div>').insertBefore(".b-popup-booking .mec-book-first");
1867        jQuery.each(date_time, function (i, val) {
1868            $(".custom_date .custom_date_select").append($('<option>', {
1869                value: val.startDate,
1870                text: val.startDate
1871            }));
1872        });
1873        $(".custom_date .custom_date_select").selectric();
1874        $(".custom_date .selectric-wrapper").addClass("selectric-mec-custom-nice-select");
1875
1876        $('<div class="mec-book-first custom_time"><label>Time: </label><select class="custom_time_select"></select></div>').insertAfter(".b-popup-booking .mec-book-first.custom_date");
1877        jQuery.each(date_time, function (i, val) {
1878            jQuery.each(val.times, function (i, time) {
1879                $(".custom_time .custom_time_select").append('<option value="' + time.optionVal + '" data-date="' + val.startDate + '">' + time.optionLabel + '</option>');
1880            });
1881        });
1882        $(".custom_time .custom_time_select").selectric();
1883
1884        $(".custom_date .custom_date_select").change();
1885    }
1886});
1887
1888
1889$(document).on("change", ".custom_date .custom_date_select", function () {
1890    $(".custom_time .custom_time_select option").prop("disabled", true);
1891    var selectDate = $(this).val();
1892    var firstItem = false;
1893    $(".custom_time .custom_time_select option[data-date='" + selectDate + "']").each(function () {
1894        var date_index = $(".custom_time .custom_time_select option").index($(this));
1895        $(this).prop("disabled", false);
1896        if (!firstItem) {
1897            $(".custom_time .custom_time_select").val($(this).val()).change();
1898            firstItem = true;
1899        }
1900    });
1901    $(".custom_time .custom_time_select").change().selectric('refresh');
1902});
1903
1904$(document).on("change", ".custom_time .custom_time_select", function () {
1905    var selectTime = $(this).val();
1906    $(".mec-custom-nice-select[name='book[date]']").val(selectTime).change().selectric('refresh');
1907});
1908
1909function timestamp_to_date(timestamp, type) {
1910    var startdate = new Date(eval(parseInt(timestamp) * 1000));
1911
1912    if (type == 'time') {
1913        var cHour = startdate.getHours();
1914        cHour = ("0" + cHour).slice(-2);
1915        var cMin = startdate.getMinutes();
1916        cMin = ("0" + cMin).slice(-2);
1917        var return_val = cHour + ":" + cMin;
1918    } else {
1919        var cDay = startdate.getDate();
1920        cDay = ("0" + cDay).slice(-2);
1921        var cMon = startdate.getMonth();
1922        cMon += 1;
1923        cMon = ("0" + cMon).slice(-2);
1924        var cYear = startdate.getFullYear();
1925        var return_val = cYear + "-" + cMon + "-" + cDay;
1926    }
1927
1928    return return_val;
1929}
1930
1931
1932$(document).ready(function () {
1933    if ($("#company_category").length > 0) {
1934        $("#company_category").change();
1935    }
1936});
1937
1938
1939$(document).on("change", ".mec-booking-shortcode form .mec-book-first > input[name='book[date]']", function () {
1940    var timestamp_datetime_ary = $(this).val().split(':');
1941    var startDate = timestamp_to_date(timestamp_datetime_ary[0], 'date');
1942    var startTime = timestamp_to_date(timestamp_datetime_ary[0], 'time');
1943    $(".mec-booking-shortcode form .mec-select-date-calendar-formatted-date").html(startDate + " - " + startTime);
1944});
1945
1946function stripHtml(str) {
1947    if ((str === null) || (str === ''))
1948        return false;
1949    else
1950        str = str.toString();
1951    return str.replace(/<[^>]*>/g, '').replace(/"/g, '');
1952}
1953
1954
1955$(document).on("click", ".brand_list_pop", function (e) {
1956    e.preventDefault();
1957    change_brand_ppl(this);
1958    return false;
1959});
1960
1961
1962function change_brand_ppl(ele) {
1963    var section_id = $(ele).parents("section").attr("data-section");
1964
1965    var txt_ppl = $(ele).parents(".brand-logo-item").attr("data-name");
1966    var txt_intro = $(ele).parents(".brand-logo-item").attr("data-intro");
1967    var img_ppl = $(ele).parents(".brand-logo-item").attr("data-image");
1968
1969    var facebook_url = $(ele).parents(".brand-logo-item").attr("data-facebook");
1970    var linkedin_url = $(ele).parents(".brand-logo-item").attr("data-linkedin");
1971    var twitter_url = $(ele).parents(".brand-logo-item").attr("data-twitter");
1972    var instagram_url = $(ele).parents(".brand-logo-item").attr("data-instagram");
1973    var website_url = $(ele).parents(".brand-logo-item").attr("data-website");
1974
1975
1976    $("#popup_brand_ppl").attr("data-section", section_id);
1977    console.log(img_ppl);
1978    $("#popup_brand_ppl .img-ppl").css('background-image', img_ppl);
1979    $("#popup_brand_ppl .txt-ppl").html(txt_ppl);
1980    $("#popup_brand_ppl .txt-intro").html(txt_intro);
1981
1982
1983
1984    $("#popup_brand_ppl .pop_facebook_url").attr("href", facebook_url);
1985    if (facebook_url != "") {
1986        $("#popup_brand_ppl .pop_facebook_url").parents("li").show();
1987    } else {
1988        $("#popup_brand_ppl .pop_facebook_url").parents("li").hide();
1989    }
1990
1991
1992    $("#popup_brand_ppl .pop_linkedin_url").attr("href", linkedin_url);
1993    if (linkedin_url != "") {
1994        $("#popup_brand_ppl .pop_linkedin_url").parents("li").show();
1995    } else {
1996        $("#popup_brand_ppl .pop_linkedin_url").parents("li").hide();
1997    }
1998
1999    $("#popup_brand_ppl .pop_twitter_url").attr("href", twitter_url);
2000    if (twitter_url != "") {
2001        $("#popup_brand_ppl .pop_twitter_url").parents("li").show();
2002    } else {
2003        $("#popup_brand_ppl .pop_twitter_url").parents("li").hide();
2004    }
2005
2006
2007    $("#popup_brand_ppl .pop_instagram_url").attr("href", instagram_url);
2008    if (instagram_url != "") {
2009        $("#popup_brand_ppl .pop_instagram_url").parents("li").show();
2010    } else {
2011        $("#popup_brand_ppl .pop_instagram_url").parents("li").hide();
2012    }
2013
2014
2015    $("#popup_brand_ppl .pop_website_url").attr("href", website_url);
2016    if (website_url != "") {
2017        $("#popup_brand_ppl .pop_website_url").parents("li").show();
2018    } else {
2019        $("#popup_brand_ppl .pop_website_url").parents("li").hide();
2020    }
2021}
2022
2023$(document).on("click", ".artcle_pop", function (e) {
2024    e.preventDefault();
2025    change_artcle_ppl(this);
2026    return false;
2027});
2028
2029
2030function change_artcle_ppl(ele) {
2031    var section_id = $(ele).parents("section").attr("data-section");
2032
2033    var txt_ppl = $(ele).parents(".artcle-pop-item").attr("data-name");
2034    var txt_intro = $(ele).parents(".artcle-pop-item").attr("data-intro");
2035    var img_ppl = $(ele).parents(".artcle-pop-item").attr("data-image");
2036
2037    var facebook_url = $(ele).parents(".artcle-pop-item").attr("data-facebook");
2038    var linkedin_url = $(ele).parents(".artcle-pop-item").attr("data-linkedin");
2039    var twitter_url = $(ele).parents(".artcle-pop-item").attr("data-twitter");
2040    var instagram_url = $(ele).parents(".artcle-pop-item").attr("data-instagram");
2041    var website_url = $(ele).parents(".artcle-pop-item").attr("data-website");
2042
2043
2044    $("#popup_artcle_ppl").attr("data-section", section_id);
2045    console.log(img_ppl);
2046    $("#popup_artcle_ppl .img-ppl").css('background-image', img_ppl);
2047    $("#popup_artcle_ppl .txt-ppl").html(txt_ppl);
2048    $("#popup_artcle_ppl .txt-intro").html(txt_intro);
2049
2050
2051
2052    $("#popup_artcle_ppl .pop_facebook_url").attr("href", facebook_url);
2053    if (facebook_url != "") {
2054        $("#popup_artcle_ppl .pop_facebook_url").parents("li").show();
2055    } else {
2056        $("#popup_artcle_ppl .pop_facebook_url").parents("li").hide();
2057    }
2058
2059
2060    $("#popup_artcle_ppl .pop_linkedin_url").attr("href", linkedin_url);
2061    if (linkedin_url != "") {
2062        $("#popup_artcle_ppl .pop_linkedin_url").parents("li").show();
2063    } else {
2064        $("#popup_artcle_ppl .pop_linkedin_url").parents("li").hide();
2065    }
2066
2067    $("#popup_artcle_ppl .pop_twitter_url").attr("href", twitter_url);
2068    if (twitter_url != "") {
2069        $("#popup_artcle_ppl .pop_twitter_url").parents("li").show();
2070    } else {
2071        $("#popup_artcle_ppl .pop_twitter_url").parents("li").hide();
2072    }
2073
2074
2075    $("#popup_artcle_ppl .pop_instagram_url").attr("href", instagram_url);
2076    if (instagram_url != "") {
2077        $("#popup_artcle_ppl .pop_instagram_url").parents("li").show();
2078    } else {
2079        $("#popup_artcle_ppl .pop_instagram_url").parents("li").hide();
2080    }
2081
2082
2083    $("#popup_artcle_ppl .pop_website_url").attr("href", website_url);
2084    if (website_url != "") {
2085        $("#popup_artcle_ppl .pop_website_url").parents("li").show();
2086    } else {
2087        $("#popup_artcle_ppl .pop_website_url").parents("li").hide();
2088    }
2089} 
2090
2091
2092
2093
2094
2095$(document).ready(function () {
2096    const targetNode = document.body;
2097
2098    const config = { childList: true, subtree: true };
2099
2100    const observer = new MutationObserver((mutationsList) => {
2101        for (const mutation of mutationsList) {
2102            const link = document.querySelector('.mec-book-reg-field-agreement a');
2103            if (link) {
2104                const lang = document.documentElement.lang;
2105
2106                const link = document.querySelector('.mec-book-reg-field-agreement a');
2107
2108                if (link) {
2109                    if (lang === 'tc') {
2110                        link.textContent = '個人資料收集聲明';
2111                    } else if (lang === 'sc') {
2112                        link.textContent = '个人资料收集声明';
2113                    }
2114                }
2115                observer.disconnect();
2116                break;
2117            }
2118        }
2119    });
2120    observer.observe(targetNode, config);
2121
2122     $(document).on("click", ".b-card-lab", function () {
2123        $('.txt-with-ico .txt').toggleClass('clamp');
2124        $('.txt-with-ico-b').toggleClass('no-show');
2125        if($('.b-card-lab .txt-with-ico').hasClass('no-show')){
2126            $('.card-img').show();
2127        }else{
2128            $('.card-img').hide();
2129        }
2130        //$('.card-img').addClass('no-expend');
2131       // $('.card-img.no-expend').hide();
2132    });
2133
2134    if($('.s-default').hasClass('s-event-detail')){
2135        $(document).ajaxComplete(function() {
2136            var lang = $('html').attr('lang');
2137            if(lang == 'en'){
2138                var txt ="By submitting this form, I agree to Nan Fung Group's use of my personal data for direct marketing purposes as set out in *<a href='https://www.themillsfabrica.com/pics/'>Personal Information Collection Statement</a>*.";
2139            }else if(lang == 'tc'){
2140                var txt = '提交此表格,即表示本人同意南豐集團按 *<a href="https://www.themillsfabrica.com/tc/pics/">個人資料收集聲明</a>* 使用本人的個人資料作直接促銷用途。';
2141            }else{
2142                var txt = '提交此表格,即表示本人同意南丰集团按 *<a href="https://www.themillsfabrica.com/sc/pics/">个人资料收集声明</a>* 使用本人的个人资料作直接促销用途。';
2143            }
2144            $('.mec-book-reg-field-agreement .wbmec-mandatory').after(txt);
2145        });
2146    }
2147    
2148});
2149
2150

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.