Difference between revisions of "Template:IONIS Paris/JS"
Line 9: | Line 9: | ||
</script> | </script> | ||
− | <script type="text/javascript"> | + | // <script type="text/javascript"> |
− | /* Respond.js: min/max-width media query polyfill. (c) Scott Jehl. MIT Lic. j.mp/respondjs */ | + | // /* Respond.js: min/max-width media query polyfill. (c) Scott Jehl. MIT Lic. j.mp/respondjs */ |
− | (function( w ){ | + | // (function( w ){ |
− | + | // | |
− | "use strict"; | + | // "use strict"; |
− | + | // | |
− | //exposed namespace | + | // //exposed namespace |
− | var respond = {}; | + | // var respond = {}; |
− | w.respond = respond; | + | // w.respond = respond; |
− | + | // | |
− | //define update even in native-mq-supporting browsers, to avoid errors | + | // //define update even in native-mq-supporting browsers, to avoid errors |
− | respond.update = function(){}; | + | // respond.update = function(){}; |
− | + | // | |
− | //define ajax obj | + | // //define ajax obj |
− | var requestQueue = [], | + | // var requestQueue = [], |
− | xmlHttp = (function() { | + | // xmlHttp = (function() { |
− | var xmlhttpmethod = false; | + | // var xmlhttpmethod = false; |
− | try { | + | // try { |
− | xmlhttpmethod = new w.XMLHttpRequest(); | + | // xmlhttpmethod = new w.XMLHttpRequest(); |
− | } | + | // } |
− | catch( e ){ | + | // catch( e ){ |
− | xmlhttpmethod = new w.ActiveXObject( "Microsoft.XMLHTTP" ); | + | // xmlhttpmethod = new w.ActiveXObject( "Microsoft.XMLHTTP" ); |
− | } | + | // } |
− | return function(){ | + | // return function(){ |
− | return xmlhttpmethod; | + | // return xmlhttpmethod; |
− | }; | + | // }; |
− | })(), | + | // })(), |
− | + | // | |
− | //tweaked Ajax functions from Quirksmode | + | // //tweaked Ajax functions from Quirksmode |
− | ajax = function( url, callback ) { | + | // ajax = function( url, callback ) { |
− | var req = xmlHttp(); | + | // var req = xmlHttp(); |
− | if (!req){ | + | // if (!req){ |
− | return; | + | // return; |
− | } | + | // } |
− | req.open( "GET", url, true ); | + | // req.open( "GET", url, true ); |
− | req.onreadystatechange = function () { | + | // req.onreadystatechange = function () { |
− | if ( req.readyState !== 4 || req.status !== 200 && req.status !== 304 ){ | + | // if ( req.readyState !== 4 || req.status !== 200 && req.status !== 304 ){ |
− | return; | + | // return; |
− | } | + | // } |
− | callback( req.responseText ); | + | // callback( req.responseText ); |
− | }; | + | // }; |
− | if ( req.readyState === 4 ){ | + | // if ( req.readyState === 4 ){ |
− | return; | + | // return; |
− | } | + | // } |
− | req.send( null ); | + | // req.send( null ); |
− | }, | + | // }, |
− | isUnsupportedMediaQuery = function( query ) { | + | // isUnsupportedMediaQuery = function( query ) { |
− | return query.replace( respond.regex.minmaxwh, '' ).match( respond.regex.other ); | + | // return query.replace( respond.regex.minmaxwh, '' ).match( respond.regex.other ); |
− | }; | + | // }; |
− | + | // | |
− | //expose for testing | + | // //expose for testing |
− | respond.ajax = ajax; | + | // respond.ajax = ajax; |
− | respond.queue = requestQueue; | + | // respond.queue = requestQueue; |
− | respond.unsupportedmq = isUnsupportedMediaQuery; | + | // respond.unsupportedmq = isUnsupportedMediaQuery; |
− | respond.regex = { | + | // respond.regex = { |
− | media: /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi, | + | // media: /@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi, |
− | keyframes: /@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi, | + | // keyframes: /@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi, |
− | comments: /\/\*[^*]*\*+([^/][^*]*\*+)*\//gi, | + | // comments: /\/\*[^*]*\*+([^/][^*]*\*+)*\//gi, |
− | urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, | + | // urls: /(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g, |
− | findStyles: /@media *([^\{]+)\{([\S\s]+?)$/, | + | // findStyles: /@media *([^\{]+)\{([\S\s]+?)$/, |
− | only: /(only\s+)?([a-zA-Z]+)\s?/, | + | // only: /(only\s+)?([a-zA-Z]+)\s?/, |
− | minw: /\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/, | + | // minw: /\(\s*min\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/, |
− | maxw: /\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/, | + | // maxw: /\(\s*max\-width\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/, |
− | minmaxwh: /\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi, | + | // minmaxwh: /\(\s*m(in|ax)\-(height|width)\s*:\s*(\s*[0-9\.]+)(px|em)\s*\)/gi, |
− | other: /\([^\)]*\)/g | + | // other: /\([^\)]*\)/g |
− | }; | + | // }; |
− | + | // | |
− | //expose media query support flag for external use | + | // //expose media query support flag for external use |
− | respond.mediaQueriesSupported = w.matchMedia && w.matchMedia( "only all" ) !== null && w.matchMedia( "only all" ).matches; | + | // respond.mediaQueriesSupported = w.matchMedia && w.matchMedia( "only all" ) !== null && w.matchMedia( "only all" ).matches; |
− | + | // | |
− | //if media queries are supported, exit here | + | // //if media queries are supported, exit here |
− | if( respond.mediaQueriesSupported ){ | + | // if( respond.mediaQueriesSupported ){ |
− | return; | + | // return; |
− | } | + | // } |
− | + | // | |
− | //define vars | + | // //define vars |
− | var doc = w.document, | + | // var doc = w.document, |
− | docElem = doc.documentElement, | + | // docElem = doc.documentElement, |
− | mediastyles = [], | + | // mediastyles = [], |
− | rules = [], | + | // rules = [], |
− | appendedEls = [], | + | // appendedEls = [], |
− | parsedSheets = {}, | + | // parsedSheets = {}, |
− | resizeThrottle = 30, | + | // resizeThrottle = 30, |
− | head = doc.getElementsByTagName( "head" )[0] || docElem, | + | // head = doc.getElementsByTagName( "head" )[0] || docElem, |
− | base = doc.getElementsByTagName( "base" )[0], | + | // base = doc.getElementsByTagName( "base" )[0], |
− | links = head.getElementsByTagName( "link" ), | + | // links = head.getElementsByTagName( "link" ), |
− | + | // | |
− | lastCall, | + | // lastCall, |
− | resizeDefer, | + | // resizeDefer, |
− | + | // | |
− | //cached container for 1em value, populated the first time it's needed | + | // //cached container for 1em value, populated the first time it's needed |
− | eminpx, | + | // eminpx, |
− | + | // | |
− | // returns the value of 1em in pixels | + | // // returns the value of 1em in pixels |
− | getEmValue = function() { | + | // getEmValue = function() { |
− | var ret, | + | // var ret, |
− | div = doc.createElement('div'), | + | // div = doc.createElement('div'), |
− | body = doc.body, | + | // body = doc.body, |
− | originalHTMLFontSize = docElem.style.fontSize, | + | // originalHTMLFontSize = docElem.style.fontSize, |
− | originalBodyFontSize = body && body.style.fontSize, | + | // originalBodyFontSize = body && body.style.fontSize, |
− | fakeUsed = false; | + | // fakeUsed = false; |
− | + | // | |
− | div.style.cssText = "position:absolute;font-size:1em;width:1em"; | + | // div.style.cssText = "position:absolute;font-size:1em;width:1em"; |
− | + | // | |
− | if( !body ){ | + | // if( !body ){ |
− | body = fakeUsed = doc.createElement( "body" ); | + | // body = fakeUsed = doc.createElement( "body" ); |
− | body.style.background = "none"; | + | // body.style.background = "none"; |
− | } | + | // } |
− | + | // | |
− | // 1em in a media query is the value of the default font size of the browser | + | // // 1em in a media query is the value of the default font size of the browser |
− | // reset docElem and body to ensure the correct value is returned | + | // // reset docElem and body to ensure the correct value is returned |
− | docElem.style.fontSize = "100%"; | + | // docElem.style.fontSize = "100%"; |
− | body.style.fontSize = "100%"; | + | // body.style.fontSize = "100%"; |
− | + | // | |
− | body.appendChild( div ); | + | // body.appendChild( div ); |
− | + | // | |
− | if( fakeUsed ){ | + | // if( fakeUsed ){ |
− | docElem.insertBefore( body, docElem.firstChild ); | + | // docElem.insertBefore( body, docElem.firstChild ); |
− | } | + | // } |
− | + | // | |
− | ret = div.offsetWidth; | + | // ret = div.offsetWidth; |
− | + | // | |
− | if( fakeUsed ){ | + | // if( fakeUsed ){ |
− | docElem.removeChild( body ); | + | // docElem.removeChild( body ); |
− | } | + | // } |
− | else { | + | // else { |
− | body.removeChild( div ); | + | // body.removeChild( div ); |
− | } | + | // } |
− | + | // | |
− | // restore the original values | + | // // restore the original values |
− | docElem.style.fontSize = originalHTMLFontSize; | + | // docElem.style.fontSize = originalHTMLFontSize; |
− | if( originalBodyFontSize ) { | + | // if( originalBodyFontSize ) { |
− | body.style.fontSize = originalBodyFontSize; | + | // body.style.fontSize = originalBodyFontSize; |
− | } | + | // } |
− | + | // | |
− | + | // | |
− | //also update eminpx before returning | + | // //also update eminpx before returning |
− | ret = eminpx = parseFloat(ret); | + | // ret = eminpx = parseFloat(ret); |
− | + | // | |
− | return ret; | + | // return ret; |
− | }, | + | // }, |
− | + | // | |
− | //enable/disable styles | + | // //enable/disable styles |
− | applyMedia = function( fromResize ){ | + | // applyMedia = function( fromResize ){ |
− | var name = "clientWidth", | + | // var name = "clientWidth", |
− | docElemProp = docElem[ name ], | + | // docElemProp = docElem[ name ], |
− | currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp, | + | // currWidth = doc.compatMode === "CSS1Compat" && docElemProp || doc.body[ name ] || docElemProp, |
− | styleBlocks = {}, | + | // styleBlocks = {}, |
− | lastLink = links[ links.length-1 ], | + | // lastLink = links[ links.length-1 ], |
− | now = (new Date()).getTime(); | + | // now = (new Date()).getTime(); |
− | + | // | |
− | //throttle resize calls | + | // //throttle resize calls |
− | if( fromResize && lastCall && now - lastCall < resizeThrottle ){ | + | // if( fromResize && lastCall && now - lastCall < resizeThrottle ){ |
− | w.clearTimeout( resizeDefer ); | + | // w.clearTimeout( resizeDefer ); |
− | resizeDefer = w.setTimeout( applyMedia, resizeThrottle ); | + | // resizeDefer = w.setTimeout( applyMedia, resizeThrottle ); |
− | return; | + | // return; |
− | } | + | // } |
− | else { | + | // else { |
− | lastCall = now; | + | // lastCall = now; |
− | } | + | // } |
− | + | // | |
− | for( var i in mediastyles ){ | + | // for( var i in mediastyles ){ |
− | if( mediastyles.hasOwnProperty( i ) ){ | + | // if( mediastyles.hasOwnProperty( i ) ){ |
− | var thisstyle = mediastyles[ i ], | + | // var thisstyle = mediastyles[ i ], |
− | min = thisstyle.minw, | + | // min = thisstyle.minw, |
− | max = thisstyle.maxw, | + | // max = thisstyle.maxw, |
− | minnull = min === null, | + | // minnull = min === null, |
− | maxnull = max === null, | + | // maxnull = max === null, |
− | em = "em"; | + | // em = "em"; |
− | + | // | |
− | if( !!min ){ | + | // if( !!min ){ |
− | min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); | + | // min = parseFloat( min ) * ( min.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); |
− | } | + | // } |
− | if( !!max ){ | + | // if( !!max ){ |
− | max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); | + | // max = parseFloat( max ) * ( max.indexOf( em ) > -1 ? ( eminpx || getEmValue() ) : 1 ); |
− | } | + | // } |
− | + | // | |
− | // if there's no media query at all (the () part), or min or max is not null, and if either is present, they're true | + | // // if there's no media query at all (the () part), or min or max is not null, and if either is present, they're true |
− | if( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){ | + | // if( !thisstyle.hasquery || ( !minnull || !maxnull ) && ( minnull || currWidth >= min ) && ( maxnull || currWidth <= max ) ){ |
− | if( !styleBlocks[ thisstyle.media ] ){ | + | // if( !styleBlocks[ thisstyle.media ] ){ |
− | styleBlocks[ thisstyle.media ] = []; | + | // styleBlocks[ thisstyle.media ] = []; |
− | } | + | // } |
− | styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] ); | + | // styleBlocks[ thisstyle.media ].push( rules[ thisstyle.rules ] ); |
− | } | + | // } |
− | } | + | // } |
− | } | + | // } |
− | + | // | |
− | //remove any existing respond style element(s) | + | // //remove any existing respond style element(s) |
− | for( var j in appendedEls ){ | + | // for( var j in appendedEls ){ |
− | if( appendedEls.hasOwnProperty( j ) ){ | + | // if( appendedEls.hasOwnProperty( j ) ){ |
− | if( appendedEls[ j ] && appendedEls[ j ].parentNode === head ){ | + | // if( appendedEls[ j ] && appendedEls[ j ].parentNode === head ){ |
− | head.removeChild( appendedEls[ j ] ); | + | // head.removeChild( appendedEls[ j ] ); |
− | } | + | // } |
− | } | + | // } |
− | } | + | // } |
− | appendedEls.length = 0; | + | // appendedEls.length = 0; |
− | + | // | |
− | //inject active styles, grouped by media type | + | // //inject active styles, grouped by media type |
− | for( var k in styleBlocks ){ | + | // for( var k in styleBlocks ){ |
− | if( styleBlocks.hasOwnProperty( k ) ){ | + | // if( styleBlocks.hasOwnProperty( k ) ){ |
− | var ss = doc.createElement( "style" ), | + | // var ss = doc.createElement( "style" ), |
− | css = styleBlocks[ k ].join( "\n" ); | + | // css = styleBlocks[ k ].join( "\n" ); |
− | + | // | |
− | ss.type = "text/css"; | + | // ss.type = "text/css"; |
− | ss.media = k; | + | // ss.media = k; |
− | + | // | |
− | //originally, ss was appended to a documentFragment and sheets were appended in bulk. | + | // //originally, ss was appended to a documentFragment and sheets were appended in bulk. |
− | //this caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one! | + | // //this caused crashes in IE in a number of circumstances, such as when the HTML element had a bg image set, so appending beforehand seems best. Thanks to @dvelyk for the initial research on this one! |
− | head.insertBefore( ss, lastLink.nextSibling ); | + | // head.insertBefore( ss, lastLink.nextSibling ); |
− | + | // | |
− | if ( ss.styleSheet ){ | + | // if ( ss.styleSheet ){ |
− | ss.styleSheet.cssText = css; | + | // ss.styleSheet.cssText = css; |
− | } | + | // } |
− | else { | + | // else { |
− | ss.appendChild( doc.createTextNode( css ) ); | + | // ss.appendChild( doc.createTextNode( css ) ); |
− | } | + | // } |
− | + | // | |
− | //push to appendedEls to track for later removal | + | // //push to appendedEls to track for later removal |
− | appendedEls.push( ss ); | + | // appendedEls.push( ss ); |
− | } | + | // } |
− | } | + | // } |
− | }, | + | // }, |
− | //find media blocks in css text, convert to style blocks | + | // //find media blocks in css text, convert to style blocks |
− | translate = function( styles, href, media ){ | + | // translate = function( styles, href, media ){ |
− | var qs = styles.replace( respond.regex.comments, '' ) | + | // var qs = styles.replace( respond.regex.comments, '' ) |
− | .replace( respond.regex.keyframes, '' ) | + | // .replace( respond.regex.keyframes, '' ) |
− | .match( respond.regex.media ), | + | // .match( respond.regex.media ), |
− | ql = qs && qs.length || 0; | + | // ql = qs && qs.length || 0; |
− | + | // | |
− | //try to get CSS path | + | // //try to get CSS path |
− | href = href.substring( 0, href.lastIndexOf( "/" ) ); | + | // href = href.substring( 0, href.lastIndexOf( "/" ) ); |
− | + | // | |
− | var repUrls = function( css ){ | + | // var repUrls = function( css ){ |
− | return css.replace( respond.regex.urls, "$1" + href + "$2$3" ); | + | // return css.replace( respond.regex.urls, "$1" + href + "$2$3" ); |
− | }, | + | // }, |
− | useMedia = !ql && media; | + | // useMedia = !ql && media; |
− | + | // | |
− | //if path exists, tack on trailing slash | + | // //if path exists, tack on trailing slash |
− | if( href.length ){ href += "/"; } | + | // if( href.length ){ href += "/"; } |
− | + | // | |
− | //if no internal queries exist, but media attr does, use that | + | // //if no internal queries exist, but media attr does, use that |
− | //note: this currently lacks support for situations where a media attr is specified on a link AND | + | // //note: this currently lacks support for situations where a media attr is specified on a link AND |
− | //its associated stylesheet has internal CSS media queries. | + | // //its associated stylesheet has internal CSS media queries. |
− | //In those cases, the media attribute will currently be ignored. | + | // //In those cases, the media attribute will currently be ignored. |
− | if( useMedia ){ | + | // if( useMedia ){ |
− | ql = 1; | + | // ql = 1; |
− | } | + | // } |
− | + | // | |
− | for( var i = 0; i < ql; i++ ){ | + | // for( var i = 0; i < ql; i++ ){ |
− | var fullq, thisq, eachq, eql; | + | // var fullq, thisq, eachq, eql; |
− | + | // | |
− | //media attr | + | // //media attr |
− | if( useMedia ){ | + | // if( useMedia ){ |
− | fullq = media; | + | // fullq = media; |
− | rules.push( repUrls( styles ) ); | + | // rules.push( repUrls( styles ) ); |
− | } | + | // } |
− | //parse for styles | + | // //parse for styles |
− | else{ | + | // else{ |
− | fullq = qs[ i ].match( respond.regex.findStyles ) && RegExp.$1; | + | // fullq = qs[ i ].match( respond.regex.findStyles ) && RegExp.$1; |
− | rules.push( RegExp.$2 && repUrls( RegExp.$2 ) ); | + | // rules.push( RegExp.$2 && repUrls( RegExp.$2 ) ); |
− | } | + | // } |
− | + | // | |
− | eachq = fullq.split( "," ); | + | // eachq = fullq.split( "," ); |
− | eql = eachq.length; | + | // eql = eachq.length; |
− | + | // | |
− | for( var j = 0; j < eql; j++ ){ | + | // for( var j = 0; j < eql; j++ ){ |
− | thisq = eachq[ j ]; | + | // thisq = eachq[ j ]; |
− | + | // | |
− | if( isUnsupportedMediaQuery( thisq ) ) { | + | // if( isUnsupportedMediaQuery( thisq ) ) { |
− | continue; | + | // continue; |
− | } | + | // } |
− | + | // | |
− | mediastyles.push( { | + | // mediastyles.push( { |
− | media : thisq.split( "(" )[ 0 ].match( respond.regex.only ) && RegExp.$2 || "all", | + | // media : thisq.split( "(" )[ 0 ].match( respond.regex.only ) && RegExp.$2 || "all", |
− | rules : rules.length - 1, | + | // rules : rules.length - 1, |
− | hasquery : thisq.indexOf("(") > -1, | + | // hasquery : thisq.indexOf("(") > -1, |
− | minw : thisq.match( respond.regex.minw ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), | + | // minw : thisq.match( respond.regex.minw ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ), |
− | maxw : thisq.match( respond.regex.maxw ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ) | + | // maxw : thisq.match( respond.regex.maxw ) && parseFloat( RegExp.$1 ) + ( RegExp.$2 || "" ) |
− | } ); | + | // } ); |
− | } | + | // } |
− | } | + | // } |
− | + | // | |
− | applyMedia(); | + | // applyMedia(); |
− | }, | + | // }, |
− | + | // | |
− | //recurse through request queue, get css text | + | // //recurse through request queue, get css text |
− | makeRequests = function(){ | + | // makeRequests = function(){ |
− | if( requestQueue.length ){ | + | // if( requestQueue.length ){ |
− | var thisRequest = requestQueue.shift(); | + | // var thisRequest = requestQueue.shift(); |
− | + | // | |
− | ajax( thisRequest.href, function( styles ){ | + | // ajax( thisRequest.href, function( styles ){ |
− | translate( styles, thisRequest.href, thisRequest.media ); | + | // translate( styles, thisRequest.href, thisRequest.media ); |
− | parsedSheets[ thisRequest.href ] = true; | + | // parsedSheets[ thisRequest.href ] = true; |
− | + | // | |
− | // by wrapping recursive function call in setTimeout | + | // // by wrapping recursive function call in setTimeout |
− | // we prevent "Stack overflow" error in IE7 | + | // // we prevent "Stack overflow" error in IE7 |
− | w.setTimeout(function(){ makeRequests(); },0); | + | // w.setTimeout(function(){ makeRequests(); },0); |
− | } ); | + | // } ); |
− | } | + | // } |
− | }, | + | // }, |
− | + | // | |
− | //loop stylesheets, send text content to translate | + | // //loop stylesheets, send text content to translate |
− | ripCSS = function(){ | + | // ripCSS = function(){ |
− | + | // | |
− | for( var i = 0; i < links.length; i++ ){ | + | // for( var i = 0; i < links.length; i++ ){ |
− | var sheet = links[ i ], | + | // var sheet = links[ i ], |
− | href = sheet.href, | + | // href = sheet.href, |
− | media = sheet.media, | + | // media = sheet.media, |
− | isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; | + | // isCSS = sheet.rel && sheet.rel.toLowerCase() === "stylesheet"; |
− | + | // | |
− | //only links plz and prevent re-parsing | + | // //only links plz and prevent re-parsing |
− | if( !!href && isCSS && !parsedSheets[ href ] ){ | + | // if( !!href && isCSS && !parsedSheets[ href ] ){ |
− | // selectivizr exposes css through the rawCssText expando | + | // // selectivizr exposes css through the rawCssText expando |
− | if (sheet.styleSheet && sheet.styleSheet.rawCssText) { | + | // if (sheet.styleSheet && sheet.styleSheet.rawCssText) { |
− | translate( sheet.styleSheet.rawCssText, href, media ); | + | // translate( sheet.styleSheet.rawCssText, href, media ); |
− | parsedSheets[ href ] = true; | + | // parsedSheets[ href ] = true; |
− | } else { | + | // } else { |
− | if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) || | + | // if( (!/^([a-zA-Z:]*\/\/)/.test( href ) && !base) || |
− | href.replace( RegExp.$1, "" ).split( "/" )[0] === w.location.host ){ | + | // href.replace( RegExp.$1, "" ).split( "/" )[0] === w.location.host ){ |
− | // IE7 doesn't handle urls that start with '//' for ajax request | + | // // IE7 doesn't handle urls that start with '//' for ajax request |
− | // manually add in the protocol | + | // // manually add in the protocol |
− | if ( href.substring(0,2) === "//" ) { href = w.location.protocol + href; } | + | // if ( href.substring(0,2) === "//" ) { href = w.location.protocol + href; } |
− | requestQueue.push( { | + | // requestQueue.push( { |
− | href: href, | + | // href: href, |
− | media: media | + | // media: media |
− | } ); | + | // } ); |
− | } | + | // } |
− | } | + | // } |
− | } | + | // } |
− | } | + | // } |
− | makeRequests(); | + | // makeRequests(); |
− | }; | + | // }; |
− | + | // | |
− | //translate CSS | + | // //translate CSS |
− | ripCSS(); | + | // ripCSS(); |
− | + | // | |
− | //expose update for re-running respond later on | + | // //expose update for re-running respond later on |
− | respond.update = ripCSS; | + | // respond.update = ripCSS; |
− | + | // | |
− | //expose getEmValue | + | // //expose getEmValue |
− | respond.getEmValue = getEmValue; | + | // respond.getEmValue = getEmValue; |
− | + | // | |
− | //adjust on resize | + | // //adjust on resize |
− | function callMedia(){ | + | // function callMedia(){ |
− | applyMedia( true ); | + | // applyMedia( true ); |
− | } | + | // } |
− | + | // | |
− | if( w.addEventListener ){ | + | // if( w.addEventListener ){ |
− | w.addEventListener( "resize", callMedia, false ); | + | // w.addEventListener( "resize", callMedia, false ); |
− | } | + | // } |
− | else if( w.attachEvent ){ | + | // else if( w.attachEvent ){ |
− | w.attachEvent( "onresize", callMedia ); | + | // w.attachEvent( "onresize", callMedia ); |
− | } | + | // } |
− | })(this); | + | // })(this); |
− | </script> | + | // </script> |
− | + | ||
− | + | // <script type="text/javascript"> | |
− | + | // !function(a){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper"],a):(window.blueimp=window.blueimp||{},window.blueimp.Gallery=a(window.blueimp.helper||window.jQuery))}(function(a){"use strict";function b(a,c){return void 0===document.body.style.maxHeight?null:this&&this.options===b.prototype.options?a&&a.length?(this.list=a,this.num=a.length,this.initOptions(c),void this.initialize()):void this.console.log("blueimp Gallery: No or empty list provided as first argument.",a):new b(a,c)}return a.extend(b.prototype,{options:{container:"#blueimp-gallery",slidesContainer:"div",titleElement:"h3",displayClass:"blueimp-gallery-display",controlsClass:"blueimp-gallery-controls",singleClass:"blueimp-gallery-single",leftEdgeClass:"blueimp-gallery-left",rightEdgeClass:"blueimp-gallery-right",playingClass:"blueimp-gallery-playing",slideClass:"slide",slideLoadingClass:"slide-loading",slideErrorClass:"slide-error",slideContentClass:"slide-content",toggleClass:"toggle",prevClass:"prev",nextClass:"next",closeClass:"close",playPauseClass:"play-pause",typeProperty:"type",titleProperty:"title",urlProperty:"href",displayTransition:!0,clearSlides:!0,stretchImages:!1,toggleControlsOnReturn:!0,toggleSlideshowOnSpace:!0,enableKeyboardNavigation:!0,closeOnEscape:!0,closeOnSlideClick:!0,closeOnSwipeUpOrDown:!0,emulateTouchEvents:!0,stopTouchEventsPropagation:!1,hidePageScrollbars:!0,disableScroll:!0,carousel:!1,continuous:!0,unloadElements:!0,startSlideshow:!1,slideshowInterval:5e3,index:0,preloadRange:2,transitionSpeed:400,slideshowTransitionSpeed:void 0,event:void 0,onopen:void 0,onopened:void 0,onslide:void 0,onslideend:void 0,onslidecomplete:void 0,onclose:void 0,onclosed:void 0},carouselOptions:{hidePageScrollbars:!1,toggleControlsOnReturn:!1,toggleSlideshowOnSpace:!1,enableKeyboardNavigation:!1,closeOnEscape:!1,closeOnSlideClick:!1,closeOnSwipeUpOrDown:!1,disableScroll:!1,startSlideshow:!0},console:window.console&&"function"==typeof window.console.log?window.console:{log:function(){}},support:function(b){var c={touch:void 0!==window.ontouchstart||window.DocumentTouch&&document instanceof DocumentTouch},d={webkitTransition:{end:"webkitTransitionEnd",prefix:"-webkit-"},MozTransition:{end:"transitionend",prefix:"-moz-"},OTransition:{end:"otransitionend",prefix:"-o-"},transition:{end:"transitionend",prefix:""}},e=function(){var a,d,e=c.transition;document.body.appendChild(b),e&&(a=e.name.slice(0,-9)+"ransform",void 0!==b.style[a]&&(b.style[a]="translateZ(0)",d=window.getComputedStyle(b).getPropertyValue(e.prefix+"transform"),c.transform={prefix:e.prefix,name:a,translate:!0,translateZ:!!d&&"none"!==d})),void 0!==b.style.backgroundSize&&(c.backgroundSize={},b.style.backgroundSize="contain",c.backgroundSize.contain="contain"===window.getComputedStyle(b).getPropertyValue("background-size"),b.style.backgroundSize="cover",c.backgroundSize.cover="cover"===window.getComputedStyle(b).getPropertyValue("background-size")),document.body.removeChild(b)};return function(a,c){var d;for(d in c)if(c.hasOwnProperty(d)&&void 0!==b.style[d]){a.transition=c[d],a.transition.name=d;break}}(c,d),document.body?e():a(document).on("DOMContentLoaded",e),c}(document.createElement("div")),requestAnimationFrame:window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame,initialize:function(){return this.initStartIndex(),this.initWidget()===!1?!1:(this.initEventListeners(),this.onslide(this.index),this.ontransitionend(),void(this.options.startSlideshow&&this.play()))},slide:function(a,b){window.clearTimeout(this.timeout);var c,d,e,f=this.index;if(f!==a&&1!==this.num){if(b||(b=this.options.transitionSpeed),this.support.transform){for(this.options.continuous||(a=this.circle(a)),c=Math.abs(f-a)/(f-a),this.options.continuous&&(d=c,c=-this.positions[this.circle(a)]/this.slideWidth,c!==d&&(a=-c*this.num+a)),e=Math.abs(f-a)-1;e;)e-=1,this.move(this.circle((a>f?a:f)-e-1),this.slideWidth*c,0);a=this.circle(a),this.move(f,this.slideWidth*c,b),this.move(a,0,b),this.options.continuous&&this.move(this.circle(a-c),-(this.slideWidth*c),0)}else a=this.circle(a),this.animate(f*-this.slideWidth,a*-this.slideWidth,b);this.onslide(a)}},getIndex:function(){return this.index},getNumber:function(){return this.num},prev:function(){(this.options.continuous||this.index)&&this.slide(this.index-1)},next:function(){(this.options.continuous||this.index<this.num-1)&&this.slide(this.index+1)},play:function(a){var b=this;window.clearTimeout(this.timeout),this.interval=a||this.options.slideshowInterval,this.elements[this.index]>1&&(this.timeout=this.setTimeout(!this.requestAnimationFrame&&this.slide||function(a,c){b.animationFrameId=b.requestAnimationFrame.call(window,function(){b.slide(a,c)})},[this.index+1,this.options.slideshowTransitionSpeed],this.interval)),this.container.addClass(this.options.playingClass)},pause:function(){window.clearTimeout(this.timeout),this.interval=null,this.container.removeClass(this.options.playingClass)},add:function(a){var b;for(a.concat||(a=Array.prototype.slice.call(a)),this.list.concat||(this.list=Array.prototype.slice.call(this.list)),this.list=this.list.concat(a),this.num=this.list.length,this.num>2&&null===this.options.continuous&&(this.options.continuous=!0,this.container.removeClass(this.options.leftEdgeClass)),this.container.removeClass(this.options.rightEdgeClass).removeClass(this.options.singleClass),b=this.num-a.length;b<this.num;b+=1)this.addSlide(b),this.positionSlide(b);this.positions.length=this.num,this.initSlides(!0)},resetSlides:function(){this.slidesContainer.empty(),this.slides=[]},handleClose:function(){var a=this.options;this.destroyEventListeners(),this.pause(),this.container[0].style.display="none",this.container.removeClass(a.displayClass).removeClass(a.singleClass).removeClass(a.leftEdgeClass).removeClass(a.rightEdgeClass),a.hidePageScrollbars&&(document.body.style.overflow=this.bodyOverflowStyle),this.options.clearSlides&&this.resetSlides(),this.options.onclosed&&this.options.onclosed.call(this)},close:function(){var a=this,b=function(c){c.target===a.container[0]&&(a.container.off(a.support.transition.end,b),a.handleClose())};this.options.onclose&&this.options.onclose.call(this),this.support.transition&&this.options.displayTransition?(this.container.on(this.support.transition.end,b),this.container.removeClass(this.options.displayClass)):this.handleClose()},circle:function(a){return(this.num+a%this.num)%this.num},move:function(a,b,c){this.translateX(a,b,c),this.positions[a]=b},translate:function(a,b,c,d){var e=this.slides[a].style,f=this.support.transition,g=this.support.transform;e[f.name+"Duration"]=d+"ms",e[g.name]="translate("+b+"px, "+c+"px)"+(g.translateZ?" translateZ(0)":"")},translateX:function(a,b,c){this.translate(a,b,0,c)},translateY:function(a,b,c){this.translate(a,0,b,c)},animate:function(a,b,c){if(!c)return void(this.slidesContainer[0].style.left=b+"px");var d=this,e=(new Date).getTime(),f=window.setInterval(function(){var g=(new Date).getTime()-e;return g>c?(d.slidesContainer[0].style.left=b+"px",d.ontransitionend(),void window.clearInterval(f)):void(d.slidesContainer[0].style.left=(b-a)*(Math.floor(g/c*100)/100)+a+"px")},4)},preventDefault:function(a){a.preventDefault?a.preventDefault():a.returnValue=!1},stopPropagation:function(a){a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},onresize:function(){this.initSlides(!0)},onmousedown:function(a){a.which&&1===a.which&&"VIDEO"!==a.target.nodeName&&(a.preventDefault(),(a.originalEvent||a).touches=[{pageX:a.pageX,pageY:a.pageY}],this.ontouchstart(a))},onmousemove:function(a){this.touchStart&&((a.originalEvent||a).touches=[{pageX:a.pageX,pageY:a.pageY}],this.ontouchmove(a))},onmouseup:function(a){this.touchStart&&(this.ontouchend(a),delete this.touchStart)},onmouseout:function(b){if(this.touchStart){var c=b.target,d=b.relatedTarget;(!d||d!==c&&!a.contains(c,d))&&this.onmouseup(b)}},ontouchstart:function(a){this.options.stopTouchEventsPropagation&&this.stopPropagation(a);var b=(a.originalEvent||a).touches[0];this.touchStart={x:b.pageX,y:b.pageY,time:Date.now()},this.isScrolling=void 0,this.touchDelta={}},ontouchmove:function(a){this.options.stopTouchEventsPropagation&&this.stopPropagation(a);var b,c,d=(a.originalEvent||a).touches[0],e=(a.originalEvent||a).scale,f=this.index;if(!(d.length>1||e&&1!==e))if(this.options.disableScroll&&a.preventDefault(),this.touchDelta={x:d.pageX-this.touchStart.x,y:d.pageY-this.touchStart.y},b=this.touchDelta.x,void 0===this.isScrolling&&(this.isScrolling=this.isScrolling||Math.abs(b)<Math.abs(this.touchDelta.y)),this.isScrolling)this.options.closeOnSwipeUpOrDown&&this.translateY(f,this.touchDelta.y+this.positions[f],0);else for(a.preventDefault(),window.clearTimeout(this.timeout),this.options.continuous?c=[this.circle(f+1),f,this.circle(f-1)]:(this.touchDelta.x=b/=!f&&b>0||f===this.num-1&&0>b?Math.abs(b)/this.slideWidth+1:1,c=[f],f&&c.push(f-1),f<this.num-1&&c.unshift(f+1));c.length;)f=c.pop(),this.translateX(f,b+this.positions[f],0)},ontouchend:function(a){this.options.stopTouchEventsPropagation&&this.stopPropagation(a);var b,c,d,e,f,g=this.index,h=this.options.transitionSpeed,i=this.slideWidth,j=Number(Date.now()-this.touchStart.time)<250,k=j&&Math.abs(this.touchDelta.x)>20||Math.abs(this.touchDelta.x)>i/2,l=!g&&this.touchDelta.x>0||g===this.num-1&&this.touchDelta.x<0,m=!k&&this.options.closeOnSwipeUpOrDown&&(j&&Math.abs(this.touchDelta.y)>20||Math.abs(this.touchDelta.y)>this.slideHeight/2);this.options.continuous&&(l=!1),b=this.touchDelta.x<0?-1:1,this.isScrolling?m?this.close():this.translateY(g,0,h):k&&!l?(c=g+b,d=g-b,e=i*b,f=-i*b,this.options.continuous?(this.move(this.circle(c),e,0),this.move(this.circle(g-2*b),f,0)):c>=0&&c<this.num&&this.move(c,e,0),this.move(g,this.positions[g]+e,h),this.move(this.circle(d),this.positions[this.circle(d)]+e,h),g=this.circle(d),this.onslide(g)):this.options.continuous?(this.move(this.circle(g-1),-i,h),this.move(g,0,h),this.move(this.circle(g+1),i,h)):(g&&this.move(g-1,-i,h),this.move(g,0,h),g<this.num-1&&this.move(g+1,i,h))},ontouchcancel:function(a){this.touchStart&&(this.ontouchend(a),delete this.touchStart)},ontransitionend:function(a){var b=this.slides[this.index];a&&b!==a.target||(this.interval&&this.play(),this.setTimeout(this.options.onslideend,[this.index,b]))},oncomplete:function(b){var c,d=b.target||b.srcElement,e=d&&d.parentNode;d&&e&&(c=this.getNodeIndex(e),a(e).removeClass(this.options.slideLoadingClass),"error"===b.type?(a(e).addClass(this.options.slideErrorClass),this.elements[c]=3):this.elements[c]=2,d.clientHeight>this.container[0].clientHeight&&(d.style.maxHeight=this.container[0].clientHeight),this.interval&&this.slides[this.index]===e&&this.play(),this.setTimeout(this.options.onslidecomplete,[c,e]))},onload:function(a){this.oncomplete(a)},onerror:function(a){this.oncomplete(a)},onkeydown:function(a){switch(a.which||a.keyCode){case 13:this.options.toggleControlsOnReturn&&(this.preventDefault(a),this.toggleControls());break;case 27:this.options.closeOnEscape&&this.close();break;case 32:this.options.toggleSlideshowOnSpace&&(this.preventDefault(a),this.toggleSlideshow());break;case 37:this.options.enableKeyboardNavigation&&(this.preventDefault(a),this.prev());break;case 39:this.options.enableKeyboardNavigation&&(this.preventDefault(a),this.next())}},handleClick:function(b){var c=this.options,d=b.target||b.srcElement,e=d.parentNode,f=function(b){return a(d).hasClass(b)||a(e).hasClass(b)};f(c.toggleClass)?(this.preventDefault(b),this.toggleControls()):f(c.prevClass)?(this.preventDefault(b),this.prev()):f(c.nextClass)?(this.preventDefault(b),this.next()):f(c.closeClass)?(this.preventDefault(b),this.close()):f(c.playPauseClass)?(this.preventDefault(b),this.toggleSlideshow()):e===this.slidesContainer[0]?(this.preventDefault(b),c.closeOnSlideClick?this.close():this.toggleControls()):e.parentNode&&e.parentNode===this.slidesContainer[0]&&(this.preventDefault(b),this.toggleControls())},onclick:function(a){return this.options.emulateTouchEvents&&this.touchDelta&&(Math.abs(this.touchDelta.x)>20||Math.abs(this.touchDelta.y)>20)?void delete this.touchDelta:this.handleClick(a)},updateEdgeClasses:function(a){a?this.container.removeClass(this.options.leftEdgeClass):this.container.addClass(this.options.leftEdgeClass),a===this.num-1?this.container.addClass(this.options.rightEdgeClass):this.container.removeClass(this.options.rightEdgeClass)},handleSlide:function(a){this.options.continuous||this.updateEdgeClasses(a),this.loadElements(a),this.options.unloadElements&&this.unloadElements(a),this.setTitle(a)},onslide:function(a){this.index=a,this.handleSlide(a),this.setTimeout(this.options.onslide,[a,this.slides[a]])},setTitle:function(a){var b=this.slides[a].firstChild.title,c=this.titleElement;c.length&&(this.titleElement.empty(),b&&c[0].appendChild(document.createTextNode(b)))},setTimeout:function(a,b,c){var d=this;return a&&window.setTimeout(function(){a.apply(d,b||[])},c||0)},imageFactory:function(b,c){var d,e,f,g=this,h=this.imagePrototype.cloneNode(!1),i=b,j=this.options.stretchImages,k=function(b){if(!d){if(b={type:b.type,target:e},!e.parentNode)return g.setTimeout(k,[b]);d=!0,a(h).off("load error",k),j&&"load"===b.type&&(e.style.background='url("'+i+'") center no-repeat',e.style.backgroundSize=j),c(b)}};return"string"!=typeof i&&(i=this.getItemProperty(b,this.options.urlProperty),f=this.getItemProperty(b,this.options.titleProperty)),j===!0&&(j="contain"),j=this.support.backgroundSize&&this.support.backgroundSize[j]&&j,j?e=this.elementPrototype.cloneNode(!1):(e=h,h.draggable=!1),f&&(e.title=f),a(h).on("load error",k),h.src=i,e},createElement:function(b,c){var d=b&&this.getItemProperty(b,this.options.typeProperty),e=d&&this[d.split("/")[0]+"Factory"]||this.imageFactory,f=b&&e.call(this,b,c);return f||(f=this.elementPrototype.cloneNode(!1),this.setTimeout(c,[{type:"error",target:f}])),a(f).addClass(this.options.slideContentClass),f},loadElement:function(b){this.elements[b]||(this.slides[b].firstChild?this.elements[b]=a(this.slides[b]).hasClass(this.options.slideErrorClass)?3:2:(this.elements[b]=1,a(this.slides[b]).addClass(this.options.slideLoadingClass),this.slides[b].appendChild(this.createElement(this.list[b],this.proxyListener))))},loadElements:function(a){var b,c=Math.min(this.num,2*this.options.preloadRange+1),d=a;for(b=0;c>b;b+=1)d+=b*(b%2===0?-1:1),d=this.circle(d),this.loadElement(d)},unloadElements:function(a){var b,c,d;for(b in this.elements)this.elements.hasOwnProperty(b)&&(d=Math.abs(a-b),d>this.options.preloadRange&&d+this.options.preloadRange<this.num&&(c=this.slides[b],c.removeChild(c.firstChild),delete this.elements[b]))},addSlide:function(a){var b=this.slidePrototype.cloneNode(!1);b.setAttribute("data-index",a),this.slidesContainer[0].appendChild(b),this.slides.push(b)},positionSlide:function(a){var b=this.slides[a];b.style.width=this.slideWidth+"px",this.support.transform&&(b.style.left=a*-this.slideWidth+"px",this.move(a,this.index>a?-this.slideWidth:this.index<a?this.slideWidth:0,0))},initSlides:function(b){var c,d;for(b||(this.positions=[],this.positions.length=this.num,this.elements={},this.imagePrototype=document.createElement("img"),this.elementPrototype=document.createElement("div"),this.slidePrototype=document.createElement("div"),a(this.slidePrototype).addClass(this.options.slideClass),this.slides=this.slidesContainer[0].children,c=this.options.clearSlides||this.slides.length!==this.num),this.slideWidth=this.container[0].offsetWidth,this.slideHeight=this.container[0].offsetHeight,this.slidesContainer[0].style.width=this.num*this.slideWidth+"px",c&&this.resetSlides(),d=0;d<this.num;d+=1)c&&this.addSlide(d),this.positionSlide(d);this.options.continuous&&this.support.transform&&(this.move(this.circle(this.index-1),-this.slideWidth,0),this.move(this.circle(this.index+1),this.slideWidth,0)),this.support.transform||(this.slidesContainer[0].style.left=this.index*-this.slideWidth+"px")},toggleControls:function(){var a=this.options.controlsClass;this.container.hasClass(a)?this.container.removeClass(a):this.container.addClass(a)},toggleSlideshow:function(){this.interval?this.pause():this.play()},getNodeIndex:function(a){return parseInt(a.getAttribute("data-index"),10)},getNestedProperty:function(a,b){return b.replace(/\[(?:'([^']+)'|"([^"]+)"|(\d+))\]|(?:(?:^|\.)([^\.\[]+))/g,function(b,c,d,e,f){var g=f||c||d||e&&parseInt(e,10);b&&a&&(a=a[g])}),a},getDataProperty:function(b,c){if(b.getAttribute){var d=b.getAttribute("data-"+c.replace(/([A-Z])/g,"-$1").toLowerCase());if("string"==typeof d){if(/^(true|false|null|-?\d+(\.\d+)?|\{[\s\S]*\}|\[[\s\S]*\])$/.test(d))try{return a.parseJSON(d)}catch(e){}return d}}},getItemProperty:function(a,b){var c=a[b];return void 0===c&&(c=this.getDataProperty(a,b),void 0===c&&(c=this.getNestedProperty(a,b))),c},initStartIndex:function(){var a,b=this.options.index,c=this.options.urlProperty;if(b&&"number"!=typeof b)for(a=0;a<this.num;a+=1)if(this.list[a]===b||this.getItemProperty(this.list[a],c)===this.getItemProperty(b,c)){b=a;break}this.index=this.circle(parseInt(b,10)||0)},initEventListeners:function(){var b=this,c=this.slidesContainer,d=function(a){var c=b.support.transition&&b.support.transition.end===a.type?"transitionend":a.type;b["on"+c](a)};a(window).on("resize",d),a(document.body).on("keydown",d),this.container.on("click",d),this.support.touch?c.on("touchstart touchmove touchend touchcancel",d):this.options.emulateTouchEvents&&this.support.transition&&c.on("mousedown mousemove mouseup mouseout",d),this.support.transition&&c.on(this.support.transition.end,d),this.proxyListener=d},destroyEventListeners:function(){var b=this.slidesContainer,c=this.proxyListener;a(window).off("resize",c),a(document.body).off("keydown",c),this.container.off("click",c),this.support.touch?b.off("touchstart touchmove touchend touchcancel",c):this.options.emulateTouchEvents&&this.support.transition&&b.off("mousedown mousemove mouseup mouseout",c),this.support.transition&&b.off(this.support.transition.end,c)},handleOpen:function(){this.options.onopened&&this.options.onopened.call(this)},initWidget:function(){var b=this,c=function(a){a.target===b.container[0]&&(b.container.off(b.support.transition.end,c),b.handleOpen())};return this.container=a(this.options.container),this.container.length?(this.slidesContainer=this.container.find(this.options.slidesContainer).first(),this.slidesContainer.length?(this.titleElement=this.container.find(this.options.titleElement).first(),1===this.num&&this.container.addClass(this.options.singleClass),this.options.onopen&&this.options.onopen.call(this),this.support.transition&&this.options.displayTransition?this.container.on(this.support.transition.end,c):this.handleOpen(),this.options.hidePageScrollbars&&(this.bodyOverflowStyle=document.body.style.overflow,document.body.style.overflow="hidden"),this.container[0].style.display="block",this.initSlides(),void this.container.addClass(this.options.displayClass)):(this.console.log("blueimp Gallery: Slides container not found.",this.options.slidesContainer),!1)):(this.console.log("blueimp Gallery: Widget container not found.",this.options.container),!1)},initOptions:function(b){this.options=a.extend({},this.options),(b&&b.carousel||this.options.carousel&&(!b||b.carousel!==!1))&&a.extend(this.options,this.carouselOptions),a.extend(this.options,b),this.num<3&&(this.options.continuous=this.options.continuous?null:!1),this.support.transition||(this.options.emulateTouchEvents=!1),this.options.event&&this.preventDefault(this.options.event)}}),b}),function(a){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery"],a):a(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";a.extend(b.prototype.options,{fullScreen:!1});var c=b.prototype.initialize,d=b.prototype.close;return a.extend(b.prototype,{getFullScreenElement:function(){return document.fullscreenElement||document.webkitFullscreenElement||document.mozFullScreenElement||document.msFullscreenElement},requestFullScreen:function(a){a.requestFullscreen?a.requestFullscreen():a.webkitRequestFullscreen?a.webkitRequestFullscreen():a.mozRequestFullScreen?a.mozRequestFullScreen():a.msRequestFullscreen&&a.msRequestFullscreen()},exitFullScreen:function(){document.exitFullscreen?document.exitFullscreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()},initialize:function(){c.call(this),this.options.fullScreen&&!this.getFullScreenElement()&&this.requestFullScreen(this.container[0])},close:function(){this.getFullScreenElement()===this.container[0]&&this.exitFullScreen(),d.call(this)}}),b}),function(a){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery"],a):a(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";a.extend(b.prototype.options,{indicatorContainer:"ol",activeIndicatorClass:"active",thumbnailProperty:"thumbnail",thumbnailIndicators:!0});var c=b.prototype.initSlides,d=b.prototype.addSlide,e=b.prototype.resetSlides,f=b.prototype.handleClick,g=b.prototype.handleSlide,h=b.prototype.handleClose;return a.extend(b.prototype,{createIndicator:function(b){var c,d,e=this.indicatorPrototype.cloneNode(!1),f=this.getItemProperty(b,this.options.titleProperty),g=this.options.thumbnailProperty;return this.options.thumbnailIndicators&&(d=b.getElementsByTagName&&a(b).find("img")[0],d?c=d.src:g&&(c=this.getItemProperty(b,g)),c&&(e.style.backgroundImage='url("'+c+'")')),f&&(e.title=f),e},addIndicator:function(a){if(this.indicatorContainer.length){var b=this.createIndicator(this.list[a]);b.setAttribute("data-index",a),this.indicatorContainer[0].appendChild(b),this.indicators.push(b)}},setActiveIndicator:function(b){this.indicators&&(this.activeIndicator&&this.activeIndicator.removeClass(this.options.activeIndicatorClass),this.activeIndicator=a(this.indicators[b]),this.activeIndicator.addClass(this.options.activeIndicatorClass))},initSlides:function(a){a||(this.indicatorContainer=this.container.find(this.options.indicatorContainer),this.indicatorContainer.length&&(this.indicatorPrototype=document.createElement("li"),this.indicators=this.indicatorContainer[0].children)),c.call(this,a)},addSlide:function(a){d.call(this,a),this.addIndicator(a)},resetSlides:function(){e.call(this),this.indicatorContainer.empty(),this.indicators=[]},handleClick:function(a){var b=a.target||a.srcElement,c=b.parentNode;if(c===this.indicatorContainer[0])this.preventDefault(a),this.slide(this.getNodeIndex(b));else{if(c.parentNode!==this.indicatorContainer[0])return f.call(this,a);this.preventDefault(a),this.slide(this.getNodeIndex(c))}},handleSlide:function(a){g.call(this,a),this.setActiveIndicator(a)},handleClose:function(){this.activeIndicator&&this.activeIndicator.removeClass(this.options.activeIndicatorClass),h.call(this)}}),b}),function(a){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery"],a):a(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";a.extend(b.prototype.options,{videoContentClass:"video-content",videoLoadingClass:"video-loading",videoPlayingClass:"video-playing",videoPosterProperty:"poster",videoSourcesProperty:"sources"});var c=b.prototype.handleSlide;return a.extend(b.prototype,{handleSlide:function(a){c.call(this,a),this.playingVideo&&this.playingVideo.pause()},videoFactory:function(b,c,d){var e,f,g,h,i,j=this,k=this.options,l=this.elementPrototype.cloneNode(!1),m=a(l),n=[{type:"error",target:l}],o=d||document.createElement("video"),p=this.getItemProperty(b,k.urlProperty),q=this.getItemProperty(b,k.typeProperty),r=this.getItemProperty(b,k.titleProperty),s=this.getItemProperty(b,k.videoPosterProperty),t=this.getItemProperty(b,k.videoSourcesProperty);if(m.addClass(k.videoContentClass),r&&(l.title=r),o.canPlayType)if(p&&q&&o.canPlayType(q))o.src=p;else for(;t&&t.length;)if(f=t.shift(),p=this.getItemProperty(f,k.urlProperty),q=this.getItemProperty(f,k.typeProperty),p&&q&&o.canPlayType(q)){o.src=p;break}return s&&(o.poster=s,e=this.imagePrototype.cloneNode(!1),a(e).addClass(k.toggleClass),e.src=s,e.draggable=!1,l.appendChild(e)),g=document.createElement("a"),g.setAttribute("target","_blank"),d||g.setAttribute("download",r),g.href=p,o.src&&(o.controls=!0,(d||a(o)).on("error",function(){j.setTimeout(c,n)}).on("pause",function(){h=!1,m.removeClass(j.options.videoLoadingClass).removeClass(j.options.videoPlayingClass),i&&j.container.addClass(j.options.controlsClass),delete j.playingVideo,j.interval&&j.play()}).on("playing",function(){h=!1,m.removeClass(j.options.videoLoadingClass).addClass(j.options.videoPlayingClass),j.container.hasClass(j.options.controlsClass)?(i=!0,j.container.removeClass(j.options.controlsClass)):i=!1}).on("play",function(){window.clearTimeout(j.timeout),h=!0,m.addClass(j.options.videoLoadingClass),j.playingVideo=o}),a(g).on("click",function(a){j.preventDefault(a),h?o.pause():o.play()}),l.appendChild(d&&d.element||o)),l.appendChild(g),this.setTimeout(c,[{type:"load",target:l}]),l}}),b}),function(a){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery-video"],a):a(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";if(!window.postMessage)return b;a.extend(b.prototype.options,{vimeoVideoIdProperty:"vimeo",vimeoPlayerUrl:"//player.vimeo.com/video/VIDEO_ID?api=1&player_id=PLAYER_ID",vimeoPlayerIdPrefix:"vimeo-player-",vimeoClickToPlay:!0});var c=b.prototype.textFactory||b.prototype.imageFactory,d=function(a,b,c,d){this.url=a,this.videoId=b,this.playerId=c,this.clickToPlay=d,this.element=document.createElement("div"),this.listeners={}},e=0;return a.extend(d.prototype,{canPlayType:function(){return!0},on:function(a,b){return this.listeners[a]=b,this},loadAPI:function(){for(var b,c,d=this,e="//"+("https"===location.protocol?"secure-":"")+"a.vimeocdn.com/js/froogaloop2.min.js",f=document.getElementsByTagName("script"),g=f.length,h=function(){!c&&d.playOnReady&&d.play(),c=!0};g;)if(g-=1,f[g].src===e){b=f[g];break}b||(b=document.createElement("script"),b.src=e),a(b).on("load",h),f[0].parentNode.insertBefore(b,f[0]),/loaded|complete/.test(b.readyState)&&h()},onReady:function(){var a=this;this.ready=!0,this.player.addEvent("play",function(){a.hasPlayed=!0,a.onPlaying()}),this.player.addEvent("pause",function(){a.onPause()}),this.player.addEvent("finish",function(){a.onPause()}),this.playOnReady&&this.play()},onPlaying:function(){this.playStatus<2&&(this.listeners.playing(),this.playStatus=2)},onPause:function(){this.listeners.pause(),delete this.playStatus},insertIframe:function(){var a=document.createElement("iframe");a.src=this.url.replace("VIDEO_ID",this.videoId).replace("PLAYER_ID",this.playerId),a.id=this.playerId,this.element.parentNode.replaceChild(a,this.element),this.element=a},play:function(){var a=this;this.playStatus||(this.listeners.play(),this.playStatus=1),this.ready?!this.hasPlayed&&(this.clickToPlay||window.navigator&&/iP(hone|od|ad)/.test(window.navigator.platform))?this.onPlaying():this.player.api("play"):(this.playOnReady=!0,window.$f?this.player||(this.insertIframe(),this.player=$f(this.element),this.player.addEvent("ready",function(){a.onReady()})):this.loadAPI())},pause:function(){this.ready?this.player.api("pause"):this.playStatus&&(delete this.playOnReady,this.listeners.pause(),delete this.playStatus)}}),a.extend(b.prototype,{VimeoPlayer:d,textFactory:function(a,b){var f=this.options,g=this.getItemProperty(a,f.vimeoVideoIdProperty);return g?(void 0===this.getItemProperty(a,f.urlProperty)&&(a[f.urlProperty]="//vimeo.com/"+g),e+=1,this.videoFactory(a,b,new d(f.vimeoPlayerUrl,g,f.vimeoPlayerIdPrefix+e,f.vimeoClickToPlay))):c.call(this,a,b)}}),b}),function(a){"use strict";"function"==typeof define&&define.amd?define(["./blueimp-helper","./blueimp-gallery-video"],a):a(window.blueimp.helper||window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";if(!window.postMessage)return b;a.extend(b.prototype.options,{youTubeVideoIdProperty:"youtube",youTubePlayerVars:{wmode:"transparent"},youTubeClickToPlay:!0});var c=b.prototype.textFactory||b.prototype.imageFactory,d=function(a,b,c){this.videoId=a,this.playerVars=b,this.clickToPlay=c,this.element=document.createElement("div"),this.listeners={}};return a.extend(d.prototype,{canPlayType:function(){return!0},on:function(a,b){return this.listeners[a]=b,this},loadAPI:function(){var a,b=this,c=window.onYouTubeIframeAPIReady,d="//www.youtube.com/iframe_api",e=document.getElementsByTagName("script"),f=e.length;for(window.onYouTubeIframeAPIReady=function(){c&&c.apply(this),b.playOnReady&&b.play()};f;)if(f-=1,e[f].src===d)return;a=document.createElement("script"),a.src=d,e[0].parentNode.insertBefore(a,e[0])},onReady:function(){this.ready=!0,this.playOnReady&&this.play()},onPlaying:function(){this.playStatus<2&&(this.listeners.playing(),this.playStatus=2)},onPause:function(){b.prototype.setTimeout.call(this,this.checkSeek,null,2e3)},checkSeek:function(){(this.stateChange===YT.PlayerState.PAUSED||this.stateChange===YT.PlayerState.ENDED)&&(this.listeners.pause(),delete this.playStatus)},onStateChange:function(a){switch(a.data){case YT.PlayerState.PLAYING:this.hasPlayed=!0,this.onPlaying();break;case YT.PlayerState.PAUSED:case YT.PlayerState.ENDED:this.onPause()}this.stateChange=a.data},onError:function(a){this.listeners.error(a)},play:function(){var a=this;this.playStatus||(this.listeners.play(),this.playStatus=1),this.ready?!this.hasPlayed&&(this.clickToPlay||window.navigator&&/iP(hone|od|ad)/.test(window.navigator.platform))?this.onPlaying():this.player.playVideo():(this.playOnReady=!0,window.YT&&YT.Player?this.player||(this.player=new YT.Player(this.element,{videoId:this.videoId,playerVars:this.playerVars,events:{onReady:function(){a.onReady()},onStateChange:function(b){a.onStateChange(b)},onError:function(b){a.onError(b)}}})):this.loadAPI())},pause:function(){this.ready?this.player.pauseVideo():this.playStatus&&(delete this.playOnReady,this.listeners.pause(),delete this.playStatus)}}),a.extend(b.prototype,{YouTubePlayer:d,textFactory:function(a,b){var e=this.options,f=this.getItemProperty(a,e.youTubeVideoIdProperty);return f?(void 0===this.getItemProperty(a,e.urlProperty)&&(a[e.urlProperty]="//www.youtube.com/watch?v="+f),void 0===this.getItemProperty(a,e.videoPosterProperty)&&(a[e.videoPosterProperty]="//img.youtube.com/vi/"+f+"/maxresdefault.jpg"),this.videoFactory(a,b,new d(f,e.youTubePlayerVars,e.youTubeClickToPlay))):c.call(this,a,b)}}),b}),function(a){"use strict";"function"==typeof define&&define.amd?define(["jquery","./blueimp-gallery"],a):a(window.jQuery,window.blueimp.Gallery)}(function(a,b){"use strict";a(document).on("click","[data-gallery]",function(c){var d=a(this).data("gallery"),e=a(d),f=e.length&&e||a(b.prototype.options.container),g={onopen:function(){f.data("gallery",this).trigger("open")},onopened:function(){f.trigger("opened")},onslide:function(){f.trigger("slide",arguments)},onslideend:function(){f.trigger("slideend",arguments)},onslidecomplete:function(){f.trigger("slidecomplete",arguments)},onclose:function(){f.trigger("close")},onclosed:function(){f.trigger("closed").removeData("gallery")}},h=a.extend(f.data(),{container:f[0],index:this,event:c},g),i=a('[data-gallery="'+d+'"]');return h.filter&&(i=i.filter(h.filter)),new b(i,h)})}); | |
− | + | // </script> | |
− | + | ||
− | + | <script type="text/javascript"> | |
− | + | ||
− | + | jQuery(document).ready(function($) { | |
− | + | $(".scroll a, .navbar-brand, .gototop").click(function(event){ | |
− | + | event.preventDefault(); | |
− | + | $('html,body').animate({scrollTop:$(this.hash).offset().top}, 600,'swing'); | |
− | + | $(".scroll li").removeClass('active'); | |
− | + | $(this).parents('li').toggleClass('active'); | |
− | + | ||
− | + | ||
}); | }); | ||
− | + | }); | |
− | + | ||
− | + | var wow = new WOW( | |
− | + | { | |
− | + | boxClass: 'wowload', // animated element css class (default is wow) | |
− | + | animateClass: 'animated', // animation css class (default is animated) | |
− | + | offset: 0, // distance to the element when triggering the animation (default is 0) | |
− | + | mobile: true, // trigger animations on mobile devices (default is true) | |
− | + | live: true // act on asynchronously loaded content (default is true) | |
− | + | } | |
− | + | ); | |
− | + | ||
− | + | wow.init(); | |
− | + | ||
− | + | $('.carousel').swipe( { | |
− | + | swipeLeft: function() { | |
− | + | $(this).carousel('next'); | |
− | + | }, | |
− | + | swipeRight: function() { | |
− | + | $(this).carousel('prev'); | |
− | + | }, | |
− | + | allowPageScroll: 'vertical' | |
− | + | }); | |
− | + | ||
− | + | // (function( $ ){ | |
− | + | // var $window = $(window); | |
− | + | // var windowHeight = $window.height(); | |
− | + | // | |
− | + | // $window.resize(function () { | |
− | + | // windowHeight = $window.height(); | |
− | + | // }); | |
− | + | // | |
− | + | // $.fn.parallax = function(xpos, speedFactor, outerHeight) { | |
− | + | // var $this = $(this); | |
− | + | // var getHeight; | |
− | + | // var firstTop; | |
− | + | // var paddingTop = 0; | |
− | + | // | |
− | + | // //get the starting position of each element to have parallax applied to it | |
− | + | // $this.each(function(){ | |
− | + | // firstTop = $this.offset().top; | |
− | + | // }); | |
− | + | // | |
− | + | // if (outerHeight) { | |
− | + | // getHeight = function(jqo) { | |
− | + | // return jqo.outerHeight(true); | |
− | + | // }; | |
− | + | // } else { | |
− | + | // getHeight = function(jqo) { | |
− | + | // return jqo.height(); | |
− | + | // }; | |
− | + | // } | |
− | + | // | |
− | + | // // setup defaults if arguments aren't specified | |
− | + | // if (arguments.length < 1 || xpos === null) xpos = "50%"; | |
− | + | // if (arguments.length < 2 || speedFactor === null) speedFactor = 0.1; | |
− | + | // if (arguments.length < 3 || outerHeight === null) outerHeight = true; | |
− | + | // | |
− | + | // // function to be called whenever the window is scrolled or resized | |
− | + | // function update(){ | |
− | + | // var pos = $window.scrollTop(); | |
− | + | // | |
− | + | // $this.each(function(){ | |
− | + | // var $element = $(this); | |
− | + | // var top = $element.offset().top; | |
− | + | // var height = getHeight($element); | |
− | + | // | |
− | + | // // Check if totally above or totally below viewport | |
− | + | // if (top + height < pos || top > pos + windowHeight) { | |
− | + | // return; | |
− | + | // } | |
− | + | // | |
− | + | // $this.css('backgroundPosition', xpos + " " + Math.round((firstTop - pos) * speedFactor) + "px"); | |
− | + | // }); | |
− | + | // } | |
− | + | // | |
− | + | // $window.bind('scroll', update).resize(update); | |
− | + | // update(); | |
− | + | // }; | |
− | + | // })(jQuery); | |
− | + | </script> | |
− | + | ||
− | + | </head> | |
+ | </html> |
Revision as of 21:05, 29 July 2015
// //