1// Window Height 2var durationValueCache = $(window).height(); 3function getDuration() { 4 'use strict'; 5 return durationValueCache; 6} 7function updateDuration() { 8 'use strict'; 9 var height = 10 window.innerHeight || 11 document.documentElement.clientHeight || 12 document.body.clientHeight; 13 durationValueCache = height; 14} 15$(window).on('resize', updateDuration); 16$(window).triggerHandler('resize'); 17 18// Anchors 19var autoanchor = {}; 20window.autoanchor = autoanchor; 21autoanchor.anc = []; 22autoanchor.cur = ''; 23 24jQuery.fn.addanchors = function () { 25 'use strict'; 26 return this.each(function () { 27 autoanchor.anc.push(this); 28 }); 29}; 30 31// Responsive 32function findBootstrapEnvironment() { 33 'use strict'; 34 var envs = ['xs', 'sm', 'md', 'lg']; 35 var $el = $('<div>'); 36 $el.appendTo($('body')); 37 for (var i = envs.length - 1; i >= 0; i--) { 38 var env = envs[i]; 39 $el.addClass('hidden-' + env); 40 if ($el.is(':hidden')) { 41 $el.remove(); 42 return env; 43 } 44 } 45} 46 47// Scroll by Link To Href 48function scrollLink() { 49 'use strict'; 50 $('.js-scrollto').click(function () { 51 $('html, body').animate( 52 { scrollTop: $($(this).attr('href')).offset().top }, 53 { duration: 1000 }, 54 ); 55 return false; 56 }); 57} 58 59// Set Dementions 60function setDementions() { 61 'use strict'; 62 $('.js-window-height').css('min-height', getDuration()); 63} 64 65// Pin Navbar 66function navbar() { 67 'use strict'; 68 if (findBootstrapEnvironment() === 'xs') { 69 $(window).on('scroll', function () { 70 if ($(window).scrollTop() > 48) { 71 $('.js-navbar').addClass('-active'); 72 } else { 73 $('.js-navbar').removeClass('-active'); 74 } 75 }); 76 $('.js-scrollto').on('click', function () { 77 $('#toggle_menu').removeAttr('checked'); 78 }); 79 } 80} 81 82// Demo App 83function demoApp(url) { 84 'use strict'; 85 86 // create transparent background 87 var elBackground = document.createElement('div'); 88 elBackground.setAttribute( 89 'style', 90 'position: fixed; top:0; left:0; width:100%; height:100%; background-color:rgba(102,102,102,0.8); z-index:1000; cursor:pointer', 91 ); 92 elBackground.onclick = function () { 93 fClose(); 94 }; 95 document.body.appendChild(elBackground); 96 97 // create iframe to load the demo page 98 var elFrame = document.createElement('iframe'); 99 elFrame.src = url; 100 elFrame.setAttribute( 101 'style', 102 'position:relative; top:5%; left:30%; width:40%; height:90%; border:none;', 103 ); 104 elBackground.appendChild(elFrame); 105 106 // function to close the popup 107 var fClose = function () { 108 document.body.removeChild(elBackground); 109 }; 110} 111 112$(function () { 113 'use strict'; 114 115 // Init 116 scrollLink(); 117 setDementions(); 118 navbar(); 119 $(window).resize(function () { 120 setDementions(); 121 navbar(); 122 }); 123 124 $('.js-open-demo').click(function () { 125 demoApp('https://www.appdemostore.com/embed?id=6301316389273600'); 126 }); 127 128 // Anchors 129 $(window).scroll(function () { 130 if (autoanchor.anc.length === 0) return; 131 var scrollY = window.scrollY 132 ? window.scrollY 133 : document.documentElement.scrollTop 134 ? document.documentElement.scrollTop 135 : document.body.scrollTop; 136 var d = 0; 137 var anc; 138 autoanchor.d = autoanchor.anc[0].offsetTop - scrollY; 139 autoanchor.e = 0; 140 for (anc in autoanchor.anc) { 141 d = autoanchor.anc[anc].offsetTop - scrollY; 142 if (d <= 0 && autoanchor.d < d) { 143 autoanchor.d = d; 144 autoanchor.e = anc; 145 } 146 } 147 if (autoanchor.cur != autoanchor.anc[autoanchor.e].name) { 148 autoanchor.cur = autoanchor.anc[autoanchor.e].name; 149 $(window).scrollTop($(window).scrollTop()); 150 $('.js-scrollto').removeClass('-active'); 151 $('a[href=#' + autoanchor.cur + ']').addClass('-active'); 152 return false; 153 } 154 }); 155 156 $('a[name]').addanchors(); 157 158 $('.js-login') 159 .on('ajax:before', function () { 160 $(this).find('.js-login-message').empty(); 161 }) 162 .on('ajax:success', function (event, response) { 163 response = $.parseJSON(response); 164 if (response.error) { 165 var $this = $(this); 166 $this.find('.js-login-field').addClass('-error'); 167 $this.find('.js-login-message').html('<p>' + response.error + '</p>'); 168 } else if (response.redirect_to) { 169 window.location.href = response.redirect_to; 170 } 171 }); 172});
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.