PageSourceSearch

https://www.ake-eisenbahntouristik.de/wp-content/themes/truetheme/…/tt-search-box/includes/searchbox.js

js ake-eisenbahntouristik.de collected 2026-10-02 12:19:43 UTC 68,074 bytes, 1,686 lines download raw bytes

1(function ($) {
2    function calendar_view_step(el, direction) {
3        var active_element = el.parent().find(".view.active");
4        if (direction == 'next') {
5            var next_item = active_element.next(".view");
6            if (next_item.next(".view").length != 0) {
7                next_item.toggleClass('active')
8                active_element.toggleClass('active');
9            }
10        }
11        if (direction == 'prev') {
12            var prev_item = active_element.prev(".view");
13            if (prev_item.prev(".view").length != 0) {
14                prev_item.toggleClass('active')
15                active_element.toggleClass('active');
16            }
17        }
18    }
19
20    function set_daterange_based_on_duration(el) {
21
22        // remove old marked days
23        $(".calendar .day").removeClass("marked");
24
25        var date_from = parseInt($(el).attr('data-date'));
26        var max_duration = parseInt($('.search-box select[data-name=duration] option:selected').attr('data-duration-max'));
27        var min_duration = parseInt($('.search-box select[data-name=duration] option:selected').attr('data-duration-min'));
28
29        var date_to = date_from + max_duration;
30
31        // mark the days
32        $(".calendar .day").each(function () {
33            if (parseInt($(this).attr("data-date")) >= date_from && parseInt($(this).attr("data-date")) <= date_to) {
34                $(this).toggleClass('marked');
35            }
36        });
37
38        // set the date range
39        $(".search-box input[name=pm_date_from]").attr('value', date_from);
40        $(".search-box input[name=pm_date_to]").attr('value', date_to);
41        $(".search-box input[name=pm_duration_max]").attr('value', max_duration);
42        $(".search-box input[name=pm_duration_min]").attr('value', min_duration);
43        //console.log("max: " + max_duration);
44        // console.log("date_from: " + date_from);
45
46
47        var fromndate = $.datepicker.formatDate("dd.mm.", new Date(date_from * 1000));
48        var todate = $.datepicker.formatDate("dd.mm.y", new Date(date_to * 1000));
49
50
51        // set human readable dates
52        var date_hr = fromndate + " - " + todate;
53        //  console.log(date_hr);
54        var popover_fieldname = $(el).closest(".tt-popover").attr('name');
55        $(".search-box .popover-field[name='" + popover_fieldname + "'] > span").html(date_hr);
56
57    }
58
59    function set_departure_date(el) {
60
61        // remove old marked days
62        $(".calendar .day").removeClass("marked");
63
64        var date_from = parseInt($(el).attr('data-date'));
65        var date_to = date_from;
66
67        // mark the days
68        $(".calendar .day").each(function () {
69            if (parseInt($(this).attr("data-date")) == date_from) {
70                $(this).toggleClass('marked');
71            }
72        });
73
74        // set the date
75        $(".search-box input[name=pm_date_from]").attr('value', date_from);
76
77
78        // set the date humanreadable in the visible datebox
79        var fromdate = $.datepicker.formatDate("dd.mm.yy", new Date(date_from * 1000));
80        var popover_fieldname = $(el).closest(".tt-popover").attr('name');
81        $(".search-box .popover-field[name='" + popover_fieldname + "'] > span").html(fromdate);
82
83    }
84
85
86    function set_arrival_date(el) {
87
88
89        var date_to = parseInt($(el).attr('data-date'));
90
91        // mark the days
92        $(".calendar .day").each(function () {
93            if (parseInt($(this).attr("data-date")) == date_to) {
94                $(this).toggleClass('marked');
95            }
96        });
97
98        // set the date in the hidden input field
99        $(".search-box input[name=pm_date_to]").attr('value', date_to);
100
101        // set the date humanreadable in the visible datebox
102        var todate = $.datepicker.formatDate("dd.mm.yy", new Date(date_to * 1000));
103        var popover_fieldname = $(el).closest(".tt-popover").attr('name');
104        $(".search-box .popover-field[name='" + popover_fieldname + "'] > span").append(' - ' + todate);
105
106        // close the popover
107        toggle_box($(".search-box .popover-field[name='" + popover_fieldname + "']"));
108
109    }
110
111
112    /**
113     * sets the daterange, triggert by on click event below
114     * @param el
115     */
116    function set_date_range(el) {
117
118        var autosearch = $(el).closest('.calendar').attr('data-autosearch');
119        var can_auto_search = false
120
121        var date_from = $(".search-box input[name=pm_date_from]").attr('value');
122        var date_to = $(".search-box input[name=pm_date_to]").attr('value');
123
124        if (date_from !== undefined && date_from !== null && date_from.length > 0 && parseInt(el.attr("data-date")) < date_from) {
125            // if the selected to date is before the from date, set reset the from date
126            $(".search-box input[name=pm_date_to]").attr('value', '');
127            set_departure_date(el);
128        } else if (date_from !== undefined && date_from !== null && date_from.length > 0 && date_to !== null && date_to !== undefined && date_to.length > 0) {
129            // if both dates are set, reset the range
130            $(".search-box input[name=pm_date_to]").attr('value', '');
131            set_departure_date(el);
132        } else if (date_from !== undefined && date_from !== null && date_from.length == 0 && date_to !== null && date_to !== undefined && date_to.length == 0) {
133            // if no date is set, set the departure
134            set_departure_date(el);
135        } else if (date_from !== undefined && date_from !== null && date_from.length > 0 && date_to !== null && date_to !== undefined && date_to.length == 0) {
136            // if  the from date is set, but not the to date
137            set_arrival_date(el);
138            can_auto_search = true;
139        } else {
140            set_departure_date(el);
141        }
142
143        var date_from = $(".search-box input[name=pm_date_from]").attr('value');
144        var date_to = $(".search-box input[name=pm_date_to]").attr('value');
145
146        if (date_from !== undefined && date_from !== null && date_from.length > 0 && date_to !== null && date_to !== undefined && date_to.length > 0) {
147            // mark the days
148            $(".calendar .day").each(function () {
149                if (parseInt($(this).attr("data-date")) >= date_from && parseInt($(this).attr("data-date")) <= date_to) {
150                    $(this).addClass('marked');
151                }
152            });
153        }
154
155
156        if(autosearch == 1 && can_auto_search === true){
157            $(el).closest('form').submit();
158        }
159
160
161    }
162
163
164    function set_right_date() {
165
166        var date_from = $(".search-box input[name=pm_date_from]").attr('value');
167        var date_to = $(".search-box input[name=pm_date_to]").attr('value');
168
169        // only the departure date is selected
170        if (date_from !== undefined && date_from !== null && date_from.length > 0 && !date_to) {
171            $(".calendar .day").each(function () {
172                if (parseInt($(this).attr("data-date")) == date_from) {
173                    $(this).toggleClass('marked');
174                }
175            });
176        }
177
178        if (date_from !== undefined && date_from !== null && date_from.length > 0 && date_to) {
179            $(".calendar .day").each(function () {
180                if (parseInt($(this).attr("data-date")) >= date_from && parseInt($(this).attr("data-date")) <= date_to) {
181                    $(this).addClass('marked');
182                }
183            });
184        }
185    }
186
187    function set_touristic_persons(el) {
188
189        var popover_fieldname = $(el).closest(".tt-popover[data-type=touristic_pax]").attr('name');
190        var popover_box = $(el).closest(".tt-popover[data-type=touristic_pax]");
191
192
193        var persons = $(el).closest(".controls").find("select[name=pm_touristic_pax] option:selected").attr('value');
194        var childs = $(el).closest(".controls").find("select[name=pm_touristic_childs] option:selected").attr('value');
195
196        var str = persons + " Erwachsene";
197        if (parseInt(childs) > 0) {
198            str += ", " + childs + " Kinder";
199        }
200        $(".search-box .popover-field[name='" + popover_fieldname + "'] > span").html(str);
201    }
202
203
204
205    function set_price_range(el) {
206
207        var popover_fieldname = $(el).closest(".tt-popover[data-type=touristic_price]").attr('name');
208
209        var price_min = $(el).closest(".controls").find("input[name=pm_price_min]").attr('data-humanreadable');
210        var price_max = $(el).closest(".controls").find("input[name=pm_price_max]").attr('data-humanreadable');
211
212        var str = price_min + " bis " + price_max;
213
214        $(".search-box .popover-field[name='" + popover_fieldname + "'] > span").html(str);
215    }
216
217
218    function set_duration_range(el){
219
220        var popover_fieldname = $(el).closest(".touristic_duration").attr('name');
221
222        var duration_min = $(el).closest(".controls").find("input[name=pm_duration_min]").attr('data-humanreadable');
223        var duration_max = $(el).closest(".controls").find("input[name=pm_duration_max]").attr('data-humanreadable');
224
225        var str = parseInt(duration_min) + " - " +parseInt(duration_max) + " Tage";
226
227        $(".search-box .popover-field[name='" + popover_fieldname + "'] > span").html(str);
228    }
229
230
231
232    /**
233     * display a waiting animation on search
234     */
235    function toggle_result_list(){
236
237        var waiting_animation = $(".search-is-running");
238        waiting_animation.toggle();
239
240        console.log(waiting_animation);
241        if(waiting_animation.data('scroll-to-here') == true){
242
243            var offset = parseInt(waiting_animation.data('scroll-to-offset')) + 200;
244            //var position = waiting_animation.position();
245            var position = waiting_animation.offset();
246
247            $('html,body').animate({
248                scrollTop: position.top - offset
249            }, 500);
250
251
252        }else{
253
254            $('html,body').animate({
255                scrollTop: 0
256            }, 500);
257        }
258
259        $(".part-of-result-list").toggle();
260
261    }
262
263    function init_result_list(){
264        $(".search-is-running").hide();
265        $(".part-of-result-list").show();
266    }
267
268    /**
269     * Trigger the Click Event if panel is not open
270     *  @param object oPanel
271     *  @return void
272     * */
273    function open_panel_heading(oPanel) {
274        //undefined or not in dom
275        if(typeof(oPanel) === "undefined" || !$(oPanel).length)
276            return;
277        //is open?
278        if($(oPanel).hasClass('in'))
279            return;
280        //prev is panel-heading?
281        if($(oPanel).prev().hasClass('panel-heading'))
282            $(oPanel).prev().click();
283    }
284    /**
285     * Check forbidden input types
286     *  @param object oInput
287     *  @return bool
288     * */
289    function is_not_forbidden_input(oInput) {
290        //undefined or not in the dom
291        if(typeof(oInput) === "undefined" || !$(oInput).length)
292            return false;
293        //Get the type
294        var cType = oInput.attr('type');
295        //undefined or empty
296        if(typeof(cType) === "undefined" || !cType.length)
297            return false;
298        //check for forbidden type
299        if(cType === "submit" || cType === "reset")
300            return false;
301        else
302            return true;
303    }
304    /**
305     * Check if input value is empty or not
306     *  @param object oInput
307     *  @return bool
308     * */
309    function is_input_selected(oInput) {
310        //undefined or not in the dom
311        if(typeof(oInput) === "undefined" || !$(oInput).length)
312            return false;
313        //Forbidden one?
314        if(!is_not_forbidden_input(oInput))
315            return false;
316        //get the type
317        var cType = $(oInput).attr('type');
318        //type undefined
319        if(typeof(cType) === "undefined" || !cType.length)
320            return false;
321        //checkbox or radio
322        if(cType === "checkbox" || cType === "radio")
323            return $(oInput).is(':checked');
324        //get the Value
325        var mValue = $(oInput).val();
326        //value empty
327        if(typeof(mValue) === "undefined" || !mValue.length)
328            return false;
329        //number
330        if(cType === "number") {
331            //Parse Value
332            var fValue = parseFloat(mValue.replace(',', '.'));
333            //NaN
334            if(isNaN(fValue))
335                return false;
336        }
337        //fallback
338        if(mValue.length)
339            return true;
340    }
341    /**
342     * Check if the selectbox is selected or not
343     *  @param object oSelect
344     *  @return bool
345     * */
346    function is_select_selected(oSelect) {
347        //undefined or not in dom
348        if(typeof(oSelect) === "undefined" || !$(oSelect).length)
349            return false;
350        //Get the value
351        var mValue = $(oSelect).val();
352        //undefined or empty
353        if(typeof(mValue) === "undefined" || !mValue.length)
354            return false;
355        //true
356        return true;
357    }
358    /**
359     * Check if the textarea is selected or not
360     *  @param object oTextarea
361     *  @return bool
362     * */
363    function is_textarea_selected(oTextarea) {
364        //undefined or not in the dom
365        if(typeof(oTextarea) === "undefined" || !$(oTextarea).length)
366            return false;
367        //Get the value
368        var mValue = $(oTextarea).val();
369        //undefined or empty
370        if(typeof(mValue) === "undefined" || !mValue.length)
371            return false;
372        //Success
373        return true;
374    }
375
376
377
378    /**
379     * Reopen the search-box-filter if any value is typed in or selcted
380     *  @return void
381     * */
382    function reopen_searchboxfilter() {
383        //search-box-filter?
384        if(!$('.search-box-filter').length)
385            return;
386        //contains inputs
387        if($('.search-box-filter input').length) {
388            //Analyse the inputs
389            $('.search-box-filter input').each(function(nIndex) {
390                //input is not
391                if(is_input_selected($(this))) {
392                    //Get the panel
393                    var oPanel = $(this).closest('.panel-collapse');
394                    //found
395                    if(oPanel.length)
396                        open_panel_heading(oPanel);
397                }
398            });
399        }
400        //contains select
401        if($('.search-box-filter select').length) {
402            //Analyse the selects
403            $('.search-box-filter select').each(function(nIndex) {
404                //value selected or not
405                if(is_select_selected($(this))) {
406                    //Get panel
407                    var oPanel = $(this).closest('.panel-collapse');
408                    //found
409                    if(oPanel.length)
410                        open_panel_heading(oPanel);
411                }
412            });
413        }
414        //contains textarea
415        if($('.search-box-filter textarea').length) {
416            //analyse the textarea
417            $('.search-box-filter textarea').each(function(nIndex) {
418                //value typed
419                if(is_textarea_selected($(this))) {
420                    //get the panle
421                    var oPanel = $(this).closest('.panel-collapse');
422                    //founded
423                    if(oPanel.length)
424                        open_panel_heading(oPanel);
425                }
426            });
427        }
428    }
429
430    $(document).ready(function () {
431
432        var isNewActionSet  =   false;
433        var defaultAction   =   '';
434        var selectedAllTreeElements =   [];
435
436        $(document).on('click', '*[data-ajax-reload="1"]', function(){
437            if ($(this).is(':checked'))
438            {
439                selectedAllTreeElements.push($(this).val());
440            }
441            else
442            {
443                selectedAllTreeElements.splice(selectedAllTreeElements.indexOf($(this).val), 1);
444            }
445
446            var code    =   $(this).data('code');
447            var imo     =   $(this).data('idMediaObject');
448
449            var parentIn    =   $(this).closest('.ajax-reload');
450
451            if (parentIn.data('landingpageFromField') != '' != '' && !isNewActionSet)
452            {
453                defaultAction   =   $(this).closest('form').attr('action');
454
455                switch (parentIn.data('landingpageFromField'))
456                {
457                    case 'code':
458
459                        if (code != '')
460                        {
461                            $(this).closest('form').attr('action', code);
462                            isNewActionSet  =   true;
463                        }
464
465                    break;
466                    case 'id':
467                    case 'id_media_object':
468
469                        if (imo != '')
470                        {
471                            $(this).closest('form').attr('action', imo);
472                            isNewActionSet  =   true;
473                        }
474
475                    break;
476                }
477            }
478
479            reloadAjaxNew($(this));
480
481            $(this).closest('form').find('.ajax-reload').each(function(index, item){
482                if ($(item).data('hash') !== parentIn.data('hash'))
483                {
484                    let parentReplace    =   $(item).closest('.ajax-reload-replace');
485
486                    if(parentReplace.find('input:checked').length > 0)
487                    {
488                        return false;
489                    }
490
491                    var r = $.post(FLBuilderLayoutConfig.paths.wpAjaxUrl, {
492                        action: 'tt_searchbox_ajax_reload_tree',
493
494                        field: $(item).data('field'),
495                        label: $(item).data('label'),
496                        placeholder: $(item).data('placeholder'),
497                        selectField: $(item).data('selectField'),
498                        settings: $(item).data('settings'),
499                        id_object_type: $(item).data('idObjectType'),
500                        selectedAllTreeElements: selectedAllTreeElements
501                    }
502                    ,
503                    function (data) {
504                        parentReplace.replaceWith(data.content);
505                        setSearchBoxAjaxNew();
506                    },'json');
507                }
508            });
509        });
510
511        $(document).on('click', '.categorytreelist', function(){
512            if (!$(this).hasClass('active'))
513            {
514                var co  =   $(this);
515                setTimeout(function(){
516                    co.closest('.input-row').find('.search_in')[0].focus();
517                }, 200);
518            }
519        });
520
521        $(document).on('click', '.searchfield_in .fa-times', function(){
522            $(this).closest('.searchfield_in').find('.search_in').val('').trigger('keyup')[0].focus();
523        });
524
525        $.each($('.searchfield_in .search_in'), function(){
526            if($(this).val() === '')
527            {
528                $(this).closest('.searchfield_in').find('.fa-times').hide();
529            }
530            else
531            {
532                $(this).closest('.searchfield_in').find('.fa-times').show();
533            }
534        });
535
536        $(document).on('keyup', '.searchfield_in .search_in', function(){
537            var search  =   $(this).val().toLowerCase();
538
539            if (search === '')
540            {
541                $(this).closest('.searchfield_in').find('.fa-times').hide();
542            }
543            else
544            {
545                $(this).closest('.searchfield_in').find('.fa-times').show();
546            }
547
548            var allShow =  [];
549
550            $.each($(this).closest('.tt-popover').find('input[name="pm_category-tree[]"]'), function(){
551                if (search === '')
552                {
553                    $(this).closest('li').show();
554                }
555                else
556                {
557                    if ($(this).attr('data-name').toLowerCase().indexOf(search) == -1)
558                    {
559                        $(this).closest('li').hide();
560                    }
561                    else
562                    {
563                        allShow.push($(this));
564                    }
565                }
566            });
567
568            if (allShow.length > 0)
569            {
570                $.each(allShow, function(){
571                    this.closest('li').find('li').show();
572                    this.parentsUntil('.search-box').show();
573                })
574            }
575        });
576
577
578
579        // Popover set selected tree values humanreadable in the popover field
580        function set_popover_field_value_checkbox_category_tree(el) {
581
582            var parentIn = $(el).closest('.tt-popover[data-type="categorytree"]').find('input[type="checkbox"]:checked');
583
584            var v = [];
585            parentIn.each(function(){
586                v.push($(this).attr('data-name'));
587            });
588
589            var str = v.join(', ');
590
591            if(str == ''){
592                str = $(el).closest('.input-row').find('.popover-field').attr('data-placeholder');
593            }
594
595            $(el).closest('.input-row').find('.popover-field span').html(str);
596        }
597
598        // Popover set selected tree values humanreadable in the popover field
599        function set_popover_field_value_landingpage(el) {
600
601            var str = $(el).closest('.tt-popover[data-type="landingpage"]').find('input[type="radio"]:checked').attr('data-name');
602
603            if(str == ''){
604                str = $(el).closest('.input-row').find('.popover-field').attr('data-placeholder');
605            }
606
607            $(el).closest('.input-row').find('.popover-field span').html(str);
608        }
609
610        function set_close_button(el) {
611            var div = $(el).parent();
612
613            if ($(el).html().trim() != div.attr('data-placeholder')  && $(el).html() !== '') {
614
615                div.find('i.fa-times').remove();
616                div.append('<i class="fa fa-times" style="right: 30px;"></i>').find('.fa-times').click(function () {
617
618                    $(this).closest('.panel-body').find('input[name="pm_date_from"]').attr('value', '');
619                    $(this).closest('.panel-body').find('input[name="pm_date_to"]').attr('value', '');
620
621
622                    if (div.hasClass('touristic_daterange'))
623                    {
624                        $(el).closest('form').submit();
625                        return;
626                    }
627
628                    var f;
629                    f = div.parent().find('input[type="checkbox"]:checked');
630                    f.removeAttr('checked');
631                    if(f.data('autosearch') == '1'){
632                        $(el).closest('form').submit();
633                    }
634
635
636                    f = div.parent().find('input[type="radio"]:checked');
637                    f.removeAttr('checked');
638                    if(f.data('autosearch') == '1'){
639                        $(el).closest('form').submit();
640                    }
641
642                    // reset sliders
643                    var name = div.attr('name');
644                    $('.tt-popover[name='+name+'] .noUi-target').each(function(){
645                        eval($(this).attr('id')).noUiSlider.reset();
646                    });
647
648                    // reset landingpage
649                    if(div.parent().find('div[data-type=landingpage]').length == 1){
650                        div.closest('form').attr('data-landingpage', '');
651                    }
652
653                    if ($(this).closest('.ajax-reload-replace').length > 0)
654                    {
655                        var form        =   $(this).closest('form');
656                        var parentIn    =   $($(this).closest('.ajax-reload-replace').find('.ajax-reload')[0]);
657
658                        selectedAllTreeElements =   [];
659
660                        $(this).closest('form').find('*[data-ajax-reload="1"]').each(function(index, item){
661                            if ($(this).is(':checked'))
662                            {
663                                selectedAllTreeElements.push($(this).val());
664                            }
665                        });
666
667                        reloadAjaxNew($(this));
668
669                        form.find('.ajax-reload').each(function(index, item){
670                            if ($(item).data('hash') !== parentIn.data('hash'))
671                            {
672                                let parentReplace    =   $(item).closest('.ajax-reload-replace');
673
674                                var r = $.post(FLBuilderLayoutConfig.paths.wpAjaxUrl, {
675                                    action: 'tt_searchbox_ajax_reload_tree',
676
677                                    field: $(item).data('field'),
678                                    label: $(item).data('label'),
679                                    placeholder: $(item).data('placeholder'),
680                                    selectField: $(item).data('selectField'),
681                                    settings: $(item).data('settings'),
682                                    id_object_type: $(item).data('idObjectType'),
683                                    selectedAllTreeElements: selectedAllTreeElements
684                                }
685                                ,
686                                function (data) {
687                                    parentReplace.replaceWith(data.content);
688                                    setSearchBoxAjaxNew();
689                                },'json');
690                            }
691                        });
692                    }
693
694                    $(el).parent().find('span').html(div.attr('data-placeholder')).parent().find('.fa-times').remove();
695
696                });
697            }
698        }
699
700
701        function reloadAjaxNew(searchBoxIn)
702        {
703            /*console.log(searchBoxIn);
704            var query_string = searchBoxIn.closest('form').serialize() // use only the current form
705            var ttsearchBoxIn = searchBoxIn.closest('.tt-search-box');
706
707            console.log();
708
709            searchBoxIn.css('opacity', '.4').css('pointer-events', 'none').css('cursor', 'wait');
710
711            $.post(siteUrl + '/wp-content/plugins/tt-plugin/tt-ajax.php', {
712                    action: 'tt_list_search_box_ajax',
713                    formdata: query_string,
714                    post_id: ttsearchBoxIn.attr('data-post-id'),
715                    node_id: ttsearchBoxIn.attr('data-node-id'),
716                    template_id: ttsearchBoxIn.attr('data-template-id'),
717                    language_code: (typeof language_code !== 'undefined') ? language_code : '',
718                    //settingsCode: settingsCode
719                    settingsCode: window["settingsCodeSearchbox" + ttsearchBoxIn.attr('data-post-id') + ttsearchBoxIn.attr('data-node-id') + ttsearchBoxIn.attr('data-template-id')+ttsearchBoxIn.attr('data-uniq-id')]
720                },
721                function (data) {
722                    var parentBox = searchBoxIn.closest('.fl-module-content');
723
724                    parentBox.html('');
725
726                    parentBox.append(data);
727
728                    setSearchBoxAjaxNew();
729                });*/
730            /*if(searchBoxIn.is(':checked'))
731            {
732                var ul  =   searchBoxIn.closest('li').find('ul');
733
734                ul.css('display', 'block');
735
736                ul.find('li input[type="checkbox"]').unbind('change').change(function(){
737                    console.log('Click');
738                    console.log($(this));
739                    //$(this).closest('ul').closest('li').find('input[data-id="'+$(this).attr('data-id-p
739arent')+'"]').prop('checked', false);
740                });
741            }
742            else
743            {
744                searchBoxIn.closest('li').find('ul').css('display', 'none');
745            }*/
746        }
747
748        function setCloseButtonForZip(el)
749        {
750            var parentIn    =   $(el).parent();
751
752            if($(el).val() == '')
753            {
754                $(el).css('padding-right', 'inherit');
755                parentIn.find('.fa-times').remove();
756            }
757            else
758            {
759                if(parentIn.find('.fa-times').length)
760                {
761                    return;
762                }
763
764                $(el).css('padding-right', '130px');
765
766                var marginRight =   105;
767
768                if (parentIn.find('.wrapper_pm_zip_range').length == 0)
769                {
770                    marginRight =   20;
771                    $(el).css('padding-right', '40px');
772                }
773
774                parentIn.append('<i class="fa fa-times" style="margin-right: '+marginRight+'px;"></i>').find('.fa-times').click(function(){
775                    $(this).parent().find('input').val('');
776                    $(this).remove();
777                });
778            }
779        }
780
781        function update_search_fields(field){
782
783
784            var field_type = field.closest('.tt-popover').attr('data-type')
785            var field_index = field.closest('.tt-popover').attr('data-field-index')
786            var id_tab = field.closest('.tab-pane').attr('data-tab-id');
787            var form = field.closest('form');
788
789
790            if(field_type == 'landingpage'){
791                var selected_landingpage_id = field.val();
792                var group = field.closest('.tt-popover').attr('data-group');
793                var level = parseInt(field.closest('.tt-popover').attr('data-level'));
794                var max_level = field.closest('.tt-popover').attr('data-max-level');
795                var id_post = form.find('input[name=post_id]').val();
796                var id_node = form.find('input[name=node_id]').val();
797                var id_template = form.find('input[name=template_id]').val();
798
799                if(level + 1 == max_level){
800                    return;
801                }
802
803
804                // the landingpage can have subsearchboxes, we have to refresh the landigpage group
805
806                // we have to refresh each landingpage that have a higher level as the current.
807                // the level + 1 box gets a conntent refresh
808                // on all other boxes we have to remove the content
809
810
811                var r = $.post(FLBuilderLayoutConfig.paths.wpAjaxUrl, {
812                        action: 'tt_get_page_childs',
813                        id_landingpage: selected_landingpage_id,
814                        id_post: id_post,
815                        id_node: id_node,
816                        id_template: id_template,
817                        id_tab: id_tab,
818                        level: level + 1,
819                        max_level: max_level,
820                        field_index: field_index
821                    }
822                    ,
823                    function (data) {
824
825                        // find the target field
826                        //form.find('div[data-group=' + group + '][data-level='+ (level + 1) +']').closest('.input-row').remove();
827
828                        field.closest('.input-row').next().remove();
829                        $(data.html).insertAfter(field.closest('.input-row'));
830                        //form.find('div[data-group=' + group + '][data-level='+ (level + 1) +']').closest('.input-row').replaceWith(data.html);
831                        //form.find('div[data-group=' + group + '][data-level='+ (level + 1) +']').closest('.input-row').replaceWith(data.html);
832                        // reset all higher levels
833
834
835                    },'json');
836
837            }
838
839
840
841
842        }
843
844        function setSearchBoxAjaxNew()
845        {
846
847            $('.search-box_toggle').stickyToggleContent();
848            // auto search on click
849            $('.search-box').find('ul li input[type="checkbox"], ul li input[type="radio"], .stars input[type="radio"]').unbind('change').change(function(){
850
851                if ($(this).data('quick-level-search') == 1)
852                {
853                    console.log('Quick level search');
854                    if($(this).is(':checked'))
855                    {
856                        $(this).closest('li').find('ul').css('display', 'block');
857
858                        console.log('Add hidden');
859                        $(this).closest('li').append('<input type="hidden" name="tree_parent_'+$(this).data('id')+'" value="'+$
859(this).data('id-parent')+'">');
860
861                        $('input[type="checkbox"][data-id-tree="'+$(this).data('id-tree')+'"][data-level="'+(parseInt($(this).data('level'))-1)+'"]').removeAttr('checked').prop('checked', false);
862                    }
863                    else
864                    {
865                        $(this).closest('li').find('ul').css('display', 'none');
866                        $(this).closest('li').find('input[name="tree_parent_'+$(this).data('id')+'"]').remove();
867
868                        $(this).closest('ul').closest('li').find('input[type="checkbox"][data-id-tree="'+$(this).data('id-tree')+'"][data-level="'+(parseInt($(this).data('level'))-1)+'"]').attr('checked', 'checked').prop('checked', true);
869                    }
870
871                    return false;
872                }
873
874                if($(this).data('autosearch') == 0 || $(this).data('autosearch') == '' || $(this).data('autosearch') == undefined){
875                    return false;
876                }
877
878                $(this).closest('li').find('input[data-id-parent="'+$(this).attr('data-id')+'"]').prop('checked', false);
879
880                if (parseInt($(this).data('ajax-handling')) > 0)
881                {
882                    if($(this).is(':checked'))
883                    {
884                        $('input[type="checkbox"][data-id-tree="'+$(this).data('id-tree')+'"][data-level="'+(parseInt($(this).data('level'))-1)+'"]').removeAttr('checked').prop('checked', false);
885                    }
886                    else
887                    {
888                        if($(this).closest('ul').find('input:checked').length == 0)
889                        {
890                            $(this).closest('ul').closest('li').find('input[type="checkbox"][data-id-tree="'+$(this).data('id-tree')+'"][data-level="'+(parseInt($(this).data('level'))-1)+'"]').attr('checked', 'checked').prop('checked', true);
891                        }
892                    }
893                }
894
895                $(this).closest('form').submit();
896                $('.tt-popover').hide();
897            });
898
899            //@Robbyn - deaktiviert, da dies immer alle Suchboxen öffnet. Auch diese die nicht geöffnet werden sollen
900            //reopen_searchboxfilter();
901
902            $('.search-box-filter input[name=tab-switch]').unbind('change').change(function(e){
903                e.preventDefault();
904                $(this).closest('.search-box-filter').find('form').hide();
905                $(this).closest('.search-box-filter').find('form.' + $(this).val()).show().submit();
906                $(this).closest('.search-box-filter').find('form .panel-collapse').collapse('show');
907            });
908
909
910            $('.search-box form').unbind('submit').submit(function(event){
911
912                event.preventDefault();
913                //console.log('Start search');
914
915                toggle_result_list();
916
917                var url = $(this).attr('action');
918
919                if($(this).attr('data-landingpage') != undefined && $(this).attr('data-landingpage') != ''){
920                    var url = $(this).attr('data-landingpage');
921                }
922
923                if($(this).attr('data-use-existing-result') == 1){
924                    var formdata = $('.pm-search').serialize(); // use all search forms on the page
925                }else{
926                    var formdata = $(this).serialize(); // use only the current form
927                }
928
929                // send the stuff by ajax, or by get
930                if($(this).attr('data-ajax') != undefined && $(this).attr('data-ajax') == 'true'){
931
932                    if (typeof ajax_loader !== 'undefined' && ajax_loader)
933                    {
934                        $.each($('.search-box'),
935                            function () {
936                                var searchBoxIn = $(this);
937                                var ttsearchBoxIn = searchBoxIn.closest('.tt-search-box');
938
939                                searchBoxIn.css('opacity', '.4').css('pointer-events', 'none').css('cursor', 'wait');
940
941                                $.post(siteUrl + '/wp-content/plugins/tt-plugin/tt-ajax.php', {
942                                        action: 'tt_list_search_box_ajax',
943                                        formdata: formdata,
944                                        post_id: ttsearchBoxIn.attr('data-post-id'),
945                                        node_id: ttsearchBoxIn.attr('data-node-id'),
946                                        template_id: ttsearchBoxIn.attr('data-template-id'),
947                                        language_code: (typeof language_code !== 'undefined') ? language_code : '',
948                                        //settingsCode: settingsCode
949                                        settingsCode: window["settingsCodeSearchbox" + ttsearchBoxIn.attr('data-post-id') + ttsearchBoxIn.attr('data-node-id') + ttsearchBoxIn.attr('data-template-id')+ttsearchBoxIn.attr('data-uniq-id')]
950                                    },
951                                    function (data) {
952                                        var parentBox = searchBoxIn.closest('.fl-module-content');
953
954                                        parentBox.html('');
955
956                                        parentBox.append(data);
957
958                                        setSearchBoxAjaxNew();
959                                    });
960
961                            });
962                    }
963
964                    //tt-list-maps
965                    $.each($('.tt-list-maps-ajax'), function(){
966                        var tt_list_maps    =   $(this);
967
968                        var post_id = tt_list_maps.attr('data-post-id');
969                        var node_id = tt_list_maps.attr('data-node-id');
970                        var template_id = tt_list_maps.attr('data-template-id');
971                        var uniqID_settings = tt_list_maps.attr('data-uniq-id');
972
973                        if (!window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings])
974                        {
975                            return;
976                        }
977
978                        tt_list_maps.css('opacity', '.4').css('pointer-events', 'n
978one').css('cursor', 'wait');
979
980                        var r = $.post(siteUrl+'/wp-content/plugins/tt-plugin/tt-ajax.php', {
981                                action: 'tt_list_maps_search_result',
982                                formdata: formdata,
983                                post_id: post_id,
984                                node_id: node_id,
985                                template_id: template_id,
986                                language_code: (typeof language_code !== 'undefined') ? language_code : '',
987                                settingsCode: window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings]
988                            },
989                            function (data) {
990                                tt_list_maps.closest('.fl-module-content').html(data);
991                                $('.eq-height').eqHeights({parentSelector:'.eq-height-wrapper'});
992                                jQuery(window).trigger('resize');
993
994                                setSearchBoxAjaxNew();
995
996                            },'html'
997                        );
998                    });
999
1000                    // tt-list
1001                    $.each($('.tt-list-ajax'), function(){
1002                        var tt_list = $(this);
1003
1004                        var post_id = tt_list.attr('data-post-id');
1005                        var node_id = tt_list.attr('data-node-id');
1006                        var template_id = tt_list.attr('data-template-id');
1007                        var uniqID_settings = tt_list.attr('data-uniq-id');
1008
1009                        if (!window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings])
1010                        {
1011                            return;
1012                        }
1013
1014
1015                        //var r = $.post(FLBuilderLayoutConfig.paths.wpAjaxUrl, {
1016                        var r = $.post(siteUrl+'/wp-content/plugins/tt-plugin/tt-ajax.php', {
1017                                action: 'tt_list_search_result',
1018                                formdata: formdata,
1019                                post_id: post_id,
1020                                node_id: node_id,
1021                                template_id: template_id,
1022                                language_code: (typeof language_code !== 'undefined') ? language_code : '',
1023                                settingsCode: window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings]
1024                            },
1025                            function (data) {
1026                                console.log('Return');
1027                                tt_list.html(data);
1028                                $('.eq-height').eqHeights({parentSelector:'.eq-height-wrapper'});
1029                                jQuery(window).trigger('resize');
1030
1031                                setSearchBoxAjaxNew();
1032
1033                            },'html'
1034                        );
1035                    });
1036                }else{
1037                    url = url + '?' + formdata;
1038                    window.location = url;
1039                }
1040
1041
1042            });
1043
1044            // if document ajax search, we catch the labelbar, and the pagination, and send them by ajax
1045            if($('.tt-list-ajax').length > 0 || $('.tt-list-maps-ajax').length > 0){
1046                $('.pagination a, .search-labelbar a, .changeview a').unbind('click').click(function(e){
1047                    e.preventDefault();
1048
1049                    toggle_result_list();
1050
1051                    var query_string = $(this).attr('href');
1052
1053                    // tt-searchbox aktualisieren
1054                    if (typeof ajax_loader !== 'undefined' && ajax_loader)
1055                    {
1056                        $.each($('.search-box'),
1057                            function () {
1058                                var searchBoxIn = $(this);
1059                                var ttsearchBoxIn = searchBoxIn.closest('.tt-search-box');
1060
1061                                searchBoxIn.css('opacity', '.4').css('pointer-events', 'none').css('cursor', 'wait');
1062
1063                                $.post(siteUrl + '/wp-content/plugins/tt-plugin/tt-ajax.php', {
1064                                        action: 'tt_list_search_box_ajax',
1065                                        formdata: query_string,
1066                                        post_id: ttsearchBoxIn.attr('data-post-id'),
1067                                        node_id: ttsearchBoxIn.attr('data-node-id'),
1068                                        template_id: ttsearchBoxIn.attr('data-template-id'),
1069                                        language_code: (typeof language_code !== 'undefined') ? language_code : '',
1070                                        //settingsCode: settingsCode
1071                                        settingsCode: window["settingsCodeSearchbox" + ttsearchBoxIn.attr('data-post-id') + ttsearchBoxIn.attr('data-node-id') + ttsearchBoxIn.attr('data-template-id')+ttsearchBoxIn.attr('data-uniq-id')]
1072                                    },
1073                                    function (data) {
1074                                        var parentBox = searchBoxIn.closest('.fl-module-content');
1075
1076                                        parentBox.html('');
1077
1078                                        parentBox.append(data);
1079
1080                                        setSearchBoxAjaxNew();
1081                                    });
1082
1083                            });
1084                    }
1085
1086                    //tt-list-maps
1087                    $.each($('.tt-list-maps-ajax'), function(){
1088                        var tt_list_maps    =   $(this);
1089
1090                        var post_id = tt_list_maps.attr('data-post-id');
1091                        var node_id = tt_list_maps.attr('data-node-id');
1092                        var template_id = tt_list_maps.attr('data-template-id');
1093                        var uniqID_settings = tt_list_maps.attr('data-uniq-id');
1094
1095                        if (!window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings])
1096                        {
1097                            return;
1098                        }
1099
1100                        tt_list_maps.css('opacity', '.4').css('pointer-events', 'n
1100one').css('cursor', 'wait');
1101
1102                        var r = $.post(siteUrl+'/wp-content/plugins/tt-plugin/tt-ajax.php', {
1103                                action: 'tt_list_maps_search_result',
1104                                formdata: query_string,
1105                                post_id: post_id,
1106                                node_id: node_id,
1107                                template_id: template_id,
1108                                language_code: (typeof language_code !== 'undefined') ? language_code : '',
1109                                settingsCode: window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings]
1110                            },
1111                            function (data) {
1112                                tt_list_maps.closest('.fl-module-content').html(data);
1113                                $('.eq-height').eqHeights({parentSelector:'.eq-height-wrapper'});
1114                                jQuery(window).trigger('resize');
1115
1116                                setSearchBoxAjaxNew();
1117
1118                            },'html'
1119                        );
1120                    });
1121
1122                    // tt-list aktualisieren
1123                    $.each($('.tt-list-ajax'), function(){
1124                        var tt_list = $(this);
1125
1126                        var post_id = tt_list.attr('data-post-id');
1127                        var node_id = tt_list.attr('data-node-id');
1128                        var template_id = tt_list.attr('data-template-id');
1129                        var uniqID_settings = tt_list.attr('data-uniq-id');
1130
1131                        if (!window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings])
1132                        {
1133                            return;
1134                        }
1135
1136                        var r = $.post(siteUrl+'/wp-content/plugins/tt-plugin/tt-ajax.php', {
1137                                action: 'tt_list_search_result',
1138                                formdata: query_string,
1139                                post_id: post_id,
1140                                node_id: node_id,
1141                                template_id: template_id,
1142                                language_code: (typeof language_code !== 'undefined') ? language_code : '',
1143                                settingsCode: window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings]
1144                            },
1145                            function (data) {
1146                                tt_list.html(data);
1147                                $('.eq-height').eqHeights({parentSelector:'.eq-height-wrapper'});
1148                                jQuery(window).trigger('resize');
1149
1150                                setSearchBoxAjaxNew();
1151                            },'html'
1152                        );
1153                    });
1154                });
1155
1156
1157
1158
1159                $('select[name=sorting]').unbind('change').change(function (e) {
1160                    e.preventDefault();
1161
1162                    var query_string = $(this).val();
1163
1164                    toggle_result_list();
1165
1166                    // tt-searchbox aktualisieren
1167                    if (typeof ajax_loader !== 'undefined' && ajax_loader)
1168                    {
1169                        $.each($('.search-box'),
1170                        function () {
1171                            var searchBoxIn = $(this);
1172                            var ttsearchBoxIn = searchBoxIn.closest('.tt-search-box');
1173
1174                            searchBoxIn.css('opacity', '.4').css('pointer-events', 'none').css('cursor', 'wait');
1175
1176                            $.post(siteUrl + '/wp-content/plugins/tt-plugin/tt-ajax.php', {
1177                                    action: 'tt_list_search_box_ajax',
1178                                    formdata: query_string,
1179                                    post_id: ttsearchBoxIn.attr('data-post-id'),
1180                                    node_id: ttsearchBoxIn.attr('data-node-id'),
1181                                    template_id: ttsearchBoxIn.attr('data-template-id'),
1182                                    language_code: (typeof language_code !== 'undefined') ? language_code : '',
1183                                    //settingsCode: settingsCode
1184                                    settingsCode: window["settingsCodeSearchbox" + ttsearchBoxIn.attr('data-post-id') + ttsearchBoxIn.attr('data-node-id') + ttsearchBoxIn.attr('data-template-id')+ttsearchBoxIn.attr('data-uniq-id')]
1185                                },
1186                                function (data) {
1187                                    var parentBox = searchBoxIn.closest('.fl-module-content');
1188
1189                                    parentBox.html('');
1190
1191                                    parentBox.append(data);
1192
1193                                    setSearchBoxAjaxNew();
1194                                });
1195
1196                        });
1197                    }
1198
1199                    //tt-list-maps
1200                    $.each($('.tt-list-maps-ajax'), function(){
1201                        var tt_list_maps    =   $(this);
1202
1203                        var post_id = tt_list_maps.attr('data-post-id');
1204                        var node_id = tt_list_maps.attr('data-node-id');
1205                        var template_id = tt_list_maps.attr('data-template-id');
1206                        var uniqID_settings = tt_list_maps.attr('data-uniq-id');
1207
1208                        if (!window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings])
1209                        {
1210                            return;
1211                        }
1212
1213                        tt_list_maps.css('opacity', '.4').css('pointer-events', 'n
1213one').css('cursor', 'wait');
1214
1215                        var r = $.post(siteUrl+'/wp-content/plugins/tt-plugin/tt-ajax.php', {
1216                                action: 'tt_list_maps_search_result',
1217                                formdata: query_string,
1218                                post_id: post_id,
1219                                node_id: node_id,
1220                                template_id: template_id,
1221                                language_code: (typeof language_code !== 'undefined') ? language_code : '',
1222                                settingsCode: window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings]
1223                            },
1224                            function (data) {
1225                                tt_list_maps.closest('.fl-module-content').html(data);
1226                                $('.eq-height').eqHeights({parentSelector:'.eq-height-wrapper'});
1227                                jQuery(window).trigger('resize');
1228
1229                                setSearchBoxAjaxNew();
1230
1231                            },'html'
1232                        );
1233                    });
1234
1235                    // tt-list aktualisieren
1236                    $.each($('.tt-list-ajax'), function(){
1237                        var tt_list = $(this);
1238
1239                        var post_id = tt_list.attr('data-post-id');
1240                        var node_id = tt_list.attr('data-node-id');
1241                        var template_id = tt_list.attr('data-template-id');
1242                        var uniqID_settings = tt_list.attr('data-uniq-id');
1243
1244                        if (!window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings])
1245                        {
1246                            return;
1247                        }
1248
1249                        var r = $.post(siteUrl+'/wp-content/plugins/tt-plugin/tt-ajax.php', {
1250                                action: 'tt_list_search_result',
1251                                formdata: query_string,
1252                                post_id: post_id,
1253                                node_id: node_id,
1254                                template_id: template_id,
1255                                language_code: (typeof language_code !== 'undefined') ? language_code : '',
1256                                settingsCode: window["settingsCodeList"+post_id+node_id+template_id+uniqID_settings]
1257                            },
1258                            function (data) {
1259                                tt_list.html(data);
1260                                $('.eq-height').eqHeights({parentSelector:'.eq-height-wrapper'});
1261                                jQuery(window).trigger('resize');
1262
1263                                setSearchBoxAjaxNew();
1264                            },'html'
1265                        );
1266                    });
1267                });
1268            }
1269
1270            // Calendar switch month previos
1271            $(".search-box .tt-popover .calendar a.left").unbind('click').click(function () {
1272                calendar_view_step($(this), 'prev');
1273                return false;
1274            });
1275
1276            // Calendar switch month next
1277            $(".search-box .tt-popover .calendar a.right").unbind('click').click(function () {
1278                calendar_view_step($(this), 'next');
1279                return false;
1280            });
1281
1282            // Calendar click on one day, set the daterange
1283            $(".search-box .tt-popover .calendar .day").unbind('click').click(function () {
1284
1285                var selector = $(this).closest('.calendar').attr('data-selector');
1286                var autosearch = $(this).closest('.calendar').attr('data-autosearch');
1287
1288                if(selector == 'daterange'){
1289                    set_date_range($(this));
1290                }else if('datefrom'){
1291                    set_departure_date($(this));
1292                }else{
1293                    console.log('Error: selector is not supported: ' + selector);
1294                }
1295
1296
1297                if(autosearch == 1){
1298                    //$(this).closest('form').submit();
1299                }
1300
1301
1302
1303                return false;
1304            });
1305
1306            // Calendar mark the daterange on hover
1307            $(".search-box .tt-popover .calendar[data-selector=daterange] .day").unbind('hover').hover(function () {
1308
1309                var date_from = $(".search-box input[name=pm_date_from]").attr('value');
1310                var date_to = $(".search-box input[name=pm_date_to]").attr('value');
1311
1312                if (date_from !== undefined && date_from !== null && date_from.length > 0 && date_to !== null && date_to.length == 0) {
1313                    // mark the days
1314                    var cur_date_ts = $(this).attr("data-date");
1315                    $(".calendar .day").each(function () {
1316                        if (parseInt($(this).attr("data-date")) >= date_from && parseInt($(this).attr("data-date")) <= cur_date_ts) {
1317                            $(this).toggleClass('marked');
1318                        }
1319                    });
1320                }
1321
1322                return false;
1323            });
1324
1325            set_right_date();
1326
1327            $('.search-box input[type="reset"]').unbind('click').click(function(){
1328                $('.search-box').find('input[type="checkbox"]:checked').removeAttr('checked').prop('checked', false);
1329                $('.search-box').find('.reset_field').val('');
1330
1331                if ($('.search-box').find("input[name=pm_date_from]"))
1332                {
1333                    $('.search-box').find("input[name=pm_date_from]").attr('value', '');
1334                    $('.search-box').find("input[name=pm_date_to]").attr('value', '');
1335                }
1336
1337                $(this).closest('form').submit();
1338            });
1339
1340            $('.search-box').find('.fa-search').unbind('click').click(function(){
1341                $(this).closest('form').submit();
1342            });
1343
1344            //Popover CategoryTree Checkboxen beim reload setzen
1345            $('.search-box input[type="checkbox"]:checked').each(function(){
1346                set_popover_field_value_checkbox_category_tree(this);
1347            });
1348
1349            //Popover CategoryTree Checkboxen beim Klicken setzen
1350            $('.search-box input[type="checkbox"]').unbind('click').click(function () {
1351                set_popover_field_value_checkbox_category_tree(this);
1352                //set_close_button(this);
1353            });
1354
1355            // Touristic Persons
1356            $(".search-box .controls > .wrapper.touristic-persons select").unbind('change').change(function () {
1357                set_touristic_persons($(this));
1358                return false;
1359            });
1360
1361            // Touristic Price Range
1362            $(".search-box .controls > input[name=pm_price_min],.search-box .controls > input[name=pm_price_max]").unbind('change').change(function () {
1363                //set_touristic_persons($(this));
1364                set_price_range($(this));
1365                return false;
1366            });
1367
1368            $(".search-box .controls > input[name=pm_duration_min],.search-box .controls > input[name=pm_duration_max]").unbind('change').change(function () {
1369                //set_touristic_persons($(this));
1370                set_duration_range($(this));
1371                return false;
1372            });
1373
1374
1375            //set the close button for trees based popover fields
1376            $('.search-box:not(.not_default) div.popover-field/*:not(.touristic_daterange)*/ span').each(function(){
1377                set_close_button(this);
1378            });
1379
1380
1381            $('.search-box div.popover-field input[name=pm_zip]').each(function(){
1382                setCloseButtonForZip(this)
1383            });
1384
1385
1386        }
1387
1388        setSearchBoxAjaxNew();
1389
1390        //Popover CategoryTree Checkboxen beim Klicken setzen
1391        $('.pm-search').on('click', '.tt-popover[data-type="landingpage"] input[type="radio"]', function() {
1392
1393            set_popover_field_value_landingpage(this);
1394
1395            // set the new landingpage
1396            $(this).closest('form').attr('data-landingpage', $(this).attr('data-url'));
1397
1398            var popover_fieldname = $(this).closest(".tt-popover").attr('name');
1399            toggle_box($(".search-box .popover-field[name='" + popover_fieldname + "']"));
1400
1401            //set_close_button(this);
1402        });
1403
1404        //set the close button for trees based popover fields
1405        $('.search-box:not(.not_default) div.popover-field').on('DOMSubtreeModified', 'span', function(){
1406            console.log('close');
1407            set_close_button(this);
1408        });
1409
1410
1411
1412        $('.pm-search input').on('change', function(){
1413            update_search_fields($(this));
1414        });
1415
1416        $('.search-box div.popover-field input[name=pm_zip]').on('input', function(){
1417            setCloseButtonForZip(this);
1418        });
1419    });
1420
1421
1422})(jQuery);
1423
1424
1425
1426;(function ($, window, document, undefined) {
1427
1428    "use strict";
1429
1430    // plugin wrapper
1431    $.fn.stickyToggleContent = function (options) {
1432
1433        var $toggle = this, // -- this cant be changed, comes from init
1434            $toggleClass = '.'+this.attr('class'),
1435            $target = this.data('target'), // -- cant be changed, gets target content
1436            $scrollTop = $(window).scrollTop(),
1437            $lastScrollTop = 0,
1438            $trigger = 0,
1439            $headerHeight = 0,
1440            $scrollTrigger = $($toggleClass).offset().top,
1441            $toggleHeight = $toggle.outerHeight(),
1442            $scrollDirection = 0, // - is changed by scroll, 0 = Down, 1 = Up
1443            defaults = $.extend({
1444
1445                // -- has sticky header?
1446                stickyHeader: true, // true / false
1447                headerClass: '.site_header', // header class as defined in html
1448
1449                targetOpenClass: 'open',
1450                toggleActClass: 'act',
1451                fixedClass: 'is-sticky',
1452
1453                // -- use parent elem to unfix element?
1454                useparent: 1,
1455                parent: '.fl-col-group', // Class of row/section where it should be sticky
1456                parentthreshold: 0
1457
1458            }, options);
1459
1460        // -- make object $target
1461        $target = $($target);
1462
1463
1464        // -- determind scrollDirection
1465        function scrollDirection() {
1466
1467            if ($scrollTop > $lastScrollTop) {
1468                $scrollDirection = 0;
1469            } else {
1470                $scrollDirection = 1;
1471            }
1472
1473            $lastScrollTop = $scrollTop;
1474
1475        }
1476
1477        // -- toggle fixed stuff
1478        function toggleFixed() {
1479
1480            // - regenerate $scrollTop
1481            $scrollTop = $(window).scrollTop();
1482            $toggleHeight = $toggle.outerHeight();
1483
1484            // - get header height for calc if needed
1485            if ( defaults.stickyHeader == true ) {
1486                $headerHeight = $(defaults.headerClass).outerHeight();
1487            }
1488
1489            if ( $toggle.hasClass(defaults.fixedClass) == false ) {
1490
1491                // -- now renew the scrollTrigger of it has changed
1492                if ( $scrollTrigger != $($toggleClass).offset().top ) {
1493                    $scrollTrigger = $($toggleClass).offset().top;
1494                }
1495
1496            }
1497
1498            // - calc $trigger
1499            $trigger = $scrollTrigger - $headerHeight;
1500
1501            // - set fixed Class to $toggle
1502            if( $scrollTop >= $trigger ) {
1503
1504                console.log($scrollTop + ' >= ' + $trigger);
1505
1506                // -- if useParent , release classes, dont set them
1507
1508                if ( defaults.useparent == 1) {
1509                    // -- release if heigher then height of parent - threshold
1510                    var $releaseTrigger =  $toggle.closest(defaults.parent).outerHeight();
1511
1512                    // -- recalculate $releaseTrigger
1513                    $releaseTrigger = ($releaseTrigger + $trigger) - defaults.parentthreshold;
1514
1515                    if( $scrollDirection == 0 ) {
1516
1517                        if($scrollTop > $releaseTrigger) {
1518
1519                            if ( $toggle.hasClass(defaults.toggleActClass) == false ) {
1520                                $toggle.removeClass(defaults.fixedClass);
1521                                $toggle.parent().attr('style', '');
1522                                $toggle.attr('style', '');
1523                            }
1524
1525                            return false;
1526
1527                        }
1528
1529                        $toggle.addClass(defaults.fixedClass);
1530                        $toggle.parent().css({'padding-top': $toggleHeight+'px'});
1531                        $toggle.css({'top': $headerHeight+'px'});
1532
1533
1534                    } else {
1535
1536
1537
1538                        if($scrollTop < $trigger) {
1539                            if($toggle.hasClass(defaults.toggleActClass) == false) {
1540                                $toggle.removeClass(defaults.fixedClass);
1541                                $toggle.parent().attr('style', '');
1542                                $toggle.attr('style', '');
1543
1544                                return false;
1545                            }
1546                        }
1547
1548                        // -- set classes + padding if scroll up
1549                        if($scrollTop < $releaseTrigger) {
1550
1551                            $toggle.addClass(defaults.fixedClass);
1552                            $toggle.parent().css({'padding-top': $toggleHeight+'px'});
1553                            $toggle.css({'top': $headerHeight+'px'});
1554
1555                        }
1556
1557                    }
1558
1559                } else {
1560
1561                    if ( $scrollTop < $trigger ) {
1562                        $toggle.attr('style', '');
1563
1564                        return false;
1565                    }
1566
1567                    $toggle.addClass(defaults.fixedClass);
1568                    $toggle.parent().css({'padding-top': $toggleHeight+'px'});
1569                    $toggle.css({'top': $headerHeight+'px'});
1570
1571                }
1572
1573
1574
1575
1576            } else {
1577
1578                if ( $toggle.hasClass(defaults.toggleActClass) == false ) {
1579                    $toggle.removeClass(defaults.fixedClass);
1580                    $toggle.parent().attr('style', '');
1581                    $toggle.attr('style', '');
1582                } else {
1583                    $toggle.removeClass(defaults.fixedClass);
1584                    $toggle.parent().attr('style', '');
1585                    $toggle.attr('style', '');
1586                }
1587            }
1588
1589        }
1590
1591        return this.each(function () {
1592
1593            // -- stuff on load
1594            toggleFixed();
1595
1596            // -- unbind click to prevent double init problemes
1597            $toggle.unbind('click');
1598
1599            // -- stuff on click events
1600            $toggle.click(function (e) {
1601
1602                if($scrollTop <= $trigger) {
1603                    if ($toggle.hasClass(defaults.toggleActClass)) {
1604
1605                        $toggle.removeClass(defaults.toggleActClass);
1606                        $toggle.removeClass(defaults.fixedClass);
1607
1608                        $target.removeClass(defaults.targetOpenClass);
1609                        $toggle.parent().attr('style', '');
1610
1611                        $toggle.attr('style', '');
1612
1613                        return false;
1614                    }
1615                }
1616
1617                $toggleHeight = $toggle.outerHeight();
1618
1619                // - toggle classes
1620                $target.toggleClass(defaults.targetOpenClass);
1621                $toggle.toggleClass(defaults.toggleActClass);
1622
1623
1624                if( $scrollTop <= $trigger ) {
1625                    $toggle.toggleClass(defaults.fixedClass);
1626                }
1627
1628                if ( $toggle.hasClass(defaults.toggleActClass) == false ) {
1629
1630                    // - remove style attr
1631                    if( $scrollTop <= $trigger ) {
1632                        $toggle.parent().attr('style', '');
1633                    }
1634
1635                } else {
1636
1637                    // - set padding top to prevent jumping page
1638                    $toggle.parent().css({'padding-top': $toggleHeight+'px'});
1639                    $toggle.css({'top': $headerHeight+'px'});
1640
1641                    // - set top val for target
1642                    $target.css({'top': $headerHeight+$toggleHeight+'px'});
1643
1644                }
1645
1646                e.preventDefault();
1647            });
1648
1649            // -- tuff on scroll events
1650            $(window).scroll(function() {
1651                toggleFixed();
1652                scrollDirection();
1653            });
1654
1655
1656        })
1657
1658    }
1659
1660
1661})(jQuery, window, document);
1662
1663
1664// set data-target=".search-box.offcanvas" to btn
1665
1666function indisearch(id) {
1667
1668    var inputhidden = document.getElementById(id + id);
1669
1670    if(inputhidden != null)
1671    {
1672
1673        if (inputhidden.disabled) {
1674            //alert('hello');
1675            // If disabled, do this
1676            inputhidden.disabled = false;
1677
1678        } else {
1679            // Enter code here
1680            inputhidden.disabled = true;
1681
1682        }
1683
1684    }
1685
1686}

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.