PageSourceSearch

https://secure-checkout.kiwiexperience.com/dataobjectcontroller/javascript/support_fns.js?m=1690900314

js kiwiexperience.com collected 2026-09-26 06:32:57 UTC 6,643 bytes, 179 lines download raw bytes

1//NOTE:
2
3
4//This file is also used by the v3 API Forms.
5//If you are applying J6-specific changes better to do them in dataobject_editpopup.js
6//or test the API forms after, epsecially edit.
7
8
9function DoWatchForEventOrProductChange($edit_modal) {
10
11    window.initCustomPickupOptionAndFields($edit_modal);
12
13    $edit_modal.on('change',function(){
14
15
16            if ($edit_modal.find('.tour-sector-list').length === 0) {
17                    return;
18            }
19            window.initJ6LiveUpdate($edit_modal);
20            $config_area = $edit_modal.find('.ProductConfig').first();
21            $sector_table = $edit_modal.find('.tour-sector-list').first();
22            $table_id = $sector_table.attr('id');
23            $id_parts = $table_id.split('-');
24            $event = $config_area.find('[name="item_'+$id_parts[2]+'[EventID]"]');
25            $current_event = $edit_modal.find('[name="CurrentEventID"]');
26            if ($event.length === 0) {
27                    $event = $config_area.find('[name="EventID"]');
28            }
29            $item_pickup = $edit_modal.find('div#PickupID');
30            if ($event.length > 0 && $current_event.length > 0) {
31                    if ($event.val() !== $current_event.val()) {
32                            $sector_table.hide();
33                            if ($item_pickup.length > 0) {
34                                    $item_pickup.show();
35                            }
36                    } else {
37                            $sector_table.show();
38                            if ($item_pickup.length > 0) {
39                                    $item_pickup.hide();
40                            }
41                    }
42            } else {
43                    $sector_table.hide();
44                    if ($item_pickup.length > 0) {
45                            $item_pickup.show();
46                    }
47            }
48    });
49  }
50
51// ability to submit the form without refreshing the page
52function DoWatchForFormAjaxSubmit($edit_modal) {
53        $edit_modal.find('form.ajax-submit-form').on('submit', function(ev){
54                var $form = jQuery(this);
55                // stop form from submitting
56                ev.preventDefault();
57
58                var $button = $form.find('[type="submit"]');
59                $button.attr('value', 'Saving...');
60                /* get some values from elements on the page: */
61                var url = $form.attr('action');
62
63                var formdata = {};
64
65                $form.find('input, select, textarea').each(function(){
66                        var $input = jQuery(this);
67                        var name = $input.attr('name');
68                        if (name != 'undefined') {
69                                formdata[name] = $input.val();
70                        }
71                });
72                // Send form data 
73	             jQuery.post( url, formdata,
74                        function() {
75                                $button.attr('value', 'Done');
76                                $edit_modal.addClass('fade');
77                                setTimeout(function() {$edit_modal.modal('hide');$edit_modal.removeClass('fade');}, 500);
78                        });
79
80                return false;
81        });
82}
83
84
85
86PopulateTheEditForm = function PopulateEditForm(){
87        var $ = jQuery;
88        var $edit_modal = $('#DataObject_EditPopup');
89        // register new elements with various plugins
90        $edit_modal.find('.date.year input').datepicker({format: 'dd/mm/yyyy', autoclose: true, startView: 2 });
91        $edit_modal.find('.date input').datepicker({format: 'dd/mm/yyyy', autoclose: true});
92
93        var preventSearch = false;
94        var minResults = 5; // making this one searchable on less results
95        // if on mobile make sure the search input does not get used
96        if($('html.mobile-template').length > 0) {
97                preventSearch = true;
98                minResults = 1000;
99        }
100//			window.initSelect2Elements($edit_modal);
101        
102        //if we are not in pricing context then these dont have to be loaded.
103        //the check is necessary anyway in case theyre not
104        
105        if (typeof initiatePricingJS === 'function'){
106	        window.setTimeout(initiatePricingJS, 150);
107        }
108        if(typeof initiateCheckoutJS  === 'function'){
109           window.setTimeout(initiateCheckoutJS, 250);
110        }
111
112	     ApplySearch2($edit_modal);
113        // $edit_modal.find('select').each(function(){
114        //         var $s = $(this);
115        //         var isTagField = $s.hasClass('tagField');
116        //         $s.select2({
117        //                 tags: isTagField,
118        //                 allowClear: false,
119        //                 width: 'resolve',
120        //                 minimumResultsForSearch: minResults,
121        //                 preventSearchInput: preventSearch,
122        //                 dropdownCssClass: 'limited-drop' // do not let the drop-down fall too far off the bottom
123        //         });
124        // });
125
126        if ($edit_modal.find('ul.tabstrip').length > 0) {
127                $edit_modal.find('ul.tabstrip').each(function(){
128                        initTabstrip(this);
129                });
130
131                $edit_modal.find('ul.tabstrip a').click(function(e){
132                        e.preventDefault();
133                        window.setTimeout(function(){$edit_modal.modal('layout')},500);
134                });
135        }
136
137        if (FindAndApplyBootstraps) {
138                FindAndApplyBootstraps($edit_modal);
139        }
140		
141		if(window.remoteFetchSelect) {
142			window.remoteFetchSelect($edit_modal); 
143		}
144
145        $edit_modal.modal('layout');
146        DoModelSearch($edit_modal);
147        if ($edit_modal.find('[name=Quantity]')) {
148                $edit_modal.find('[name=Quantity]').change();
149        }
150
151        // got to set a watch for tour products because we don't want people thinking they can edit the sectors if they are changing the Event or Product
152        if ($edit_modal.find('.tour-sector-list')) {
153                DoWatchForEventOrProductChange($edit_modal);
154        }
155
156        // init dataobjectmanager
157        $edit_modal.DataObjectManager();
158
159        DoWatchForFormAjaxSubmit($edit_modal);
160
161     
162
163};
164
165window.initSprintfLabels = function($context){
166
167	$context.find('.sprintf-label').each(function(){
168		var $sprintf_label = $(this).find('label'),
169			$sprintf_input = $(this).find('input');
170
171		$sprintf_label.html($sprintf_label.html().replace('%s', '<span class="sprintf-val">'+$sprintf_input.val()+'</span>'));
172
173		$sprintf_input.on('change', function(){
174			$sprintf_label.find('sprintf-val').html($(this).val());
175		});
176
177	});
178
179};

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.