ractive-ez-combobox
Version:
Ractive Ez UI Combobox
1,853 lines (1,487 loc) • 575 kB
JavaScript
/******/ (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 = 8);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
// css base code, injected by the css-loader
module.exports = function (useSourceMap) {
var list = [];
// return the list of modules as css string
list.toString = function toString() {
return this.map(function (item) {
var content = cssWithMappingToString(item, useSourceMap);
if (item[2]) {
return "@media " + item[2] + "{" + content + "}";
} else {
return content;
}
}).join("");
};
// import a list of modules into the list
list.i = function (modules, mediaQuery) {
if (typeof modules === "string") modules = [[null, modules, ""]];
var alreadyImportedModules = {};
for (var i = 0; i < this.length; i++) {
var id = this[i][0];
if (typeof id === "number") alreadyImportedModules[id] = true;
}
for (i = 0; i < modules.length; i++) {
var item = modules[i];
// skip already imported module
// this implementation is not 100% perfect for weird media query combinations
// when a module is imported multiple times with different media queries.
// I hope this will never occur (Hey this way we have smaller bundles)
if (typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
if (mediaQuery && !item[2]) {
item[2] = mediaQuery;
} else if (mediaQuery) {
item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
}
list.push(item);
}
}
};
return list;
};
function cssWithMappingToString(item, useSourceMap) {
var content = item[1] || '';
var cssMapping = item[3];
if (!cssMapping) {
return content;
}
if (useSourceMap && typeof btoa === 'function') {
var sourceMapping = toComment(cssMapping);
var sourceURLs = cssMapping.sources.map(function (source) {
return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */';
});
return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
}
return [content].join('\n');
}
// Adapted from convert-source-map (MIT)
function toComment(sourceMap) {
// eslint-disable-next-line no-undef
var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
return '/*# ' + data + ' */';
}
/***/ }),
/* 1 */
/***/ (function(module, exports, __webpack_require__) {
/*
MIT License http://www.opensource.org/licenses/mit-license.php
Author Tobias Koppers @sokra
*/
var stylesInDom = {};
var memoize = function (fn) {
var memo;
return function () {
if (typeof memo === "undefined") memo = fn.apply(this, arguments);
return memo;
};
};
var isOldIE = memoize(function () {
// Test for IE <= 9 as proposed by Browserhacks
// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
// Tests for existence of standard globals is to allow style-loader
// to operate correctly into non-standard environments
// @see https://github.com/webpack-contrib/style-loader/issues/177
return window && document && document.all && !window.atob;
});
var getElement = (function (fn) {
var memo = {};
return function(selector) {
if (typeof memo[selector] === "undefined") {
var styleTarget = fn.call(this, selector);
// Special case to return head of iframe instead of iframe itself
if (styleTarget instanceof window.HTMLIFrameElement) {
try {
// This will throw an exception if access to iframe is blocked
// due to cross-origin restrictions
styleTarget = styleTarget.contentDocument.head;
} catch(e) {
styleTarget = null;
}
}
memo[selector] = styleTarget;
}
return memo[selector]
};
})(function (target) {
return document.querySelector(target)
});
var singleton = null;
var singletonCounter = 0;
var stylesInsertedAtTop = [];
var fixUrls = __webpack_require__(13);
module.exports = function(list, options) {
if (typeof DEBUG !== "undefined" && DEBUG) {
if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
}
options = options || {};
options.attrs = typeof options.attrs === "object" ? options.attrs : {};
// Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
// tags it will allow on a page
if (!options.singleton) options.singleton = isOldIE();
// By default, add <style> tags to the <head> element
if (!options.insertInto) options.insertInto = "head";
// By default, add <style> tags to the bottom of the target
if (!options.insertAt) options.insertAt = "bottom";
var styles = listToStyles(list, options);
addStylesToDom(styles, options);
return function update (newList) {
var mayRemove = [];
for (var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
domStyle.refs--;
mayRemove.push(domStyle);
}
if(newList) {
var newStyles = listToStyles(newList, options);
addStylesToDom(newStyles, options);
}
for (var i = 0; i < mayRemove.length; i++) {
var domStyle = mayRemove[i];
if(domStyle.refs === 0) {
for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
delete stylesInDom[domStyle.id];
}
}
};
};
function addStylesToDom (styles, options) {
for (var i = 0; i < styles.length; i++) {
var item = styles[i];
var domStyle = stylesInDom[item.id];
if(domStyle) {
domStyle.refs++;
for(var j = 0; j < domStyle.parts.length; j++) {
domStyle.parts[j](item.parts[j]);
}
for(; j < item.parts.length; j++) {
domStyle.parts.push(addStyle(item.parts[j], options));
}
} else {
var parts = [];
for(var j = 0; j < item.parts.length; j++) {
parts.push(addStyle(item.parts[j], options));
}
stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
}
}
}
function listToStyles (list, options) {
var styles = [];
var newStyles = {};
for (var i = 0; i < list.length; i++) {
var item = list[i];
var id = options.base ? item[0] + options.base : item[0];
var css = item[1];
var media = item[2];
var sourceMap = item[3];
var part = {css: css, media: media, sourceMap: sourceMap};
if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
else newStyles[id].parts.push(part);
}
return styles;
}
function insertStyleElement (options, style) {
var target = getElement(options.insertInto)
if (!target) {
throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
}
var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
if (options.insertAt === "top") {
if (!lastStyleElementInsertedAtTop) {
target.insertBefore(style, target.firstChild);
} else if (lastStyleElementInsertedAtTop.nextSibling) {
target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
} else {
target.appendChild(style);
}
stylesInsertedAtTop.push(style);
} else if (options.insertAt === "bottom") {
target.appendChild(style);
} else if (typeof options.insertAt === "object" && options.insertAt.before) {
var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
target.insertBefore(style, nextSibling);
} else {
throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
}
}
function removeStyleElement (style) {
if (style.parentNode === null) return false;
style.parentNode.removeChild(style);
var idx = stylesInsertedAtTop.indexOf(style);
if(idx >= 0) {
stylesInsertedAtTop.splice(idx, 1);
}
}
function createStyleElement (options) {
var style = document.createElement("style");
options.attrs.type = "text/css";
addAttrs(style, options.attrs);
insertStyleElement(options, style);
return style;
}
function createLinkElement (options) {
var link = document.createElement("link");
options.attrs.type = "text/css";
options.attrs.rel = "stylesheet";
addAttrs(link, options.attrs);
insertStyleElement(options, link);
return link;
}
function addAttrs (el, attrs) {
Object.keys(attrs).forEach(function (key) {
el.setAttribute(key, attrs[key]);
});
}
function addStyle (obj, options) {
var style, update, remove, result;
// If a transform function was defined, run it on the css
if (options.transform && obj.css) {
result = options.transform(obj.css);
if (result) {
// If transform returns a value, use that instead of the original css.
// This allows running runtime transformations on the css.
obj.css = result;
} else {
// If the transform function returns a falsy value, don't add this css.
// This allows conditional loading of css
return function() {
// noop
};
}
}
if (options.singleton) {
var styleIndex = singletonCounter++;
style = singleton || (singleton = createStyleElement(options));
update = applyToSingletonTag.bind(null, style, styleIndex, false);
remove = applyToSingletonTag.bind(null, style, styleIndex, true);
} else if (
obj.sourceMap &&
typeof URL === "function" &&
typeof URL.createObjectURL === "function" &&
typeof URL.revokeObjectURL === "function" &&
typeof Blob === "function" &&
typeof btoa === "function"
) {
style = createLinkElement(options);
update = updateLink.bind(null, style, options);
remove = function () {
removeStyleElement(style);
if(style.href) URL.revokeObjectURL(style.href);
};
} else {
style = createStyleElement(options);
update = applyToTag.bind(null, style);
remove = function () {
removeStyleElement(style);
};
}
update(obj);
return function updateStyle (newObj) {
if (newObj) {
if (
newObj.css === obj.css &&
newObj.media === obj.media &&
newObj.sourceMap === obj.sourceMap
) {
return;
}
update(obj = newObj);
} else {
remove();
}
};
}
var replaceText = (function () {
var textStore = [];
return function (index, replacement) {
textStore[index] = replacement;
return textStore.filter(Boolean).join('\n');
};
})();
function applyToSingletonTag (style, index, remove, obj) {
var css = remove ? "" : obj.css;
if (style.styleSheet) {
style.styleSheet.cssText = replaceText(index, css);
} else {
var cssNode = document.createTextNode(css);
var childNodes = style.childNodes;
if (childNodes[index]) style.removeChild(childNodes[index]);
if (childNodes.length) {
style.insertBefore(cssNode, childNodes[index]);
} else {
style.appendChild(cssNode);
}
}
}
function applyToTag (style, obj) {
var css = obj.css;
var media = obj.media;
if(media) {
style.setAttribute("media", media)
}
if(style.styleSheet) {
style.styleSheet.cssText = css;
} else {
while(style.firstChild) {
style.removeChild(style.firstChild);
}
style.appendChild(document.createTextNode(css));
}
}
function updateLink (link, options, obj) {
var css = obj.css;
var sourceMap = obj.sourceMap;
/*
If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
and there is no publicPath defined then lets turn convertToAbsoluteUrls
on by default. Otherwise default to the convertToAbsoluteUrls option
directly
*/
var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
if (options.convertToAbsoluteUrls || autoFixUrls) {
css = fixUrls(css);
}
if (sourceMap) {
// http://stackoverflow.com/a/26603875
css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
}
var blob = new Blob([css], { type: "text/css" });
var oldSrc = link.href;
link.href = URL.createObjectURL(blob);
if(oldSrc) URL.revokeObjectURL(oldSrc);
}
/***/ }),
/* 2 */
/***/ (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.pa