1(function(){ 2 'use strict'; 3 4 function set_cookie( name, value, expire, path ) { 5 var expires = '', date; 6 7 if ( typeof path === 'undefined' ) { 8 path = '/'; 9 } 10 11 if ( expire ) { 12 date = new Date(); 13 date.setTime( date.getTime() + ( expire * 1000 ) ); 14 expires = '; expires=' + date.toUTCString(); 15 } 16 17 document.cookie = name + '=' + value + expires + '; path=' + path; 18 } 19 20 function get_cookie( name ) { 21 var nameEQ = name + '=', 22 ca = document.cookie.split(';'), 23 c; 24 25 for ( var i=0; i < ca.length; i++ ) { 26 c = ca[i]; 27 while ( c.charAt(0) === ' ' ) { 28 c = c.substring( 1, c.length ); 29 } 30 31 if ( c.indexOf( nameEQ ) === 0 ) { 32 return c.substring( nameEQ.length, c.length ); 33 } 34 } 35 36 return null; 37 } 38 39 function unset_cookie( name ) { 40 set_cookie( name, '', -1 ); 41 } 42 43 window.iditarod = window.iditarod || {}; 44 window.iditarod.cookie = { 45 set: set_cookie, 46 get: get_cookie, 47 unset: unset_cookie 48 }; 49})(); 50 51 52(function(){ 53 'use strict'; 54 55 var popups = []; 56 57 function create( opt ) { 58 var popup = new Instance( opt || {} ); 59 popups.push( popup ); 60 return popup; 61 } 62 63 function create_el( cls, type ) { 64 if ( typeof type === 'undefined' ) { 65 type = 'div'; 66 } 67 68 var el = document.createElement( type ); 69 el.className = cls; 70 return el; 71 } 72 73 function create_dom() { 74 var wrapper = create_el( 'popup-wrapper' ), 75 overlay = create_el( 'popup-overlay' ), 76 container = create_el( 'popup-container' ), 77 content = create_el( 'popup-content' ), 78 close = create_el( 'popup-close', 'a' ); 79 80 close.innerHTML = '✖'; 81 close.title = 'Close'; 82 close.href = '#'; 83 84 container.appendChild( close ); 85 container.appendChild( content ); 86 wrapper.appendChild( overlay ); 87 wrapper.appendChild( container ); 88 89 return { 90 wrapper: wrapper, 91 overlay: overlay, 92 container: container, 93 content: content, 94 close: close 95 }; 96 } 97 98 function Instance( opt ) { 99 var _opt, 100 _dom, 101 _on_scroll; 102 103 function init() { 104 _opt = parse_options( opt ); 105 _dom = create_dom(); 106 107 _dom.close.addEventListener( 'click', close_popup, false ); 108 _dom.overlay.addEventListener( 'click', close_popup, false ); 109 _on_scroll = _debounce( set_top_position, 50 ); 110 111 if ( opt.id ) { 112 _dom.overlay.id = opt.id; 113 } 114 115 if ( opt.html !== null ) { 116 set_content( opt.html ); 117 } 118 119 if ( opt.open !== null ) { 120 show( opt.open ); 121 } 122 123 } 124 125 function parse_options( opt ) { 126 var defaults = { 127 id: false, 128 html: null, 129 open: null 130 /* 131 innerWidth: false, 132 innerHeight: false, 133 width: false, 134 height: false, 135 */ 136 }; 137 138 for ( var o in defaults ) { 139 if ( typeof opt[o] === 'undefined' ) { 140 opt[o] = defaults[o]; 141 } 142 } 143 144 return opt; 145 } 146 147 function _in_document() { 148 return _dom.wrapper.parentNode !== null; 149 } 150 151 function set_top_position() { 152 _dom.container.style.top = window.pageYOffset + 'px'; 153 } 154 155 function show( _show ) { 156 if ( !_in_document() ) { 157 document.body.appendChild( _dom.wrapper ); 158 } 159 160 set_top_position(); 161 // var vis = 162 toggle_class( _dom.wrapper, 'popup-active', _show ); 163 164// track_scrolling( vis ); 165 } 166 167/* 168 function track_scrolling( enable ) { 169 var opt = { passive: false }; 170 171 if ( enable ) { 172 window.addEventListener( 'scroll', _on_scroll, opt ); 173 } else { 174 window.removeEventListener( 'scroll', _on_scroll, opt ); 175 } 176 } 177*/ 178 function close_popup() { 179 show( false ); 180 } 181 182 function set_content( content ) { 183 var type = typeof content, 184 el = _dom.content; 185 if ( type === 'object' ) { 186 el.innerHTML = ''; 187 el.appendChild( content ); 188 } else if ( type === 'function' ) { 189 set_content( content() ); 190 } else { 191 el.innerHTML = content; 192 } 193 194 } 195 196 init(); 197 198 return { 199 show: show, 200 close: close_popup, 201 set_content: set_content 202 }; 203 } 204 205/* 206 function has_class( el, cls ) { 207 return ( -1 !== el.className.split(' ').indexOf(cls) ); 208 } 209*/ 210 211 function toggle_class( el, cls, tog ) { 212 var c = el.className.split(' '), 213 i = c.indexOf( cls ), 214 has_class = ( -1 !== i ), 215 change = (typeof tog === 'undefined') || ( tog !== has_class ), 216 has_class_now = has_class; 217 218 if ( change ) { 219 if ( i === -1 ) { 220 has_class_now = true; 221 c.push( cls ); 222 } else { 223 has_class_now = false;
224 c.splice( i, 1 ); 225 } 226 227 el.className = c.join( ' ' ); 228 229 return has_class_now; 230 } 231 232 return el; 233 } 234 235 // https://davidwalsh.name/javascript-debounce-function 236 function _debounce(func, wait, immediate) { 237 var timeout; 238 return function() { 239 var context = this, args = arguments; 240 var later = function() { 241 timeout = null; 242 if (!immediate) { 243 func.apply(context, args); 244 } 245 }; 246 var callNow = immediate && !timeout; 247 clearTimeout(timeout); 248 timeout = setTimeout(later, wait); 249 if (callNow) { 250 func.apply(context, args); 251 } 252 }; 253 } 254 255 function show_popover() { 256 var c = window.iditarod.cookie, 257 p; 258 if ( ! c.get( popoverconfig.cookie ) ) { 259 p = window.iditarod.popup.create( popoverconfig.colorbox ); 260// jQuery.colorbox( popoverconfig.colorbox ); 261 } 262 263 c.set( popoverconfig.cookie, popoverconfig.expire, popoverconfig.expire ); 264 265 return p; 266 } 267 268 window.iditarod = window.iditarod || {}; 269 window.iditarod.popup = { 270 create: create, 271 show: show_popover 272 }; 273 274})(); 275 276 277window.show_popover = iditarod.popup.show; 278/* 279window.ppp = iditarod.popup.create(); 280ppp.set_content( popoverconfig.colorbox.html ); 281ppp.show(); 282*/
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.