UNPKG

can

Version:

MIT-licensed, client-side, JavaScript framework that makes building rich web applications easy.

1,331 lines (1,327 loc) 367 kB
/*! * CanJS - 2.3.34 * http://canjs.com/ * Copyright (c) 2018 Bitovi * Mon, 30 Apr 2018 20:56:51 GMT * Licensed MIT */ /*[global-shim-start]*/ (function (exports, global){ var origDefine = global.define; var get = function(name){ var parts = name.split("."), cur = global, i; for(i = 0 ; i < parts.length; i++){ if(!cur) { break; } cur = cur[parts[i]]; } return cur; }; var modules = (global.define && global.define.modules) || (global._define && global._define.modules) || {}; var ourDefine = global.define = function(moduleName, deps, callback){ var module; if(typeof deps === "function") { callback = deps; deps = []; } var args = [], i; for(i =0; i < deps.length; i++) { args.push( exports[deps[i]] ? get(exports[deps[i]]) : ( modules[deps[i]] || get(deps[i]) ) ); } // CJS has no dependencies but 3 callback arguments if(!deps.length && callback.length) { module = { exports: {} }; var require = function(name) { return exports[name] ? get(exports[name]) : modules[name]; }; args.push(require, module.exports, module); } // Babel uses the exports and module object. else if(!args[0] && deps[0] === "exports") { module = { exports: {} }; args[0] = module.exports; if(deps[1] === "module") { args[1] = module; } } else if(!args[0] && deps[0] === "module") { args[0] = { id: moduleName }; } global.define = origDefine; var result = callback ? callback.apply(null, args) : undefined; global.define = ourDefine; // Favor CJS module.exports over the return value modules[moduleName] = module && module.exports ? module.exports : result; }; global.define.orig = origDefine; global.define.modules = modules; global.define.amd = true; ourDefine("@loader", [], function(){ // shim for @@global-helpers var noop = function(){}; return { get: function(){ return { prepareGlobal: noop, retrieveGlobal: noop }; }, global: global, __exec: function(__load){ eval("(function() { " + __load.source + " \n }).call(global);"); } }; }); })({},window) /*can@2.3.34#util/can*/ define('can/util/can', [], function () { var glbl = typeof window !== 'undefined' ? window : typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope ? self : global; var can = {}; if (typeof GLOBALCAN === 'undefined' || GLOBALCAN !== false) { glbl.can = can; } can.global = glbl; can.k = function () { }; can.isDeferred = function (obj) { if (!!can.dev) { can.dev.warn('can.isDeferred: this function is deprecated and will be removed in a future release. can.isPromise replaces the functionality of can.isDeferred.'); } return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function'; }; can.isPromise = function (obj) { return !!obj && (window.Promise && obj instanceof Promise || can.isFunction(obj.then) && (can.List === undefined || !(obj instanceof can.List))); }; can.isMapLike = function (obj) { return can.Map && (obj instanceof can.Map || obj && obj.___get); }; var cid = 0; can.cid = function (object, name) { if (!object._cid) { cid++; object._cid = (name || '') + cid; } return object._cid; }; can.VERSION = '2.3.34'; can.simpleExtend = function (d, s) { for (var prop in s) { d[prop] = s[prop]; } return d; }; can.last = function (arr) { return arr && arr[arr.length - 1]; }; can.isDOM = function (el) { return (el.ownerDocument || el) === can.global.document; }; can.childNodes = function (node) { var childNodes = node.childNodes; if ('length' in childNodes) { return childNodes; } else { var cur = node.firstChild; var nodes = []; while (cur) { nodes.push(cur); cur = cur.nextSibling; } return nodes; } }; var protoBind = Function.prototype.bind; if (protoBind) { can.proxy = function (fn, context) { return protoBind.call(fn, context); }; } else { can.proxy = function (fn, context) { return function () { return fn.apply(context, arguments); }; }; } can.frag = function (item, doc) { var document = doc || can.document || can.global.document; var frag; if (!item || typeof item === 'string') { frag = can.buildFragment(item == null ? '' : '' + item, document); if (!frag.childNodes.length) { frag.appendChild(document.createTextNode('')); } return frag; } else if (item.nodeType === 11) { return item; } else if (typeof item.nodeType === 'number') { frag = document.createDocumentFragment(); frag.appendChild(item); return frag; } else if (typeof item.length === 'number') { frag = document.createDocumentFragment(); can.each(item, function (item) { frag.appendChild(can.frag(item)); }); if (!can.childNodes(frag).length) { frag.appendChild(document.createTextNode('')); } return frag; } else { frag = can.buildFragment('' + item, document); if (!can.childNodes(frag).length) { frag.appendChild(document.createTextNode('')); } return frag; } }; can.scope = can.viewModel = function (el, attr, val) { el = can.$(el); var scope = can.data(el, 'scope') || can.data(el, 'viewModel'); if (!scope) { scope = new can.Map(); can.data(el, 'scope', scope); can.data(el, 'viewModel', scope); } switch (arguments.length) { case 0: case 1: return scope; case 2: return scope.attr(attr); default: scope.attr(attr, val); return el; } }; var parseURI = function (url) { var m = String(url).replace(/^\s+|\s+$/g, '').match(/^([^:\/?#]+:)?(\/\/(?:[^:@]*(?::[^:@]*)?@)?(([^:\/?#]*)(?::(\d*))?))?([^?#]*)(\?[^#]*)?(#[\s\S]*)?/); return m ? { href: m[0] || '', protocol: m[1] || '', authority: m[2] || '', host: m[3] || '', hostname: m[4] || '', port: m[5] || '', pathname: m[6] || '', search: m[7] || '', hash: m[8] || '' } : null; }; can.joinURIs = function (base, href) { function removeDotSegments(input) { var output = []; input.replace(/^(\.\.?(\/|$))+/, '').replace(/\/(\.(\/|$))+/g, '/').replace(/\/\.\.$/, '/../').replace(/\/?[^\/]*/g, function (p) { if (p === '/..') { output.pop(); } else { output.push(p); } }); return output.join('').replace(/^\//, input.charAt(0) === '/' ? '/' : ''); } href = parseURI(href || ''); base = parseURI(base || ''); return !href || !base ? null : (href.protocol || base.protocol) + (href.protocol || href.authority ? href.authority : base.authority) + removeDotSegments(href.protocol || href.authority || href.pathname.charAt(0) === '/' ? href.pathname : href.pathname ? (base.authority && !base.pathname ? '/' : '') + base.pathname.slice(0, base.pathname.lastIndexOf('/') + 1) + href.pathname : base.pathname) + (href.protocol || href.authority || href.pathname ? href.search : href.search || base.search) + href.hash; }; can['import'] = function (moduleName, parentName) { var deferred = new can.Deferred(); if (typeof window.System === 'object' && can.isFunction(window.System['import'])) { window.System['import'](moduleName, { name: parentName }).then(can.proxy(deferred.resolve, deferred), can.proxy(deferred.reject, deferred)); } else if (window.define && window.define.amd) { window.require([moduleName], function (value) { deferred.resolve(value); }); } else if (window.steal) { steal.steal(moduleName, function (value) { deferred.resolve(value); }); } else if (window.require) { deferred.resolve(window.require(moduleName)); } else { deferred.resolve(); } return deferred.promise(); }; can.__observe = function () { }; can.isNode = typeof process === 'object' && {}.toString.call(process) === '[object process]'; can.isBrowserWindow = typeof window !== 'undefined' && typeof document !== 'undefined' && typeof SimpleDOM === 'undefined'; can.isWebWorker = typeof WorkerGlobalScope !== 'undefined' && self instanceof WorkerGlobalScope; can.dev = { warnTimeout: 5000, logLevel: 0, warn: function (out) { var ll = this.logLevel; if (ll < 2) { Array.prototype.unshift.call(arguments, 'WARN:'); if (typeof window !== undefined && window.console && console.warn) { this._logger('warn', Array.prototype.slice.call(arguments)); } else if (window.console && console.log) { this._logger('log', Array.prototype.slice.call(arguments)); } else if (window.opera && window.opera.postError) { window.opera.postError('steal.js WARNING: ' + out); } } }, log: function (out) { var ll = this.logLevel; if (ll < 1) { if (window.console && console.log) { Array.prototype.unshift.call(arguments, 'Info:'); this._logger('log', Array.prototype.slice.call(arguments)); } else if (window.opera && window.opera.postError) { window.opera.postError('steal.js INFO: ' + out); } } }, _logger: function (type, arr) { try { console[type].apply(console, arr); } catch (e) { console[type](arr); } } }; return can; }); /*can@2.3.34#util/attr/attr*/ define('can/util/attr/attr', ['can/util/can'], function (can) { var namespaces = { 'xlink': 'http://www.w3.org/1999/xlink' }; var setImmediate = can.global.setImmediate || function (cb) { return setTimeout(cb, 0); }, formElements = { 'input': true, 'textarea': true, 'select': true }, hasProperty = function (el, attrName) { return attrName in el || can.document && formElements[el.nodeName.toLowerCase()]; }, attr = { MutationObserver: can.global.MutationObserver || can.global.WebKitMutationObserver || can.global.MozMutationObserver, map: { 'class': function (el, val) { val = val || ''; if (el.namespaceURI === 'http://www.w3.org/2000/svg') { el.setAttribute('class', val); } else { el.className = val; } return val; }, 'value': 'value', 'innertext': 'innerText', 'innerhtml': 'innerHTML', 'textcontent': 'textContent', 'for': 'htmlFor', 'checked': true, 'disabled': true, 'readonly': function (el, val) { el.readOnly = val || typeof val === 'string' ? true : false; return val; }, 'required': true, src: function (el, val) { if (val == null || val === '') { el.removeAttribute('src'); return null; } else { el.setAttribute('src', val); return val; } }, style: function () { var el = can.global.document && document.createElement('div'); if (el && el.style && 'cssText' in el.style) { return function (el, val) { return el.style.cssText = val || ''; }; } else { return function (el, val) { return el.setAttribute('style', val); }; } }() }, defaultValue: [ 'input', 'textarea' ], setAttrOrProp: function (el, attrName, val) { attrName = attrName.toLowerCase(); var prop = attr.map[attrName]; if (prop === true && !val) { this.remove(el, attrName); } else { this.set(el, attrName, val); } }, setSelectValue: function (el, val) { if (val != null) { var options = el.getElementsByTagName('option'); for (var i = 0; i < options.length; i++) { if (val == options[i].value) { options[i].selected = true; return; } } } el.selectedIndex = -1; }, set: function (el, attrName, val) { var usingMutationObserver = can.isDOM(el) && attr.MutationObserver; attrName = attrName.toLowerCase(); var oldValue; if (!usingMutationObserver) { oldValue = attr.get(el, attrName); } var prop = attr.map[attrName], newValue; if (typeof prop === 'function') { newValue = prop(el, val); } else if (prop === true && hasProperty(el, attrName)) { newValue = el[attrName] = true; if (attrName === 'checked' && el.type === 'radio') { if (can.inArray((el.nodeName + '').toLowerCase(), attr.defaultValue) >= 0) { el.defaultChecked = true; } } } else if (typeof prop === 'string' && hasProperty(el, prop)) { newValue = val; if (el[prop] !== val || el.nodeName.toUpperCase() === 'OPTION') { el[prop] = val; } if (prop === 'value' && can.inArray((el.nodeName + '').toLowerCase(), attr.defaultValue) >= 0) { el.defaultValue = val; } } else { attr.setAttribute(el, attrName, val); } if (!usingMutationObserver && newValue !== oldValue) { attr.trigger(el, attrName, oldValue); } }, setAttribute: function () { var doc = can.global.document; if (doc && document.createAttribute) { try { doc.createAttribute('{}'); } catch (e) { var invalidNodes = {}, attributeDummy = document.createElement('div'); return function (el, attrName, val) { var first = attrName.charAt(0), cachedNode, node, attr; if ((first === '{' || first === '(' || first === '*') && el.setAttributeNode) { cachedNode = invalidNodes[attrName]; if (!cachedNode) { attributeDummy.innerHTML = '<div ' + attrName + '=""></div>'; cachedNode = invalidNodes[attrName] = attributeDummy.childNodes[0].attributes[0]; } node = cachedNode.cloneNode(); node.value = val; el.setAttributeNode(node); } else { attr = attrName.split(':'); if (attr.length !== 1) { el.setAttributeNS(namespaces[attr[0]], attrName, val); } else { el.setAttribute(attrName, val); } } }; } } return function (el, attrName, val) { el.setAttribute(attrName, val); }; }(), trigger: function (el, attrName, oldValue) { if (can.data(can.$(el), 'canHasAttributesBindings')) { attrName = attrName.toLowerCase(); return setImmediate(function () { can.trigger(el, { type: 'attributes', attributeName: attrName, target: el, oldValue: oldValue, bubbles: false }, []); }); } }, get: function (el, attrName) { attrName = attrName.toLowerCase(); var prop = attr.map[attrName]; if (typeof prop === 'string' && hasProperty(el, prop)) { return el[prop]; } else if (prop === true && hasProperty(el, attrName)) { return el[attrName]; } return el.getAttribute(attrName); }, remove: function (el, attrName) { attrName = attrName.toLowerCase(); var oldValue; if (!attr.MutationObserver) { oldValue = attr.get(el, attrName); } var setter = attr.map[attrName]; if (typeof setter === 'function') { setter(el, undefined); } if (setter === true && hasProperty(el, attrName)) { el[attrName] = false; } else if (typeof setter === 'string' && hasProperty(el, setter)) { el[setter] = ''; } else { el.removeAttribute(attrName); } if (!attr.MutationObserver && oldValue != null) { attr.trigger(el, attrName, oldValue); } }, has: function () { var el = can.global.document && document.createElement('div'); if (el && el.hasAttribute) { return function (el, name) { return el.hasAttribute(name); }; } else { return function (el, name) { return el.getAttribute(name) !== null; }; } }() }; return attr; }); /*can@2.3.34#event/event*/ define('can/event/event', ['can/util/can'], function (can) { can.addEvent = function (event, handler) { var allEvents = this.__bindEvents || (this.__bindEvents = {}), eventList = allEvents[event] || (allEvents[event] = []); eventList.push({ handler: handler, name: event }); return this; }; can.listenTo = function (other, event, handler) { var idedEvents = this.__listenToEvents; if (!idedEvents) { idedEvents = this.__listenToEvents = {}; } var otherId = can.cid(other); var othersEvents = idedEvents[otherId]; if (!othersEvents) { othersEvents = idedEvents[otherId] = { obj: other, events: {} }; } var eventsEvents = othersEvents.events[event]; if (!eventsEvents) { eventsEvents = othersEvents.events[event] = []; } eventsEvents.push(handler); can.bind.call(other, event, handler); }; can.stopListening = function (other, event, handler) { var idedEvents = this.__listenToEvents, iterIdedEvents = idedEvents, i = 0; if (!idedEvents) { return this; } if (other) { var othercid = can.cid(other); (iterIdedEvents = {})[othercid] = idedEvents[othercid]; if (!idedEvents[othercid]) { return this; } } for (var cid in iterIdedEvents) { var othersEvents = iterIdedEvents[cid], eventsEvents; other = idedEvents[cid].obj; if (!event) { eventsEvents = othersEvents.events; } else { (eventsEvents = {})[event] = othersEvents.events[event]; } for (var eventName in eventsEvents) { var handlers = eventsEvents[eventName] || []; i = 0; while (i < handlers.length) { if (handler && handler === handlers[i] || !handler) { can.unbind.call(other, eventName, handlers[i]); handlers.splice(i, 1); } else { i++; } } if (!handlers.length) { delete othersEvents.events[eventName]; } } if (can.isEmptyObject(othersEvents.events)) { delete idedEvents[cid]; } } return this; }; can.removeEvent = function (event, fn, __validate) { if (!this.__bindEvents) { return this; } var events = this.__bindEvents[event] || [], i = 0, ev, isFunction = typeof fn === 'function'; while (i < events.length) { ev = events[i]; if (__validate ? __validate(ev, event, fn) : isFunction && ev.handler === fn || !isFunction && (ev.cid === fn || !fn)) { events.splice(i, 1); } else { i++; } } return this; }; can.dispatch = function (event, args) { var events = this.__bindEvents; if (!events) { return; } var eventName; if (typeof event === 'string') { eventName = event; event = { type: event }; } else { eventName = event.type; } var handlers = events[eventName]; if (!handlers) { return; } else { handlers = handlers.slice(0); } var passed = [event]; if (args) { passed.push.apply(passed, args); } for (var i = 0, len = handlers.length; i < len; i++) { handlers[i].handler.apply(this, passed); } return event; }; can.one = function (event, handler) { var one = function () { can.unbind.call(this, event, one); return handler.apply(this, arguments); }; can.bind.call(this, event, one); return this; }; can.event = { on: function () { if (arguments.length === 0 && can.Control && this instanceof can.Control) { return can.Control.prototype.on.call(this); } else { return can.addEvent.apply(this, arguments); } }, off: function () { if (arguments.length === 0 && can.Control && this instanceof can.Control) { return can.Control.prototype.off.call(this); } else { return can.removeEvent.apply(this, arguments); } }, bind: can.addEvent, unbind: can.removeEvent, delegate: function (selector, event, handler) { return can.addEvent.call(this, event, handler); }, undelegate: function (selector, event, handler) { return can.removeEvent.call(this, event, handler); }, trigger: can.dispatch, one: can.one, addEvent: can.addEvent, removeEvent: can.removeEvent, listenTo: can.listenTo, stopListening: can.stopListening, dispatch: can.dispatch }; return can.event; }); /*can@2.3.34#util/fragment*/ define('can/util/fragment', ['can/util/can'], function (can) { var fragmentRE = /^\s*<(\w+)[^>]*>/, toString = {}.toString, fragment = function (html, name, doc) { if (name === undefined) { name = fragmentRE.test(html) && RegExp.$1; } if (html && toString.call(html.replace) === '[object Function]') { html = html.replace(/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi, '<$1></$2>'); } var container = doc.createElement('div'), temp = doc.createElement('div'); if (name === 'tbody' || name === 'tfoot' || name === 'thead' || name === 'colgroup') { temp.innerHTML = '<table>' + html + '</table>'; container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; } else if (name === 'col') { temp.innerHTML = '<table><colgroup>' + html + '</colgroup></table>'; container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; } else if (name === 'tr') { temp.innerHTML = '<table><tbody>' + html + '</tbody></table>'; container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild; } else if (name === 'td' || name === 'th') { temp.innerHTML = '<table><tbody><tr>' + html + '</tr></tbody></table>'; container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild.firstChild.firstChild; } else if (name === 'option') { temp.innerHTML = '<select>' + html + '</select>'; container = temp.firstChild.nodeType === 3 ? temp.lastChild : temp.firstChild; } else { container.innerHTML = '' + html; } var tmp = {}, children = can.childNodes(container); tmp.length = children.length; for (var i = 0; i < children.length; i++) { tmp[i] = children[i]; } return [].slice.call(tmp); }; can.buildFragment = function (html, doc) { if (html && html.nodeType === 11) { return html; } if (!doc) { doc = document; } else if (doc.length) { doc = doc[0]; } var parts = fragment(html, undefined, doc), frag = (doc || document).createDocumentFragment(); for (var i = 0, length = parts.length; i < length; i++) { frag.appendChild(parts[i]); } return frag; }; (function () { var text = '<-\n>', frag = can.buildFragment(text, document); if (text !== frag.firstChild.nodeValue) { var oldBuildFragment = can.buildFragment; can.buildFragment = function (html, nodes) { var res = oldBuildFragment(html, nodes); if (res.childNodes.length === 1 && res.childNodes[0].nodeType === 3) { res.childNodes[0].nodeValue = html; } return res; }; } }()); return can; }); /*can@2.3.34#util/deferred*/ define('can/util/deferred', ['can/util/can'], function (can) { var extend = function (target, src) { for (var key in src) { if (src.hasOwnProperty(key)) { target[key] = src[key]; } } }, Deferred = function (func) { if (!(this instanceof Deferred)) { return new Deferred(); } this._doneFuncs = []; this._failFuncs = []; this._resultArgs = null; this._status = ''; if (func) { func.call(this, this); } }; can.Deferred = Deferred; can.when = Deferred.when = function () { var args = can.makeArray(arguments); if (args.length < 2) { var obj = args[0]; if (obj && (can.isFunction(obj.isResolved) && can.isFunction(obj.isRejected))) { return obj; } else { return Deferred().resolve(obj); } } else { var df = Deferred(), done = 0, rp = []; can.each(args, function (arg, j) { arg.done(function () { rp[j] = arguments.length < 2 ? arguments[0] : arguments; if (++done === args.length) { df.resolve.apply(df, rp); } }).fail(function () { df.reject(arguments.length === 1 ? arguments[0] : arguments); }); }); return df; } }; var resolveFunc = function (type, _status) { return function (context) { var args = this._resultArgs = arguments.length > 1 ? arguments[1] : []; return this.exec(context, this[type], args, _status); }; }, doneFunc = function doneFunc(type, _status) { return function () { var self = this; can.each(Array.prototype.slice.call(arguments), function (v, i, args) { if (!v) { return; } if (v.constructor === Array) { doneFunc.apply(self, v); } else { if (self._status === _status) { v.apply(self, self._resultArgs || []); } self[type].push(v); } }); return this; }; }; var isDeferred = function (obj) { return obj && obj.then && obj.fail && obj.done; }; var wire = function (parentDeferred, result, setter, value) { if (isDeferred(result)) { result.done(can.proxy(parentDeferred.resolve, parentDeferred)).fail(can.proxy(parentDeferred.reject, parentDeferred)); } else { setter.call(parentDeferred, result !== undefined ? result : value); } }; extend(Deferred.prototype, { then: function (done, fail) { var d = can.Deferred(), resolve = d.resolve, reject = d.reject; this.done(function (value) { if (typeof done === 'function') { wire(d, done.apply(this, arguments), resolve, value); } else { resolve.apply(d, arguments); } }); this.fail(function (value) { if (typeof fail === 'function') { wire(d, fail.apply(this, arguments), reject, value); } else { reject.apply(d, arguments); } }); return d; }, resolveWith: resolveFunc('_doneFuncs', 'rs'), rejectWith: resolveFunc('_failFuncs', 'rj'), done: doneFunc('_doneFuncs', 'rs'), fail: doneFunc('_failFuncs', 'rj'), always: function () { var args = can.makeArray(arguments); if (args.length && args[0]) { this.done(args[0]).fail(args[0]); } return this; }, state: function () { switch (this._status) { case 'rs': return 'resolved'; case 'rj': return 'rejected'; default: return 'pending'; } }, isResolved: function () { return this._status === 'rs'; }, isRejected: function () { return this._status === 'rj'; }, reject: function () { return this.rejectWith(this, arguments); }, resolve: function () { return this.resolveWith(this, arguments); }, exec: function (context, dst, args, st) { if (this._status !== '') { return this; } this._status = st; can.each(dst, function (d) { if (typeof d.apply === 'function') { d.apply(context, args); } }); return this; }, promise: function () { var promise = this.then(); promise.reject = promise.resolve = undefined; return promise; } }); Deferred.prototype.pipe = Deferred.prototype.then; return can; }); /*can@2.3.34#util/array/isArrayLike*/ define('can/util/array/isArrayLike', ['can/util/can'], function (can) { can.isArrayLike = function (obj) { var length = obj && typeof obj !== 'boolean' && typeof obj !== 'number' && 'length' in obj && obj.length; return typeof arr !== 'function' && (length === 0 || typeof length === 'number' && length > 0 && length - 1 in obj); }; }); /*can@2.3.34#util/array/each*/ define('can/util/array/each', [ 'can/util/can', 'can/util/array/isArrayLike' ], function (can) { can.each = function (elements, callback, context) { var i = 0, key, len, item; if (elements) { if (can.isArrayLike(elements)) { if (can.List && elements instanceof can.List) { for (len = elements.attr('length'); i < len; i++) { item = elements.attr(i); if (callback.call(context || item, item, i, elements) === false) { break; } } } else { for (len = elements.length; i < len; i++) { item = elements[i]; if (callback.call(context || item, item, i, elements) === false) { break; } } } } else if (typeof elements === 'object') { if (can.Map && elements instanceof can.Map || elements === can.route) { var keys = can.Map.keys(elements); for (i = 0, len = keys.length; i < len; i++) { key = keys[i]; item = elements.attr(key); if (callback.call(context || item, item, key, elements) === false) { break; } } } else { for (key in elements) { if (Object.prototype.hasOwnProperty.call(elements, key) && callback.call(context || elements[key], elements[key], key, elements) === false) { break; } } } } } return elements; }; return can; }); /*can@2.3.34#util/object/isplain/isplain*/ define('can/util/object/isplain/isplain', ['can/util/can'], function (can) { var core_hasOwn = Object.prototype.hasOwnProperty, isWindow = function (obj) { return obj !== null && obj == obj.window; }, isPlainObject = function (obj) { if (!obj || typeof obj !== 'object' || obj.nodeType || isWindow(obj)) { return false; } try { if (obj.constructor && !core_hasOwn.call(obj, 'constructor') && !core_hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) { return false; } } catch (e) { return false; } var key; for (key in obj) { } return key === undefined || core_hasOwn.call(obj, key); }; can.isPlainObject = isPlainObject; return can; }); /*can@2.3.34#util/inserted/inserted*/ define('can/util/inserted/inserted', ['can/util/can'], function (can) { can.inserted = function (elems, document) { if (!elems.length) { return; } elems = can.makeArray(elems); var doc = document || elems[0].ownerDocument || elems[0], inDocument = false, root = can.$(doc.contains ? doc : doc.body), children; for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { if (!inDocument) { if (elem.getElementsByTagName) { if (can.has(root, elem).length) { inDocument = true; } else { return; } } else { continue; } } if (inDocument && elem.getElementsByTagName) { children = can.makeArray(elem.getElementsByTagName('*')); can.trigger(elem, 'inserted', [], false); for (var j = 0, child; (child = children[j]) !== undefined; j++) { can.trigger(child, 'inserted', [], false); } } } }; can.appendChild = function (el, child, document) { var children; if (child.nodeType === 11) { children = can.makeArray(can.childNodes(child)); } else { children = [child]; } el.appendChild(child); can.inserted(children, document); }; can.insertBefore = function (el, child, ref, document) { var children; if (child.nodeType === 11) { children = can.makeArray(can.childNodes(child)); } else { children = [child]; } el.insertBefore(child, ref); can.inserted(children, document); }; }); /*can@2.3.34#util/util*/ define('can/util/util', [ 'can/util/can', 'can/util/attr/attr', 'can/mootools/mootools', 'can/event/event', 'can/util/fragment', 'can/util/deferred', 'can/util/array/each', 'can/util/object/isplain/isplain', 'can/util/inserted/inserted' ], function (can, attr) { can.trim = function (s) { return s ? s.trim() : s; }; var extend = function () { var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false; if (typeof target === 'boolean') { deep = target; target = arguments[1] || {}; i = 2; } if (typeof target !== 'object' && !can.isFunction(target)) { target = {}; } if (length === i) { target = this; --i; } for (; i < length; i++) { if ((options = arguments[i]) !== null) { for (name in options) { src = target[name]; copy = options[name]; if (target === copy) { continue; } if (deep && copy && (can.isPlainObject(copy) || (copyIsArray = can.isArray(copy)))) { if (copyIsArray) { copyIsArray = false; clone = src && can.isArray(src) ? src : []; } else { clone = src && can.isPlainObject(src) ? src : {}; } target[name] = can.extend(deep, clone, copy); } else if (copy !== undefined) { target[name] = copy; } } } } return target; }; can.extend = extend; can.makeArray = function (item) { if (item === null) { return []; } try { return Type.isEnumerable(item) && typeof item !== 'string' ? Array.prototype.slice.call(item) : [item]; } catch (ex) { var arr = [], i; for (i = 0; i < item.length; ++i) { arr.push(item[i]); } return arr; } }; can.isArray = function (arr) { return typeOf(arr) === 'array'; }; can.inArray = function (item, arr, fromIndex) { if (!arr) { return -1; } return Array.prototype.indexOf.call(arr, item, fromIndex); }; can.map = function (arr, fn) { return Array.from(arr || []).map(fn); }; can.param = function (object) { return Object.toQueryString(object); }; can.isEmptyObject = function (object) { return Object.keys(object).length === 0; }; can.isFunction = function (f) { return typeOf(f) === 'function'; }; can.bind = function (ev, cb) { if (this.bind && this.bind !== can.bind) { this.bind(ev, cb); } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { can.$(this).addEvent(ev, cb); } else if (this.addEvent) { this.addEvent(ev, cb); } else { can.addEvent.call(this, ev, cb); } return this; }; can.unbind = function (ev, cb) { if (this.unbind && this.unbind !== can.unbind) { this.unbind(ev, cb); } else if (this.nodeName && (this.nodeType && this.nodeType !== 11)) { can.$(this).removeEvent(ev, cb); } else if (this.removeEvent) { this.removeEvent(ev, cb); } else { can.removeEvent.call(this, ev, cb); } return this; }; can.on = can.bind; can.off = can.unbind; can.trigger = function (item, event, args, bubble) { bubble = bubble === undefined ? true : bubble; args = args || []; var propagating = true; if (item.fireEvent) { item = item[0] || item; while (item && propagating) { if (!event.type) { event = { type: event, target: item, stopPropagation: function () { propagating = false; } }; } var events = item !== window ? can.$(item).retrieve('events')[0] : item.retrieve('events'); if (events && events[event.type]) { events[event.type].keys.each(function (fn) { fn.apply(item, [event].concat(args)); }, this); } if (bubble && item.parentNode && item.parentNode.nodeType !== 11) { item = item.parentNode; } else { item = null; } } } else { if (typeof event === 'string') { event = { type: event }; } event.target = event.target || item; can.dispatch.call(item, event, can.makeArray(args)); } }; can.delegate = function (selector, ev, cb) { if (this.delegate) { this.delegate(selector, ev, cb); } else if (this.addEvent) { this.addEvent(ev + ':relay(' + selector + ')', cb); } else { can.bind.call(this, ev, cb); } return this; }; can.undelegate = function (selector, ev, cb) { if (this.undelegate) { this.undelegate(selector, ev, cb); } else if (this.removeEvent) { this.removeEvent(ev + ':relay(' + selector + ')', cb); } else { can.unbind.call(this, ev, cb); } return this; }; var optionsMap = { type: 'method', success: undefined, error: undefined }; var updateDeferred = function (xhr, d) { for (var prop in xhr) { if (typeof d[prop] === 'function') { d[prop] = function () { xhr[prop].apply(xhr, arguments); }; } else { d[prop] = prop[xhr]; } } }; can.ajax = function (options) { var d = can.Deferred(), requestOptions = can.extend({}, options), request; for (var option in optionsMap) { if (requestOptions[option] !== undefined) { requestOptions[optionsMap[option]] = requestOptions[option]; delete requestOptions[option]; } } requestOptions.method = requestOptions.method || 'get'; requestOptions.url = requestOptions.url.toString(); var success = options.onSuccess || options.success, error = options.onFailure || options.error; requestOptions.onSuccess = function (response, xml) { var data = response; updateDeferred(request.xhr, d); d.resolve(data, 'success', request.xhr); if (success) { success(data, 'success', request.xhr); } }; requestOptions.onFailure = function () { updateDeferred(request.xhr, d); d.reject(request.xhr, 'error'); if (error) { error(request.xhr, 'error'); } }; if (options.dataType === 'json') { request = new Request.JSON(requestOptions); } else { request = new Request(requestOptions); } request.send(); updateDeferred(request.xhr, d); return d; }; can.$ = function (selector) { if (selector === window) { return window; } return $$(selector && selector.nodeName ? [selector] : selector); }; var old = document.id; document.id = function (el) { if (el && el.nodeType === 11) { return el; } else { return old.apply(document, arguments); } }; can.append = function (wrapped, html) { if (typeof html === 'string') { html = can.buildFragment(html); } return wrapped.grab(html); }; can.filter = function (wrapped, filter) { return wrapped.filter(filter); }; can.data = function (wrapped, key, value) { if (value === undefined) { return wrapped[0].retrieve(key); } else { return wrapped.store(key, value); } }; can.addClass = function (wrapped, className) { return wrapped.addClass(className); }; can.remove = function (wrapped) { var filtered = wrapped.filter(function (node) { if (node.nodeType !== 1) { node.parentNode.removeChild(node); } else { return true; } }); filtered.destroy(); return filtered; }; can.has = function (wrapped, element) { if (Slick.contains(wrapped[0], element)) { return wrapped; } else { return []; } }; var destroy = Element.prototype.destroy, grab = Element.prototype.grab, oldSet = Element.prototype.set; Element.implement({ destroy: function () { can.trigger(this, 'removed', [], false); var elems = this.getElementsByTagName('*'); for (var i = 0, elem; (elem = elems[i]) !== undefined; i++) { can.trigger(elem, 'removed', [], false); } destroy.apply(this, arguments); }, grab: function (el) { var elems; if (el && el.nodeType === 11) { elems = can.makeArray(el.childNodes); } else { elems = [el]; } var ret = grab.apply(this, arguments); can.inserted(elems); return ret; }, set: function (attrName, value) { var isAttributeOrProp = can.inArray(attrName, [ 'events', 'html', 'load', 'morph', 'send', 'tag', 'tween' ]) === -1, newValue, oldValue; if (isAttributeOrProp) { oldValue = this.get(attrName); } var res = oldSet.apply(this, arguments); if (isAttributeOrProp) { newValue = this.get(attrName); } if (newValue !== oldValue) { can.attr.trigger(this, attrName, oldValue); } return res; }.overloadSetter() }); can.get = function (wrapped, index) { return wrapped[index]; }; var idOf = Slick.uidOf; Slick.uidOf = function (node) { if (node.nodeType === 1 || node === window || node.document === document) { return idOf(node); } else { return Math.random(); } }; Element.NativeEvents.hashchange = 2; can.attr = attr; delete attr.MutationObserver; Element.Events.attributes = { onAdd: function () { var el = can.$(this); can.data(el, 'canHasAttributesBindings', (can.data(el, 'canHasAttributes