-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathiFSM.compressed.js
9 lines (9 loc) · 22.4 KB
/
iFSM.compressed.js
1
2
3
4
5
6
7
8
9
/*
Intersel 2013-2018
@fileoverview : iFSM : a finite state machine with jQuery
@see {@link https://github.com/intersel/iFSM}
@author : Emmanuel Podvin - [email protected]
@version : 1.7.5
-----------------------------------------------------------------------------------------
*/
!function($){var nb_FSM=0,fsm_manager=window.fsm_manager=function(t,e,n){var a,i;nb_FSM+=1,null==n&&(n=null),this.opts=jQuery.extend({},{debug:!1,LogLevel:1,AlertError:!1,maxPushEvent:100,startEvent:"start",prefixFsmName:"FSM_",logFSM:""},n||{}),this.FSMName=this.opts.prefixFsmName+nb_FSM,this._stateDefinition=jQuery.extend(!0,{},e),this._originalstateDefinition=e,this.currentState="",this.lastState=this.currentState,this.currentEvent="",this.pushStateList=new Array,this.processEventStatus="idle",this.pushEventList=new Array,this.myUIObject=t,this.listEvents={},this.currentDataEvent={},this.returnGeneralEventStatus=!0,null==this.opts.rootMachine&&(this.opts.rootMachine=this),this.rootMachine=this.opts.rootMachine,null==this.opts.nextParent?this.parentMachine=null:this.parentMachine=this.opts.nextParent,this.opts.nextParent=this,this.childrenMachine=new Array,this.parentMachine&&this.parentMachine.childrenMachine.push(this);var r="",s="",o=$(document),c=!1,u=!1,h=new Array,v=!1;for(a in this._stateDefinition)for(i in"string"==typeof this._stateDefinition[a]&&(this._stateDefinition[a]=this._stateDefinition[this._stateDefinition[a]]),this._stateDefinition[a])"string"==typeof this._stateDefinition[a][i]&&(this._stateDefinition[a][i]=this._stateDefinition[a][this._stateDefinition[a][i]]),this.rootMachine.listEvents[i]||"delegate_machines"==i||i==this.opts.startEvent?i==this.opts.startEvent&&(v=!0):(this.listEvents[i]=i,this!=this.rootMachine&&(this.rootMachine.listEvents[i]=i));var l="";for(i in this.listEvents)"attrchange"==(l=i.split("_"))[0]&&(c=!0,h.push(i),"style"==l[1]&&l.length>2&&(u=!0)),r=r+s+i,s=" ";if(!t.selector&&t.attr("id")?t.selector="#"+t.attr("id"):t.selector="",c&&t.selector){var E,g,_,p,f,S={},m={};$(t.selector).attrchange({trackValues:!0,callback:function(t){if(jQuery.inArray("attrchange",h)>=0&&$(this).trigger("attrchange",t),jQuery.inArray("attrchange_"+t.attributeName,h)>=0&&$(this).trigger("attrchange_"+t.attributeName,{newValue:t.newValue,oldValue:t.oldValue}),"style"==t.attributeName&&u){for(E=t.newValue?t.newValue.split(";"):[],g=t.oldValue?t.oldValue.split(";"):[],p=0;p<E.length;p++)2==(_=E[p].split(":")).length&&(S[_[0]]=_[1].replace(/^\s+/g,"").replace(/\s+$/g,""));for(p=0;p<g.length;p++)2==(_=g[p].split(":")).length&&(m[_[0]]=_[1].replace(/^\s+/g,"").replace(/\s+$/g,""));for(f in S)(null==m[f]||m[f]&&m[f]!=S[f])&&$(this).trigger("attrchange_style_"+fsm_manager_getcss3prop(f),{newValue:S[f],oldValue:m[f]})}}})}$.isWindow(t[0])&&(o=$(window));var M=this.rootMachine;if(""!=r&&o.on(r,t.selector,function(t,e){return M.returnGeneralEventStatus=!0,M.processEvent(t.type,arguments),M.returnGeneralEventStatus}),v){var d=this;o.on(this.opts.startEvent,t.selector,function(t,e){d.processEvent(t.type,arguments)})}this._log("new fsm_manager:"+this.FSMName+"-"+t.selector,2)};fsm_manager.prototype.InitManager=function(t){if(this._log("InitManager"),this.currentState=null==t?"DefaultState":t,null==this._stateDefinition.DefaultState&&(this._stateDefinition.DefaultState={}),this.parentMachine){var e=new Array;e[0]=fsm_manager_create_event(this.myUIObject,this.opts.startEvent,null),this.processEvent(this.opts.startEvent,e,!0)}else this.trigger(this.opts.startEvent)},fsm_manager.prototype.processEvent=function(anEvent,data,forceProcess){var thisFSM=this,currentState=this.currentState,currentEvent=this.currentUIEvent=data[0];this.receivedEvent=anEvent,this.currentDataEvent=data,this.currentEvent=currentEvent;var currentStateEvent=this.currentState,doForceProcess=null!=forceProcess,anEv=new Array;if(anEv[0]=fsm_manager_create_event(this.myUIObject,"",null),anEv[1]=data[1],anEv[2]=data[2],this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> START Processing Event",2,1),data.length>1&&null!=data[data.length-1]&&data[data.length-1].targetFSM&&data[data.length-1].targetFSM!=this&&(data[data.length-1].localMachine||data[data.length-1].targetFSM.rootMachine!=this.rootMachine))return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> not for the current machine ---\x3e exit",2),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if(data.length>1&&null!=data[data.length-1]&&data[data.length-1].localMachine&&this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> process event locally",2),this.subMachineName&&(!this.parentMachine._stateDefinition[this.parentMachine.currentState].delegate_machines||this.parentMachine._stateDefinition[this.parentMachine.currentState].delegate_machines&&!this.parentMachine._stateDefinition[this.parentMachine.currentState].delegate_machines[this.subMachineName]))return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> submachine can't run if the parent state is not active for the submachine ---\x3e exit",2),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if(null==this._stateDefinition[currentState])return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> currentState does not exist!",2),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if("enterState"!=anEvent&&"exitState"!=anEvent||(doForceProcess=!0),!(this.myUIObject.is(currentEvent.currentTarget)||this.myUIObject.is(currentEvent.target)||this.myUIObject[0]==document||$.isWindow(currentEvent.currentTarget)||$.isWindow(currentEvent.target)))return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> object not a good target ---\x3e "+$(currentEvent.currentTarget).attr("id")+"---\x3e exit",2),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);this.myUIObject[0]==document?this.actualTarget=$(document):this.actualTarget=$(currentEvent.currentTarget);var currentEventConfiguration=null,aSubMachineDefinition;if(currentEventConfiguration=this._stateDefinition[currentState][anEvent],0==doForceProcess&&"idle"!=this.processEventStatus&&(null==currentEventConfiguration||currentEventConfiguration&&null==currentEventConfiguration.how_process_event||currentEventConfiguration&¤tEventConfiguration.how_process_event&&null==currentEventConfiguration.how_process_event.immediate&&null==currentEventConfiguration.how_process_event.delay))return this.pushEvent(anEvent,data),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Event pushed (lastevent)---\x3e "+this.lastevent+" --\x3e exit",2),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if(this.lastevent=currentState+"-"+anEvent,this._stateDefinition[currentState].delegate_machines)for(aSubMachine in this._stateDefinition[currentState].delegate_machines)if(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> delegate to submachine---\x3e "+aSubMachine,2),aSubMachineDefinition=this._stateDefinition[currentState].delegate_machines[aSubMachine],null==aSubMachineDefinition.myFSM&&(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> process submachine ---\x3e create FSM for the submachine "+aSubMachine,2),this._stateDefinition[currentState].delegate_machines[aSubMachine].myFSM=new fsm_manager(this.myUIObject,aSubMachineDefinition.submachine,this.opts),this._stateDefinition[currentState].delegate_machines[aSubMachine].myFSM.opts.FSMParent=this,this._stateDefinition[currentState].delegate_machines[aSubMachine].myFSM.subMachineName=aSubMachine),"enterState"==anEvent)""!=aSubMachineDefinition.myFSM.currentState&&null!=aSubMachineDefinition.no_reinitialisation&&0!=aSubMachineDefinition.no_reinitialisation||aSubMachineDefinition.myFSM.InitManager();else if("exitState"==anEvent)anEv[0].type="exitMachine",aSubMachineDefinition.myFSM.processEvent("exitMachine",anEv,!0),aSubMachineDefinition.myFSM.cancelDelayedProcess();else{if(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> process submachine (event)---\x3e "+aSubMachine+"("+anEvent+") Start",2),aSubMachineDefinition.myFSM.processEvent(anEvent,data),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> process submachine (event)---\x3e "+aSubMachine+"("+anEvent+") Processed",2),currentState!=this.currentState)return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> process submachine changed the current environment (event)",2),this.cleanExitProcess(),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if(aSubMachineDefinition.myFSM._stateDefinition[aSubMachineDefinition.myFSM.currentState][anEvent]&&aSubMachineDefinition.myFSM._stateDefinition[aSubMachineDefinition.myFSM.currentState][anEvent].prevent_bubble||aSubMachineDefinition.myFSM._stateDefinition.DefaultState[anEvent]&&aSubMachineDefinition.myFSM._stateDefinition.DefaultState[anEvent].prevent_bubble||anEvent==this.opts.startEvent)return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> submachine processed and exit due to prevent_bubble directive",2),this.cleanExitProcess(),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> submachine exit",2),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1)}if("DefaultState"==currentState||null==currentEventConfiguration){if(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> take Event "+anEvent+" configuration from DefaultState (not present in current state)",2),currentEventConfiguration=this._stateDefinition.DefaultState[anEvent],null==currentEventConfiguration&&["start","enterState","exitState","exitMachine"].indexOf(anEvent)<0&&(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> take Event "+anEvent+" configuration from catchEvent",2),currentEventConfiguration=this._stateDefinition.DefaultState.catchEvent,this._stateDefinition.DefaultState[anEvent]||(this._stateDefinition.DefaultState[anEvent]=jQuery.extend(!0,{},currentEventConfiguration))),null==currentEventConfiguration)return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Event "+anEvent+" does not exist and no catchEvent--\x3e will exit",2),this.cleanExitProcess(),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);currentStateEvent="DefaultState"}if(currentEventConfiguration.pushpop_state&&"PopState"==currentEventConfiguration.pushpop_state&&this.pushStateList.length>0&&(currentEventConfiguration.next_state=this.pushStateList[this.pushStateList.length-1]),currentEventConfiguration.pushpop_state_if_error&&"PopState"==currentEventConfiguration.pushpop_state_if_error&&this.pushStateList.length>0&&(currentEventConfiguration.next_state_if_error=this.pushStateList[this.pushStateList.length-1]),!this.myUIObject.is(currentEvent.target)&&this.myUIObject[0]!=document&&!$.isWindow(currentEvent.currentTarget)&&!$.isWindow(currentEvent.target)&¤tEventConfiguration.process_on_UItarget&&1==currentEventConfiguration.process_on_UItarget)return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Event "+anEvent+" does not address the correct UI target (see process_on_UItarget) will exit",2),this.cleanExitProcess(),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if(currentEventConfiguration.UI_event_bubble&&0!=currentEventConfiguration.UI_event_bubble||(currentEvent.stopPropagation(),this.returnGeneralEventStatus=!1,this.rootMachine.returnGeneralEventStatus=!1),0==doForceProcess&¤tEventConfiguration&¤tEventConfiguration.how_process_event&¤tEventConfiguration.how_process_event.delay)return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Event "+anEvent+" delayed will exit",2),this.delayProcess(anEvent,currentEventConfiguration.how_process_event.delay,data),this.cleanExitProcess(),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);if(null==this._stateDefinition[currentStateEvent][anEvent].EventIteration&&(this._stateDefinition[currentStateEvent][anEvent].EventIteration=0),this._stateDefinition[currentStateEvent][anEvent].EventIteration++,this.EventIteration=this._stateDefinition[currentStateEvent][anEvent].EventIteration,currentEventConfiguration.process_event_if&&0==eval(currentEventConfiguration.process_event_if))return this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Event "+anEvent+" event not allowed to process (process_event_if rule is not OK) will exit",2),currentEventConfiguration.propagate_event_on_refused&&(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Event "+currentEventConfiguration.propagate_event_on_refused+" triggered on exit because of propagate_event_on_refused",2),this.trigger(currentEventConfiguration.propagate_event_on_refused,null,currentEventConfiguration.propagate_event_on_localmachine)),this.cleanExitProcess(),void this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1);this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> currently processing",0);var lastprocessEventStatus=this.processEventStatus;this.processEventStatus="processing";var funcReturn=!0,localdata;if(currentEventConfiguration.init_function&&(localdata=[].slice.call(data),localdata.unshift(currentEventConfiguration.properties_init_function),funcReturn=currentEventConfiguration.init_function.apply(this,localdata),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> init_function done",2)),0!=funcReturn&¤tEventConfiguration.pushpop_state)switch(currentEventConfiguration.pushpop_state){case"PushState":this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Push state to state "+this.currentState,2),this.pushStateList.push(this.currentState);break;case"PopState":this.pushStateList.length>0&&(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Pop state to state "+currentEventConfiguration.next_state,2),this.pushStateList.pop())}if(0!=funcReturn&¤tEventConfiguration.next_state&¤tState!=currentEventConfiguration.next_state&&(null==currentEventConfiguration.next_state_when&&null==currentEventConfiguration.next_state_on_target||currentEventConfiguration.next_state_when&&1==eval(currentEventConfiguration.next_state_when)||currentEventConfiguration.next_state_on_target&&1==this.subMachinesRespectTargets(anEvent)))$.each(this._stateDefinition[this.currentState],function(t,e){"delegate_machines"!=t&&(thisFSM._stateDefinition[thisFSM.currentState][t].EventIteration=0)}),this.cancelDelayedProcess(),anEv[0].type="exitState",anEvent!=this.opts.startEvent&&this.processEvent("exitState",anEv,!0),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Go to (see next_state) "+currentEventConfiguration.next_state,2),this.lastState=this.currentState,this.currentState=currentEventConfiguration.next_state,anEv[0].type="enterState",this.processEvent("enterState",anEv,!0),null!=currentEventConfiguration.propagate_event&&(currentEventConfiguration.propagate_event instanceof Array||(currentEventConfiguration.propagate_event=[currentEventConfiguration.propagate_event]),$.each(currentEventConfiguration.propagate_event,function(t,e){thisFSM._log("processEvent: "+thisFSM.FSMName+":"+currentState+":"+anEvent+"-> trigger event (see propagate_event) ---\x3e "+e,2),!0===e?thisFSM.trigger(anEvent,data[1],currentEventConfiguration.propagate_event_on_localmachine):thisFSM.trigger(e,data[1],currentEventConfiguration.propagate_event_on_localmachine)}));else if(0!=funcReturn&&null!=currentEventConfiguration.propagate_event)currentEventConfiguration.propagate_event instanceof Array||(currentEventConfiguration.propagate_event=[currentEventConfiguration.propagate_event]),$.each(currentEventConfiguration.propagate_event,function(t,e){thisFSM._log("processEvent: "+thisFSM.FSMName+":"+currentState+":"+anEvent+"-> trigger event (see propagate_event) ---\x3e "+e,2),!0===e?thisFSM.trigger(anEvent,data[1],currentEventConfiguration.propagate_event_on_localmachine):thisFSM.trigger(e,data[1],currentEventConfiguration.propagate_event_on_localmachine)});else if(0==funcReturn&¤tEventConfiguration.next_state_if_error){if(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> error in init_function",2),currentEventConfiguration.pushpop_state_if_error)switch(currentEventConfiguration.pushpop_state_if_error){case"PushState":this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Push state to state "+this.currentState,2),this.pushStateList.push(this.currentState);break;case"PopState":this.pushStateList.length>0&&(this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Pop state to state "+currentEventConfiguration.next_state_if_error,2),this.pushStateList.pop())}this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> Go to (see next_state_if_error) "+currentEventConfiguration.next_state_if_error,2),this.lastState=this.currentState,this.currentState=currentEventConfiguration.next_state_if_error,anEv[0].type="enterState",this.processEvent("enterState",anEv,!0)}else this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> nothing to do",2);currentEventConfiguration.out_function&&(localdata=[].slice.call(data),localdata.unshift(currentEventConfiguration.properties_out_function),funcReturn=currentEventConfiguration.out_function.apply(this,localdata),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> out_function done",2)),this.processEventStatus=lastprocessEventStatus,this.cleanExitProcess(),this._log("processEvent: "+this.FSMName+":"+currentState+":"+anEvent+"-> EXIT PROCESS",2,-1)},fsm_manager.prototype.cleanExitProcess=function(t,e){this.pushEventList.length&&("idle"==this.processEventStatus||this.pushEventList.length>this.opts.maxPushEvent)&&this.popEvent()},fsm_manager.prototype.pushEvent=function(t,e){if(this._log("pushEvent: ---\x3e "+t),this.pushEventList.length>this.opts.maxPushEvent)this._log("pushEvent: too much events... ---\x3e "+this.pushEventList.length,2);else{if(null==e||0==e.length||null==e[0].type){var n=new Array;n[0]=fsm_manager_create_event(this.myUIObject,t),n[1]=e,e=n}var a={anEvent:t,data:e};this.pushEventList.push(a),this._log("pushEvent: push nb event ---\x3e "+this.pushEventList.length)}},fsm_manager.prototype.popEvent=function(){return this._log("popEvent"),this.pushEventList.length>0?(anEventToProcess=this.pushEventList.shift(),this._log("popEvent:"+anEventToProcess.anEvent,2),null!=anEventToProcess&&null!=anEventToProcess.anEvent&&(this.processEvent(anEventToProcess.anEvent,anEventToProcess.data),!0)):(this._log("popEvent void list"),!1)};var aPreviousId=0;fsm_manager.prototype.delayProcess=function(t,e,n){this._log("delayProcess: ---\x3e "+t),aPreviousId++;var a=this.currentState;this._stateDefinition[this.currentState][t]||(a="DefaultState"),this._stateDefinition[a][t].how_process_event.DelayedProcessNames||(this._stateDefinition[a][t].how_process_event.DelayedProcessNames=[]),aDelayedProcessName=this.myUIObject.attr("id")+a+t+aPreviousId,this._stateDefinition[a][t].how_process_event.DelayedProcessNames[aDelayedProcessName]=aDelayedProcessName,jQuery.doTimeout(aDelayedProcessName,e,fsm_manager_launchProcess,this,t,n)},fsm_manager.prototype.cancelDelayedProcess=function(){this._log("cancelDelayedProcess");var t,e=null;for(aEvent in this._stateDefinition[this.currentState])if(e=this.currentState,this._stateDefinition[e][aEvent]||(e="DefaultState"),(t=this._stateDefinition[e][aEvent]).how_process_event&&(null==t.how_process_event.preventcancel||1!=t.how_process_event.preventcancel)&&t.how_process_event.DelayedProcessNames){for(aDelayedProcessName in t.how_process_event.DelayedProcessNames)jQuery.doTimeout(aDelayedProcessName);t.how_process_event.DelayedProcessNames=[]}},fsm_manager.prototype.trigger=function(t,e,n){n||(n=!1);var a=new Array;a[0]=fsm_manager_create_event(this.myUIObject,t,null),a[1]=e,a[2]={targetFSM:this,localMachine:n},n?this.processEvent(t,a):this.rootMachine.processEvent(t,a)},fsm_manager.prototype.subMachinesRespectTargets=function(t){this._log("subMachinesRespectTargets:");var e,n=this._stateDefinition[this.currentState],a=n[t].next_state_on_target,i=a.condition,r="||"!=i,s=a.submachines;for(aSubMachine in s)if(e=a.submachines[aSubMachine].target_list.indexOf(n.delegate_machines[aSubMachine].myFSM.currentState)>-1,null!=a.submachines[aSubMachine].condition&&"not"==a.submachines[aSubMachine].condition&&(e=!e),"||"==i){if(1==(r=r||e))return r}else{if("&&"!=i)return this._log("operator unknown"+i),r;if(0==(r=r&&e))return r}return r};var log_offsetstring="";function fsm_manager_getcss3prop(t){var e=["","-moz-","-webkit-","-o-","-ms-","-khtml-"],n=document.documentElement;for(var a=0;a<e.length;a++){var i=(e[a]+t).replace(/\-([a-z])/gi,function(t,e){return e.toUpperCase()});if("Ms"==i.substr(0,2)&&(i="m"+i.substr(1)),i in n.style)return i}}function fsm_manager_create_event(t,e,n){var a={};return a.data=n,a.target=t,a.currentTarget=t,a.type=e,a.stopPropagation=function(){return!0},a}fsm_manager.prototype._log=function(t){this.opts.debug&&(arguments.length>1&&arguments[1]>this.opts.LogLevel||arguments.length<=1&&3>this.opts.LogLevel||this.opts.logFSM&&this.opts.logFSM.indexOf(this.FSMName)<0||(arguments.length>2&&-1==arguments[2]&&(log_offsetstring=log_offsetstring.replace(" ","")),window.console&&console.log&&(console.log("[fsm] "+log_offsetstring+t),1==arguments[1]&&this.opts.AlertError&&alert(t),arguments.length>2&&1==arguments[2]&&(log_offsetstring+=" "))))},fsm_manager_triggerMe=function(t,e,n){this._log("[fsm_manager_triggerMe]"+$(t.objectToTrigger).attr("id")+"-"+t.eventNameToTrigger),$(t.objectToTrigger).trigger(t.eventNameToTrigger)},fsm_manager_launchProcess=function(t,e,n){t._log("launchProcess: ---\x3e "+e),t.processEvent(e,n,!0)};var iFSMList={};$.fn.iFSM=function(t,e){return this.each(function(){var n=new fsm_manager($(this),t,e);null!=$(this).attr("id")&&(null==iFSMList[$(this).attr("id")]&&(iFSMList[$(this).attr("id")]=[]),iFSMList[$(this).attr("id")].push(n)),e&&null!=e.initState?n.InitManager(e.initState):n.InitManager()})},$.fn.getFSM=function(t){if(1!=this.length||null==this.attr("id"))return[];if(null==t)return iFSMList[$(this).attr("id")];for(var e=null,n=0,a=null;n<iFSMList[$(this).attr("id")].length;n++)if((a=iFSMList[$(this).attr("id")][n])._originalstateDefinition==t){e=a;break}return e}}(jQuery);