PageSourceSearch

https://steamspy.com/pages/js/pages.js

js steamspy.com collected 2026-09-24 17:37:50 UTC 66,972 bytes, 1,973 lines download raw bytes

1(function($) {
2
3    'use strict';
4
5    var Pages = function() {
6        this.VERSION = "1.0.0";
7        this.AUTHOR = "Revox";
8        this.SUPPORT = "[email protected]";
9
10        this.pageScrollElement = 'html, body';
11        this.$body = $('body');
12
13        this.setUserOS();
14        this.setUserAgent();
15    }
16
17    // Set environment vars
18    Pages.prototype.setUserOS = function() {
19        var OSName = "";
20        if (navigator.appVersion.indexOf("Win") != -1) OSName = "windows";
21        if (navigator.appVersion.indexOf("Mac") != -1) OSName = "mac";
22        if (navigator.appVersion.indexOf("X11") != -1) OSName = "unix";
23        if (navigator.appVersion.indexOf("Linux") != -1) OSName = "linux";
24
25        this.$body.addClass(OSName);
26    }
27
28    Pages.prototype.setUserAgent = function() {
29        if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
30            this.$body.addClass('mobile');
31        } else {
32            this.$body.addClass('desktop');
33            if (navigator.userAgent.match(/MSIE 9.0/)) {
34                this.$body.addClass('ie9');
35            }
36        }
37    }
38
39    // Pages util functions
40    Pages.prototype.isVisibleXs = function() {
41        (!$('#pg-visible-xs').length) && this.$body.append('<div id="pg-visible-xs" class="visible-xs" />');
42        return $('#pg-visible-xs').is(':visible');
43    }
44
45    Pages.prototype.isVisibleSm = function() {
46        (!$('#pg-visible-sm').length) && this.$body.append('<div id="pg-visible-sm" class="visible-sm" />');
47        return $('#pg-visible-sm').is(':visible');
48    }
49
50    Pages.prototype.isVisibleMd = function() {
51        (!$('#pg-visible-md').length) && this.$body.append('<div id="pg-visible-md" class="visible-md" />');
52        return $('#pg-visible-md').is(':visible');
53    }
54
55    Pages.prototype.isVisibleLg = function() {
56        (!$('#pg-visible-lg').length) && this.$body.append('<div id="pg-visible-lg" class="visible-lg" />');
57        return $('#pg-visible-lg').is(':visible');
58    }
59
60    Pages.prototype.getUserAgent = function() {
61        return $('body').hasClass('mobile') ? "mobile" : "desktop";
62    }
63
64    Pages.prototype.setFullScreen = function(element) {
65        // Supports most browsers and their versions.
66        var requestMethod = element.requestFullScreen || element.webkitRequestFullScreen || element.mozRequestFullScreen || element.msRequestFullscreen;
67
68        if (requestMethod) { // Native full screen.
69            requestMethod.call(element);
70        } else if (typeof window.ActiveXObject !== "undefined") { // Older IE.
71            var wscript = new ActiveXObject("WScript.Shell");
72            if (wscript !== null) {
73                wscript.SendKeys("{F11}");
74            }
75        }
76    }
77
78    Pages.prototype.getColor = function(color, opacity) {
79        opacity = parseFloat(opacity) || 1;
80
81        var elem = $('.pg-colors').length ? $('.pg-colors') : $('<div class="pg-colors"></div>').appendTo('body');
82
83        var colorElem = elem.find('[data-color="' + color + '"]').length ? elem.find('[data-color="' + color + '"]') : $('<div class="bg-' + color + '" data-color="' + color + '"></div>').appendTo(elem);
84
85        var color = colorElem.css('background-color');
86
87        var rgb = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
88        var rgba = "rgba(" + rgb[1] + ", " + rgb[2] + ", " + rgb[3] + ', ' + opacity + ')';
89
90        return rgba;
91    }
92
93    // Initialize Layout
94    Pages.prototype.initDropDown = function() {
95        // adjust width of each dropdown to match content width
96        $('.dropdown-default').each(function() {
97            var btn = $(this).find('.dropdown-menu').siblings('.dropdown-toggle');
98            var offset = 0;
99
100            var padding = btn.actual('innerWidth') - btn.actual('width');
101            var menuWidth = $(this).find('.dropdown-menu').actual('outerWidth');
102
103            if (btn.actual('outerWidth') < menuWidth) {
104                btn.width(menuWidth - offset);
105                $(this).find('.dropdown-menu').width(btn.actual('outerWidth'));
106            } else {
107                $(this).find('.dropdown-menu').width(btn.actual('outerWidth'));
108            }
109        });
110    }
111
112    Pages.prototype.initFormGroupDefault = function() {
113        $('.form-group.form-group-default').click(function() {
114            $(this).find(':input').focus();
115        });
116        $('body').on('focus', '.form-group.form-group-default :input', function() {
117            $('.form-group.form-group-default').removeClass('focused');
118            $(this).parents('.form-group').addClass('focused');
119        });
120
121        $('body').on('blur', '.form-group.form-group-default :input', function() {
122            $(this).parents('.form-group').removeClass('focused');
123            if ($(this).val()) {
124                $(this).closest('.form-group').find('label').addClass('fade');
125            } else {
126                $(this).closest('.form-group').find('label').removeClass('fade');
127            }
128        });
129
130        $('.form-group.form-group-default .checkbox, .form-group.form-group-default .radio').hover(function() {
131            $(this).parents('.form-group').addClass('focused');
132        }, function() {
133            $(this).parents('.form-group').removeClass('focused');
134        });
135    }
136
137    Pages.prototype.initSlidingTabs = function() {
138        // TODO: move this to a separate file
139        $('a[data-toggle="tab"]').on('show.bs.tab', function(e) {
140            //e = $(e.relatedTarget || e.target).parent().find('a[data-toggle=tab]');
141            e = $(e.target).parent().find('a[data-toggle=tab]');
142
143            var hrefPrev = e.attr('href');
144
145            var hrefCurrent = e.attr('href');
146
147            if (!$(hrefCurrent).is('.slide-left, .slide-right')) return;
148            $(hrefCurrent).addClass('sliding');
149
150            setTimeout(function() {
151                $(hrefCurrent).removeClass('sliding');
152            }, 100);
153        });
154    }
155
156    Pages.prototype.initNotificationCenter = function() {
157        $('.notification-list .dropdown-menu').on('click', function(event) {
158            event.stopPropagation();
159        });
160        $('.toggle-more-details').on('click', function(event) {
161            var p = $(this).closest('.heading');
162            p.closest('.heading').children('.more-details').stop().slideToggle('fast', function() {
163                p.toggleClass('open');
164            });
165        });
166    }
167
168
169    Pages.prototype.initProgressBars = function() {
170        $(window).on('load', function() {
171            $('.progress-bar').each(function() {
172                $(this).css('width', $(this).attr("data-percentage"));
173            });
174            // Hack: FF doesn't play SVG animations set as background-image
175            $('.progress-bar-indeterminate, .progress-circle-indeterminate, .mapplic-pin').hide().show(0);
176        });
177    }
178
179    Pages.prototype.initView = function() {
180            $('[data-navigate="view"]').on('click', function(e) {
181                e.preventDefault();
182                var el = $(this).attr('data-view-port');
183                $(el).toggleClass($(this).attr('data-view-animation'));
184                return false;
185            })
186        }
187        // Initialize Plugins
188    Pages.prototype.initTooltipPlugin = function() {
189        $.fn.tooltip && $('[data-toggle="tooltip"]').tooltip();
190    }
191
192    Pages.prototype.initSelect2Plugin = function() {
193        $.fn.select2 && $('[data-init-plugin="select2"]').each(function() {
194            $(this).select2({
195                minimumResultsForSearch: ($(this).attr('data-disable-search') == 'true' ? -1 : 1)
196            }).on('select2-opening', function() {
197                $.fn.scrollbar && $('.select2-results').scrollbar({
198                    ignoreMobile: false
199                })
200            });
201        });
202    }
203
204    Pages.prototype.initScrollBarPlugin = function() {
205        $.fn.scrollbar && $('.scrollable').scrollbar({
206            ignoreOverlay: false
207        });
208    }
209
210    Pages.prototype.initListView = function() {
211        $.fn.ioslist && $('[data-init-list-view="ioslist"]').ioslist();
212        $.fn.scrollbar && $('.list-view-wrapper').scrollbar({
213            ignoreOverlay: false
214        });
215    }
216
217    Pages.prototype.initSwitcheryPlugin = function() {
218        // Switchery - ios7 switch
219        window.Switchery && $('[data-init-plugin="switchery"]').each(function() {
220            new Switchery($(this).get(0), {
221                color: $.Pages.getColor('success')
222            });
223        });
224    }
225
226    Pages.prototype.initSelectFxPlugin = function() {
227        window.SelectFx && $('select[data-init-plugin="cs-select"]').each(function() {
228            var el = $(this).get(0);
229            $(el).wrap('<div class="cs-wrapper"></div>');
230            new SelectFx(el);
231        });
232    }
233
234    Pages.prototype.initUnveilPlugin = function() {
235        // lazy load retina images
236        $.fn.unveil && $("img").unveil();
237    }
238
239    Pages.prototype.initValidatorPlugin = function() {
240        $.validator && $.validator.setDefaults({
241            ignore: "", // validate hidden fields, required for cs-select
242            showErrors: function(errorMap, errorList) {
243                var $this = this;
244                $.each(this.successList, function(index, value) {
245                    var parent = $(this).closest('.form-group-attached');
246                    if (parent.length) return $(value).popover("hide");
247                });
248                return $.each(errorList, function(index, value) {
249
250                    var parent = $(value.element).closest('.form-group-attached');
251                    if (!parent.length) {
252                        return $this.defaultShowErrors();
253                    }
254                    var _popover;
255                    _popover = $(value.element).popover({
256                        trigger: "manual",
257                        placement: "top",
258                        html: true,
259                        container: parent.closest('form'),
260                        content: value.message
261                    });
262                    _popover.data("bs.popover").options.content = value.message;
263                    var parent = $(value.element).closest('.form-group');
264                    parent.addClass('has-error');
265                    $(value.element).popover("show");
266                });
267            },
268            onfocusout: function(element) {
269                var parent = $(element).closest('.form-group');
270                if ($(element).valid()) {
271                    parent.removeClass('has-error');
272                    parent.next('.error').remove();
273                }
274            },
275            onkeyup: function(element) {
276                var parent = $(element).closest('.form-group');
277                if ($(element).valid()) {
278                    $(element).removeClass('error');
279                    parent.removeClass('has-error');
280                    parent.next('label.error').remove();
281                    parent.find('label.error').remove();
282                } else {
283                    parent.addClass('has-error');
284                }
285            },
286            errorPlacement: function(error, element) {
287                var parent = $(element).closest('.form-group');
288                if (parent.hasClass('form-group-default')) {
289                    parent.addClass('has-error');
290                    error.insertAfter(parent);
291                } else {
292                    error.insertAfter(element);
293                }
294            }
295        });
296    }
297
298    // Call initializers
299    Pages.prototype.init = function() {
300        // init layout
301        this.initDropDown();
302        this.initFormGroupDefault();
303        this.initSlidingTabs();
304        this.initNotificationCenter();
305        this.initProgressBars();
306        // init plugins
307        this.initTooltipPlugin();
308        this.initSelect2Plugin();
309        this.initScrollBarPlugin();
310        this.initSwitcheryPlugin();
311        this.initSelectFxPlugin();
312        this.initUnveilPlugin();
313        this.initValidatorPlugin();
314        this.initView();
315        this.initListView();
316    }
317
318    $.Pages = new Pages();
319    $.Pages.Constructor = Pages;
320
321})(window.jQuery);
322/**
323 * selectFx.js v1.0.0
324 * http://www.codrops.com
325 *
326 * Licensed under the MIT license.
327 * http://www.opensource.org/licenses/mit-license.php
328 * 
329 * Copyright 2014, Codrops
330 * http://www.codrops.com
331 */
332;( function( window ) {
333    
334    'use strict';
335
336    /**
337     * based on from https://github.com/inuyaksa/jquery.nicescroll/blob/master/jquery.nicescroll.js
338     */
339    function hasParent( e, p ) {
340        if (!e) return false;
341        var el = e.target||e.srcElement||e||false;
342        while (el && el != p) {
343            el = el.parentNode||false;
344        }
345        return (el!==false);
346    };
347    
348    /**
349     * extend obj function
350     */
351    function extend( a, b ) {
352        for( var key in b ) { 
353            if( b.hasOwnProperty( key ) ) {
354                a[key] = b[key];
355            }
356        }
357        return a;
358    }
359
360    /**
361     * SelectFx function
362     */
363    function SelectFx( el, options ) {  
364        this.el = el;
365        this.options = extend( {}, this.options );
366        extend( this.options, options );
367        this._init();
368    }
369
370    /**
371    * Pure-JS alternative to jQuery closest()
372    */
373    function closest(elem, selector) {
374       var matchesSelector = elem.matches || elem.webkitMatchesSelector || elem.mozMatchesSelector || elem.msMatchesSelector;
375        while (elem) {
376            if (matchesSelector.bind(elem)(selector)) {
377                return elem;
378            } else {
379                elem = elem.parentElement;
380            }
381        }
382        return false;
383    }
384
385    /**
386    * jQuery offset() in pure JS
387    */
388    function offset(el) {
389        return {
390            left : el.getBoundingClientRect().left + window.pageXOffset - el.ownerDocument.documentElement.clientLeft,
391            top : el.getBoundingClientRect().top + window.pageYOffset - el.ownerDocument.documentElement.clientTop
392        }
393        
394    }
395
396    /**
397    * jQuery after() in pure JS
398    */
399    function insertAfter(newNode, referenceNode) {
400        referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
401    }
402    /**
403     * SelectFx options
404     */
405    SelectFx.prototype.options = {
406        // if true all the links will open in a new tab.
407        // if we want to be redirected when we click an option, we need to define a data-link attr on the option of the native select element
408        newTab : true,
409        // when opening the select element, the default placeholder (if any) is shown
410        stickyPlaceholder : true,
411        // default container is body
412        container : 'body',
413        // callback when changing the value
414        onChange : function( el ) { 
415            var event = document.createEvent('HTMLEvents');
416            event.initEvent('change', true, false);
417            el.dispatchEvent(event);
418        }
419    }
420
421    /**
422     * init function
423     * initialize and cache some vars
424     */
425    SelectFx.prototype._init = function() {
426        // check if we are using a placeholder for the native select box
427        // we assume the placeholder is disabled and selected by default
428        var selectedOpt = this.el.querySelector( 'option[selected]' );
429        this.hasDefaultPlaceholder = selectedOpt && selectedOpt.disabled;
430
431        // get selected option (either the first option with attr selected or just the first option)
432        this.selectedOpt = selectedOpt || this.el.querySelector( 'option' );
433
434        // create structure
435        this._createSelectEl();
436
437        // all options
438        this.selOpts = [].slice.call( this.selEl.querySelectorAll( 'li[data-option]' ) );
439        
440        // total options
441        this.selOptsCount = this.selOpts.length;
442        
443        // current index
444        this.current = this.selOpts.indexOf( this.selEl.querySelector( 'li.cs-selected' ) ) || -1;
445        
446        // placeholder elem
447        this.selPlaceholder = this.selEl.querySelector( 'span.cs-placeholder' );
448
449        // init events
450        this._initEvents();
451    }
452
453    /**
454     * creates the structure for the select element
455     */
456    SelectFx.prototype._createSelectEl = function() {
457        var self = this, options = '', createOptionHTML = function(el) {
458            var optclass = '', classes = '', link = '';
459
460            if( el.selectedOpt && !this.foundSelected && !this.hasDefaultPlaceholder ) {
461                classes += 'cs-selected ';
462                this.foundSelected = true;
463            }
464            // extra classes
465            if( el.getAttribute( 'data-class' ) ) {
466                classes += el.getAttribute( 'data-class' );
467            }
468            // link options
469            if( el.getAttribute( 'data-link' ) ) {
470                link = 'data-link=' + el.getAttribute( 'data-link' );
471            }
472
473            if( classes !== '' ) {
474                optclass = 'class="' + classes + '" ';
475            }
476
477            return '<li ' + optclass + link + ' data-option data-value="' + el.value + '"><span>' + el.textContent + '</span></li>';
478        };
479
480        [].slice.call( this.el.children ).forEach( function(el) {
481            if( el.disabled ) { return; }
482
483            var tag = el.tagName.toLowerCase();
484
485            if( tag === 'option' ) {
486                options += createOptionHTML(el);
487            }
488            else if( tag === 'optgroup' ) {
489                options += '<li class="cs-optgroup"><span>' + el.label + '</span><ul>';
490                [].slice.call( el.children ).forEach( function(opt) {
491                    options += createOptionHTML(opt);
492                } )
493                options += '</ul></li>';
494            }
495        } );
496
497        var opts_el = '<div class="cs-options"><ul>' + options + '</ul></div>';
498        this.selEl = document.createElement( 'div' );
499        this.selEl.className = this.el.className;
500        this.selEl.tabIndex = this.el.tabIndex;
501        this.selEl.innerHTML = '<span class="cs-placeholder">' + this.selectedOpt.textContent + '</span>' + opts_el;
502        this.el.parentNode.appendChild( this.selEl );
503        this.selEl.appendChild( this.el );
504
505        // backdrop to support dynamic heights of the dropdown
506        var backdrop = document.createElement('div');
507        backdrop.className = 'cs-backdrop';
508        this.selEl.appendChild(backdrop);
509    }
510
511    /**
512     * initialize the events
513     */
514    SelectFx.prototype._initEvents = function() {
515        var self = this;
516
517        // open/close select
518        this.selPlaceholder.addEventListener( 'click', function() {
519            self._toggleSelect();
520        } );
521
522        // clicking the options
523        this.selOpts.forEach( function(opt, idx) {
524            opt.addEventListener( 'click', function() {
525                self.current = idx;
526                self._changeOption();
527                // close select elem
528                self._toggleSelect();
529            } );
530        } );
531
532        // close the select element if the target it´s not the select element or one of its descendants..
533        document.addEventListener( 'click', function(ev) {
534            var target = ev.target;
535            if( self._isOpen() && target !== self.selEl && !hasParent( target, self.selEl ) ) {
536                self._toggleSelect();
537            }
538        } );
539
540        // keyboard navigation events
541        this.selEl.addEventListener( 'keydown', function( ev ) {
542            var keyCode = ev.keyCode || ev.which;
543
544            switch (keyCode) {
545                // up key
546                case 38:
547                    ev.preventDefault();
548                    self._navigateOpts('prev');
549                    break;
550                // down key
551                case 40:
552                    ev.preventDefault();
553                    self._navigateOpts('next');
554                    break;
555                // space key
556                case 32:
557                    ev.preventDefault();
558                    if( self._isOpen() && typeof self.preSelCurrent != 'undefined' && self.preSelCurrent !== -1 ) {
559                        self._changeOption();
560                    }
561                    self._toggleSelect();
562                    break;
563                // enter key
564                case 13:
565                    ev.preventDefault();
566                    if( self._isOpen() && typeof self.preSelCurrent != 'undefined' && self.preSelCurrent !== -1 ) {
567                        self._changeOption();
568                        self._toggleSelect();
569                    }
570                    break;
571                // esc key
572                case 27:
573                    ev.preventDefault();
574                    if( self._isOpen() ) {
575                        self._toggleSelect();
576                    }
577                    break;
578            }
579        } );
580    }
581
582    /**
583     * navigate with up/dpwn keys
584     */
585    SelectFx.prototype._navigateOpts = function(dir) {
586        if( !this._isOpen() ) {
587            this._toggleSelect();
588        }
589
590        var tmpcurrent = typeof this.preSelCurrent != 'undefined' && this.preSelCurrent !== -1 ? this.preSelCurrent : this.current;
591        
592        if( dir === 'prev' && tmpcurrent > 0 || dir === 'next' && tmpcurrent < this.selOptsCount - 1 ) {
593            // save pre selected current - if we click on option, or press enter, or press space this is going to be the index of the current option
594            this.preSelCurrent = dir === 'next' ? tmpcurrent + 1 : tmpcurrent - 1;
595            // remove focus class if any..
596            this._removeFocus();
597            // add class focus - track which option we are navigating
598            classie.add( this.selOpts[this.preSelCurrent], 'cs-focus' );
599        }
600    }
601
602    /**
603     * open/close select
604     * when opened show the default placeholder if any
605     */
606    SelectFx.prototype._toggleSelect = function() {
607        var backdrop = this.selEl.querySelector('.cs-backdrop');
608        var container = document.querySelector(this.options.container);
609        var mask = container.querySelector('.dropdown-mask');
610        var csOptions = this.selEl.querySelector('.cs-options');
611        var csPlaceholder = this.selEl.querySelector('.cs-placeholder');
612
613        var csPlaceholderWidth = csPlaceholder.offsetWidth;
614         var csPlaceholderHeight = csPlaceholder.offsetHeight;
615        var csOptionsWidth = csOptions.scrollWidth;
616
617        if (this._isOpen()) {
618            if (this.current !== -1) {
619                // update placeholder text
620                this.selPlaceholder.textContent = this.selOpts[this.current].textContent;
621            }
622
623            var dummy = this.selEl.data;
624
625            var parent = dummy.parentNode;
626            //parent.appendChild(this.selEl);
627            insertAfter(this.selEl,dummy);
628            this.selEl.removeAttribute('style');
629
630            parent.removeChild(dummy);
631
632            // Hack for FF
633            // http://stackoverflow.com/questions/12088819/css-transitions-on-new-elements
634            var x = this.selEl.clientHeight;
635
636            // reset backdrop
637            backdrop.style.transform = backdrop.style.webkitTransform = backdrop.style.MozTransform = backdrop.style.msTransform = backdrop.style.OTransform = 'scale3d(1,1,1)';
638            classie.remove(this.selEl, 'cs-active');
639
640            mask.style.display = 'none';
641            csOptions.style.overflowY = 'hidden';
642            csOptions.style.width = 'auto';
643            
644            var parentFormGroup = closest(this.selEl,'.form-group');
645            parentFormGroup && classie.removeClass(parentFormGroup, 'focused');
646
647        } else {
648            if (this.hasDefaultPlaceholder && this.options.stickyPlaceholder) {
649                // everytime we open we wanna see the default placeholder text
650                this.selPlaceholder.textContent = this.selectedOpt.textContent;
651            }
652
653            var dummy;
654            if (this.selEl.parentNode.querySelector('.dropdown-placeholder')) {
655                dummy = this.selEl.parentNode.querySelector('.dropdown-placeholder');
656            } else {
657                dummy = document.createElement('div');
658                classie.add(dummy, 'dropdown-placeholder');
659                //this.selEl.parentNode.appendChild(dummy);
660                insertAfter(dummy, this.selEl);
661
662            }
663
664
665            dummy.style.height = csPlaceholderHeight + 'px';
666            dummy.style.width = this.selEl.offsetWidth + 'px';
667
668            this.selEl.data = dummy;
669
670
671
672            this.selEl.style.position = 'absolute';
673            var offsetselEl = offset(this.selEl);
674
675            this.selEl.style.left = offsetselEl.left + 'px';
676            this.selEl.style.top = offsetselEl.top + 'px';
677
678            container.appendChild(this.selEl);
679
680            // decide backdrop's scale factor depending on the content height
681            var contentHeight = csOptions.offsetHeight;
682            var originalHeight = csPlaceholder.offsetHeight;
683
684            var contentWidth = csOptions.offsetWidth;
685            var originalWidth = csPlaceholder.offsetWidth;
686
687            var scaleV = contentHeight / originalHeight ;
688            var scaleH = (contentWidth > originalWidth) ? contentWidth / originalWidth : 1.05;
689            //backdrop.style.transform = backdrop.style.webkitTransform = backdrop.style.MozTransform = backdrop.style.msTransform = backdrop.style.OTransform = 'scale3d(' + scaleH + ', ' + scaleV + ', 1)';
690            backdrop.style.transform = backdrop.style.webkitTransform = backdrop.style.MozTransform = backdrop.style.msTransform = backdrop.style.OTransform = 'scale3d(' + 1 + ', ' + scaleV + ', 1)';
691
692            if (!mask) {
693                mask = document.createElement('div');
694                classie.add(mask, 'dropdown-mask');
695                container.appendChild(mask);
696            }
697
698            mask.style.display = 'block';
699            
700            classie.add(this.selEl, 'cs-active');
701
702            var resizedWidth = (csPlaceholderWidth < csOptionsWidth) ? csOptionsWidth : csPlaceholderWidth;
703
704            this.selEl.style.width = resizedWidth + 'px';
705            this.selEl.style.height = originalHeight + 'px';
706            csOptions.style.width = '100%';
707
708            setTimeout(function() {
709                csOptions.style.overflowY = 'auto';
710            }, 300);
711
712        }
713    }
714
715    /**
716     * change option - the new value is set
717     */
718    SelectFx.prototype._changeOption = function() {
719        // if pre selected current (if we navigate with the keyboard)...
720        if( typeof this.preSelCurrent != 'undefined' && this.preSelCurrent !== -1 ) {
721            this.current = this.preSelCurrent;
722            this.preSelCurrent = -1;
723        }
724
725        // current option
726        var opt = this.selOpts[ this.current ];
727
728        // update current selected value
729        this.selPlaceholder.textContent = opt.textContent;
730        
731        // change native select element´s value
732        this.el.value = opt.getAttribute( 'data-value' );
733
734        // remove class cs-selected from old selected option and add it to current selected option
735        var oldOpt = this.selEl.querySelector( 'li.cs-selected' );
736        if( oldOpt ) {
737            classie.remove( oldOpt, 'cs-selected' );
738        }
739        classie.add( opt, 'cs-selected' );
740
741        // if there´s a link defined
742        if( opt.getAttribute( 'data-link' ) ) {
743            // open in new tab?
744            if( this.options.newTab ) {
745                window.open( opt.getAttribute( 'data-link' ), '_blank' );
746            }
747            else {
748                window.location = opt.getAttribute( 'data-link' );
749            }
750        }
751
752        // callback
753        this.options.onChange( this.el );
754    }
755
756    /**
757     * returns true if select element is opened
758     */
759    SelectFx.prototype._isOpen = function(opt) {
760        return classie.has( this.selEl, 'cs-active' );
761    }
762
763    /**
764     * removes the focus class from the option
765     */
766    SelectFx.prototype._removeFocus = function(opt) {
767        var focusEl = this.selEl.querySelector( 'li.cs-focus' )
768        if( focusEl ) {
769            classie.remove( focusEl, 'cs-focus' );
770        }
771    }
772
773    /**
774     * add to global namespace
775     */
776    window.SelectFx = SelectFx;
777
778} )( window );
779
780/* ============================================================
781 * Pages Chat
782 * ============================================================ */
783
784(function($) {
785  'use strict';
786  //To Open Chat When Clicked
787  $('[data-chat-input]').on('keypress',function(e){
788    if(e.which == 13) {
789       var el = $(this).attr('data-chat-conversation');
790       $(el).append('<div class="message clearfix">'+
791        '<div class="chat-bubble from-me">'+$(this).val()+
792        '</div></div>');
793       $(this).val('');
794    }
795  });
796
797})(window.jQuery);
798/* ============================================================
799 * Pages Circular Progress
800 * ============================================================ */
801
802(function($) {
803    'use strict';
804    // CIRCULAR PROGRESS CLASS DEFINITION
805    // ======================
806
807    var Progress = function(element, options) {
808        this.$element = $(element);
809        this.options = $.extend(true, {}, $.fn.circularProgress.defaults, options);
810
811
812        // start adding to to DOM
813        this.$container = $('<div class="progress-circle"></div>');
814
815        this.$element.attr('data-color') && this.$container.addClass('progress-circle-' + this.$element.attr('data-color'));
816        this.$element.attr('data-thick') && this.$container.addClass('progress-circle-thick');
817
818        this.$pie = $('<div class="pie"></div>');
819
820        this.$pie.$left = $('<div class="left-side half-circle"></div>');
821        this.$pie.$right = $('<div class="right-side half-circle"></div>');
822
823        this.$pie.append(this.$pie.$left).append(this.$pie.$right);
824
825        this.$container.append(this.$pie).append('<div class="shadow"></div>');
826
827        this.$element.after(this.$container);
828        // end DOM adding
829
830        this.val = this.$element.val();
831        var deg = perc2deg(this.val);
832
833
834        if (this.val <= 50) {
835            this.$pie.$right.css('transform', 'rotate(' + deg + 'deg)');
836        } else {
837            this.$pie.css('clip', 'rect(auto, auto, auto, auto)');
838            this.$pie.$right.css('transform', 'rotate(180deg)');
839            this.$pie.$left.css('transform', 'rotate(' + deg + 'deg)');
840        }
841
842    }
843    Progress.VERSION = "1.0.0";
844
845    Progress.prototype.value = function(val) {
846        if (typeof val == 'undefined') return;
847
848        var deg = perc2deg(val);
849
850        this.$pie.removeAttr('style');
851
852        this.$pie.$right.removeAttr('style');
853        this.$pie.$left.removeAttr('style');
854
855        if (val <= 50) {
856            this.$pie.$right.css('transform', 'rotate(' + deg + 'deg)');
857        } else {
858            this.$pie.css('clip', 'rect(auto, auto, auto, auto)');
859            this.$pie.$right.css('transform', 'rotate(180deg)');
860            this.$pie.$left.css('transform', 'rotate(' + deg + 'deg)');
861        }
862
863    }
864
865    // CIRCULAR PROGRESS PLUGIN DEFINITION
866    // =======================
867    function Plugin(option) {
868        return this.filter(':input').each(function() {
869            var $this = $(this);
870            var data = $this.data('pg.circularProgress');
871            var options = typeof option == 'object' && option;
872
873            if (!data) $this.data('pg.circularProgress', (data = new Progress(this, options)));
874            if (typeof option == 'string') data[option]();
875            else if (options.hasOwnProperty('value')) data.value(options.value);
876        })
877    }
878
879    var old = $.fn.circularProgress
880
881    $.fn.circularProgress = Plugin
882    $.fn.circularProgress.Constructor = Progress
883
884
885    $.fn.circularProgress.defaults = {
886        value: 0
887    }
888
889    // CIRCULAR PROGRESS NO CONFLICT
890    // ====================
891
892    $.fn.circularProgress.noConflict = function() {
893        $.fn.circularProgress = old;
894        return this;
895    }
896
897    // CIRCULAR PROGRESS DATA API
898    //===================
899
900    $(window).on('load', function() {
901        $('[data-pages-progress="circle"]').each(function() {
902            var $progress = $(this)
903            $progress.circularProgress($progress.data())
904        })
905    })
906
907    function perc2deg(p) {
908        return parseInt(p / 100 * 360);
909    }
910
911    // TODO: Add API to change size, stroke width, color
912
913})(window.jQuery);
914
915/* ============================================================
916 * Pages Notifications
917 * ============================================================ */
918
919(function($) {
920
921    'use strict';
922
923    var Notification = function(container, options) {
924
925        var self = this;
926
927        // Element collection
928        self.container = $(container); // 'body' recommended
929        self.notification = $('<div class="pgn"></div>');
930        self.options = $.extend(true, {}, $.fn.pgNotification.defaults, options);
931
932        if (!self.container.find('.pgn-wrapper[data-position=' + this.options.position + ']').length) {
933            self.wrapper = $('<div class="pgn-wrapper" data-position="' + this.options.position + '"></div>');
934            self.container.append(self.wrapper);
935        } else {
936            self.wrapper = $('.pgn-wrapper[data-position=' + this.options.position + ']');
937        }
938
939        self.alert = $('<div class="alert"></div>');
940        self.alert.addClass('alert-' + self.options.type);
941
942        if (self.options.style == 'bar') {
943            new BarNotification();
944        } else if (self.options.style == 'flip') {
945            new FlipNotification();
946        } else if (self.options.style == 'circle') {
947            new CircleNotification();
948        } else if (self.options.style == 'simple') {
949            new SimpleNotification();
950        } else { // default = 'simple'
951            new SimpleNotification();
952        }
953
954        // Notification styles
955        function SimpleNotification() {
956
957            self.notification.addClass('pgn-simple');
958
959            self.alert.append(self.options.message);
960            if (self.options.showClose) {
961                var close = $('<button type="button" class="close" data-dismiss="alert"></button>')
962                    .append('<span aria-hidden="true">&times;</span>')
963                    .append('<span class="sr-only">Close</span>');
964
965                self.alert.prepend(close);
966            }
967
968        }
969
970        function BarNotification() {
971
972            self.notification.addClass('pgn-bar');
973
974            self.alert.append('<span>' + self.options.message + '</span>');
975            self.alert.addClass('alert-' + self.options.type);
976
977
978            if (self.options.showClose) {
979                var close = $('<button type="button" class="close" data-dismiss="alert"></button>')
980                    .append('<span aria-hidden="true">&times;</span>')
981                    .append('<span class="sr-only">Close</span>');
982
983                self.alert.prepend(close);
984            }
985
986        }
987
988        function CircleNotification() {
989
990            self.notification.addClass('pgn-circle');
991
992            var table = '<div>';
993            if (self.options.thumbnail) {
994                table += '<div class="pgn-thumbnail"><div>' + self.options.thumbnail + '</div></div>';
995            }
996
997            table += '<div class="pgn-message"><div>';
998
999            if (self.options.title) {
1000                table += '<p class="bold">' + self.options.title + '</p>';
1001            }
1002            table += '<p>' + self.options.message + '</p></div></div>';
1003            table += '</div>';
1004
1005            if (self.options.showClose) {
1006                table += '<button type="button" class="close" data-dismiss="alert">';
1007                table += '<span aria-hidden="true">&times;</span><span class="sr-only">Close</span>';
1008                table += '</button>';
1009            }
1010
1011
1012            self.alert.append(table);
1013            self.alert.after('<div class="clearfix"></div>');
1014
1015        }
1016
1017        function FlipNotification() {
1018
1019            self.notification.addClass('pgn-flip');
1020            self.alert.append("<span>" + self.options.message + "</span>");
1021            if (self.options.showClose) {
1022                var close = $('<button type="button" class="close" data-dismiss="alert"></button>')
1023                    .append('<span aria-hidden="true">&times;</span>')
1024                    .append('<span class="sr-only">Close</span>');
1025
1026                self.alert.prepend(close);
1027            }
1028
1029        }
1030
1031        self.notification.append(self.alert);
1032
1033        // bind to Bootstrap closed event for alerts 
1034        self.alert.on('closed.bs.alert', function() {
1035            self.notification.remove();
1036            self.options.onClosed();
1037            // refresh layout after removal
1038        });
1039
1040        return this; // enable chaining
1041    };
1042
1043    Notification.VERSION = "1.0.0";
1044    
1045    Notification.prototype.show = function() {
1046
1047        // TODO: add fadeOut animation on show as option
1048        this.wrapper.prepend(this.notification);
1049
1050        this.options.onShown();
1051
1052        if (this.options.timeout != 0) {
1053            var _this = this;
1054            // settimeout removes scope. use .bind(this)
1055            setTimeout(function() {
1056                this.notification.fadeOut("slow", function() {
1057                    $(this).remove();
1058                    _this.options.onClosed();
1059                });
1060            }.bind(this), this.options.timeout);
1061        }
1062
1063    };
1064
1065    $.fn.pgNotification = function(options) {
1066        return new Notification(this, options);
1067    };
1068
1069    $.fn.pgNotification.defaults = {
1070        style: 'simple',
1071        message: null,
1072        position: 'top-right',
1073        type: 'info',
1074        showClose: true,
1075        timeout: 4000,
1076        onShown: function() {},
1077        onClosed: function() {}
1078    }
1079})(window.jQuery);
1080/* ============================================================
1081 * Pages Portlet
1082 * ============================================================ */
1083
1084(function($) {
1085    'use strict';
1086    // PORTLET CLASS DEFINITION
1087    // ======================
1088
1089    var Portlet = function(element, options) {
1090        this.$element = $(element);
1091        this.options = $.extend(true, {}, $.fn.portlet.defaults, options);
1092        this.$loader = null;
1093        this.$body = this.$element.find('.panel-body');
1094    }
1095    Portlet.VERSION = "1.0.0";
1096    // Button actions
1097    Portlet.prototype.collapse = function() {
1098        var icon = this.$element.find('[data-toggle="collapse"] > i');
1099        var heading = this.$element.find('.panel-heading');
1100
1101        this.$body.stop().slideToggle("fast");
1102
1103        if (this.$element.hasClass('panel-collapsed')) {
1104            this.$element.removeClass('panel-collapsed');
1105            icon.removeClass().addClass('pg-arrow_maximize');
1106            $.isFunction(this.options.onExpand) && this.options.onExpand();
1107            return
1108        }
1109        this.$element.addClass('panel-collapsed');
1110        icon.removeClass().addClass('pg-arrow_minimize');
1111        $.isFunction(this.options.onCollapse) && this.options.onCollapse();
1112    }
1113
1114    Portlet.prototype.close = function() {
1115        this.$element.remove();
1116        $.isFunction(this.options.onClose) && this.options.onClose();
1117    }
1118
1119    Portlet.prototype.maximize = function() {
1120        var icon = this.$element.find('[data-toggle="maximize"] > i');
1121
1122        if (this.$element.hasClass('panel-maximized')) {
1123            this.$element.removeClass('panel-maximized');
1124            icon.removeClass('pg-fullscreen_restore').addClass('pg-fullscreen');
1125            $.isFunction(this.options.onRestore) && this.options.onRestore();
1126        } else {
1127            this.$element.addClass('panel-maximized');
1128            icon.removeClass('pg-fullscreen').addClass('pg-fullscreen_restore');
1129            $.isFunction(this.options.onMaximize) && this.options.onMaximize();
1130        }
1131    }
1132
1133    // Options
1134    Portlet.prototype.refresh = function(refresh) {
1135        var toggle = this.$element.find('[data-toggle="refresh"]');
1136
1137        if (refresh) {
1138            if (this.$loader && this.$loader.is(':visible')) return;
1139            if (!$.isFunction(this.options.onRefresh)) return; // onRefresh() not set
1140            this.$loader = $('<div class="portlet-progress"></div>');
1141            this.$loader.css({
1142                'background-color': 'rgba('+this.options.overlayColor+','+this.options.overlayOpacity+')'
1143           
1144            });
1145
1146            var elem = '';
1147            if (this.options.progress == 'circle') {
1148                elem += '<div class="progress-circle-indeterminate progress-circle-' + this.options.progressColor + '"></div>';
1149            } else if (this.options.progress == 'bar') {
1150
1151                elem += '<div class="progress progress-small">';
1152                elem += '    <div class="progress-bar-indeterminate progress-bar-' + this.options.progressColor + '"></div>';
1153                elem += '</div>';
1154            } else if (this.options.progress == 'circle-lg') {
1155                toggle.addClass('refreshing');
1156                var iconOld = toggle.find('> i').first();
1157                var iconNew;
1158                if (!toggle.find('[class$="-animated"]').length) {
1159                    iconNew = $('<i/>');
1160                    iconNew.css({
1161                        'position': 'absolute',
1162                        'top': iconOld.position().top,
1163                        'left': iconOld.position().left
1164                    });
1165                    iconNew.addClass('portlet-icon-refresh-lg-' + this.options.progressColor + '-animated');
1166                    toggle.append(iconNew);
1167                } else {
1168                    iconNew = toggle.find('[class$="-animated"]');
1169                }
1170
1171                iconOld.addClass('fade');
1172                iconNew.addClass('active');
1173
1174
1175            } else {
1176                elem += '<div class="progress progress-small">';
1177                elem += '    <div class="progress-bar-indeterminate progress-bar-' + this.options.progressColor + '"></div>';
1178                elem += '</div>';
1179            }
1180
1181            this.$loader.append(elem);
1182            this.$element.append(this.$loader);
1183
1184            // Start Fix for FF: pre-loading animated to SVGs
1185            var _loader = this.$loader;
1186            setTimeout(function(){
1187                this.$loader.remove();
1188                this.$element.append(_loader);
1189            }.bind(this), 300);
1190            // End fix
1191            this.$loader.fadeIn();
1192
1193            $.isFunction(this.options.onRefresh) && this.options.onRefresh();
1194
1195        } else {
1196            var _this = this;
1197            this.$loader.fadeOut(function() {
1198                $(this).remove();
1199                if (_this.options.progress == 'circle-lg') {
1200                    var iconNew = toggle.find('.active');
1201                    var iconOld = toggle.find('.fade');
1202                    iconNew.removeClass('active');
1203                    iconOld.removeClass('fade');
1204                    toggle.removeClass('refreshing');
1205
1206                }
1207                _this.options.refresh = false;
1208            });
1209        }
1210    }
1211
1212    Portlet.prototype.error = function(error) {
1213        if (error) {
1214            var _this = this;
1215            this.$element.pgNotification({
1216                style: 'bar',
1217                message: error,
1218                position: 'top',
1219                timeout: 0,
1220                type: 'danger',
1221                onShown: function() {
1222                    _this.$loader.find('> div').fadeOut()
1223                },
1224                onClosed: function() {
1225                    _this.refresh(false)
1226                }
1227            }).show();
1228        }
1229    }
1230
1231    // PORTLET PLUGIN DEFINITION
1232    // =======================
1233
1234    function Plugin(option) {
1235        return this.each(function() {
1236            var $this = $(this);
1237            var data = $this.data('pg.portlet');
1238            var options = typeof option == 'object' && option;
1239
1240            if (!data) $this.data('pg.portlet', (data = new Portlet(this, options)));
1241            if (typeof option == 'string') data[option]();
1242            else if (options.hasOwnProperty('refresh')) data.refresh(options.refresh);
1243            else if (options.hasOwnProperty('error')) data.error(options.error);
1244        })
1245    }
1246
1247    var old = $.fn.portlet
1248
1249    $.fn.portlet = Plugin
1250    $.fn.portlet.Constructor = Portlet
1251
1252
1253    $.fn.portlet.defaults = {
1254        progress: 'circle',
1255        progressColor: 'master',
1256        refresh: false,
1257        error: null,
1258        overlayColor: '255,255,255',
1259        overlayOpacity: 0.8
1260            // onRefresh: function() {},
1261            // onCollapse: function() {},
1262            // onExpand: function() {},
1263            // onMaximize: function() {},
1264            // onRestore: function() {},
1265            // onClose: function() {}
1266    }
1267
1268    // PORTLET NO CONFLICT
1269    // ====================
1270
1271    $.fn.portlet.noConflict = function() {
1272        $.fn.portlet = old;
1273        return this;
1274    }
1275
1276    // PORTLET DATA API
1277    //===================
1278
1279    $(document).on('click.pg.portlet.data-api', '[data-toggle="collapse"]', function(e) {
1280        var $this = $(this);
1281        var $target = $this.closest('.panel');
1282        if ($this.is('a')) e.preventDefault();
1283        $target.data('pg.portlet') && $target.portlet('collapse');
1284    })
1285
1286    $(document).on('click.pg.portlet.data-api', '[data-toggle="close"]', function(e) {
1287        var $this = $(this);
1288        var $target = $this.closest('.panel');
1289        if ($this.is('a')) e.preventDefault();
1290        $target.data('pg.portlet') && $target.portlet('close');
1291    })
1292
1293    $(document).on('click.pg.portlet.data-api', '[data-toggle="refresh"]', function(e) {
1294        var $this = $(this);
1295        var $target = $this.closest('.panel');
1296        if ($this.is('a')) e.preventDefault();
1297        $target.data('pg.portlet') && $target.portlet({
1298            refresh: true
1299        })
1300    })
1301
1302    $(document).on('click.pg.portlet.data-api', '[data-toggle="maximize"]', function(e) {
1303        var $this = $(this);
1304        var $target = $this.closest('.panel');
1305        if ($this.is('a')) e.preventDefault();
1306        $target.data('pg.portlet') && $target.portlet('maximize');
1307    })
1308
1309    $(window).on('load', function() {
1310        $('[data-pages="portlet"]').each(function() {
1311            var $portlet = $(this)
1312            $portlet.portlet($portlet.data())
1313        })
1314    })
1315
1316})(window.jQuery);
1317/* ============================================================
1318 * Pages Quickview Plugin
1319 * ============================================================ */
1320
1321(function($) {
1322    'use strict';
1323    // QUICKVIEW CLASS DEFINITION
1324    // ======================
1325
1326    var Quickview = function(element, options) {
1327        this.$element = $(element);
1328        this.options = $.extend(true, {}, $.fn.quickview.defaults, options);
1329        this.bezierEasing = [.05, .74, .27, .99];
1330        var _this = this;
1331
1332        $(this.options.notes).on('click', '.list > ul > li', function(e) {
1333            var note = $(this).find('.note-preview');
1334            var note = $(this).find('.note-preview');
1335            $(_this.options.noteEditor).html(note.html());
1336            $(_this.options.notes).toggleClass('push');
1337        });
1338        $(this.options.notes).on('click', '.list > ul > li .checkbox', function(e) {
1339            e.stopPropagation();
1340        });
1341        $(this.options.notes).on('click', _this.options.backButton, function(e) {
1342            $(_this.options.notes).find('.toolbar > li > a').removeClass('active');
1343            $(_this.options.notes).toggleClass('push');
1344        });
1345        $(this.options.deleteNoteButton).click(function(e) {
1346            e.preventDefault();
1347            $(this).toggleClass('selected');
1348            $(_this.options.notes).find('.list > ul > li .checkbox').fadeToggle("fast");
1349            $(_this.options.deleteNoteConfirmButton).fadeToggle("fast").removeClass('hide');
1350        });
1351        $(this.options.newNoteButton).click(function(e) {
1352            e.preventDefault();
1353            $(_this.options.noteEditor).html('');
1354        });
1355
1356        $(this.options.deleteNoteConfirmButton).click(function() {
1357            var checked = $(_this.options.notes).find('input[type=checkbox]:checked');
1358            checked.each(function() {
1359                $(this).parents('li').remove();
1360            });
1361        });
1362        $(this.options.notes).on('click', '.toolbar > li > a', function(e) {
1363            //e.preventDefault();
1364            var command = $(this).attr('data-action');
1365            document.execCommand(command, false, null);
1366            $(this).toggleClass('active');
1367        });
1368
1369    }
1370    Quickview.VERSION = "1.0.0";
1371
1372    // QUICKVIEW PLUGIN DEFINITION
1373    // =======================
1374    function Plugin(option) {
1375        return this.each(function() {
1376            var $this = $(this);
1377            var data = $this.data('pg.quickview');
1378            var options = typeof option == 'object' && option;
1379
1380            if (!data) $this.data('pg.quickview', (data = new Quickview(this, options)));
1381            if (typeof option == 'string') data[option]();
1382        })
1383    }
1384
1385    var old = $.fn.quickview
1386
1387    $.fn.quickview = Plugin
1388    $.fn.quickview.Constructor = Quickview
1389
1390
1391    $.fn.quickview.defaults = {
1392        notes: '#note-views',
1393        alerts: '#alerts',
1394        chat: '#chat',
1395        notesList: '.list',
1396        noteEditor: '.quick-note-editor',
1397        deleteNoteButton: '.delete-note-link',
1398        deleteNoteConfirmButton: '.btn-remove-notes',
1399        newNoteButton: '.new-note-link',
1400        backButton: '.close-note-link'
1401    }
1402
1403    // QUICKVIEW NO CONFLICT
1404    // ====================
1405
1406    $.fn.quickview.noConflict = function() {
1407        $.fn.quickview = old;
1408        return this;
1409    }
1410
1411    // QUICKVIEW DATA API
1412    //===================
1413
1414    $(window).on('load', function() {
1415
1416        $('[data-pages="quickview"]').each(function() {
1417            var $quickview = $(this)
1418            $quickview.quickview($quickview.data())
1419        })
1420    });
1421
1422
1423    $(document).on('click.pg.quickview.data-api touchstart', '[data-toggle="quickview"]', function(e) {
1424        var elem = $(this).attr('data-toggle-element');
1425        if (Modernizr.csstransitions) {
1426            $(elem).toggleClass('open');
1427        } else {
1428            var width = $(elem).width();
1429            if (!$(elem).hasClass('open-ie')) {
1430                $(elem).stop().animate({
1431                    right: -1 * width
1432                }, 400, $.bez([.05, .74, .27, .99]), function() {
1433                    $(elem).addClass('open-ie')
1434                });
1435            } else {
1436                $(elem).stop().animate({
1437                    right: 0
1438                }, 400, $.bez([.05, .74, .27, .99]), function() {
1439                    $(elem).removeClass('open-ie')
1440                });
1441            }
1442        }
1443        e.preventDefault();
1444    })
1445
1446})(window.jQuery);
1447/* ============================================================
1448 * Pages Parallax Plugin
1449 * ============================================================ */
1450
1451(function($) {
1452    'use strict';
1453    // PARALLAX CLASS DEFINITION
1454    // ======================
1455
1456    var Parallax = function(element, options) {
1457        this.$element = $(element);
1458        this.options = $.extend(true, {}, $.fn.parallax.defaults, options);
1459        this.$coverPhoto = this.$element.find('.cover-photo');
1460        // TODO: rename .inner to .page-cover-content
1461        this.$content = this.$element.find('.inner');
1462
1463        // if cover photo img is found make it a background-image
1464        if (this.$coverPhoto.find('> img').length) {
1465            var img = this.$coverPhoto.find('> img');
1466            this.$coverPhoto.css('background-image', 'url(' + img.attr('src') + ')');
1467            img.remove();
1468        }
1469
1470    }
1471    Parallax.VERSION = "1.0.0";
1472
1473    Parallax.prototype.animate = function() {
1474
1475        var scrollPos;
1476        var pagecoverWidth = this.$element.height();
1477        //opactiy to text starts at 50% scroll length
1478        var opacityKeyFrame = pagecoverWidth * 50 / 100;
1479        var direction = 'translateX';
1480
1481        scrollPos = $(window).scrollTop();
1482        direction = 'translateY';
1483
1484
1485        this.$coverPhoto.css({
1486            'transform': direction + '(' + scrollPos * this.options.speed.coverPhoto + 'px)'
1487        });
1488
1489        this.$content.css({
1490            'transform': direction + '(' + scrollPos * this.options.speed.content + 'px)',
1491        });
1492
1493        if (scrollPos > opacityKeyFrame) {
1494            this.$content.css({
1495                'opacity': 1 - scrollPos / 1200
1496            });
1497        } else {
1498            this.$content.css({
1499                'opacity': 1
1500            });
1501        }
1502
1503    }
1504
1505    // PARALLAX PLUGIN DEFINITION
1506    // =======================
1507    function Plugin(option) {
1508        return this.each(function() {
1509            var $this = $(this);
1510            var data = $this.data('pg.parallax');
1511            var options = typeof option == 'object' && option;
1512
1513            if (!data) $this.data('pg.parallax', (data = new Parallax(this, options)));
1514            if (typeof option == 'string') data[option]();
1515        })
1516    }
1517
1518    var old = $.fn.parallax
1519
1520    $.fn.parallax = Plugin
1521    $.fn.parallax.Constructor = Parallax
1522
1523
1524    $.fn.parallax.defaults = {
1525        speed: {
1526            coverPhoto: 0.3,
1527            content: 0.17
1528        }
1529    }
1530
1531    // PARALLAX NO CONFLICT
1532    // ====================
1533    
1534    $.fn.parallax.noConflict = function() {
1535        $.fn.parallax = old;
1536        return this;
1537    }
1538
1539    // PARALLAX DATA API
1540    //===================
1541
1542    $(window).on('load', function() {
1543
1544        $('[data-pages="parallax"]').each(function() {
1545            var $parallax = $(this)
1546            $parallax.parallax($parallax.data())
1547        })
1548    });
1549
1550    $(window).on('scroll', function() {
1551        // Disable parallax for Touch devices
1552        if (Modernizr.touch) {
1553            return;
1554        }
1555        $('[data-pages="parallax"]').parallax('animate');
1556    });
1557
1558})(window.jQuery);
1559 /* ============================================================
1560  * Pages Sidebar
1561  * ============================================================ */
1562
1563 (function($) {
1564     'use strict';
1565     // SIDEBAR CLASS DEFINITION
1566     // ======================
1567
1568     var Sidebar = function(element, options) {
1569         this.$element = $(element);
1570         this.options = $.extend(true, {}, $.fn.sidebar.defaults, options);
1571
1572         this.bezierEasing = [.05, .74, .27, .99];
1573         this.cssAnimation = true;
1574         this.menuClosedCSS;
1575         this.menuOpenCSS;
1576         this.css3d = true;
1577
1578         this.sideBarWidth = 280;
1579         this.sideBarWidthCondensed = 280 - 70;
1580
1581         this.$sidebarMenu = this.$element.find('.sidebar-menu > ul');
1582         this.$pageContainer = $(this.options.pageContainer);
1583         this.$body = $('body');
1584
1585         if (!this.$sidebarMenu.length) return;
1586
1587         // apply perfectScrollbar plugin only for desktops
1588         ($.Pages.getUserAgent() == 'desktop') && this.$sidebarMenu.scrollbar({
1589             ignoreOverlay:false
1590         });
1591
1592
1593         if (!Modernizr.csstransitions)
1594             this.cssAnimation = false;
1595         if (!Modernizr.csstransforms3d)
1596             this.css3d = false;
1597
1598         this.menuOpenCSS = (this.css3d == true ? 'translate3d(' + this.sideBarWidthCondensed + 'px, 0,0)' : 'translate(' + this.sideBarWidthCondensed + 'px, 0)');
1599         this.menuClosedCSS = (this.css3d == true ? 'translate3d(0, 0,0)' : 'translate(0, 0)');
1600
1601
1602         // Bind events
1603         // Toggle sub menus
1604         this.$sidebarMenu.find('li > a').on('click', function(e) {
1605
1606             if ($(this).parent().children('.sub-menu') === false) {
1607                 return;
1608             }
1609
1610             var parent = $(this).parent().parent();
1611             var tempElem = $(this).parent();
1612
1613             parent.children('li.open').children('a').children('.arrow').removeClass('open');
1614             parent.children('li.open').children('a').children('.arrow').removeClass('active');
1615             parent.children('li.open').children('.sub-menu').slideUp(200, function() {
1616
1617             });
1618             parent.children('li').removeClass('open');
1619             var sub = $(this).parent().children('.sub-menu');
1620             if (sub.is(":visible")) {
1621                 $('.arrow', $(this)).removeClass("open");
1622
1623                 sub.slideUp(200, function() {
1624                     $(this).parent().removeClass("active");
1625                 });
1626             } else {
1627                 $('.arrow', $(this)).addClass("open");
1628                 $(this).parent().addClass("open");
1629                 sub.slideDown(200, function() {});
1630             }
1631             //e.preventDefault();
1632         });
1633
1634         // Toggle sidebar
1635         $('.sidebar-slide-toggle').on('click touchend',function(e) {
1636            e.preventDefault();
1637             $(this).toggleClass('active');
1638             var el = $(this).attr('data-pages-toggle');
1639             if (el != null) {
1640                 $(el).toggleClass('show');
1641             }
1642         });
1643
1644         var _this = this;
1645
1646         function sidebarMouseEnter(e) {
1647             if ($.Pages.isVisibleSm() || $.Pages.isVisibleXs()) {
1648                 return false
1649             }
1650             if ($('.close-sidebar').data('clicked')) {
1651                 return;
1652             }
1653             if (_this.$body.hasClass('menu-pin'))
1654                 return;
1655             if (_this.cssAnimation) {
1656                 _this.$element.css({
1657                     'transform': _this.menuOpenCSS
1658                 });
1659                 _this.$body.addClass('sidebar-visible');
1660             } else {
1661                 _this.$element.stop().animate({
1662                     left: '0px'
1663                 }, 400, $.bez(_this.bezierEasing), function() {
1664                     _this.$body.addClass('sidebar-visible');
1665                 });
1666             }
1667         }
1668
1669         function sidebarMouseLeave(e) {
1670             if ($.Pages.isVisibleSm() || $.Pages.isVisibleXs()) {
1671                 return false
1672             }
1673             if (typeof e != 'undefined') {
1674                 var target = $(e.target);
1675                 if (target.parent('.page-sidebar').length) {
1676                     return;
1677                 }
1678             }
1679             if (_this.$body.hasClass('menu-pin'))
1680                 return;
1681
1682             if ($('.sidebar-overlay-slide').hasClass('show')) {
1683                 $('.sidebar-overlay-slide').removeClass('show')
1684                 $("[data-pages-toggle']").removeClass('active')
1685
1686             }
1687
1688             if (_this.cssAnimation) {
1689                 _this.$element.css({
1690                     'transform': _this.menuClosedCSS
1691                 });
1692                 _this.$body.removeClass('sidebar-visible');
1693             } else {
1694
1695                 _this.$element.stop().animate({
1696                     left: '-' + _this.sideBarWidthCondensed + 'px'
1697                 }, 400, $.bez(_this.bezierEasing), function() {
1698
1699                     _this.$body.removeClass('sidebar-visible')
1700                     setTimeout(function() {
1701                         $('.close-sidebar').data({
1702                             clicked: false
1703                         });
1704                     }, 100);
1705                 });
1706             }
1707         }
1708
1709
1710         this.$element.bind('mouseenter mouseleave', sidebarMouseEnter);
1711         this.$pageContainer.bind('mouseover', sidebarMouseLeave);
1712
1713     }
1714
1715
1716     // Toggle sidebar for mobile view   
1717     Sidebar.prototype.toggleSidebar = function(toggle) {
1718         var timer;
1719         if (this.$body.hasClass('sidebar-open')) {
1720             this.$body.removeClass('sidebar-open');
1721             timer = setTimeout(function() {
1722                 this.$element.removeClass('visible');
1723             }.bind(this), 400);
1724         } else {
1725             clearTimeout(timer);
1726             this.$element.addClass('visible');
1727             setTimeout(function() {
1728                 this.$body.addClass('sidebar-open');
1729             }.bind(this), 10);
1730
1731         }
1732
1733     }
1734
1735     Sidebar.prototype.togglePinSidebar = function(toggle) {
1736         if (toggle == 'hide') {
1737             this.$body.removeClass('menu-pin');
1738         } else if (toggle == 'show') {
1739             this.$body.addClass('menu-pin');
1740         } else {
1741             this.$body.toggleClass('menu-pin');
1742         }
1743
1744     }
1745
1746
1747     // SIDEBAR PLUGIN DEFINITION
1748     // =======================
1749     function Plugin(option) {
1750         return this.each(function() {
1751             var $this = $(this);
1752             var data = $this.data('pg.sidebar');
1753             var options = typeof option == 'object' && option;
1754
1755             if (!data) $this.data('pg.sidebar', (data = new Sidebar(this, options)));
1756             if (typeof option == 'string') data[option]();
1757         })
1758     }
1759
1760     var old = $.fn.sidebar;
1761
1762     $.fn.sidebar = Plugin;
1763     $.fn.sidebar.Constructor = Sidebar;
1764
1765
1766     $.fn.sidebar.defaults = {
1767         pageContainer: '.page-container'
1768     }
1769
1770     // SIDEBAR PROGRESS NO CONFLICT
1771     // ====================
1772
1773     $.fn.sidebar.noConflict = function() {
1774         $.fn.sidebar = old;
1775         return this;
1776     }
1777
1778     // SIDEBAR PROGRESS DATA API
1779     //===================
1780
1781     $(document).on('ready', function() {
1782         $('[data-pages="sidebar"]').each(function() {
1783             var $sidebar = $(this)
1784             $sidebar.sidebar($sidebar.data())
1785         })
1786     })
1787
1788     $(document).on('click.pg.sidebar.data-api', '[data-toggle-pin="sidebar"]', function(e) {
1789         e.preventDefault();
1790         var $this = $(this);
1791         var $target = $('[data-pages="sidebar"]');
1792         $target.data('pg.sidebar').togglePinSidebar();
1793         return false;
1794     })
1795     $(document).on('click.pg.sidebar.data-api touchstart', '[data-toggle="sidebar"]', function(e) {
1796         e.preventDefault();
1797         var $this = $(this);
1798         var $target = $('[data-pages="sidebar"]');
1799         $target.data('pg.sidebar').toggleSidebar();
1800         return false
1801     })
1802
1803 })(window.jQuery);
1804/* ============================================================
1805 * Pages Search overlay
1806 * ============================================================ */
1807
1808(function($) {
1809
1810    'use strict';
1811
1812    // SEARCH CLASS DEFINITION
1813    // ======================
1814
1815    var Search = function(element, options) {
1816        this.$element = $(element);
1817        this.options = $.extend(true, {}, $.fn.search.defaults, options);
1818        this.init();
1819    }
1820    Search.VERSION = "1.0.0";
1821
1822    Search.prototype.init = function() {
1823        var _this = this;
1824        this.pressedKeys = [];
1825        this.ignoredKeys = [];
1826
1827        //Cache elements
1828        this.$searchField = this.$element.find(this.options.searchField);
1829        this.$closeButton = this.$element.find(this.options.closeButton);
1830        this.$suggestions = this.$element.find(this.options.suggestions);
1831        this.$brand = this.$element.find(this.options.brand);
1832
1833        this.$searchField.on('keyup', function(e) {
1834            _this.$suggestions.html($(this).val());
1835        });
1836
1837        this.$searchField.on('keyup', function(e) {
1838            _this.options.onKeyEnter(_this.$searchField.val());
1839            if (e.keyCode == 13) { //Enter pressed
1840                e.preventDefault();
1841                _this.options.onSearchSubmit(_this.$searchField.val());
1842            }
1843            if ($('body').hasClass('overlay-disabled')) {
1844                return 0;
1845            }
1846
1847        });
1848
1849        this.$closeButton.on('click', function() {
1850            _this.toggleOverlay('hide');
1851        });
1852
1853        this.$element.on('click', function(e) {
1854            if ($(e.target).data('pages') == 'search') {
1855                _this.toggleOverlay('hide');
1856            }
1857        });
1858
1859        $(document).on('keypress.pg.search', function(e) {
1860            _this.keypress(e);
1861        });
1862
1863        $(document).on('keyup', function(e) {
1864            // Dismiss overlay on ESC is pressed
1865            if (_this.$element.is(':visible') && e.keyCode == 27) {
1866                _this.toggleOverlay('hide');
1867            }
1868        });
1869
1870    }
1871
1872
1873    Search.prototype.keypress = function(e) {
1874
1875        e = e || event; // to deal with IE
1876        var nodeName = e.target.nodeName;
1877        if ($('body').hasClass('overlay-disabled') ||
1878            $(e.target).hasClass('js-input') ||
1879            nodeName == 'INPUT' ||
1880            nodeName == 'TEXTAREA') {
1881            return;
1882        }
1883
1884        if (e.which !== 0 && e.charCode !== 0 && !e.ctrlKey && !e.metaKey && !e.altKey) {
1885            this.toggleOverlay('show', String.fromCharCode(e.keyCode | e.charCode));
1886        }
1887    }
1888
1889
1890    Search.prototype.toggleOverlay = function(action, key) {
1891        var _this = this;
1892        if (action == 'show') {
1893            this.$element.removeClass("hide");
1894            this.$element.fadeIn("fast");
1895            if(!this.$searchField.is(':focus')) { 
1896                this.$searchField.val(key);
1897                setTimeout(function(){
1898                    this.$searchField.focus();
1899                    var tmpStr = this.$searchField.val();
1900                        this.$searchField.val('');
1901                        this.$searchField.val(tmpStr);
1902                }.bind(this), 100);
1903            }
1904
1905            this.$element.removeClass("closed");
1906            this.$brand.toggleClass('invisible');
1907            $(document).off('keypress.pg.search');
1908        } else {
1909            this.$element.fadeOut("fast").addClass("closed");
1910            this.$searchField.val('').blur();
1911            setTimeout(function() {
1912                if ((this.$element).is(':visible')) {
1913                    this.$brand.toggleClass('invisible');
1914                }
1915                $(document).on('keypress.pg.search', function(e) {
1916                    _this.keypress(e);
1917                });
1918            }.bind(this), 100);
1919        }
1920    };
1921
1922    // SEARCH PLUGIN DEFINITION
1923    // =======================
1924
1925
1926    function Plugin(option) {
1927        return this.each(function() {
1928            var $this = $(this);
1929            var data = $this.data('pg.search');
1930            var options = typeof option == 'object' && option;
1931
1932            if (!data) {
1933                $this.data('pg.search', (data = new Search(this, options)));
1934
1935            }
1936            if (typeof option == 'string') data[option]();
1937        })
1938    }
1939
1940    var old = $.fn.search
1941
1942    $.fn.search = Plugin
1943    $.fn.search.Constructor = Search
1944
1945    $.fn.search.defaults = {
1946        searchField: '[data-search="searchField"]',
1947        closeButton: '[data-search="closeButton"]',
1948        suggestions: '[data-search="suggestions"]',
1949        brand: '[data-search="brand"]'
1950    }
1951
1952    // SEARCH NO CONFLICT
1953    // ====================
1954
1955    $.fn.search.noConflict = function() {
1956        $.fn.search = old;
1957        return this;
1958    }
1959
1960    $(document).on('click.pg.search.data-api', '[data-toggle="search"]', function(e) {
1961        var $this = $(this);
1962        var $target = $('[data-pages="search"]');
1963        if ($this.is('a')) e.preventDefault();
1964        $target.data('pg.search').toggleOverlay('show');
1965    })
1966
1967
1968}
1968)(window.jQuery);
1969(function($) {
1970	'use strict';
1971	// Initialize layouts and plugins
1972    $.Pages.init();
1973})(window.jQuery);

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.