UNPKG

ractive-ez-tabs

Version:
1,878 lines (1,507 loc) 497 kB
/******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // identity function for calling harmony imports with the correct context /******/ __webpack_require__.i = function(value) { return value; }; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { /******/ configurable: false, /******/ enumerable: true, /******/ get: getter /******/ }); /******/ } /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = 5); /******/ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* WEBPACK VAR INJECTION */(function(global) {/* Ractive.js v0.9.9 Build: 45f61d837bf610970e0bd6591c98587cfd49a024 Date: Thu Nov 02 2017 20:19:45 GMT+0000 (UTC) Website: http://ractivejs.org License: MIT */ /* istanbul ignore if */ if (!Object.assign) { Object.assign = function (target) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); } var to = Object(target); var sourcesLength = sources.length; for (var index = 0; index < sourcesLength; index++) { var nextSource = sources[index]; for (var nextKey in nextSource) { if (!Object.prototype.hasOwnProperty.call(nextSource, nextKey)) { continue; } to[nextKey] = nextSource[nextKey]; } } return to; }; } function hasOwn ( obj, prop ) { return Object.prototype.hasOwnProperty.call( obj, prop ); } function fillGaps ( target ) { var sources = [], len = arguments.length - 1; while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ]; for (var i = 0; i < sources.length; i++){ var source = sources[i]; for ( var key in source ) { // Source can be a prototype-less object. if ( key in target || !hasOwn( source, key ) ) { continue; } target[ key ] = source[ key ]; } } return target; } function toPairs ( obj ) { if ( obj === void 0 ) obj = {}; var pairs = []; for ( var key in obj ) { // Source can be a prototype-less object. if ( !hasOwn( obj, key ) ) { continue; } pairs.push( [ key, obj[ key ] ] ); } return pairs; } var obj$1 = Object; var assign = obj$1.assign; var create = obj$1.create; var defineProperty = obj$1.defineProperty; var defineProperties = obj$1.defineProperties; var keys = obj$1.keys; var toString = Object.prototype.toString; var isArray = Array.isArray; function isEqual ( a, b ) { if ( a === null && b === null ) { return true; } if ( isObjectType( a ) || isObjectType( b ) ) { return false; } return a === b; } // http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric function isNumeric ( thing ) { return !isNaN( parseFloat( thing ) ) && isFinite( thing ); } function isObject ( thing ) { return ( thing && toString.call( thing ) === '[object Object]' ); } function isObjectLike ( thing ) { return !!( thing && ( isObjectType( thing ) || isFunction( thing ) ) ); } function isObjectType ( thing ) { return typeof thing === 'object'; } function isFunction ( thing ) { return typeof thing === 'function'; } function isString ( thing ) { return typeof thing === 'string'; } function isNumber ( thing ) { return typeof thing === 'number'; } /* istanbul ignore if */ if (!Array.prototype.find) { defineProperty( Array.prototype, 'find', { value: function value (callback, thisArg) { if (this === null || this === undefined) { throw new TypeError('Array.prototype.find called on null or undefined'); } if (!isFunction( callback )) { throw new TypeError((callback + " is not a function")); } var array = Object(this); var arrayLength = array.length >>> 0; for (var index = 0; index < arrayLength; index++) { if (!hasOwn(array, index)) { continue; } if (!callback.call(thisArg, array[index], index, array)) { continue; } return array[index]; } return undefined; }, configurable: true, writable: true }); } // NOTE: Node doesn't exist in IE8. Nothing can be done. /* istanbul ignore if */ if (typeof window !== 'undefined' && window.Node && window.Node.prototype && !window.Node.prototype.contains) { Node.prototype.contains = function (node) { var this$1 = this; if (!node) { throw new TypeError('node required'); } do { if (this$1 === node) { return true; } } while (node = node && node.parentNode); return false; }; } /* istanbul ignore if */ if (typeof window !== 'undefined' && window.performance && !window.performance.now) { window.performance = window.performance || {}; var nowOffset = Date.now(); window.performance.now = function () { return Date.now() - nowOffset; }; } /* istanbul ignore if */ if (typeof window !== 'undefined' && !window.Promise) { var PENDING = {}; var FULFILLED = {}; var REJECTED = {}; var Promise$1 = window.Promise = function (callback) { var fulfilledHandlers = []; var rejectedHandlers = []; var state = PENDING; var result; var dispatchHandlers; var makeResolver = function (newState) { return function (value) { if (state !== PENDING) { return; } result = value; state = newState; dispatchHandlers = makeDispatcher((state === FULFILLED ? fulfilledHandlers : rejectedHandlers), result); wait(dispatchHandlers); }; }; var fulfill = makeResolver(FULFILLED); var reject = makeResolver(REJECTED); try { callback(fulfill, reject); } catch (err) { reject(err); } return { // `then()` returns a Promise - 2.2.7 then: function then(onFulfilled, onRejected) { var promise2 = new Promise$1(function (fulfill, reject) { var processResolutionHandler = function (handler, handlers, forward) { if (isFunction( handler )) { handlers.push(function (p1result) { try { resolve$1(promise2, handler(p1result), fulfill, reject); } catch (err) { reject(err); } }); } else { handlers.push(forward); } }; processResolutionHandler(onFulfilled, fulfilledHandlers, fulfill); processResolutionHandler(onRejected, rejectedHandlers, reject); if (state !== PENDING) { wait(dispatchHandlers); } }); return promise2; }, 'catch': function catch$1(onRejected) { return this.then(null, onRejected); } }; }; Promise$1.all = function (promises) { return new Promise$1(function (fulfil, reject) { var result = []; var pending; var i; if (!promises.length) { fulfil(result); return; } var processPromise = function (promise, i) { if (promise && isFunction( promise.then )) { promise.then(function (value) { result[i] = value; --pending || fulfil(result); }, reject); } else { result[i] = promise; --pending || fulfil(result); } }; pending = i = promises.length; while (i--) { processPromise(promises[i], i); } }); }; Promise$1.resolve = function (value) { return new Promise$1(function (fulfill) { fulfill(value); }); }; Promise$1.reject = function (reason) { return new Promise$1(function (fulfill, reject) { reject(reason); }); }; // TODO use MutationObservers or something to simulate setImmediate var wait = function (callback) { setTimeout(callback, 0); }; var makeDispatcher = function (handlers, result) { return function () { for (var handler = (void 0); handler = handlers.shift();) { handler(result); } }; }; var resolve$1 = function (promise, x, fulfil, reject) { var then; if (x === promise) { throw new TypeError("A promise's fulfillment handler cannot return the same promise"); } if (x instanceof Promise$1) { x.then(fulfil, reject); } else if (x && (isObjectType( x ) || isFunction( x ))) { try { then = x.then; } catch (e) { reject(e); return; } if (isFunction( then )) { var called; var resolvePromise = function (y) { if (called) { return; } called = true; resolve$1(promise, y, fulfil, reject); }; var rejectPromise = function (r) { if (called) { return; } called = true; reject(r); }; try { then.call(x, resolvePromise, rejectPromise); } catch (e) { if (!called) { reject(e); called = true; return; } } } else { fulfil(x); } } else { fulfil(x); } }; } /* istanbul ignore if */ if (typeof window !== 'undefined' && !(window.requestAnimationFrame && window.cancelAnimationFrame)) { var lastTime = 0; window.requestAnimationFrame = function (callback) { var currentTime = Date.now(); var timeToNextCall = Math.max(0, 16 - (currentTime - lastTime)); var id = window.setTimeout(function () { callback(currentTime + timeToNextCall); }, timeToNextCall); lastTime = currentTime + timeToNextCall; return id; }; window.cancelAnimationFrame = function (id) { clearTimeout(id); }; } var defaults = { // render placement: el: void 0, append: false, delegate: true, // template: template: null, // parse: delimiters: [ '{{', '}}' ], tripleDelimiters: [ '{{{', '}}}' ], staticDelimiters: [ '[[', ']]' ], staticTripleDelimiters: [ '[[[', ']]]' ], csp: true, interpolate: false, preserveWhitespace: false, sanitize: false, stripComments: true, contextLines: 0, // data & binding: data: {}, computed: {}, syncComputedChildren: false, resolveInstanceMembers: true, warnAboutAmbiguity: false, adapt: [], isolated: true, twoway: true, lazy: false, // transitions: noIntro: false, noOutro: false, transitionsEnabled: true, complete: void 0, nestedTransitions: true, // css: css: null, noCssTransform: false }; // These are a subset of the easing equations found at // https://raw.github.com/danro/easing-js - license info // follows: // -------------------------------------------------- // easing.js v0.5.4 // Generic set of easing functions with AMD support // https://github.com/danro/easing-js // This code may be freely distributed under the MIT license // http://danro.mit-license.org/ // -------------------------------------------------- // All functions adapted from Thomas Fuchs & Jeremy Kahn // Easing Equations (c) 2003 Robert Penner, BSD license // https://raw.github.com/danro/easing-js/master/LICENSE // -------------------------------------------------- // In that library, the functions named easeIn, easeOut, and // easeInOut below are named easeInCubic, easeOutCubic, and // (you guessed it) easeInOutCubic. // // You can add additional easing functions to this list, and they // will be globally available. var easing = { linear: function linear ( pos ) { return pos; }, easeIn: function easeIn ( pos ) { /* istanbul ignore next */ return Math.pow( pos, 3 ); }, easeOut: function easeOut ( pos ) { return ( Math.pow( ( pos - 1 ), 3 ) + 1 ); }, easeInOut: function easeInOut ( pos ) { /* istanbul ignore next */ if ( ( pos /= 0.5 ) < 1 ) { return ( 0.5 * Math.pow( pos, 3 ) ); } /* istanbul ignore next */ return ( 0.5 * ( Math.pow( ( pos - 2 ), 3 ) + 2 ) ); } }; /* eslint no-console:"off" */ var win = typeof window !== 'undefined' ? window : null; var doc = win ? document : null; var isClient = !!doc; var hasConsole = ( typeof console !== 'undefined' && isFunction( console.warn ) && isFunction( console.warn.apply ) ); var svg = doc ? doc.implementation.hasFeature( 'http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1' ) : false; var vendors = [ 'o', 'ms', 'moz', 'webkit' ]; var noop = function () {}; /* global console */ /* eslint no-console:"off" */ var alreadyWarned = {}; var log; var printWarning; var welcome; if ( hasConsole ) { var welcomeIntro = [ "%cRactive.js %c0.9.9 %cin debug mode, %cmore...", 'color: rgb(114, 157, 52); font-weight: normal;', 'color: rgb(85, 85, 85); font-weight: normal;', 'color: rgb(85, 85, 85); font-weight: normal;', 'color: rgb(82, 140, 224); font-weight: normal; text-decoration: underline;' ]; var welcomeMessage = "You're running Ractive 0.9.9 in debug mode - messages will be printed to the console to help you fix problems and optimise your application.\n\nTo disable debug mode, add this line at the start of your app:\n Ractive.DEBUG = false;\n\nTo disable debug mode when your app is minified, add this snippet:\n Ractive.DEBUG = /unminified/.test(function(){/*unminified*/});\n\nGet help and support:\n http://ractive.js.org\n http://stackoverflow.com/questions/tagged/ractivejs\n http://groups.google.com/forum/#!forum/ractive-js\n http://twitter.com/ractivejs\n\nFound a bug? Raise an issue:\n https://github.com/ractivejs/ractive/issues\n\n"; welcome = function () { if ( Ractive.WELCOME_MESSAGE === false ) { welcome = noop; return; } var message = 'WELCOME_MESSAGE' in Ractive ? Ractive.WELCOME_MESSAGE : welcomeMessage; var hasGroup = !!console.groupCollapsed; if ( hasGroup ) { console.groupCollapsed.apply( console, welcomeIntro ); } console.log( message ); if ( hasGroup ) { console.groupEnd( welcomeIntro ); } welcome = noop; }; printWarning = function ( message, args ) { welcome(); // extract information about the instance this message pertains to, if applicable if ( isObjectType( args[ args.length - 1 ] ) ) { var options = args.pop(); var ractive = options ? options.ractive : null; if ( ractive ) { // if this is an instance of a component that we know the name of, add // it to the message var name; if ( ractive.component && ( name = ractive.component.name ) ) { message = "<" + name + "> " + message; } var node; if ( node = ( options.node || ( ractive.fragment && ractive.fragment.rendered && ractive.find( '*' ) ) ) ) { args.push( node ); } } } console.warn.apply( console, [ '%cRactive.js: %c' + message, 'color: rgb(114, 157, 52);', 'color: rgb(85, 85, 85);' ].concat( args ) ); }; log = function () { console.log.apply( console, arguments ); }; } else { printWarning = log = welcome = noop; } function format ( message, args ) { return message.replace( /%s/g, function () { return args.shift(); } ); } function fatal ( message ) { var args = [], len = arguments.length - 1; while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; message = format( message, args ); throw new Error( message ); } function logIfDebug () { if ( Ractive.DEBUG ) { log.apply( null, arguments ); } } function warn ( message ) { var args = [], len = arguments.length - 1; while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; message = format( message, args ); printWarning( message, args ); } function warnOnce ( message ) { var args = [], len = arguments.length - 1; while ( len-- > 0 ) args[ len ] = arguments[ len + 1 ]; message = format( message, args ); if ( alreadyWarned[ message ] ) { return; } alreadyWarned[ message ] = true; printWarning( message, args ); } function warnIfDebug () { if ( Ractive.DEBUG ) { warn.apply( null, arguments ); } } function warnOnceIfDebug () { if ( Ractive.DEBUG ) { warnOnce.apply( null, arguments ); } } // Error messages that are used (or could be) in multiple places var badArguments = 'Bad arguments'; var noRegistryFunctionReturn = 'A function was specified for "%s" %s, but no %s was returned'; var missingPlugin = function ( name, type ) { return ("Missing \"" + name + "\" " + type + " plugin. You may need to download a plugin via http://ractive.js.org/integrations/#" + type + "s"); }; function findInViewHierarchy ( registryName, ractive, name ) { var instance = findInstance( registryName, ractive, name ); return instance ? instance[ registryName ][ name ] : null; } function findInstance ( registryName, ractive, name ) { while ( ractive ) { if ( name in ractive[ registryName ] ) { return ractive; } if ( ractive.isolated ) { return null; } ractive = ractive.parent; } } function interpolate ( from, to, ractive, type ) { if ( from === to ) { return null; } if ( type ) { var interpol = findInViewHierarchy( 'interpolators', ractive, type ); if ( interpol ) { return interpol( from, to ) || null; } fatal( missingPlugin( type, 'interpolator' ) ); } return interpolators.number( from, to ) || interpolators.array( from, to ) || interpolators.object( from, to ) || null; } var interpolators = { number: function number ( from, to ) { if ( !isNumeric( from ) || !isNumeric( to ) ) { return null; } from = +from; to = +to; var delta = to - from; if ( !delta ) { return function () { return from; }; } return function ( t ) { return from + ( t * delta ); }; }, array: function array ( from, to ) { var len, i; if ( !isArray( from ) || !isArray( to ) ) { return null; } var intermediate = []; var interpolators = []; i = len = Math.min( from.length, to.length ); while ( i-- ) { interpolators[i] = interpolate( from[i], to[i] ); } // surplus values - don't interpolate, but don't exclude them either for ( i=len; i<from.length; i+=1 ) { intermediate[i] = from[i]; } for ( i=len; i<to.length; i+=1 ) { intermediate[i] = to[i]; } return function ( t ) { var i = len; while ( i-- ) { intermediate[i] = interpolators[i]( t ); } return intermediate; }; }, object: function object ( from, to ) { if ( !isObject( from ) || !isObject( to ) ) { return null; } var properties = []; var intermediate = {}; var interpolators = {}; var loop = function ( prop ) { if ( hasOwn( from, prop ) ) { if ( hasOwn( to, prop ) ) { properties.push( prop ); interpolators[ prop ] = interpolate( from[ prop ], to[ prop ] ) || ( function () { return to[ prop ]; } ); } else { intermediate[ prop ] = from[ prop ]; } } }; for ( var prop in from ) loop( prop ); for ( var prop$1 in to ) { if ( hasOwn( to, prop$1 ) && !hasOwn( from, prop$1 ) ) { intermediate[ prop$1 ] = to[ prop$1 ]; } } var len = properties.length; return function ( t ) { var i = len; while ( i-- ) { var prop = properties[i]; intermediate[ prop ] = interpolators[ prop ]( t ); } return intermediate; }; } }; var refPattern = /\[\s*(\*|[0-9]|[1-9][0-9]+)\s*\]/g; var splitPattern = /([^\\](?:\\\\)*)\./; var escapeKeyPattern = /\\|\./g; var unescapeKeyPattern = /((?:\\)+)\1|\\(\.)/g; function escapeKey ( key ) { if ( isString( key ) ) { return key.replace( escapeKeyPattern, '\\$&' ); } return key; } function normalise ( ref ) { return ref ? ref.replace( refPattern, '.$1' ) : ''; } function splitKeypath ( keypath ) { var result = []; var match; keypath = normalise( keypath ); while ( match = splitPattern.exec( keypath ) ) { var index = match.index + match[1].length; result.push( keypath.substr( 0, index ) ); keypath = keypath.substr( index + 1 ); } result.push( keypath ); return result; } function unescapeKey ( key ) { if ( isString( key ) ) { return key.replace( unescapeKeyPattern, '$1$2' ); } return key; } function addToArray ( array, value ) { var index = array.indexOf( value ); if ( index === -1 ) { array.push( value ); } } function arrayContains ( array, value ) { for ( var i = 0, c = array.length; i < c; i++ ) { if ( array[i] == value ) { return true; } } return false; } function arrayContentsMatch ( a, b ) { var i; if ( !isArray( a ) || !isArray( b ) ) { return false; } if ( a.length !== b.length ) { return false; } i = a.length; while ( i-- ) { if ( a[i] !== b[i] ) { return false; } } return true; } function ensureArray ( x ) { if ( isString( x ) ) { return [ x ]; } if ( x === undefined ) { return []; } return x; } function lastItem ( array ) { return array[ array.length - 1 ]; } function removeFromArray ( array, member ) { if ( !array ) { return; } var index = array.indexOf( member ); if ( index !== -1 ) { array.splice( index, 1 ); } } function combine () { var arrays = [], len = arguments.length; while ( len-- ) arrays[ len ] = arguments[ len ]; var res = arrays.concat.apply( [], arrays ); var i = res.length; while ( i-- ) { var idx = res.indexOf( res[i] ); if ( ~idx && idx < i ) { res.splice( i, 1 ); } } return res; } function toArray ( arrayLike ) { var array = []; var i = arrayLike.length; while ( i-- ) { array[i] = arrayLike[i]; } return array; } function findMap ( array, fn ) { var len = array.length; for ( var i = 0; i < len; i++ ) { var result = fn( array[i] ); if ( result ) { return result; } } } var stack = []; var captureGroup; function startCapturing () { stack.push( captureGroup = [] ); } function stopCapturing () { var dependencies = stack.pop(); captureGroup = stack[ stack.length - 1 ]; return dependencies; } function capture ( model ) { if ( captureGroup ) { captureGroup.push( model ); } } var KeyModel = function KeyModel ( key, parent ) { this.value = key; this.isReadonly = this.isKey = true; this.deps = []; this.links = []; this.parent = parent; }; var KeyModel__proto__ = KeyModel.prototype; KeyModel__proto__.get = function get ( shouldCapture ) { if ( shouldCapture ) { capture( this ); } return unescapeKey( this.value ); }; KeyModel__proto__.getKeypath = function getKeypath () { return unescapeKey( this.value ); }; KeyModel__proto__.rebind = function rebind ( next, previous ) { var this$1 = this; var i = this.deps.length; while ( i-- ) { this$1.deps[i].rebind( next, previous, false ); } i = this.links.length; while ( i-- ) { this$1.links[i].relinking( next, false ); } }; KeyModel__proto__.register = function register ( dependant ) { this.deps.push( dependant ); }; KeyModel__proto__.registerLink = function registerLink ( link ) { addToArray( this.links, link ); }; KeyModel__proto__.unregister = function unregister ( dependant ) { removeFromArray( this.deps, dependant ); }; KeyModel__proto__.unregisterLink = function unregisterLink ( link ) { removeFromArray( this.links, link ); }; KeyModel.prototype.reference = noop; KeyModel.prototype.unreference = noop; function bind ( x ) { x.bind(); } function cancel ( x ) { x.cancel(); } function destroyed ( x ) { x.destroyed(); } function handleChange ( x ) { x.handleChange(); } function mark ( x ) { x.mark(); } function markForce ( x ) { x.mark( true ); } function marked ( x ) { x.marked(); } function markedAll ( x ) { x.markedAll(); } function render ( x ) { x.render(); } function shuffled ( x ) { x.shuffled(); } function teardown ( x ) { x.teardown(); } function unbind ( x ) { x.unbind(); } function unrender ( x ) { x.unrender(); } function unrenderAndDestroy ( x ) { x.unrender( true ); } function update ( x ) { x.update(); } function toString$1 ( x ) { return x.toString(); } function toEscapedString ( x ) { return x.toString( true ); } var KeypathModel = function KeypathModel ( parent, ractive ) { this.parent = parent; this.ractive = ractive; this.value = ractive ? parent.getKeypath( ractive ) : parent.getKeypath(); this.deps = []; this.children = {}; this.isReadonly = this.isKeypath = true; }; var KeypathModel__proto__ = KeypathModel.prototype; KeypathModel__proto__.get = function get ( shouldCapture ) { if ( shouldCapture ) { capture( this ); } return this.value; }; KeypathModel__proto__.getChild = function getChild ( ractive ) { if ( !( ractive._guid in this.children ) ) { var model = new KeypathModel( this.parent, ractive ); this.children[ ractive._guid ] = model; model.owner = this; } return this.children[ ractive._guid ]; }; KeypathModel__proto__.getKeypath = function getKeypath () { return this.value; }; KeypathModel__proto__.handleChange = function handleChange$1 () { var this$1 = this; var keys$$1 = keys( this.children ); var i = keys$$1.length; while ( i-- ) { this$1.children[ keys$$1[i] ].handleChange(); } this.deps.forEach( handleChange ); }; KeypathModel__proto__.rebindChildren = function rebindChildren ( next ) { var this$1 = this; var keys$$1 = keys( this.children ); var i = keys$$1.length; while ( i-- ) { var child = this$1.children[keys$$1[i]]; child.value = next.getKeypath( child.ractive ); child.handleChange(); } }; KeypathModel__proto__.rebind = function rebind ( next, previous ) { var this$1 = this; var model = next ? next.getKeypathModel( this.ractive ) : undefined; var keys$$1 = keys( this.children ); var i = keys$$1.length; while ( i-- ) { this$1.children[ keys$$1[i] ].rebind( next, previous, false ); } i = this.deps.length; while ( i-- ) { this$1.deps[i].rebind( model, this$1, false ); } }; KeypathModel__proto__.register = function register ( dep ) { this.deps.push( dep ); }; KeypathModel__proto__.removeChild = function removeChild ( model ) { if ( model.ractive ) { delete this.children[ model.ractive._guid ]; } }; KeypathModel__proto__.teardown = function teardown () { var this$1 = this; if ( this.owner ) { this.owner.removeChild( this ); } var keys$$1 = keys( this.children ); var i = keys$$1.length; while ( i-- ) { this$1.children[ keys$$1[i] ].teardown(); } }; KeypathModel__proto__.unregister = function unregister ( dep ) { removeFromArray( this.deps, dep ); if ( !this.deps.length ) { this.teardown(); } }; KeypathModel.prototype.reference = noop; KeypathModel.prototype.unreference = noop; var fnBind = Function.prototype.bind; function bind$1 ( fn, context ) { if ( !/this/.test( fn.toString() ) ) { return fn; } var bound = fnBind.call( fn, context ); for ( var prop in fn ) { bound[ prop ] = fn[ prop ]; } return bound; } var shuffleTasks = { early: [], mark: [] }; var registerQueue = { early: [], mark: [] }; var ModelBase = function ModelBase ( parent ) { this.deps = []; this.children = []; this.childByKey = {}; this.links = []; this.keyModels = {}; this.bindings = []; this.patternObservers = []; if ( parent ) { this.parent = parent; this.root = parent.root; } }; var ModelBase__proto__ = ModelBase.prototype; ModelBase__proto__.addShuffleTask = function addShuffleTask ( task, stage ) { if ( stage === void 0 ) stage = 'early'; shuffleTasks[stage].push( task ); }; ModelBase__proto__.addShuffleRegister = function addShuffleRegister ( item, stage ) { if ( stage === void 0 ) stage = 'early'; registerQueue[stage].push({ model: this, item: item }); }; ModelBase__proto__.downstreamChanged = function downstreamChanged () {}; ModelBase__proto__.findMatches = function findMatches ( keys$$1 ) { var len = keys$$1.length; var existingMatches = [ this ]; var matches; var i; var loop = function ( ) { var key = keys$$1[i]; if ( key === '*' ) { matches = []; existingMatches.forEach( function (model) { matches.push.apply( matches, model.getValueChildren( model.get() ) ); }); } else { matches = existingMatches.map( function (model) { return model.joinKey( key ); } ); } existingMatches = matches; }; for ( i = 0; i < len; i += 1 ) loop( ); return matches; }; ModelBase__proto__.getKeyModel = function getKeyModel ( key, skip ) { if ( key !== undefined && !skip ) { return this.parent.getKeyModel( key, true ); } if ( !( key in this.keyModels ) ) { this.keyModels[ key ] = new KeyModel( escapeKey( key ), this ); } return this.keyModels[ key ]; }; ModelBase__proto__.getKeypath = function getKeypath ( ractive ) { if ( ractive !== this.ractive && this._link ) { return this._link.target.getKeypath( ractive ); } if ( !this.keypath ) { var parent = this.parent && this.parent.getKeypath( ractive ); this.keypath = parent ? ((this.parent.getKeypath( ractive )) + "." + (escapeKey( this.key ))) : escapeKey( this.key ); } return this.keypath; }; ModelBase__proto__.getValueChildren = function getValueChildren ( value ) { var this$1 = this; var children; if ( isArray( value ) ) { children = []; if ( 'length' in this && this.length !== value.length ) { children.push( this.joinKey( 'length' ) ); } value.forEach( function ( m, i ) { children.push( this$1.joinKey( i ) ); }); } else if ( isObject( value ) || isFunction( value ) ) { children = keys( value ).map( function (key) { return this$1.joinKey( key ); } ); } else if ( value != null ) { return []; } return children; }; ModelBase__proto__.getVirtual = function getVirtual ( shouldCapture ) { var this$1 = this; var value = this.get( shouldCapture, { virtual: false } ); if ( isObject( value ) ) { var result = isArray( value ) ? [] : {}; var keys$$1 = keys( value ); var i = keys$$1.length; while ( i-- ) { var child = this$1.childByKey[ keys$$1[i] ]; if ( !child ) { result[ keys$$1[i] ] = value[ keys$$1[i] ]; } else if ( child._link ) { result[ keys$$1[i] ] = child._link.getVirtual(); } else { result[ keys$$1[i] ] = child.getVirtual(); } } i = this.children.length; while ( i-- ) { var child$1 = this$1.children[i]; if ( !( child$1.key in result ) && child$1._link ) { result[ child$1.key ] = child$1._link.getVirtual(); } } return result; } else { return value; } }; ModelBase__proto__.has = function has ( key ) { if ( this._link ) { return this._link.has( key ); } var value = this.get(); if ( !value ) { return false; } key = unescapeKey( key ); if ( hasOwn( value, key ) ) { return true; } // We climb up the constructor chain to find if one of them contains the key var constructor = value.constructor; while ( constructor !== Function && constructor !== Array && constructor !== Object ) { if ( hasOwn( constructor.prototype, key ) ) { return true; } constructor = constructor.constructor; } return false; }; ModelBase__proto__.joinAll = function joinAll ( keys$$1, opts ) { var model = this; for ( var i = 0; i < keys$$1.length; i += 1 ) { if ( opts && opts.lastLink === false && i + 1 === keys$$1.length && model.childByKey[keys$$1[i]] && model.childByKey[keys$$1[i]]._link ) { return model.childByKey[keys$$1[i]]; } model = model.joinKey( keys$$1[i], opts ); } return model; }; ModelBase__proto__.notifyUpstream = function notifyUpstream ( startPath ) { var this$1 = this; var parent = this.parent; var path = startPath || [ this.key ]; while ( parent ) { if ( parent.patternObservers.length ) { parent.patternObservers.forEach( function (o) { return o.notify( path.slice() ); } ); } path.unshift( parent.key ); parent.links.forEach( function (l) { return l.notifiedUpstream( path, this$1.root ); } ); parent.deps.forEach( function (d) { return d.handleChange( path ); } ); parent.downstreamChanged( startPath ); parent = parent.parent; } }; ModelBase__proto__.rebind = function rebind ( next, previous, safe ) { var this$1 = this; if ( this._link ) { this._link.rebind( next, previous, false ); } // tell the deps to move to the new target var i = this.deps.length; while ( i-- ) { if ( this$1.deps[i].rebind ) { this$1.deps[i].rebind( next, previous, safe ); } } i = this.links.length; while ( i-- ) { var link = this$1.links[i]; // only relink the root of the link tree if ( link.owner._link ) { link.relinking( next, safe ); } } i = this.children.length; while ( i-- ) { var child = this$1.children[i]; child.rebind( next ? next.joinKey( child.key ) : undefined, child, safe ); } if ( this.keypathModel ) { this.keypathModel.rebind( next, previous, false ); } i = this.bindings.length; while ( i-- ) { this$1.bindings[i].rebind( next, previous, safe ); } }; ModelBase__proto__.reference = function reference () { 'refs' in this ? this.refs++ : this.refs = 1; }; ModelBase__proto__.register = function register ( dep ) { this.deps.push( dep ); }; ModelBase__proto__.registerLink = function registerLink ( link ) { addToArray( this.links, link ); }; ModelBase__proto__.registerPatternObserver = function registerPatternObserver ( observer ) { this.patternObservers.push( observer ); this.register( observer ); }; ModelBase__proto__.registerTwowayBinding = function registerTwowayBinding ( binding ) { this.bindings.push( binding ); }; ModelBase__proto__.unreference = function unreference () { if ( 'refs' in this ) { this.refs--; } }; ModelBase__proto__.unregister = function unregister ( dep ) { removeFromArray( this.deps, dep ); }; ModelBase__proto__.unregisterLink = function unregisterLink ( link ) { removeFromArray( this.links, link ); }; ModelBase__proto__.unregisterPatternObserver = function unregisterPatternObserver ( observer ) { removeFromArray( this.patternObservers, observer ); this.unregister( observer ); }; ModelBase__proto__.unregisterTwowayBinding = function unregisterTwowayBinding ( binding ) { removeFromArray( this.bindings, binding ); }; ModelBase__proto__.updateFromBindings = function updateFromBindings$1 ( cascade ) { var this$1 = this; var i = this.bindings.length; while ( i-- ) { var value = this$1.bindings[i].getValue(); if ( value !== this$1.value ) { this$1.set( value ); } } // check for one-way bindings if there are no two-ways if ( !this.bindings.length ) { var oneway = findBoundValue( this.deps ); if ( oneway && oneway.value !== this.value ) { this.set( oneway.value ); } } if ( cascade ) { this.children.forEach( updateFromBindings ); this.links.forEach( updateFromBindings ); if ( this._link ) { this._link.updateFromBindings( cascade ); } } }; // TODO: this may be better handled by overreiding `get` on models with a parent that isRoot function maybeBind ( model, value, shouldBind ) { if ( shouldBind && isFunction( value ) && model.parent && model.parent.isRoot ) { if ( !model.boundValue ) { model.boundValue = bind$1( value._r_unbound || value, model.parent.ractive ); } return model.boundValue; } return value; } function updateFromBindings ( model ) { model.updateFromBindings( true ); } function findBoundValue( list ) { var i = list.length; while ( i-- ) { if ( list[i].bound ) { var owner = list[i].owner; if ( owner ) { var value = owner.name === 'checked' ? owner.node.checked : owner.node.value; return { value: value }; } } } } function fireShuffleTasks ( stage ) { if ( !stage ) { fireShuffleTasks( 'early' ); fireShuffleTasks( 'mark' ); } else { var tasks = shuffleTasks[stage]; shuffleTasks[stage] = []; var i = tasks.length; while ( i-- ) { tasks[i](); } var register = registerQueue[stage]; registerQueue[stage] = []; i = register.length; while ( i-- ) { register[i].model.register( register[i].item ); } } } function shuffle ( model, newIndices, link, unsafe ) { model.shuffling = true; var i = newIndices.length; while ( i-- ) { var idx = newIndices[ i ]; // nothing is actually changing, so move in the index and roll on if ( i === idx ) { continue; } // rebind the children on i to idx if ( i in model.childByKey ) { model.childByKey[ i ].rebind( !~idx ? undefined : model.joinKey( idx ), model.childByKey[ i ], !unsafe ); } if ( !~idx && model.keyModels[ i ] ) { model.keyModels[i].rebind( undefined, model.keyModels[i], false ); } else if ( ~idx && model.keyModels[ i ] ) { if ( !model.keyModels[ idx ] ) { model.childByKey[ idx ].getKeyModel( idx ); } model.keyModels[i].rebind( model.keyModels[ idx ], model.keyModels[i], false ); } } var upstream = model.source().length !== model.source().value.length; model.links.forEach( function (l) { return l.shuffle( newIndices ); } ); if ( !link ) { fireShuffleTasks( 'early' ); } i = model.deps.length; while ( i-- ) { if ( model.deps[i].shuffle ) { model.deps[i].shuffle( newIndices ); } } model[ link ? 'marked' : 'mark' ](); if ( !link ) { fireShuffleTasks( 'mark' ); } if ( upstream ) { model.notifyUpstream(); } model.shuffling = false; } KeyModel.prototype.addShuffleTask = ModelBase.prototype.addShuffleTask; KeyModel.prototype.addShuffleRegister = ModelBase.prototype.addShuffleRegister; KeypathModel.prototype.addShuffleTask = ModelBase.prototype.addShuffleTask; KeypathModel.prototype.addShuffleRegister = ModelBase.prototype.addShuffleRegister; // this is the dry method of checking to see if a rebind applies to // a particular keypath because in some cases, a dep may be bound // directly to a particular keypath e.g. foo.bars.0.baz and need // to avoid getting kicked to foo.bars.1.baz if foo.bars is unshifted function rebindMatch ( template, next, previous, fragment ) { var keypath = template.r || template; // no valid keypath, go with next if ( !keypath || !isString( keypath ) ) { return next; } // completely contextual ref, go with next if ( keypath === '.' || keypath[0] === '@' || ( next || previous ).isKey || ( next || previous ).isKeypath ) { return next; } var parts = keypath.split( '/' ); var keys = splitKeypath( parts[ parts.length - 1 ] ); var last = keys[ keys.length - 1 ]; // check the keypath against the model keypath to see if it matches var model = next || previous; // check to see if this was an alias if ( model && keys.length === 1 && last !== model.key && fragment ) { keys = findAlias( last, fragment ) || keys; } var i = keys.length; var match = true; var shuffling = false; while ( model && i-- ) { if ( model.shuffling ) { shuffling = true; } // non-strict comparison to account for indices in keypaths if ( keys[i] != model.key ) { match = false; } model = model.parent; } // next is undefined, but keypath is shuffling and previous matches if ( !next && match && shuffling ) { return previous; } // next is defined, but doesn't match the keypath else if ( next && !match && shuffling ) { return previous; } else { return next; } } function findAlias ( name, fragment ) { while ( fragment ) { var z = fragment.aliases; if ( z && z[ name ] ) { var aliases = ( fragment.owner.iterations ? fragment.owner : fragment ).owner.template.z; for ( var i = 0; i < aliases.length; i++ ) { if ( aliases[i].n === name ) { var alias = aliases[i].x; if ( !alias.r ) { return false; } var parts = alias.r.split( '/' ); return splitKeypath( parts[ parts.length - 1 ] ); } } return; } fragment = fragment.componentParent || fragment.parent; } } // temporary placeholder target for detached implicit links var Missing = { key: '@missing', animate: noop, applyValue: noop, get: noop, getKeypath: function getKeypath () { return this.key; }, joinAll: function joinAll () { return this; }, joinKey: function joinKey () { return this; }, mark: noop, registerLink: noop, shufle: noop, set: noop, unregisterLink: noop }; Missing.parent = Missing; var LinkModel = (function (ModelBase) { function LinkModel ( parent, owner, target, key ) { ModelBase.call( this, parent ); this.owner = owner; this.target = target; this.key = key === undefined ? owner.key : key; if ( owner.isLink ) { this.sourcePath = (owner.sourcePath) + "." + (this.key); } target.registerLink( this ); if ( parent ) { this.isReadonly = parent.isReadonly; } this.isLink = true; } if ( ModelBase ) LinkModel.__proto__ = ModelBase; var LinkModel__proto__ = LinkModel.prototype = Object.create( ModelBase && ModelBase.prototype ); LinkModel__proto__.constructor = LinkModel; LinkModel__proto__.animate = function animate ( from, to, options, interpolator ) { return this.target.animate( from, to, options, interpolator ); }; LinkModel__proto__.applyValue = function applyValue ( value ) { if ( this.boundValue ) { this.boundValue = null; } this.target.applyValue( value ); }; LinkModel__proto__.attach = function attach ( fragment ) { var model = resolveReference( fragment, this.key ); if ( model ) { this.relinking( model, false ); } else { // if there is no link available, move everything here to real models this.owner.unlink(); } }; LinkModel__proto__.detach = function detach () { this.relinking( Missing, false ); }; LinkModel__proto__.get = function get ( shouldCapture, opts ) { if ( opts === void 0 ) opts = {}; if ( shouldCapture ) { capture( this ); // may need to tell the target to unwrap opts.unwrap = true; } var bind$$1 = 'shouldBind' in opts ? opts.shouldBind : true; opts.shouldBind = this.mapping && this.target.parent && this.target.parent.isRoot; return maybeBind( this, this.target.get( false, opts ), bind$$1 ); }; LinkModel__proto__.getKeypath = function getKeypath ( ractive ) { if ( ractive && ractive !== this.root.ractive ) { return this.target.getKeypath( ractive ); } return ModelBase.prototype.getKeypath.call( this, ractive ); }; LinkModel__proto__.getKeypathModel = function getKeypathModel ( ractive ) { if ( !this.keypathModel ) { this.keypathModel = new KeypathModel( this ); } if ( ractive && ractive !== this.root.ractive ) { return this.keypathModel.getChild( ractive ); } return this.keypathModel; }; LinkModel__proto__.handleChange = function handleChange$2 () { this.deps.forEach( handleChange ); this.links.forEach( handleChange ); this.notifyUpstream(); }; LinkModel__proto__.isDetached = function isDetached () { return this.virtual && this.target === Missing; }; LinkModel__proto__.joinKey = function joinKey ( key ) { // TODO: handle nested links if ( key === undefined || key === '' ) { return this; } if ( !hasOwn( this.childByKey, key ) ) { var child = new LinkModel( this, this, this.target.joinKey( key ), key ); this.children.push( child ); this.childByKey[ key ] = child; } return this.childByKey[ key ]; }; LinkModel__proto__.mark = function mark ( force ) { this.target.mark( force ); }; LinkModel__proto__.marked = function marked$1 () { if ( this.boundValue ) { this.boundValue = null; } this.links.forEach( marked ); this.deps.forEach( handleChange ); }; LinkModel__proto__.markedAll = function markedAll$1 () { this.children.forEach( markedAll ); this.marked(); }; LinkModel__proto__.notifiedUpstream = function notifiedUpstream ( startPath, root ) { var this$1 = this; this.links.forEach( function (l) { return l.notifiedUpstream( startPath, this$1.root ); } ); this.deps.forEach( handleChange ); if ( startPath && this.rootLink && this.root !== root ) { var path = startPath.slice( 1 ); path.unshift( this.key ); this.notifyUpstream( path ); } }; LinkModel__proto__.relinked = function relinked () { this.target.registerLink( this ); this.children.forEach( function (c) { return c.relinked(); } ); }; LinkModel__proto__.relinking = function relinking ( target, safe ) { var this$1 = this; if ( this.rootLink && this.sourcePath ) { target = rebindMatch( this.sourcePath, target, this.target ); } if ( !target || this.target === target ) { return; } this.target.unregisterLink( this ); if ( this.keypathModel ) { this.keypathModel.rebindChildren( target ); } this.target = target; this.children.forEach( function (c) { c.relinking( target.joinKey( c.key ), safe ); }); if ( this.rootLink ) { this.addShuffleTask( function () { this$1.relinked(); if ( !safe ) { this$1.markedAll(); this$1.notifyUpstream(); } }); } }; LinkModel__proto__.set = function set ( value ) { if ( this.boundValue ) { this.boundValue = null; } this.target.set( value ); }; LinkModel__proto__.shuffle = function shuffle$1 ( newIndices ) { // watch for extra shuffles caused by a shuffle in a downstream link if ( this.shuffling ) { return; } // let the real model handle firing off shuffles if ( !this.target.shuffling ) { this.target.shuffle( newIndices ); } else { shuffle( this, newIndices, true ); } }; LinkModel__proto__.source = function source () { if ( this.target.source ) { return this.target.source(); } else { return this.target; } }; LinkModel__proto__.teardown = function teardown$2 () { if ( this._link ) { this._link.teardown(); } this.target.unregisterLink( this ); this.children.forEach( teardown ); }; return LinkModel; }(ModelBase)); ModelBase.prototype.link = function link ( model, keypath, options ) { var lnk = this._link || new LinkModel( this.parent, this, model, this.key ); lnk.implicit = options && options.implicit; lnk.mapping = options && options.mapping; lnk.sourcePath = keypath; lnk.rootLink = true; if ( this._link ) { this._link.relinking( model, false ); } this.rebind( lnk, this, false ); fireShuffleTasks(); this._link = lnk; lnk.markedAll(); this.notifyUpstream(); return lnk; }; ModelBase.prototype.unlink = function unlink () { if ( this._link ) { var ln = this._link; this._link = undefined; ln.rebind( this, ln, false ); fireShuffleTasks(); ln.teardown(); this.notifyUpstream(); } }; var TransitionManager = function TransitionManager ( callback, parent ) { this.callback = callback; this.parent = parent; this.intros = []; this.outros = []; this.children = []; this.totalChildren = this.outroChildren = 0; this.detachQueue = []; this.outrosComplete = false; if ( parent ) { parent.addChild( this ); } }; var TransitionManager__proto__ = TransitionManager.prototype; TransitionManager__proto__.add = function add ( transition ) { var list = transition.isIntro ? this.intros : this.outros; transition.starting = true; list.push( transition ); }; TransitionManager__proto__.addChild = function addChild ( child ) { this.children.push( child ); this.totalChildren += 1; this.outroChildren += 1; }; TransitionManager__proto__.decrementOutros = function decrementOutros () { this.outroChildren -= 1; check( this ); }; TransitionManager__proto__.decrementTotal = function decrementTotal () { this.totalChildren -= 1; check( this ); }; TransitionManager__proto__.detachNodes = function detachNodes () { this.detachQueue.forEach( detach ); this.children.forEach( _detachNodes ); this.detachQueue = []; }; TransitionManager__proto__.ready = function ready () { if ( this.detachQueue.length ) { detachImmediate( this ); } }; TransitionManager__proto__.remove = function remove ( transition ) { var list = transition.isIntro ? this.intros : this.outros; removeFromArray( list, transition ); check( this ); }; TransitionManager__proto__.start = function start () { this.children.forEach( function (c) { return c.start(); } ); this.intros.concat( this.outros ).forEach( function (t) { return t.start(); } ); this.ready = true; check( this ); }; function detach ( element ) { element.detach(); } function _detachNodes ( tm ) { // _ to avoid transpiler quirk tm.detachNodes(); } function check ( tm ) { if ( !tm.ready || tm.outros.length || tm.outroChildren ) { return; } // If all outros are complete, and we haven't already done this, // we notify the parent if there is one, otherwise // start detaching nodes if ( !tm.outrosComplete ) { tm.outrosComplete = true; if ( tm.parent && !tm.parent.outrosComplete ) { tm.parent.decrementOutros( tm ); } else { tm.detachNodes(); } } // Once everything is done, we can notify parent transition // manager and call the callback if ( !tm.intros.length && !tm.totalChildren ) { if ( isFunction( tm.callback ) ) { tm.callback(); } if ( tm.parent && !tm.notifiedTotal ) { tm.notifiedTotal = true; tm.parent.decrementTotal();