forked from jakesgordon/javascript-state-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate-machine-history.min.js
More file actions
1 lines (1 loc) · 1.85 KB
/
Copy pathstate-machine-history.min.js
File metadata and controls
1 lines (1 loc) · 1.85 KB
1
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("StateMachineHistory",[],e):"object"==typeof exports?exports.StateMachineHistory=e():t.StateMachineHistory=e()}(this,function(){return function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,e),o.l=!0,o.exports}var n={};return e.m=t,e.c=n,e.i=function(t){return t},e.d=function(t,n,r){e.o(t,n)||Object.defineProperty(t,n,{configurable:!1,enumerable:!0,get:r})},e.n=function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,"a",n),n},e.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},e.p="",e(e.s=1)}([function(t,e,n){"use strict";t.exports=function(t){var e,n=t.split(/[_-]/),r=n[0];for(e=1;e<n.length;e++)r=r+n[e].charAt(0).toUpperCase()+n[e].substring(1);return r}},function(t,e,n){"use strict";var r=n(0);t.exports=function(t){t=t||{};var e=r(t.name||t.past||"history"),n=r(t.future||"future"),o=r("clear-"+e),i=r(e+"-back"),s=r(e+"-forward"),u=r("can-"+i),c=r("can-"+s),f=t.max,a={configure:function(t){t.addTransitionLifecycleNames(i),t.addTransitionLifecycleNames(s)},init:function(t){t[e]=[],t[n]=[]},lifecycle:function(t,r){"onEnterState"===r.event&&(t[e].push(r.to),f&&t[e].length>f&&t[e].shift(),r.transition!==i&&r.transition!==s&&(t[n].length=0))},methods:{},properties:{}};return a.methods[o]=function(){this[e].length=0,this[n].length=0},a.properties[u]={get:function(){return this[e].length>1}},a.properties[c]={get:function(){return this[n].length>0}},a.methods[i]=function(){if(!this[u])throw Error("no history");var t=this[e].pop(),r=this[e].pop();this[n].push(t),this._fsm.transit(i,t,r,[])},a.methods[s]=function(){if(!this[c])throw Error("no history");var t=this.state,e=this[n].pop();this._fsm.transit(s,t,e,[])},a}}])});