PageSourceSearch

https://www.toyota.co.th/custom/js/common.js

js toyota.co.th collected 2026-10-02 07:41:54 UTC 16,809 bytes, 436 lines download raw bytes

1function refreshCommon() {
2    function reloadSlide() {
3        $('.slide__car .frame').addClass('reload');
4    }
5
6    function resetNavMain() {
7        $('#header').removeClass('show-nav show-subnav');
8        $('#header #nav__main .detail').removeClass('resize');
9        $('#header #nav__main .has-info').removeClass('active');
10        $('#header #nav__main .box__link').removeClass('hidden');
11        $('#header #nav__main [class^="box__detail"]').removeClass('show');
12    }
13
14    function resetNavSub() {
15        $('#header #nav__main .box__link').removeClass('hidden');
16        $('#header #nav__main [class^="box__detail"]').removeClass('show');
17        $('#header #nav__main .has-info').removeClass('active');
18    }
19
20    $(function () {
21        // var $frame  = $('.slide__car .frame');
22        // var $slidee = $frame.children('ul').eq(0);
23        // var $wrap   = $frame.parent();
24
25        // $frame.sly({
26        //     horizontal: 1,
27        //     itemNav: 'basic',
28        //     smart: 1,
29        //     activateOn: 'click',
30        //     mouseDragging: 1,
31        //     touchDragging: 1,
32        //     releaseSwing: 1,
33        //     startAt: 0,
34        //     scrollBar: $wrap.find('.scrollbar'),
35        //     pagesBar: $wrap.find('.pages'),
36        //     activatePageOn: 'click',
37        //     speed: 300,
38        //     elasticBounds: 1,
39        //     easing: 'easeOutExpo',
40        //     dragHandle: 1,
41        //     dynamicHandle: 1,
42        //     clickBar: 1,
43        //     scrollSource: false
44        // });
45
46        // setTimeout(function(){
47        //     reloadSlide();
48        // }, 2000);
49
50        $('#header #nav__main .toggle').on('click', function () {
51            $('#header').addClass('show-nav');
52        });
53
54        $('#header #nav__main .detail > .btn-close, #header #nav__main > .bg').on('click', function () {
55            resetNavMain();
56        });
57
58        $('#header .link-search').on('click', function () {
59            $('.popup__search').show();
60            $('#header').removeClass('show-nav show-subnav');
61        });
62
63        $('#header .link-buy').on('click', function () {
64            $('#header').addClass('show-nav');
65            $('#nav__main #nav-buy a').click();
66        });
67
68        $('.popup__search .btn-close, .popup__search .bg').on('click', function () {
69            $('.popup__search').hide();
70        });
71
72        // $('.box__shopping-tool .toggle').on('click', function(){
73        //     $('.box__shopping-tool').toggleClass('hide');
74        //     $('.box__shopping-tool .box__quick-link').removeClass('show');
75        //     $('.bg-shopping-tool').fadeOut();
76        // });
77
78        // $('.box__shopping-tool .quick-link').on('click', function(){
79        //     $('.box__shopping-tool .box__quick-link').toggleClass('show');
80        //     $('.bg-shopping-tool').fadeToggle();
81        // });
82
83        // $('.box__shopping-tool .btn-close, .bg-shopping-tool').on('click', function(){
84        //     $('.box__shopping-tool .box__quick-link').removeClass('show');
85        //     $('.bg-shopping-tool').fadeToggle();
86        // });
87
88        // $('.list__filter .btn-link').on('click', function(){
89        //     $(this).toggleClass('not-selected');
90        // });
91
92        $('#header #nav__main .box__detail .btn-back').on('click', function () {
93            resetNavSub();
94        });
95
96        $('#header #nav__main .has-info').on('click', function () {
97            $('#header #nav__main .detail').addClass('resize');
98            $('#header #nav__main .has-info').removeClass('active');
99            if ($(window).width() <= 991) {
100                $('#header #nav__main .box__link').addClass('hidden');
101            }
102            $(this).addClass('active');
103            $('#header #nav__main [class^="box__detail"]').removeClass('show');
104        });
105
106        if ($(window).width() > 960) {
107            $('.box__shopping-tool').css({ marginTop: $('.box__shopping-tool .list__info').height() * (-0.5) });
108            $('.box__shopping-tool .list__info .link').hover(function () {
109                $(this).parent().addClass('active');
110            }, function () {
111                $(this).parent().removeClass('active');
112            });
113
114            setTimeout(function () {
115                $('.box__detail-model .box__overflow').css({ height: $(window).height() - ($('#header .box__language').innerHeight() * 2.5) - $('.box__detail-model .box__head').innerHeight() });
116            }, 300);
117        } else {
118            $('.nav__footer .head').on('click', function () {
119                if ($(this).parent().hasClass('show')) {
120                    $(this).parent().removeClass('show');
121                } else {
122                    $('.nav__footer .box').removeClass('show');
123                    $(this).parent().addClass('show');
124                }
125            });
126
127            setTimeout(function () {
128                $('.box__detail-model .box__overflow').css({ height: $(window).height() - $('.box__detail-model .box__head').innerHeight() });
129            }, 300);
130        }
131
132        var scroll = $(window).scrollTop();
133        var window_offset = $(window).height();
134
135        if (scroll > window_offset) {
136            $('#header').addClass('swap-color');
137        } else if (scroll < window_offset) {
138            $('#header').removeClass('swap-color');
139        }
140
141        $('.popup__info .btn-close').on('click', function () {
142            $(this).parent().parent().toggleClass('show');
143        });
144
145        $('.popup__info .bg').on('click', function () {
146            $(this).parent().toggleClass('show');
147        });
148
149        // $('.box__nav .box__text, .bg__nav').on('click', function(){
150        //     $('.box__nav .box__text').toggleClass('show');
151        //     $('.box__nav .box__sub').toggle();
152        //     $('.bg__nav').toggle();
153        // });
154
155        $('#select-multiple-detail-model').on('click', function () {
156            $('#box__select-detail-model').addClass('show');
157            $('#box__select-detail-model .bg').fadeIn();
158        });
159
160        $('#box__select-detail-model .bg, #box__select-detail-model .btn-close').on('click', function () {
161            $('#box__select-detail-model').removeClass('show');
162            $('#box__select-detail-model .bg').fadeOut();
163        });
164
165        $('#header .box__language .btn-switch-lang').on('click', function () {
166            resetNavMain();
167        })
168    });
169
170    $(window).scroll(function () {
171        var scroll = $(window).scrollTop();
172        var window_offset = $(window).height() / 1.3;
173
174        if (scroll > window_offset) {
175            $('#header').addClass('swap-color');
176        } else if (scroll < window_offset) {
177            $('#header').removeClass('swap-color');
178        }
179
180        if ($(window).width() > 960) {
181            setTimeout(function () {
182                $('.box__detail-model .box__overflow').css({ height: $(window).height() - ($('#header .box__language').innerHeight() * 2.5) - $('.box__detail-model .box__head').innerHeight() });
183            }, 300);
184        } else {
185            setTimeout(function () {
186                $('.box__detail-model .box__overflow').css({ height: $(window).height() - $('.box__detail-model .box__head').innerHeight() });
187            }, 300);
188        }
189    });
190
191    setTimeout(function () {
192        // ------------- from navmain.js ---------------
193        $('#header #nav__main .info-model').on('click', function () {
194            $('#header #nav__main .box__detail-model').addClass('show');
195
196            $('.box__detail-model .info').removeClass('show');
197            $('.detail-model-1').addClass('show');
198        });
199
200        $('#header #nav__main .info-aftersale').on('click', function () {
201            $('#header #nav__main .box__detail-aftersale').addClass('show');
202
203            $('.box__detail-aftersale .info').removeClass('show');
204            $('.detail-aftersale-1').addClass('show');
205        });
206
207        $('#header #nav__main .info-network').on('click', function () {
208            $('#header #nav__main .box__detail-network').addClass('show');
209
210            $('.box__detail-network .info').removeClass('show');
211            $('.detail-network-1').addClass('show');
212        });
213
214        $('#header #nav__main .info-group').on('click', function () {
215            $('#header #nav__main .box__detail-group').addClass('show');
216
217            $('.box__detail-group .info').removeClass('show');
218            $('.detail-group-1').addClass('show');
219        });
220
221        $('#header #nav__main .info-dealer').on('click', function () {
222            $('#header #nav__main .box__detail-dealer').addClass('show');
223
224            $('.box__detail-dealer .info').removeClass('show');
225            $('.detail-dealer-1').addClass('show');
226        });
227
228        $('#header #nav__main .info-aftersale .list li:nth-child(1) a').on('mouseover', function () {
229            $('.box__detail-aftersale .info').removeClass('show');
230            $('.detail-aftersale-1').addClass('show');
231        });
232
233        $('#header #nav__main .info-aftersale .list li:nth-child(2) a').on('mouseover', function () {
234            $('.box__detail-aftersale .info').removeClass('show');
235            $('.detail-aftersale-2').addClass('show');
236        });
237
238        $('#header #nav__main .info-aftersale .list li:nth-child(3) a').on('mouseover', function () {
239            $('.box__detail-aftersale .info').removeClass('show');
240            $('.detail-aftersale-3').addClass('show');
241        });
242
243        $('#header #nav__main .info-aftersale .list li:nth-child(4) a').on('mouseover', function () {
244            $('.box__detail-aftersale .info').removeClass('show');
245            $('.detail-aftersale-4').addClass('show');
246        });
247
248        $('#header #nav__main .info-aftersale .list li:nth-child(5) a').on('mouseover', function () {
249            $('.box__detail-aftersale .info').removeClass('show');
250            $('.detail-aftersale-5').addClass('show');
251        });
252
253        $('#header #nav__main .info-aftersale .list li:nth-child(6) a').on('mouseover', function () {
254            $('.box__detail-aftersale .info').removeClass('show');
255            $('.detail-aftersale-6').addClass('show');
256        });
257
258        $('#header #nav__main .info-aftersale .list li:nth-child(7) a').on('mouseover', function () {
259            $('.box__detail-aftersale .info').removeClass('show');
260            $('.detail-aftersale-7').addClass('show');
261        });
262
263        $('#header #nav__main .info-aftersale .list li:nth-child(8) a').on('mouseover', function () {
264            $('.box__detail-aftersale .info').removeClass('show');
265            $('.detail-aftersale-8').addClass('show');
266        });
267
268        $('#header #nav__main .info-network .list li:nth-child(1) a').on('mouseover', function () {
269            $('.box__detail-network .info').removeClass('show');
270            $('.detail-network-1').addClass('show');
271        });
272
273        $('#header #nav__main .info-network .list li:nth-child(2) a').on('mouseover', function () {
274            $('.box__detail-network .info').removeClass('show');
275            $('.detail-network-2').addClass('show');
276        });
277
278        $('#header #nav__main .info-network .list li:nth-child(3) a').on('mouseover', function () {
279            $('.box__detail-network .info').removeClass('show');
280            $('.detail-network-3').addClass('show');
281        });
282
283        $('#header #nav__main .info-network .list li:nth-child(4) a').on('mouseover', function () {
284            $('.box__detail-network .info').removeClass('show');
285            $('.detail-network-4').addClass('show');
286        });
287
288        $('#header #nav__main .info-network .list li:nth-child(5) a').on('mouseover', function () {
289            $('.box__detail-network .info').removeClass('show');
290            $('.detail-network-5').addClass('show');
291        });
292
293        $('#header #nav__main .info-network .list li:nth-child(6) a').on('mouseover', function () {
294            $('.box__detail-network .info').removeClass('show');
295            $('.detail-network-6').addClass('show');
296        });
297
298        $('#header #nav__main .info-group .list li:nth-child(1) a').on('mouseover', function () {
299            $('.box__detail-group .info').removeClass('show');
300            $('.detail-group-1').addClass('show');
301        });
302
303        $('#header #nav__main .info-group .list li:nth-child(2) a').on('mouseover', function () {
304            $('.box__detail-group .info').removeClass('show');
305            $('.detail-group-2').addClass('show');
306        });
307
308        $('#header #nav__main .info-group .list li:nth-child(3) a').on('mouseover', function () {
309            $('.box__detail-group .info').removeClass('show');
310            $('.detail-group-3').addClass('show');
311        });
312
313        $('#header #nav__main .info-group .list li:nth-child(4) a').on('mouseover', function () {
314            $('.box__detail-group .info').removeClass('show');
315            $('.detail-group-4').addClass('show');
316        });
317
318        $('#header #nav__main .info-group .list li:nth-child(5) a').on('mouseover', function () {
319            $('.box__detail-group .info').removeClass('show');
320            $('.detail-group-5').addClass('show');
321        });
322
323        $('#header #nav__main .info-group .list li:nth-child(6) a').on('mouseover', function () {
324            $('.box__detail-group .info').removeClass('show');
325            $('.detail-group-6').addClass('show');
326        });
327
328        $('#price-range-submit').hide();
329
330        // let min_price_init = 400000;
331        // let max_price_init = 5000000;
332
333        // setTimeout(function() {
334        //     min_price_init = parseInt($("#min_price_int").val());
335        //     max_price_init = parseInt($("#max_price_int").val());    
336        // }, 1000)
337
338        // $("#slider-range").slider({
339        //     range: true,
340        //     orientation: "horizontal",
341        //     min: min_price_init,
342        //     max: max_price_init,
343        //     values: [min_price_init, max_price_init],
344        //     step: 10000,
345
346        //     slide: function (event, ui) {
347        //       if (ui.values[0] == ui.values[1]) {
348        //           return false;
349        //       }
350
351        //       $("#min_price").val(ui.values[0]);
352        //       $("#max_price").val(ui.values[1]);
353        //     }
354        // });
355
356        // $("#min_price").val($("#slider-range").slider("values", 0));
357        // $("#max_price").val($("#slider-range").slider("values", 1));
358
359        // $("#slider-range,#price-range-submit").click(function () {
360        //     var min_price = $('#min_price').val();
361        //     var max_price = $('#max_price').val();
362
363        //     $("#searchResults").text("Here List of products will be shown which are cost between " + min_price  +" "+ "and" + " "+ max_price + ".");
364        // });
365
366        // $("#min_price,#max_price").on('change', function () {
367
368        //     $('#price-range-submit').show();
369
370        //     var min_price_range = parseInt($("#min_price").val());
371
372        //     var max_price_range = parseInt($("#max_price").val());
373
374        //     if (min_price_range > max_price_range) {
375        //       $('#max_price').val(min_price_range);
376        //     }
377
378        //     $("#slider-range").slider({
379        //       values: [min_price_range, max_price_range]
380        //     });
381
382        // });
383
384
385        // $("#min_price,#max_price").on("paste keyup", function () {                                        
386
387        //     $('#price-range-submit').show();
388
389        //     var min_price_range = parseInt($("#min_price").val());
390
391        //     var max_price_range = parseInt($("#max_price").val());
392
393        //     if(min_price_range == max_price_range){
394
395        //           max_price_range = min_price_range + 100;
396
397        //           $("#min_price").val(min_price_range);		
398        //           $("#max_price").val(max_price_range);
399        //     }
400
401        //     $("#slider-range").slider({
402        //       values: [min_price_range, max_price_range]
403        //     });
404
405        // });
406
407        // $('#min_price').on('change', function(){
408        //     console.log($(this).val())
409        // })
410    }, 300);
411}
412
413document.addEventListener('DOMContentLoaded', function () {
414    const closeButtons = document.querySelectorAll('.popup__info .btn-close');
415    closeButtons.forEach(btn => {
416        btn.addEventListener('click', function (e) {
417            e.preventDefault();
418
419            const popup = this.closest('.popup__info');
420            if (popup) {
421                popup.classList.remove('show');
422            }
423        });
424    });
425
426    const bgOverlays = document.querySelectorAll('.popup__info .bg');
427    bgOverlays.forEach(bg => {
428        bg.addEventListener('click', function () {
429
430            const popup = this.closest('.popup__info');
431            if (popup) {
432                popup.classList.remove('show');
433            }
434        });
435    });
436});

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.