PageSourceSearch

https://icc.co.za/wp-content/themes/icc2020/platform/library/js/vendor/litebox.js?ver=1790288968

js icc.co.za collected 2026-09-24 22:30:15 UTC 10,611 bytes, 296 lines download raw bytes

1var staticWidth = 400;
2var staticHeight = 500;
3var liteForm;
4
5function liteboxInitialise(portalUrl, form) {
6    $(document).ready(function () {
7
8        if (portalUrl === null || portalUrl === '')
9            throw new Error('Required field "portalUrl" not set. Please set the portalUrl.');
10
11        if (form) {
12            if ($("#" + form).length)
13                liteForm = form;
14            else
15                throw new Error('Could not locate Form tag with id \'' + form + '\' on page');
16        }
17
18        $.fn.center = function (obj) {
19            this.css('position', 'fixed');
20            this.css('top', '130px');
21            this.css('left', (obj.width() / 2 - this.width() / 2) + 'px');
22            return this;
23        };
24
25        // Get handle to iveri-litebox
26        var litebox = document.getElementById('iveri-litebox');
27        if (litebox) {
28            litebox.setAttribute('class', 'modal fade');
29            litebox.setAttribute('data-backdrop', 'static');
30            litebox.setAttribute('data-keyboard', 'false');
31            var actualWidth = getActualWidth();
32            if (staticWidth > actualWidth) {
33                litebox.style.height = getFrameHeight() + 'px';
34                litebox.style.width = getFrameWidth() + 'px';
35            }
36
37            // Create the iveri-litebox-dialog div
38            var liteboxDialog = document.createElement('div');
39            liteboxDialog.setAttribute('id', 'iveri-litebox-dialog');
40            liteboxDialog.setAttribute('class', 'modal-dialog modal-dialog-centered');
41
42            // Append the div to the iveri-litebox
43            litebox.appendChild(liteboxDialog);
44            if (liteboxDialog) {
45                liteboxDialog.style.height = getFrameHeight() + 'px';
46                liteboxDialog.style.width = getFrameWidth() + 'px';
47                if (staticWidth < actualWidth)
48                    $("#iveri-litebox-dialog").center($("#iveri-litebox"));
49
50                // Create the iveri-litebox-content div
51                var liteboxContent = document.createElement('div');
52                liteboxContent.setAttribute('id', 'iveri-litebox-content');
53                liteboxContent.setAttribute('class', 'modal-content');
54
55                // Append the div to the iveri-litebox-dialog
56                liteboxDialog.appendChild(liteboxContent);
57                if (liteboxContent) {
58                    liteboxContent.style.height = getFrameHeight() + 'px';
59                    liteboxContent.style.width = getFrameWidth() + 'px';
60                    liteboxContent.style.position = 'fixed';
61
62                    // Create the iveri-litebox-iframe iframe
63                    var liteboxFrame = document.createElement('iframe');
64                    liteboxFrame.setAttribute('src', portalUrl + '/Lite/LiteBox.aspx');
65                    liteboxFrame.setAttribute('id', 'iveri-litebox-iframe');
66                    liteboxFrame.setAttribute('seamless', 'seamless');
67                    liteboxFrame.setAttribute('frameborder', '0');
68                    liteboxFrame.setAttribute('height', getFrameHeight());
69                    liteboxFrame.setAttribute('width', getFrameWidth());
70                    liteboxFrame.onload = function () { };
71
72                    // Append the frame to the iveri-litebox-content
73                    liteboxContent.appendChild(liteboxFrame);
74                    if (liteboxFrame) {
75                        // Get handle to iveri-litebox-button
76                        var liteboxButton = document.getElementById('iveri-litebox-button');
77                        if (liteboxButton) {
78                            liteboxButton.setAttribute('class', 'btn btn-lg btn-primary');
79                            liteboxButton.setAttribute('data-toggle', 'modal');
80                            liteboxButton.setAttribute('data-target', '#iveri-litebox');
81
82                            //Check browser
83                            if (browser() === 'IE') {
84                                console.error('Litebox functionality not supported in your browser!...');
85                                liteboxButton.style.visibility = 'hidden';
86                            }
87
88                            // Send data on modal dialog button click
89                            bindEvent(liteboxButton, 'click', function (e) {
90                                var form = getFormFields();
91
92                                console.log(form);
93
94                                alert(1);
95
96                                // Make sure you are sending a string, and to stringify JSON
97                                liteboxFrame.contentWindow.postMessage(form, '*');
98                            });
99                        }
100
101                        // Listen to message from child window
102                        bindEvent(window, 'message', function (e) {
103                            liteboxComplete(e.data);
104                            $('#iveri-litebox').modal('hide');
105                        });
106                    }
107                }
108            }
109        }
110    });
111}
112
113// tell merchant which if browser is supported
114function isBrowserSupported() {
115    if (browser() === 'IE')
116        return false;
117}
118
119// addEventListener support for IE8
120function bindEvent(element, eventName, eventHandler) {
121    if (element.addEventListener) {
122        element.addEventListener(eventName, eventHandler, false);
123    } else if (element.attachEvent) {
124        element.attachEvent('on' + eventName, eventHandler);
125    }
126}
127
128function getAttrs(DOMelement) {
129    var obj = {};
130    $.each(DOMelement.attributes, function () {
131        if (this.specified) {
132            obj[this.name] = this.value;
133        }
134    });
135    return obj;
136}
137
138// Retrieve the form fields
139function getFormFields() {
140    var jsonData = '{}';
141    if (liteForm === undefined) {
142        $("form").each(function () {
143            var json = {
144                "form": []
145            };
146            $(this).find("input").each(function () {
147                if (isLiteField(this) && nonEmtyField(this)) {
148                    json.form.push(getAttrs(this));
149                }
150            });
151
152            $(this).find("select").each(function () {
153                if (isLiteField(this) && nonEmtyField(this)) {
154                    var select = getAttrs(this);
155                    select["type"] = "select";
156                    var options = [];
157                    $(this).children().each(function () {
158                        options.push(getAttrs(this));
159                    });
160                    select["options"] = options;
161                    json.form.push(select);
162                }
163            });
164
165            //console.log(json);
166            jsonData = json;
167        });
168    } else {
169        $("#" + liteForm).each(function () {
170            var json = {
171                "form": []
172            };
173            $(this).find("input").each(function () {
174                if (isLiteField(this) && nonEmtyField(this)) {
175                    json.form.push(getAttrs(this));
176                }
177            });
178
179            $(this).find("select").each(function () {
180                if (isLiteField(this) && nonEmtyField(this)) {
181                    var select = getAttrs(this);
182                    select["type"] = "select";
183                    var options = [];
184                    $(this).children().each(function () {
185                        options.push(getAttrs(this));
186                    });
187                    select["options"] = options;
188                    json.form.push(select);
189                }
190            });
191
192            //console.log(json);
193            jsonData = json;
194        });
195    }
196    return JSON.stringify(jsonData);
197}
198
199// Returns true only for Lite request fields
200function isLiteField(DOMelement) {
201    var id = DOMelement.id;
202    if (id.startsWith('Lite_') || id.startsWith('Ecom_') || id.startsWith('Airline_') || id.startsWith('MerchantReference'))
203        return true;
204    else
205        return false;
206}
207
208// Returns true only for fields that has a value
209function nonEmtyField(DOMelement) {
210    var value = DOMelement.value;
211    if (value === '')
212        return false;
213    else
214        return true;
215}
216
217// The width of the iFrame
218function getFrameWidth() {
219    var actualWidth = getActualWidth();
220    if (actualWidth < staticWidth)
221        return actualWidth;
222    else
223        return staticWidth;
224}
225
226// The height of the iFrame
227function getFrameHeight() {
228    var actualHeight = getActualHeight();
229    if (actualHeight < staticHeight)
230        return actualHeight;
231    else
232        return staticHeight;
233}
234
235function getActualWidth() {
236    var actualWidth = window.innerWidth ||
237        document.documentElement.clientWidth ||
238        document.body.clientWidth ||
239        document.body.offsetWidth;
240    return actualWidth;
241}
242
243function getActualHeight() {
244    var actualHeight = window.innerHeight ||
245        document.documentElement.clientHeight ||
246        document.body.clientHeight ||
247        document.body.offsetHeight;
248    return actualHeight;
249}
250
251if (!String.prototype.startsWith) {
252    String.prototype.startsWith = function (searchString, position) {
253        position = position || 0;
254        return this.indexOf(searchString, position) === position;
255    };
256}
257
258/**
259 * Gets the browser name or returns an empty string if unknown.
260 * This function also caches the result to provide for any
261 * future calls this function has.
262 *
263 * @returns {string}
264 */
265var browser = function () {
266    // Return cached result if avalible, else get result then cache it.
267    if (browser.prototype._cachedResult)
268        return browser.prototype._cachedResult;
269
270    // Opera 8.0+
271    var isOpera = (!!window.opr && !!opr.addons) || !!window.opera || navigator.userAgent.indexOf(' OPR/') >= 0;
272
273    // Firefox 1.0+
274    var isFirefox = typeof InstallTrigger !== 'undefined';
275
276    // Safari 3.0+ "[object HTMLElementConstructor]" 
277    var isSafari = /constructor/i.test(window.HTMLElement) || (function (p) { return p.toString() === "[object SafariRemoteNotification]"; })(!window['safari'] || safari.pushNotification);
278
279    // Internet Explorer 6-11
280    var isIE = /*@cc_on!@*/false || !!document.documentMode;
281
282    // Edge 20+
283    var isEdge = !isIE && !!window.StyleMedia;
284
285    // Chrome 1+
286    var isChrome = !!window.chrome && !!window.chrome.webstore;
287
288    return browser.prototype._cachedResult =
289        isOpera ? 'Opera' :
290            isFirefox ? 'Firefox' :
291                isSafari ? 'Safari' :
292                    isChrome ? 'Chrome' :
293                        isIE ? 'IE' :
294                            isEdge ? 'Edge' :
295                                "Don't know";
296};

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.