PageSourceSearch

https://www.snapsafe.com/assets/templates/snap/js/ng.js?v=20260325

js snapsafe.com collected 2026-09-29 14:57:04 UTC 21,397 bytes, 638 lines download raw bytes

1/**
2 * Created with PhpStorm.
3 * User: MATdave
4 ___      ___       __  ___________  ________       __  ___      ___  _______
5 |"  \    /"  |     /""\("     _   ")|"      "\     /""\|"  \    /"  |/"     "|
6 \   \  //   |    /    \)__/  \\__/ (.  ___  :)   /    \\   \  //  /(: ______)
7 /\\  \/.    |   /' /\  \  \\_ /    |: \   ) ||  /' /\  \\\  \/. ./  \/    |
8 |: \.        |  //  __'  \ |.  |    (| (___\ || //  __'  \\.    //   // ___)_
9 |.  \    /:  | /   /  \\  \\:  |    |:       :)/   /  \\  \\\   /   (:      "|
10 |___|\__/|___|(___/    \___)\__|    (________/(___/    \___)\__/     \_______)
11
12 * Date: 2/11/15
13 * Time: 3:43 PM
14 */
15
16angular.module('header.directives', [])
17    .directive('pwCheck', [function () {
18        return {
19            require: 'ngModel',
20            link: function (scope, elem, attrs, ctrl) {
21                var firstPassword = '#' + attrs.pwCheck;
22                elem.add(firstPassword).on('keyup', function () {
23                    scope.$apply(function () {
24                        var v = elem.val() === $(firstPassword).val();
25                        ctrl.$setValidity('pwmatch', v);
26                    });
27                });
28            }
29        }
30    }])
31    .directive('goTo', ['$window', function ($window) {
32        return {
33            link: function (scope, element, attrs) {
34                element.on('click', function () {
35                    scope.$apply(function () {
36                        $window.location.href = attrs.goTo;
37                    });
38                });
39            }
40        }
41    }]).directive('angularRipple', function () {
42    return {
43        restrict: 'A',
44        link: function (scope, element, attrs) {
45            var x, y, size, offsets,
46                func = function (e) {
47                    var ripple = this.querySelector('.angular-ripple');
48                    var eventType = e.type;
49                    // Ripple
50                    if (ripple === null) {
51                        // Create ripple
52                        ripple = document.createElement('span');
53                        ripple.className += ' angular-ripple';
54
55                        // Prepend ripple to element
56                        this.insertBefore(ripple, this.firstChild);
57
58                        // Set ripple size
59                        if (!ripple.offsetHeight && !ripple.offsetWidth) {
60                            size = Math.max(element[0].offsetWidth, element[0].offsetHeight);
61                            ripple.style.width = size + 'px';
62                            ripple.style.height = size + 'px';
63                        }
64                    }
65
66                    // Remove animation effect
67                    ripple.className = ripple.className.replace(/ ?(animate)/g, '');
68
69                    // get click coordinates by event type
70                    if (eventType === 'mouseup') {
71                        x = e.pageX;
72                        y = e.pageY;
73                    } else if (eventType === 'touchend') {
74                        try {
75                            var origEvent;
76
77                            if (typeof e.changedTouches !== 'undefined') {
78                                origEvent = e.changedTouches[0];
79                            } else {
80                                origEvent = e.originalEvent;
81                            }
82
83                            x = origEvent.pageX;
84                            y = origEvent.pageY;
85                        } catch (e) {
86                            // fall back to center of el
87                            x = ripple.offsetWidth / 2;
88                            y = ripple.offsetHeight / 2;
89                        }
90                    }
91
92                    // set new ripple position by click or touch position
93                    function getPos(element) {
94                        var de = document.documentElement;
95                        var box = element.getBoundingClientRect();
96                        var top = box.top + window.pageYOffset - de.clientTop;
97                        var left = box.left + window.pageXOffset - de.clientLeft;
98                        return {top: top, left: left};
99                    }
100
101                    offsets = getPos(element[0]);
102                    ripple.style.left = (x - offsets.left - size / 2) + 'px';
103                    ripple.style.top = (y - offsets.top - size / 2) + 'px';
104
105                    // Add animation effect
106                    ripple.className += ' animate';
107                }
108
109            element.on('touchend mouseup', func);
110
111            //remove the event listener on scope destroy
112            scope.$on('$destroy', function () {
113                element.off('touchend mouseup', func);
114            });
115        }
116    };
117}).directive('starRating', function () {
118    return {
119        restrict: 'EA',
120        template:
121        '<ul class="star-rating" ng-class="{readonly: readonly}">' +
122        '  <li ng-repeat="star in stars" class="star" ng-class="{filled: star.filled}" ng-click="toggle($index)">' +
123        '    <i class="fa fa-star"></i>' + // or &#9733
124        '  </li>' +
125        '</ul>',
126        scope: {
127            ratingValue: '=ngModel',
128            max: '=?', // optional (default is 5)
129            onRatingSelect: '&?',
130            readonly: '=?'
131        },
132        link: function(scope, element, attributes) {
133            if (scope.max == undefined) {
134                scope.max = 5;
135            }
136            function updateStars() {
137                scope.stars = [];
138                for (var i = 0; i < scope.max; i++) {
139                    scope.stars.push({
140                        filled: i < scope.ratingValue
141                    });
142                }
143            };
144            scope.toggle = function(index) {
145                if (scope.readonly == undefined || scope.readonly === false){
146                    scope.ratingValue = index + 1;
147                    scope.onRatingSelect({
148                        rating: index + 1
149                    });
150                }
151            };
152            scope.$watch('ratingValue', function(oldValue, newValue) {
153                if (newValue || newValue === 0) {
154                    updateStars();
155                }
156            });
157        }
158    };
159}).directive('tooltip', function ($document, $compile) {
160    return {
161        restrict: 'A',
162        scope: true,
163        link: function (scope, element, attrs) {
164
165            var tip = $compile('<div ng-class="tipClass" ng-bind-html="text"><div class="tooltip-arrow"></div></div>')(scope),
166                tipClassName = 'tooltip',
167                tipActiveClassName = 'tooltip-show';
168
169            scope.tipClass = [tipClassName];
170            scope.text = attrs.tooltip;
171
172            if (attrs.tooltipPosition) {
173                scope.tipClass.push('tooltip-' + attrs.tooltipPosition);
174            }
175            else {
176                scope.tipClass.push('tooltip-down');
177            }
178            $document.find('body').append(tip);
179
180            element.bind('mouseover click', function (e) {
181                tip.addClass(tipActiveClassName);
182
183                var pos = e.target.getBoundingClientRect(),
184                    offset = tip.offset(),
185                    tipHeight = tip.outerHeight(),
186                    tipWidth = tip.outerWidth(),
187                    elWidth = pos.width || pos.right - pos.left,
188                    elHeight = pos.height || pos.bottom - pos.top,
189                    tipOffset = 10;
190
191                if (tip.hasClass('tooltip-right')) {
192                    offset.top = pos.top - (tipHeight / 2) + (elHeight / 2);
193                    offset.left = pos.right + tipOffset;
194                }
195                else if (tip.hasClass('tooltip-left')) {
196                    offset.top = pos.top - (tipHeight / 2) + (elHeight / 2);
197                    offset.left = pos.left - tipWidth - tipOffset;
198                }
199                else if (tip.hasClass('tooltip-down')) {
200                    offset.top = pos.top + elHeight + tipOffset;
201                    offset.left = pos.left - (tipWidth / 2) + (elWidth / 2);
202                }
203                else {
204                    offset.top = pos.top - tipHeight - tipOffset;
205                    offset.left = pos.left - (tipWidth / 2) + (elWidth / 2);
206                }
207                tip.css({'top': offset.top, 'left': offset.left});
208                return false;
209            });
210
211            element.bind('mouseout', function () {
212                tip.removeClass(tipActiveClassName);
213            });
214
215            tip.bind('mouseover', function () {
216                tip.addClass(tipActiveClassName);
217            });
218
219            tip.bind('mouseout', function () {
220                tip.removeClass(tipActiveClassName);
221            });
222
223
224        }
225    }
226}).directive('magnificPopup',
227    [
228        "$compile",
229        function ($compile) {
230            return {
231                restrict: 'A',
232                scope: {},
233                link: function ($scope, element, attr) {
234                    attr.callbacks = {
235                        ajaxContentAdded: function () {
236                            var content = this.content;
237
238                            var scope = content.scope();
239                            $compile(content)(scope);
240                            scope.$digest();
241                        }
242                    };
243
244                    element.magnificPopup(attr);
245                }
246            }
247        }
248    ]
249).directive('ngUnique', function ($http) {
250    return {
251        require: 'ngModel',
252        link: function (scope, elem, attrs, ctrl) {
253            elem.on('blur', function (evt) {
254                scope.$apply(function () {
255                    $http({
256                        method: 'GET',
257                        url: '/js/namecheck.json?v=' + elem.val() + '&m=' + attrs.ngUnique
258                    }).success(function (data, status, headers, config) {
259                        ctrl.$setValidity('unique', data.status);
260                        var elem = document.getElementById(data.elem);
261                        elem.value = data.value;
262                    });
263                });
264            })
265        }
266    }
267}).directive('scrollTo', ['ScrollTo', function (ScrollTo) {
268    return {
269        restrict: "AC",
270        compile: function () {
271
272            return function (scope, element, attr) {
273                element.bind("click", function (event) {
274                    ScrollTo.idOrName(attr.scrollTo, attr.offset);
275                });
276            };
277        }
278    };
279}]).directive('ngEsc', function () {
280    return function (scope, element, attrs) {
281        element.bind("keydown keypress keyup", function (event) {
282            if (event.which === 27) {
283                scope.$apply(function () {
284                    scope.$eval(attrs.ngEsc);
285                });
286
287                event.preventDefault();
288            }
289        });
290    };
291}).directive('keypressEvents', function ($document, $rootScope) {
292    return {
293        restrict: 'A',
294        link: function () {
295            console.log('linked');
296            $document.bind('keypress', function (e) {
297                $rootScope.$broadcast('keypress', e, e.keyCode);
298            });
299        }
300    }
301}).service('ScrollTo', ['$window', 'ngScrollToOptions', function ($window, ngScrollToOptions) {
302
303    this.idOrName = function (idOrName, offset, focus) {//find element with the given id or name and scroll to the first element it finds
304        var document = $window.document;
305
306        if (!idOrName) {//move to top if idOrName is not provided
307            $window.scrollTo(0, 0);
308        }
309
310        if (focus === undefined) { //set default action to focus element
311            focus = true;
312        }
313
314        //check if an element can be found with id attribute
315        var el = document.getElementById(idOrName);
316        if (!el) {//check if an element can be found with name attribute if there is no such id
317            el = document.getElementsByName(idOrName);
318
319            if (el && el.length)
320                el = el[0];
321            else
322                el = null;
323        }
324
325        if (el) { //if an element is found, scroll to the element
326            if (focus) {
327                el.focus();
328            }
329
330            ngScrollToOptions.handler(el, offset);
331        }
332
333        //otherwise, ignore
334    }
335
336}])
337    .provider("ngScrollToOptions", function () {
338        this.options = {
339            handler: function (el, offset) {
340                if (offset) {
341                    var top = $(el).offset().top - offset;
342                    window.scrollTo(0, top);
343                }
344                else {
345                    el.scrollIntoView();
346                }
347            }
348        };
349        this.$get = function () {
350            return this.options;
351        };
352        this.extend = function (options) {
353            this.options = angular.extend(this.options, options);
354        };
355    });
356
357angular.module('ui.gravatar').config([
358    'gravatarServiceProvider', function (gravatarServiceProvider) {
359        gravatarServiceProvider.defaults = {
360            size: 100,
361            "default": 'mm'  // Mystery man as default for missing avatars
362        };
363
364        // Use https endpoint
365        gravatarServiceProvider.secure = true;
366    }
367]);
368var header = angular.module('header', ['ngRoute', 'ngDialog', 'ngSanitize', 'ngTouch', 'header.directives', 'ui.gravatar', 'slick', 'panzoom', 'panzoomwidget', 'angular-click-outside', 'ngStorage', 'angular-loading-bar']);
369
370header.controller('login', function ($scope, $routeParams, $location, $route, ngDialog, $rootScope, $anchorScroll, $window) {
371    $scope.auth = auth;
372    $scope.signin = ($scope.auth >= 1) ? "Profile" : "Sign In";
373
374    $scope.loginWin = function () {
375        ngDialog.open({
376            templateUrl: '/js/loginwindow.html'
377            , scope: $scope
378        });
379    };
380
381    $scope.closeLogin = function () {
382        ngDialog.closeAll();
383    }
384});
385
386header.controller('menu', function ($scope, $routeParams, $location, $route, ngDialog, $rootScope, $anchorScroll, $window) {
387    $scope.expand = null;
388    $scope.menuWin = function () {
389        ngDialog.open({
390            templateUrl: '/js/mobilemenu.html'
391            , appendClassName: 'mobile-menu'
392            , closeByNavigation: true
393            , scope: $scope
394        });
395    };
396
397    $scope.closeMenu = function () {
398        ngDialog.closeAll();
399    }
400});
401
402header.controller('register', function ($scope, $http) {
403    $scope.master = {};
404    $scope.user = {};
405    $scope.update = function (user) {
406        $scope.master = angular.copy(user);
407    };
408
409    $scope.reset = function () {
410        $scope.user = angular.copy($scope.master);
411    };
412
413
414    $scope.$watch('shippingSame', function (value) {
415        if (value) {
416            $scope.shipping = $scope.user;
417            $scope.shipping.name = $scope.user.fname + ' ' + $scope.user.lname;
418        } else {
419            $scope.shipping = angular.copy($scope.user);
420        }
421    });
422    $scope.reset();
423
424});
425
426header.controller('social', function ($scope, $filter) {
427    $scope.messages = angular.extend(twitter, google);
428    $scope.messages = angular.extend($scope.messages, facebook);
429    var message = $filter('orderBy')($scope.messages, 'time', true);
430    message = $filter('limitTo')(message, 1);
431    $scope.message = message[0];
432});
433
434
435header.controller("genGalleryController", function ($scope, $filter, $timeout, PanZoomService) {
436    $scope.item = {thumbnail: null, gallery: []};
437    $scope.index = null;
438    $scope.gallery = {
439        thumbs: $scope.item.gallery,
440        active: $scope.item.thumbnail || ($scope.item.gallery.length > 0) ? $scope.item.gallery[0].thumbnail : null,
441        popup: false
442    };
443    $scope.showThumb = function (img, thumbrotate) {
444        $scope.gallery.active = img;
445        $scope.gallery.thumbrotate = thumbrotate;
446    };
447    $scope.responsive = [
448        {
449            breakpoint: 1025,
450            settings: {
451                slidesToShow: 2,
452                slidesToScroll: 1
453            }
454        },
455        {
456            breakpoint: 825,
457            settings: {
458                slidesToShow: 1,
459                slidesToScroll: 1
460            }
461        },
462        {
463            breakpoint: 559,
464            settings: {
465                slidesToShow: 1,
466                slidesToScroll: 1
467            }
468        }];
469    $scope.closePopup = function (t) {
470        $scope.gallery.popup = false;
471        t = null
472    };
473    var imagebox = {
474        x: 0,
475        y: 0,
476        width: 1200,
477        height: 1200
478    };
479    $scope.panzoomConfig = {
480        zoomLevels: 8,
481        //initialZoomLevel: $scope.zoom,
482        neutralZoomLevel: 5,
483        scalePerZoomLevel: 1.5,
484        //initialPanX: $scope.panx,
485        //initialPanY: $scope.pany,
486        initialZoomToFit: imagebox,
487        zoomToFitZoomLevelFactor: 1
488    };
489    $scope.panzoomModel = {};
490    $scope.zoomToBox = function () {
491        PanZoomService.getAPI($scope.index).then(function (api) {
492            api.zoomToFit(imagebox);
493        });
494    };
495    $scope.$watch(function () {
496        return $scope.gallery.active;
497    }, function (newVal, oldVal) {
498        $scope.gallery.active = newVal;
499    });
500    $scope.$watch(function () {
501        return $scope.item;
502    }, function (newVal, oldVal) {
503        $scope.item = newVal;
504        $scope.item.gallery = $filter('orderBy')(newVal.gallery,'order');
505        $scope.gallery.thumbs = $scope.item.gallery;
506    });
507    $scope.$watch(function () {
508        return $scope.index;
509    }, function (newVal, oldVal) {
510        $scope.index = newVal;
511    });
512    $scope.$watch(function () {
513        return $scope.gallery.popup;
514    }, function (newVal, oldVal) {
515        $scope.gallery.popup = newVal;
516        if(newVal){
517            $('#editable').css('position','relative');
518            $('#editable').css('z-index','999');
519            console.log('popup open');
520        }else{
521            $('#editable').css('position','inherit');
522            $('#editable').css('z-index','1');
523            console.log('popup closed');
524        }
525        $scope.zoomToBox();
526    });
527
528    $scope.next = function (t, total) {
529        var r = 0;
530        if (t < (total - 1)) {
531            r = t + 1;
532        }
533        $scope.zoomToBox();
534        return r;
535    };
536    $scope.previous = function (t, total) {
537        var r = (total - 1);
538        if (t > 0) {
539            r = t - 1;
540        }
541        $scope.zoomToBox();
542        return r;
543    };
544});
545
546header.controller('productform',function($scope){
547    $scope.productprice = null;
548    $scope.$watch(function(){
549        return $scope.productprice;
550    }, function(newVal, oldVal){
551        $scope.productprice = newVal;
552    });
553    $scope.productprice_mobile = null;
554    $scope.$watch(function(){
555        return $scope.productprice_mobile;
556    }, function(newVal, oldVal){
557        $scope.productprice_mobile = newVal;
558    });
559});
560
561header.controller('genVideoController', function ($scope, $timeout, $http, $sce) {
562    $scope.item = {vidgallery: []};
563    $scope.videos = {items: $scope.item.vidgallery, active: null, embed: null, popup: false};
564    $scope.closeVideo = function () {
565        $scope.videos.popup = false;
566        $scope.videos.active = null
567    };
568    $scope.responsive = [
569        {
570            breakpoint: 1025,
571            settings: {
572                slidesToShow: 2,
573                slidesToScroll: 2
574            }
575        },
576        {
577            breakpoint: 825,
578            settings: {
579                slidesToShow: 2,
580                slidesToScroll: 2
581            }
582        },
583        {
584            breakpoint: 559,
585            settings: {
586                slidesToShow: 1,
587                slidesToScroll: 1
588            }
589        }];
590    //*<iframe src="https://player.vimeo.com/video/225307972?color=f0a61d&byline=0&portrait=0" width="640" height="360" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
591    $scope.onBeforeChange = function(event,slick,currentSlide,nextSlide){
592        console.log(event);
593        console.log(slick);
594      console.log(currentSlide);
595      console.log(nextSlide);
596    };
597    $scope.embedURL = function(e) {
598        return $sce.trustAsResourceUrl('https://player.vimeo.com/video/'+e);
599    };
600    $scope.$watch(function () {
601        return $scope.videos.active;
602    }, function (newVal, oldVal) {
603        $scope.videos.embed = null;
604        var endpoint = 'https://www.vimeo.com/api/oembed.json';
605        var params = {
606            url: 'https://vimeo.com/' + newVal,
607            callback: 'JSON_CALLBACK',
608            player_id: 'vimeo1'
609        };
610        if (newVal)
611            $http.jsonp(endpoint, {params: params}).then(function (res) {
612                //console.log(res);
613                $scope.videos.embed = $sce.trustAsHtml(res.data.html);
614            });
615    });
616    $scope.$watch(function () {
617        return $scope.item;
618    }, function (newVal, oldVal) {
619        $scope.item = newVal;
620        $scope.videos.items = $scope.item.vidgallery;
621    });
622});
623header.config(function (ngDialogProvider, ngScrollToOptionsProvider) {
624    //Route the Request
625    ngDialogProvider.setDefaults({
626        className: 'header-theme',
627        showClose: false,
628        closeByDocument: false,
629        closeByEscape: true
630    });
631
632    ngScrollToOptionsProvider.extend({
633        handler: function (el) {
634
635            $(el)[0].scrollIntoView();
636        }
637    });
638});

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.