123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- (function webpackUniversalModuleDefinition(root, factory) {
- if(typeof exports === 'object' && typeof module === 'object')
- module.exports = factory();
- else if(typeof define === 'function' && define.amd)
- define("StateMachineHistory", [], factory);
- else if(typeof exports === 'object')
- exports["StateMachineHistory"] = factory();
- else
- root["StateMachineHistory"] = factory();
- })(this, function() {
- return (function(modules) {
-
- var installedModules = {};
-
- function __webpack_require__(moduleId) {
-
- if(installedModules[moduleId]) {
- return installedModules[moduleId].exports;
- }
-
- var module = installedModules[moduleId] = {
- i: moduleId,
- l: false,
- exports: {}
- };
-
- modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
-
- module.l = true;
-
- return module.exports;
- }
-
- __webpack_require__.m = modules;
-
- __webpack_require__.c = installedModules;
-
- __webpack_require__.i = function(value) { return value; };
-
- __webpack_require__.d = function(exports, name, getter) {
- if(!__webpack_require__.o(exports, name)) {
- Object.defineProperty(exports, name, {
- configurable: false,
- enumerable: true,
- get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- var getter = module && module.__esModule ?
- function getDefault() { return module['default']; } :
- function getModuleExports() { return module; };
- __webpack_require__.d(getter, 'a', getter);
- return getter;
- };
-
- __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
-
- __webpack_require__.p = "";
-
- return __webpack_require__(__webpack_require__.s = 1);
- })
- ([
- (function(module, exports, __webpack_require__) {
- "use strict";
- function camelize(label) {
- if (label.length === 0)
- return label;
- var n, result, word, words = label.split(/[_-]/);
-
- if ((words.length === 1) && (words[0][0].toLowerCase() === words[0][0]))
- return label;
- result = words[0].toLowerCase();
- for(n = 1 ; n < words.length ; n++) {
- result = result + words[n].charAt(0).toUpperCase() + words[n].substring(1).toLowerCase();
- }
- return result;
- }
- camelize.prepended = function(prepend, label) {
- label = camelize(label);
- return prepend + label[0].toUpperCase() + label.substring(1);
- }
- module.exports = camelize;
- }),
- (function(module, exports, __webpack_require__) {
- "use strict";
- var camelize = __webpack_require__(0);
- module.exports = function(options) { options = options || {};
- var past = camelize(options.name || options.past || 'history'),
- future = camelize( options.future || 'future'),
- clear = camelize.prepended('clear', past),
- back = camelize.prepended(past, 'back'),
- forward = camelize.prepended(past, 'forward'),
- canBack = camelize.prepended('can', back),
- canForward = camelize.prepended('can', forward),
- max = options.max;
- var plugin = {
- configure: function(config) {
- config.addTransitionLifecycleNames(back);
- config.addTransitionLifecycleNames(forward);
- },
- init: function(instance) {
- instance[past] = [];
- instance[future] = [];
- },
- lifecycle: function(instance, lifecycle) {
- if (lifecycle.event === 'onEnterState') {
- instance[past].push(lifecycle.to);
- if (max && instance[past].length > max)
- instance[past].shift();
- if (lifecycle.transition !== back && lifecycle.transition !== forward)
- instance[future].length = 0;
- }
- },
- methods: {},
- properties: {}
- }
- plugin.methods[clear] = function() {
- this[past].length = 0
- this[future].length = 0
- }
- plugin.properties[canBack] = {
- get: function() {
- return this[past].length > 1
- }
- }
- plugin.properties[canForward] = {
- get: function() {
- return this[future].length > 0
- }
- }
- plugin.methods[back] = function() {
- if (!this[canBack])
- throw Error('no history');
- var from = this[past].pop(),
- to = this[past].pop();
- this[future].push(from);
- this._fsm.transit(back, from, to, []);
- }
- plugin.methods[forward] = function() {
- if (!this[canForward])
- throw Error('no history');
- var from = this.state,
- to = this[future].pop();
- this._fsm.transit(forward, from, to, []);
- }
- return plugin;
- }
- })
- ]);
- });
|