diff --git a/timesheets-playlist.js b/timesheets-playlist.js index 37abbba..aae827c 100644 --- a/timesheets-playlist.js +++ b/timesheets-playlist.js @@ -24,7 +24,7 @@ * contact : fabien.cazenave@inria.fr, kaze@kompozer.net * license : MIT * version : 0.5.1pre - * last change : 2011-05-25 + * last change : 2014-12-05 * * TODO: * - factorize the onbegin/onend code @@ -88,8 +88,8 @@ // ========================================================================== // Generic Events // ========================================================================== - // addEventListener should work fine everywhere except with IE<9 - if (window.addEventListener) { // modern browsers + // addEventListener and createEvent should work fine everywhere except IE<9 + if (window.addEventListener && document.createEvent) { // modern browsers EVENTS.bind = function(node, type, callback) { if (!node) return; node.addEventListener(type, callback, false); @@ -798,7 +798,7 @@ function parseAllTimeContainers() { if (!OLDIE) { var docElt = document.documentElement; var ns = { - "xhtml" : "http://www.w3.org/1999/xhtml", + "xhtml" : "http://www.w3.org/1999/xhtml", "svg" : "http://www.w3.org/2000/svg", "smil" : docElt.getAttribute("xmlns:smil") || "http://www.w3.org/ns/SMIL" }; diff --git a/timesheets-playlist.min.js b/timesheets-playlist.min.js new file mode 100644 index 0000000..fed7c7c --- /dev/null +++ b/timesheets-playlist.min.js @@ -0,0 +1,215 @@ +!function(window,document,undefined){var EVENTS={bind:function(node,type,callback){},unbind:function(node,type,callback){},trigger:function(node,type){}};if(window.addEventListener&&document.createEvent){EVENTS.bind=function(node,type,callback){if(!node)return;node.addEventListener(type,callback,false);};EVENTS.unbind=function(node,type,callback){if(!node)return;node.removeEventListener(type,callback,false);};EVENTS.trigger=function(node,type){if(!node)return;if(!EVENTS.eventList) +EVENTS.eventList=[];var evtObject=EVENTS.eventList[type];if(!evtObject){evtObject=document.createEvent("Event");evtObject.initEvent(type,false,false);EVENTS.eventList[type]=evtObject;} +node.dispatchEvent(evtObject);};EVENTS.preventDefault=function(e){e.preventDefault();};} +else if(window.attachEvent){EVENTS.bind=function(node,type,callback){if(!node)return;var ref=type+callback;type="on"+type;if(type in node){if(!node["e"+ref]){node["e"+ref]=callback;node[ref]=function(){node["e"+ref](window.event);};node.attachEvent(type,node[ref]);}} +else{if(!node.eventList) +node.eventList=[];if(!node.eventList[type]) +node.eventList[type]=[];node.eventList[type].push(callback);}};EVENTS.unbind=function(node,type,callback){if(!node)return;var ref=type+callback;type="on"+type;if(type in node){if(node["e"+ref]){node.detachEvent(type,node[ref]);try{delete(node[ref]);delete(node["e"+ref]);}catch(e){node[ref]=null;node["e"+ref]=null;}}} +else{if(!node||!node.eventList||!node.eventList[type]) +return;var callbacks=node.eventList[type];var cbLength=callbacks.length;for(var i=0;i=0;i--){consoleLog(containers[i].nodeName+" - index="+indexes[i]);containers[i].selectIndex(indexes[i]);} +if(targetTiming&&!isNaN(time)){targetTiming.setCurrentTime(time);consoleLog(targetElement.nodeName+" time: "+time);} +if(targetElement["scrollIntoViewIfNeeded"]!=undefined) +targetElement.scrollIntoViewIfNeeded();else try{var tabIndex=targetElement.tabIndex;targetElement.tabIndex=0;targetElement.focus();targetElement.blur();if(tabIndex>=0) +targetElement.tabIndex=tabIndex;else +targetElement.removeAttribute("tabIndex");}catch(e){}} +EVENTS.onSMILReady(function(){consoleLog("SMIL data parsed, starting 'hashchange' event listener.");checkHash();EVENTS.onHashChange(checkHash);});function parseMediaElement(node){if(window.MediaElement){var m=new MediaElement(node,{success:function(mediaAPI,element){consoleLog("MediaElement with "+mediaAPI.pluginType+" player");if((/^(flash|silverlight)$/i).test(mediaAPI.pluginType)){var pluginElement=element.previousSibling;if(element.firstChild&&(/^(object|embed)$/i).test(element.firstChild.nodeName)){pluginElement=element.firstChild;consoleLog(" (childNode)");}else if(pluginElement&&((/^me_flash/).test(pluginElement.id)||(/^me_silverlight/).test(pluginElement.id)||(pluginElement.className=="me-plugin"))){pluginElement.setAttribute("timeAction","none");consoleLog(" (previousSibling)");} +element.pluginElement=pluginElement;element.mediaAPI=mediaAPI;} +EVENTS.trigger(document,"MediaElementLoaded");},error:function(){alert("MediaElement error");}});} +else{node.setCurrentTime=function(time){node.currentTime=time;};EVENTS.trigger(document,"MediaElementLoaded");}} +function parseAllMediaElements(){var allAudioElements=document.getElementsByTagName("audio");var allVideoElements=document.getElementsByTagName("video");var meLength=allAudioElements.length+allVideoElements.length;if(meLength===0){EVENTS.trigger(window,"MediaContentLoaded");return;} +else if(OLDIE&&!window.MediaElement){if(0)throw"MediaElement.js is required on IE<9";} +var meParsed=0;function CountMediaElements(){meParsed++;if(meParsed>=meLength){EVENTS.unbind(document,"MediaElementLoaded",CountMediaElements);EVENTS.trigger(window,"MediaContentLoaded");}} +EVENTS.bind(document,"MediaElementLoaded",CountMediaElements);for(var i=0;itsLength){EVENTS.unbind(document,"SMILTimesheetLoaded",CountTimesheets);EVENTS.trigger(window,"SMILContentLoaded");}} +EVENTS.bind(document,"SMILTimesheetLoaded",CountTimesheets);var xhr;for(var i=0;i=2){target=document.getElementById(tmp[0]);evt=tmp[1];}else{target=this.parentTarget;evt=eventStr;} +events.push({target:target,event:evt});if(callback) +EVENTS.bind(target,evt,callback);} +return events;};smilTimeItem.prototype.parseAttribute=function(attrName,dValue){var node=this.getNode();var nodeName=node.nodeName.replace(/^smil:/,"");var value="";if((attrName=="timeContainer")&&(/^(seq|par|excl)$/i).test(nodeName)) +value=nodeName;else +value=node.getAttribute(attrName)||node.getAttribute("data-"+attrName.toLowerCase())||node.getAttribute("smil-"+attrName.toLowerCase())||node.getAttribute("smil:"+attrName);if(!value||!value.length) +return dValue;switch(attrName){case"timeContainer":case"timeAction":return value.toLowerCase();case"repeatCount":return(value=="indefinite")?Infinity:parseFloat(value);case"onbegin":case"onend":return function(){eval(value);};case"beginInc":case"begin":case"dur":case"end":case"repeatDur":return this.parseTime(value);default:return value;}};smilTimeItem.prototype.newTargetHandler=function(timeAction,target){if(!target){return function(state){};} +var setTargetState_intrinsic=function(state){target.setAttribute("smil",state);};var setTargetState_display=function(state){target.setAttribute("smil",state);target.style.display=(state=="active")?"block":"none";};var setTargetState_visibility=function(state){target.setAttribute("smil",state);target.style.visibility=(state=="active")?"visible":"hidden";};var setTargetState_style=function(state){target.setAttribute("smil",state);var active=(state=="active");if(!target._smilstyle) +target._smilstyle=target.style.cssText;target.style.cssText=active?target._smilstyle:"";};var setTargetState_class=function(state){target.setAttribute("smil",state);var active=(state=="active");if(!target._smilclass_active){var activeCN=target.className+(target.className.length?" ":"") ++timeAction.replace(/class:[\s]*/,"");target._smilclass_active=activeCN;target._smilclass_idle=target.className;} +target.className=active?target._smilclass_active:target._smilclass_idle;};switch(timeAction){case"display":return setTargetState_display;break;case"visibility":return setTargetState_visibility;break;case"style":return setTargetState_style;break;case"intrinsic":if(OLDIE) +return setTargetState_display;else +return setTargetState_intrinsic;default:if(/^class:/.test(timeAction)) +return setTargetState_class;else +return setTargetState_display;break;} +return null;};smilTimeItem.prototype.addEventListener=function(events,callback){for(var i=0;i0) +segment.previousSibling=timeNodes[i-1];if(i=0)&&(index "+this.timeNodes[i].time_out);} +this.mediaSyncNode=this.getMediaSync(result.syncMasterNode);var timer=null;this.mediaSyncAPI=this.mediaSyncNode;if(this.mediaSyncNode){timer=new smilExternalTimer(this.mediaSyncNode);if(this.mediaSyncNode.mediaAPI) +this.mediaSyncAPI=this.mediaSyncNode.mediaAPI;}else{timer=new smilInternalTimer(timerate);} +this.isPaused=timer.isPaused;this.getCurrentTime=timer.getTime;this.setCurrentTime=timer.setTime;this.Play=timer.Play;this.Pause=timer.Pause;this.Stop=timer.Stop;timer.onTimeUpdate=function(){self.onTimeUpdate();};this.addEventListener=smilTimeItem.prototype.addEventListener;this.removeEventListener=smilTimeItem.prototype.removeEventListener;this.dispatchEvent=smilTimeItem.prototype.dispatchEvent;this.onbegin=this.parseAttribute("onbegin");this.onend=this.parseAttribute("onend");var beginEvents=this.parseEvents(this.begin);var endEvents=this.parseEvents(this.end);function onbeginListener(){consoleLog("onbeginListener");self.time_in=self.parentNode.getCurrentTime();self.time_out=isNaN(self.end)?Infinity:self.end;self.parentNode.selectItem(self);} +function onendListener(){consoleLog("onendListener");self.time_in=isNaN(self.begin)?Infinity:self.begin;self.time_out=self.parentNode.getCurrentTime();self.parentNode.currentIndex=-1;if(self.parentNode){if(self.parentNode.timeContainer=="seq") +self.parentNode.selectIndex(self.parentNode.currentIndex+1);else +self.parentNode.currentIndex=-1;self.hide();}} +var state="";this.isActive=function(){return(state=="active");};this.show=function(){if(state=="active")return;state="active";self.Play();self.setTargetState(state);self.dispatchEvent("begin");self.addEventListener(endEvents,onendListener);self.removeEventListener(beginEvents,onbeginListener);this.currentIndex=-1;};this.hide=function(){if(state=="done")return;state="done";self.Stop();self.setTargetState(state);for(var i=0;i=Infinity) +time=time%this.dur;for(var i=0;i=this.timeNodes[i].time_out) +this.timeNodes[i].hide();else +this.timeNodes[i].show();}};function smilTimeContainer_par(domNode,parentNode,timerate){this.computeTimeNodes=smilTimeContainer_par.prototype.computeTimeNodes;this.onTimeUpdate=smilTimeContainer_par.prototype.onTimeUpdate;smilTimeContainer_generic.call(this,domNode,timerate);this.currentIndex=-1;this.selectIndex=function(index){};this.selectItem=function(item){if(!isNaN(item.time_in)) +this.setCurrentTime(item.time_in);item.show();};} +smilTimeContainer_excl.prototype.computeTimeNodes=function(){var segment=null;for(var i=0;ithis.clipEnd){this.kill();return;} +if(this.repeatCount>=Infinity) +time=time%this.dur;if(this.currentIndex>=0){var time_in=this.timeNodes[this.currentIndex].time_in;var time_out=this.timeNodes[this.currentIndex].time_out;var outOfBounds=(time=time_out);if(!outOfBounds) +return;} +var index=-1;var active=false;for(var i=0;i=segment.time_in)&&(time=segment.time_out) +segment.hide();else if(withinBounds){if(active){segment.reset();}else{active=true;segment.show();index=i;}}} +if(index>=0){this.currentIndex=index;} +else if((this.currentIndex0)&&(this.timeNodes[i-1].time_out=Infinity)) +this.dur=segment.time_out;if(this.end==undefined) +this.end=segment.time_out+this.begin;};smilTimeContainer_seq.prototype.onTimeUpdate=function(){var time=this.getCurrentTime();var withinBounds,outOfBounds,segment;if(this.repeatCount>=Infinity) +time=time%this.dur;if(this.currentIndex>=0){segment=this.timeNodes[this.currentIndex];outOfBounds=(time=segment.time_out);withinBounds=(time>=segment.time_in)&&(time=time_out);if((time_in>=Infinity)||!outOfBounds){this.currentIndex++;this.timeNodes[this.currentIndex].show();return;}} +var index=-1;var active=false;for(var i=0;i=segment.time_in)&&(time=segment.time_out) +segment.hide();else if(withinBounds){if(active){segment.reset();}else{active=true;segment.show();index=i;}}} +if(index>=0){this.currentIndex=index;} +else if((this.currentIndex=0;i--){containers[i].selectIndex(indexes[i])}if(targetTiming&&!isNaN(time)){targetTiming.setCurrentTime(time)}if(targetElement.scrollIntoViewIfNeeded!=undefined){targetElement.scrollIntoViewIfNeeded()}else{try{var tabIndex=targetElement.tabIndex;targetElement.tabIndex=0;targetElement.focus();targetElement.blur();if(tabIndex>=0){targetElement.tabIndex=tabIndex}else{targetElement.removeAttribute("tabIndex")}}catch(e){}}}EVENTS.onSMILReady(function(){checkHash();EVENTS.onHashChange(checkHash)});function parseMediaElement(node){if(window.MediaElement){var m=new MediaElement(node,{success:function(mediaAPI,element){if((/^(flash|silverlight)$/i).test(mediaAPI.pluginType)){var pluginElement=element.previousSibling;if(element.firstChild&&(/^(object|embed)$/i).test(element.firstChild.nodeName)){pluginElement=element.firstChild}else{if(pluginElement&&((/^me_flash/).test(pluginElement.id)||(/^me_silverlight/).test(pluginElement.id)||(pluginElement.className=="me-plugin"))){pluginElement.setAttribute("timeAction","none")}}element.pluginElement=pluginElement;element.mediaAPI=mediaAPI}EVENTS.trigger(document,"MediaElementLoaded")},error:function(){alert("MediaElement error")}})}else{node.setCurrentTime=function(time){node.currentTime=time};EVENTS.trigger(document,"MediaElementLoaded")}}function parseAllMediaElements(){var allAudioElements=document.getElementsByTagName("audio");var allVideoElements=document.getElementsByTagName("video");var meLength=allAudioElements.length+allVideoElements.length;if(meLength===0){EVENTS.trigger(window,"MediaContentLoaded");return}else{if(OLDIE&&!window.MediaElement){if(0){throw"MediaElement.js is required on IE<9"}}}var meParsed=0;function CountMediaElements(){meParsed++;if(meParsed>=meLength){EVENTS.unbind(document,"MediaElementLoaded",CountMediaElements);EVENTS.trigger(window,"MediaContentLoaded")}}EVENTS.bind(document,"MediaElementLoaded",CountMediaElements);for(var i=0;itsLength){EVENTS.unbind(document,"SMILTimesheetLoaded",CountTimesheets);EVENTS.trigger(window,"SMILContentLoaded")}}EVENTS.bind(document,"SMILTimesheetLoaded",CountTimesheets);var xhr;for(i=0;i=2){target=document.getElementById(tmp[0]);evt=tmp[1]}else{target=this.parentTarget;evt=eventStr}events.push({target:target,event:evt});if(callback){EVENTS.bind(target,evt,callback)}}return events};smilTimeItem.prototype.parseAttribute=function(attrName,dValue){var node=this.getNode();var nodeName=node.nodeName.replace(/^smil:/,"");var value="";if((attrName=="timeContainer")&&(/^(seq|par|excl)$/i).test(nodeName)){value=nodeName}else{value=node.getAttribute(attrName)||node.getAttribute("data-"+attrName.toLowerCase())||node.getAttribute("smil-"+attrName.toLowerCase())||node.getAttribute("smil:"+attrName)}if(!value||!value.length){return dValue}switch(attrName){case"timeContainer":case"timeAction":return value.toLowerCase();case"repeatCount":return(value=="indefinite")?Infinity:parseFloat(value);case"onbegin":case"onend":return function(){eval(value)};case"beginInc":case"begin":case"dur":case"end":case"repeatDur":return this.parseTime(value);default:return value}};smilTimeItem.prototype.newTargetHandler=function(timeAction,target){if(!target){return function(state){}}var setTargetState_intrinsic=function(state){target.setAttribute("smil",state)};var setTargetState_display=function(state){target.setAttribute("smil",state);target.style.display=(state=="active")?"block":"none"};var setTargetState_visibility=function(state){target.setAttribute("smil",state);target.style.visibility=(state=="active")?"visible":"hidden"};var setTargetState_style=function(state){target.setAttribute("smil",state);var active=(state=="active");if(!target._smilstyle){target._smilstyle=target.style.cssText}target.style.cssText=active?target._smilstyle:""};var setTargetState_class=function(state){target.setAttribute("smil",state);var active=(state=="active");if(!target._smilclass_active){var activeCN=target.className+(target.className.length?" ":"")+timeAction.replace(/class:[\s]*/,"");target._smilclass_active=activeCN;target._smilclass_idle=target.className}target.className=active?target._smilclass_active:target._smilclass_idle};switch(timeAction){case"display":return setTargetState_display;break;case"visibility":return setTargetState_visibility;break;case"style":return setTargetState_style;break;case"intrinsic":if(OLDIE){return setTargetState_display}else{return setTargetState_intrinsic}default:if(/^class:/.test(timeAction)){return setTargetState_class}else{return setTargetState_display}break}return null};smilTimeItem.prototype.addEventListener=function(events,callback){for(var i=0;i0){segment.previousSibling=timeNodes[i-1]}if(i=0)&&(index=Infinity){time=time%this.dur}for(var i=0;i=this.timeNodes[i].time_out){this.timeNodes[i].hide()}else{this.timeNodes[i].show()}}}};function smilTimeContainer_par(domNode,parentNode,timerate){this.computeTimeNodes=smilTimeContainer_par.prototype.computeTimeNodes;this.onTimeUpdate=smilTimeContainer_par.prototype.onTimeUpdate;smilTimeContainer_generic.call(this,domNode,timerate);this.currentIndex=-1;this.selectIndex=function(index){};this.selectItem=function(item){if(!isNaN(item.time_in)){this.setCurrentTime(item.time_in)}item.show()}}smilTimeContainer_excl.prototype.computeTimeNodes=function(){var segment=null;for(i=0;i=Infinity){time=time%this.dur}if(this.currentIndex>=0){var time_in=this.timeNodes[this.currentIndex].time_in;var time_out=this.timeNodes[this.currentIndex].time_out;var outOfBounds=(time=time_out);if(!outOfBounds){return}}var index=-1;var active=false;for(var i=0;i=segment.time_in)&&(time=segment.time_out){segment.hide()}else{if(withinBounds){if(active){segment.reset()}else{active=true;segment.show();index=i}}}}}if(index>=0){this.currentIndex=index}else{if((this.currentIndex0)&&(this.timeNodes[i-1].time_out=Infinity)){this.dur=segment.time_out}if(this.end==undefined){this.end=segment.time_out+this.begin}};smilTimeContainer_seq.prototype.onTimeUpdate=function(){var time=this.getCurrentTime();var withinBounds,outOfBounds,segment;if(this.repeatCount>=Infinity){time=time%this.dur}if(this.currentIndex>=0){segment=this.timeNodes[this.currentIndex];outOfBounds=(time=segment.time_out);withinBounds=(time>=segment.time_in)&&(time=time_out);if((time_in>=Infinity)||!outOfBounds){this.currentIndex++;this.timeNodes[this.currentIndex].show();return}}var index=-1;var active=false;for(var i=0;i=segment.time_in)&&(time=segment.time_out){segment.hide()}else{if(withinBounds){if(active){segment.reset()}else{active=true;segment.show();index=i}}}}}if(index>=0){this.currentIndex=index}else{if((this.currentIndex=0;i--){consoleLog(containers[i].nodeName+' - index='+indexes[i]);containers[i].selectIndex(indexes[i]);} +if(targetTiming&&!isNaN(time)){targetTiming.setCurrentTime(time);consoleLog(targetElement.nodeName+' time: '+time);} +if(targetElement['scrollIntoViewIfNeeded']!=undefined){targetElement.scrollIntoViewIfNeeded();} +else try{var tabIndex=targetElement.tabIndex;targetElement.tabIndex=0;targetElement.focus();targetElement.blur();if(tabIndex>=0) +targetElement.tabIndex=tabIndex;else +targetElement.removeAttribute('tabIndex');}catch(e){}} +EVENTS.onSMILReady(function(){consoleLog("SMIL data parsed, starting 'hashchange' event listener.");checkHash();EVENTS.onHashChange(checkHash);});function parseMediaElement(node){if(window.MediaElement){var m=new MediaElement(node,{success:function(mediaAPI,element){consoleLog('MediaElement with '+mediaAPI.pluginType+' player');if((/^(flash|silverlight)$/i).test(mediaAPI.pluginType)){var pluginElement=element.previousSibling;if(element.firstChild&&(/^(object|embed)$/i).test(element.firstChild.nodeName)){pluginElement=element.firstChild;consoleLog(' (childNode)');} +else if(pluginElement&&((/^me_flash/).test(pluginElement.id)||(/^me_silverlight/).test(pluginElement.id)||(pluginElement.className=='me-plugin'))){pluginElement.setAttribute('timeAction','none');consoleLog(' (previousSibling)');} +element.pluginElement=pluginElement;element.mediaAPI=mediaAPI;} +EVENTS.trigger(document,'MediaElementLoaded');},error:function(){alert('MediaElement error');}});} +else{node.setCurrentTime=function(time){node.currentTime=time;};EVENTS.trigger(document,'MediaElementLoaded');}} +function parseAllMediaElements(){var allAudioElements=document.getElementsByTagName('audio');var allVideoElements=document.getElementsByTagName('video');var meLength=allAudioElements.length+allVideoElements.length;if(meLength===0){EVENTS.trigger(window,'MediaContentLoaded');return;} +else if(OLDIE&&!window.MediaElement){if(0)throw'MediaElement.js is required on IE<9';} +var meParsed=0;function CountMediaElements(){meParsed++;if(meParsed>=meLength){EVENTS.unbind(document,'MediaElementLoaded',CountMediaElements);EVENTS.trigger(window,'MediaContentLoaded');}} +EVENTS.bind(document,'MediaElementLoaded',CountMediaElements);for(var i=0;itsLength){EVENTS.unbind(document,'SMILTimesheetLoaded',CountTimesheets);EVENTS.trigger(window,'SMILContentLoaded');}} +EVENTS.bind(document,'SMILTimesheetLoaded',CountTimesheets);var xhr;for(i=0;i=2){target=document.getElementById(tmp[0]);evt=tmp[1];}else{target=this.parentTarget;evt=eventStr;} +events.push({target:target,event:evt});if(callback) +EVENTS.bind(target,evt,callback);} +return events;};smilTimeItem.prototype.parseAttribute=function(attrName,dValue){var node=this.getNode();var nodeName=node.nodeName.replace(/^smil:/,'');var value='';if((attrName=='timeContainer')&&(/^(seq|par|excl)$/i).test(nodeName)) +value=nodeName;else +value=node.getAttribute(attrName)||node.getAttribute('data-'+attrName.toLowerCase())||node.getAttribute('smil-'+attrName.toLowerCase())||node.getAttribute('smil:'+attrName);if(!value||!value.length) +return dValue;switch(attrName){case'timeContainer':case'timeAction':return value.toLowerCase();case'repeatCount':return(value=='indefinite')?Infinity:parseFloat(value);case'onbegin':case'onend':return function(){eval(value);};case'beginInc':case'begin':case'dur':case'end':case'repeatDur':return this.parseTime(value);default:return value;}};smilTimeItem.prototype.newTargetHandler=function(timeAction,target){if(!target){return function(state){};} +var setTargetState_intrinsic=function(state){target.setAttribute('smil',state);};var setTargetState_display=function(state){target.setAttribute('smil',state);target.style.display=(state=='active')?'block':'none';};var setTargetState_visibility=function(state){target.setAttribute('smil',state);target.style.visibility=(state=='active')?'visible':'hidden';};var setTargetState_style=function(state){target.setAttribute('smil',state);var active=(state=='active');if(!target._smilstyle) +target._smilstyle=target.style.cssText;target.style.cssText=active?target._smilstyle:'';};var setTargetState_class=function(state){target.setAttribute('smil',state);var active=(state=='active');if(!target._smilclass_active){var activeCN=target.className+(target.className.length?' ':'')+ +timeAction.replace(/class:[\s]*/,'');target._smilclass_active=activeCN;target._smilclass_idle=target.className;} +target.className=active?target._smilclass_active:target._smilclass_idle;};switch(timeAction){case'display':return setTargetState_display;break;case'visibility':return setTargetState_visibility;break;case'style':return setTargetState_style;break;case'intrinsic':if(OLDIE){return setTargetState_display;}else{return setTargetState_intrinsic;} +default:if(/^class:/.test(timeAction)){return setTargetState_class;} +else{return setTargetState_display;} +break;} +return null;};smilTimeItem.prototype.addEventListener=function(events,callback){for(var i=0;i0){segment.previousSibling=timeNodes[i-1];} +if(i=0)&&(index '+this.timeNodes[i].time_out);}} +this.mediaSyncNode=this.getMediaSync(result.syncMasterNode);var timer=null;this.mediaSyncAPI=this.mediaSyncNode;if(this.mediaSyncNode){timer=new smilExternalTimer(this.mediaSyncNode);if(this.mediaSyncNode.mediaAPI){this.mediaSyncAPI=this.mediaSyncNode.mediaAPI;}}else{timer=new smilInternalTimer(timerate);} +this.isPaused=timer.isPaused;this.getCurrentTime=timer.getTime;this.setCurrentTime=timer.setTime;this.Play=timer.Play;this.Pause=timer.Pause;this.Stop=timer.Stop;timer.onTimeUpdate=function(){self.onTimeUpdate();};this.addEventListener=smilTimeItem.prototype.addEventListener;this.removeEventListener=smilTimeItem.prototype.removeEventListener;this.dispatchEvent=smilTimeItem.prototype.dispatchEvent;this.onbegin=this.parseAttribute('onbegin');this.onend=this.parseAttribute('onend');var beginEvents=this.parseEvents(this.begin);var endEvents=this.parseEvents(this.end);function onbeginListener(){consoleLog('onbeginListener');self.time_in=self.parentNode.getCurrentTime();self.time_out=isNaN(self.end)?Infinity:self.end;self.parentNode.selectItem(self);} +function onendListener(){consoleLog('onendListener');self.time_in=isNaN(self.begin)?Infinity:self.begin;self.time_out=self.parentNode.getCurrentTime();self.parentNode.currentIndex=-1;if(self.parentNode){if(self.parentNode.timeContainer=='seq'){self.parentNode.selectIndex(self.parentNode.currentIndex+1);}else{self.parentNode.currentIndex=-1;} +self.hide();}} +var state='';this.isActive=function(){return(state=='active');};this.show=function(){if(state=='active')return;state='active';self.Play();self.setTargetState(state);self.dispatchEvent('begin');self.addEventListener(endEvents,onendListener);self.removeEventListener(beginEvents,onbeginListener);this.currentIndex=-1;};this.hide=function(){if(state=='done')return;state='done';self.Stop();self.setTargetState(state);for(var i=0;i=Infinity){time=time%this.dur;} +for(var i=0;i=this.timeNodes[i].time_out){this.timeNodes[i].hide();}else{this.timeNodes[i].show();}}};function smilTimeContainer_par(domNode,parentNode,timerate){this.computeTimeNodes=smilTimeContainer_par.prototype.computeTimeNodes;this.onTimeUpdate=smilTimeContainer_par.prototype.onTimeUpdate;smilTimeContainer_generic.call(this,domNode,timerate);this.currentIndex=-1;this.selectIndex=function(index){};this.selectItem=function(item){if(!isNaN(item.time_in)){this.setCurrentTime(item.time_in);} +item.show();};} +smilTimeContainer_excl.prototype.computeTimeNodes=function(){var segment=null;for(i=0;i=Infinity) +time=time%this.dur;if(this.currentIndex>=0){var time_in=this.timeNodes[this.currentIndex].time_in;var time_out=this.timeNodes[this.currentIndex].time_out;var outOfBounds=(time=time_out);if(!outOfBounds) +return;} +var index=-1;var active=false;for(var i=0;i=segment.time_in)&&(time=segment.time_out){segment.hide();}else if(withinBounds){if(active){segment.reset();}else{active=true;segment.show();index=i;}}} +if(index>=0){this.currentIndex=index;} +else if((this.currentIndex0)&&(this.timeNodes[i-1].time_out=Infinity)){this.dur=segment.time_out;} +if(this.end==undefined){this.end=segment.time_out+this.begin;}};smilTimeContainer_seq.prototype.onTimeUpdate=function(){var time=this.getCurrentTime();var withinBounds,outOfBounds,segment;if(this.repeatCount>=Infinity){time=time%this.dur;} +if(this.currentIndex>=0){segment=this.timeNodes[this.currentIndex];outOfBounds=(time=segment.time_out);withinBounds=(time>=segment.time_in)&&(time=time_out);if((time_in>=Infinity)||!outOfBounds){this.currentIndex++;this.timeNodes[this.currentIndex].show();return;}} +var index=-1;var active=false;for(var i=0;i=segment.time_in)&&(time=segment.time_out){segment.hide();}else if(withinBounds){if(active){segment.reset();}else{active=true;segment.show();index=i;}}} +if(index>=0){this.currentIndex=index;} +else if((this.currentIndex