????
| Current Path : /home/degesdxb/public_html/wp-content/plugins/motopress-hotel-booking/vendors/canjs/ |
| Current File : //home/degesdxb/public_html/wp-content/plugins/motopress-hotel-booking/vendors/canjs/can.custom.js |
/*!
* CanJS - 2.3.22
* http://canjs.com/
* Copyright (c) 2016 Bitovi
* Fri, 08 Apr 2016 17:39:46 GMT
* Licensed MIT
* Includes: can/construct/construct,can/control/control,can/construct/super/super,can/construct/proxy/proxy
* Download from: http://bitbuilder.herokuapp.com/can.custom.js?configuration=jquery&plugins=can%2Fconstruct%2Fconstruct&plugins=can%2Fcontrol%2Fcontrol&plugins=can%2Fconstruct%2Fsuper%2Fsuper&plugins=can%2Fconstruct%2Fproxy%2Fproxy
*/
/*[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/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 = can.isPromise = function (obj) {
return obj && typeof obj.then === 'function' && typeof obj.pipe === 'function';
};
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 = '@EDGE';
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;
return can;
});
/*can/util/attr/attr*/
define('can/util/attr/attr', ['can/util/can'], function (can) {
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 = true;
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;
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 {
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/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/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/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/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/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) {
// Fork notice: check if the element in not null (see MB-1254)
if (elem && 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/util/jquery/jquery*/
define('can/util/jquery/jquery', [
'jquery/dist/jquery',
'can/util/can',
'can/util/attr/attr',
'can/event/event',
'can/util/fragment',
'can/util/array/each',
'can/util/inserted/inserted'
], function ($, can, attr, event) {
var isBindableElement = function (node) {
return node.nodeName && (node.nodeType === 1 || node.nodeType === 9) || node == window || node.addEventListener;
};
$ = $ || window.jQuery;
$.extend(can, $, {
trigger: function (obj, event, args, bubbles) {
if (isBindableElement(obj)) {
$.event.trigger(event, args, obj, !bubbles);
} else if (obj.trigger) {
obj.trigger(event, args);
} else {
if (typeof event === 'string') {
event = { type: event };
}
event.target = event.target || obj;
if (args) {
if (args.length && typeof args === 'string') {
args = [args];
} else if (!args.length) {
args = [args];
}
}
if (!args) {
args = [];
}
can.dispatch.call(obj, event, args);
}
},
event: can.event,
addEvent: can.addEvent,
removeEvent: can.removeEvent,
buildFragment: can.buildFragment,
$: $,
each: can.each,
bind: function (ev, cb) {
if (this.bind && this.bind !== can.bind) {
this.bind(ev, cb);
} else if (isBindableElement(this)) {
$.event.add(this, ev, cb);
} else {
can.addEvent.call(this, ev, cb);
}
return this;
},
unbind: function (ev, cb) {
if (this.unbind && this.unbind !== can.unbind) {
this.unbind(ev, cb);
} else if (isBindableElement(this)) {
$.event.remove(this, ev, cb);
} else {
can.removeEvent.call(this, ev, cb);
}
return this;
},
delegate: function (selector, ev, cb) {
if (this.delegate) {
this.delegate(selector, ev, cb);
} else if (isBindableElement(this)) {
$(this).delegate(selector, ev, cb);
} else {
can.bind.call(this, ev, cb);
}
return this;
},
undelegate: function (selector, ev, cb) {
if (this.undelegate) {
this.undelegate(selector, ev, cb);
} else if (isBindableElement(this)) {
$(this).undelegate(selector, ev, cb);
} else {
can.unbind.call(this, ev, cb);
}
return this;
},
proxy: can.proxy,
attr: attr
});
can.on = can.bind;
can.off = can.unbind;
$.each([
'append',
'filter',
'addClass',
'remove',
'data',
'get',
'has'
], function (i, name) {
can[name] = function (wrapped) {
return wrapped[name].apply(wrapped, can.makeArray(arguments).slice(1));
};
});
var oldClean = $.cleanData;
$.cleanData = function (elems) {
$.each(elems, function (i, elem) {
if (elem) {
can.trigger(elem, 'removed', [], false);
}
});
oldClean(elems);
};
var oldDomManip = $.fn.domManip, cbIndex;
$.fn.domManip = function (args, cb1, cb2) {
for (var i = 1; i < arguments.length; i++) {
if (typeof arguments[i] === 'function') {
cbIndex = i;
break;
}
}
return oldDomManip.apply(this, arguments);
};
$(document.createElement('div')).append(document.createElement('div'));
var getChildNodes = function (node) {
var childNodes = node.childNodes;
if ('length' in childNodes) {
return can.makeArray(childNodes);
} else {
var cur = node.firstChild;
var nodes = [];
while (cur) {
nodes.push(cur);
cur = cur.nextSibling;
}
return nodes;
}
};
if (cbIndex === undefined) {
$.fn.domManip = oldDomManip;
can.each([
'after',
'prepend',
'before',
'append',
'replaceWith'
], function (name) {
var original = $.fn[name];
$.fn[name] = function () {
var elems = [], args = can.makeArray(arguments);
if (args[0] != null) {
if (typeof args[0] === 'string') {
args[0] = can.buildFragment(args[0]);
}
if (args[0].nodeType === 11) {
elems = getChildNodes(args[0]);
} else if (can.isArrayLike(args[0])) {
elems = can.makeArray(args[0]);
} else {
elems = [args[0]];
}
}
var ret = original.apply(this, args);
can.inserted(elems);
return ret;
};
});
} else {
$.fn.domManip = cbIndex === 2 ? function (args, table, callback) {
return oldDomManip.call(this, args, table, function (elem) {
var elems;
if (elem.nodeType === 11) {
elems = can.makeArray(can.childNodes(elem));
}
var ret = callback.apply(this, arguments);
can.inserted(elems ? elems : [elem]);
return ret;
});
} : function (args, callback) {
return oldDomManip.call(this, args, function (elem) {
var elems;
if (elem.nodeType === 11) {
elems = can.makeArray(can.childNodes(elem));
}
var ret = callback.apply(this, arguments);
can.inserted(elems ? elems : [elem]);
return ret;
});
};
}
var oldAttr = $.attr;
$.attr = function (el, attrName) {
if (can.isDOM(el) && can.attr.MutationObserver) {
return oldAttr.apply(this, arguments);
} else {
var oldValue, newValue;
if (arguments.length >= 3) {
oldValue = oldAttr.call(this, el, attrName);
}
var res = oldAttr.apply(this, arguments);
if (arguments.length >= 3) {
newValue = oldAttr.call(this, el, attrName);
}
if (newValue !== oldValue) {
can.attr.trigger(el, attrName, oldValue);
}
return res;
}
};
var oldRemove = $.removeAttr;
$.removeAttr = function (el, attrName) {
if (can.isDOM(el) && can.attr.MutationObserver) {
return oldRemove.apply(this, arguments);
} else {
var oldValue = oldAttr.call(this, el, attrName), res = oldRemove.apply(this, arguments);
if (oldValue != null) {
can.attr.trigger(el, attrName, oldValue);
}
return res;
}
};
$.event.special.attributes = {
setup: function () {
if (can.isDOM(this) && can.attr.MutationObserver) {
var self = this;
var observer = new can.attr.MutationObserver(function (mutations) {
mutations.forEach(function (mutation) {
var copy = can.simpleExtend({}, mutation);
can.trigger(self, copy, []);
});
});
observer.observe(this, {
attributes: true,
attributeOldValue: true
});
can.data(can.$(this), 'canAttributesObserver', observer);
} else {
can.data(can.$(this), 'canHasAttributesBindings', true);
}
},
teardown: function () {
if (can.isDOM(this) && can.attr.MutationObserver) {
can.data(can.$(this), 'canAttributesObserver').disconnect();
$.removeData(this, 'canAttributesObserver');
} else {
$.removeData(this, 'canHasAttributesBindings');
}
}
};
$.event.special.inserted = {};
$.event.special.removed = {};
return can;
});
/*can/util/util*/
define('can/util/util', ['can/util/jquery/jquery'], function (can) {
return can;
});
/*can/util/string/string*/
define('can/util/string/string', ['can/util/util'], function (can) {
var strUndHash = /_|-/, strColons = /\=\=/, strWords = /([A-Z]+)([A-Z][a-z])/g, strLowUp = /([a-z\d])([A-Z])/g, strDash = /([a-z\d])([A-Z])/g, strReplacer = /\{([^\}]+)\}/g, strQuote = /"/g, strSingleQuote = /'/g, strHyphenMatch = /-+(.)?/g, strCamelMatch = /[a-z][A-Z]/g, getNext = function (obj, prop, add) {
var result = obj[prop];
if (result === undefined && add === true) {
result = obj[prop] = {};
}
return result;
}, isContainer = function (current) {
return /^f|^o/.test(typeof current);
}, convertBadValues = function (content) {
var isInvalid = content === null || content === undefined || isNaN(content) && '' + content === 'NaN';
return '' + (isInvalid ? '' : content);
};
can.extend(can, {
esc: function (content) {
return convertBadValues(content).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(strQuote, '"').replace(strSingleQuote, ''');
},
getObject: function (name, roots, add) {
var parts = name ? name.split('.') : [], length = parts.length, current, r = 0, i, container, rootsLength;
roots = can.isArray(roots) ? roots : [roots || window];
rootsLength = roots.length;
if (!length) {
return roots[0];
}
for (r; r < rootsLength; r++) {
current = roots[r];
container = undefined;
for (i = 0; i < length && isContainer(current); i++) {
container = current;
current = getNext(container, parts[i]);
}
if (container !== undefined && current !== undefined) {
break;
}
}
if (add === false && current !== undefined) {
delete container[parts[i - 1]];
}
if (add === true && current === undefined) {
current = roots[0];
for (i = 0; i < length && isContainer(current); i++) {
current = getNext(current, parts[i], true);
}
}
return current;
},
capitalize: function (s, cache) {
return s.charAt(0).toUpperCase() + s.slice(1);
},
camelize: function (str) {
return convertBadValues(str).replace(strHyphenMatch, function (match, chr) {
return chr ? chr.toUpperCase() : '';
});
},
hyphenate: function (str) {
return convertBadValues(str).replace(strCamelMatch, function (str, offset) {
return str.charAt(0) + '-' + str.charAt(1).toLowerCase();
});
},
underscore: function (s) {
return s.replace(strColons, '/').replace(strWords, '$1_$2').replace(strLowUp, '$1_$2').replace(strDash, '_').toLowerCase();
},
sub: function (str, data, remove) {
var obs = [];
str = str || '';
obs.push(str.replace(strReplacer, function (whole, inside) {
var ob = can.getObject(inside, data, remove === true ? false : undefined);
if (ob === undefined || ob === null) {
obs = null;
return '';
}
if (isContainer(ob) && obs) {
obs.push(ob);
return '';
}
return '' + ob;
}));
return obs === null ? obs : obs.length <= 1 ? obs[0] : obs;
},
replacer: strReplacer,
undHash: strUndHash
});
return can;
});
/*can/construct/construct*/
define('can/construct/construct', ['can/util/string/string'], function (can) {
var initializing = 0;
var canGetDescriptor;
try {
Object.getOwnPropertyDescriptor({});
canGetDescriptor = true;
} catch (e) {
canGetDescriptor = false;
}
var getDescriptor = function (newProps, name) {
var descriptor = Object.getOwnPropertyDescriptor(newProps, name);
if (descriptor && (descriptor.get || descriptor.set)) {
return descriptor;
}
return null;
}, inheritGetterSetter = function (newProps, oldProps, addTo) {
addTo = addTo || newProps;
var descriptor;
for (var name in newProps) {
if (descriptor = getDescriptor(newProps, name)) {
this._defineProperty(addTo, oldProps, name, descriptor);
} else {
can.Construct._overwrite(addTo, oldProps, name, newProps[name]);
}
}
}, simpleInherit = function (newProps, oldProps, addTo) {
addTo = addTo || newProps;
for (var name in newProps) {
can.Construct._overwrite(addTo, oldProps, name, newProps[name]);
}
};
can.Construct = function () {
if (arguments.length) {
return can.Construct.extend.apply(can.Construct, arguments);
}
};
can.extend(can.Construct, {
constructorExtends: true,
newInstance: function () {
var inst = this.instance(), args;
if (inst.setup) {
inst.__inSetup = true;
args = inst.setup.apply(inst, arguments);
delete inst.__inSetup;
}
if (inst.init) {
inst.init.apply(inst, args || arguments);
}
return inst;
},
_inherit: canGetDescriptor ? inheritGetterSetter : simpleInherit,
_defineProperty: function (what, oldProps, propName, descriptor) {
Object.defineProperty(what, propName, descriptor);
},
_overwrite: function (what, oldProps, propName, val) {
what[propName] = val;
},
setup: function (base, fullName) {
this.defaults = can.extend(true, {}, base.defaults, this.defaults);
},
instance: function () {
initializing = 1;
var inst = new this();
initializing = 0;
return inst;
},
extend: function (name, staticProperties, instanceProperties) {
var fullName = name, klass = staticProperties, proto = instanceProperties;
if (typeof fullName !== 'string') {
proto = klass;
klass = fullName;
fullName = null;
}
if (!proto) {
proto = klass;
klass = null;
}
proto = proto || {};
var _super_class = this, _super = this.prototype, Constructor, parts, current, _fullName, _shortName, propName, shortName, namespace, prototype;
prototype = this.instance();
can.Construct._inherit(proto, _super, prototype);
if (fullName) {
parts = fullName.split('.');
shortName = parts.pop();
} else if (klass && klass.shortName) {
shortName = klass.shortName;
} else if (this.shortName) {
shortName = this.shortName;
}
if (typeof constructorName === 'undefined') {
Constructor = function () {
return init.apply(this, arguments);
};
}
function init() {
if (!initializing) {
return this.constructor !== Constructor && arguments.length && Constructor.constructorExtends ? Constructor.extend.apply(Constructor, arguments) : Constructor.newInstance.apply(Constructor, arguments);
}
}
for (propName in _super_class) {
if (_super_class.hasOwnProperty(propName)) {
Constructor[propName] = _super_class[propName];
}
}
can.Construct._inherit(klass, _super_class, Constructor);
if (fullName) {
current = can.getObject(parts.join('.'), window, true);
namespace = current;
_fullName = can.underscore(fullName.replace(/\./g, '_'));
_shortName = can.underscore(shortName);
current[shortName] = Constructor;
}
can.extend(Constructor, {
constructor: Constructor,
prototype: prototype,
namespace: namespace,
_shortName: _shortName,
fullName: fullName,
_fullName: _fullName
});
if (shortName !== undefined) {
Constructor.shortName = shortName;
}
Constructor.prototype.constructor = Constructor;
var t = [_super_class].concat(can.makeArray(arguments)), args = Constructor.setup.apply(Constructor, t);
if (Constructor.init) {
Constructor.init.apply(Constructor, args || t);
}
return Constructor;
}
});
can.Construct.prototype.setup = function () {
};
can.Construct.prototype.init = function () {
};
return can.Construct;
});
/*can/control/control*/
define('can/control/control', [
'can/util/util',
'can/construct/construct'
], function (can) {
var bind = function (el, ev, callback) {
can.bind.call(el, ev, callback);
return function () {
can.unbind.call(el, ev, callback);
};
}, isFunction = can.isFunction, extend = can.extend, each = can.each, slice = [].slice, paramReplacer = /\{([^\}]+)\}/g, special = can.getObject('$.event.special', [can]) || {}, delegate = function (el, selector, ev, callback) {
can.delegate.call(el, selector, ev, callback);
return function () {
can.undelegate.call(el, selector, ev, callback);
};
}, binder = function (el, ev, callback, selector) {
return selector ? delegate(el, can.trim(selector), ev, callback) : bind(el, ev, callback);
}, basicProcessor;
var Control = can.Control = can.Construct({
setup: function () {
can.Construct.setup.apply(this, arguments);
if (can.Control) {
var control = this, funcName;
control.actions = {};
for (funcName in control.prototype) {
if (control._isAction(funcName)) {
control.actions[funcName] = control._action(funcName);
}
}
}
},
_shifter: function (context, name) {
var method = typeof name === 'string' ? context[name] : name;
if (!isFunction(method)) {
method = context[method];
}
return function () {
context.called = name;
return method.apply(context, [this.nodeName ? can.$(this) : this].concat(slice.call(arguments, 0)));
};
},
_isAction: function (methodName) {
var val = this.prototype[methodName], type = typeof val;
return methodName !== 'constructor' && (type === 'function' || type === 'string' && isFunction(this.prototype[val])) && !!(special[methodName] || processors[methodName] || /[^\w]/.test(methodName));
},
_action: function (methodName, options) {
paramReplacer.lastIndex = 0;
if (options || !paramReplacer.test(methodName)) {
var convertedName = options ? can.sub(methodName, this._lookup(options)) : methodName;
if (!convertedName) {
return null;
}
var arr = can.isArray(convertedName), name = arr ? convertedName[1] : convertedName, parts = name.split(/\s+/g), event = parts.pop();
return {
processor: processors[event] || basicProcessor,
parts: [
name,
parts.join(' '),
event
],
delegate: arr ? convertedName[0] : undefined
};
}
},
_lookup: function (options) {
return [
options,
window
];
},
processors: {},
defaults: {}
}, {
setup: function (element, options) {
var cls = this.constructor, pluginname = cls.pluginName || cls._fullName, arr;
this.element = can.$(element);
if (pluginname && pluginname !== 'can_control') {
this.element.addClass(pluginname);
}
arr = can.data(this.element, 'controls');
if (!arr) {
arr = [];
can.data(this.element, 'controls', arr);
}
arr.push(this);
this.options = extend({}, cls.defaults, options);
this.on();
return [
this.element,
this.options
];
},
on: function (el, selector, eventName, func) {
if (!el) {
this.off();
var cls = this.constructor, bindings = this._bindings, actions = cls.actions, element = this.element, destroyCB = can.Control._shifter(this, 'destroy'), funcName, ready;
for (funcName in actions) {
if (actions.hasOwnProperty(funcName)) {
ready = actions[funcName] || cls._action(funcName, this.options, this);
if (ready) {
bindings.control[funcName] = ready.processor(ready.delegate || element, ready.parts[2], ready.parts[1], funcName, this);
}
}
}
can.bind.call(element, 'removed', destroyCB);
bindings.user.push(function (el) {
can.unbind.call(el, 'removed', destroyCB);
});
return bindings.user.length;
}
if (typeof el === 'string') {
func = eventName;
eventName = selector;
selector = el;
el = this.element;
}
if (func === undefined) {
func = eventName;
eventName = selector;
selector = null;
}
if (typeof func === 'string') {
func = can.Control._shifter(this, func);
}
this._bindings.user.push(binder(el, eventName, func, selector));
return this._bindings.user.length;
},
off: function () {
var el = this.element[0], bindings = this._bindings;
if (bindings) {
each(bindings.user || [], function (value) {
value(el);
});
each(bindings.control || {}, function (value) {
value(el);
});
}
this._bindings = {
user: [],
control: {}
};
},
destroy: function () {
if (this.element === null) {
return;
}
var Class = this.constructor, pluginName = Class.pluginName || Class._fullName, controls;
this.off();
if (pluginName && pluginName !== 'can_control') {
this.element.removeClass(pluginName);
}
controls = can.data(this.element, 'controls');
controls.splice(can.inArray(this, controls), 1);
can.trigger(this, 'destroyed');
this.element = null;
}
});
var processors = can.Control.processors;
basicProcessor = function (el, event, selector, methodName, control) {
return binder(el, event, can.Control._shifter(control, methodName), selector);
};
each([
'change',
'click',
'contextmenu',
'dblclick',
'keydown',
'keyup',
'keypress',
'mousedown',
'mousemove',
'mouseout',
'mouseover',
'mouseup',
'reset',
'resize',
'scroll',
'select',
'submit',
'focusin',
'focusout',
'mouseenter',
'mouseleave',
'touchstart',
'touchmove',
'touchcancel',
'touchend',
'touchleave',
'inserted',
'removed',
'dragstart',
'dragenter',
'dragover',
'dragleave',
'drag',
'drop',
'dragend'
], function (v) {
processors[v] = basicProcessor;
});
return Control;
});
/*can/construct/super/super*/
define('can/construct/super/super', [
'can/util/util',
'can/construct/construct'
], function (can, Construct) {
var isFunction = can.isFunction, fnTest = /xyz/.test(function () {
return this.xyz;
}) ? /\b_super\b/ : /.*/, getset = [
'get',
'set'
], getSuper = function (base, name, fn) {
return function () {
var tmp = this._super, ret;
this._super = base[name];
ret = fn.apply(this, arguments);
this._super = tmp;
return ret;
};
};
can.Construct._defineProperty = function (addTo, base, name, descriptor) {
var _super = Object.getOwnPropertyDescriptor(base, name);
if (_super) {
can.each(getset, function (method) {
if (isFunction(_super[method]) && isFunction(descriptor[method])) {
descriptor[method] = getSuper(_super, method, descriptor[method]);
} else if (!isFunction(descriptor[method])) {
descriptor[method] = _super[method];
}
});
}
Object.defineProperty(addTo, name, descriptor);
};
can.Construct._overwrite = function (addTo, base, name, val) {
addTo[name] = isFunction(val) && isFunction(base[name]) && fnTest.test(val) ? getSuper(base, name, val) : val;
};
return can;
});
/*can/construct/proxy/proxy*/
define('can/construct/proxy/proxy', [
'can/util/util',
'can/construct/construct'
], function (can, Construct) {
var isFunction = can.isFunction, isArray = can.isArray, makeArray = can.makeArray, proxy = function (funcs) {
var args = makeArray(arguments), self;
funcs = args.shift();
if (!isArray(funcs)) {
funcs = [funcs];
}
self = this;
return function class_cb() {
var cur = args.concat(makeArray(arguments)), isString, length = funcs.length, f = 0, func;
for (; f < length; f++) {
func = funcs[f];
if (!func) {
continue;
}
isString = typeof func === 'string';
cur = (isString ? self[func] : func).apply(self, cur || []);
if (f < length - 1) {
cur = !isArray(cur) || cur._use_call ? [cur] : cur;
}
}
return cur;
};
};
can.Construct.proxy = can.Construct.prototype.proxy = proxy;
var correctedClasses = [
can.Map,
can.Control,
can.Model
], i = 0;
for (; i < correctedClasses.length; i++) {
if (correctedClasses[i]) {
correctedClasses[i].proxy = proxy;
}
}
return can;
});
/*[global-shim-end]*/
(function (){
window._define = window.define;
window.define = window.define.orig;
})();