PageSourceSearch

https://lri-lb.org/assets/js/_services.js

js lri-lb.org collected 2026-10-02 05:51:28 UTC 70,308 bytes, 1,764 lines download raw bytes

1app.service('myServices', function () {
2    this.ConvertObjectToQueryString = function (inputObject, includingEmty) {
3        var str = '';
4        for (var key in inputObject) {
5            if (key.indexOf('exc_') == -1) {
6                if (!inputObject.hasOwnProperty(key) || typeof inputObject[key] === 'function') {
7                    continue;
8                }
9                if (typeof inputObject[key] === 'object') { // an object and an array are objects
10                    str += (str == '' ? '' : '&') + key + '=' + encodeURIComponent(inputObject[key].join());
11                } else {
12                    str += (str == '' ? '' : '&') + key + '=' + encodeURIComponent(inputObject[key]);
13                }
14            }
15        }
16        if (includingEmty == undefined || includingEmty == false) {
17            str = str.replace(/(&?\w+=((?=$)|(?=&)))/g, '');
18        }
19        if (str.indexOf("&") == 0) {
20            str = str.substring(1, str.length);
21        }
22        return str;
23    }
24
25    this.ConvertObjectToKendoFilterQueryString = function (inputObject) {
26        var str = '';
27        for (var key in inputObject) {
28            if (!inputObject.hasOwnProperty(key) || typeof inputObject[key] === 'function') {
29                continue;
30            }
31            if (typeof inputObject[key] === 'object') { // an object and an array are objects
32                str += (str == '' ? '' : '~and~') + key + '~' + encodeURIComponent(inputObject[key].join());
33            } else if (inputObject[key] != '') {
34                str += (str == '' ? '' : '~and~') + key + '~' + encodeURIComponent(inputObject[key]);
35            }
36        }
37        str = str.replace(/(&?\w+=((?=$)|(?=&)))/g, '');
38        if (str.indexOf("~and~") == 0) {
39            str = str.substring(1, str.length);
40        }
41        return str;
42    }
43
44    this.parseFilterString = function (filterString) {
45
46        filterString = filterString == undefined ? "" : filterString;
47        filterString = decodeURIComponent(filterString);
48        // Remove all of the ' characters from the string.
49        filterString = filterString.replace(/[']/g, '');
50        // Split the string into an array of strings, using the ~ as a delimiter.
51        var ss = filterString.split("~"); // ss stands for "split string". I'm clever.
52        var F = []; // Used to store all of the parsed filters.
53        var fIndex = -1; // Used to track filter index.
54        var cIndex = 0; // Used to track filter index within a composite filter object.
55        var isComposite = false; // Used to indicate if a composite filter is currently being parsed.
56        for (var i = 0; i < ss.length; i++) {
57            if (i % 4 == 0) { // Field.
58                if (ss[i].indexOf('(') > -1) { // If we're starting a composite object, create a composite object and add it to the parsed filters.
59                    F.push({
60                        filters: [],
61                        logic: ""
62                    });
63                    fIndex++; // We added an object to the array, so increment the counter.
64                    F[fIndex]
65                    F[fIndex].filters.push({
66                        field: ss[i].replace('(', ''),
67                        operator: "",
68                        value: ""
69                    });
70                    cIndex = 0; // We added the first filter to the composite object, so set the counter.
71                    isComposite = true;
72                } else if (isComposite) { // If we're parsing the second filter in a composite filter object, then add the field to the child filter.
73                    F[fIndex].filters.push({
74                        field: ss[i],
75                        operator: "",
76                        value: ""
77                    });
78                    cIndex++; // We added the second filter to the composite object, so increment the counter.
79                } else { // Add the field as normal.
80                    F.push({
81                        field: ss[i],
82                        operator: "",
83                        value: ""
84                    });
85                    fIndex++; // We added an object to the array, so increment the counter.
86                }
87            }
88            if (i % 4 == 1) { // Operator.
89                if (isComposite) {
90                    F[fIndex].filters[cIndex].operator = ss[i];
91                } else {
92                    F[fIndex].operator = ss[i];
93                }
94            }
95            if (i % 4 == 2) { // Value.
96                if (ss[i].indexOf(')') > -1) {
97                    F[fIndex].filters[cIndex].value = ss[i].replace(')', '');
98                    isComposite = false;
99                } else if (isComposite) {
100                    F[fIndex].filters[cIndex].value = ss[i];
101                } else {
102                    F[fIndex].value = ss[i];
103                }
104            }
105            if (i % 4 == 3) { // Logic.
106                if (isComposite) {
107                    F[fIndex].logic = ss[i]; // Add the logic to the composite filter object.
108                }
109                // If the filter is not composite, the logic will always be "and". So, we just don't do anything if that's the case.
110            }
111        }
112
113        if (F.length > 0 && (F[0].field == undefined || F[0].field == "")) {
114            F.splice(0, 1);
115        }
116
117
118        return {
119            filters: F,
120            logic: "or"
121        };
122    };
123
124
125    this.parseSortString = function (sortString) {
126        sortString = sortString == undefined ? "" : sortString;
127        // Split the string into an array of strings, using the ~ as a delimiter.
128        var ss = sortString.split("~"); // ss stands for "split string". I'm clever.
129        var S = []; // Array containing sort objects.
130        for (var i = 0; i < ss.length; i++) {
131            var sort = ss[i].split('-'); // Split sort string into field and direction.
132            S.push({
133                compare: undefined, // This field exists in the sort objects, but is always undefined (as far as I can tell). I added it anyways, to minimize potential future issues.
134                dir: sort[1], // Direction.
135                field: sort[0] // Field.
136            });
137        }
138        return S;
139    };
140
141    this.parseGroupString = function (groupString, gridObj) {
142        groupString = groupString == undefined ? "" : groupString;
143        // Split the string into an array of strings, using the ~ as a delimiter.
144        var ss = groupString.split("~"); // ss stands for "split string". I'm clever.
145        var S = []; // Array containing sort objects.
146        for (var i = 0; i < ss.length; i++) {
147            var sort = ss[i].split('-'); // Split sort string into field and direction.
148            if (sort[0] != "") {
149                S.push({
150                    dir: sort[1], // Direction.
151                    field: sort[0] // Field.
152                });
153            }
154        }
155
156        this.AutoInitGrouping(gridObj, S);
157        return S;
158    };
159
160    this.AnchorSmoothScroll = function (eID, cheating) {
161        var startY = currentYPosition();
162        var stopY = elmYPosition(eID) + cheating;
163        var distance = stopY > startY ? stopY - startY : startY - stopY;
164        if (distance < 100) {
165            scrollTo(0, stopY);
166            return;
167        }
168        var speed = Math.round(distance / 100);
169        if (speed >= 20) speed = 20;
170        var step = Math.round(distance / 25);
171        var leapY = stopY > startY ? startY + step : startY - step;
172        var timer = 0;
173        if (stopY > startY) {
174            for (var i = startY; i < stopY; i += step) {
175                setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
176                leapY += step;
177                if (leapY > stopY) leapY = stopY;
178                timer++;
179            }
180            return;
181        }
182        for (var i = startY; i > stopY; i -= step) {
183            setTimeout("window.scrollTo(0, " + leapY + ")", timer * speed);
184            leapY -= step;
185            if (leapY < stopY) leapY = stopY;
186            timer++;
187        }
188
189        function currentYPosition() {
190            // Firefox, Chrome, Opera, Safari
191            if (self.pageYOffset) return self.pageYOffset;
192            // Internet Explorer 6 - standards mode
193            if (document.documentElement && document.documentElement.scrollTop)
194                return document.documentElement.scrollTop;
195            // Internet Explorer 6, 7 and 8
196            if (document.body.scrollTop) return document.body.scrollTop;
197            return 0;
198        }
199
200        function elmYPosition(eID) {
201            var elm = document.getElementById(eID);
202            if (elm != null) {
203                var y = elm.offsetTop;
204                var node = elm;
205                while (node.offsetParent && node.offsetParent != document.body) {
206                    node = node.offsetParent;
207                    y += node.offsetTop;
208                }
209                return y;
210            } else {
211                return 0;
212            }
213        }
214    };
215
216    this.AutoInitGrouping = function (gridObj, grouping) {
217        if (gridObj != undefined) {
218            setTimeout(function () { //wait until thi grid is loaded
219                resultsContainer = gridObj.find(".action-wrapper").siblings(".results-wrapper");
220                if (grouping.length > 0) {
221                    $.each(grouping, function (index, item) {
222                        selectedText = gridObj.find(".filter-groupby select option[value='" + item.field + "']").text();
223                        $(resultsContainer).append("<div class=\"action-result-wrapper\">" + "<i class=\"zmdi zmdi-close-circle\" onclick=\"resetGrouping(this)\"></i>" + "<div class=\"action-type\">Grouped by: [</div>" + "<div class=\"action-result\">" + selectedText + "</div>" + "<div class=\"action-type\">]</div>" + "</div>")
224                    });
225                }
226            });
227        }
228    }
229
230});
231
232app.service('Session', function ($rootScope, localStorageService, AUTH_EVENTS) {
233
234    this.create = function (token, userRole) {
235
236        this.access_token = token.access_token;
237        this.refresh_token = token.refresh_token;
238        this.token_type = token.token_type;
239        //this.userId = userId;
240        this.userRole = userRole;
241
242        localStorageService.set('token', token);
243
244
245        //local storage
246    };
247
248    this.CreateByKey = function (key, value) {
249        this[key] = value
250    }
251
252    this.DeleteByKey = function (key) {
253        this[key] = null
254    }
255
256    this.userInfos = null;
257
258    this.refillWhileBuyingUrl = null;
259
260
261    this.userPermissions = {};
262
263    this.createMenu = function (menu) {
264        this.menu = menu;
265    }
266
267    this.destroy = function () {
268        this.id = null;
269        this.access_token = null;
270        this.refresh_token = null;
271        this.token_type = null;
272        //this.userId = userId;
273        this.userRole = null;
274        this.userInfos = null;
275        //  this.offlineData = null;
276        localStorageService.remove('token');
277        $rootScope.$broadcast(AUTH_EVENTS.logoutSuccess);
278
279        // local storage code
280    };
281
282    this.populateData = function (staticData) {
283        this.staticData = staticData;
284    };
285
286    this.retreiveData = function () {
287        return this.staticData;
288    };
289});
290
291app.service('MapHelper', function ($timeout, NgMap, JSHelper) {
292
293    var self = this;
294
295    var originalLat = 0;
296    var originalLng = 0;
297
298    var locationNotId = undefined;
299    var locationNotId1 = undefined;
300    var locationNotId2 = undefined;
301
302    NgMap.getMap().then(function (gmap) {
303        originalLat = gmap.getCenter().lat();
304        originalLng = gmap.getCenter().lng();
305    });
306
307    this.GetCurrentLocation = function () {
308        var current_stateIdentifierAlert = stateIdentifier;
309
310        if (navigator.geolocation) {
311            $(".editableMap .notification").removeClass("show");
312            $(".editableMap .notificationCtn").hide();
313            $timeout.cancel(locationNotId);
314            $timeout.cancel(locationNotId1);
315            $timeout.cancel(locationNotId2);
316            locationNotId = locationNotId1 = locationNotId2 = undefined;
317
318            var GetLoc = function () {
319                navigator.geolocation.getCurrentPosition(
320                    function (position) {
321                        NgMap.getMap().then(function (gmap) {
322                            gmap.setZoom(16);
323                            gmap.setCenter({
324                                lat: position.coords.latitude,
325                                lng: position.coords.longitude
326                            });
327                        });
328                    },
329                    function (error) {
330                        //in mobile you need to enable your gps
331                        var errorMsg = "No permissions to access your location";
332                        if (window.cordova) {
333                            var isiOS = device.platform == "IOS" || device.platform == "ios" || device.platform == "iOS";
334                            if (isiOS) {
335                                errorMsg = "Please grant permission. Settings -> EasySell -> Location -> While Using the App";
336                            } else {
337                                errorMsg = "Please grant permission. Settings -> Apps -> EasySell -> Permissions -> Location";
338                            }
339                        }
340
341                        JSHelper.ShowAlert(errorMsg, current_stateIdentifierAlert);
342                    }, {
343                        enableHighAccuracy: true
344                    });
345
346            }
347            if (window.cordova) {
348                //check if location is enabled
349                cordova.plugins.diagnostic.isLocationEnabled(function (enabled) {
350                    if (enabled) {
351                        GetLoc();
352                    } else {
353                        var errorMsg = "Please enable your GPS in order to get your position"
354
355                        JSHelper.ShowAlert(errorMsg, current_stateIdentifierAlert);
356                    }
357
358                }, function (error) {
359
360                });
361            } else {
362                GetLoc();
363            }
364        }
365    }
366
367    this.GoToMarker = function () {
368        NgMap.getMap().then(function (gmap) {
369            gmap.setCenter({
370                lat: originalLat,
371                lng: originalLng
372            });
373        });
374    }
375
376});
377
378/**
379 * Caches the data in the local storage and updates the entries if they have changed.
380 */
381app.service('DataCaching', function ($http, $filter, $q, localStorageService, Session, SERVER_CONFIG) {
382    var _self = this;
383    this.InitializeDataCaching = function () {
384        var lStorage = localStorageService.get('staticData');
385
386        if (!lStorage) {
387            localStorageService.set('staticData', staticData);
388            lStorage = staticData;
389        }
390        Session.populateData(lStorage);
391    }
392
393    this.updateData = function (updatedSectionArr) {
394        var deferred = $q.defer();
395        $http({
396            method: 'GET',
397            url: SERVER_CONFIG.baseUrl + 'api/Settings/GetStaticData'
398        }).then(function (res) {
399            var currentSession = Session.retreiveData();
400            if (moment(res.data.staticDataLastChanged).isAfter(moment(currentSession.staticDataLastChanged))) {
401                //if (moment(res.data.staticImageLastChanged).isAfter(moment(currentSession.staticImageLastChanged))) {
402                angular.forEach(updatedSectionArr, function (value, key) {
403                    angular.forEach(res.data.offlineData[value], function (innerValue, innerKey) {
404                        var oldEntry = $filter('filter')(currentSession.offlineData[value], {
405                            id: innerValue.id
406                        }, false)[0];
407                        if (oldEntry != undefined && oldEntry != null && moment(innerValue.imgSrcDateModified).isSameOrBefore(moment(oldEntry.imgSrcDateModified))
407) {
408                            innerValue.imgSrc = oldEntry.imgSrc;
409                        }
410                    });
411                });
412                //}
413                localStorageService.set('staticData', res.data);
414                Session.populateData(res.data);
415            }
416            deferred.resolve();
417        });
418        return deferred.promise;
419    };
420});
421
422app.service('JSHelper', function ($timeout, $rootScope) {
423
424    var $win = $(window);
425    var $doc = $(document);
426
427    var currentClass = 'current';
428    var openClass = 'is-open';
429    var visibleClass = 'is-visible';
430
431    var selfService = this;
432
433    //#region Form Related
434    this.FormFieldsValidatePreSubmit = function () {
435        setTimeout(function () {
436            $("form input, form select, form textearea").focusout(function () {
437                $(this).valid();
438            });
439            $("[data-rule-landlinephone]").keyup(function () {
440                $(this).valid();
441            });
442            $("[data-rule-mobilephone]").keyup(function () {
443                $(this).valid();
444            });
445            $("form input, form select, form textearea").focusin(function () {
446                if (!$($(this).hasClass("[type='submit']"))) {
447                    var eltFormRow = $(this).parents(".form__row")[0];
448                    if (!selfService.IsElementInViewport(eltFormRow, 72, 43, 0, 0)) {
449                        $('html, body').animate({
450                            scrollTop: $(eltFormRow).offset().top - 72
451                        }, 1000);
452                    }
453                }
454            });
455        }, 0);
456    }
457
458    this.AlertForm = function (formElt, message, stateIdentifierReceived) {
459        if (stateIdentifierReceived == undefined) {
460            stateIdentifierReceived = stateIdentifier;
461        }
462
463        if (stateIdentifierReceived == stateIdentifier) {
464            if (message == "" || message == undefined) {
465                message = "Something went wrong"
466            }
467            $(formElt).find(".btn-wrapper").removeClass("loading");
468            $(".bar-alert .alert-mssg").text(message); //res.data.message
469            $(".bar-alert").addClass("show-alert");
470        }
471        // $timeout(function () {
472        //     $(".bar-alert").removeClass("show-alert");
473        //     $timeout(function () {
474        //         $(".bar-alert .alert-mssg").text("");
475        //     }, 100);
476        // }, errorMessageTimeout);
477    }
478
479    this.ResetForm = function () {
480        $(".bar-alert").removeClass("show-alert");
481        $timeout(function () {
482            $(".bar-alert .alert-mssg").text("");
483        }, 100);
484    }
485
486    this.AlertInitialize = function () {
487        $(".main-wrapper").click(function (e) {
488            var clicked = e.target;
489            if (!$(clicked).hasClass("form-btn") && !$(clicked).hasClass("btn") && $(".bar-alert").hasClass("show-alert") && !$(clicked).hasClass("input-label")) {
490                $(".bar-alert").removeClass("show-alert");
491                $timeout(function () {
492                    if ($(".bar-alert").hasClass("show-alert")) {
493                        $(".bar-alert").removeClass("show-alert");
494                        $timeout(function () {
495                            $(".bar-alert .alert-mssg").text("");
496                        }, 100);
497                    }
498                    $(".bar-alert .alert-mssg").text("");
499                }, 100);
500            }
501        })
502    }
503
504    //#endregion
505
506    this.isMobileDevice = function () {
507        var ua = navigator.userAgent;
508        if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(ua)) {
509            return true;
510        } else {
511            return false;
512        }
513    }
514
515    this.ResetAlert = function () {
516        $(".bar-alert").removeClass("show-alert");
517        $timeout(function () {
518            $(".bar-alert .alert-mssg").text("");
519        }, 100);
520    }
521
522    this.ShowAlert = function (message, stateIdentifierReceived) {
523        if (stateIdentifierReceived == undefined) {
524            stateIdentifierReceived = stateIdentifier;
525        }
526        if (stateIdentifierReceived == stateIdentifier) {
527            if (message == "" || message == undefined) {
528                message = "Something went wrong"
529            }
530            $(".bar-alert .alert-mssg").text(message);
531            $(".bar-alert").addClass("show-alert");
532        }
533        // $timeout(function () {
534        //     // $(".bar-alert").removeClass("show-alert");
535        //     $timeout(function () {
536        //         // $(".bar-alert .alert-mssg").text("");
537        //         $("#verificationCode").val("");
538        //     }, 100);
539        // }, errorMessageTimeout);
540    }
541
542    this.GenerateStateIdentifier = function (toStateName) {
543        var desired = toStateName.replace('.', "");
544        var randNum = Math.floor(Math.random() * 200) + 1;
545        stateIdentifier = desired + randNum;
546        return stateIdentifier;
547    }
548
549    this.AssignClassToBody = function (toStateName) {
550        var desired = toStateName.name.replace('app', "").replace('.', "");
551        $("body").removeClass(function (index, className) {
552            return (className.match(/(^|\s)state-\S+/g) || []).join(' ');
553        });
554        $("body").addClass("state-" + stateName);
555    }
556
557    this.Init_Panel = function () {
558        $('.js-panel-toggle').on('click submit', function (event) {
559            event.preventDefault();
560
561            var $toggler = $(this);
562            var $panel = $($toggler.data('target'));
563            var hash = '';
564
565            if (typeof $panel.data('hash') !== 'undefined') {
566                hash = '#' + $panel.data('hash');
567            };
568
569            if ($toggler.hasClass('js-panel-close') || $toggler.hasClass('is-' + currentClass)) {
570                hash = '';
571            };
572
573            history.pushState(null, null, window.location.pathname + hash);
574
575            $win.trigger('popstate');
576
577            $toggler.closest('.' + openClass).removeClass(openClass);
578        });
579
580        $win.on('load popstate', function (event) {
581            var hash = this.location.hash.slice(1);
582            var $element = $('[data-hash="' + hash + '"]');
583            var $toggler = $('[data-target="#' + hash + '"]');
584
585            $('.is-' + currentClass).removeClass('is-' + currentClass);
586            $('.' + visibleClass).removeClass(visibleClass);
587
588            if ($element.length) {
589                $element.addClass(visibleClass);
590                $toggler.addClass('is-' + currentClass);
591            };
592        });
593    }
594
595    this.OpenPanel = function (PanelId, event) {
596        if (event) {
597            event.preventDefault();
598        }
599
600        var triggerPanel = $("[data-target='" + PanelId + "']");
601        $(triggerPanel).addClass("is-current");
602
603        var modalPanel = $(PanelId);
604        $(modalPanel).addClass("is-visible");
605        $(modalPanel).find('.js-panel-close').addClass("is-current");
606    }
607
608    this.ClosePanel = function (PanelId, event) {
609        if (event) {
610            event.preventDefault();
611        }
612
613        if (browserI != undefined) {
614            browserI.close();
615            browserI = undefined;
616        }
617        var triggerPanel = $("[data-target='" + PanelId + "']");
618        $(triggerPanel).removeClass("is-current");
619
620        var modalPanel = $(PanelId);
621        $(modalPanel).removeClass("is-visible");
622        $(modalPanel).find('.js-panel-close').removeClass("is-current");
623    }
624
625    this.CloseAllPanels = function () {
626        $(".modal-overlay").click()
627    }
628
629    this.IsElementInViewport = function (el, topGap, bottomGap, leftGap, rightGap) {
630
631        //special bonus for those using jQuery
632        if (typeof jQuery === "function" && el instanceof jQuery) {
633            el = el[0];
634        }
635
636        var rect = el.getBoundingClientRect();
637
638        var topLimit = topGap,
639            bottomLimit = (window.innerHeight || document.documentElement.clientHeight) - bottomGap,
640            leftLimit = leftGap,
641            rightLimit = (window.innerWidth || document.documentElement.clientWidth) - leftGap;
642
643        return (
644            rect.top >= topLimit &&
645            rect.left >= leftLimit &&
646            rect.bottom <= bottomLimit && /*or $(window).height() */
647            rect.right <= rightLimit /*or $(window).width() */
648        );
649    }
650
651    this.GoToState = function (toState, stateParams, transitionParams) {
652        location.href = toState;
653    }
654
655    this.ShowNotification = function (params) {
656        $rootScope.$broadcast("opennotification", params);
657        $("#noPoints").modal("show");
658    }
659    this.PrintElement = function (obj, isRtlLang) {
660
661        //#region Check if multiple languages and assign direction
662        var hasRtlDirection = false;
663
664        if (isRtlLang === true) {
665            hasRtlDirection = true;
666        }
667        //#endregion
668
669        var contents = obj.html();
670        var frame1 = $('<iframe />');
671        frame1[0].name = "frame1";
672
673        //#region Real iframe css
674        frame1.css({
675            "position": "absolute",
676            "top": "0px",
677            "left": "0px",
678            "z-index": "150",
679            "width": "1024px",
680            "height": "1000px",
681        });
682        //#endregion
683
684        //#region Testing iframe css
685        // frame1.css({
686        //     "position": "absolute",
687        //     "top": "0px",
688        //     "left": "0px",
689        //     "width": "1024px",
690        //     "height": "1000px",
691        //     "z-index": "2000"
692        // });
693        //#endregion
694
695        $("body").append(frame1);
696        var frameDoc = frame1[0].contentWindow ? frame1[0].contentWindow : frame1[0].contentDocument.document ? frame1[0].contentDocument.document : frame1[0].contentDocument;
697        frameDoc.document.open();
698        //Create a new HTML document.
699        frameDoc.document.write('<html><head><title>' + $("title").text() + '</title>');
700        //Append the external CSS file.
701        frameDoc.document.write($("head").html());
702
703        //#region Create the DIV container
704        // var orderReceiptContainer = document.createElement("div");
705        // // orderReceiptContainer.classList.add("order-receipt-print");
706        // if (hasRtlDirection) {
707        //     orderReceiptContainer.classList.add("direction-rtl");
708        // }
709        // orderReceiptContainer.innerHTML = contents;
710        //#endregion
711
712        //#region Append the DIV contents.
713
714        // frameDoc.document.write('</head><body>'+'<main class="order-summary"><div class="order-content-wrap"><div class="container"><div class="row"><div class="col-md-12"><div class="order-content" style="margin:0;border:none;">');
715        // frameDoc.document.write(contents);
716        // frameDoc.document.write('</div></div></div></div></div></main></body></html>');
717        //--------------------------------------------------------------------------------------------
718        frameDoc.document.write('</head><body><div class="dontation-print" style="margin:0;border:none;">');
719        frameDoc.document.write(contents);
720        frameDoc.document.write('</div><script>setTimeout(function(){window.print();},200)</script></body></html>');
721        //#endregion
722
723        frameDoc.document.close();
724        setTimeout(function () {
725            // window.frames["frame1"].focus();
726            // window.frames["frame1"].print();
727            frame1.remove();
728        }, 2000);
729    }
730
731    this.InitFacebook = function () {
732        if ((typeof FB === 'undefined')) {
733            window.fbAsyncInit = function () {
734                FB.init({
735                    appId: '1916228261804868',
736                    status: false,
737                    cookie: true,
738                    xfbml: true
739                });
740                FB.Event.subscribe('auth.authResponseChange', function (response) {});
741            };
742            // Load the SDK asynchronously
743            (function (d) {
744                var js, id = 'facebook-jssdk',
745                    ref = d.getElementsByTagName('script')[0];
746                if (d.getElementById(id)) {
747                    return;
748                }
749                js = d.createElement('script');
750                js.id = id;
751                js.async = true;
752                js.src = 'https://connect.facebook.net/en_US/all.js';
753                ref.parentNode.insertBefore(js, ref);
754            }(document));
755        }
756    };
757
758    //------------------------------------------------------------------------------------------------------------------//
759
760    //#region Specific to LMT
761    var $win = $(window);
762    var $doc = $(document);
763
764
765    this.CloseMenu = function () {
766        console.log("closing");
767        $('.drowpdown-bg').css('height', '0');
768        $('.navbar-collapse').removeClass('show');
769        $('.js-opencart').removeClass('cart-open');
770    }
771
772    this.CloseAllOpenenedElements = function () {
773        $('.header-menu .js-show-sub').removeClass('active').parents('.menu-item').siblings('.menu-item').find('.js-show-sub').addClass('active');
774        $('.header-menu .overlay').removeClass('active');
775  
776        if($('.header-menu .js-show-sub').hasClass('active')) {
777          $('.left-menu').removeClass('dim');
778        } else {
779        //   $('.left-menu').addClass('dim');
780        }
781        $('body').removeClass('overflow-hidden custom-modal-open no-scroll');
782        $('.header-overlay').removeClass('overlay-show');
783        $('.sidebar').removeClass('sidebar-show');
784        $('.header .header-menu').removeClass('menu-show');
785        $('.header .link').parent().siblings().removeClass('unbordered');
786        $('.header .dropdown-custom').removeClass('dropdown-show');
787        $('.header .bordered .link').removeClass('active');
788        $('.header .holder-search').removeClass('holder-search-show');
789        $('.header .search .search-close').css({'position':'absolute', 'left':'0', 'right':'0', 'z-index':'1', 'margin':'auto', 'width':'0', 'height':'0'});
790        $('.header .search .search-open').css({'position':'initial', 'z-index':'6', 'width':'initial', 'height':'initial'});
791        $('.js-link-search').parent().find('.search-close').removeClass('active');
792        $('.js-link-close').parent().find('a').removeClass('active');
793        $('main, footer').removeClass('bg-overlay');
794        $('.left-menu').removeClass('dim');
795        $('#rate-login-modal').modal('hide');
796    }
797
798    this.OpenSidebarById = function (sidebarId, buttonClass) {
799        
800            $('#rate-login-modal').modal('hide');
801            $(sidebarId).addClass('sidebar-show');
802            $(buttonClass).addClass('active').parent().siblings().removeClass('unbordered');
803            $(buttonClass).parent().siblings().find('.link').removeClass('active');
804            $(buttonClass).parent().addClass('unbordered').next().addClass('unbordered');
805            $('.header-overlay').addClass('overlay-show');
806            // event.preventDefault();
807            // menuLinkBg(this);
808            mainAndFooterOverlay();
809            // e.preventDefault(); 
810            // customScrollFix();
811            $('body').removeClass('no-scroll');
812
813    } 
814
815    this.CloseSideBarById = function (sidebarId) {
816        var sidebarID = '#' + sidebarId;
817        var parent = $(sidebarID); //.parents('.sidebarWrapper');
818        $('html, body').removeClass('overflow-hidden lock-body');
819        // $('.overlay-on-open').removeClass('active-dark');
820        $('.header-overlay').removeClass('active-dark');
821        $('.user-links .nav-item .nav-link').removeClass('active');
822        if ($('body').hasClass('direction-ltr')) {
823            // $(parent).toggle('slide', {
824            //     direction: "right"
825            // }, 500);
826            $(sidebarID).removeClass("slidedIn");
827        } else {
828            // $(parent).toggle('slide', {
829            //     direction: "left"
830            // }, 500);
831            $(sidebarID).removeClass("slidedIn");
832        }
833    }
834
835    this.SidebarShowSuccess = function (sidebarId) {
836        var sidebarID = '#' + sidebarId;
837        var parent = $(sidebarID);
838
839        $(parent).addClass("show-success-message");
840    }
841
842    this.OpenMenu = function () {
843        $('.header-toggler-wrapper .btn-toggler').toggleClass('is-active open');
844        $('.header-overlay').toggleClass('active-dark');
845        $('html,body').toggleClass('overflow-hidden lock-body');
846        $('.header-toggler-wrapper').toggleClass('sidebar-open');
847        $('.header-sidebar').toggle('slide', {
848            direction: "left"
849        }, 500);
850    }
851
852    var _navbarFunctions = function () {
853        //Scroll to Display Div
854
855        // if ($(window).width() >= 768) {
856
857        // }
858
859
860
861        $('main, .header-toggler-wrapper .btn-toggler, .c-nav-link').unbind('click').click(function (e) {
862            $('.dropdown-category').removeClass('opened');
863            $('.overlay-on-open').removeClass('active-light');
864            $('.nav-item').removeClass('active');
865            $('.user-links .nav-link').removeClass('active');
866        });
867
868        $('.user-links .dropdown').on('show.bs.dropdown', function () {
869            $(this).find('.dropdown-menu').fadeIn(300).toggleClass('show');
870            $('.overlay-on-open').fadeIn(300).addClass('active-light');
871            $('.dropdown-category').removeClass('opened');
872            $('.nav-item').removeClass('active');
873        });
874
875        $('.user-links .nav-item').click(function () {
876            var navItemSiblings = $(this).siblings().find('.nav-link').removeClass('active');
877            $(this).find('.nav-link').fadeIn(300).toggleClass('active');
878            if ($('.user-links .nav-item .nav-link').hasClass('active')) {
879                $(this).removeClass('active');
880                $('.user-links .dropdown').removeClass('show');
881            }
882        });
883
884        $('.js-login-dropdown .dropdown-toggle, .js-language-dropdown .dropdown-toggle, .js-signin-dropdown .dropdown-toggle, .js-sidebar-toggler').on('click', function () {
885            $('.dropdown-menu').fadeOut(300).removeClass('show');
886            $('.overlay-on-open').fadeOut(300).removeClass('active-light');
887            // $('.user-links .nav-item .nav-link').fadeOut(300).removeClass('active');
888            // $('.dropdown-toggle').removeClass('active');
889        });
890
891        $('main').on('click', function () {
892            $('.dropdown-menu').fadeOut(300).removeClass('show');
893            $('.nav-item').removeClass('active');
894            $('.overlay-on-open').fadeOut(300).removeClass('active-light');
895            $('.user-links .nav-item .nav-link').removeClass('active');
896        });
897
898        //On scroll
899        $(window).on('scroll', function () {
900            if ($(window).scrollTop() > 10) {
901                $('.header').addClass('fixed-header');
902                $('.js-navbar-brand-img').attr('src', '/assets/images/logo-white.png');
903            } else {
904                $('.header').removeClass('fixed-header');
905                $('.js-navbar-brand-img').attr('src', '/assets/images/logo.png');
906            }
907        });
908
909        //for sidebar menu
910        $('.header-toggler-wrapper .btn-toggler').on('click', function () {
911            $('.header-toggler-wrapper .btn-toggler').toggleClass('is-active open');
912            $('.header-overlay').toggleClass('active-dark');
913            $('html,body').toggleClass('overflow-hidden lock-body');
914            $('.header-toggler-wrapper').toggleClass('sidebar-open');
915            $('.header-sidebar').toggle('slide', {
916                direction: "left"
917            }, 500);
918        });
919
920        $('.js-sidebar-toggler, .js-close-sm').click(function () {
921            $('.header-sidebar').hide('slide', {
922                direction: "left"
923            }, 500);
924            $('.header-toggler-wrapper .btn-toggler').removeClass('is-active open');
925            $('.dropdown-category').removeClass('opened');
926            $('.header-overlay').removeClass('active-dark');
927            $('html,body').removeClass('overflow-hidden lock-body');
928        });
929
930        // for responsive
931        if ($(window).width() <= 767) {
932            $('.mobile-sidebar .header-sidebar-main-link').addClass('js-category-mobile');
933            $('.on-mobile .dropdown').on('show.bs.dropdown', function () {
934                $(this).find('.dropdown-menu').fadeIn(300).addClass('show');
935                $('.dropdown-category').removeClass('opened');
936                $('.nav-item').removeClass('active');
937            });
938        }
939
940        $('.js-category-mobile').unbind('click').click(function (e) {
941            var category = $(this).data('category-mobile');
942            var categoryID = "#" + category;
943            if ($(window).width() <= 767) {
944
945                console.log(categoryID);
946
947                $('.header-sidebar').toggle('slide', {
948                    direction: "left"
949                }, 400);
950
951                $(categoryID).addClass('opened');
952
953                e.preventDefault();
954            } else {
955                $('.header-sidebar-main-link').removeClass('js-category-mobile');
956                $('.js-category-mobile').removeData('category-mobile');
957                $(categoryID).removeClass('opened');
958            }
959        });
960
961        $('.js-back-menu').click(function () {
962            $('.header-overlay').removeClass('active-dark');
963            $('.dropdown-category').hide('slide', {
964                direction: "left"
965            }, 400, function () {
966                $(this).removeClass('opened');
967            });
968            $('.header-sidebar').toggle('slide', {
969                direction: "left"
970            }, 400);
971        });
972
973
974        if ($(window).width() >= 768) {
975            $('.on-mobile .dropdown-menu').hide();
976            $('.on-mobile .dropdown-menu').removeClass('show');
977        }
978
979        $('.header-sidebar').unbind('click').click(function (e) {
980            if ($(e.target).closest('.dropdown-menu').length === 0) {
981                $('.dropdown-menu').fadeOut(300).removeClass('show');
982            }
983        });
984
985
986        //RESIZE
987        $(window).resize(function () {
988            if ($(window).width() >= 768) {
989                $('main').trigger('click');
990                $('.header-overlay').removeClass('active-dark');
991                $('.header-toggler-wrapper .btn-toggler').removeClass('is-active open');
992                $('html,body').removeClass('overflow-hidden lock-body');
993                $('.header-toggler-wrapper').removeClass('sidebar-open');
994                $('.header-sidebar').hide('slide', {
995                    direction: "left"
996                }, 400);
997                $('.on-mobile .dropdown-menu').hide();
998                $('.on-mobile .dropdown-menu').removeClass('show');
999            }
1000
1001            if ($(window).width() <= 767) {
1002                $('.header-sidebar-main-link').addClass('js-category-mobile');
1003                $('.on-mobile .dropdown').on('show.bs.dropdown', function () {
1004                    $(this).find('.dropdown-menu').fadeIn(300).addClass('show');
1005                    $('.dropdown-category').removeClass('opened');
1006                    $('.nav-item').removeClass('active');
1007                    if (!$(this).find('.dropdown-menu').hasClass('show')) {
1008                        $('.log-in-menu').css('z-index', '-1');
1009                    }
1010                });
1011            }
1012
1013            $('.js-category-mobile').unbind('click').click(function (e) {
1014                var category = $(this).data('category-mobile');
1015                var categoryID = "#" + category;
1016                if ($(window).width() <= 767) {
1017
1018                    console.log(categoryID);
1019
1020                    $('.header-sidebar').toggle('slide', {
1021                        direction: "left"
1022                    }, 400);
1023
1024                    $(categoryID).addClass('opened');
1025
1026                    e.preventDefault();
1027                } else {
1028                    $('.header-sidebar-main-link').removeClass('js-category-mobile');
1029                    $('.js-category-mobile').removeData('category-mobile');
1030                    $(categoryID).removeClass('opened');
1031                    // $('main').trigger('click');
1032                }
1033            });
1034        });
1035    }
1036
1037    var _sidebar = function () {
1038        $(window).on('load', function () {
1039            //open sidebar
1040            $('.js-sidebar-toggler').on('click', function () {
1041                var sidebarID = '#' + $(this).data('open');
1042
1043                if ($('body').hasClass('direction-ltr')) {
1044                    $(sidebarID).toggle('slide', {
1045                        direction: "right"
1046                    }, 500);
1047                } else {
1048                    $(sidebarID).toggle('slide', {
1049                        direction: "left"
1050                    }, 500);
1051                }
1052
1053                $(sidebarID).siblings('.sign-in-sidebar').hide();
1054                $('html,body').addClass('overflow-hidden lock-body');
1055                // $('.overlay-on-open').addClass('active-dark');
1056                $('.header-overlay').addClass('active-dark');
1057                $('.dropdown-category').removeClass('opened');
1058                $('.overlay-on-open').removeClass('active-light');
1059                $('.nav-item').removeClass('active');
1060                $('.log-in-menu').removeClass('show');
1061                $('.user-links .dropdown .dropdown-toggle').removeClass('active');
1062                // $('.user-links .nav-item .nav-item').removeClass('active');
1063            });
1064
1065            //close sidebar
1066            $('.sidebar-close').on('click', function () {
1067                var sidebarID = '#' + $(this).data('close');
1068                var parent = $(this).parents('.sign-in-sidebar');
1069                $('html, body').removeClass('overflow-hidden lock-body');
1070                // $('.overlay-on-open').removeClass('active-dark');
1071                $('.header-overlay').removeClass('active-dark');
1072                $('.user-links .nav-item .nav-link').removeClass('active');
1073                if ($('body').hasClass('direction-ltr')) {
1074                    $(parent).toggle('slide', {
1075                        direction: "right"
1076                    }, 500);
1077                } else {
1078                    $(parent).toggle('slide', {
1079                        direction: "left"
1080                    }, 500);
1081                }
1082            });
1083        });
1084    }
1085
1086    this.CloseAllTabs = function () {
1087
1088        // event.preventDefault();
1089    }
1090
1091    this.Init_AccountIcon = function () {
1092
1093    }
1094
1095    this.InitializeHeader = function () {
1096        //Scroll to Display Div
1097
1098        // if ($(window).width() >= 768) {
1099        $('.navbar-nav .js-with-dropdown').on('mouseenter', function (e) {
1100
1101            // var navItem = $(this).parents('.nav-item');
1102            var navItemSiblings = $(this).siblings('.nav-item');
1103            $('.js-with-dropdown').addClass('active');
1104            navItemSiblings.removeClass('active');
1105
1106            var getID = $(this).find('.nav-link').data('id');
1107            $('#' + getID + '.dropdown-category').addClass('opened');
1108            $('.dropdown-category').not('#' + getID + '').removeClass('opened');
1109
1110            if ($('.dropdown-category').hasClass('opened')) {
1111                $('.overlay-on-open').show().addClass('active-light');
1112            } else {
1113                $('.overlay-on-open').removeClass('active-light');
1114            }
1115
1116            $('.dropdown-menu').fadeOut(300).removeClass('show');
1117        });
1118        // }
1119
1120        $('.category-links .nav-item:not(.js-with-dropdown)').on('mouseenter', function () {
1121            // var navItem = $(this).parents('.nav-item');
1122            var navItemSiblings = $(this).siblings('.nav-item');
1123            $('.dropdown-category').removeClass('opened');
1124            $('.overlay-on-open').removeClass('active-light');
1125            $('.category-links .nav-item').addClass('active');
1126            navItemSiblings.removeClass('active');
1127            $('.dropdown-menu').fadeOut(300).removeClass('show');
1128            $('.dropdown-toggle').removeClass('active');
1129            // $('.user-links .dropdown').removeClass('show');
1130        });
1131
1132        $('.category-links .nav-item:not(.js-with-dropdown)').on('mouseleave', function () {
1133            $('.category-links .nav-item').removeClass('active');
1134        });
1135
1136        $('main, .header-toggler-wrapper .btn-toggler, .c-nav-link').unbind('click').click(function (e) {
1137            $('.dropdown-category').removeClass('opened');
1138            $('.overlay-on-open').removeClass('active-light');
1139            $('.nav-item').removeClass('active');
1140            $('.user-links .nav-link').removeClass('active');
1141        });
1142
1143        $('.user-links .dropdown').on('show.bs.dropdown', function () {
1144            $(this).find('.dropdown-menu').fadeIn(300).toggleClass('show');
1145            $('.overlay-on-open').fadeIn(300).addClass('active-light');
1146            $('.dropdown-category').removeClass('opened');
1147            $('.nav-item').removeClass('active');
1148        });
1149
1150        $('.user-links .nav-item').click(function () {
1151            var navItemSiblings = $(this).siblings().find('.nav-link').removeClass('active');
1152            $(this).find('.nav-link').fadeIn(300).toggleClass('active');
1153            if ($('.user-links .nav-item .nav-link').hasClass('active')) {
1154                $(this).removeClass('active');
1155                $('.user-links .dropdown').removeClass('show');
1156            }
1157        });
1158
1159        $('.js-login-dropdown .dropdown-toggle, .js-language-dropdown .dropdown-toggle, .js-signin-dropdown .dropdown-toggle, .js-sidebar-toggler').on('click', function () {
1160            $('.dropdown-menu').fadeOut(300).removeClass('show');
1161            $('.overlay-on-open').fadeOut(300).removeClass('active-light');
1162            // $('.user-links .nav-item .nav-link').fadeOut(300).removeClass('active');
1163            // $('.dropdown-toggle').removeClass('active');
1164        });
1165
1166        $('main').on('click', function () {
1167            $('.dropdown-menu').fadeOut(300).removeClass('show');
1168            $('.nav-item').removeClass('active');
1169            $('.overlay-on-open').fadeOut(300).removeClass('active-light');
1170            $('.user-links .nav-item .nav-link').removeClass('active');
1171        });
1172
1173        //On scroll
1174        $(window).on('scroll', function () {
1175            if ($(window).scrollTop() > 10) {
1176                $('.header').addClass('fixed-header');
1177                $('.js-navbar-brand-img').attr('src', '/assets/images/logo-white.png');
1178            } else {
1179                $('.header').removeClass('fixed-header');
1180                $('.js-navbar-brand-img').attr('src', '/assets/imag
1180es/logo.png');
1181            }
1182        });
1183
1184        //for sidebar menu
1185        $('.header-toggler-wrapper .btn-toggler').on('click', function () {
1186            $('.header-toggler-wrapper .btn-toggler').toggleClass('is-active open');
1187            $('.header-overlay').toggleClass('active-dark');
1188            $('html,body').toggleClass('overflow-hidden lock-body');
1189            $('.header-toggler-wrapper').toggleClass('sidebar-open');
1190            $('.header-sidebar').toggle('slide', {
1191                direction: "left"
1192            }, 500);
1193        });
1194
1195        $('.js-sidebar-toggler, .js-close-sm').click(function () {
1196            $('.header-sidebar').hide('slide', {
1197                direction: "left"
1198            }, 500);
1199            $('.header-toggler-wrapper .btn-toggler').removeClass('is-active open');
1200            $('.dropdown-category').removeClass('opened');
1201            $('.header-overlay').removeClass('active-dark');
1202            $('html,body').removeClass('overflow-hidden lock-body');
1203        });
1204
1205        // for responsive
1206        if ($(window).width() <= 767) {
1207            $('.mobile-sidebar .header-sidebar-main-link').addClass('js-category-mobile');
1208            $('.on-mobile .dropdown').on('show.bs.dropdown', function () {
1209                $(this).find('.dropdown-menu').fadeIn(300).addClass('show');
1210                $('.dropdown-category').removeClass('opened');
1211                $('.nav-item').removeClass('active');
1212            });
1213        }
1214
1215        $('.js-category-mobile').unbind('click').click(function (e) {
1216            var category = $(this).data('category-mobile');
1217            var categoryID = "#" + category;
1218            if ($(window).width() <= 767) {
1219
1220                console.log(categoryID);
1221
1222                $('.header-sidebar').toggle('slide', {
1223                    direction: "left"
1224                }, 400);
1225
1226                $(categoryID).addClass('opened');
1227
1228                e.preventDefault();
1229            } else {
1230                $('.header-sidebar-main-link').removeClass('js-category-mobile');
1231                $('.js-category-mobile').removeData('category-mobile');
1232                $(categoryID).removeClass('opened');
1233            }
1234        });
1235
1236        $('.js-back-menu').click(function () {
1237            $('.header-overlay').removeClass('active-dark');
1238            $('.dropdown-category').hide('slide', {
1239                direction: "left"
1240            }, 400, function () {
1241                $(this).removeClass('opened');
1242            });
1243            $('.header-sidebar').toggle('slide', {
1244                direction: "left"
1245            }, 400);
1246        });
1247
1248
1249        if ($(window).width() >= 768) {
1250            $('.on-mobile .dropdown-menu').hide();
1251            $('.on-mobile .dropdown-menu').removeClass('show');
1252        }
1253
1254        $('.header-sidebar').unbind('click').click(function (e) {
1255            if ($(e.target).closest('.dropdown-menu').length === 0) {
1256                $('.dropdown-menu').fadeOut(300).removeClass('show');
1257            }
1258        });
1259
1260
1261        //RESIZE
1262        $(window).resize(function () {
1263            if ($(window).width() >= 768) {
1264                $('main').trigger('click');
1265                $('.header-overlay').removeClass('active-dark');
1266                $('.header-toggler-wrapper .btn-toggler').removeClass('is-active open');
1267                $('html,body').removeClass('overflow-hidden lock-body');
1268                $('.header-toggler-wrapper').removeClass('sidebar-open');
1269                $('.header-sidebar').hide('slide', {
1270                    direction: "left"
1271                }, 400);
1272                $('.on-mobile .dropdown-menu').hide();
1273                $('.on-mobile .dropdown-menu').removeClass('show');
1274            }
1275
1276            if ($(window).width() <= 767) {
1277                $('.header-sidebar-main-link').addClass('js-category-mobile');
1278                $('.on-mobile .dropdown').on('show.bs.dropdown', function () {
1279                    $(this).find('.dropdown-menu').fadeIn(300).addClass('show');
1280                    $('.dropdown-category').removeClass('opened');
1281                    $('.nav-item').removeClass('active');
1282                    if (!$(this).find('.dropdown-menu').hasClass('show')) {
1283                        $('.log-in-menu').css('z-index', '-1');
1284                    }
1285                });
1286            }
1287
1288            $('.js-category-mobile').unbind('click').click(function (e) {
1289                var category = $(this).data('category-mobile');
1290                var categoryID = "#" + category;
1291                if ($(window).width() <= 767) {
1292
1293                    console.log(categoryID);
1294
1295                    $('.header-sidebar').toggle('slide', {
1296                        direction: "left"
1297                    }, 400);
1298
1299                    $(categoryID).addClass('opened');
1300
1301                    e.preventDefault();
1302                } else {
1303                    $('.header-sidebar-main-link').removeClass('js-category-mobile');
1304                    $('.js-category-mobile').removeData('category-mobile');
1305                    $(categoryID).removeClass('opened');
1306                    // $('main').trigger('click');
1307                }
1308            });
1309        });
1310    }
1311
1312    this.EmptyAndPristineForm = function (formId) {
1313        var form = $("form#" + formId);
1314
1315        $(form).find("label.form-error").remove();
1316        $(form).find(".form-group.form-error").remove("form-error");
1317
1318        $(form).find(".btn-wrapper").removeClass("loading");
1319
1320        var parent = $(form).parents(".sidebarWrapper");
1321
1322        $(parent).removeClass("show-success-message");
1323    }
1324
1325    //#endregion
1326});
1327
1328app.service('Filters', function ($location) {
1329
1330    this.ConvertQueryStringToObject = function (params) {
1331        var tempObjecty = {};
1332        if (params != null && params != '') {
1333            var paramsArray = params.split(',');
1334            angular.forEach(paramsArray, function (value, key) {
1335                tempObjecty[value] = true;
1336            });
1337        }
1338        return tempObjecty;
1339    };
1340
1341    this.ConvertObjectToQueryString = function (params) {
1342        var str = '';
1343        var inputObject = angular.copy(params);
1344        for (var key in inputObject) {
1345            if (!inputObject.hasOwnProperty(key) || typeof inputObject[ke
1345y] === 'function') {
1346                continue;
1347            }
1348            if (Array.isArray(inputObject[key])) { // an object and an array are objects
1349                str += (str == '' ? '' : '&') + key + '=' + encodeURIComponent(inputObject[key].join());
1350            } else if (typeof inputObject[key] === 'object') {
1351                var subStr = "";
1352                for (var subKey in inputObject[key]) {
1353                    if (inputObject[key][subKey] == true) {
1354                        if (key == "prices") {
1355                            var pricesArray = subKey.split('_');
1356                            str += (str == '' ? '' : '&') + 'pricefrom=' + pricesArray[0] + '&' + 'priceto=' + pricesArray[1];
1357                        } else {
1358                            subStr += (subStr == '' ? '' : ',') + encodeURIComponent(subKey);
1359                        }
1360                    }
1361                }
1362                str += (str == '' ? '' : '&') + key + '=' + subStr;
1363            } else {
1364                str += (str == '' ? '' : '&') + key + '=' + encodeURIComponent(inputObject[key]);
1365            }
1366        }
1367        str = str.replace(/[^=&]+=(&|$)/g, "").replace(/&$/, "");
1368        if (str.indexOf("&") == 0) {
1369            str = str.substring(1, str.length);
1370        }
1371        return str;
1372    };
1373
1374    this.UpdateUrlSearch = function (params) {
1375        var inputObject = angular.copy(params);
1376        angular.forEach(inputObject, function (value, key) {
1377
1378            if (typeof value === 'object') {
1379                var subStr = "";
1380                angular.forEach(value, function (subValue, subKey) {
1381                    if (subValue == true) {
1382                        subStr += (subStr == '' ? '' : ',') + encodeURIComponent(subKey);
1383                    }
1384                });
1385                value = subStr;
1386            }
1387
1388            if (value === "" || value === null || (key == 'page' && value == 1) || key == 'pageSize') {
1389                if (key == "prices") {
1390                    $location.search('pricefrom', null);
1391                    $location.search('priceto', null);
1392                } else {
1393                    $location.search(key, null);
1394                }
1395            } else {
1396                if (key == "prices") {
1397                    var pricesArray = value.split('_');
1398                    $location.search('pricefrom', pricesArray[0]);
1399                    $location.search('priceto', pricesArray[1]);
1400                } else {
1401                    $location.search(key, value);
1402                }
1403            }
1404        });
1405    };
1406});
1407
1408app.service('ZendeskHelper', function ($timeout, $rootScope) {
1409    this.InitChat = function () {
1410        setTimeout(function () {
1411            $zopim(function () {
1412                $zopim.livechat.hideAll();
1413                $zopim.livechat.window.onHide(function () {
1414                    $zopim.livechat.hideAll();
1415                });
1416            });
1417        }, 500);
1418    }
1419
1420    this.LoginChat = function (userInfos) {
1421        $zopim(function () {
1422            $zopim.livechat.set({
1423                language: 'en',
1424                name: userInfos.firstName + ' ' + userInfos.lastName,
1425                email: userInfos.userName,
1426                phone: userInfos.mobile
1427            });
1428        });
1429    }
1430
1431    this.ClearChat = function () {
1432        $zopim(function () {
1433            $zopim.livechat.clearAll();
1434        });
1435    }
1436})
1437
1438app.service('FormService', function (JSHelper) {
1439
1440    var selfService = this;
1441
1442    this.HideFooterWhenKeyboardOpens = function () {
1443        if (device != undefined) {
1444            if (cordova.plugins.Keyboard) {
1445                window.addEventListener('native.keyboardshow', function () {
1446                    $(".wrapper").addClass("footer-removed");
1447                    $("[name='footer'] .nav-app").hide();
1448                });
1449                window.addEventListener('native.keyboardhide', function () {
1450                    $(".wrapper").removeClass("footer-removed");
1451                    $("[name='footer'] .nav-app").show();
1452                });
1453            }
1454        }
1455    }
1456
1457    this.ScrollFieldOnFocusIn = function () {
1458        setTimeout(function () {
1459            $("form input, form select, form textearea").focusin(function () {
1460                if (!$($(this).hasClass("[type='submit']"))) {
1461                    var eltFormRow = $(this).parents(".form__row")[0];
1462                    try {
1463
1464                        if (!JSHelper.IsElementInViewport(eltFormRow, 38, 53, 0, 0)) {
1465                            $('html, body').animate({
1466                                scrollTop: $(eltFormRow).offset().top - 72
1467                            }, 1000);
1468                        }
1469                    } catch (err) {
1470                        console.log("FormService --> ScrollFieldOnFocusIn --> err: " + err);
1471                    }
1472
1473                }
1474            })
1475        }, 0);
1476    }
1477
1478    /**
1479     * Notify User if changes have been made to a form before changing state.
1480     *
1481     * @param {Array}  formsToIgnore Forms to ignore when checking if changes have been made eg: login.
1482     * @param {Array}  formsToAlwaysNotify Forms to always notify user upon changing states even if no changes have been made eg: upload list of document as seperate state.
1483     * @returns {bool} Whether the user should be notified when leaving form or not
1484     */
1485    this.ChangesToForm = function (formsToIgnore, formsToAlwaysNotify) {
1486
1487        var formsInPage = $("form");
1488        var notifyUser = false;
1489
1490        $(formsInPage).each(function (index) {
1491            var this_form = formsInPage[index];
1492            var this_form_id = $(this_form).attr("id");
1493
1494            console.log(this_form);
1495            if ($(this_form).hasClass("ng-dirty") && !$(this_form).hasClass("ng-submitted")) {
1496                //Is Form Beteen forms to ignore
1497                if (formsToIgnore.indexOf(this_form_id) != -1) {
1498                    notifyUser = notifyUser || false;
1499                } else {
1500                    notifyUser = notifyUser || true;
1501                }
1502            } else if ((!$(this_form).hasClass("ng-dirty") && !$(this_form).hasClass("ng-submitted"))) {
1503                //Is Form Beteen forms to always notify
1504                if (formsToAlwaysNotify.indexOf(this_form_id) != -1) {
1505                    notifyUser = notifyUser || true;
1506                } else {
1507                    notifyUser = notifyUser || false;
1508                }
1509            } else {
1510                notifyUser = notifyUser || false;
1511            }
1512        });
1513        console.log("notifyUser : " + notifyUser);
1514        return notifyUser;
1515    }
1516
1517});
1518
1519app.service('App_Plugins', function ($rootScope, $interval, APP_CONFIG) {
1520
1521    //#region Location Services
1522    function watchLocationServicesPermission() {
1523        if (device) {
1524            cordova.plugins.diagnostic.isGpsLocationEnabled(function (enabled) {
1525                if (!enabled) {
1526                    $rootScope.GeoLocationStatus = 1;
1527                    $rootScope.$broadcast('$rootScope.GeoLocationStatus', {});
1528                } else {
1529                    cordova.plugins.permissions.checkPermission(cordova.plugins.permissions.ACCESS_FINE_LOCATION, function (resp) {
1530                        if (!resp.hasPermission) {
1531                            $rootScope.GeoLocationStatus = 2;
1532                            $rootScope.$broadcast('$rootScope.GeoLocationStatus', {});
1533                        } else {
1534                            $rootScope.GeoLocationStatus = 0;
1535                            $rootScope.$broadcast('$rootScope.GeoLocationStatus', {});
1536                        }
1537                    }, function (error) {
1538                        console.error("The following error occurred: ", error);
1539                    });
1540                }
1541                // isGpsLocationEnabled = enabled;
1542            }, function (error) {
1543                console.error("The following error occurred: ", error);
1544            });
1545        }
1546    }
1547
1548    this.LocationService_Check_Permissions = function () {
1549
1550        $rootScope.GeoLocationStatus = -1; // 0: working, 1: geolocation disabled on phone, 2: geolocation permission missing
1551
1552        $interval(function () {
1553            if (device) {
1554                watchLocationServicesPermission();
1555            }
1556        }, 2000);
1557
1558    }
1559    //#endregion
1560
1561});
1562
1563app.service('CordovaCrossover', function ($timeout, AppConfigService) {
1564
1565    this.ChangeStatusBarColor = function (Hex_Color) {
1566        AppConfigService.DebugConsoleLog([
1567            "CordovaCrossover -> ChangeStatusBarColor ",
1568            Hex_Color,
1569            AppConfigService.GetCallerFile() + ":" + AppConfigService.LineNumber()
1570        ]);
1571
1572        if (window.cordova) {
1573            if (cordova.platformId == 'android') {
1574                $timeout(function () {
1575                    StatusBar.backgroundColorByHexString(Hex_Color);
1576                }, 25);
1577            } else {
1578                StatusBar.backgroundColorByHexString(Hex_Color);
1579            }
1580        }
1581    }
1582});
1583
1584app.service('AppConfigService', function (APP_CONFIG) {
1585
1586    /**
1587     * Eg: 
1588     *  AppConfigService.DebugConsoleLog([
1589     *    "Session.staticData.offlineData",
1590     *     Session.staticData.offlineData,
1591     *     AppConfigService.GetCallerFile() +":" + AppConfigService.LineNumber()
1592     *   ]);
1593     * @param {*} params Send Flag such as a title/Calling function name to find it easier in console, the result, file and line in order to revert to original line of code
1594     */
1595    this.DebugConsoleLog = function (params) {
1596        if (APP_CONFIG.enable_debugging) {
1597            if (params.length > 1) {
1598                if (params.length == 2) {
1599                    if (typeof (params[1]) != "object") {
1600                        console.log(params[0], "\n" + params[1], "\n" + new Date().toDateString() + ' ' + new Date().toLocaleTimeString());
1601                    } else {
1602                        console.log(params[0], params[1], "\n" + new Date().toDateString() + ' ' + new Date().toLocaleTimeString());
1603                    }
1604
1605                    // console.log(params[0], params[1], "\n" + new Date().toDateString() + ' ' + new Date().toLocaleTimeString());
1606                } else if (params.length == 3) {
1607                    if (typeof (params[1]) != "object") {
1608                        console.log(params[0], "\n" + params[1], "\n" + params[2], "\n" + new Date().toDateString() + ' ' + new Date().toLocaleTimeString());
1609                    } else {
1610                        console.log(params[0], params[1], params[2], "\n" + new Date().toDateString() + ' ' + new Date().toLocaleTimeString());
1611                    }
1612                } else {
1613                    console.log("NEED IMPLEMENTATION");
1614                }
1615            } else {
1616                console.log(params[0]);
1617            }
1618        }
1619    }
1620
1621    this.LineNumber = function () {
1622        var e = new Error();
1623        if (!e.stack) try {
1624            // IE requires the Error to actually be throw or else the Error's 'stack'
1625            // property is undefined.
1626            throw e;
1627        } catch (e) {
1628            if (!e.stack) {
1629                return 0; // IE < 10, likely
1630            }
1631        }
1632        var stack = e.stack.toString().split(/\r\n|\n/);
1633        // We want our caller's frame. It's index into |stack| depends on the
1634        // browser and browser version, so we need to search for the second frame:
1635        var frameRE = /:(\d+):(?:\d+)[^\d]*$/;
1636        do {
1637            var frame = stack.shift();
1638        } while (!frameRE.exec(frame) && stack.length);
1639        return frameRE.exec(stack.shift())[1];
1640    }
1641
1642    this.GetCallerFile = function () {
1643        var originalFunc = Error.prepareStackTrace;
1644
1645        var callerfile;
1646        try {
1647            var err = new Error();
1648            var currentfile;
1649
1650            Error.prepareStackTrace = function (err, stack) {
1651                return stack;
1652            };
1653
1654            currentfile = err.stack.shift().getFileName();
1655
1656            while (err.stack.length) {
1657                callerfile = err.stack.shift().getFileName();
1658
1659                if (currentfile !== callerfile) break;
1660            }
1661        } catch (e) {}
1662
1663        Error.prepareStackTrace = originalFunc;
1664
1665        return callerfile.substr(callerfile.lastIndexOf('/') + 1);
1666    }
1667});
1668
1669app.service('SocialMediaHelpers', function () {
1670
1671    this.facebookShare = function (n, t) {
1672        (t == "" || t == undefined) && (t = encodeURIComponent(document.title));
1673        var i = "http://www.facebook.com/sharer.php?u=" + encodeURIComponent(n) + "&t=" + encodeURIComponent(t),
1674            r = window.open(i, "facebookshare", "height=600,width=700,resizable=1")
1675    }
1676
1677    this.googlePlusShare = function (n) {
1678        var t = "https://plus.google.com/share?url=" + n,
1679            i = window.open(t, "", "menubar=no,toolbar=no,resizable=no,scrollbars=no,height=400,width=600")
1680    }
1681
1682    this.tweetPopup = function (n, t) {
1683        var i = "ounousa";
1684        (t == "" || t == undefined) && (t = encodeURIComponent(document.title));
1685        var u = "counturl=" + n + "&text=" + t + "&original_referer=" + window.location.href + "&priority=1&related=" + i + "&url=" + n + "&via=" + i,
1686            f = "http://twitter.com/share?" + u,
1687            r = window.open(f, "tweet", "height=450,width=550,resizable=1"),
1688            e = window.setInterval(function () {
1689                (r.closed || r == null) && window.clearInterval(e)
1690            }, 200)
1691    }
1692    
1693});
1694
1695app.service('YoutubeHelpers', function () {
1696    var _self = this;
1697
1698    function serialize(obj) {
1699        var str = [];
1700        for (var p in obj)
1701            if (obj.hasOwnProperty(p)) {
1702                str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
1703            }
1704        return str.join("&");
1705    }
1706
1707    this.GetYoutubeVideoURL = function (url) {
1708        var youtubeRegexp = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
1709        var id = url.replace(youtubeRegexp, '$1');
1710
1711        if (id.indexOf(";") > -1) {
1712            var pieces = id.split(';');
1713
1714            if (pieces[1].indexOf("%") > -1) {
1715                var uriComponent = decodeURIComponent(id.split(';')[1]);
1716                id = ('http://youtube.com' + uriComponent)
1717                    .replace(youtubeRegexp, '$1');
1718            } else {
1719                id = pieces[0];
1720            }
1721        } else if (id.indexOf("#") > -1) {
1722            id = id.split('#')[0];
1723        }
1724        return "https://www.youtube.com/embed/" + id;
1725    }
1726
1727    this.ApplyParamsToYoutubeVideo = function (url, params) {
1728        var paramsToStr = serialize(params);
1729        return url + "?" + paramsToStr
1730    }
1731
1732    this.GetYoutubeVideoId = function (url) {
1733        var youtubeRegexp = /https?:\/\/(?:[0-9A-Z-]+\.)?(?:youtu\.be\/|youtube(?:-nocookie)?\.com\S*[^\w\s-])([\w-]{11})(?=[^\w-]|$)(?![?=&+%\w.-]*(?:['"][^<>]*>|<\/a>))[?=&+%\w.-]*/ig;
1734        var id = url.replace(youtubeRegexp, '$1');
1735
1736        if (id.indexOf(";") > -1) {
1737            var pieces = id.split(';');
1738
1739            if (pieces[1].indexOf("%") > -1) {
1740                var uriComponent = decodeURIComponent(id.split(';')[1]);
1741                id = ('http://youtube.com' + uriComponent)
1742                    .replace(youtubeRegexp, '$1');
1743            } else {
1744                id = pieces[0];
1745            }
1746        } else if (id.indexOf("#") > -1) {
1747            id = id.split('#')[0];
1748        }
1749        return id;
1750    }
1751
1752    this.onYouTubeIframeAPIReady = function (playerId, width, height, url) {
1753        player = new YT.Player(playerId, {
1754            height: height,
1755            width: width,
1756            videoId: _self.GetYoutubeVideoId(url),
1757            //   events: {
1758            //     'onReady': onPlayerReady,
1759            //     'onStateChange': onPlayerStateChange
1760            //   }
1761        });
1762        return player;
1763    }
1764});

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.