if(typeof jQuery!='undefined'){ mejs.$=jQuery; }else if(typeof ender!='undefined'){ mejs.$=ender; } (function ($){ mejs.MepDefaults={ poster: '', defaultVideoWidth: 480, defaultVideoHeight: 270, videoWidth: -1, videoHeight: -1, defaultAudioWidth: 400, defaultAudioHeight: 30, audioWidth: -1, audioHeight: -1, startVolume: 0.8, loop: false, enableAutosize: true, alwaysShowHours: false, showTimecodeFrameCount: false, framesPerSecond: 25, autosizeProgress:true, alwaysShowControls: false, iPadUseNativeControls: false, iPhoneUseNativeControls: false, AndroidUseNativeControls: false, features: ['playpause','current','progress','duration','tracks','volume','fullscreen'], isVideo: true, enableKeyboard: true, pauseOtherPlayers: true, keyActions: [ { keys: [ 32, 179 ], action: function(player, media){ if(media.paused||media.ended){ media.play(); }else{ media.pause(); }} }, { keys: [38], action: function(player, media){ var newVolume=Math.min(media.volume + 0.1, 1); media.setVolume(newVolume); }}, { keys: [40], action: function(player, media){ var newVolume=Math.max(media.volume - 0.1, 0); media.setVolume(newVolume); }}, { keys: [ 37, 227 ], action: function(player, media){ if(!isNaN(media.duration)&&media.duration > 0){ if(player.isVideo){ player.showControls(); player.startControlsTimer(); } var newTime=Math.max(media.currentTime - (media.duration * 0.05), 0); media.setCurrentTime(newTime); }} }, { keys: [ 39, 228 ], action: function(player, media){ if(!isNaN(media.duration)&&media.duration > 0){ if(player.isVideo){ player.showControls(); player.startControlsTimer(); } var newTime=Math.min(media.currentTime + (media.duration * 0.05), media.duration); media.setCurrentTime(newTime); }} }, { keys: [70], action: function(player, media){ if(typeof player.enterFullScreen!='undefined'){ if(player.isFullScreen){ player.exitFullScreen(); }else{ player.enterFullScreen(); }} }} ] }; mejs.mepIndex=0; mejs.players=[]; mejs.MediaElementPlayer=function(node, o){ if(!(this instanceof mejs.MediaElementPlayer)){ return new mejs.MediaElementPlayer(node, o); } var t=this; t.$media=t.$node=$(node); t.node=t.media=t.$media[0]; if(typeof t.node.player!='undefined'){ return t.node.player; }else{ t.node.player=t; } if(typeof o=='undefined'){ o=t.$node.data('mejsoptions'); } t.options=$.extend({},mejs.MepDefaults,o); mejs.players.push(t); t.init(); return t; }; mejs.MediaElementPlayer.prototype={ hasFocus: false, controlsAreVisible: true, init: function(){ var t=this, mf=mejs.MediaFeatures, meOptions=$.extend(true, {}, t.options, { success: function(media, domNode){ t.meReady(media, domNode); }, error: function(e){ t.handleError(e);}}), tagName=t.media.tagName.toLowerCase(); t.isDynamic=(tagName!=='audio'&&tagName!=='video'); if(t.isDynamic){ t.isVideo=t.options.isVideo; }else{ t.isVideo=(tagName!=='audio'&&t.options.isVideo); } if((mf.isiPad&&t.options.iPadUseNativeControls)||(mf.isiPhone&&t.options.iPhoneUseNativeControls)){ t.$media.attr('controls', 'controls'); if(mf.isiPad&&t.media.getAttribute('autoplay')!==null){ t.media.load(); t.media.play(); }}else if(mf.isAndroid&&t.AndroidUseNativeControls){ }else{ t.$media.removeAttr('controls'); t.id='mep_' + mejs.mepIndex++; t.container = $('
'+ '
'+ '
'+ '
'+ '
'+ '
'+ '
' + '
') .addClass(t.$media[0].className) .insertBefore(t.$media); t.container.addClass((mf.isAndroid ? 'mejs-android ':'') + (mf.isiOS ? 'mejs-ios ':'') + (mf.isiPad ? 'mejs-ipad ':'') + (mf.isiPhone ? 'mejs-iphone ':'') + (t.isVideo ? 'mejs-video ':'mejs-audio ') ); if(mf.isiOS){ var $newMedia=t.$media.clone(); t.container.find('.mejs-mediaelement').append($newMedia); t.$media.remove(); t.$node=t.$media=$newMedia; t.node=t.media=$newMedia[0] }else{ t.container.find('.mejs-mediaelement').append(t.$media); } t.controls=t.container.find('.mejs-controls'); t.layers=t.container.find('.mejs-layers'); var capsTagName=tagName.substring(0,1).toUpperCase() + tagName.substring(1); if(t.options[tagName + 'Width'] > 0||t.options[tagName + 'Width'].toString().indexOf('%') > -1){ t.width=t.options[tagName + 'Width']; }else if(t.media.style.width!==''&&t.media.style.width!==null){ t.width=t.media.style.width; }else if(t.media.getAttribute('width')!==null){ t.width=t.$media.attr('width'); }else{ t.width=t.options['default' + capsTagName + 'Width']; } if(t.options[tagName + 'Height'] > 0||t.options[tagName + 'Height'].toString().indexOf('%') > -1){ t.height=t.options[tagName + 'Height']; }else if(t.media.style.height!==''&&t.media.style.height!==null){ t.height=t.media.style.height; }else if(t.$media[0].getAttribute('height')!==null){ t.height=t.$media.attr('height'); }else{ t.height=t.options['default' + capsTagName + 'Height']; } t.setPlayerSize(t.width, t.height); meOptions.pluginWidth=t.height; meOptions.pluginHeight=t.width; } mejs.MediaElement(t.$media[0], meOptions); }, showControls: function(doAnimation){ var t=this; doAnimation=typeof doAnimation=='undefined'||doAnimation; if(t.controlsAreVisible) return; if(doAnimation){ t.controls .css('visibility','visible') .stop(true, true).fadeIn(200, function(){t.controlsAreVisible=true;}); t.container.find('.mejs-control') .css('visibility','visible') .stop(true, true).fadeIn(200, function(){t.controlsAreVisible=true;}); }else{ t.controls .css('visibility','visible') .css('display','block'); t.container.find('.mejs-control') .css('visibility','visible') .css('display','block'); t.controlsAreVisible=true; } t.setControlsSize(); }, hideControls: function(doAnimation){ var t=this; doAnimation=typeof doAnimation=='undefined'||doAnimation; if(!t.controlsAreVisible) return; if(doAnimation){ t.controls.stop(true, true).fadeOut(200, function(){ $(this) .css('visibility','hidden') .css('display','block'); t.controlsAreVisible=false; }); t.container.find('.mejs-control').stop(true, true).fadeOut(200, function(){ $(this) .css('visibility','hidden') .css('display','block'); }); }else{ t.controls .css('visibility','hidden') .css('display','block'); t.container.find('.mejs-control') .css('visibility','hidden') .css('display','block'); t.controlsAreVisible=false; }}, controlsTimer: null, startControlsTimer: function(timeout){ var t=this; timeout=typeof timeout!='undefined' ? timeout:1500; t.killControlsTimer('start'); t.controlsTimer=setTimeout(function(){ t.hideControls(); t.killControlsTimer('hide'); }, timeout); }, killControlsTimer: function(src){ var t=this; if(t.controlsTimer!==null){ clearTimeout(t.controlsTimer); delete t.controlsTimer; t.controlsTimer=null; }}, controlsEnabled: true, disableControls: function(){ var t=this; t.killControlsTimer(); t.hideControls(false); this.controlsEnabled=false; }, enableControls: function(){ var t=this; t.showControls(false); t.controlsEnabled=true; }, meReady: function(media, domNode){ var t=this, mf=mejs.MediaFeatures, autoplayAttr=domNode.getAttribute('autoplay'), autoplay = !(typeof autoplayAttr=='undefined'||autoplayAttr===null||autoplayAttr==='false'), featureIndex, feature; if(t.created) return; else t.created=true; t.media=media; t.domNode=domNode; if(!(mf.isAndroid&&t.options.AndroidUseNativeControls)&&!(mf.isiPad&&t.options.iPadUseNativeControls)&&!(mf.isiPhone&&t.options.iPhoneUseNativeControls)){ t.buildposter(t, t.controls, t.layers, t.media); t.buildkeyboard(t, t.controls, t.layers, t.media); t.buildoverlays(t, t.controls, t.layers, t.media); t.findTracks(); for (featureIndex in t.options.features){ feature=t.options.features[featureIndex]; if(t['build' + feature]){ try { t['build' + feature](t, t.controls, t.layers, t.media); } catch (e){ }} } t.container.trigger('controlsready'); t.setPlayerSize(t.width, t.height); t.setControlsSize(); if(t.isVideo){ if(mejs.MediaFeatures.hasTouch){ t.$media.bind('touchstart', function(){ if(t.controlsAreVisible){ t.hideControls(false); }else{ if(t.controlsEnabled){ t.showControls(false); }} }); }else{ var clickElement=(t.media.pluginType=='native') ? t.$media:$(t.media.pluginElement); clickElement.click(function(){ if(media.paused){ media.play(); }else{ media.pause(); }}); t.container .bind('mouseenter mouseover', function (){ if(t.controlsEnabled){ if(!t.options.alwaysShowControls){ t.killControlsTimer('enter'); t.showControls(); t.startControlsTimer(2500); }} }) .bind('mousemove', function(){ if(t.controlsEnabled){ if(!t.controlsAreVisible){ t.showControls(); } if(!t.options.alwaysShowControls){ t.startControlsTimer(2500); }} }) .bind('mouseleave', function (){ if(t.controlsEnabled){ if(!t.media.paused&&!t.options.alwaysShowControls){ t.startControlsTimer(1000); }} }); } if(autoplay&&!t.options.alwaysShowControls){ t.hideControls(); } if(t.options.enableAutosize){ t.media.addEventListener('loadedmetadata', function(e){ if(t.options.videoHeight <=0&&t.domNode.getAttribute('height')===null&&!isNaN(e.target.videoHeight)){ t.setPlayerSize(e.target.videoWidth, e.target.videoHeight); t.setControlsSize(); t.media.setVideoSize(e.target.videoWidth, e.target.videoHeight); }}, false); }} media.addEventListener('play', function(){ for (var i=0, il=mejs.players.length; i 0){ var nativeWidth=(t.media.videoWidth&&t.media.videoWidth > 0) ? t.media.videoWidth:t.options.defaultVideoWidth, nativeHeight=(t.media.videoHeight&&t.media.videoHeight > 0) ? t.media.videoHeight:t.options.defaultVideoHeight, parentWidth=t.container.parent().width(), newHeight=parseInt(parentWidth * nativeHeight/nativeWidth, 10); if(t.container.parent()[0].tagName.toLowerCase()==='body'){ parentWidth=$(window).width(); newHeight=$(window).height(); } t.container .width(parentWidth) .height(newHeight); t.$media .width('100%') .height('100%'); t.container.find('object, embed, iframe') .width('100%') .height('100%'); if(t.media.setVideoSize) t.media.setVideoSize(parentWidth, newHeight); t.layers.children('.mejs-layer') .width('100%') .height('100%'); }else{ t.container .width(t.width) .height(t.height); t.layers.children('.mejs-layer') .width(t.width) .height(t.height); }}, setControlsSize: function(){ var t=this, usedWidth=0, railWidth=0, rail=t.controls.find('.mejs-time-rail'), total=t.controls.find('.mejs-time-total'), current=t.controls.find('.mejs-time-current'), loaded=t.controls.find('.mejs-time-loaded'), others=rail.siblings(); if(t.options&&!t.options.autosizeProgress){ railWidth=parseInt(rail.css('width')); } if(railWidth===0||!railWidth){ others.each(function(){ if($(this).css('position')!='absolute'){ usedWidth +=$(this).outerWidth(true); }}); railWidth=t.controls.width() - usedWidth - (rail.outerWidth(true) - rail.width()); } rail.width(railWidth); total.width(railWidth - (total.outerWidth(true) - total.width())); if(t.setProgressRail) t.setProgressRail(); if(t.setCurrentRail) t.setCurrentRail(); }, buildposter: function(player, controls, layers, media){ var t=this, poster = $('
' + '
') .appendTo(layers), posterUrl=player.$media.attr('poster'); if(player.options.poster!==''){ posterUrl=player.options.poster; } if(posterUrl!==''&&posterUrl!=null){ t.setPoster(posterUrl); }else{ poster.hide(); } media.addEventListener('play',function(){ poster.hide(); }, false); }, setPoster: function(url){ var t=this, posterDiv=t.container.find('.mejs-poster'), posterImg=posterDiv.find('img'); if(posterImg.length==0){ posterImg=$('').appendTo(posterDiv); } posterImg.attr('src', url); }, buildoverlays: function(player, controls, layers, media){ if(!player.isVideo) return; var loading = $('
'+ '
'+ '
') .hide() .appendTo(layers), error = $('
'+ '
'+ '
') .hide() .appendTo(layers), bigPlay = $('
'+ '
'+ '
') .appendTo(layers) .click(function(){ if(media.paused){ media.play(); }else{ media.pause(); }}); media.addEventListener('play',function(){ bigPlay.hide(); loading.hide(); controls.find('.mejs-time-buffering').hide(); error.hide(); }, false); media.addEventListener('playing', function(){ bigPlay.hide(); loading.hide(); controls.find('.mejs-time-buffering').hide(); error.hide(); }, false); media.addEventListener('seeking', function(){ loading.show(); controls.find('.mejs-time-buffering').show(); }, false); media.addEventListener('seeked', function(){ loading.hide(); controls.find('.mejs-time-buffering').hide(); }, false); media.addEventListener('pause',function(){ if(!mejs.MediaFeatures.isiPhone){ bigPlay.show(); }}, false); media.addEventListener('waiting', function(){ loading.show(); controls.find('.mejs-time-buffering').show(); }, false); media.addEventListener('loadeddata',function(){ loading.show(); controls.find('.mejs-time-buffering').show(); }, false); media.addEventListener('canplay',function(){ loading.hide(); controls.find('.mejs-time-buffering').hide(); }, false); media.addEventListener('error',function(){ loading.hide(); controls.find('.mejs-time-buffering').hide(); error.show(); error.find('mejs-overlay-error').html("Error loading this resource"); }, false); }, buildkeyboard: function(player, controls, layers, media){ var t=this; $(document).keydown(function(e){ if(player.hasFocus&&player.options.enableKeyboard){ for (var i=0, il=player.options.keyActions.length; i' + '' + '') .appendTo(controls) .click(function(e){ e.preventDefault(); if(media.paused){ media.play(); }else{ media.pause(); } return false; }); media.addEventListener('play',function(){ play.removeClass('mejs-play').addClass('mejs-pause'); }, false); media.addEventListener('playing',function(){ play.removeClass('mejs-play').addClass('mejs-pause'); }, false); media.addEventListener('pause',function(){ play.removeClass('mejs-pause').addClass('mejs-play'); }, false); media.addEventListener('paused',function(){ play.removeClass('mejs-pause').addClass('mejs-play'); }, false); }}); })(mejs.$); (function($){ $.extend(mejs.MepDefaults, { stopText: 'Stop' }); $.extend(MediaElementPlayer.prototype, { buildstop: function(player, controls, layers, media){ var t=this, stop = $('
' + '' + '
') .appendTo(controls) .click(function(){ if(!media.paused){ media.pause(); } if(media.currentTime > 0){ media.setCurrentTime(0); controls.find('.mejs-time-current').width('0px'); controls.find('.mejs-time-handle').css('left', '0px'); controls.find('.mejs-time-float-current').html(mejs.Utility.secondsToTimeCode(0)); controls.find('.mejs-currenttime').html(mejs.Utility.secondsToTimeCode(0)); layers.find('.mejs-poster').show(); }}); }}); })(mejs.$); (function($){ $.extend(MediaElementPlayer.prototype, { buildprogress: function(player, controls, layers, media){ $('
'+ ''+ ''+ ''+ ''+ ''+ '' + '00:00' + '' + ''+ ''+ '
') .appendTo(controls); controls.find('.mejs-time-buffering').hide(); var t=this, total=controls.find('.mejs-time-total'), loaded=controls.find('.mejs-time-loaded'), current=controls.find('.mejs-time-current'), handle=controls.find('.mejs-time-handle'), timefloat=controls.find('.mejs-time-float'), timefloatcurrent=controls.find('.mejs-time-float-current'), handleMouseMove=function (e){ var x=e.pageX, offset=total.offset(), width=total.outerWidth(), percentage=0, newTime=0, pos=x - offset.left; if(x > offset.left&&x <=width + offset.left&&media.duration){ percentage=((x - offset.left) / width); newTime=(percentage <=0.02) ? 0:percentage * media.duration; if(mouseIsDown){ media.setCurrentTime(newTime); } if(!mejs.MediaFeatures.hasTouch){ timefloat.css('left', pos); timefloatcurrent.html(mejs.Utility.secondsToTimeCode(newTime)); timefloat.show(); }} }, mouseIsDown=false, mouseIsOver=false; total .bind('mousedown', function (e){ if(e.which===1){ mouseIsDown=true; handleMouseMove(e); $(document) .bind('mousemove.dur', function(e){ handleMouseMove(e); }) .bind('mouseup.dur', function (e){ mouseIsDown=false; timefloat.hide(); $(document).unbind('.dur'); }); return false; }}) .bind('mouseenter', function(e){ mouseIsOver=true; $(document).bind('mousemove.dur', function(e){ handleMouseMove(e); }); if(!mejs.MediaFeatures.hasTouch){ timefloat.show(); }}) .bind('mouseleave',function(e){ mouseIsOver=false; if(!mouseIsDown){ $(document).unbind('.dur'); timefloat.hide(); }}); media.addEventListener('progress', function (e){ player.setProgressRail(e); player.setCurrentRail(e); }, false); media.addEventListener('timeupdate', function(e){ player.setProgressRail(e); player.setCurrentRail(e); }, false); t.loaded=loaded; t.total=total; t.current=current; t.handle=handle; }, setProgressRail: function(e){ var t=this, target=(e!=undefined) ? e.target:t.media, percent=null; if(target&&target.buffered&&target.buffered.length > 0&&target.buffered.end&&target.duration){ percent=target.buffered.end(0) / target.duration; } else if(target&&target.bytesTotal!=undefined&&target.bytesTotal > 0&&target.bufferedBytes!=undefined){ percent=target.bufferedBytes / target.bytesTotal; } else if(e&&e.lengthComputable&&e.total!=0){ percent=e.loaded/e.total; } if(percent!==null){ percent=Math.min(1, Math.max(0, percent)); if(t.loaded&&t.total){ t.loaded.width(t.total.width() * percent); }} }, setCurrentRail: function(){ var t=this; if(t.media.currentTime!=undefined&&t.media.duration){ if(t.total&&t.handle){ var newWidth=t.total.width() * t.media.currentTime / t.media.duration, handlePos=newWidth - (t.handle.outerWidth(true) / 2); t.current.width(newWidth); t.handle.css('left', handlePos); }} }}); })(mejs.$); (function($){ $.extend(mejs.MepDefaults, { duration: -1, timeAndDurationSeparator: ' | ' }); $.extend(MediaElementPlayer.prototype, { buildcurrent: function(player, controls, layers, media){ var t=this; $('
'+ '' + (player.options.alwaysShowHours ? '00:':'') + (player.options.showTimecodeFrameCount? '00:00:00':'00:00')+ ''+ '
') .appendTo(controls); t.currenttime=t.controls.find('.mejs-currenttime'); media.addEventListener('timeupdate',function(){ player.updateCurrent(); }, false); }, buildduration: function(player, controls, layers, media){ var t=this; if(controls.children().last().find('.mejs-currenttime').length > 0){ $(t.options.timeAndDurationSeparator + '' + (t.options.duration > 0 ? mejs.Utility.secondsToTimeCode(t.options.duration, t.options.alwaysShowHours||t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond||25) : ((player.options.alwaysShowHours ? '00:':'') + (player.options.showTimecodeFrameCount? '00:00:00':'00:00')) ) + '') .appendTo(controls.find('.mejs-time')); }else{ controls.find('.mejs-currenttime').parent().addClass('mejs-currenttime-container'); $('
'+ '' + (t.options.duration > 0 ? mejs.Utility.secondsToTimeCode(t.options.duration, t.options.alwaysShowHours||t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond||25) : ((player.options.alwaysShowHours ? '00:':'') + (player.options.showTimecodeFrameCount? '00:00:00':'00:00')) ) + '' + '
') .appendTo(controls); } t.durationD=t.controls.find('.mejs-duration'); media.addEventListener('timeupdate',function(){ player.updateDuration(); }, false); }, updateCurrent: function(){ var t=this; if(t.currenttime){ t.currenttime.html(mejs.Utility.secondsToTimeCode(t.media.currentTime, t.options.alwaysShowHours||t.media.duration > 3600, t.options.showTimecodeFrameCount, t.options.framesPerSecond||25)); }}, updateDuration: function(){ var t=this; if(t.media.duration&&t.durationD){ t.durationD.html(mejs.Utility.secondsToTimeCode(t.media.duration, t.options.alwaysShowHours, t.options.showTimecodeFrameCount, t.options.framesPerSecond||25)); }} }); })(mejs.$); (function($){ $.extend(mejs.MepDefaults, { muteText: 'Mute Toggle', hideVolumeOnTouchDevices: true, audioVolume: 'horizontal', videoVolume: 'vertical' }); $.extend(MediaElementPlayer.prototype, { buildvolume: function(player, controls, layers, media){ if(mejs.MediaFeatures.hasTouch&&this.options.hideVolumeOnTouchDevices) return; var t=this, mode=(t.isVideo) ? t.options.videoVolume:t.options.audioVolume, mute=(mode=='horizontal') ? $('
'+ ''+ '
' + '
'+ '
'+ '
'+ '
'+ '
' ) .appendTo(controls) : $('
'+ ''+ '
'+ '
'+ '
'+ '
'+ '
'+ '
') .appendTo(controls), volumeSlider=t.container.find('.mejs-volume-slider, .mejs-horizontal-volume-slider'), volumeTotal=t.container.find('.mejs-volume-total, .mejs-horizontal-volume-total'), volumeCurrent=t.container.find('.mejs-volume-current, .mejs-horizontal-volume-current'), volumeHandle=t.container.find('.mejs-volume-handle, .mejs-horizontal-volume-handle'), positionVolumeHandle=function(volume, secondTry){ if(!volumeSlider.is(':visible')&&typeof secondTry!='undefined'){ volumeSlider.show(); positionVolumeHandle(volume, true); volumeSlider.hide() return; } volume=Math.max(0,volume); volume=Math.min(volume,1); if(volume==0){ mute.removeClass('mejs-mute').addClass('mejs-unmute'); }else{ mute.removeClass('mejs-unmute').addClass('mejs-mute'); } if(mode=='vertical'){ var totalHeight=volumeTotal.height(), totalPosition=volumeTotal.position(), newTop=totalHeight - (totalHeight * volume); volumeHandle.css('top', totalPosition.top + newTop - (volumeHandle.height() / 2)); volumeCurrent.height(totalHeight - newTop); volumeCurrent.css('top', totalPosition.top + newTop); }else{ var totalWidth=volumeTotal.width(), totalPosition=volumeTotal.position(), newLeft=totalWidth * volume; volumeHandle.css('left', totalPosition.left + newLeft - (volumeHandle.width() / 2)); volumeCurrent.width(newLeft); }}, handleVolumeMove=function(e){ var volume=null, totalOffset=volumeTotal.offset(); if(mode=='vertical'){ var railHeight=volumeTotal.height(), totalTop=parseInt(volumeTotal.css('top').replace(/px/,''),10), newY=e.pageY - totalOffset.top; volume=(railHeight - newY) / railHeight; if(totalOffset.top==0||totalOffset.left==0) return; }else{ var railWidth=volumeTotal.width(), newX=e.pageX - totalOffset.left; volume=newX / railWidth; } volume=Math.max(0,volume); volume=Math.min(volume,1); positionVolumeHandle(volume); if(volume==0){ media.setMuted(true); }else{ media.setMuted(false); } media.setVolume(volume); }, mouseIsDown=false, mouseIsOver=false; mute .hover(function(){ volumeSlider.show(); mouseIsOver=true; }, function(){ mouseIsOver=false; if(!mouseIsDown&&mode=='vertical'){ volumeSlider.hide(); }}); volumeSlider .bind('mouseover', function(){ mouseIsOver=true; }) .bind('mousedown', function (e){ handleVolumeMove(e); $(document) .bind('mousemove.vol', function(e){ handleVolumeMove(e); }) .bind('mouseup.vol', function (){ mouseIsDown=false; $(document).unbind('.vol'); if(!mouseIsOver&&mode=='vertical'){ volumeSlider.hide(); }}); mouseIsDown=true; return false; }); mute.find('button').click(function(){ media.setMuted(!media.muted); }); media.addEventListener('volumechange', function(e){ if(!mouseIsDown){ if(media.muted){ positionVolumeHandle(0); mute.removeClass('mejs-mute').addClass('mejs-unmute'); }else{ positionVolumeHandle(media.volume); mute.removeClass('mejs-unmute').addClass('mejs-mute'); }} }, false); if(t.container.is(':visible')){ positionVolumeHandle(player.options.startVolume); if(media.pluginType==='native'){ media.setVolume(player.options.startVolume); }} }}); })(mejs.$); (function($){ $.extend(mejs.MepDefaults, { usePluginFullScreen: true, newWindowCallback: function(){ return '';}, fullscreenText: 'Fullscreen' }); $.extend(MediaElementPlayer.prototype, { isFullScreen: false, isNativeFullScreen: false, docStyleOverflow: null, isInIframe: false, buildfullscreen: function(player, controls, layers, media){ if(!player.isVideo) return; player.isInIframe=(window.location!=window.parent.location); if(mejs.MediaFeatures.hasTrueNativeFullScreen){ var target=null; if(mejs.MediaFeatures.hasMozNativeFullScreen){ target=$(document); }else{ target=player.container; } target.bind(mejs.MediaFeatures.fullScreenEventName, function(e){ if(mejs.MediaFeatures.isFullScreen()){ player.isNativeFullScreen=true; player.setControlsSize(); }else{ player.isNativeFullScreen=false; player.exitFullScreen(); }}); } var t=this, normalHeight=0, normalWidth=0, container=player.container, fullscreenBtn = $('
' + '' + '
') .appendTo(controls); if(t.media.pluginType==='native'||(!t.options.usePluginFullScreen&&!mejs.MediaFeatures.isFirefox)){ fullscreenBtn.click(function(){ var isFullScreen=(mejs.MediaFeatures.hasTrueNativeFullScreen&&mejs.MediaFeatures.isFullScreen())||player.isFullScreen; if(isFullScreen){ player.exitFullScreen(); }else{ player.enterFullScreen(); }}); }else{ var hideTimeout=null, supportsPointerEvents=(function(){ var element=document.createElement('x'), documentElement=document.documentElement, getComputedStyle=window.getComputedStyle, supports; if(!('pointerEvents' in element.style)){ return false; } element.style.pointerEvents='auto'; element.style.pointerEvents='x'; documentElement.appendChild(element); supports=getComputedStyle && getComputedStyle(element, '').pointerEvents==='auto'; documentElement.removeChild(element); return !!supports; })(); console.log('supportsPointerEvents', supportsPointerEvents); if(supportsPointerEvents&&!mejs.MediaFeatures.isOpera){ var fullscreenIsDisabled=false, restoreControls=function(){ if(fullscreenIsDisabled){ videoHoverDiv.hide(); controlsLeftHoverDiv.hide(); controlsRightHoverDiv.hide(); fullscreenBtn.css('pointer-events', ''); t.controls.css('pointer-events', ''); fullscreenIsDisabled=false; }}, videoHoverDiv=$('
').appendTo(t.container).mouseover(restoreControls), controlsLeftHoverDiv=$('
').appendTo(t.container).mouseover(restoreControls), controlsRightHoverDiv=$('
').appendTo(t.container).mouseover(restoreControls), positionHoverDivs=function(){ var style={position: 'absolute', top: 0, left: 0}; //, backgroundColor: '#f00'}; videoHoverDiv.css(style); controlsLeftHoverDiv.css(style); controlsRightHoverDiv.css(style); videoHoverDiv .width(t.container.width()) .height(t.container.height() - t.controls.height()); var fullScreenBtnOffset=fullscreenBtn.offset().left - t.container.offset().left; fullScreenBtnWidth=fullscreenBtn.outerWidth(true); controlsLeftHoverDiv .width(fullScreenBtnOffset) .height(t.controls.height()) .css({top: t.container.height() - t.controls.height()}); controlsRightHoverDiv .width(t.container.width() - fullScreenBtnOffset - fullScreenBtnWidth) .height(t.controls.height()) .css({top: t.container.height() - t.controls.height(), left: fullScreenBtnOffset + fullScreenBtnWidth}); }; $(document).resize(function(){ positionHoverDivs(); }); fullscreenBtn .mouseover(function(){ if(!t.isFullScreen){ var buttonPos=fullscreenBtn.offset(), containerPos=player.container.offset(); media.positionFullscreenButton(buttonPos.left - containerPos.left, buttonPos.top - containerPos.top, false); fullscreenBtn.css('pointer-events', 'none'); t.controls.css('pointer-events', 'none'); videoHoverDiv.show(); controlsRightHoverDiv.show(); controlsLeftHoverDiv.show(); positionHoverDivs(); fullscreenIsDisabled=true; }}); media.addEventListener('fullscreenchange', function(e){ restoreControls(); }); /* $(document).mousemove(function(e){ if(fullscreenIsDisabled){ var fullscreenBtnPos=fullscreenBtn.offset(); if(e.pageY < fullscreenBtnPos.top||e.pageY > fullscreenBtnPos.top + fullscreenBtn.outerHeight(true) || e.pageX < fullscreenBtnPos.left||e.pageX > fullscreenBtnPos.left + fullscreenBtn.outerWidth(true) ){ fullscreenBtn.css('pointer-events', ''); t.controls.css('pointer-events', ''); fullscreenIsDisabled=false; }} }); */ }else{ fullscreenBtn .mouseover(function(){ if(hideTimeout!==null){ clearTimeout(hideTimeout); delete hideTimeout; } var buttonPos=fullscreenBtn.offset(), containerPos=player.container.offset(); media.positionFullscreenButton(buttonPos.left - containerPos.left, buttonPos.top - containerPos.top, true); }) .mouseout(function(){ if(hideTimeout!==null){ clearTimeout(hideTimeout); delete hideTimeout; } hideTimeout=setTimeout(function(){ media.hideFullscreenButton(); }, 1500); }); }} player.fullscreenBtn=fullscreenBtn; $(document).bind('keydown',function (e){ if(((mejs.MediaFeatures.hasTrueNativeFullScreen&&mejs.MediaFeatures.isFullScreen())||t.isFullScreen)&&e.keyCode==27){ player.exitFullScreen(); }}); }, enterFullScreen: function(){ var t=this; if(t.media.pluginType!=='native'&&(mejs.MediaFeatures.isFirefox||t.options.usePluginFullScreen)){ return; } docStyleOverflow=document.documentElement.style.overflow; document.documentElement.style.overflow='hidden'; normalHeight=t.container.height(); normalWidth=t.container.width(); if(t.media.pluginType==='native'){ if(mejs.MediaFeatures.hasTrueNativeFullScreen){ mejs.MediaFeatures.requestFullScreen(t.container[0]); if(t.isInIframe){ setTimeout(function checkFullscreen(){ if(t.isNativeFullScreen){ if($(window).width()!==screen.width){ t.exitFullScreen(); }else{ setTimeout(checkFullscreen, 500); }} }, 500); }}else if(mejs.MediaFeatures.hasSemiNativeFullScreen){ t.media.webkitEnterFullscreen(); return; }} if(t.isInIframe){ var url=t.options.newWindowCallback(this); if(url!==''){ if(!mejs.MediaFeatures.hasTrueNativeFullScreen){ t.pause(); window.open(url, t.id, 'top=0,left=0,width=' + screen.availWidth + ',height=' + screen.availHeight + ',resizable=yes,scrollbars=no,status=no,toolbar=no'); return; }else{ setTimeout(function(){ if(!t.isNativeFullScreen){ t.pause(); window.open(url, t.id, 'top=0,left=0,width=' + screen.availWidth + ',height=' + screen.availHeight + ',resizable=yes,scrollbars=no,status=no,toolbar=no'); }}, 250); }} } t.container .addClass('mejs-container-fullscreen') .width('100%') .height('100%'); setTimeout(function(){ t.container.css({width: '100%', height: '100%'}); t.setControlsSize(); }, 500); if(t.pluginType==='native'){ t.$media .width('100%') .height('100%'); }else{ t.container.find('object, embed, iframe') .width('100%') .height('100%'); t.media.setVideoSize($(window).width(),$(window).height()); } t.layers.children('div') .width('100%') .height('100%'); if(t.fullscreenBtn){ t.fullscreenBtn .removeClass('mejs-fullscreen') .addClass('mejs-unfullscreen'); } t.setControlsSize(); t.isFullScreen=true; }, exitFullScreen: function(){ var t=this; if(t.media.pluginType!=='native'&&mejs.MediaFeatures.isFirefox){ t.media.setFullscreen(false); return; } if(mejs.MediaFeatures.hasTrueNativeFullScreen&&(mejs.MediaFeatures.isFullScreen()||t.isFullScreen)){ mejs.MediaFeatures.cancelFullScreen(); } document.documentElement.style.overflow=docStyleOverflow; t.container .removeClass('mejs-container-fullscreen') .width(normalWidth) .height(normalHeight); if(t.pluginType==='native'){ t.$media .width(normalWidth) .height(normalHeight); }else{ t.container.find('object embed') .width(normalWidth) .height(normalHeight); t.media.setVideoSize(normalWidth, normalHeight); } t.layers.children('div') .width(normalWidth) .height(normalHeight); t.fullscreenBtn .removeClass('mejs-unfullscreen') .addClass('mejs-fullscreen'); t.setControlsSize(); t.isFullScreen=false; }}); })(mejs.$); (function($){ $.extend(mejs.MepDefaults, { startLanguage: '', tracksText: 'Captions/Subtitles' }); $.extend(MediaElementPlayer.prototype, { hasChapters: false, buildtracks: function(player, controls, layers, media){ if(!player.isVideo) return; if(player.tracks.length==0) return; var t=this, i, options=''; player.chapters = $('
') .prependTo(layers).hide(); player.captions = $('
') .prependTo(layers).hide(); player.captionsText=player.captions.find('.mejs-captions-text'); player.captionsButton = $('
'+ ''+ '
'+ '
    '+ '
  • '+ '' + ''+ '
  • ' + '
'+ '
'+ '
') .appendTo(controls) .hover(function(){ $(this).find('.mejs-captions-selector').css('visibility','visible'); }, function(){ $(this).find('.mejs-captions-selector').css('visibility','hidden'); }) .delegate('input[type=radio]','click',function(){ lang=this.value; if(lang=='none'){ player.selectedTrack=null; }else{ for (i=0; i 0){ t.drawChapters(track); }}, error: function(){ t.loadNextTrack(); }}); }}, enableTrackButton: function(lang, label){ var t=this; if(label===''){ label=mejs.language.codes[lang]||lang; } t.captionsButton .find('input[value=' + lang + ']') .prop('disabled',false) .siblings('label') .html(label); if(t.options.startLanguage==lang){ $('#' + t.id + '_captions_' + lang).click(); } t.adjustLanguageBox(); }, addTrackButton: function(lang, label){ var t=this; if(label===''){ label=mejs.language.codes[lang]||lang; } t.captionsButton.find('ul').append($('
  • '+ '' + ''+ '
  • ') ); t.adjustLanguageBox(); t.container.find('.mejs-captions-translations option[value=' + lang + ']').remove(); }, adjustLanguageBox:function(){ var t=this; t.captionsButton.find('.mejs-captions-selector').height(t.captionsButton.find('.mejs-captions-selector ul').outerHeight(true) + t.captionsButton.find('.mejs-captions-translations').outerHeight(true) ); }, displayCaptions: function(){ if(typeof this.tracks=='undefined') return; var t=this, i, track=t.selectedTrack; if(track!=null&&track.isLoaded){ for (i=0; i=track.entries.times[i].start&&t.media.currentTime <=track.entries.times[i].stop){ t.captionsText.html(track.entries.text[i]); t.captions.show().height(0); return; }} t.captions.hide(); }else{ t.captions.hide(); }}, displayChapters: function(){ var t=this, i; for (i=0; i 100 || i==chapters.entries.times.length-1&&percent + usedPercent < 100){ percent=100 - usedPercent; } t.chapters.append($( '
    ' + '
    ' + '' + chapters.entries.text[i] + '' + '' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].start) + '–' + mejs.Utility.secondsToTimeCode(chapters.entries.times[i].stop) + '' + '
    ' + '
    ')); usedPercent +=percent; } t.chapters.find('div.mejs-chapter').click(function(){ t.media.setCurrentTime(parseFloat($(this).attr('rel'))); if(t.media.paused){ t.media.play(); }}); t.chapters.show(); }}); mejs.language={ codes: { af:'Afrikaans', sq:'Albanian', ar:'Arabic', be:'Belarusian', bg:'Bulgarian', ca:'Catalan', zh:'Chinese', 'zh-cn':'Chinese Simplified', 'zh-tw':'Chinese Traditional', hr:'Croatian', cs:'Czech', da:'Danish', nl:'Dutch', en:'English', et:'Estonian', tl:'Filipino', fi:'Finnish', fr:'French', gl:'Galician', de:'German', el:'Greek', ht:'Haitian Creole', iw:'Hebrew', hi:'Hindi', hu:'Hungarian', is:'Icelandic', id:'Indonesian', ga:'Irish', it:'Italian', ja:'Japanese', ko:'Korean', lv:'Latvian', lt:'Lithuanian', mk:'Macedonian', ms:'Malay', mt:'Maltese', no:'Norwegian', fa:'Persian', pl:'Polish', pt:'Portuguese', ro:'Romanian', ru:'Russian', sr:'Serbian', sk:'Slovak', sl:'Slovenian', es:'Spanish', sw:'Swahili', sv:'Swedish', tl:'Tagalog', th:'Thai', tr:'Turkish', uk:'Ukrainian', vi:'Vietnamese', cy:'Welsh', yi:'Yiddish' }}; mejs.TrackFormatParser={ pattern_identifier: /^([a-zA-z]+-)?[0-9]+$/, pattern_timecode: /^([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{1,3})?) --\> ([0-9]{2}:[0-9]{2}:[0-9]{2}([,.][0-9]{3})?)(.*)$/, split2: function (text, regex){ return text.split(regex); }, parse: function(trackText){ var i=0, lines=this.split2(trackText, /\r?\n/), entries={text:[], times:[]}, timecode, text; for(; i
    ') .appendTo($('body')) .hide(); player.container.bind('contextmenu', function(e){ if(player.isContextMenuEnabled){ e.preventDefault(); player.renderContextMenu(e.clientX-1, e.clientY-1); return false; }}); player.container.bind('click', function(){ player.contextMenu.hide(); }); player.contextMenu.bind('mouseleave', function(){ player.startContextMenuTimer(); }); }, isContextMenuEnabled: true, enableContextMenu: function(){ this.isContextMenuEnabled=true; }, disableContextMenu: function(){ this.isContextMenuEnabled=false; }, contextMenuTimeout: null, startContextMenuTimer: function(){ var t=this; t.killContextMenuTimer(); t.contextMenuTimer=setTimeout(function(){ t.hideContextMenu(); t.killContextMenuTimer(); }, 750); }, killContextMenuTimer: function(){ var timer=this.contextMenuTimer; if(timer!=null){ clearTimeout(timer); delete timer; timer=null; }}, hideContextMenu: function(){ this.contextMenu.hide(); }, renderContextMenu: function(x,y){ var t=this, html='', items=t.options.contextMenuItems; for (var i=0, il=items.length; i' + rendered + '
    '; }} } t.contextMenu .empty() .append($(html)) .css({top:y, left:x}) .show(); t.contextMenu.find('.mejs-contextmenu-item').each(function(){ var $dom=$(this), itemIndex=parseInt($dom.data('itemindex'), 10), item=t.options.contextMenuItems[itemIndex]; if(typeof item.show!='undefined') item.show($dom , t); $dom.click(function(){ if(typeof item.click!='undefined') item.click(t); t.contextMenu.hide(); }); }); setTimeout(function(){ t.killControlsTimer('rev3'); }, 100); }}); })(mejs.$); ;(function($){ $.fn.infinitescroll=function(options,callback){ function debug(){ if(opts.debug){ window.console&&console.log.call(console,arguments)}} function areSelectorsValid(opts){ for (var key in opts){ if(key.indexOf&&key.indexOf('Selector') > -1&&$(opts[key]).length===0){ debug('Your ' + key + ' found no elements.'); return false; } return true; }} function determinePath(path){ path.match(relurl) ? path.match(relurl)[2]:path; if(path.match(/^(.*?)\b2\b(.*?$)/)){ path=path.match(/^(.*?)\b2\b(.*?$)/).slice(1); } else if(path.match(/^(.*?)2(.*?$)/)){ if(path.match(/^(.*?page=)2(\/.*|$)/)){ path=path.match(/^(.*?page=)2(\/.*|$)/).slice(1); return path; } debug('Trying backup next selector parse technique. Treacherous waters here, matey.'); path=path.match(/^(.*?)2(.*?$)/).slice(1); }else{ if(path.match(/^(.*?page=)1(\/.*|$)/)){ path=path.match(/^(.*?page=)1(\/.*|$)/).slice(1); return path; } debug('Sorry, we couldn\'t parse your Next (Previous Posts) URL. Verify your the css selector points to the correct A tag. If you still get this error: yell, scream, and kindly ask for help at infinite-scroll.com.'); props.isInvalidPage=true; } return path; } function getDocumentHeight(){ return opts.localMode ? ($(props.container)[0].scrollHeight&&$(props.container)[0].scrollHeight) : $(document).height() } function isNearBottom(){ var pixelsFromWindowBottomToBottom=0 + getDocumentHeight() - ( opts.localMode ? $(props.container).scrollTop() : ($(props.container).scrollTop()||$(props.container.ownerDocument.body).scrollTop()) ) - $(opts.localMode ? props.container:window).height(); debug('math:',pixelsFromWindowBottomToBottom, props.pixelsFromNavToBottom); return (pixelsFromWindowBottomToBottom - opts.bufferPx < props.pixelsFromNavToBottom); } function showDoneMsg(){ props.loadingMsg .find('img').hide() .parent() .find('div').html(opts.donetext).animate({opacity: 1},2000).fadeOut('normal'); opts.errorCallback(); } function infscrSetup(){ if(props.isDuringAjax||props.isInvalidPage||props.isDone) return; if(!isNearBottom(opts,props)) return; $(document).trigger('retrieve.infscr'); } function kickOffAjax(){ props.isDuringAjax=true; props.loadingMsg.appendTo($(opts.contentSelector).parent()).show(); $(opts.navSelector).hide(); props.currPage++; debug('heading into ajax',path); box=$(opts.contentSelector).is('table') ? $(''):$('
    '); frag=document.createDocumentFragment(); box.load(path.join(props.currPage) + ' ' + opts.itemSelector,null,loadCallback); } function loadCallback(){ if(props.isDone){ showDoneMsg(); return false; }else{ var children=box.children().get(); if(children.length==0){ return $.event.trigger("ajaxError", [{status:404}]); } while (box[0].firstChild){ frag.appendChild(box[0].firstChild); } $(opts.contentSelector)[0].appendChild(frag); props.loadingMsg.fadeOut('normal'); if(opts.animate){ var scrollTo=$(window).scrollTop() + $('#infscr-loading').height() + opts.extraScrollPx + 'px'; $('html,body').animate({scrollTop: scrollTo}, 800,function(){ props.isDuringAjax=false; }); } callback.call($(opts.contentSelector)[0], children); if(!opts.animate) props.isDuringAjax=false; }} $.browser.ie6=$.browser.msie&&$.browser.version < 7; var opts=$.extend({}, $.infinitescroll.defaults, options), props=$.infinitescroll, box, frag; callback=callback||function(){}; if(!areSelectorsValid(opts)){ return false; } props.container=opts.localMode ? this:document.documentElement; opts.contentSelector=opts.contentSelector||this; var relurl=/(.*?\/\/).*?(\/.*)/, path=$(opts.nextSelector).attr('href'); if(!path){ debug('Navigation selector not found'); return; } path=determinePath(path); if(opts.localMode) $(props.container)[0].scrollTop=0; props.pixelsFromNavToBottom=getDocumentHeight() + (props.container==document.documentElement ? 0:$(props.container).offset().top)- $(opts.navSelector).offset().top; props.loadingMsg=$('
    Loading...
    '+opts.loadingText+'
    '); (new Image()).src=opts.loadingImg; $(document).ajaxError(function(e,xhr,opt){ debug('Page not found. Self-destructing...'); if(xhr.status==404){ showDoneMsg(); props.isDone=true; $(opts.localMode ? this:window).unbind('scroll.infscr'); }}); $(opts.localMode ? this:window) .bind('scroll.infscr', infscrSetup) .trigger('scroll.infscr'); $(document).bind('retrieve.infscr',kickOffAjax); return this; } $.infinitescroll={ defaults:{ debug:false, preload:false, nextSelector:"div.navigation a:first", loadingImg:"http://www.infinite-scroll.com/loading.gif", loadingText:"Loading the next set of posts...", donetext:"Congratulations, you've reached the end of the internet.", navSelector:"div.navigation", contentSelector:null, extraScrollPx:150, itemSelector:"div.post", animate:false, localMode:false, bufferPx:40, errorCallback:function(){}}, loadingImg:undefined, loadingMsg:undefined, container:undefined, currPage:1, currDOMChunk:null, isDuringAjax:false, isInvalidPage:false, isDone:false };})(jQuery); (function ($, document, window){ var defaults={ transition: "elastic", speed: 300, width: false, initialWidth: "600", innerWidth: false, maxWidth: false, height: false, initialHeight: "450", innerHeight: false, maxHeight: false, scalePhotos: true, scrolling: true, inline: false, html: false, iframe: false, fastIframe: true, photo: false, href: false, title: false, rel: false, opacity: 0.9, preloading: true, current: "image {current} of {total}", previous: "previous", next: "next", close: "close", open: false, returnFocus: true, loop: true, slideshow: false, slideshowAuto: true, slideshowSpeed: 2500, slideshowStart: "start slideshow", slideshowStop: "stop slideshow", onOpen: false, onLoad: false, onComplete: false, onCleanup: false, onClosed: false, overlayClose: true, escKey: true, arrowKey: true }, colorbox='colorbox', prefix='cbox', event_open=prefix + '_open', event_load=prefix + '_load', event_complete=prefix + '_complete', event_cleanup=prefix + '_cleanup', event_closed=prefix + '_closed', event_purge=prefix + '_purge', isIE=$.browser.msie&&!$.support.opacity, isIE6=isIE&&$.browser.version < 7, event_ie6=prefix + '_IE6', $overlay, $box, $wrap, $content, $topBorder, $leftBorder, $rightBorder, $bottomBorder, $related, $window, $loaded, $loadingBay, $loadingOverlay, $title, $current, $slideshow, $next, $prev, $close, $groupControls, settings={}, interfaceHeight, interfaceWidth, loadedHeight, loadedWidth, element, index, photo, open, active, closing=false, publicMethod, boxElement=prefix + 'Element'; function $div(id, cssText){ var div=document.createElement('div'); if(id){ div.id=prefix + id; } div.style.cssText=cssText||false; return $(div); } function setSize(size, dimension){ dimension=dimension==='x' ? $window.width():$window.height(); return (typeof size==='string') ? Math.round((/%/.test(size) ? (dimension / 100) * parseInt(size, 10):parseInt(size, 10))):size; } function isImage(url){ return settings.photo||/\.(gif|png|jpg|jpeg|bmp)(?:\?([^#]*))?(?:#(\.*))?$/i.test(url); } function process(settings){ for (var i in settings){ if($.isFunction(settings[i])&&i.substring(0, 2)!=='on'){ settings[i]=settings[i].call(element); }} settings.rel=settings.rel||element.rel||'nofollow'; settings.href=$.trim(settings.href||$(element).attr('href')); settings.title=settings.title||element.title; } function trigger(event, callback){ if(callback){ callback.call(element); } $.event.trigger(event); } function slideshow(){ var timeOut, className=prefix + "Slideshow_", click="click." + prefix, start, stop, clear; if(settings.slideshow&&$related[1]){ start=function (){ $slideshow .text(settings.slideshowStop) .unbind(click) .bind(event_complete, function (){ if(index < $related.length - 1||settings.loop){ timeOut=setTimeout(publicMethod.next, settings.slideshowSpeed); }}) .bind(event_load, function (){ clearTimeout(timeOut); }) .one(click + ' ' + event_cleanup, stop); $box.removeClass(className + "off").addClass(className + "on"); timeOut=setTimeout(publicMethod.next, settings.slideshowSpeed); }; stop=function (){ clearTimeout(timeOut); $slideshow .text(settings.slideshowStart) .unbind([event_complete, event_load, event_cleanup, click].join(' ')) .one(click, start); $box.removeClass(className + "on").addClass(className + "off"); }; if(settings.slideshowAuto){ start(); }else{ stop(); }} } function launch(elem){ if(!closing){ element=elem; process($.extend(settings, $.data(element, colorbox))); $related=$(element); index=0; if(settings.rel!=='nofollow'){ $related=$('.' + boxElement).filter(function (){ var relRelated=$.data(this, colorbox).rel||this.rel; return (relRelated===settings.rel); }); index=$related.index(element); if(index===-1){ $related=$related.add(element); index=$related.length - 1; }} if(!open){ open=active=true; $box.show(); if(settings.returnFocus){ try { element.blur(); $(element).one(event_closed, function (){ try { this.focus(); } catch (e){ }}); } catch (e){ }} $overlay.css({"opacity": +settings.opacity, "cursor": settings.overlayClose ? "pointer":"auto"}).show(); settings.w=setSize(settings.initialWidth, 'x'); settings.h=setSize(settings.initialHeight, 'y'); publicMethod.position(0); if(isIE6){ $window.bind('resize.' + event_ie6 + ' scroll.' + event_ie6, function (){ $overlay.css({width: $window.width(), height: $window.height(), top: $window.scrollTop(), left: $window.scrollLeft()}); }).trigger('resize.' + event_ie6); } trigger(event_open, settings.onOpen); $groupControls.add($title).hide(); $close.html(settings.close).show(); } publicMethod.load(true); }} publicMethod=$.fn[colorbox]=$[colorbox]=function (options, callback){ var $this=this, autoOpen; if(!$this[0]&&$this.selector){ return $this; } options=options||{}; if(callback){ options.onComplete=callback; } if(!$this[0]||$this.selector===undefined){ $this=$(''); options.open=true; } $this.each(function (){ $.data(this, colorbox, $.extend({}, $.data(this, colorbox)||defaults, options)); $(this).addClass(boxElement); }); autoOpen=options.open; if($.isFunction(autoOpen)){ autoOpen=autoOpen.call($this); } if(autoOpen){ launch($this[0]); } return $this; }; publicMethod.init=function (){ $window=$(window); $box=$div().attr({id: colorbox, 'class': isIE ? prefix + (isIE6 ? 'IE6':'IE'):''}); $overlay=$div("Overlay", isIE6 ? 'position:absolute':'').hide(); $wrap=$div("Wrapper"); $content=$div("Content").append($loaded=$div("LoadedContent", 'width:0; height:0; overflow:hidden'), $loadingOverlay=$div("LoadingOverlay").add($div("LoadingGraphic")), $title=$div("Title"), $current=$div("Current"), $next=$div("Next"), $prev=$div("Previous"), $slideshow=$div("Slideshow").bind(event_open, slideshow), $close=$div("Close") ); $wrap.append($div().append($div("TopLeft"), $topBorder=$div("TopCenter"), $div("TopRight") ), $div(false, 'clear:left').append($leftBorder=$div("MiddleLeft"), $content, $rightBorder=$div("MiddleRight") ), $div(false, 'clear:left').append($div("BottomLeft"), $bottomBorder=$div("BottomCenter"), $div("BottomRight") ) ).children().children().css({'float': 'left'}); $loadingBay=$div(false, 'position:absolute; width:9999px; visibility:hidden; display:none'); $('body').prepend($overlay, $box.append($wrap, $loadingBay)); $content.children() .hover(function (){ $(this).addClass('hover'); }, function (){ $(this).removeClass('hover'); }).addClass('hover'); interfaceHeight=$topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height(); interfaceWidth=$leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width(); loadedHeight=$loaded.outerHeight(true); loadedWidth=$loaded.outerWidth(true); $box.css({"padding-bottom": interfaceHeight, "padding-right": interfaceWidth}).hide(); $next.click(function (){ publicMethod.next(); }); $prev.click(function (){ publicMethod.prev(); }); $close.click(function (){ publicMethod.close(); }); $groupControls=$next.add($prev).add($current).add($slideshow); $content.children().removeClass('hover'); $('.' + boxElement).live('click', function (e){ if(!((e.button!==0&&typeof e.button!=='undefined')||e.ctrlKey||e.shiftKey||e.altKey)){ e.preventDefault(); launch(this); }}); $overlay.click(function (){ if(settings.overlayClose){ publicMethod.close(); }}); $(document).bind('keydown.' + prefix, function (e){ var key=e.keyCode; if(open&&settings.escKey&&key===27){ e.preventDefault(); publicMethod.close(); } if(open&&settings.arrowKey&&$related[1]){ if(key===37){ e.preventDefault(); $prev.click(); }else if(key===39){ e.preventDefault(); $next.click(); }} }); }; publicMethod.remove=function (){ $box.add($overlay).remove(); $('.' + boxElement).die('click').removeData(colorbox).removeClass(boxElement); }; publicMethod.position=function (speed, loadedCallback){ var animate_speed, posTop=Math.max(document.documentElement.clientHeight - settings.h - loadedHeight - interfaceHeight, 0) / 2 + $window.scrollTop(), posLeft=Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2 + $window.scrollLeft(); animate_speed=($box.width()===settings.w + loadedWidth&&$box.height()===settings.h + loadedHeight) ? 0:speed; $wrap[0].style.width=$wrap[0].style.height="9999px"; function modalDimensions(that){ $topBorder[0].style.width=$bottomBorder[0].style.width=$content[0].style.width=that.style.width; $loadingOverlay[0].style.height=$loadingOverlay[1].style.height=$content[0].style.height=$leftBorder[0].style.height=$rightBorder[0].style.height=that.style.height; } $box.dequeue().animate({width: settings.w + loadedWidth, height: settings.h + loadedHeight, top: posTop, left: posLeft}, { duration: animate_speed, complete: function (){ modalDimensions(this); active=false; $wrap[0].style.width=(settings.w + loadedWidth + interfaceWidth) + "px"; $wrap[0].style.height=(settings.h + loadedHeight + interfaceHeight) + "px"; if(loadedCallback){ loadedCallback(); }}, step: function (){ modalDimensions(this); }}); }; publicMethod.resize=function (options){ if(open){ options=options||{}; if(options.width){ settings.w=setSize(options.width, 'x') - loadedWidth - interfaceWidth; } if(options.innerWidth){ settings.w=setSize(options.innerWidth, 'x'); } $loaded.css({width: settings.w}); if(options.height){ settings.h=setSize(options.height, 'y') - loadedHeight - interfaceHeight; } if(options.innerHeight){ settings.h=setSize(options.innerHeight, 'y'); } if(!options.innerHeight&&!options.height){ var $child=$loaded.wrapInner("
    ").children(); settings.h=$child.height(); $child.replaceWith($child.children()); } $loaded.css({height: settings.h}); publicMethod.position(settings.transition==="none" ? 0:settings.speed); }}; publicMethod.prep=function (object){ if(!open){ return; } var speed=settings.transition==="none" ? 0:settings.speed; $window.unbind('resize.' + prefix); $loaded.remove(); $loaded=$div('LoadedContent').html(object); function getWidth(){ settings.w=settings.w||$loaded.width(); settings.w=settings.mw&&settings.mw < settings.w ? settings.mw:settings.w; return settings.w; } function getHeight(){ settings.h=settings.h||$loaded.height(); settings.h=settings.mh&&settings.mh < settings.h ? settings.mh:settings.h; return settings.h; } $loaded.hide() .appendTo($loadingBay.show()) .css({width: getWidth(), overflow: settings.scrolling ? 'auto':'hidden'}) .css({height: getHeight()}) .prependTo($content); $loadingBay.hide(); $(photo).css({'float': 'none'}); if(isIE6){ $('select').not($box.find('select')).filter(function (){ return this.style.visibility!=='hidden'; }).css({'visibility': 'hidden'}).one(event_cleanup, function (){ this.style.visibility='inherit'; }); } function setPosition(s){ publicMethod.position(s, function (){ var prev, prevSrc, next, nextSrc, total=$related.length, iframe, complete; if(!open){ return; } complete=function (){ $loadingOverlay.hide(); trigger(event_complete, settings.onComplete); }; if(isIE){ if(photo){ $loaded.fadeIn(100); }} $title.html(settings.title).add($loaded).show(); if(total > 1){ if(typeof settings.current==="string"){ $current.html(settings.current.replace(/\{current\}/, index + 1).replace(/\{total\}/, total)).show(); } $next[(settings.loop||index < total - 1) ? "show":"hide"]().html(settings.next); $prev[(settings.loop||index) ? "show":"hide"]().html(settings.previous); prev=index ? $related[index - 1]:$related[total - 1]; next=index < total - 1 ? $related[index + 1]:$related[0]; if(settings.slideshow){ $slideshow.show(); } if(settings.preloading){ nextSrc=$.data(next, colorbox).href||next.href; prevSrc=$.data(prev, colorbox).href||prev.href; nextSrc=$.isFunction(nextSrc) ? nextSrc.call(next):nextSrc; prevSrc=$.isFunction(prevSrc) ? prevSrc.call(prev):prevSrc; if(isImage(nextSrc)){ $('')[0].src=nextSrc; } if(isImage(prevSrc)){ $('')[0].src=prevSrc; }} }else{ $groupControls.hide(); } if(settings.iframe){ iframe=$('