File dist/app.js added (mode: 100644) (index 0000000..02465e1) |
|
1 |
|
/******/ (function(modules) { // webpackBootstrap |
|
2 |
|
/******/ // The module cache |
|
3 |
|
/******/ var installedModules = {}; |
|
4 |
|
|
|
5 |
|
/******/ // The require function |
|
6 |
|
/******/ function __webpack_require__(moduleId) { |
|
7 |
|
|
|
8 |
|
/******/ // Check if module is in cache |
|
9 |
|
/******/ if(installedModules[moduleId]) |
|
10 |
|
/******/ return installedModules[moduleId].exports; |
|
11 |
|
|
|
12 |
|
/******/ // Create a new module (and put it into the cache) |
|
13 |
|
/******/ var module = installedModules[moduleId] = { |
|
14 |
|
/******/ exports: {}, |
|
15 |
|
/******/ id: moduleId, |
|
16 |
|
/******/ loaded: false |
|
17 |
|
/******/ }; |
|
18 |
|
|
|
19 |
|
/******/ // Execute the module function |
|
20 |
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
21 |
|
|
|
22 |
|
/******/ // Flag the module as loaded |
|
23 |
|
/******/ module.loaded = true; |
|
24 |
|
|
|
25 |
|
/******/ // Return the exports of the module |
|
26 |
|
/******/ return module.exports; |
|
27 |
|
/******/ } |
|
28 |
|
|
|
29 |
|
|
|
30 |
|
/******/ // expose the modules object (__webpack_modules__) |
|
31 |
|
/******/ __webpack_require__.m = modules; |
|
32 |
|
|
|
33 |
|
/******/ // expose the module cache |
|
34 |
|
/******/ __webpack_require__.c = installedModules; |
|
35 |
|
|
|
36 |
|
/******/ // __webpack_public_path__ |
|
37 |
|
/******/ __webpack_require__.p = ""; |
|
38 |
|
|
|
39 |
|
/******/ // Load entry module and return exports |
|
40 |
|
/******/ return __webpack_require__(0); |
|
41 |
|
/******/ }) |
|
42 |
|
/************************************************************************/ |
|
43 |
|
/******/ ([ |
|
44 |
|
/* 0 */ |
|
45 |
|
/***/ function(module, exports, __webpack_require__) { |
|
46 |
|
|
|
47 |
|
'use strict'; |
|
48 |
|
|
|
49 |
|
var _store = __webpack_require__(1); |
|
50 |
|
|
|
51 |
|
var _store2 = _interopRequireDefault(_store); |
|
52 |
|
|
|
53 |
|
var _render = __webpack_require__(17); |
|
54 |
|
|
|
55 |
|
var _render2 = _interopRequireDefault(_render); |
|
56 |
|
|
|
57 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
58 |
|
|
|
59 |
|
var initialState = {}; |
|
60 |
|
var store = (0, _store2.default)(initialState); |
|
61 |
|
|
|
62 |
|
window.onload = function () { |
|
63 |
|
(0, _render2.default)(store); |
|
64 |
|
}; |
|
65 |
|
|
|
66 |
|
/***/ }, |
|
67 |
|
/* 1 */ |
|
68 |
|
/***/ function(module, exports, __webpack_require__) { |
|
69 |
|
|
|
70 |
|
'use strict'; |
|
71 |
|
|
|
72 |
|
Object.defineProperty(exports, "__esModule", { |
|
73 |
|
value: true |
|
74 |
|
}); |
|
75 |
|
exports.default = appStore; |
|
76 |
|
|
|
77 |
|
var _redux = __webpack_require__(2); |
|
78 |
|
|
|
79 |
|
var _reduxThunk = __webpack_require__(12); |
|
80 |
|
|
|
81 |
|
var _reduxThunk2 = _interopRequireDefault(_reduxThunk); |
|
82 |
|
|
|
83 |
|
var _reducers = __webpack_require__(13); |
|
84 |
|
|
|
85 |
|
var _reducers2 = _interopRequireDefault(_reducers); |
|
86 |
|
|
|
87 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
88 |
|
|
|
89 |
|
function appStore(initialState) { |
|
90 |
|
var createStoreWithMiddleware = (0, _redux.compose)((0, _redux.applyMiddleware)(_reduxThunk2.default), window.devToolsExtension ? window.devToolsExtension() : function (f) { |
|
91 |
|
return f; |
|
92 |
|
})(_redux.createStore); |
|
93 |
|
|
|
94 |
|
var store = createStoreWithMiddleware(_reducers2.default, initialState); |
|
95 |
|
|
|
96 |
|
return store; |
|
97 |
|
} |
|
98 |
|
|
|
99 |
|
/***/ }, |
|
100 |
|
/* 2 */ |
|
101 |
|
/***/ function(module, exports, __webpack_require__) { |
|
102 |
|
|
|
103 |
|
'use strict'; |
|
104 |
|
|
|
105 |
|
exports.__esModule = true; |
|
106 |
|
|
|
107 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
108 |
|
|
|
109 |
|
var _createStore = __webpack_require__(3); |
|
110 |
|
|
|
111 |
|
var _createStore2 = _interopRequireDefault(_createStore); |
|
112 |
|
|
|
113 |
|
var _utilsCombineReducers = __webpack_require__(5); |
|
114 |
|
|
|
115 |
|
var _utilsCombineReducers2 = _interopRequireDefault(_utilsCombineReducers); |
|
116 |
|
|
|
117 |
|
var _utilsBindActionCreators = __webpack_require__(9); |
|
118 |
|
|
|
119 |
|
var _utilsBindActionCreators2 = _interopRequireDefault(_utilsBindActionCreators); |
|
120 |
|
|
|
121 |
|
var _utilsApplyMiddleware = __webpack_require__(10); |
|
122 |
|
|
|
123 |
|
var _utilsApplyMiddleware2 = _interopRequireDefault(_utilsApplyMiddleware); |
|
124 |
|
|
|
125 |
|
var _utilsCompose = __webpack_require__(11); |
|
126 |
|
|
|
127 |
|
var _utilsCompose2 = _interopRequireDefault(_utilsCompose); |
|
128 |
|
|
|
129 |
|
exports.createStore = _createStore2['default']; |
|
130 |
|
exports.combineReducers = _utilsCombineReducers2['default']; |
|
131 |
|
exports.bindActionCreators = _utilsBindActionCreators2['default']; |
|
132 |
|
exports.applyMiddleware = _utilsApplyMiddleware2['default']; |
|
133 |
|
exports.compose = _utilsCompose2['default']; |
|
134 |
|
|
|
135 |
|
/***/ }, |
|
136 |
|
/* 3 */ |
|
137 |
|
/***/ function(module, exports, __webpack_require__) { |
|
138 |
|
|
|
139 |
|
'use strict'; |
|
140 |
|
|
|
141 |
|
exports.__esModule = true; |
|
142 |
|
exports['default'] = createStore; |
|
143 |
|
|
|
144 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
145 |
|
|
|
146 |
|
var _utilsIsPlainObject = __webpack_require__(4); |
|
147 |
|
|
|
148 |
|
var _utilsIsPlainObject2 = _interopRequireDefault(_utilsIsPlainObject); |
|
149 |
|
|
|
150 |
|
/** |
|
151 |
|
* These are private action types reserved by Redux. |
|
152 |
|
* For any unknown actions, you must return the current state. |
|
153 |
|
* If the current state is undefined, you must return the initial state. |
|
154 |
|
* Do not reference these action types directly in your code. |
|
155 |
|
*/ |
|
156 |
|
var ActionTypes = { |
|
157 |
|
INIT: '@@redux/INIT' |
|
158 |
|
}; |
|
159 |
|
|
|
160 |
|
exports.ActionTypes = ActionTypes; |
|
161 |
|
/** |
|
162 |
|
* Creates a Redux store that holds the state tree. |
|
163 |
|
* The only way to change the data in the store is to call `dispatch()` on it. |
|
164 |
|
* |
|
165 |
|
* There should only be a single store in your app. To specify how different |
|
166 |
|
* parts of the state tree respond to actions, you may combine several reducers |
|
167 |
|
* into a single reducer function by using `combineReducers`. |
|
168 |
|
* |
|
169 |
|
* @param {Function} reducer A function that returns the next state tree, given |
|
170 |
|
* the current state tree and the action to handle. |
|
171 |
|
* |
|
172 |
|
* @param {any} [initialState] The initial state. You may optionally specify it |
|
173 |
|
* to hydrate the state from the server in universal apps, or to restore a |
|
174 |
|
* previously serialized user session. |
|
175 |
|
* If you use `combineReducers` to produce the root reducer function, this must be |
|
176 |
|
* an object with the same shape as `combineReducers` keys. |
|
177 |
|
* |
|
178 |
|
* @returns {Store} A Redux store that lets you read the state, dispatch actions |
|
179 |
|
* and subscribe to changes. |
|
180 |
|
*/ |
|
181 |
|
|
|
182 |
|
function createStore(reducer, initialState) { |
|
183 |
|
if (typeof reducer !== 'function') { |
|
184 |
|
throw new Error('Expected the reducer to be a function.'); |
|
185 |
|
} |
|
186 |
|
|
|
187 |
|
var currentReducer = reducer; |
|
188 |
|
var currentState = initialState; |
|
189 |
|
var listeners = []; |
|
190 |
|
var isDispatching = false; |
|
191 |
|
|
|
192 |
|
/** |
|
193 |
|
* Reads the state tree managed by the store. |
|
194 |
|
* |
|
195 |
|
* @returns {any} The current state tree of your application. |
|
196 |
|
*/ |
|
197 |
|
function getState() { |
|
198 |
|
return currentState; |
|
199 |
|
} |
|
200 |
|
|
|
201 |
|
/** |
|
202 |
|
* Adds a change listener. It will be called any time an action is dispatched, |
|
203 |
|
* and some part of the state tree may potentially have changed. You may then |
|
204 |
|
* call `getState()` to read the current state tree inside the callback. |
|
205 |
|
* |
|
206 |
|
* @param {Function} listener A callback to be invoked on every dispatch. |
|
207 |
|
* @returns {Function} A function to remove this change listener. |
|
208 |
|
*/ |
|
209 |
|
function subscribe(listener) { |
|
210 |
|
listeners.push(listener); |
|
211 |
|
var isSubscribed = true; |
|
212 |
|
|
|
213 |
|
return function unsubscribe() { |
|
214 |
|
if (!isSubscribed) { |
|
215 |
|
return; |
|
216 |
|
} |
|
217 |
|
|
|
218 |
|
isSubscribed = false; |
|
219 |
|
var index = listeners.indexOf(listener); |
|
220 |
|
listeners.splice(index, 1); |
|
221 |
|
}; |
|
222 |
|
} |
|
223 |
|
|
|
224 |
|
/** |
|
225 |
|
* Dispatches an action. It is the only way to trigger a state change. |
|
226 |
|
* |
|
227 |
|
* The `reducer` function, used to create the store, will be called with the |
|
228 |
|
* current state tree and the given `action`. Its return value will |
|
229 |
|
* be considered the **next** state of the tree, and the change listeners |
|
230 |
|
* will be notified. |
|
231 |
|
* |
|
232 |
|
* The base implementation only supports plain object actions. If you want to |
|
233 |
|
* dispatch a Promise, an Observable, a thunk, or something else, you need to |
|
234 |
|
* wrap your store creating function into the corresponding middleware. For |
|
235 |
|
* example, see the documentation for the `redux-thunk` package. Even the |
|
236 |
|
* middleware will eventually dispatch plain object actions using this method. |
|
237 |
|
* |
|
238 |
|
* @param {Object} action A plain object representing “what changed”. It is |
|
239 |
|
* a good idea to keep actions serializable so you can record and replay user |
|
240 |
|
* sessions, or use the time travelling `redux-devtools`. An action must have |
|
241 |
|
* a `type` property which may not be `undefined`. It is a good idea to use |
|
242 |
|
* string constants for action types. |
|
243 |
|
* |
|
244 |
|
* @returns {Object} For convenience, the same action object you dispatched. |
|
245 |
|
* |
|
246 |
|
* Note that, if you use a custom middleware, it may wrap `dispatch()` to |
|
247 |
|
* return something else (for example, a Promise you can await). |
|
248 |
|
*/ |
|
249 |
|
function dispatch(action) { |
|
250 |
|
if (!_utilsIsPlainObject2['default'](action)) { |
|
251 |
|
throw new Error('Actions must be plain objects. ' + 'Use custom middleware for async actions.'); |
|
252 |
|
} |
|
253 |
|
|
|
254 |
|
if (typeof action.type === 'undefined') { |
|
255 |
|
throw new Error('Actions may not have an undefined "type" property. ' + 'Have you misspelled a constant?'); |
|
256 |
|
} |
|
257 |
|
|
|
258 |
|
if (isDispatching) { |
|
259 |
|
throw new Error('Reducers may not dispatch actions.'); |
|
260 |
|
} |
|
261 |
|
|
|
262 |
|
try { |
|
263 |
|
isDispatching = true; |
|
264 |
|
currentState = currentReducer(currentState, action); |
|
265 |
|
} finally { |
|
266 |
|
isDispatching = false; |
|
267 |
|
} |
|
268 |
|
|
|
269 |
|
listeners.slice().forEach(function (listener) { |
|
270 |
|
return listener(); |
|
271 |
|
}); |
|
272 |
|
return action; |
|
273 |
|
} |
|
274 |
|
|
|
275 |
|
/** |
|
276 |
|
* Replaces the reducer currently used by the store to calculate the state. |
|
277 |
|
* |
|
278 |
|
* You might need this if your app implements code splitting and you want to |
|
279 |
|
* load some of the reducers dynamically. You might also need this if you |
|
280 |
|
* implement a hot reloading mechanism for Redux. |
|
281 |
|
* |
|
282 |
|
* @param {Function} nextReducer The reducer for the store to use instead. |
|
283 |
|
* @returns {void} |
|
284 |
|
*/ |
|
285 |
|
function replaceReducer(nextReducer) { |
|
286 |
|
currentReducer = nextReducer; |
|
287 |
|
dispatch({ type: ActionTypes.INIT }); |
|
288 |
|
} |
|
289 |
|
|
|
290 |
|
// When a store is created, an "INIT" action is dispatched so that every |
|
291 |
|
// reducer returns their initial state. This effectively populates |
|
292 |
|
// the initial state tree. |
|
293 |
|
dispatch({ type: ActionTypes.INIT }); |
|
294 |
|
|
|
295 |
|
return { |
|
296 |
|
dispatch: dispatch, |
|
297 |
|
subscribe: subscribe, |
|
298 |
|
getState: getState, |
|
299 |
|
replaceReducer: replaceReducer |
|
300 |
|
}; |
|
301 |
|
} |
|
302 |
|
|
|
303 |
|
/***/ }, |
|
304 |
|
/* 4 */ |
|
305 |
|
/***/ function(module, exports) { |
|
306 |
|
|
|
307 |
|
'use strict'; |
|
308 |
|
|
|
309 |
|
exports.__esModule = true; |
|
310 |
|
exports['default'] = isPlainObject; |
|
311 |
|
var fnToString = function fnToString(fn) { |
|
312 |
|
return Function.prototype.toString.call(fn); |
|
313 |
|
}; |
|
314 |
|
var objStringValue = fnToString(Object); |
|
315 |
|
|
|
316 |
|
/** |
|
317 |
|
* @param {any} obj The object to inspect. |
|
318 |
|
* @returns {boolean} True if the argument appears to be a plain object. |
|
319 |
|
*/ |
|
320 |
|
|
|
321 |
|
function isPlainObject(obj) { |
|
322 |
|
if (!obj || typeof obj !== 'object') { |
|
323 |
|
return false; |
|
324 |
|
} |
|
325 |
|
|
|
326 |
|
var proto = typeof obj.constructor === 'function' ? Object.getPrototypeOf(obj) : Object.prototype; |
|
327 |
|
|
|
328 |
|
if (proto === null) { |
|
329 |
|
return true; |
|
330 |
|
} |
|
331 |
|
|
|
332 |
|
var constructor = proto.constructor; |
|
333 |
|
|
|
334 |
|
return typeof constructor === 'function' && constructor instanceof constructor && fnToString(constructor) === objStringValue; |
|
335 |
|
} |
|
336 |
|
|
|
337 |
|
module.exports = exports['default']; |
|
338 |
|
|
|
339 |
|
/***/ }, |
|
340 |
|
/* 5 */ |
|
341 |
|
/***/ function(module, exports, __webpack_require__) { |
|
342 |
|
|
|
343 |
|
/* WEBPACK VAR INJECTION */(function(process) {'use strict'; |
|
344 |
|
|
|
345 |
|
exports.__esModule = true; |
|
346 |
|
exports['default'] = combineReducers; |
|
347 |
|
|
|
348 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
349 |
|
|
|
350 |
|
var _createStore = __webpack_require__(3); |
|
351 |
|
|
|
352 |
|
var _isPlainObject = __webpack_require__(4); |
|
353 |
|
|
|
354 |
|
var _isPlainObject2 = _interopRequireDefault(_isPlainObject); |
|
355 |
|
|
|
356 |
|
var _mapValues = __webpack_require__(7); |
|
357 |
|
|
|
358 |
|
var _mapValues2 = _interopRequireDefault(_mapValues); |
|
359 |
|
|
|
360 |
|
var _pick = __webpack_require__(8); |
|
361 |
|
|
|
362 |
|
var _pick2 = _interopRequireDefault(_pick); |
|
363 |
|
|
|
364 |
|
/* eslint-disable no-console */ |
|
365 |
|
|
|
366 |
|
function getUndefinedStateErrorMessage(key, action) { |
|
367 |
|
var actionType = action && action.type; |
|
368 |
|
var actionName = actionType && '"' + actionType.toString() + '"' || 'an action'; |
|
369 |
|
|
|
370 |
|
return 'Reducer "' + key + '" returned undefined handling ' + actionName + '. ' + 'To ignore an action, you must explicitly return the previous state.'; |
|
371 |
|
} |
|
372 |
|
|
|
373 |
|
function getUnexpectedStateKeyWarningMessage(inputState, outputState, action) { |
|
374 |
|
var reducerKeys = Object.keys(outputState); |
|
375 |
|
var argumentName = action && action.type === _createStore.ActionTypes.INIT ? 'initialState argument passed to createStore' : 'previous state received by the reducer'; |
|
376 |
|
|
|
377 |
|
if (reducerKeys.length === 0) { |
|
378 |
|
return 'Store does not have a valid reducer. Make sure the argument passed ' + 'to combineReducers is an object whose values are reducers.'; |
|
379 |
|
} |
|
380 |
|
|
|
381 |
|
if (!_isPlainObject2['default'](inputState)) { |
|
382 |
|
return 'The ' + argumentName + ' has unexpected type of "' + ({}).toString.call(inputState).match(/\s([a-z|A-Z]+)/)[1] + '". Expected argument to be an object with the following ' + ('keys: "' + reducerKeys.join('", "') + '"'); |
|
383 |
|
} |
|
384 |
|
|
|
385 |
|
var unexpectedKeys = Object.keys(inputState).filter(function (key) { |
|
386 |
|
return reducerKeys.indexOf(key) < 0; |
|
387 |
|
}); |
|
388 |
|
|
|
389 |
|
if (unexpectedKeys.length > 0) { |
|
390 |
|
return 'Unexpected ' + (unexpectedKeys.length > 1 ? 'keys' : 'key') + ' ' + ('"' + unexpectedKeys.join('", "') + '" found in ' + argumentName + '. ') + 'Expected to find one of the known reducer keys instead: ' + ('"' + reducerKeys.join('", "') + '". Unexpected keys will be ignored.'); |
|
391 |
|
} |
|
392 |
|
} |
|
393 |
|
|
|
394 |
|
function assertReducerSanity(reducers) { |
|
395 |
|
Object.keys(reducers).forEach(function (key) { |
|
396 |
|
var reducer = reducers[key]; |
|
397 |
|
var initialState = reducer(undefined, { type: _createStore.ActionTypes.INIT }); |
|
398 |
|
|
|
399 |
|
if (typeof initialState === 'undefined') { |
|
400 |
|
throw new Error('Reducer "' + key + '" returned undefined during initialization. ' + 'If the state passed to the reducer is undefined, you must ' + 'explicitly return the initial state. The initial state may ' + 'not be undefined.'); |
|
401 |
|
} |
|
402 |
|
|
|
403 |
|
var type = '@@redux/PROBE_UNKNOWN_ACTION_' + Math.random().toString(36).substring(7).split('').join('.'); |
|
404 |
|
if (typeof reducer(undefined, { type: type }) === 'undefined') { |
|
405 |
|
throw new Error('Reducer "' + key + '" returned undefined when probed with a random type. ' + ('Don\'t try to handle ' + _createStore.ActionTypes.INIT + ' or other actions in "redux/*" ') + 'namespace. They are considered private. Instead, you must return the ' + 'current state for any unknown actions, unless it is undefined, ' + 'in which case you must return the initial state, regardless of the ' + 'action type. The initial state may not be undefined.'); |
|
406 |
|
} |
|
407 |
|
}); |
|
408 |
|
} |
|
409 |
|
|
|
410 |
|
/** |
|
411 |
|
* Turns an object whose values are different reducer functions, into a single |
|
412 |
|
* reducer function. It will call every child reducer, and gather their results |
|
413 |
|
* into a single state object, whose keys correspond to the keys of the passed |
|
414 |
|
* reducer functions. |
|
415 |
|
* |
|
416 |
|
* @param {Object} reducers An object whose values correspond to different |
|
417 |
|
* reducer functions that need to be combined into one. One handy way to obtain |
|
418 |
|
* it is to use ES6 `import * as reducers` syntax. The reducers may never return |
|
419 |
|
* undefined for any action. Instead, they should return their initial state |
|
420 |
|
* if the state passed to them was undefined, and the current state for any |
|
421 |
|
* unrecognized action. |
|
422 |
|
* |
|
423 |
|
* @returns {Function} A reducer function that invokes every reducer inside the |
|
424 |
|
* passed object, and builds a state object with the same shape. |
|
425 |
|
*/ |
|
426 |
|
|
|
427 |
|
function combineReducers(reducers) { |
|
428 |
|
var finalReducers = _pick2['default'](reducers, function (val) { |
|
429 |
|
return typeof val === 'function'; |
|
430 |
|
}); |
|
431 |
|
var sanityError; |
|
432 |
|
|
|
433 |
|
try { |
|
434 |
|
assertReducerSanity(finalReducers); |
|
435 |
|
} catch (e) { |
|
436 |
|
sanityError = e; |
|
437 |
|
} |
|
438 |
|
|
|
439 |
|
var defaultState = _mapValues2['default'](finalReducers, function () { |
|
440 |
|
return undefined; |
|
441 |
|
}); |
|
442 |
|
|
|
443 |
|
return function combination(state, action) { |
|
444 |
|
if (state === undefined) state = defaultState; |
|
445 |
|
|
|
446 |
|
if (sanityError) { |
|
447 |
|
throw sanityError; |
|
448 |
|
} |
|
449 |
|
|
|
450 |
|
var hasChanged = false; |
|
451 |
|
var finalState = _mapValues2['default'](finalReducers, function (reducer, key) { |
|
452 |
|
var previousStateForKey = state[key]; |
|
453 |
|
var nextStateForKey = reducer(previousStateForKey, action); |
|
454 |
|
if (typeof nextStateForKey === 'undefined') { |
|
455 |
|
var errorMessage = getUndefinedStateErrorMessage(key, action); |
|
456 |
|
throw new Error(errorMessage); |
|
457 |
|
} |
|
458 |
|
hasChanged = hasChanged || nextStateForKey !== previousStateForKey; |
|
459 |
|
return nextStateForKey; |
|
460 |
|
}); |
|
461 |
|
|
|
462 |
|
if (process.env.NODE_ENV !== 'production') { |
|
463 |
|
var warningMessage = getUnexpectedStateKeyWarningMessage(state, finalState, action); |
|
464 |
|
if (warningMessage) { |
|
465 |
|
console.error(warningMessage); |
|
466 |
|
} |
|
467 |
|
} |
|
468 |
|
|
|
469 |
|
return hasChanged ? finalState : state; |
|
470 |
|
}; |
|
471 |
|
} |
|
472 |
|
|
|
473 |
|
module.exports = exports['default']; |
|
474 |
|
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(6))) |
|
475 |
|
|
|
476 |
|
/***/ }, |
|
477 |
|
/* 6 */ |
|
478 |
|
/***/ function(module, exports) { |
|
479 |
|
|
|
480 |
|
// shim for using process in browser |
|
481 |
|
|
|
482 |
|
var process = module.exports = {}; |
|
483 |
|
var queue = []; |
|
484 |
|
var draining = false; |
|
485 |
|
var currentQueue; |
|
486 |
|
var queueIndex = -1; |
|
487 |
|
|
|
488 |
|
function cleanUpNextTick() { |
|
489 |
|
draining = false; |
|
490 |
|
if (currentQueue.length) { |
|
491 |
|
queue = currentQueue.concat(queue); |
|
492 |
|
} else { |
|
493 |
|
queueIndex = -1; |
|
494 |
|
} |
|
495 |
|
if (queue.length) { |
|
496 |
|
drainQueue(); |
|
497 |
|
} |
|
498 |
|
} |
|
499 |
|
|
|
500 |
|
function drainQueue() { |
|
501 |
|
if (draining) { |
|
502 |
|
return; |
|
503 |
|
} |
|
504 |
|
var timeout = setTimeout(cleanUpNextTick); |
|
505 |
|
draining = true; |
|
506 |
|
|
|
507 |
|
var len = queue.length; |
|
508 |
|
while(len) { |
|
509 |
|
currentQueue = queue; |
|
510 |
|
queue = []; |
|
511 |
|
while (++queueIndex < len) { |
|
512 |
|
if (currentQueue) { |
|
513 |
|
currentQueue[queueIndex].run(); |
|
514 |
|
} |
|
515 |
|
} |
|
516 |
|
queueIndex = -1; |
|
517 |
|
len = queue.length; |
|
518 |
|
} |
|
519 |
|
currentQueue = null; |
|
520 |
|
draining = false; |
|
521 |
|
clearTimeout(timeout); |
|
522 |
|
} |
|
523 |
|
|
|
524 |
|
process.nextTick = function (fun) { |
|
525 |
|
var args = new Array(arguments.length - 1); |
|
526 |
|
if (arguments.length > 1) { |
|
527 |
|
for (var i = 1; i < arguments.length; i++) { |
|
528 |
|
args[i - 1] = arguments[i]; |
|
529 |
|
} |
|
530 |
|
} |
|
531 |
|
queue.push(new Item(fun, args)); |
|
532 |
|
if (queue.length === 1 && !draining) { |
|
533 |
|
setTimeout(drainQueue, 0); |
|
534 |
|
} |
|
535 |
|
}; |
|
536 |
|
|
|
537 |
|
// v8 likes predictible objects |
|
538 |
|
function Item(fun, array) { |
|
539 |
|
this.fun = fun; |
|
540 |
|
this.array = array; |
|
541 |
|
} |
|
542 |
|
Item.prototype.run = function () { |
|
543 |
|
this.fun.apply(null, this.array); |
|
544 |
|
}; |
|
545 |
|
process.title = 'browser'; |
|
546 |
|
process.browser = true; |
|
547 |
|
process.env = {}; |
|
548 |
|
process.argv = []; |
|
549 |
|
process.version = ''; // empty string to avoid regexp issues |
|
550 |
|
process.versions = {}; |
|
551 |
|
|
|
552 |
|
function noop() {} |
|
553 |
|
|
|
554 |
|
process.on = noop; |
|
555 |
|
process.addListener = noop; |
|
556 |
|
process.once = noop; |
|
557 |
|
process.off = noop; |
|
558 |
|
process.removeListener = noop; |
|
559 |
|
process.removeAllListeners = noop; |
|
560 |
|
process.emit = noop; |
|
561 |
|
|
|
562 |
|
process.binding = function (name) { |
|
563 |
|
throw new Error('process.binding is not supported'); |
|
564 |
|
}; |
|
565 |
|
|
|
566 |
|
process.cwd = function () { return '/' }; |
|
567 |
|
process.chdir = function (dir) { |
|
568 |
|
throw new Error('process.chdir is not supported'); |
|
569 |
|
}; |
|
570 |
|
process.umask = function() { return 0; }; |
|
571 |
|
|
|
572 |
|
|
|
573 |
|
/***/ }, |
|
574 |
|
/* 7 */ |
|
575 |
|
/***/ function(module, exports) { |
|
576 |
|
|
|
577 |
|
/** |
|
578 |
|
* Applies a function to every key-value pair inside an object. |
|
579 |
|
* |
|
580 |
|
* @param {Object} obj The source object. |
|
581 |
|
* @param {Function} fn The mapper function that receives the value and the key. |
|
582 |
|
* @returns {Object} A new object that contains the mapped values for the keys. |
|
583 |
|
*/ |
|
584 |
|
"use strict"; |
|
585 |
|
|
|
586 |
|
exports.__esModule = true; |
|
587 |
|
exports["default"] = mapValues; |
|
588 |
|
|
|
589 |
|
function mapValues(obj, fn) { |
|
590 |
|
return Object.keys(obj).reduce(function (result, key) { |
|
591 |
|
result[key] = fn(obj[key], key); |
|
592 |
|
return result; |
|
593 |
|
}, {}); |
|
594 |
|
} |
|
595 |
|
|
|
596 |
|
module.exports = exports["default"]; |
|
597 |
|
|
|
598 |
|
/***/ }, |
|
599 |
|
/* 8 */ |
|
600 |
|
/***/ function(module, exports) { |
|
601 |
|
|
|
602 |
|
/** |
|
603 |
|
* Picks key-value pairs from an object where values satisfy a predicate. |
|
604 |
|
* |
|
605 |
|
* @param {Object} obj The object to pick from. |
|
606 |
|
* @param {Function} fn The predicate the values must satisfy to be copied. |
|
607 |
|
* @returns {Object} The object with the values that satisfied the predicate. |
|
608 |
|
*/ |
|
609 |
|
"use strict"; |
|
610 |
|
|
|
611 |
|
exports.__esModule = true; |
|
612 |
|
exports["default"] = pick; |
|
613 |
|
|
|
614 |
|
function pick(obj, fn) { |
|
615 |
|
return Object.keys(obj).reduce(function (result, key) { |
|
616 |
|
if (fn(obj[key])) { |
|
617 |
|
result[key] = obj[key]; |
|
618 |
|
} |
|
619 |
|
return result; |
|
620 |
|
}, {}); |
|
621 |
|
} |
|
622 |
|
|
|
623 |
|
module.exports = exports["default"]; |
|
624 |
|
|
|
625 |
|
/***/ }, |
|
626 |
|
/* 9 */ |
|
627 |
|
/***/ function(module, exports, __webpack_require__) { |
|
628 |
|
|
|
629 |
|
'use strict'; |
|
630 |
|
|
|
631 |
|
exports.__esModule = true; |
|
632 |
|
exports['default'] = bindActionCreators; |
|
633 |
|
|
|
634 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
635 |
|
|
|
636 |
|
var _mapValues = __webpack_require__(7); |
|
637 |
|
|
|
638 |
|
var _mapValues2 = _interopRequireDefault(_mapValues); |
|
639 |
|
|
|
640 |
|
function bindActionCreator(actionCreator, dispatch) { |
|
641 |
|
return function () { |
|
642 |
|
return dispatch(actionCreator.apply(undefined, arguments)); |
|
643 |
|
}; |
|
644 |
|
} |
|
645 |
|
|
|
646 |
|
/** |
|
647 |
|
* Turns an object whose values are action creators, into an object with the |
|
648 |
|
* same keys, but with every function wrapped into a `dispatch` call so they |
|
649 |
|
* may be invoked directly. This is just a convenience method, as you can call |
|
650 |
|
* `store.dispatch(MyActionCreators.doSomething())` yourself just fine. |
|
651 |
|
* |
|
652 |
|
* For convenience, you can also pass a single function as the first argument, |
|
653 |
|
* and get a function in return. |
|
654 |
|
* |
|
655 |
|
* @param {Function|Object} actionCreators An object whose values are action |
|
656 |
|
* creator functions. One handy way to obtain it is to use ES6 `import * as` |
|
657 |
|
* syntax. You may also pass a single function. |
|
658 |
|
* |
|
659 |
|
* @param {Function} dispatch The `dispatch` function available on your Redux |
|
660 |
|
* store. |
|
661 |
|
* |
|
662 |
|
* @returns {Function|Object} The object mimicking the original object, but with |
|
663 |
|
* every action creator wrapped into the `dispatch` call. If you passed a |
|
664 |
|
* function as `actionCreators`, the return value will also be a single |
|
665 |
|
* function. |
|
666 |
|
*/ |
|
667 |
|
|
|
668 |
|
function bindActionCreators(actionCreators, dispatch) { |
|
669 |
|
if (typeof actionCreators === 'function') { |
|
670 |
|
return bindActionCreator(actionCreators, dispatch); |
|
671 |
|
} |
|
672 |
|
|
|
673 |
|
if (typeof actionCreators !== 'object' || actionCreators === null || actionCreators === undefined) { |
|
674 |
|
throw new Error('bindActionCreators expected an object or a function, instead received ' + (actionCreators === null ? 'null' : typeof actionCreators) + '. ' + 'Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?'); |
|
675 |
|
} |
|
676 |
|
|
|
677 |
|
return _mapValues2['default'](actionCreators, function (actionCreator) { |
|
678 |
|
return bindActionCreator(actionCreator, dispatch); |
|
679 |
|
}); |
|
680 |
|
} |
|
681 |
|
|
|
682 |
|
module.exports = exports['default']; |
|
683 |
|
|
|
684 |
|
/***/ }, |
|
685 |
|
/* 10 */ |
|
686 |
|
/***/ function(module, exports, __webpack_require__) { |
|
687 |
|
|
|
688 |
|
'use strict'; |
|
689 |
|
|
|
690 |
|
exports.__esModule = true; |
|
691 |
|
|
|
692 |
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; |
|
693 |
|
|
|
694 |
|
exports['default'] = applyMiddleware; |
|
695 |
|
|
|
696 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } |
|
697 |
|
|
|
698 |
|
var _compose = __webpack_require__(11); |
|
699 |
|
|
|
700 |
|
var _compose2 = _interopRequireDefault(_compose); |
|
701 |
|
|
|
702 |
|
/** |
|
703 |
|
* Creates a store enhancer that applies middleware to the dispatch method |
|
704 |
|
* of the Redux store. This is handy for a variety of tasks, such as expressing |
|
705 |
|
* asynchronous actions in a concise manner, or logging every action payload. |
|
706 |
|
* |
|
707 |
|
* See `redux-thunk` package as an example of the Redux middleware. |
|
708 |
|
* |
|
709 |
|
* Because middleware is potentially asynchronous, this should be the first |
|
710 |
|
* store enhancer in the composition chain. |
|
711 |
|
* |
|
712 |
|
* Note that each middleware will be given the `dispatch` and `getState` functions |
|
713 |
|
* as named arguments. |
|
714 |
|
* |
|
715 |
|
* @param {...Function} middlewares The middleware chain to be applied. |
|
716 |
|
* @returns {Function} A store enhancer applying the middleware. |
|
717 |
|
*/ |
|
718 |
|
|
|
719 |
|
function applyMiddleware() { |
|
720 |
|
for (var _len = arguments.length, middlewares = Array(_len), _key = 0; _key < _len; _key++) { |
|
721 |
|
middlewares[_key] = arguments[_key]; |
|
722 |
|
} |
|
723 |
|
|
|
724 |
|
return function (next) { |
|
725 |
|
return function (reducer, initialState) { |
|
726 |
|
var store = next(reducer, initialState); |
|
727 |
|
var _dispatch = store.dispatch; |
|
728 |
|
var chain = []; |
|
729 |
|
|
|
730 |
|
var middlewareAPI = { |
|
731 |
|
getState: store.getState, |
|
732 |
|
dispatch: function dispatch(action) { |
|
733 |
|
return _dispatch(action); |
|
734 |
|
} |
|
735 |
|
}; |
|
736 |
|
chain = middlewares.map(function (middleware) { |
|
737 |
|
return middleware(middlewareAPI); |
|
738 |
|
}); |
|
739 |
|
_dispatch = _compose2['default'].apply(undefined, chain)(store.dispatch); |
|
740 |
|
|
|
741 |
|
return _extends({}, store, { |
|
742 |
|
dispatch: _dispatch |
|
743 |
|
}); |
|
744 |
|
}; |
|
745 |
|
}; |
|
746 |
|
} |
|
747 |
|
|
|
748 |
|
module.exports = exports['default']; |
|
749 |
|
|
|
750 |
|
/***/ }, |
|
751 |
|
/* 11 */ |
|
752 |
|
/***/ function(module, exports) { |
|
753 |
|
|
|
754 |
|
/** |
|
755 |
|
* Composes single-argument functions from right to left. |
|
756 |
|
* |
|
757 |
|
* @param {...Function} funcs The functions to compose. |
|
758 |
|
* @returns {Function} A function obtained by composing functions from right to |
|
759 |
|
* left. For example, compose(f, g, h) is identical to arg => f(g(h(arg))). |
|
760 |
|
*/ |
|
761 |
|
"use strict"; |
|
762 |
|
|
|
763 |
|
exports.__esModule = true; |
|
764 |
|
exports["default"] = compose; |
|
765 |
|
|
|
766 |
|
function compose() { |
|
767 |
|
for (var _len = arguments.length, funcs = Array(_len), _key = 0; _key < _len; _key++) { |
|
768 |
|
funcs[_key] = arguments[_key]; |
|
769 |
|
} |
|
770 |
|
|
|
771 |
|
return function (arg) { |
|
772 |
|
return funcs.reduceRight(function (composed, f) { |
|
773 |
|
return f(composed); |
|
774 |
|
}, arg); |
|
775 |
|
}; |
|
776 |
|
} |
|
777 |
|
|
|
778 |
|
module.exports = exports["default"]; |
|
779 |
|
|
|
780 |
|
/***/ }, |
|
781 |
|
/* 12 */ |
|
782 |
|
/***/ function(module, exports) { |
|
783 |
|
|
|
784 |
|
'use strict'; |
|
785 |
|
|
|
786 |
|
function thunkMiddleware(_ref) { |
|
787 |
|
var dispatch = _ref.dispatch; |
|
788 |
|
var getState = _ref.getState; |
|
789 |
|
|
|
790 |
|
return function (next) { |
|
791 |
|
return function (action) { |
|
792 |
|
return typeof action === 'function' ? action(dispatch, getState) : next(action); |
|
793 |
|
}; |
|
794 |
|
}; |
|
795 |
|
} |
|
796 |
|
|
|
797 |
|
module.exports = thunkMiddleware; |
|
798 |
|
|
|
799 |
|
/***/ }, |
|
800 |
|
/* 13 */ |
|
801 |
|
/***/ function(module, exports, __webpack_require__) { |
|
802 |
|
|
|
803 |
|
'use strict'; |
|
804 |
|
|
|
805 |
|
Object.defineProperty(exports, "__esModule", { |
|
806 |
|
value: true |
|
807 |
|
}); |
|
808 |
|
|
|
809 |
|
var _redux = __webpack_require__(2); |
|
810 |
|
|
|
811 |
|
var _counter = __webpack_require__(14); |
|
812 |
|
|
|
813 |
|
var _counter2 = _interopRequireDefault(_counter); |
|
814 |
|
|
|
815 |
|
var _simple = __webpack_require__(16); |
|
816 |
|
|
|
817 |
|
var _simple2 = _interopRequireDefault(_simple); |
|
818 |
|
|
|
819 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
820 |
|
|
|
821 |
|
exports.default = (0, _redux.combineReducers)({ |
|
822 |
|
rdxCounter: _counter2.default, |
|
823 |
|
rdxSimple: _simple2.default |
|
824 |
|
}); |
|
825 |
|
|
|
826 |
|
/***/ }, |
|
827 |
|
/* 14 */ |
|
828 |
|
/***/ function(module, exports, __webpack_require__) { |
|
829 |
|
|
|
830 |
|
"use strict"; |
|
831 |
|
|
|
832 |
|
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; |
|
833 |
|
|
|
834 |
|
Object.defineProperty(exports, "__esModule", { |
|
835 |
|
value: true |
|
836 |
|
}); |
|
837 |
|
exports.default = rdxCounter; |
|
838 |
|
|
|
839 |
|
var _actions = __webpack_require__(15); |
|
840 |
|
|
|
841 |
|
var _actions2 = _interopRequireDefault(_actions); |
|
842 |
|
|
|
843 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
844 |
|
|
|
845 |
|
function rdxCounter(state, action) { |
|
846 |
|
if (typeof state == "undefined") { |
|
847 |
|
state = { counter: 0 }; |
|
848 |
|
} |
|
849 |
|
|
|
850 |
|
if (typeof state.counter == "undefined") { |
|
851 |
|
state.counter = 0; |
|
852 |
|
} |
|
853 |
|
|
|
854 |
|
switch (action.type) { |
|
855 |
|
case _actions2.default.COUNTER_INCREMENT: |
|
856 |
|
var newState = _extends({}, state, { |
|
857 |
|
counter: state.counter + 1 |
|
858 |
|
}); |
|
859 |
|
|
|
860 |
|
return newState; |
|
861 |
|
|
|
862 |
|
case _actions2.default.COUNTER_DECREMENT: |
|
863 |
|
return _extends({}, state, { |
|
864 |
|
counter: state.counter - 1 |
|
865 |
|
}); |
|
866 |
|
|
|
867 |
|
default: |
|
868 |
|
return state; |
|
869 |
|
} |
|
870 |
|
} |
|
871 |
|
|
|
872 |
|
/***/ }, |
|
873 |
|
/* 15 */ |
|
874 |
|
/***/ function(module, exports) { |
|
875 |
|
|
|
876 |
|
"use strict"; |
|
877 |
|
|
|
878 |
|
Object.defineProperty(exports, "__esModule", { |
|
879 |
|
value: true |
|
880 |
|
}); |
|
881 |
|
var appActions = { |
|
882 |
|
COUNTER_INCREMENT: "COUNTER_INCREMENT", |
|
883 |
|
COUNTER_DECREMENT: "COUNTER_DECREMENT", |
|
884 |
|
TEXT_CHANGE: "TEXT_CHANGE" |
|
885 |
|
}; |
|
886 |
|
|
|
887 |
|
exports.default = appActions; |
|
888 |
|
|
|
889 |
|
/***/ }, |
|
890 |
|
/* 16 */ |
|
891 |
|
/***/ function(module, exports, __webpack_require__) { |
|
892 |
|
|
|
893 |
|
"use strict"; |
|
894 |
|
|
|
895 |
|
Object.defineProperty(exports, "__esModule", { |
|
896 |
|
value: true |
|
897 |
|
}); |
|
898 |
|
exports.default = rdxSimple; |
|
899 |
|
|
|
900 |
|
var _actions = __webpack_require__(15); |
|
901 |
|
|
|
902 |
|
var _actions2 = _interopRequireDefault(_actions); |
|
903 |
|
|
|
904 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
905 |
|
|
|
906 |
|
var defaultState = { |
|
907 |
|
text: "ZZZ" |
|
908 |
|
}; |
|
909 |
|
|
|
910 |
|
function rdxSimple(state, action) { |
|
911 |
|
if (!state) { |
|
912 |
|
return defaultState; |
|
913 |
|
} |
|
914 |
|
|
|
915 |
|
switch (action.type) { |
|
916 |
|
case _actions2.default.TEXT_CHANGE: |
|
917 |
|
return Object.assign({}, state, { text: action.text }); |
|
918 |
|
|
|
919 |
|
default: |
|
920 |
|
return state; |
|
921 |
|
} |
|
922 |
|
}; |
|
923 |
|
|
|
924 |
|
/***/ }, |
|
925 |
|
/* 17 */ |
|
926 |
|
/***/ function(module, exports, __webpack_require__) { |
|
927 |
|
|
|
928 |
|
'use strict'; |
|
929 |
|
|
|
930 |
|
Object.defineProperty(exports, "__esModule", { |
|
931 |
|
value: true |
|
932 |
|
}); |
|
933 |
|
exports.default = render; |
|
934 |
|
|
|
935 |
|
var _mithril = __webpack_require__(18); |
|
936 |
|
|
|
937 |
|
var _mithril2 = _interopRequireDefault(_mithril); |
|
938 |
|
|
|
939 |
|
var _main = __webpack_require__(20); |
|
940 |
|
|
|
941 |
|
var _main2 = _interopRequireDefault(_main); |
|
942 |
|
|
|
943 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
944 |
|
|
|
945 |
|
function render(store) { |
|
946 |
|
var rootTag = _mithril2.default.component(_main2.default, { data: store }); |
|
947 |
|
_mithril2.default.mount(document.getElementById('root'), rootTag); |
|
948 |
|
} |
|
949 |
|
|
|
950 |
|
/***/ }, |
|
951 |
|
/* 18 */ |
|
952 |
|
/***/ function(module, exports, __webpack_require__) { |
|
953 |
|
|
|
954 |
|
var __WEBPACK_AMD_DEFINE_RESULT__;/* WEBPACK VAR INJECTION */(function(module) {var m = (function app(window, undefined) {
|
|
955 |
|
var OBJECT = "[object Object]", ARRAY = "[object Array]", STRING = "[object String]", FUNCTION = "function";
|
|
956 |
|
var type = {}.toString;
|
|
957 |
|
var parser = /(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g, attrParser = /\[(.+?)(?:=("|'|)(.*?)\2)?\]/;
|
|
958 |
|
var voidElements = /^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/;
|
|
959 |
|
var noop = function() {}
|
|
960 |
|
|
|
961 |
|
// caching commonly used variables
|
|
962 |
|
var $document, $location, $requestAnimationFrame, $cancelAnimationFrame;
|
|
963 |
|
|
|
964 |
|
// self invoking function needed because of the way mocks work
|
|
965 |
|
function initialize(window){
|
|
966 |
|
$document = window.document;
|
|
967 |
|
$location = window.location;
|
|
968 |
|
$cancelAnimationFrame = window.cancelAnimationFrame || window.clearTimeout;
|
|
969 |
|
$requestAnimationFrame = window.requestAnimationFrame || window.setTimeout;
|
|
970 |
|
}
|
|
971 |
|
|
|
972 |
|
initialize(window);
|
|
973 |
|
|
|
974 |
|
|
|
975 |
|
/**
|
|
976 |
|
* @typedef {String} Tag
|
|
977 |
|
* A string that looks like -> div.classname#id[param=one][param2=two]
|
|
978 |
|
* Which describes a DOM node
|
|
979 |
|
*/
|
|
980 |
|
|
|
981 |
|
/**
|
|
982 |
|
*
|
|
983 |
|
* @param {Tag} The DOM node tag
|
|
984 |
|
* @param {Object=[]} optional key-value pairs to be mapped to DOM attrs
|
|
985 |
|
* @param {...mNode=[]} Zero or more Mithril child nodes. Can be an array, or splat (optional)
|
|
986 |
|
*
|
|
987 |
|
*/
|
|
988 |
|
function m() {
|
|
989 |
|
var args = [].slice.call(arguments);
|
|
990 |
|
var hasAttrs = args[1] != null && type.call(args[1]) === OBJECT && !("tag" in args[1] || "view" in args[1]) && !("subtree" in args[1]);
|
|
991 |
|
var attrs = hasAttrs ? args[1] : {};
|
|
992 |
|
var classAttrName = "class" in attrs ? "class" : "className";
|
|
993 |
|
var cell = {tag: "div", attrs: {}};
|
|
994 |
|
var match, classes = [];
|
|
995 |
|
if (type.call(args[0]) != STRING) throw new Error("selector in m(selector, attrs, children) should be a string")
|
|
996 |
|
while (match = parser.exec(args[0])) {
|
|
997 |
|
if (match[1] === "" && match[2]) cell.tag = match[2];
|
|
998 |
|
else if (match[1] === "#") cell.attrs.id = match[2];
|
|
999 |
|
else if (match[1] === ".") classes.push(match[2]);
|
|
1000 |
|
else if (match[3][0] === "[") {
|
|
1001 |
|
var pair = attrParser.exec(match[3]);
|
|
1002 |
|
cell.attrs[pair[1]] = pair[3] || (pair[2] ? "" :true)
|
|
1003 |
|
}
|
|
1004 |
|
}
|
|
1005 |
|
|
|
1006 |
|
var children = hasAttrs ? args.slice(2) : args.slice(1);
|
|
1007 |
|
if (children.length === 1 && type.call(children[0]) === ARRAY) {
|
|
1008 |
|
cell.children = children[0]
|
|
1009 |
|
}
|
|
1010 |
|
else {
|
|
1011 |
|
cell.children = children
|
|
1012 |
|
}
|
|
1013 |
|
|
|
1014 |
|
for (var attrName in attrs) {
|
|
1015 |
|
if (attrs.hasOwnProperty(attrName)) {
|
|
1016 |
|
if (attrName === classAttrName && attrs[attrName] != null && attrs[attrName] !== "") {
|
|
1017 |
|
classes.push(attrs[attrName])
|
|
1018 |
|
cell.attrs[attrName] = "" //create key in correct iteration order
|
|
1019 |
|
}
|
|
1020 |
|
else cell.attrs[attrName] = attrs[attrName]
|
|
1021 |
|
}
|
|
1022 |
|
}
|
|
1023 |
|
if (classes.length > 0) cell.attrs[classAttrName] = classes.join(" ");
|
|
1024 |
|
|
|
1025 |
|
return cell
|
|
1026 |
|
}
|
|
1027 |
|
function build(parentElement, parentTag, parentCache, parentIndex, data, cached, shouldReattach, index, editable, namespace, configs) {
|
|
1028 |
|
//`build` is a recursive function that manages creation/diffing/removal of DOM elements based on comparison between `data` and `cached`
|
|
1029 |
|
//the diff algorithm can be summarized as this:
|
|
1030 |
|
//1 - compare `data` and `cached`
|
|
1031 |
|
//2 - if they are different, copy `data` to `cached` and update the DOM based on what the difference is
|
|
1032 |
|
//3 - recursively apply this algorithm for every array and for the children of every virtual element
|
|
1033 |
|
|
|
1034 |
|
//the `cached` data structure is essentially the same as the previous redraw's `data` data structure, with a few additions:
|
|
1035 |
|
//- `cached` always has a property called `nodes`, which is a list of DOM elements that correspond to the data represented by the respective virtual element
|
|
1036 |
|
//- in order to support attaching `nodes` as a property of `cached`, `cached` is *always* a non-primitive object, i.e. if the data was a string, then cached is a String instance. If data was `null` or `undefined`, cached is `new String("")`
|
|
1037 |
|
//- `cached also has a `configContext` property, which is the state storage object exposed by config(element, isInitialized, context)
|
|
1038 |
|
//- when `cached` is an Object, it represents a virtual element; when it's an Array, it represents a list of elements; when it's a String, Number or Boolean, it represents a text node
|
|
1039 |
|
|
|
1040 |
|
//`parentElement` is a DOM element used for W3C DOM API calls
|
|
1041 |
|
//`parentTag` is only used for handling a corner case for textarea values
|
|
1042 |
|
//`parentCache` is used to remove nodes in some multi-node cases
|
|
1043 |
|
//`parentIndex` and `index` are used to figure out the offset of nodes. They're artifacts from before arrays started being flattened and are likely refactorable
|
|
1044 |
|
//`data` and `cached` are, respectively, the new and old nodes being diffed
|
|
1045 |
|
//`shouldReattach` is a flag indicating whether a parent node was recreated (if so, and if this node is reused, then this node must reattach itself to the new parent)
|
|
1046 |
|
//`editable` is a flag that indicates whether an ancestor is contenteditable
|
|
1047 |
|
//`namespace` indicates the closest HTML namespace as it cascades down from an ancestor
|
|
1048 |
|
//`configs` is a list of config functions to run after the topmost `build` call finishes running
|
|
1049 |
|
|
|
1050 |
|
//there's logic that relies on the assumption that null and undefined data are equivalent to empty strings
|
|
1051 |
|
//- this prevents lifecycle surprises from procedural helpers that mix implicit and explicit return statements (e.g. function foo() {if (cond) return m("div")}
|
|
1052 |
|
//- it simplifies diffing code
|
|
1053 |
|
//data.toString() might throw or return null if data is the return value of Console.log in Firefox (behavior depends on version)
|
|
1054 |
|
try {if (data == null || data.toString() == null) data = "";} catch (e) {data = ""}
|
|
1055 |
|
if (data.subtree === "retain") return cached;
|
|
1056 |
|
var cachedType = type.call(cached), dataType = type.call(data);
|
|
1057 |
|
if (cached == null || cachedType !== dataType) {
|
|
1058 |
|
if (cached != null) {
|
|
1059 |
|
if (parentCache && parentCache.nodes) {
|
|
1060 |
|
var offset = index - parentIndex;
|
|
1061 |
|
var end = offset + (dataType === ARRAY ? data : cached.nodes).length;
|
|
1062 |
|
clear(parentCache.nodes.slice(offset, end), parentCache.slice(offset, end))
|
|
1063 |
|
}
|
|
1064 |
|
else if (cached.nodes) clear(cached.nodes, cached)
|
|
1065 |
|
}
|
|
1066 |
|
cached = new data.constructor;
|
|
1067 |
|
if (cached.tag) cached = {}; //if constructor creates a virtual dom element, use a blank object as the base cached node instead of copying the virtual el (#277)
|
|
1068 |
|
cached.nodes = []
|
|
1069 |
|
}
|
|
1070 |
|
|
|
1071 |
|
if (dataType === ARRAY) {
|
|
1072 |
|
//recursively flatten array
|
|
1073 |
|
for (var i = 0, len = data.length; i < len; i++) {
|
|
1074 |
|
if (type.call(data[i]) === ARRAY) {
|
|
1075 |
|
data = data.concat.apply([], data);
|
|
1076 |
|
i-- //check current index again and flatten until there are no more nested arrays at that index
|
|
1077 |
|
len = data.length
|
|
1078 |
|
}
|
|
1079 |
|
}
|
|
1080 |
|
|
|
1081 |
|
var nodes = [], intact = cached.length === data.length, subArrayCount = 0;
|
|
1082 |
|
|
|
1083 |
|
//keys algorithm: sort elements without recreating them if keys are present
|
|
1084 |
|
//1) create a map of all existing keys, and mark all for deletion
|
|
1085 |
|
//2) add new keys to map and mark them for addition
|
|
1086 |
|
//3) if key exists in new list, change action from deletion to a move
|
|
1087 |
|
//4) for each key, handle its corresponding action as marked in previous steps
|
|
1088 |
|
var DELETION = 1, INSERTION = 2 , MOVE = 3;
|
|
1089 |
|
var existing = {}, shouldMaintainIdentities = false;
|
|
1090 |
|
for (var i = 0; i < cached.length; i++) {
|
|
1091 |
|
if (cached[i] && cached[i].attrs && cached[i].attrs.key != null) {
|
|
1092 |
|
shouldMaintainIdentities = true;
|
|
1093 |
|
existing[cached[i].attrs.key] = {action: DELETION, index: i}
|
|
1094 |
|
}
|
|
1095 |
|
}
|
|
1096 |
|
|
|
1097 |
|
var guid = 0
|
|
1098 |
|
for (var i = 0, len = data.length; i < len; i++) {
|
|
1099 |
|
if (data[i] && data[i].attrs && data[i].attrs.key != null) {
|
|
1100 |
|
for (var j = 0, len = data.length; j < len; j++) {
|
|
1101 |
|
if (data[j] && data[j].attrs && data[j].attrs.key == null) data[j].attrs.key = "__mithril__" + guid++
|
|
1102 |
|
}
|
|
1103 |
|
break
|
|
1104 |
|
}
|
|
1105 |
|
}
|
|
1106 |
|
|
|
1107 |
|
if (shouldMaintainIdentities) {
|
|
1108 |
|
var keysDiffer = false
|
|
1109 |
|
if (data.length != cached.length) keysDiffer = true
|
|
1110 |
|
else for (var i = 0, cachedCell, dataCell; cachedCell = cached[i], dataCell = data[i]; i++) {
|
|
1111 |
|
if (cachedCell.attrs && dataCell.attrs && cachedCell.attrs.key != dataCell.attrs.key) {
|
|
1112 |
|
keysDiffer = true
|
|
1113 |
|
break
|
|
1114 |
|
}
|
|
1115 |
|
}
|
|
1116 |
|
|
|
1117 |
|
if (keysDiffer) {
|
|
1118 |
|
for (var i = 0, len = data.length; i < len; i++) {
|
|
1119 |
|
if (data[i] && data[i].attrs) {
|
|
1120 |
|
if (data[i].attrs.key != null) {
|
|
1121 |
|
var key = data[i].attrs.key;
|
|
1122 |
|
if (!existing[key]) existing[key] = {action: INSERTION, index: i};
|
|
1123 |
|
else existing[key] = {
|
|
1124 |
|
action: MOVE,
|
|
1125 |
|
index: i,
|
|
1126 |
|
from: existing[key].index,
|
|
1127 |
|
element: cached.nodes[existing[key].index] || $document.createElement("div")
|
|
1128 |
|
}
|
|
1129 |
|
}
|
|
1130 |
|
}
|
|
1131 |
|
}
|
|
1132 |
|
var actions = []
|
|
1133 |
|
for (var prop in existing) actions.push(existing[prop])
|
|
1134 |
|
var changes = actions.sort(sortChanges);
|
|
1135 |
|
var newCached = new Array(cached.length)
|
|
1136 |
|
newCached.nodes = cached.nodes.slice()
|
|
1137 |
|
|
|
1138 |
|
for (var i = 0, change; change = changes[i]; i++) {
|
|
1139 |
|
if (change.action === DELETION) {
|
|
1140 |
|
clear(cached[change.index].nodes, cached[change.index]);
|
|
1141 |
|
newCached.splice(change.index, 1)
|
|
1142 |
|
}
|
|
1143 |
|
if (change.action === INSERTION) {
|
|
1144 |
|
var dummy = $document.createElement("div");
|
|
1145 |
|
dummy.key = data[change.index].attrs.key;
|
|
1146 |
|
parentElement.insertBefore(dummy, parentElement.childNodes[change.index] || null);
|
|
1147 |
|
newCached.splice(change.index, 0, {attrs: {key: data[change.index].attrs.key}, nodes: [dummy]})
|
|
1148 |
|
newCached.nodes[change.index] = dummy
|
|
1149 |
|
}
|
|
1150 |
|
|
|
1151 |
|
if (change.action === MOVE) {
|
|
1152 |
|
if (parentElement.childNodes[change.index] !== change.element && change.element !== null) {
|
|
1153 |
|
parentElement.insertBefore(change.element, parentElement.childNodes[change.index] || null)
|
|
1154 |
|
}
|
|
1155 |
|
newCached[change.index] = cached[change.from]
|
|
1156 |
|
newCached.nodes[change.index] = change.element
|
|
1157 |
|
}
|
|
1158 |
|
}
|
|
1159 |
|
cached = newCached;
|
|
1160 |
|
}
|
|
1161 |
|
}
|
|
1162 |
|
//end key algorithm
|
|
1163 |
|
|
|
1164 |
|
for (var i = 0, cacheCount = 0, len = data.length; i < len; i++) {
|
|
1165 |
|
//diff each item in the array
|
|
1166 |
|
var item = build(parentElement, parentTag, cached, index, data[i], cached[cacheCount], shouldReattach, index + subArrayCount || subArrayCount, editable, namespace, configs);
|
|
1167 |
|
if (item === undefined) continue;
|
|
1168 |
|
if (!item.nodes.intact) intact = false;
|
|
1169 |
|
if (item.$trusted) {
|
|
1170 |
|
//fix offset of next element if item was a trusted string w/ more than one html element
|
|
1171 |
|
//the first clause in the regexp matches elements
|
|
1172 |
|
//the second clause (after the pipe) matches text nodes
|
|
1173 |
|
subArrayCount += (item.match(/<[^\/]|\>\s*[^<]/g) || [0]).length
|
|
1174 |
|
}
|
|
1175 |
|
else subArrayCount += type.call(item) === ARRAY ? item.length : 1;
|
|
1176 |
|
cached[cacheCount++] = item
|
|
1177 |
|
}
|
|
1178 |
|
if (!intact) {
|
|
1179 |
|
//diff the array itself
|
|
1180 |
|
|
|
1181 |
|
//update the list of DOM nodes by collecting the nodes from each item
|
|
1182 |
|
for (var i = 0, len = data.length; i < len; i++) {
|
|
1183 |
|
if (cached[i] != null) nodes.push.apply(nodes, cached[i].nodes)
|
|
1184 |
|
}
|
|
1185 |
|
//remove items from the end of the array if the new array is shorter than the old one
|
|
1186 |
|
//if errors ever happen here, the issue is most likely a bug in the construction of the `cached` data structure somewhere earlier in the program
|
|
1187 |
|
for (var i = 0, node; node = cached.nodes[i]; i++) {
|
|
1188 |
|
if (node.parentNode != null && nodes.indexOf(node) < 0) clear([node], [cached[i]])
|
|
1189 |
|
}
|
|
1190 |
|
if (data.length < cached.length) cached.length = data.length;
|
|
1191 |
|
cached.nodes = nodes
|
|
1192 |
|
}
|
|
1193 |
|
}
|
|
1194 |
|
else if (data != null && dataType === OBJECT) {
|
|
1195 |
|
var views = [], controllers = []
|
|
1196 |
|
while (data.view) {
|
|
1197 |
|
var view = data.view.$original || data.view
|
|
1198 |
|
var controllerIndex = m.redraw.strategy() == "diff" && cached.views ? cached.views.indexOf(view) : -1
|
|
1199 |
|
var controller = controllerIndex > -1 ? cached.controllers[controllerIndex] : new (data.controller || noop)
|
|
1200 |
|
var key = data && data.attrs && data.attrs.key
|
|
1201 |
|
data = pendingRequests == 0 || (cached && cached.controllers && cached.controllers.indexOf(controller) > -1) ? data.view(controller) : {tag: "placeholder"}
|
|
1202 |
|
if (data.subtree === "retain") return cached;
|
|
1203 |
|
if (key) {
|
|
1204 |
|
if (!data.attrs) data.attrs = {}
|
|
1205 |
|
data.attrs.key = key
|
|
1206 |
|
}
|
|
1207 |
|
if (controller.onunload) unloaders.push({controller: controller, handler: controller.onunload})
|
|
1208 |
|
views.push(view)
|
|
1209 |
|
controllers.push(controller)
|
|
1210 |
|
}
|
|
1211 |
|
if (!data.tag && controllers.length) throw new Error("Component template must return a virtual element, not an array, string, etc.")
|
|
1212 |
|
if (!data.attrs) data.attrs = {};
|
|
1213 |
|
if (!cached.attrs) cached.attrs = {};
|
|
1214 |
|
|
|
1215 |
|
var dataAttrKeys = Object.keys(data.attrs)
|
|
1216 |
|
var hasKeys = dataAttrKeys.length > ("key" in data.attrs ? 1 : 0)
|
|
1217 |
|
//if an element is different enough from the one in cache, recreate it
|
|
1218 |
|
if (data.tag != cached.tag || dataAttrKeys.sort().join() != Object.keys(cached.attrs).sort().join() || data.attrs.id != cached.attrs.id || data.attrs.key != cached.attrs.key || (m.redraw.strategy() == "all" && (!cached.configContext || cached.configContext.retain !== true)) || (m.redraw.strategy() == "diff" && cached.configContext && cached.configContext.retain === false)) {
|
|
1219 |
|
if (cached.nodes.length) clear(cached.nodes);
|
|
1220 |
|
if (cached.configContext && typeof cached.configContext.onunload === FUNCTION) cached.configContext.onunload()
|
|
1221 |
|
if (cached.controllers) {
|
|
1222 |
|
for (var i = 0, controller; controller = cached.controllers[i]; i++) {
|
|
1223 |
|
if (typeof controller.onunload === FUNCTION) controller.onunload({preventDefault: noop})
|
|
1224 |
|
}
|
|
1225 |
|
}
|
|
1226 |
|
}
|
|
1227 |
|
if (type.call(data.tag) != STRING) return;
|
|
1228 |
|
|
|
1229 |
|
var node, isNew = cached.nodes.length === 0;
|
|
1230 |
|
if (data.attrs.xmlns) namespace = data.attrs.xmlns;
|
|
1231 |
|
else if (data.tag === "svg") namespace = "http://www.w3.org/2000/svg";
|
|
1232 |
|
else if (data.tag === "math") namespace = "http://www.w3.org/1998/Math/MathML";
|
|
1233 |
|
|
|
1234 |
|
if (isNew) {
|
|
1235 |
|
if (data.attrs.is) node = namespace === undefined ? $document.createElement(data.tag, data.attrs.is) : $document.createElementNS(namespace, data.tag, data.attrs.is);
|
|
1236 |
|
else node = namespace === undefined ? $document.createElement(data.tag) : $document.createElementNS(namespace, data.tag);
|
|
1237 |
|
cached = {
|
|
1238 |
|
tag: data.tag,
|
|
1239 |
|
//set attributes first, then create children
|
|
1240 |
|
attrs: hasKeys ? setAttributes(node, data.tag, data.attrs, {}, namespace) : data.attrs,
|
|
1241 |
|
children: data.children != null && data.children.length > 0 ?
|
|
1242 |
|
build(node, data.tag, undefined, undefined, data.children, cached.children, true, 0, data.attrs.contenteditable ? node : editable, namespace, configs) :
|
|
1243 |
|
data.children,
|
|
1244 |
|
nodes: [node]
|
|
1245 |
|
};
|
|
1246 |
|
if (controllers.length) {
|
|
1247 |
|
cached.views = views
|
|
1248 |
|
cached.controllers = controllers
|
|
1249 |
|
for (var i = 0, controller; controller = controllers[i]; i++) {
|
|
1250 |
|
if (controller.onunload && controller.onunload.$old) controller.onunload = controller.onunload.$old
|
|
1251 |
|
if (pendingRequests && controller.onunload) {
|
|
1252 |
|
var onunload = controller.onunload
|
|
1253 |
|
controller.onunload = noop
|
|
1254 |
|
controller.onunload.$old = onunload
|
|
1255 |
|
}
|
|
1256 |
|
}
|
|
1257 |
|
}
|
|
1258 |
|
|
|
1259 |
|
if (cached.children && !cached.children.nodes) cached.children.nodes = [];
|
|
1260 |
|
//edge case: setting value on <select> doesn't work before children exist, so set it again after children have been created
|
|
1261 |
|
if (data.tag === "select" && "value" in data.attrs) setAttributes(node, data.tag, {value: data.attrs.value}, {}, namespace);
|
|
1262 |
|
parentElement.insertBefore(node, parentElement.childNodes[index] || null)
|
|
1263 |
|
}
|
|
1264 |
|
else {
|
|
1265 |
|
node = cached.nodes[0];
|
|
1266 |
|
if (hasKeys) setAttributes(node, data.tag, data.attrs, cached.attrs, namespace);
|
|
1267 |
|
cached.children = build(node, data.tag, undefined, undefined, data.children, cached.children, false, 0, data.attrs.contenteditable ? node : editable, namespace, configs);
|
|
1268 |
|
cached.nodes.intact = true;
|
|
1269 |
|
if (controllers.length) {
|
|
1270 |
|
cached.views = views
|
|
1271 |
|
cached.controllers = controllers
|
|
1272 |
|
}
|
|
1273 |
|
if (shouldReattach === true && node != null) parentElement.insertBefore(node, parentElement.childNodes[index] || null)
|
|
1274 |
|
}
|
|
1275 |
|
//schedule configs to be called. They are called after `build` finishes running
|
|
1276 |
|
if (typeof data.attrs["config"] === FUNCTION) {
|
|
1277 |
|
var context = cached.configContext = cached.configContext || {};
|
|
1278 |
|
|
|
1279 |
|
// bind
|
|
1280 |
|
var callback = function(data, args) {
|
|
1281 |
|
return function() {
|
|
1282 |
|
return data.attrs["config"].apply(data, args)
|
|
1283 |
|
}
|
|
1284 |
|
};
|
|
1285 |
|
configs.push(callback(data, [node, !isNew, context, cached]))
|
|
1286 |
|
}
|
|
1287 |
|
}
|
|
1288 |
|
else if (typeof data != FUNCTION) {
|
|
1289 |
|
//handle text nodes
|
|
1290 |
|
var nodes;
|
|
1291 |
|
if (cached.nodes.length === 0) {
|
|
1292 |
|
if (data.$trusted) {
|
|
1293 |
|
nodes = injectHTML(parentElement, index, data)
|
|
1294 |
|
}
|
|
1295 |
|
else {
|
|
1296 |
|
nodes = [$document.createTextNode(data)];
|
|
1297 |
|
if (!parentElement.nodeName.match(voidElements)) parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null)
|
|
1298 |
|
}
|
|
1299 |
|
cached = "string number boolean".indexOf(typeof data) > -1 ? new data.constructor(data) : data;
|
|
1300 |
|
cached.nodes = nodes
|
|
1301 |
|
}
|
|
1302 |
|
else if (cached.valueOf() !== data.valueOf() || shouldReattach === true) {
|
|
1303 |
|
nodes = cached.nodes;
|
|
1304 |
|
if (!editable || editable !== $document.activeElement) {
|
|
1305 |
|
if (data.$trusted) {
|
|
1306 |
|
clear(nodes, cached);
|
|
1307 |
|
nodes = injectHTML(parentElement, index, data)
|
|
1308 |
|
}
|
|
1309 |
|
else {
|
|
1310 |
|
//corner case: replacing the nodeValue of a text node that is a child of a textarea/contenteditable doesn't work
|
|
1311 |
|
//we need to update the value property of the parent textarea or the innerHTML of the contenteditable element instead
|
|
1312 |
|
if (parentTag === "textarea") parentElement.value = data;
|
|
1313 |
|
else if (editable) editable.innerHTML = data;
|
|
1314 |
|
else {
|
|
1315 |
|
if (nodes[0].nodeType === 1 || nodes.length > 1) { //was a trusted string
|
|
1316 |
|
clear(cached.nodes, cached);
|
|
1317 |
|
nodes = [$document.createTextNode(data)]
|
|
1318 |
|
}
|
|
1319 |
|
parentElement.insertBefore(nodes[0], parentElement.childNodes[index] || null);
|
|
1320 |
|
nodes[0].nodeValue = data
|
|
1321 |
|
}
|
|
1322 |
|
}
|
|
1323 |
|
}
|
|
1324 |
|
cached = new data.constructor(data);
|
|
1325 |
|
cached.nodes = nodes
|
|
1326 |
|
}
|
|
1327 |
|
else cached.nodes.intact = true
|
|
1328 |
|
}
|
|
1329 |
|
|
|
1330 |
|
return cached
|
|
1331 |
|
}
|
|
1332 |
|
function sortChanges(a, b) {return a.action - b.action || a.index - b.index}
|
|
1333 |
|
function setAttributes(node, tag, dataAttrs, cachedAttrs, namespace) {
|
|
1334 |
|
for (var attrName in dataAttrs) {
|
|
1335 |
|
var dataAttr = dataAttrs[attrName];
|
|
1336 |
|
var cachedAttr = cachedAttrs[attrName];
|
|
1337 |
|
if (!(attrName in cachedAttrs) || (cachedAttr !== dataAttr)) {
|
|
1338 |
|
cachedAttrs[attrName] = dataAttr;
|
|
1339 |
|
try {
|
|
1340 |
|
//`config` isn't a real attributes, so ignore it
|
|
1341 |
|
if (attrName === "config" || attrName == "key") continue;
|
|
1342 |
|
//hook event handlers to the auto-redrawing system
|
|
1343 |
|
else if (typeof dataAttr === FUNCTION && attrName.indexOf("on") === 0) {
|
|
1344 |
|
node[attrName] = autoredraw(dataAttr, node)
|
|
1345 |
|
}
|
|
1346 |
|
//handle `style: {...}`
|
|
1347 |
|
else if (attrName === "style" && dataAttr != null && type.call(dataAttr) === OBJECT) {
|
|
1348 |
|
for (var rule in dataAttr) {
|
|
1349 |
|
if (cachedAttr == null || cachedAttr[rule] !== dataAttr[rule]) node.style[rule] = dataAttr[rule]
|
|
1350 |
|
}
|
|
1351 |
|
for (var rule in cachedAttr) {
|
|
1352 |
|
if (!(rule in dataAttr)) node.style[rule] = ""
|
|
1353 |
|
}
|
|
1354 |
|
}
|
|
1355 |
|
//handle SVG
|
|
1356 |
|
else if (namespace != null) {
|
|
1357 |
|
if (attrName === "href") node.setAttributeNS("http://www.w3.org/1999/xlink", "href", dataAttr);
|
|
1358 |
|
else if (attrName === "className") node.setAttribute("class", dataAttr);
|
|
1359 |
|
else node.setAttribute(attrName, dataAttr)
|
|
1360 |
|
}
|
|
1361 |
|
//handle cases that are properties (but ignore cases where we should use setAttribute instead)
|
|
1362 |
|
//- list and form are typically used as strings, but are DOM element references in js
|
|
1363 |
|
//- when using CSS selectors (e.g. `m("[style='']")`), style is used as a string, but it's an object in js
|
|
1364 |
|
else if (attrName in node && !(attrName === "list" || attrName === "style" || attrName === "form" || attrName === "type" || attrName === "width" || attrName === "height")) {
|
|
1365 |
|
//#348 don't set the value if not needed otherwise cursor placement breaks in Chrome
|
|
1366 |
|
if (tag !== "input" || node[attrName] !== dataAttr) node[attrName] = dataAttr
|
|
1367 |
|
}
|
|
1368 |
|
else node.setAttribute(attrName, dataAttr)
|
|
1369 |
|
}
|
|
1370 |
|
catch (e) {
|
|
1371 |
|
//swallow IE's invalid argument errors to mimic HTML's fallback-to-doing-nothing-on-invalid-attributes behavior
|
|
1372 |
|
if (e.message.indexOf("Invalid argument") < 0) throw e
|
|
1373 |
|
}
|
|
1374 |
|
}
|
|
1375 |
|
//#348 dataAttr may not be a string, so use loose comparison (double equal) instead of strict (triple equal)
|
|
1376 |
|
else if (attrName === "value" && tag === "input" && node.value != dataAttr) {
|
|
1377 |
|
node.value = dataAttr
|
|
1378 |
|
}
|
|
1379 |
|
}
|
|
1380 |
|
return cachedAttrs
|
|
1381 |
|
}
|
|
1382 |
|
function clear(nodes, cached) {
|
|
1383 |
|
for (var i = nodes.length - 1; i > -1; i--) {
|
|
1384 |
|
if (nodes[i] && nodes[i].parentNode) {
|
|
1385 |
|
try {nodes[i].parentNode.removeChild(nodes[i])}
|
|
1386 |
|
catch (e) {} //ignore if this fails due to order of events (see http://stackoverflow.com/questions/21926083/failed-to-execute-removechild-on-node)
|
|
1387 |
|
cached = [].concat(cached);
|
|
1388 |
|
if (cached[i]) unload(cached[i])
|
|
1389 |
|
}
|
|
1390 |
|
}
|
|
1391 |
|
if (nodes.length != 0) nodes.length = 0
|
|
1392 |
|
}
|
|
1393 |
|
function unload(cached) {
|
|
1394 |
|
if (cached.configContext && typeof cached.configContext.onunload === FUNCTION) {
|
|
1395 |
|
cached.configContext.onunload();
|
|
1396 |
|
cached.configContext.onunload = null
|
|
1397 |
|
}
|
|
1398 |
|
if (cached.controllers) {
|
|
1399 |
|
for (var i = 0, controller; controller = cached.controllers[i]; i++) {
|
|
1400 |
|
if (typeof controller.onunload === FUNCTION) controller.onunload({preventDefault: noop});
|
|
1401 |
|
}
|
|
1402 |
|
}
|
|
1403 |
|
if (cached.children) {
|
|
1404 |
|
if (type.call(cached.children) === ARRAY) {
|
|
1405 |
|
for (var i = 0, child; child = cached.children[i]; i++) unload(child)
|
|
1406 |
|
}
|
|
1407 |
|
else if (cached.children.tag) unload(cached.children)
|
|
1408 |
|
}
|
|
1409 |
|
}
|
|
1410 |
|
function injectHTML(parentElement, index, data) {
|
|
1411 |
|
var nextSibling = parentElement.childNodes[index];
|
|
1412 |
|
if (nextSibling) {
|
|
1413 |
|
var isElement = nextSibling.nodeType != 1;
|
|
1414 |
|
var placeholder = $document.createElement("span");
|
|
1415 |
|
if (isElement) {
|
|
1416 |
|
parentElement.insertBefore(placeholder, nextSibling || null);
|
|
1417 |
|
placeholder.insertAdjacentHTML("beforebegin", data);
|
|
1418 |
|
parentElement.removeChild(placeholder)
|
|
1419 |
|
}
|
|
1420 |
|
else nextSibling.insertAdjacentHTML("beforebegin", data)
|
|
1421 |
|
}
|
|
1422 |
|
else parentElement.insertAdjacentHTML("beforeend", data);
|
|
1423 |
|
var nodes = [];
|
|
1424 |
|
while (parentElement.childNodes[index] !== nextSibling) {
|
|
1425 |
|
nodes.push(parentElement.childNodes[index]);
|
|
1426 |
|
index++
|
|
1427 |
|
}
|
|
1428 |
|
return nodes
|
|
1429 |
|
}
|
|
1430 |
|
function autoredraw(callback, object) {
|
|
1431 |
|
return function(e) {
|
|
1432 |
|
e = e || event;
|
|
1433 |
|
m.redraw.strategy("diff");
|
|
1434 |
|
m.startComputation();
|
|
1435 |
|
try {return callback.call(object, e)}
|
|
1436 |
|
finally {
|
|
1437 |
|
endFirstComputation()
|
|
1438 |
|
}
|
|
1439 |
|
}
|
|
1440 |
|
}
|
|
1441 |
|
|
|
1442 |
|
var html;
|
|
1443 |
|
var documentNode = {
|
|
1444 |
|
appendChild: function(node) {
|
|
1445 |
|
if (html === undefined) html = $document.createElement("html");
|
|
1446 |
|
if ($document.documentElement && $document.documentElement !== node) {
|
|
1447 |
|
$document.replaceChild(node, $document.documentElement)
|
|
1448 |
|
}
|
|
1449 |
|
else $document.appendChild(node);
|
|
1450 |
|
this.childNodes = $document.childNodes
|
|
1451 |
|
},
|
|
1452 |
|
insertBefore: function(node) {
|
|
1453 |
|
this.appendChild(node)
|
|
1454 |
|
},
|
|
1455 |
|
childNodes: []
|
|
1456 |
|
};
|
|
1457 |
|
var nodeCache = [], cellCache = {};
|
|
1458 |
|
m.render = function(root, cell, forceRecreation) {
|
|
1459 |
|
var configs = [];
|
|
1460 |
|
if (!root) throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");
|
|
1461 |
|
var id = getCellCacheKey(root);
|
|
1462 |
|
var isDocumentRoot = root === $document;
|
|
1463 |
|
var node = isDocumentRoot || root === $document.documentElement ? documentNode : root;
|
|
1464 |
|
if (isDocumentRoot && cell.tag != "html") cell = {tag: "html", attrs: {}, children: cell};
|
|
1465 |
|
if (cellCache[id] === undefined) clear(node.childNodes);
|
|
1466 |
|
if (forceRecreation === true) reset(root);
|
|
1467 |
|
cellCache[id] = build(node, null, undefined, undefined, cell, cellCache[id], false, 0, null, undefined, configs);
|
|
1468 |
|
for (var i = 0, len = configs.length; i < len; i++) configs[i]()
|
|
1469 |
|
};
|
|
1470 |
|
function getCellCacheKey(element) {
|
|
1471 |
|
var index = nodeCache.indexOf(element);
|
|
1472 |
|
return index < 0 ? nodeCache.push(element) - 1 : index
|
|
1473 |
|
}
|
|
1474 |
|
|
|
1475 |
|
m.trust = function(value) {
|
|
1476 |
|
value = new String(value);
|
|
1477 |
|
value.$trusted = true;
|
|
1478 |
|
return value
|
|
1479 |
|
};
|
|
1480 |
|
|
|
1481 |
|
function gettersetter(store) {
|
|
1482 |
|
var prop = function() {
|
|
1483 |
|
if (arguments.length) store = arguments[0];
|
|
1484 |
|
return store
|
|
1485 |
|
};
|
|
1486 |
|
|
|
1487 |
|
prop.toJSON = function() {
|
|
1488 |
|
return store
|
|
1489 |
|
};
|
|
1490 |
|
|
|
1491 |
|
return prop
|
|
1492 |
|
}
|
|
1493 |
|
|
|
1494 |
|
m.prop = function (store) {
|
|
1495 |
|
//note: using non-strict equality check here because we're checking if store is null OR undefined
|
|
1496 |
|
if (((store != null && type.call(store) === OBJECT) || typeof store === FUNCTION) && typeof store.then === FUNCTION) {
|
|
1497 |
|
return propify(store)
|
|
1498 |
|
}
|
|
1499 |
|
|
|
1500 |
|
return gettersetter(store)
|
|
1501 |
|
};
|
|
1502 |
|
|
|
1503 |
|
var roots = [], components = [], controllers = [], lastRedrawId = null, lastRedrawCallTime = 0, computePreRedrawHook = null, computePostRedrawHook = null, prevented = false, topComponent, unloaders = [];
|
|
1504 |
|
var FRAME_BUDGET = 16; //60 frames per second = 1 call per 16 ms
|
|
1505 |
|
function parameterize(component, args) {
|
|
1506 |
|
var controller = function() {
|
|
1507 |
|
return (component.controller || noop).apply(this, args) || this
|
|
1508 |
|
}
|
|
1509 |
|
var view = function(ctrl) {
|
|
1510 |
|
if (arguments.length > 1) args = args.concat([].slice.call(arguments, 1))
|
|
1511 |
|
return component.view.apply(component, args ? [ctrl].concat(args) : [ctrl])
|
|
1512 |
|
}
|
|
1513 |
|
view.$original = component.view
|
|
1514 |
|
var output = {controller: controller, view: view}
|
|
1515 |
|
if (args[0] && args[0].key != null) output.attrs = {key: args[0].key}
|
|
1516 |
|
return output
|
|
1517 |
|
}
|
|
1518 |
|
m.component = function(component) {
|
|
1519 |
|
return parameterize(component, [].slice.call(arguments, 1))
|
|
1520 |
|
}
|
|
1521 |
|
m.mount = m.module = function(root, component) {
|
|
1522 |
|
if (!root) throw new Error("Please ensure the DOM element exists before rendering a template into it.");
|
|
1523 |
|
var index = roots.indexOf(root);
|
|
1524 |
|
if (index < 0) index = roots.length;
|
|
1525 |
|
|
|
1526 |
|
var isPrevented = false;
|
|
1527 |
|
var event = {preventDefault: function() {
|
|
1528 |
|
isPrevented = true;
|
|
1529 |
|
computePreRedrawHook = computePostRedrawHook = null;
|
|
1530 |
|
}};
|
|
1531 |
|
for (var i = 0, unloader; unloader = unloaders[i]; i++) {
|
|
1532 |
|
unloader.handler.call(unloader.controller, event)
|
|
1533 |
|
unloader.controller.onunload = null
|
|
1534 |
|
}
|
|
1535 |
|
if (isPrevented) {
|
|
1536 |
|
for (var i = 0, unloader; unloader = unloaders[i]; i++) unloader.controller.onunload = unloader.handler
|
|
1537 |
|
}
|
|
1538 |
|
else unloaders = []
|
|
1539 |
|
|
|
1540 |
|
if (controllers[index] && typeof controllers[index].onunload === FUNCTION) {
|
|
1541 |
|
controllers[index].onunload(event)
|
|
1542 |
|
}
|
|
1543 |
|
|
|
1544 |
|
if (!isPrevented) {
|
|
1545 |
|
m.redraw.strategy("all");
|
|
1546 |
|
m.startComputation();
|
|
1547 |
|
roots[index] = root;
|
|
1548 |
|
if (arguments.length > 2) component = subcomponent(component, [].slice.call(arguments, 2))
|
|
1549 |
|
var currentComponent = topComponent = component = component || {controller: function() {}};
|
|
1550 |
|
var constructor = component.controller || noop
|
|
1551 |
|
var controller = new constructor;
|
|
1552 |
|
//controllers may call m.mount recursively (via m.route redirects, for example)
|
|
1553 |
|
//this conditional ensures only the last recursive m.mount call is applied
|
|
1554 |
|
if (currentComponent === topComponent) {
|
|
1555 |
|
controllers[index] = controller;
|
|
1556 |
|
components[index] = component
|
|
1557 |
|
}
|
|
1558 |
|
endFirstComputation();
|
|
1559 |
|
return controllers[index]
|
|
1560 |
|
}
|
|
1561 |
|
};
|
|
1562 |
|
var redrawing = false
|
|
1563 |
|
m.redraw = function(force) {
|
|
1564 |
|
if (redrawing) return
|
|
1565 |
|
redrawing = true
|
|
1566 |
|
//lastRedrawId is a positive number if a second redraw is requested before the next animation frame
|
|
1567 |
|
//lastRedrawID is null if it's the first redraw and not an event handler
|
|
1568 |
|
if (lastRedrawId && force !== true) {
|
|
1569 |
|
//when setTimeout: only reschedule redraw if time between now and previous redraw is bigger than a frame, otherwise keep currently scheduled timeout
|
|
1570 |
|
//when rAF: always reschedule redraw
|
|
1571 |
|
if ($requestAnimationFrame === window.requestAnimationFrame || new Date - lastRedrawCallTime > FRAME_BUDGET) {
|
|
1572 |
|
if (lastRedrawId > 0) $cancelAnimationFrame(lastRedrawId);
|
|
1573 |
|
lastRedrawId = $requestAnimationFrame(redraw, FRAME_BUDGET)
|
|
1574 |
|
}
|
|
1575 |
|
}
|
|
1576 |
|
else {
|
|
1577 |
|
redraw();
|
|
1578 |
|
lastRedrawId = $requestAnimationFrame(function() {lastRedrawId = null}, FRAME_BUDGET)
|
|
1579 |
|
}
|
|
1580 |
|
redrawing = false
|
|
1581 |
|
};
|
|
1582 |
|
m.redraw.strategy = m.prop();
|
|
1583 |
|
function redraw() {
|
|
1584 |
|
if (computePreRedrawHook) {
|
|
1585 |
|
computePreRedrawHook()
|
|
1586 |
|
computePreRedrawHook = null
|
|
1587 |
|
}
|
|
1588 |
|
for (var i = 0, root; root = roots[i]; i++) {
|
|
1589 |
|
if (controllers[i]) {
|
|
1590 |
|
var args = components[i].controller && components[i].controller.$$args ? [controllers[i]].concat(components[i].controller.$$args) : [controllers[i]]
|
|
1591 |
|
m.render(root, components[i].view ? components[i].view(controllers[i], args) : "")
|
|
1592 |
|
}
|
|
1593 |
|
}
|
|
1594 |
|
//after rendering within a routed context, we need to scroll back to the top, and fetch the document title for history.pushState
|
|
1595 |
|
if (computePostRedrawHook) {
|
|
1596 |
|
computePostRedrawHook();
|
|
1597 |
|
computePostRedrawHook = null
|
|
1598 |
|
}
|
|
1599 |
|
lastRedrawId = null;
|
|
1600 |
|
lastRedrawCallTime = new Date;
|
|
1601 |
|
m.redraw.strategy("diff")
|
|
1602 |
|
}
|
|
1603 |
|
|
|
1604 |
|
var pendingRequests = 0;
|
|
1605 |
|
m.startComputation = function() {pendingRequests++};
|
|
1606 |
|
m.endComputation = function() {
|
|
1607 |
|
pendingRequests = Math.max(pendingRequests - 1, 0);
|
|
1608 |
|
if (pendingRequests === 0) m.redraw()
|
|
1609 |
|
};
|
|
1610 |
|
var endFirstComputation = function() {
|
|
1611 |
|
if (m.redraw.strategy() == "none") {
|
|
1612 |
|
pendingRequests--
|
|
1613 |
|
m.redraw.strategy("diff")
|
|
1614 |
|
}
|
|
1615 |
|
else m.endComputation();
|
|
1616 |
|
}
|
|
1617 |
|
|
|
1618 |
|
m.withAttr = function(prop, withAttrCallback) {
|
|
1619 |
|
return function(e) {
|
|
1620 |
|
e = e || event;
|
|
1621 |
|
var currentTarget = e.currentTarget || this;
|
|
1622 |
|
withAttrCallback(prop in currentTarget ? currentTarget[prop] : currentTarget.getAttribute(prop))
|
|
1623 |
|
}
|
|
1624 |
|
};
|
|
1625 |
|
|
|
1626 |
|
//routing
|
|
1627 |
|
var modes = {pathname: "", hash: "#", search: "?"};
|
|
1628 |
|
var redirect = noop, routeParams, currentRoute, isDefaultRoute = false;
|
|
1629 |
|
m.route = function() {
|
|
1630 |
|
//m.route()
|
|
1631 |
|
if (arguments.length === 0) return currentRoute;
|
|
1632 |
|
//m.route(el, defaultRoute, routes)
|
|
1633 |
|
else if (arguments.length === 3 && type.call(arguments[1]) === STRING) {
|
|
1634 |
|
var root = arguments[0], defaultRoute = arguments[1], router = arguments[2];
|
|
1635 |
|
redirect = function(source) {
|
|
1636 |
|
var path = currentRoute = normalizeRoute(source);
|
|
1637 |
|
if (!routeByValue(root, router, path)) {
|
|
1638 |
|
if (isDefaultRoute) throw new Error("Ensure the default route matches one of the routes defined in m.route")
|
|
1639 |
|
isDefaultRoute = true
|
|
1640 |
|
m.route(defaultRoute, true)
|
|
1641 |
|
isDefaultRoute = false
|
|
1642 |
|
}
|
|
1643 |
|
};
|
|
1644 |
|
var listener = m.route.mode === "hash" ? "onhashchange" : "onpopstate";
|
|
1645 |
|
window[listener] = function() {
|
|
1646 |
|
var path = $location[m.route.mode]
|
|
1647 |
|
if (m.route.mode === "pathname") path += $location.search
|
|
1648 |
|
if (currentRoute != normalizeRoute(path)) {
|
|
1649 |
|
redirect(path)
|
|
1650 |
|
}
|
|
1651 |
|
};
|
|
1652 |
|
computePreRedrawHook = setScroll;
|
|
1653 |
|
window[listener]()
|
|
1654 |
|
}
|
|
1655 |
|
//config: m.route
|
|
1656 |
|
else if (arguments[0].addEventListener || arguments[0].attachEvent) {
|
|
1657 |
|
var element = arguments[0];
|
|
1658 |
|
var isInitialized = arguments[1];
|
|
1659 |
|
var context = arguments[2];
|
|
1660 |
|
var vdom = arguments[3];
|
|
1661 |
|
element.href = (m.route.mode !== 'pathname' ? $location.pathname : '') + modes[m.route.mode] + vdom.attrs.href;
|
|
1662 |
|
if (element.addEventListener) {
|
|
1663 |
|
element.removeEventListener("click", routeUnobtrusive);
|
|
1664 |
|
element.addEventListener("click", routeUnobtrusive)
|
|
1665 |
|
}
|
|
1666 |
|
else {
|
|
1667 |
|
element.detachEvent("onclick", routeUnobtrusive);
|
|
1668 |
|
element.attachEvent("onclick", routeUnobtrusive)
|
|
1669 |
|
}
|
|
1670 |
|
}
|
|
1671 |
|
//m.route(route, params, shouldReplaceHistoryEntry)
|
|
1672 |
|
else if (type.call(arguments[0]) === STRING) {
|
|
1673 |
|
var oldRoute = currentRoute;
|
|
1674 |
|
currentRoute = arguments[0];
|
|
1675 |
|
var args = arguments[1] || {}
|
|
1676 |
|
var queryIndex = currentRoute.indexOf("?")
|
|
1677 |
|
var params = queryIndex > -1 ? parseQueryString(currentRoute.slice(queryIndex + 1)) : {}
|
|
1678 |
|
for (var i in args) params[i] = args[i]
|
|
1679 |
|
var querystring = buildQueryString(params)
|
|
1680 |
|
var currentPath = queryIndex > -1 ? currentRoute.slice(0, queryIndex) : currentRoute
|
|
1681 |
|
if (querystring) currentRoute = currentPath + (currentPath.indexOf("?") === -1 ? "?" : "&") + querystring;
|
|
1682 |
|
|
|
1683 |
|
var shouldReplaceHistoryEntry = (arguments.length === 3 ? arguments[2] : arguments[1]) === true || oldRoute === arguments[0];
|
|
1684 |
|
|
|
1685 |
|
if (window.history.pushState) {
|
|
1686 |
|
computePreRedrawHook = setScroll
|
|
1687 |
|
computePostRedrawHook = function() {
|
|
1688 |
|
window.history[shouldReplaceHistoryEntry ? "replaceState" : "pushState"](null, $document.title, modes[m.route.mode] + currentRoute);
|
|
1689 |
|
};
|
|
1690 |
|
redirect(modes[m.route.mode] + currentRoute)
|
|
1691 |
|
}
|
|
1692 |
|
else {
|
|
1693 |
|
$location[m.route.mode] = currentRoute
|
|
1694 |
|
redirect(modes[m.route.mode] + currentRoute)
|
|
1695 |
|
}
|
|
1696 |
|
}
|
|
1697 |
|
};
|
|
1698 |
|
m.route.param = function(key) {
|
|
1699 |
|
if (!routeParams) throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()")
|
|
1700 |
|
return routeParams[key]
|
|
1701 |
|
};
|
|
1702 |
|
m.route.mode = "search";
|
|
1703 |
|
function normalizeRoute(route) {
|
|
1704 |
|
return route.slice(modes[m.route.mode].length)
|
|
1705 |
|
}
|
|
1706 |
|
function routeByValue(root, router, path) {
|
|
1707 |
|
routeParams = {};
|
|
1708 |
|
|
|
1709 |
|
var queryStart = path.indexOf("?");
|
|
1710 |
|
if (queryStart !== -1) {
|
|
1711 |
|
routeParams = parseQueryString(path.substr(queryStart + 1, path.length));
|
|
1712 |
|
path = path.substr(0, queryStart)
|
|
1713 |
|
}
|
|
1714 |
|
|
|
1715 |
|
// Get all routes and check if there's
|
|
1716 |
|
// an exact match for the current path
|
|
1717 |
|
var keys = Object.keys(router);
|
|
1718 |
|
var index = keys.indexOf(path);
|
|
1719 |
|
if(index !== -1){
|
|
1720 |
|
m.mount(root, router[keys [index]]);
|
|
1721 |
|
return true;
|
|
1722 |
|
}
|
|
1723 |
|
|
|
1724 |
|
for (var route in router) {
|
|
1725 |
|
if (route === path) {
|
|
1726 |
|
m.mount(root, router[route]);
|
|
1727 |
|
return true
|
|
1728 |
|
}
|
|
1729 |
|
|
|
1730 |
|
var matcher = new RegExp("^" + route.replace(/:[^\/]+?\.{3}/g, "(.*?)").replace(/:[^\/]+/g, "([^\\/]+)") + "\/?$");
|
|
1731 |
|
|
|
1732 |
|
if (matcher.test(path)) {
|
|
1733 |
|
path.replace(matcher, function() {
|
|
1734 |
|
var keys = route.match(/:[^\/]+/g) || [];
|
|
1735 |
|
var values = [].slice.call(arguments, 1, -2);
|
|
1736 |
|
for (var i = 0, len = keys.length; i < len; i++) routeParams[keys[i].replace(/:|\./g, "")] = decodeURIComponent(values[i])
|
|
1737 |
|
m.mount(root, router[route])
|
|
1738 |
|
});
|
|
1739 |
|
return true
|
|
1740 |
|
}
|
|
1741 |
|
}
|
|
1742 |
|
}
|
|
1743 |
|
function routeUnobtrusive(e) {
|
|
1744 |
|
e = e || event;
|
|
1745 |
|
if (e.ctrlKey || e.metaKey || e.which === 2) return;
|
|
1746 |
|
if (e.preventDefault) e.preventDefault();
|
|
1747 |
|
else e.returnValue = false;
|
|
1748 |
|
var currentTarget = e.currentTarget || e.srcElement;
|
|
1749 |
|
var args = m.route.mode === "pathname" && currentTarget.search ? parseQueryString(currentTarget.search.slice(1)) : {};
|
|
1750 |
|
while (currentTarget && currentTarget.nodeName.toUpperCase() != "A") currentTarget = currentTarget.parentNode
|
|
1751 |
|
m.route(currentTarget[m.route.mode].slice(modes[m.route.mode].length), args)
|
|
1752 |
|
}
|
|
1753 |
|
function setScroll() {
|
|
1754 |
|
if (m.route.mode != "hash" && $location.hash) $location.hash = $location.hash;
|
|
1755 |
|
else window.scrollTo(0, 0)
|
|
1756 |
|
}
|
|
1757 |
|
function buildQueryString(object, prefix) {
|
|
1758 |
|
var duplicates = {}
|
|
1759 |
|
var str = []
|
|
1760 |
|
for (var prop in object) {
|
|
1761 |
|
var key = prefix ? prefix + "[" + prop + "]" : prop
|
|
1762 |
|
var value = object[prop]
|
|
1763 |
|
var valueType = type.call(value)
|
|
1764 |
|
var pair = (value === null) ? encodeURIComponent(key) :
|
|
1765 |
|
valueType === OBJECT ? buildQueryString(value, key) :
|
|
1766 |
|
valueType === ARRAY ? value.reduce(function(memo, item) {
|
|
1767 |
|
if (!duplicates[key]) duplicates[key] = {}
|
|
1768 |
|
if (!duplicates[key][item]) {
|
|
1769 |
|
duplicates[key][item] = true
|
|
1770 |
|
return memo.concat(encodeURIComponent(key) + "=" + encodeURIComponent(item))
|
|
1771 |
|
}
|
|
1772 |
|
return memo
|
|
1773 |
|
}, []).join("&") :
|
|
1774 |
|
encodeURIComponent(key) + "=" + encodeURIComponent(value)
|
|
1775 |
|
if (value !== undefined) str.push(pair)
|
|
1776 |
|
}
|
|
1777 |
|
return str.join("&")
|
|
1778 |
|
}
|
|
1779 |
|
function parseQueryString(str) {
|
|
1780 |
|
if (str.charAt(0) === "?") str = str.substring(1);
|
|
1781 |
|
|
|
1782 |
|
var pairs = str.split("&"), params = {};
|
|
1783 |
|
for (var i = 0, len = pairs.length; i < len; i++) {
|
|
1784 |
|
var pair = pairs[i].split("=");
|
|
1785 |
|
var key = decodeURIComponent(pair[0])
|
|
1786 |
|
var value = pair.length == 2 ? decodeURIComponent(pair[1]) : null
|
|
1787 |
|
if (params[key] != null) {
|
|
1788 |
|
if (type.call(params[key]) !== ARRAY) params[key] = [params[key]]
|
|
1789 |
|
params[key].push(value)
|
|
1790 |
|
}
|
|
1791 |
|
else params[key] = value
|
|
1792 |
|
}
|
|
1793 |
|
return params
|
|
1794 |
|
}
|
|
1795 |
|
m.route.buildQueryString = buildQueryString
|
|
1796 |
|
m.route.parseQueryString = parseQueryString
|
|
1797 |
|
|
|
1798 |
|
function reset(root) {
|
|
1799 |
|
var cacheKey = getCellCacheKey(root);
|
|
1800 |
|
clear(root.childNodes, cellCache[cacheKey]);
|
|
1801 |
|
cellCache[cacheKey] = undefined
|
|
1802 |
|
}
|
|
1803 |
|
|
|
1804 |
|
m.deferred = function () {
|
|
1805 |
|
var deferred = new Deferred();
|
|
1806 |
|
deferred.promise = propify(deferred.promise);
|
|
1807 |
|
return deferred
|
|
1808 |
|
};
|
|
1809 |
|
function propify(promise, initialValue) {
|
|
1810 |
|
var prop = m.prop(initialValue);
|
|
1811 |
|
promise.then(prop);
|
|
1812 |
|
prop.then = function(resolve, reject) {
|
|
1813 |
|
return propify(promise.then(resolve, reject), initialValue)
|
|
1814 |
|
};
|
|
1815 |
|
return prop
|
|
1816 |
|
}
|
|
1817 |
|
//Promiz.mithril.js | Zolmeister | MIT
|
|
1818 |
|
//a modified version of Promiz.js, which does not conform to Promises/A+ for two reasons:
|
|
1819 |
|
//1) `then` callbacks are called synchronously (because setTimeout is too slow, and the setImmediate polyfill is too big
|
|
1820 |
|
//2) throwing subclasses of Error cause the error to be bubbled up instead of triggering rejection (because the spec does not account for the important use case of default browser error handling, i.e. message w/ line number)
|
|
1821 |
|
function Deferred(successCallback, failureCallback) {
|
|
1822 |
|
var RESOLVING = 1, REJECTING = 2, RESOLVED = 3, REJECTED = 4;
|
|
1823 |
|
var self = this, state = 0, promiseValue = 0, next = [];
|
|
1824 |
|
|
|
1825 |
|
self["promise"] = {};
|
|
1826 |
|
|
|
1827 |
|
self["resolve"] = function(value) {
|
|
1828 |
|
if (!state) {
|
|
1829 |
|
promiseValue = value;
|
|
1830 |
|
state = RESOLVING;
|
|
1831 |
|
|
|
1832 |
|
fire()
|
|
1833 |
|
}
|
|
1834 |
|
return this
|
|
1835 |
|
};
|
|
1836 |
|
|
|
1837 |
|
self["reject"] = function(value) {
|
|
1838 |
|
if (!state) {
|
|
1839 |
|
promiseValue = value;
|
|
1840 |
|
state = REJECTING;
|
|
1841 |
|
|
|
1842 |
|
fire()
|
|
1843 |
|
}
|
|
1844 |
|
return this
|
|
1845 |
|
};
|
|
1846 |
|
|
|
1847 |
|
self.promise["then"] = function(successCallback, failureCallback) {
|
|
1848 |
|
var deferred = new Deferred(successCallback, failureCallback);
|
|
1849 |
|
if (state === RESOLVED) {
|
|
1850 |
|
deferred.resolve(promiseValue)
|
|
1851 |
|
}
|
|
1852 |
|
else if (state === REJECTED) {
|
|
1853 |
|
deferred.reject(promiseValue)
|
|
1854 |
|
}
|
|
1855 |
|
else {
|
|
1856 |
|
next.push(deferred)
|
|
1857 |
|
}
|
|
1858 |
|
return deferred.promise
|
|
1859 |
|
};
|
|
1860 |
|
|
|
1861 |
|
function finish(type) {
|
|
1862 |
|
state = type || REJECTED;
|
|
1863 |
|
next.map(function(deferred) {
|
|
1864 |
|
state === RESOLVED && deferred.resolve(promiseValue) || deferred.reject(promiseValue)
|
|
1865 |
|
})
|
|
1866 |
|
}
|
|
1867 |
|
|
|
1868 |
|
function thennable(then, successCallback, failureCallback, notThennableCallback) {
|
|
1869 |
|
if (((promiseValue != null && type.call(promiseValue) === OBJECT) || typeof promiseValue === FUNCTION) && typeof then === FUNCTION) {
|
|
1870 |
|
try {
|
|
1871 |
|
// count protects against abuse calls from spec checker
|
|
1872 |
|
var count = 0;
|
|
1873 |
|
then.call(promiseValue, function(value) {
|
|
1874 |
|
if (count++) return;
|
|
1875 |
|
promiseValue = value;
|
|
1876 |
|
successCallback()
|
|
1877 |
|
}, function (value) {
|
|
1878 |
|
if (count++) return;
|
|
1879 |
|
promiseValue = value;
|
|
1880 |
|
failureCallback()
|
|
1881 |
|
})
|
|
1882 |
|
}
|
|
1883 |
|
catch (e) {
|
|
1884 |
|
m.deferred.onerror(e);
|
|
1885 |
|
promiseValue = e;
|
|
1886 |
|
failureCallback()
|
|
1887 |
|
}
|
|
1888 |
|
} else {
|
|
1889 |
|
notThennableCallback()
|
|
1890 |
|
}
|
|
1891 |
|
}
|
|
1892 |
|
|
|
1893 |
|
function fire() {
|
|
1894 |
|
// check if it's a thenable
|
|
1895 |
|
var then;
|
|
1896 |
|
try {
|
|
1897 |
|
then = promiseValue && promiseValue.then
|
|
1898 |
|
}
|
|
1899 |
|
catch (e) {
|
|
1900 |
|
m.deferred.onerror(e);
|
|
1901 |
|
promiseValue = e;
|
|
1902 |
|
state = REJECTING;
|
|
1903 |
|
return fire()
|
|
1904 |
|
}
|
|
1905 |
|
thennable(then, function() {
|
|
1906 |
|
state = RESOLVING;
|
|
1907 |
|
fire()
|
|
1908 |
|
}, function() {
|
|
1909 |
|
state = REJECTING;
|
|
1910 |
|
fire()
|
|
1911 |
|
}, function() {
|
|
1912 |
|
try {
|
|
1913 |
|
if (state === RESOLVING && typeof successCallback === FUNCTION) {
|
|
1914 |
|
promiseValue = successCallback(promiseValue)
|
|
1915 |
|
}
|
|
1916 |
|
else if (state === REJECTING && typeof failureCallback === "function") {
|
|
1917 |
|
promiseValue = failureCallback(promiseValue);
|
|
1918 |
|
state = RESOLVING
|
|
1919 |
|
}
|
|
1920 |
|
}
|
|
1921 |
|
catch (e) {
|
|
1922 |
|
m.deferred.onerror(e);
|
|
1923 |
|
promiseValue = e;
|
|
1924 |
|
return finish()
|
|
1925 |
|
}
|
|
1926 |
|
|
|
1927 |
|
if (promiseValue === self) {
|
|
1928 |
|
promiseValue = TypeError();
|
|
1929 |
|
finish()
|
|
1930 |
|
}
|
|
1931 |
|
else {
|
|
1932 |
|
thennable(then, function () {
|
|
1933 |
|
finish(RESOLVED)
|
|
1934 |
|
}, finish, function () {
|
|
1935 |
|
finish(state === RESOLVING && RESOLVED)
|
|
1936 |
|
})
|
|
1937 |
|
}
|
|
1938 |
|
})
|
|
1939 |
|
}
|
|
1940 |
|
}
|
|
1941 |
|
m.deferred.onerror = function(e) {
|
|
1942 |
|
if (type.call(e) === "[object Error]" && !e.constructor.toString().match(/ Error/)) throw e
|
|
1943 |
|
};
|
|
1944 |
|
|
|
1945 |
|
m.sync = function(args) {
|
|
1946 |
|
var method = "resolve";
|
|
1947 |
|
function synchronizer(pos, resolved) {
|
|
1948 |
|
return function(value) {
|
|
1949 |
|
results[pos] = value;
|
|
1950 |
|
if (!resolved) method = "reject";
|
|
1951 |
|
if (--outstanding === 0) {
|
|
1952 |
|
deferred.promise(results);
|
|
1953 |
|
deferred[method](results)
|
|
1954 |
|
}
|
|
1955 |
|
return value
|
|
1956 |
|
}
|
|
1957 |
|
}
|
|
1958 |
|
|
|
1959 |
|
var deferred = m.deferred();
|
|
1960 |
|
var outstanding = args.length;
|
|
1961 |
|
var results = new Array(outstanding);
|
|
1962 |
|
if (args.length > 0) {
|
|
1963 |
|
for (var i = 0; i < args.length; i++) {
|
|
1964 |
|
args[i].then(synchronizer(i, true), synchronizer(i, false))
|
|
1965 |
|
}
|
|
1966 |
|
}
|
|
1967 |
|
else deferred.resolve([]);
|
|
1968 |
|
|
|
1969 |
|
return deferred.promise
|
|
1970 |
|
};
|
|
1971 |
|
function identity(value) {return value}
|
|
1972 |
|
|
|
1973 |
|
function ajax(options) {
|
|
1974 |
|
if (options.dataType && options.dataType.toLowerCase() === "jsonp") {
|
|
1975 |
|
var callbackKey = "mithril_callback_" + new Date().getTime() + "_" + (Math.round(Math.random() * 1e16)).toString(36);
|
|
1976 |
|
var script = $document.createElement("script");
|
|
1977 |
|
|
|
1978 |
|
window[callbackKey] = function(resp) {
|
|
1979 |
|
script.parentNode.removeChild(script);
|
|
1980 |
|
options.onload({
|
|
1981 |
|
type: "load",
|
|
1982 |
|
target: {
|
|
1983 |
|
responseText: resp
|
|
1984 |
|
}
|
|
1985 |
|
});
|
|
1986 |
|
window[callbackKey] = undefined
|
|
1987 |
|
};
|
|
1988 |
|
|
|
1989 |
|
script.onerror = function(e) {
|
|
1990 |
|
script.parentNode.removeChild(script);
|
|
1991 |
|
|
|
1992 |
|
options.onerror({
|
|
1993 |
|
type: "error",
|
|
1994 |
|
target: {
|
|
1995 |
|
status: 500,
|
|
1996 |
|
responseText: JSON.stringify({error: "Error making jsonp request"})
|
|
1997 |
|
}
|
|
1998 |
|
});
|
|
1999 |
|
window[callbackKey] = undefined;
|
|
2000 |
|
|
|
2001 |
|
return false
|
|
2002 |
|
};
|
|
2003 |
|
|
|
2004 |
|
script.onload = function(e) {
|
|
2005 |
|
return false
|
|
2006 |
|
};
|
|
2007 |
|
|
|
2008 |
|
script.src = options.url
|
|
2009 |
|
+ (options.url.indexOf("?") > 0 ? "&" : "?")
|
|
2010 |
|
+ (options.callbackKey ? options.callbackKey : "callback")
|
|
2011 |
|
+ "=" + callbackKey
|
|
2012 |
|
+ "&" + buildQueryString(options.data || {});
|
|
2013 |
|
$document.body.appendChild(script)
|
|
2014 |
|
}
|
|
2015 |
|
else {
|
|
2016 |
|
var xhr = new window.XMLHttpRequest;
|
|
2017 |
|
xhr.open(options.method, options.url, true, options.user, options.password);
|
|
2018 |
|
xhr.onreadystatechange = function() {
|
|
2019 |
|
if (xhr.readyState === 4) {
|
|
2020 |
|
if (xhr.status >= 200 && xhr.status < 300) options.onload({type: "load", target: xhr});
|
|
2021 |
|
else options.onerror({type: "error", target: xhr})
|
|
2022 |
|
}
|
|
2023 |
|
};
|
|
2024 |
|
if (options.serialize === JSON.stringify && options.data && options.method !== "GET") {
|
|
2025 |
|
xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8")
|
|
2026 |
|
}
|
|
2027 |
|
if (options.deserialize === JSON.parse) {
|
|
2028 |
|
xhr.setRequestHeader("Accept", "application/json, text/*");
|
|
2029 |
|
}
|
|
2030 |
|
if (typeof options.config === FUNCTION) {
|
|
2031 |
|
var maybeXhr = options.config(xhr, options);
|
|
2032 |
|
if (maybeXhr != null) xhr = maybeXhr
|
|
2033 |
|
}
|
|
2034 |
|
|
|
2035 |
|
var data = options.method === "GET" || !options.data ? "" : options.data
|
|
2036 |
|
if (data && (type.call(data) != STRING && data.constructor != window.FormData)) {
|
|
2037 |
|
throw "Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";
|
|
2038 |
|
}
|
|
2039 |
|
xhr.send(data);
|
|
2040 |
|
return xhr
|
|
2041 |
|
}
|
|
2042 |
|
}
|
|
2043 |
|
function bindData(xhrOptions, data, serialize) {
|
|
2044 |
|
if (xhrOptions.method === "GET" && xhrOptions.dataType != "jsonp") {
|
|
2045 |
|
var prefix = xhrOptions.url.indexOf("?") < 0 ? "?" : "&";
|
|
2046 |
|
var querystring = buildQueryString(data);
|
|
2047 |
|
xhrOptions.url = xhrOptions.url + (querystring ? prefix + querystring : "")
|
|
2048 |
|
}
|
|
2049 |
|
else xhrOptions.data = serialize(data);
|
|
2050 |
|
return xhrOptions
|
|
2051 |
|
}
|
|
2052 |
|
function parameterizeUrl(url, data) {
|
|
2053 |
|
var tokens = url.match(/:[a-z]\w+/gi);
|
|
2054 |
|
if (tokens && data) {
|
|
2055 |
|
for (var i = 0; i < tokens.length; i++) {
|
|
2056 |
|
var key = tokens[i].slice(1);
|
|
2057 |
|
url = url.replace(tokens[i], data[key]);
|
|
2058 |
|
delete data[key]
|
|
2059 |
|
}
|
|
2060 |
|
}
|
|
2061 |
|
return url
|
|
2062 |
|
}
|
|
2063 |
|
|
|
2064 |
|
m.request = function(xhrOptions) {
|
|
2065 |
|
if (xhrOptions.background !== true) m.startComputation();
|
|
2066 |
|
var deferred = new Deferred();
|
|
2067 |
|
var isJSONP = xhrOptions.dataType && xhrOptions.dataType.toLowerCase() === "jsonp";
|
|
2068 |
|
var serialize = xhrOptions.serialize = isJSONP ? identity : xhrOptions.serialize || JSON.stringify;
|
|
2069 |
|
var deserialize = xhrOptions.deserialize = isJSONP ? identity : xhrOptions.deserialize || JSON.parse;
|
|
2070 |
|
var extract = isJSONP ? function(jsonp) {return jsonp.responseText} : xhrOptions.extract || function(xhr) {
|
|
2071 |
|
return xhr.responseText.length === 0 && deserialize === JSON.parse ? null : xhr.responseText
|
|
2072 |
|
};
|
|
2073 |
|
xhrOptions.method = (xhrOptions.method || 'GET').toUpperCase();
|
|
2074 |
|
xhrOptions.url = parameterizeUrl(xhrOptions.url, xhrOptions.data);
|
|
2075 |
|
xhrOptions = bindData(xhrOptions, xhrOptions.data, serialize);
|
|
2076 |
|
xhrOptions.onload = xhrOptions.onerror = function(e) {
|
|
2077 |
|
try {
|
|
2078 |
|
e = e || event;
|
|
2079 |
|
var unwrap = (e.type === "load" ? xhrOptions.unwrapSuccess : xhrOptions.unwrapError) || identity;
|
|
2080 |
|
var response = unwrap(deserialize(extract(e.target, xhrOptions)), e.target);
|
|
2081 |
|
if (e.type === "load") {
|
|
2082 |
|
if (type.call(response) === ARRAY && xhrOptions.type) {
|
|
2083 |
|
for (var i = 0; i < response.length; i++) response[i] = new xhrOptions.type(response[i])
|
|
2084 |
|
}
|
|
2085 |
|
else if (xhrOptions.type) response = new xhrOptions.type(response)
|
|
2086 |
|
}
|
|
2087 |
|
deferred[e.type === "load" ? "resolve" : "reject"](response)
|
|
2088 |
|
}
|
|
2089 |
|
catch (e) {
|
|
2090 |
|
m.deferred.onerror(e);
|
|
2091 |
|
deferred.reject(e)
|
|
2092 |
|
}
|
|
2093 |
|
if (xhrOptions.background !== true) m.endComputation()
|
|
2094 |
|
};
|
|
2095 |
|
ajax(xhrOptions);
|
|
2096 |
|
deferred.promise = propify(deferred.promise, xhrOptions.initialValue);
|
|
2097 |
|
return deferred.promise
|
|
2098 |
|
};
|
|
2099 |
|
|
|
2100 |
|
//testing API
|
|
2101 |
|
m.deps = function(mock) {
|
|
2102 |
|
initialize(window = mock || window);
|
|
2103 |
|
return window;
|
|
2104 |
|
};
|
|
2105 |
|
//for internal testing only, do not use `m.deps.factory`
|
|
2106 |
|
m.deps.factory = app;
|
|
2107 |
|
|
|
2108 |
|
return m
|
|
2109 |
|
})(typeof window != "undefined" ? window : {});
|
|
2110 |
|
|
|
2111 |
|
if (typeof module != "undefined" && module !== null && module.exports) module.exports = m;
|
|
2112 |
|
else if (true) !(__WEBPACK_AMD_DEFINE_RESULT__ = function() {return m}.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
|
|
2113 |
|
|
|
2114 |
|
/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(19)(module))) |
|
2115 |
|
|
|
2116 |
|
/***/ }, |
|
2117 |
|
/* 19 */ |
|
2118 |
|
/***/ function(module, exports) { |
|
2119 |
|
|
|
2120 |
|
module.exports = function(module) {
|
|
2121 |
|
if(!module.webpackPolyfill) {
|
|
2122 |
|
module.deprecate = function() {};
|
|
2123 |
|
module.paths = [];
|
|
2124 |
|
// module.parent = undefined by default
|
|
2125 |
|
module.children = [];
|
|
2126 |
|
module.webpackPolyfill = 1;
|
|
2127 |
|
}
|
|
2128 |
|
return module;
|
|
2129 |
|
}
|
|
2130 |
|
|
|
2131 |
|
|
|
2132 |
|
/***/ }, |
|
2133 |
|
/* 20 */ |
|
2134 |
|
/***/ function(module, exports, __webpack_require__) { |
|
2135 |
|
|
|
2136 |
|
'use strict'; |
|
2137 |
|
|
|
2138 |
|
Object.defineProperty(exports, "__esModule", { |
|
2139 |
|
value: true |
|
2140 |
|
}); |
|
2141 |
|
|
|
2142 |
|
var _mithril = __webpack_require__(18); |
|
2143 |
|
|
|
2144 |
|
var _mithril2 = _interopRequireDefault(_mithril); |
|
2145 |
|
|
|
2146 |
|
var _counter = __webpack_require__(21); |
|
2147 |
|
|
|
2148 |
|
var _counter2 = _interopRequireDefault(_counter); |
|
2149 |
|
|
|
2150 |
|
var _simple = __webpack_require__(22); |
|
2151 |
|
|
|
2152 |
|
var _simple2 = _interopRequireDefault(_simple); |
|
2153 |
|
|
|
2154 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
2155 |
|
|
|
2156 |
|
var comMain = {}; |
|
2157 |
|
// import MComponent from './component.com'; |
|
2158 |
|
|
|
2159 |
|
comMain.controller = function (opts) { |
|
2160 |
|
this.store = opts.data; |
|
2161 |
|
this.mSimple = new _simple2.default(); |
|
2162 |
|
}; |
|
2163 |
|
|
|
2164 |
|
comMain.view = function (ctrl) { |
|
2165 |
|
return (0, _mithril2.default)('div', [_mithril2.default.component(_counter2.default, { data: ctrl.store }), _mithril2.default.component(ctrl.mSimple.m(), { data: ctrl.store })]); |
|
2166 |
|
}; |
|
2167 |
|
|
|
2168 |
|
exports.default = comMain; |
|
2169 |
|
|
|
2170 |
|
/***/ }, |
|
2171 |
|
/* 21 */ |
|
2172 |
|
/***/ function(module, exports, __webpack_require__) { |
|
2173 |
|
|
|
2174 |
|
'use strict'; |
|
2175 |
|
|
|
2176 |
|
Object.defineProperty(exports, "__esModule", { |
|
2177 |
|
value: true |
|
2178 |
|
}); |
|
2179 |
|
|
|
2180 |
|
var _mithril = __webpack_require__(18); |
|
2181 |
|
|
|
2182 |
|
var _mithril2 = _interopRequireDefault(_mithril); |
|
2183 |
|
|
|
2184 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
2185 |
|
|
|
2186 |
|
var comCounter = { |
|
2187 |
|
controller: function controller(opts) { |
|
2188 |
|
var _this = this; |
|
2189 |
|
|
|
2190 |
|
this.store = opts.data; |
|
2191 |
|
this.count = opts.data.getState().counter; |
|
2192 |
|
|
|
2193 |
|
this.increment = function () { |
|
2194 |
|
console.log(_this.store); |
|
2195 |
|
_this.store.dispatch({ |
|
2196 |
|
type: 'INCREMENT' |
|
2197 |
|
}); |
|
2198 |
|
}; |
|
2199 |
|
this.decrement = function () { |
|
2200 |
|
_this.store.dispatch({ |
|
2201 |
|
type: 'DECREMENT' |
|
2202 |
|
}); |
|
2203 |
|
}; |
|
2204 |
|
|
|
2205 |
|
opts.data.subscribe(function () { |
|
2206 |
|
_this.count = _this.store.getState().counter; |
|
2207 |
|
}); |
|
2208 |
|
}, |
|
2209 |
|
|
|
2210 |
|
view: function view(ctrl) { |
|
2211 |
|
return (0, _mithril2.default)('div', [(0, _mithril2.default)('span', ctrl.count), (0, _mithril2.default)('br'), (0, _mithril2.default)('button', { onclick: ctrl.increment }, '+'), (0, _mithril2.default)('button', { onclick: ctrl.decrement }, '-')]); |
|
2212 |
|
} |
|
2213 |
|
}; |
|
2214 |
|
|
|
2215 |
|
exports.default = comCounter; |
|
2216 |
|
|
|
2217 |
|
/***/ }, |
|
2218 |
|
/* 22 */ |
|
2219 |
|
/***/ function(module, exports, __webpack_require__) { |
|
2220 |
|
|
|
2221 |
|
'use strict'; |
|
2222 |
|
|
|
2223 |
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); |
|
2224 |
|
|
|
2225 |
|
Object.defineProperty(exports, "__esModule", { |
|
2226 |
|
value: true |
|
2227 |
|
}); |
|
2228 |
|
|
|
2229 |
|
var _mithril = __webpack_require__(18); |
|
2230 |
|
|
|
2231 |
|
var _mithril2 = _interopRequireDefault(_mithril); |
|
2232 |
|
|
|
2233 |
|
var _component = __webpack_require__(23); |
|
2234 |
|
|
|
2235 |
|
var _component2 = _interopRequireDefault(_component); |
|
2236 |
|
|
|
2237 |
|
var _button = __webpack_require__(24); |
|
2238 |
|
|
|
2239 |
|
var _button2 = _interopRequireDefault(_button); |
|
2240 |
|
|
|
2241 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
2242 |
|
|
|
2243 |
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
2244 |
|
|
|
2245 |
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
|
2246 |
|
|
|
2247 |
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
|
2248 |
|
|
|
2249 |
|
var MSimple = (function (_MComponent) { |
|
2250 |
|
_inherits(MSimple, _MComponent); |
|
2251 |
|
|
|
2252 |
|
function MSimple() { |
|
2253 |
|
_classCallCheck(this, MSimple); |
|
2254 |
|
|
|
2255 |
|
return _possibleConstructorReturn(this, Object.getPrototypeOf(MSimple).apply(this, arguments)); |
|
2256 |
|
} |
|
2257 |
|
|
|
2258 |
|
_createClass(MSimple, [{ |
|
2259 |
|
key: 'controller', |
|
2260 |
|
value: function controller(args) { |
|
2261 |
|
this.store = args.data; |
|
2262 |
|
this.mBtnTest = new _button2.default({ |
|
2263 |
|
tag: 'a', |
|
2264 |
|
label: "Initial Label", |
|
2265 |
|
size: _button2.default.sizes.SMALL |
|
2266 |
|
}); |
|
2267 |
|
} |
|
2268 |
|
}, { |
|
2269 |
|
key: 'view', |
|
2270 |
|
value: function view(ctrl, args) { |
|
2271 |
|
var state = this.store.getState(); |
|
2272 |
|
|
|
2273 |
|
return (0, _mithril2.default)('.test', [(0, _mithril2.default)('h1', 'Hello World !'), (0, _mithril2.default)("p", state.text), (0, _mithril2.default)("button", { onclick: this.clickText }, "What time is it ?"), _mithril2.default.component(this.mBtnTest.m(), { label: "Changed Label" })]); |
|
2274 |
|
} |
|
2275 |
|
}, { |
|
2276 |
|
key: 'clickText', |
|
2277 |
|
value: function clickText(e) { |
|
2278 |
|
e.preventDefault(); |
|
2279 |
|
|
|
2280 |
|
this.store.dispatch({ |
|
2281 |
|
type: appActions.TEXT_CHANGE, |
|
2282 |
|
text: "It's currently: " + new Date().toTimeString() |
|
2283 |
|
}); |
|
2284 |
|
} |
|
2285 |
|
}]); |
|
2286 |
|
|
|
2287 |
|
return MSimple; |
|
2288 |
|
})(_component2.default); |
|
2289 |
|
|
|
2290 |
|
exports.default = MSimple; |
|
2291 |
|
|
|
2292 |
|
/***/ }, |
|
2293 |
|
/* 23 */ |
|
2294 |
|
/***/ function(module, exports) { |
|
2295 |
|
|
|
2296 |
|
'use strict'; |
|
2297 |
|
|
|
2298 |
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); |
|
2299 |
|
|
|
2300 |
|
Object.defineProperty(exports, "__esModule", { |
|
2301 |
|
value: true |
|
2302 |
|
}); |
|
2303 |
|
|
|
2304 |
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
2305 |
|
|
|
2306 |
|
var MComponent = (function () { |
|
2307 |
|
function MComponent(options) { |
|
2308 |
|
_classCallCheck(this, MComponent); |
|
2309 |
|
|
|
2310 |
|
this.options = {}; |
|
2311 |
|
|
|
2312 |
|
// if (new.target === MComponent) throw TypeError('New of abstract class MComponent'); |
|
2313 |
|
|
|
2314 |
|
var self = this; |
|
2315 |
|
|
|
2316 |
|
self.options = Object.assign({}, this.options, options); |
|
2317 |
|
|
|
2318 |
|
self.mithril = { |
|
2319 |
|
controller: function controller() { |
|
2320 |
|
self.controller.apply(self, arguments); |
|
2321 |
|
}, |
|
2322 |
|
|
|
2323 |
|
view: function view() { |
|
2324 |
|
return self.view.apply(self, arguments); |
|
2325 |
|
} |
|
2326 |
|
}; |
|
2327 |
|
} |
|
2328 |
|
|
|
2329 |
|
_createClass(MComponent, [{ |
|
2330 |
|
key: 'reducer', |
|
2331 |
|
value: function reducer(state) { |
|
2332 |
|
throw TypeError('Method "reducer" should be overriden in children'); |
|
2333 |
|
} |
|
2334 |
|
}, { |
|
2335 |
|
key: 'controller', |
|
2336 |
|
value: function controller(state) { |
|
2337 |
|
return; |
|
2338 |
|
} |
|
2339 |
|
}, { |
|
2340 |
|
key: 'view', |
|
2341 |
|
value: function view(state) { |
|
2342 |
|
return []; |
|
2343 |
|
} |
|
2344 |
|
}, { |
|
2345 |
|
key: 'm', |
|
2346 |
|
value: function m() { |
|
2347 |
|
return this.mithril; |
|
2348 |
|
} |
|
2349 |
|
}]); |
|
2350 |
|
|
|
2351 |
|
return MComponent; |
|
2352 |
|
})(); |
|
2353 |
|
|
|
2354 |
|
exports.default = MComponent; |
|
2355 |
|
|
|
2356 |
|
/***/ }, |
|
2357 |
|
/* 24 */ |
|
2358 |
|
/***/ function(module, exports, __webpack_require__) { |
|
2359 |
|
|
|
2360 |
|
'use strict'; |
|
2361 |
|
|
|
2362 |
|
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); |
|
2363 |
|
|
|
2364 |
|
Object.defineProperty(exports, "__esModule", { |
|
2365 |
|
value: true |
|
2366 |
|
}); |
|
2367 |
|
|
|
2368 |
|
var _component = __webpack_require__(23); |
|
2369 |
|
|
|
2370 |
|
var _component2 = _interopRequireDefault(_component); |
|
2371 |
|
|
|
2372 |
|
var _mithril = __webpack_require__(18); |
|
2373 |
|
|
|
2374 |
|
var _mithril2 = _interopRequireDefault(_mithril); |
|
2375 |
|
|
|
2376 |
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } |
|
2377 |
|
|
|
2378 |
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } |
|
2379 |
|
|
|
2380 |
|
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } |
|
2381 |
|
|
|
2382 |
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } |
|
2383 |
|
|
|
2384 |
|
var MButton = (function (_MComponent) { |
|
2385 |
|
_inherits(MButton, _MComponent); |
|
2386 |
|
|
|
2387 |
|
function MButton(options) { |
|
2388 |
|
_classCallCheck(this, MButton); |
|
2389 |
|
|
|
2390 |
|
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(MButton).call(this, options)); |
|
2391 |
|
|
|
2392 |
|
_this.options = { |
|
2393 |
|
tag: 'button', |
|
2394 |
|
label: 'Button', |
|
2395 |
|
size: MButton.sizes.NORMAL |
|
2396 |
|
}; |
|
2397 |
|
return _this; |
|
2398 |
|
} |
|
2399 |
|
|
|
2400 |
|
_createClass(MButton, [{ |
|
2401 |
|
key: 'controller', |
|
2402 |
|
value: function controller(args) { |
|
2403 |
|
var options = Object.assign({}, this.options, args); |
|
2404 |
|
|
|
2405 |
|
this.theme = _mithril2.default.prop(); |
|
2406 |
|
this.size = _mithril2.default.prop(options.size); |
|
2407 |
|
this.tag = _mithril2.default.prop(options.tag); |
|
2408 |
|
this.label = _mithril2.default.prop(options.label); |
|
2409 |
|
} |
|
2410 |
|
}, { |
|
2411 |
|
key: 'view', |
|
2412 |
|
value: function view(ctrl, args) { |
|
2413 |
|
return (0, _mithril2.default)(this.tag(), this.label()); |
|
2414 |
|
} |
|
2415 |
|
}]); |
|
2416 |
|
|
|
2417 |
|
return MButton; |
|
2418 |
|
})(_component2.default); |
|
2419 |
|
|
|
2420 |
|
MButton.sizes = { |
|
2421 |
|
NORMAL: 'BTN_SIZE_NORMAL', |
|
2422 |
|
SMALL: 'BTN_SIZE_SMALL', |
|
2423 |
|
LARGE: 'BTN_SIZE_LARGE' |
|
2424 |
|
}; |
|
2425 |
|
|
|
2426 |
|
exports.default = MButton; |
|
2427 |
|
|
|
2428 |
|
/***/ } |
|
2429 |
|
/******/ ]); |
File dist/app.min.js added (mode: 100644) (index 0000000..cf04e10) |
|
1 |
|
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}var o=n(1),a=r(o),i=n(17),u=r(i),l={},c=(0,a["default"])(l);window.onload=function(){(0,u["default"])(c)}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=(0,a.compose)((0,a.applyMiddleware)(u["default"]),window.devToolsExtension?window.devToolsExtension():function(e){return e})(a.createStore),n=t(c["default"],e);return n}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var a=n(2),i=n(12),u=r(i),l=n(13),c=r(l)},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}t.__esModule=!0;var o=n(3),a=r(o),i=n(5),u=r(i),l=n(9),c=r(l),s=n(10),f=r(s),d=n(11),p=r(d);t.createStore=a["default"],t.combineReducers=u["default"],t.bindActionCreators=c["default"],t.applyMiddleware=f["default"],t.compose=p["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){function n(){return c}function r(e){s.push(e);var t=!0;return function(){if(t){t=!1;var n=s.indexOf(e);s.splice(n,1)}}}function o(e){if(!i["default"](e))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if("undefined"==typeof e.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(f)throw new Error("Reducers may not dispatch actions.");try{f=!0,c=l(c,e)}finally{f=!1}return s.slice().forEach(function(e){return e()}),e}function a(e){l=e,o({type:u.INIT})}if("function"!=typeof e)throw new Error("Expected the reducer to be a function.");var l=e,c=t,s=[],f=!1;return o({type:u.INIT}),{dispatch:o,subscribe:r,getState:n,replaceReducer:a}}t.__esModule=!0,t["default"]=o;var a=n(4),i=r(a),u={INIT:"@@redux/INIT"};t.ActionTypes=u},function(e,t){"use strict";function n(e){if(!e||"object"!=typeof e)return!1;var t="function"==typeof e.constructor?Object.getPrototypeOf(e):Object.prototype;if(null===t)return!0;var n=t.constructor;return"function"==typeof n&&n instanceof n&&r(n)===o}t.__esModule=!0,t["default"]=n;var r=function(e){return Function.prototype.toString.call(e)},o=r(Object);e.exports=t["default"]},function(e,t,n){(function(r){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function a(e,t){var n=t&&t.type,r=n&&'"'+n.toString()+'"'||"an action";return'Reducer "'+e+'" returned undefined handling '+r+". To ignore an action, you must explicitly return the previous state."}function i(e,t,n){var r=Object.keys(t),o=n&&n.type===c.ActionTypes.INIT?"initialState argument passed to createStore":"previous state received by the reducer";if(0===r.length)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!f["default"](e))return"The "+o+' has unexpected type of "'+{}.toString.call(e).match(/\s([a-z|A-Z]+)/)[1]+'". Expected argument to be an object with the following '+('keys: "'+r.join('", "')+'"');var a=Object.keys(e).filter(function(e){return r.indexOf(e)<0});return a.length>0?"Unexpected "+(a.length>1?"keys":"key")+" "+('"'+a.join('", "')+'" found in '+o+". ")+"Expected to find one of the known reducer keys instead: "+('"'+r.join('", "')+'". Unexpected keys will be ignored.'):void 0}function u(e){Object.keys(e).forEach(function(t){var n=e[t],r=n(void 0,{type:c.ActionTypes.INIT});if("undefined"==typeof r)throw new Error('Reducer "'+t+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');var o="@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".");if("undefined"==typeof n(void 0,{type:o}))throw new Error('Reducer "'+t+'" returned undefined when probed with a random type. '+("Don't try to handle "+c.ActionTypes.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined.")})}function l(e){var t,n=v["default"](e,function(e){return"function"==typeof e});try{u(n)}catch(o){t=o}var l=p["default"](n,function(){});return function(e,o){if(void 0===e&&(e=l),t)throw t;var u=!1,c=p["default"](n,function(t,n){var r=e[n],i=t(r,o);if("undefined"==typeof i){var l=a(n,o);throw new Error(l)}return u=u||i!==r,i});if("production"!==r.env.NODE_ENV){var s=i(e,c,o);s&&console.error(s)}return u?c:e}}t.__esModule=!0,t["default"]=l;var c=n(3),s=n(4),f=o(s),d=n(7),p=o(d),h=n(8),v=o(h);e.exports=t["default"]}).call(t,n(6))},function(e,t){function n(){c=!1,i.length?l=i.concat(l):s=-1,l.length&&r()}function r(){if(!c){var e=setTimeout(n);c=!0;for(var t=l.length;t;){for(i=l,l=[];++s<t;)i&&i[s].run();s=-1,t=l.length}i=null,c=!1,clearTimeout(e)}}function o(e,t){this.fun=e,this.array=t}function a(){}var i,u=e.exports={},l=[],c=!1,s=-1;u.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new o(e,t)),1!==l.length||c||setTimeout(r,0)},o.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=a,u.addListener=a,u.once=a,u.off=a,u.removeListener=a,u.removeAllListeners=a,u.emit=a,u.binding=function(e){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(e){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},function(e,t){"use strict";function n(e,t){return Object.keys(e).reduce(function(n,r){return n[r]=t(e[r],r),n},{})}t.__esModule=!0,t["default"]=n,e.exports=t["default"]},function(e,t){"use strict";function n(e,t){return Object.keys(e).reduce(function(n,r){return t(e[r])&&(n[r]=e[r]),n},{})}t.__esModule=!0,t["default"]=n,e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){return function(){return t(e.apply(void 0,arguments))}}function a(e,t){if("function"==typeof e)return o(e,t);if("object"!=typeof e||null===e||void 0===e)throw new Error("bindActionCreators expected an object or a function, instead received "+(null===e?"null":typeof e)+'. Did you write "import ActionCreators from" instead of "import * as ActionCreators from"?');return u["default"](e,function(e){return o(e,t)})}t.__esModule=!0,t["default"]=a;var i=n(7),u=r(i);e.exports=t["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return function(n,r){var o=e(n,r),i=o.dispatch,l=[],c={getState:o.getState,dispatch:function(e){return i(e)}};return l=t.map(function(e){return e(c)}),i=u["default"].apply(void 0,l)(o.dispatch),a({},o,{dispatch:i})}}}t.__esModule=!0;var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};t["default"]=o;var i=n(11),u=r(i);e.exports=t["default"]},function(e,t){"use strict";function n(){for(var e=arguments.length,t=Array(e),n=0;e>n;n++)t[n]=arguments[n];return function(e){return t.reduceRight(function(e,t){return t(e)},e)}}t.__esModule=!0,t["default"]=n,e.exports=t["default"]},function(e,t){"use strict";function n(e){var t=e.dispatch,n=e.getState;return function(e){return function(r){return"function"==typeof r?r(t,n):e(r)}}}e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(2),a=n(14),i=r(a),u=n(16),l=r(u);t["default"]=(0,o.combineReducers)({rdxCounter:i["default"],rdxSimple:l["default"]})},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){switch("undefined"==typeof e&&(e={counter:0}),"undefined"==typeof e.counter&&(e.counter=0),t.type){case u["default"].COUNTER_INCREMENT:var n=a({},e,{counter:e.counter+1});return n;case u["default"].COUNTER_DECREMENT:return a({},e,{counter:e.counter-1});default:return e}}var a=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var i=n(15),u=r(i)},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n={COUNTER_INCREMENT:"COUNTER_INCREMENT",COUNTER_DECREMENT:"COUNTER_DECREMENT",TEXT_CHANGE:"TEXT_CHANGE"};t["default"]=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!e)return u;switch(t.type){case i["default"].TEXT_CHANGE:return Object.assign({},e,{text:t.text});default:return e}}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var a=n(15),i=r(a),u={text:"ZZZ"}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){var t=i["default"].component(l["default"],{data:e});i["default"].mount(document.getElementById("root"),t)}Object.defineProperty(t,"__esModule",{value:!0}),t["default"]=o;var a=n(18),i=r(a),u=n(20),l=r(u)},function(e,t,n){var r;(function(e){var o=function a(e,t){function n(e){k=e.document,M=e.location,S=e.cancelAnimationFrame||e.clearTimeout,A=e.requestAnimationFrame||e.setTimeout}function r(){var e,t=[].slice.call(arguments),n=!(null==t[1]||D.call(t[1])!==R||"tag"in t[1]||"view"in t[1]||"subtree"in t[1]),r=n?t[1]:{},o="class"in r?"class":"className",a={tag:"div",attrs:{}},i=[];if(D.call(t[0])!=L)throw new Error("selector in m(selector, attrs, children) should be a string");for(;e=U.exec(t[0]);)if(""===e[1]&&e[2])a.tag=e[2];else if("#"===e[1])a.attrs.id=e[2];else if("."===e[1])i.push(e[2]);else if("["===e[3][0]){var u=B.exec(e[3]);a.attrs[u[1]]=u[3]||(u[2]?"":!0)}var l=n?t.slice(2):t.slice(1);1===l.length&&D.call(l[0])===I?a.children=l[0]:a.children=l;for(var c in r)r.hasOwnProperty(c)&&(c===o&&null!=r[c]&&""!==r[c]?(i.push(r[c]),a.attrs[c]=""):a.attrs[c]=r[c]);return i.length>0&&(a.attrs[o]=i.join(" ")),a}function o(e,n,a,c,f,d,p,h,v,g,m){try{(null==f||null==f.toString())&&(f="")}catch(y){f=""}if("retain"===f.subtree)return d;var w=D.call(d),b=D.call(f);if(null==d||w!==b){if(null!=d)if(a&&a.nodes){var E=h-c,x=E+(b===I?f:d.nodes).length;l(a.nodes.slice(E,x),a.slice(E,x))}else d.nodes&&l(d.nodes,d);d=new f.constructor,d.tag&&(d={}),d.nodes=[]}if(b===I){for(var _=0,O=f.length;O>_;_++)D.call(f[_])===I&&(f=f.concat.apply([],f),_--,O=f.length);for(var T=[],N=d.length===f.length,j=0,C=1,M=2,A=3,S={},U=!1,_=0;_<d.length;_++)d[_]&&d[_].attrs&&null!=d[_].attrs.key&&(U=!0,S[d[_].attrs.key]={action:C,index:_});for(var B=0,_=0,O=f.length;O>_;_++)if(f[_]&&f[_].attrs&&null!=f[_].attrs.key){for(var H=0,O=f.length;O>H;H++)f[H]&&f[H].attrs&&null==f[H].attrs.key&&(f[H].attrs.key="__mithril__"+B++);break}if(U){var G=!1;if(f.length!=d.length)G=!0;else for(var q,K,_=0;q=d[_],K=f[_];_++)if(q.attrs&&K.attrs&&q.attrs.key!=K.attrs.key){G=!0;break}if(G){for(var _=0,O=f.length;O>_;_++)if(f[_]&&f[_].attrs&&null!=f[_].attrs.key){var J=f[_].attrs.key;S[J]?S[J]={action:A,index:_,from:S[J].index,element:d.nodes[S[J].index]||k.createElement("div")}:S[J]={action:M,index:_}}var Z=[];for(var F in S)Z.push(S[F]);var X=Z.sort(i),V=new Array(d.length);V.nodes=d.nodes.slice();for(var W,_=0;W=X[_];_++){if(W.action===C&&(l(d[W.index].nodes,d[W.index]),V.splice(W.index,1)),W.action===M){var Q=k.createElement("div");Q.key=f[W.index].attrs.key,e.insertBefore(Q,e.childNodes[W.index]||null),V.splice(W.index,0,{attrs:{key:f[W.index].attrs.key},nodes:[Q]}),V.nodes[W.index]=Q}W.action===A&&(e.childNodes[W.index]!==W.element&&null!==W.element&&e.insertBefore(W.element,e.childNodes[W.index]||null),V[W.index]=d[W.from],V.nodes[W.index]=W.element)}d=V}}for(var _=0,Y=0,O=f.length;O>_;_++){var te=o(e,n,d,h,f[_],d[Y],p,h+j||j,v,g,m);te!==t&&(te.nodes.intact||(N=!1),j+=te.$trusted?(te.match(/<[^\/]|\>\s*[^<]/g)||[0]).length:D.call(te)===I?te.length:1,d[Y++]=te)}if(!N){for(var _=0,O=f.length;O>_;_++)null!=d[_]&&T.push.apply(T,d[_].nodes);for(var ne,_=0;ne=d.nodes[_];_++)null!=ne.parentNode&&T.indexOf(ne)<0&&l([ne],[d[_]]);f.length<d.length&&(d.length=f.length),d.nodes=T}}else if(null!=f&&b===R){for(var oe=[],ae=[];f.view;){var ie=f.view.$original||f.view,ue="diff"==r.redraw.strategy()&&d.views?d.views.indexOf(ie):-1,le=ue>-1?d.controllers[ue]:new(f.controller||$),J=f&&f.attrs&&f.attrs.key;if(f=0==re||d&&d.controllers&&d.controllers.indexOf(le)>-1?f.view(le):{tag:"placeholder"},"retain"===f.subtree)return d;J&&(f.attrs||(f.attrs={}),f.attrs.key=J),le.onunload&&ee.push({controller:le,handler:le.onunload}),oe.push(ie),ae.push(le)}if(!f.tag&&ae.length)throw new Error("Component template must return a virtual element, not an array, string, etc.");f.attrs||(f.attrs={}),d.attrs||(d.attrs={});var ce=Object.keys(f.attrs),se=ce.length>("key"in f.attrs?1:0);if((f.tag!=d.tag||ce.sort().join()!=Object.keys(d.attrs).sort().join()||f.attrs.id!=d.attrs.id||f.attrs.key!=d.attrs.key||"all"==r.redraw.strategy()&&(!d.configContext||d.configContext.retain!==!0)||"diff"==r.redraw.strategy()&&d.configContext&&d.configContext.retain===!1)&&(d.nodes.length&&l(d.nodes),d.configContext&&typeof d.configContext.onunload===P&&d.configContext.onunload(),d.controllers))for(var le,_=0;le=d.controllers[_];_++)typeof le.onunload===P&&le.onunload({preventDefault:$});if(D.call(f.tag)!=L)return;var ne,fe=0===d.nodes.length;if(f.attrs.xmlns?g=f.attrs.xmlns:"svg"===f.tag?g="http://www.w3.org/2000/svg":"math"===f.tag&&(g="http://www.w3.org/1998/Math/MathML"),fe){if(ne=f.attrs.is?g===t?k.createElement(f.tag,f.attrs.is):k.createElementNS(g,f.tag,f.attrs.is):g===t?k.createElement(f.tag):k.createElementNS(g,f.tag),d={tag:f.tag,attrs:se?u(ne,f.tag,f.attrs,{},g):f.attrs,children:null!=f.children&&f.children.length>0?o(ne,f.tag,t,t,f.children,d.children,!0,0,f.attrs.contenteditable?ne:v,g,m):f.children,nodes:[ne]},ae.length){d.views=oe,d.controllers=ae;for(var le,_=0;le=ae[_];_++)if(le.onunload&&le.onunload.$old&&(le.onunload=le.onunload.$old),re&&le.onunload){var de=le.onunload;le.onunload=$,le.onunload.$old=de}}d.children&&!d.children.nodes&&(d.children.nodes=[]),"select"===f.tag&&"value"in f.attrs&&u(ne,f.tag,{value:f.attrs.value},{},g),e.insertBefore(ne,e.childNodes[h]||null)}else ne=d.nodes[0],se&&u(ne,f.tag,f.attrs,d.attrs,g),d.children=o(ne,f.tag,t,t,f.children,d.children,!1,0,f.attrs.contenteditable?ne:v,g,m),d.nodes.intact=!0,ae.length&&(d.views=oe,d.controllers=ae),p===!0&&null!=ne&&e.insertBefore(ne,e.childNodes[h]||null);if(typeof f.attrs.config===P){var pe=d.configContext=d.configContext||{},he=function(e,t){return function(){return e.attrs.config.apply(e,t)}};m.push(he(f,[ne,!fe,pe,d]))}}else if(typeof f!=P){var T;0===d.nodes.length?(f.$trusted?T=s(e,h,f):(T=[k.createTextNode(f)],e.nodeName.match(z)||e.insertBefore(T[0],e.childNodes[h]||null)),d="string number boolean".indexOf(typeof f)>-1?new f.constructor(f):f,d.nodes=T):d.valueOf()!==f.valueOf()||p===!0?(T=d.nodes,v&&v===k.activeElement||(f.$trusted?(l(T,d),T=s(e,h,f)):"textarea"===n?e.value=f:v?v.innerHTML=f:((1===T[0].nodeType||T.length>1)&&(l(d.nodes,d),T=[k.createTextNode(f)]),e.insertBefore(T[0],e.childNodes[h]||null),T[0].nodeValue=f)),d=new f.constructor(f),d.nodes=T):d.nodes.intact=!0}return d}function i(e,t){return e.action-t.action||e.index-t.index}function u(e,t,n,r,o){for(var a in n){var i=n[a],u=r[a];if(a in r&&u===i)"value"===a&&"input"===t&&e.value!=i&&(e.value=i);else{r[a]=i;try{if("config"===a||"key"==a)continue;if(typeof i===P&&0===a.indexOf("on"))e[a]=f(i,e);else if("style"===a&&null!=i&&D.call(i)===R){for(var l in i)(null==u||u[l]!==i[l])&&(e.style[l]=i[l]);for(var l in u)l in i||(e.style[l]="")}else null!=o?"href"===a?e.setAttributeNS("http://www.w3.org/1999/xlink","href",i):"className"===a?e.setAttribute("class",i):e.setAttribute(a,i):a in e&&"list"!==a&&"style"!==a&&"form"!==a&&"type"!==a&&"width"!==a&&"height"!==a?("input"!==t||e[a]!==i)&&(e[a]=i):e.setAttribute(a,i)}catch(c){if(c.message.indexOf("Invalid argument")<0)throw c}}}return r}function l(e,t){for(var n=e.length-1;n>-1;n--)if(e[n]&&e[n].parentNode){try{e[n].parentNode.removeChild(e[n])}catch(r){}t=[].concat(t),t[n]&&c(t[n])}0!=e.length&&(e.length=0)}function c(e){if(e.configContext&&typeof e.configContext.onunload===P&&(e.configContext.onunload(),e.configContext.onunload=null),e.controllers)for(var t,n=0;t=e.controllers[n];n++)typeof t.onunload===P&&t.onunload({preventDefault:$});if(e.children)if(D.call(e.children)===I)for(var r,n=0;r=e.children[n];n++)c(r);else e.children.tag&&c(e.children)}function s(e,t,n){var r=e.childNodes[t];if(r){var o=1!=r.nodeType,a=k.createElement("span");o?(e.insertBefore(a,r||null),a.insertAdjacentHTML("beforebegin",n),e.removeChild(a)):r.insertAdjacentHTML("beforebegin",n)}else e.insertAdjacentHTML("beforeend",n);for(var i=[];e.childNodes[t]!==r;)i.push(e.childNodes[t]),t++;return i}function f(e,t){return function(n){n=n||event,r.redraw.strategy("diff"),r.startComputation();try{return e.call(t,n)}finally{oe()}}}function d(e){var t=q.indexOf(e);return 0>t?q.push(e)-1:t}function p(e){var t=function(){return arguments.length&&(e=arguments[0]),e};return t.toJSON=function(){return e},t}function h(e,t){var n=function(){return(e.controller||$).apply(this,t)||this},r=function(n){return arguments.length>1&&(t=t.concat([].slice.call(arguments,1))),e.view.apply(e,t?[n].concat(t):[n])};r.$original=e.view;var o={controller:n,view:r};return t[0]&&null!=t[0].key&&(o.attrs={key:t[0].key}),o}function v(){Q&&(Q(),Q=null);for(var e,t=0;e=Z[t];t++)if(X[t]){var n=F[t].controller&&F[t].controller.$$args?[X[t]].concat(F[t].controller.$$args):[X[t]];r.render(e,F[t].view?F[t].view(X[t],n):"")}Y&&(Y(),Y=null),V=null,W=new Date,r.redraw.strategy("diff")}function g(e){return e.slice(ue[r.route.mode].length)}function m(e,t,n){ae={};var o=n.indexOf("?");-1!==o&&(ae=E(n.substr(o+1,n.length)),n=n.substr(0,o));var a=Object.keys(t),i=a.indexOf(n);if(-1!==i)return r.mount(e,t[a[i]]),!0;for(var u in t){if(u===n)return r.mount(e,t[u]),!0;var l=new RegExp("^"+u.replace(/:[^\/]+?\.{3}/g,"(.*?)").replace(/:[^\/]+/g,"([^\\/]+)")+"/?$");if(l.test(n))return n.replace(l,function(){for(var n=u.match(/:[^\/]+/g)||[],o=[].slice.call(arguments,1,-2),a=0,i=n.length;i>a;a++)ae[n[a].replace(/:|\./g,"")]=decodeURIComponent(o[a]);r.mount(e,t[u])}),!0}}function y(e){if(e=e||event,!e.ctrlKey&&!e.metaKey&&2!==e.which){e.preventDefault?e.preventDefault():e.returnValue=!1;for(var t=e.currentTarget||e.srcElement,n="pathname"===r.route.mode&&t.search?E(t.search.slice(1)):{};t&&"A"!=t.nodeName.toUpperCase();)t=t.parentNode;r.route(t[r.route.mode].slice(ue[r.route.mode].length),n)}}function w(){"hash"!=r.route.mode&&M.hash?M.hash=M.hash:e.scrollTo(0,0)}function b(e,n){var r={},o=[];for(var a in e){var i=n?n+"["+a+"]":a,u=e[a],l=D.call(u),c=null===u?encodeURIComponent(i):l===R?b(u,i):l===I?u.reduce(function(e,t){return r[i]||(r[i]={}),r[i][t]?e:(r[i][t]=!0,e.concat(encodeURIComponent(i)+"="+encodeURIComponent(t)))},[]).join("&"):encodeURIComponent(i)+"="+encodeURIComponent(u);u!==t&&o.push(c)}return o.join("&")}function E(e){"?"===e.charAt(0)&&(e=e.substring(1));for(var t=e.split("&"),n={},r=0,o=t.length;o>r;r++){var a=t[r].split("="),i=decodeURIComponent(a[0]),u=2==a.length?decodeURIComponent(a[1]):null;null!=n[i]?(D.call(n[i])!==I&&(n[i]=[n[i]]),n[i].push(u)):n[i]=u}return n}function x(e){var n=d(e);l(e.childNodes,K[n]),K[n]=t}function _(e,t){var n=r.prop(t);return e.then(n),n.then=function(n,r){return _(e.then(n,r),t)},n}function O(e,t){function n(e){f=e||c,p.map(function(e){f===l&&e.resolve(d)||e.reject(d)})}function o(e,t,n,o){if((null!=d&&D.call(d)===R||typeof d===P)&&typeof e===P)try{var a=0;e.call(d,function(e){a++||(d=e,t())},function(e){a++||(d=e,n())})}catch(i){r.deferred.onerror(i),d=i,n()}else o()}function a(){var c;try{c=d&&d.then}catch(p){return r.deferred.onerror(p),d=p,f=u,a()}o(c,function(){f=i,a()},function(){f=u,a()},function(){try{f===i&&typeof e===P?d=e(d):f===u&&"function"==typeof t&&(d=t(d),f=i)}catch(a){return r.deferred.onerror(a),d=a,n()}d===s?(d=TypeError(),n()):o(c,function(){n(l)},n,function(){n(f===i&&l)})})}var i=1,u=2,l=3,c=4,s=this,f=0,d=0,p=[];s.promise={},s.resolve=function(e){return f||(d=e,f=i,a()),this},s.reject=function(e){return f||(d=e,f=u,a()),this},s.promise.then=function(e,t){var n=new O(e,t);return f===l?n.resolve(d):f===c?n.reject(d):p.push(n),n.promise}}function T(e){return e}function N(n){if(!n.dataType||"jsonp"!==n.dataType.toLowerCase()){var r=new e.XMLHttpRequest;if(r.open(n.method,n.url,!0,n.user,n.password),r.onreadystatechange=function(){4===r.readyState&&(r.status>=200&&r.status<300?n.onload({type:"load",target:r}):n.onerror({type:"error",target:r}))},n.serialize===JSON.stringify&&n.data&&"GET"!==n.method&&r.setRequestHeader("Content-Type","application/json; charset=utf-8"),n.deserialize===JSON.parse&&r.setRequestHeader("Accept","application/json, text/*"),typeof n.config===P){var o=n.config(r,n);null!=o&&(r=o)}var a="GET"!==n.method&&n.data?n.data:"";if(a&&D.call(a)!=L&&a.constructor!=e.FormData)throw"Request data should be either be a string or FormData. Check the `serialize` option in `m.request`";return r.send(a),r}var i="mithril_callback_"+(new Date).getTime()+"_"+Math.round(1e16*Math.random()).toString(36),u=k.createElement("script");e[i]=function(r){u.parentNode.removeChild(u),n.onload({type:"load",target:{responseText:r}}),e[i]=t},u.onerror=function(r){return u.parentNode.removeChild(u),n.onerror({type:"error",target:{status:500,responseText:JSON.stringify({error:"Error making jsonp request"})}}),e[i]=t,!1},u.onload=function(e){return!1},u.src=n.url+(n.url.indexOf("?")>0?"&":"?")+(n.callbackKey?n.callbackKey:"callback")+"="+i+"&"+b(n.data||{}),k.body.appendChild(u)}function j(e,t,n){if("GET"===e.method&&"jsonp"!=e.dataType){var r=e.url.indexOf("?")<0?"?":"&",o=b(t);e.url=e.url+(o?r+o:"")}else e.data=n(t);return e}function C(e,t){var n=e.match(/:[a-z]\w+/gi);if(n&&t)for(var r=0;r<n.length;r++){var o=n[r].slice(1);e=e.replace(n[r],t[o]),delete t[o]}return e}var k,M,A,S,R="[object Object]",I="[object Array]",L="[object String]",P="function",D={}.toString,U=/(?:(^|#|\.)([^#\.\[\]]+))|(\[.+?\])/g,B=/\[(.+?)(?:=("|'|)(.*?)\2)?\]/,z=/^(AREA|BASE|BR|COL|COMMAND|EMBED|HR|IMG|INPUT|KEYGEN|LINK|META|PARAM|SOURCE|TRACK|WBR)$/,$=function(){};n(e);var H,G={appendChild:function(e){H===t&&(H=k.createElement("html")),k.documentElement&&k.documentElement!==e?k.replaceChild(e,k.documentElement):k.appendChild(e),this.childNodes=k.childNodes},insertBefore:function(e){this.appendChild(e)},childNodes:[]},q=[],K={};r.render=function(e,n,r){var a=[];if(!e)throw new Error("Ensure the DOM element being passed to m.route/m.mount/m.render is not undefined.");var i=d(e),u=e===k,c=u||e===k.documentElement?G:e;u&&"html"!=n.tag&&(n={tag:"html",attrs:{},children:n}),K[i]===t&&l(c.childNodes),r===!0&&x(e),K[i]=o(c,null,t,t,n,K[i],!1,0,null,t,a);for(var s=0,f=a.length;f>s;s++)a[s]()},r.trust=function(e){return e=new String(e),e.$trusted=!0,e},r.prop=function(e){return(null!=e&&D.call(e)===R||typeof e===P)&&typeof e.then===P?_(e):p(e)};var J,Z=[],F=[],X=[],V=null,W=0,Q=null,Y=null,ee=[],te=16;r.component=function(e){return h(e,[].slice.call(arguments,1))},r.mount=r.module=function(e,t){if(!e)throw new Error("Please ensure the DOM element exists before rendering a template into it.");var n=Z.indexOf(e);0>n&&(n=Z.length);for(var o,a=!1,i={preventDefault:function(){a=!0,Q=Y=null}},u=0;o=ee[u];u++)o.handler.call(o.controller,i),o.controller.onunload=null;if(a)for(var o,u=0;o=ee[u];u++)o.controller.onunload=o.handler;else ee=[];if(X[n]&&typeof X[n].onunload===P&&X[n].onunload(i),!a){r.redraw.strategy("all"),r.startComputation(),Z[n]=e,arguments.length>2&&(t=subcomponent(t,[].slice.call(arguments,2)));var l=J=t=t||{controller:function(){}},c=t.controller||$,s=new c;return l===J&&(X[n]=s,F[n]=t),oe(),X[n]}};var ne=!1;r.redraw=function(t){ne||(ne=!0,V&&t!==!0?(A===e.requestAnimationFrame||new Date-W>te)&&(V>0&&S(V),V=A(v,te)):(v(),V=A(function(){V=null},te)),ne=!1)},r.redraw.strategy=r.prop();var re=0;r.startComputation=function(){re++},r.endComputation=function(){re=Math.max(re-1,0),0===re&&r.redraw()};var oe=function(){"none"==r.redraw.strategy()?(re--,r.redraw.strategy("diff")):r.endComputation()};r.withAttr=function(e,t){return function(n){n=n||event;var r=n.currentTarget||this;t(e in r?r[e]:r.getAttribute(e))}};var ae,ie,ue={pathname:"",hash:"#",search:"?"},le=$,ce=!1;return r.route=function(){if(0===arguments.length)return ie;if(3===arguments.length&&D.call(arguments[1])===L){var t=arguments[0],n=arguments[1],o=arguments[2];le=function(e){var a=ie=g(e);if(!m(t,o,a)){if(ce)throw new Error("Ensure the default route matches one of the routes defined in m.route");ce=!0,r.route(n,!0),ce=!1}};var a="hash"===r.route.mode?"onhashchange":"onpopstate";e[a]=function(){var e=M[r.route.mode];"pathname"===r.route.mode&&(e+=M.search),ie!=g(e)&&le(e)},Q=w,e[a]()}else if(arguments[0].addEventListener||arguments[0].attachEvent){var i=arguments[0],u=(arguments[1],arguments[2],arguments[3]);i.href=("pathname"!==r.route.mode?M.pathname:"")+ue[r.route.mode]+u.attrs.href,i.addEventListener?(i.removeEventListener("click",y),i.addEventListener("click",y)):(i.detachEvent("onclick",y),i.attachEvent("onclick",y))}else if(D.call(arguments[0])===L){var l=ie;ie=arguments[0];var c=arguments[1]||{},s=ie.indexOf("?"),f=s>-1?E(ie.slice(s+1)):{};for(var d in c)f[d]=c[d];var p=b(f),h=s>-1?ie.slice(0,s):ie;p&&(ie=h+(-1===h.indexOf("?")?"?":"&")+p);var v=(3===arguments.length?arguments[2]:arguments[1])===!0||l===arguments[0];e.history.pushState?(Q=w,Y=function(){e.history[v?"replaceState":"pushState"](null,k.title,ue[r.route.mode]+ie)},le(ue[r.route.mode]+ie)):(M[r.route.mode]=ie,le(ue[r.route.mode]+ie))}},r.route.param=function(e){if(!ae)throw new Error("You must call m.route(element, defaultRoute, routes) before calling m.route.param()");return ae[e]},r.route.mode="search",r.route.buildQueryString=b,r.route.parseQueryString=E,r.deferred=function(){var e=new O;return e.promise=_(e.promise),e},r.deferred.onerror=function(e){if("[object Error]"===D.call(e)&&!e.constructor.toString().match(/ Error/))throw e},r.sync=function(e){function t(e,t){return function(r){return i[e]=r,t||(n="reject"),0===--a&&(o.promise(i),o[n](i)),r}}var n="resolve",o=r.deferred(),a=e.length,i=new Array(a);if(e.length>0)for(var u=0;u<e.length;u++)e[u].then(t(u,!0),t(u,!1));else o.resolve([]);return o.promise},r.request=function(e){e.background!==!0&&r.startComputation();var t=new O,n=e.dataType&&"jsonp"===e.dataType.toLowerCase(),o=e.serialize=n?T:e.serialize||JSON.stringify,a=e.deserialize=n?T:e.deserialize||JSON.parse,i=n?function(e){return e.responseText}:e.extract||function(e){return 0===e.responseText.length&&a===JSON.parse?null:e.responseText};return e.method=(e.method||"GET").toUpperCase(),e.url=C(e.url,e.data),e=j(e,e.data,o),e.onload=e.onerror=function(n){try{n=n||event;var o=("load"===n.type?e.unwrapSuccess:e.unwrapError)||T,u=o(a(i(n.target,e)),n.target);if("load"===n.type)if(D.call(u)===I&&e.type)for(var l=0;l<u.length;l++)u[l]=new e.type(u[l]);else e.type&&(u=new e.type(u));t["load"===n.type?"resolve":"reject"](u)}catch(n){r.deferred.onerror(n),t.reject(n)}e.background!==!0&&r.endComputation()},N(e),t.promise=_(t.promise,e.initialValue),t.promise},r.deps=function(t){return n(e=t||e),e},r.deps.factory=a,r}("undefined"!=typeof window?window:{});"undefined"!=typeof e&&null!==e&&e.exports?e.exports=o:(r=function(){return o}.call(t,n,t,e),!(void 0!==r&&(e.exports=r)))}).call(t,n(19)(e))},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(18),a=r(o),i=n(21),u=r(i),l=n(22),c=r(l),s={};s.controller=function(e){this.store=e.data,this.mSimple=new c["default"]},s.view=function(e){return(0,a["default"])("div",[a["default"].component(u["default"],{data:e.store}),a["default"].component(e.mSimple.m(),{data:e.store})])},t["default"]=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(18),a=r(o),i={controller:function(e){var t=this;this.store=e.data,this.count=e.data.getState().counter,this.increment=function(){console.log(t.store),t.store.dispatch({type:"INCREMENT"})},this.decrement=function(){t.store.dispatch({type:"DECREMENT"})},e.data.subscribe(function(){t.count=t.store.getState().counter})},view:function(e){return(0,a["default"])("div",[(0,a["default"])("span",e.count),(0,a["default"])("br"),(0,a["default"])("button",{onclick:e.increment},"+"),(0,a["default"])("button",{onclick:e.decrement},"-")])}};t["default"]=i},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n(18),c=r(l),s=n(23),f=r(s),d=n(24),p=r(d),h=function(e){function t(){return o(this,t),a(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),u(t,[{key:"controller",value:function(e){this.store=e.data,this.mBtnTest=new p["default"]({tag:"a",label:"Initial Label",size:p["default"].sizes.SMALL})}},{key:"view",value:function(e,t){var n=this.store.getState();return(0,c["default"])(".test",[(0,c["default"])("h1","Hello World !"),(0,c["default"])("p",n.text),(0,c["default"])("button",{onclick:this.clickText},"What time is it ?"),c["default"].component(this.mBtnTest.m(),{label:"Changed Label"})])}},{key:"clickText",value:function(e){e.preventDefault(),this.store.dispatch({type:appActions.TEXT_CHANGE,text:"It's currently: "+(new Date).toTimeString()})}}]),t}(f["default"]);t["default"]=h},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(t){n(this,e),this.options={};var r=this;r.options=Object.assign({},this.options,t),r.mithril={controller:function(){r.controller.apply(r,arguments)},view:function(){return r.view.apply(r,arguments)}}}return r(e,[{key:"reducer",value:function(e){throw TypeError('Method "reducer" should be overriden in children')}},{key:"controller",value:function(e){}},{key:"view",value:function(e){return[]}},{key:"m",value:function(){return this.mithril}}]),e}();t["default"]=o},function(e,t,n){"use strict";function r(e){ |
|
2 |
|
return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function a(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}var u=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();Object.defineProperty(t,"__esModule",{value:!0});var l=n(23),c=r(l),s=n(18),f=r(s),d=function(e){function t(e){o(this,t);var n=a(this,Object.getPrototypeOf(t).call(this,e));return n.options={tag:"button",label:"Button",size:t.sizes.NORMAL},n}return i(t,e),u(t,[{key:"controller",value:function(e){var t=Object.assign({},this.options,e);this.theme=f["default"].prop(),this.size=f["default"].prop(t.size),this.tag=f["default"].prop(t.tag),this.label=f["default"].prop(t.label)}},{key:"view",value:function(e,t){return(0,f["default"])(this.tag(),this.label())}}]),t}(c["default"]);d.sizes={NORMAL:"BTN_SIZE_NORMAL",SMALL:"BTN_SIZE_SMALL",LARGE:"BTN_SIZE_LARGE"},t["default"]=d}]); |