2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-05-26 00:04:59 +00:00
|
|
|
|
2010-06-17 00:19:11 +00:00
|
|
|
// **********
|
2010-05-26 00:04:59 +00:00
|
|
|
// Title: iq.js
|
2010-07-20 17:17:29 +00:00
|
|
|
// Various helper functions, in the vein of jQuery.
|
2010-06-17 00:19:11 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// ----------
|
|
|
|
// Function: iQ
|
|
|
|
// Returns an iQClass object which represents an individual element or a group
|
|
|
|
// of elements. It works pretty much like jQuery(), with a few exceptions,
|
|
|
|
// most notably that you can't use strings with complex html,
|
|
|
|
// just simple tags like '<div>'.
|
|
|
|
function iQ(selector, context) {
|
|
|
|
// The iQ object is actually just the init constructor 'enhanced'
|
2010-07-29 04:40:55 +00:00
|
|
|
return new iQClass(selector, context);
|
2010-07-29 03:33:43 +00:00
|
|
|
};
|
2010-05-26 00:04:59 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// A simple way to check for HTML strings or ID strings
|
|
|
|
// (both of which we optimize for)
|
|
|
|
let quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/;
|
2010-05-26 00:04:59 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// Match a standalone tag
|
|
|
|
let rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/;
|
2010-05-27 00:04:56 +00:00
|
|
|
|
2010-05-26 00:04:59 +00:00
|
|
|
// ##########
|
2010-07-29 03:33:43 +00:00
|
|
|
// Class: iQClass
|
|
|
|
// The actual class of iQ result objects, representing an individual element
|
|
|
|
// or a group of elements.
|
|
|
|
//
|
|
|
|
// ----------
|
|
|
|
// Function: iQClass
|
|
|
|
// You don't call this directly; this is what's called by iQ().
|
2010-09-08 17:02:08 +00:00
|
|
|
function iQClass(selector, context) {
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// Handle $(""), $(null), or $(undefined)
|
2010-07-29 04:40:55 +00:00
|
|
|
if (!selector) {
|
2010-07-29 03:33:43 +00:00
|
|
|
return this;
|
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// Handle $(DOMElement)
|
2010-07-29 04:40:55 +00:00
|
|
|
if (selector.nodeType) {
|
2010-07-29 03:33:43 +00:00
|
|
|
this.context = selector;
|
|
|
|
this[0] = selector;
|
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// The body element only exists once, optimize finding it
|
2010-07-29 04:40:55 +00:00
|
|
|
if (selector === "body" && !context) {
|
2010-07-29 03:33:43 +00:00
|
|
|
this.context = document;
|
|
|
|
this[0] = document.body;
|
|
|
|
this.selector = "body";
|
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// Handle HTML strings
|
2010-07-29 04:40:55 +00:00
|
|
|
if (typeof selector === "string") {
|
2010-07-29 03:33:43 +00:00
|
|
|
// Are we dealing with HTML string or an ID?
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
let match = quickExpr.exec(selector);
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// Verify a match, and that no context was specified for #id
|
2010-07-29 04:40:55 +00:00
|
|
|
if (match && (match[1] || !context)) {
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// HANDLE $(html) -> $(array)
|
2010-07-29 04:40:55 +00:00
|
|
|
if (match[1]) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let doc = (context ? context.ownerDocument || context : document);
|
|
|
|
|
|
|
|
// If a single string is passed in and it's a single tag
|
|
|
|
// just do a createElement and skip the rest
|
2010-07-29 04:40:55 +00:00
|
|
|
let ret = rsingleTag.exec(selector);
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
if (ret) {
|
|
|
|
if (Utils.isPlainObject(context)) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(false, 'does not support HTML creation with context');
|
2010-07-11 23:48:05 +00:00
|
|
|
} else {
|
2010-07-29 04:40:55 +00:00
|
|
|
selector = [doc.createElement(ret[1])];
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-11 23:48:05 +00:00
|
|
|
} else {
|
2010-08-11 17:06:49 +00:00
|
|
|
Utils.assert(false, 'does not support complex HTML creation');
|
2010-07-29 03:33:43 +00:00
|
|
|
}
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
return Utils.merge(this, selector);
|
2010-07-29 03:33:43 +00:00
|
|
|
|
|
|
|
// HANDLE $("#id")
|
|
|
|
} else {
|
2010-07-29 04:40:55 +00:00
|
|
|
let elem = document.getElementById(match[2]);
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
if (elem) {
|
2010-07-29 03:33:43 +00:00
|
|
|
this.length = 1;
|
|
|
|
this[0] = elem;
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
this.context = document;
|
2010-07-29 03:33:43 +00:00
|
|
|
this.selector = selector;
|
|
|
|
return this;
|
|
|
|
}
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// HANDLE $("TAG")
|
2010-07-29 04:40:55 +00:00
|
|
|
} else if (!context && /^\w+$/.test(selector)) {
|
2010-07-29 03:33:43 +00:00
|
|
|
this.selector = selector;
|
|
|
|
this.context = document;
|
2010-07-29 04:40:55 +00:00
|
|
|
selector = document.getElementsByTagName(selector);
|
|
|
|
return Utils.merge(this, selector);
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// HANDLE $(expr, $(...))
|
2010-07-29 04:40:55 +00:00
|
|
|
} else if (!context || context.iq) {
|
|
|
|
return (context || iQ(document)).find(selector);
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// HANDLE $(expr, context)
|
|
|
|
// (which is just equivalent to: $(context).find(expr)
|
|
|
|
} else {
|
2010-07-29 04:40:55 +00:00
|
|
|
return iQ(context).find(selector);
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
// HANDLE $(function)
|
|
|
|
// Shortcut for document ready
|
|
|
|
} else if (typeof selector == "function") {
|
|
|
|
Utils.log('iQ does not support ready functions');
|
|
|
|
return null;
|
|
|
|
}
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2011-01-17 17:31:39 +00:00
|
|
|
if ("selector" in selector) {
|
2010-07-29 03:33:43 +00:00
|
|
|
this.selector = selector.selector;
|
|
|
|
this.context = selector.context;
|
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
let ret = this || [];
|
2010-07-29 04:40:55 +00:00
|
|
|
if (selector != null) {
|
2010-07-29 03:33:43 +00:00
|
|
|
// The window, strings (and functions) also have 'length'
|
|
|
|
if (selector.length == null || typeof selector == "string" || selector.setInterval) {
|
2010-07-29 04:40:55 +00:00
|
|
|
Array.push(ret, selector);
|
2010-07-29 03:33:43 +00:00
|
|
|
} else {
|
2010-07-29 04:40:55 +00:00
|
|
|
Utils.merge(ret, selector);
|
2010-07-29 03:33:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
2010-08-10 23:31:12 +00:00
|
|
|
};
|
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
iQClass.prototype = {
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2011-02-26 14:28:00 +00:00
|
|
|
// ----------
|
|
|
|
// Function: toString
|
|
|
|
// Prints [iQ...] for debug use
|
|
|
|
toString: function iQClass_toString() {
|
|
|
|
if (this.length > 1) {
|
|
|
|
if (this.selector)
|
|
|
|
return "[iQ (" + this.selector + ")]";
|
|
|
|
else
|
|
|
|
return "[iQ multi-object]";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.length == 1)
|
|
|
|
return "[iQ (" + this[0].toString() + ")]";
|
|
|
|
|
|
|
|
return "[iQ non-object]";
|
|
|
|
},
|
|
|
|
|
2010-07-11 23:48:05 +00:00
|
|
|
// Start with an empty selector
|
|
|
|
selector: "",
|
|
|
|
|
|
|
|
// The default length of a iQ object is 0
|
2010-07-18 15:58:10 +00:00
|
|
|
length: 0,
|
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: each
|
2010-07-11 23:48:05 +00:00
|
|
|
// Execute a callback for every element in the matched set.
|
2010-09-08 17:02:08 +00:00
|
|
|
each: function iQClass_each(callback) {
|
2010-07-24 02:29:32 +00:00
|
|
|
if (typeof callback != "function") {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(false, "each's argument must be a function");
|
2010-07-14 04:08:45 +00:00
|
|
|
return null;
|
|
|
|
}
|
2011-04-15 17:47:43 +00:00
|
|
|
for (let i = 0; this[i] != null && callback(this[i]) !== false; i++) {}
|
2010-07-14 04:08:45 +00:00
|
|
|
return this;
|
2010-07-11 23:48:05 +00:00
|
|
|
},
|
2010-05-27 00:04:56 +00:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: addClass
|
2010-07-20 17:17:29 +00:00
|
|
|
// Adds the given class(es) to the receiver.
|
2010-09-08 17:02:08 +00:00
|
|
|
addClass: function iQClass_addClass(value) {
|
2010-08-11 17:06:49 +00:00
|
|
|
Utils.assertThrow(typeof value == "string" && value,
|
|
|
|
'requires a valid string argument');
|
2010-07-11 23:48:05 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
let length = this.length;
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; i < length; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
2010-07-29 04:40:55 +00:00
|
|
|
if (elem.nodeType === 1) {
|
|
|
|
value.split(/\s+/).forEach(function(className) {
|
2010-07-29 03:33:43 +00:00
|
|
|
elem.classList.add(className);
|
|
|
|
});
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-27 00:04:56 +00:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: removeClass
|
2010-07-20 17:17:29 +00:00
|
|
|
// Removes the given class(es) from the receiver.
|
2010-09-08 17:02:08 +00:00
|
|
|
removeClass: function iQClass_removeClass(value) {
|
2010-07-29 04:40:55 +00:00
|
|
|
if (typeof value != "string" || !value) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(false, 'does not support function argument');
|
2010-07-11 23:48:05 +00:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
let length = this.length;
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; i < length; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
2010-07-29 04:40:55 +00:00
|
|
|
if (elem.nodeType === 1 && elem.className) {
|
|
|
|
value.split(/\s+/).forEach(function(className) {
|
2010-07-29 03:33:43 +00:00
|
|
|
elem.classList.remove(className);
|
|
|
|
});
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-27 00:04:56 +00:00
|
|
|
|
2010-05-28 00:25:14 +00:00
|
|
|
// ----------
|
|
|
|
// Function: hasClass
|
2010-07-20 17:17:29 +00:00
|
|
|
// Returns true is the receiver has the given css class.
|
2010-09-08 17:02:08 +00:00
|
|
|
hasClass: function iQClass_hasClass(singleClassName) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let length = this.length;
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
if (this[i].classList.contains(singleClassName)) {
|
2010-07-11 23:48:05 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2010-05-28 00:25:14 +00:00
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: find
|
2010-07-20 17:17:29 +00:00
|
|
|
// Searches the receiver and its children, returning a new iQ object with
|
|
|
|
// elements that match the given selector.
|
2010-09-08 17:02:08 +00:00
|
|
|
find: function iQClass_find(selector) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let ret = [];
|
|
|
|
let length = 0;
|
2010-05-27 00:04:56 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
let l = this.length;
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; i < l; i++) {
|
2010-07-11 23:48:05 +00:00
|
|
|
length = ret.length;
|
2010-05-27 00:04:56 +00:00
|
|
|
try {
|
2010-07-29 04:40:55 +00:00
|
|
|
Utils.merge(ret, this[i].querySelectorAll(selector));
|
2010-05-27 00:04:56 +00:00
|
|
|
} catch(e) {
|
|
|
|
Utils.log('iQ.find error (bad selector)', e);
|
|
|
|
}
|
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
if (i > 0) {
|
2010-07-11 23:48:05 +00:00
|
|
|
// Make sure that the results are unique
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let n = length; n < ret.length; n++) {
|
|
|
|
for (let r = 0; r < length; r++) {
|
|
|
|
if (ret[r] === ret[n]) {
|
2010-07-11 23:48:05 +00:00
|
|
|
ret.splice(n--, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iQ(ret);
|
|
|
|
},
|
2010-05-27 00:04:56 +00:00
|
|
|
|
2011-02-03 09:51:20 +00:00
|
|
|
// ----------
|
|
|
|
// Function: contains
|
|
|
|
// Check to see if a given DOM node descends from the receiver.
|
|
|
|
contains: function iQClass_contains(selector) {
|
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
|
|
|
|
|
|
|
// fast path when querySelector() can be used
|
|
|
|
if ('string' == typeof selector)
|
|
|
|
return null != this[0].querySelector(selector);
|
|
|
|
|
|
|
|
let object = iQ(selector);
|
|
|
|
Utils.assert(object.length <= 1, 'does not yet support multi-objects');
|
|
|
|
|
|
|
|
let elem = object[0];
|
|
|
|
if (!elem || !elem.parentNode)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
do {
|
|
|
|
elem = elem.parentNode;
|
|
|
|
} while (elem && this[0] != elem);
|
|
|
|
|
|
|
|
return this[0] == elem;
|
|
|
|
},
|
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: remove
|
2010-07-20 17:17:29 +00:00
|
|
|
// Removes the receiver from the DOM.
|
2011-06-22 08:03:32 +00:00
|
|
|
remove: function iQClass_remove(options) {
|
|
|
|
if (!options || !options.preserveEventHandlers)
|
|
|
|
this.unbindAll();
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
2010-07-29 04:40:55 +00:00
|
|
|
if (elem.parentNode) {
|
|
|
|
elem.parentNode.removeChild(elem);
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-27 00:04:56 +00:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: empty
|
2010-07-19 22:27:19 +00:00
|
|
|
// Removes all of the reciever's children and HTML content from the DOM.
|
2010-09-08 17:02:08 +00:00
|
|
|
empty: function iQClass_empty() {
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
2010-07-29 04:40:55 +00:00
|
|
|
while (elem.firstChild) {
|
2011-06-22 08:03:32 +00:00
|
|
|
iQ(elem.firstChild).unbindAll();
|
2010-07-29 04:40:55 +00:00
|
|
|
elem.removeChild(elem.firstChild);
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-27 00:04:56 +00:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: width
|
2011-02-11 19:24:51 +00:00
|
|
|
// Returns the width of the receiver, including padding and border.
|
2010-09-08 17:02:08 +00:00
|
|
|
width: function iQClass_width() {
|
2011-02-11 19:24:51 +00:00
|
|
|
return Math.floor(this[0].offsetWidth);
|
2010-05-27 00:04:56 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: height
|
2011-02-11 19:24:51 +00:00
|
|
|
// Returns the height of the receiver, including padding and border.
|
2010-09-08 17:02:08 +00:00
|
|
|
height: function iQClass_height() {
|
2011-02-11 19:24:51 +00:00
|
|
|
return Math.floor(this[0].offsetHeight);
|
2010-05-27 00:04:56 +00:00
|
|
|
},
|
|
|
|
|
2010-05-28 22:56:00 +00:00
|
|
|
// ----------
|
|
|
|
// Function: position
|
2010-07-30 09:54:30 +00:00
|
|
|
// Returns an object with the receiver's position in left and top
|
2010-07-29 03:33:43 +00:00
|
|
|
// properties.
|
2010-09-08 17:02:08 +00:00
|
|
|
position: function iQClass_position() {
|
2010-08-10 13:22:38 +00:00
|
|
|
let bounds = this.bounds();
|
|
|
|
return new Point(bounds.left, bounds.top);
|
2010-05-28 22:56:00 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: bounds
|
2010-07-20 17:17:29 +00:00
|
|
|
// Returns a <Rect> with the receiver's bounds.
|
2010-09-08 17:02:08 +00:00
|
|
|
bounds: function iQClass_bounds() {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-08-10 13:22:38 +00:00
|
|
|
let rect = this[0].getBoundingClientRect();
|
|
|
|
return new Rect(Math.floor(rect.left), Math.floor(rect.top),
|
|
|
|
Math.floor(rect.width), Math.floor(rect.height));
|
2010-05-27 00:04:56 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: data
|
2010-07-20 17:17:29 +00:00
|
|
|
// Pass in both key and value to attach some data to the receiver;
|
|
|
|
// pass in just key to retrieve it.
|
2010-09-08 17:02:08 +00:00
|
|
|
data: function iQClass_data(key, value) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let data = null;
|
2011-01-17 17:31:39 +00:00
|
|
|
if (value === undefined) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-06-25 23:00:51 +00:00
|
|
|
data = this[0].iQData;
|
2010-07-29 03:33:43 +00:00
|
|
|
if (data)
|
|
|
|
return data[key];
|
|
|
|
else
|
|
|
|
return null;
|
2010-06-04 22:08:24 +00:00
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
2010-06-25 23:00:51 +00:00
|
|
|
data = elem.iQData;
|
2010-06-04 22:08:24 +00:00
|
|
|
|
2010-07-12 00:54:42 +00:00
|
|
|
if (!data)
|
2010-06-04 22:08:24 +00:00
|
|
|
data = elem.iQData = {};
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 22:08:24 +00:00
|
|
|
data[key] = value;
|
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
|
|
|
return this;
|
2010-05-27 00:04:56 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: html
|
2010-07-29 03:33:43 +00:00
|
|
|
// Given a value, sets the receiver's innerHTML to it; otherwise returns
|
|
|
|
// what's already there.
|
2010-09-08 17:02:08 +00:00
|
|
|
html: function iQClass_html(value) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2011-01-17 17:31:39 +00:00
|
|
|
if (value === undefined)
|
2010-05-27 00:04:56 +00:00
|
|
|
return this[0].innerHTML;
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
this[0].innerHTML = value;
|
|
|
|
return this;
|
2010-07-18 15:58:10 +00:00
|
|
|
},
|
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: text
|
2010-07-29 03:33:43 +00:00
|
|
|
// Given a value, sets the receiver's textContent to it; otherwise returns
|
|
|
|
// what's already there.
|
2010-09-08 17:02:08 +00:00
|
|
|
text: function iQClass_text(value) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2011-01-17 17:31:39 +00:00
|
|
|
if (value === undefined) {
|
2010-05-27 00:04:56 +00:00
|
|
|
return this[0].textContent;
|
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(value));
|
2010-07-18 15:58:10 +00:00
|
|
|
},
|
|
|
|
|
2010-06-03 22:31:18 +00:00
|
|
|
// ----------
|
|
|
|
// Function: val
|
2010-07-20 17:17:29 +00:00
|
|
|
// Given a value, sets the receiver's value to it; otherwise returns what's already there.
|
2010-09-08 17:02:08 +00:00
|
|
|
val: function iQClass_val(value) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2011-01-17 17:31:39 +00:00
|
|
|
if (value === undefined) {
|
2010-06-03 22:31:18 +00:00
|
|
|
return this[0].value;
|
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
|
|
|
this[0].value = value;
|
2010-07-11 23:48:05 +00:00
|
|
|
return this;
|
2010-07-18 15:58:10 +00:00
|
|
|
},
|
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: appendTo
|
2010-07-20 17:17:29 +00:00
|
|
|
// Appends the receiver to the result of iQ(selector).
|
2010-09-08 17:02:08 +00:00
|
|
|
appendTo: function iQClass_appendTo(selector) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-05-27 00:04:56 +00:00
|
|
|
iQ(selector).append(this);
|
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-27 00:04:56 +00:00
|
|
|
// ----------
|
|
|
|
// Function: append
|
2010-07-20 17:17:29 +00:00
|
|
|
// Appends the result of iQ(selector) to the receiver.
|
2010-09-08 17:02:08 +00:00
|
|
|
append: function iQClass_append(selector) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let object = iQ(selector);
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(object.length == 1 && this.length == 1,
|
|
|
|
'does not yet support multi-objects (or null objects)');
|
2010-05-27 00:04:56 +00:00
|
|
|
this[0].appendChild(object[0]);
|
|
|
|
return this;
|
2010-05-28 00:25:14 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-22 00:27:12 +00:00
|
|
|
// ----------
|
|
|
|
// Function: attr
|
|
|
|
// Sets or gets an attribute on the element(s).
|
2010-09-08 17:02:08 +00:00
|
|
|
attr: function iQClass_attr(key, value) {
|
2010-08-10 23:31:12 +00:00
|
|
|
Utils.assert(typeof key === 'string', 'string key');
|
2011-01-17 17:31:39 +00:00
|
|
|
if (value === undefined) {
|
2010-08-10 23:31:12 +00:00
|
|
|
Utils.assert(this.length == 1, 'retrieval does not support multi-objects (or null objects)');
|
|
|
|
return this[0].getAttribute(key);
|
2010-06-22 00:27:12 +00:00
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-08-10 23:31:12 +00:00
|
|
|
for (let i = 0; this[i] != null; i++)
|
|
|
|
this[i].setAttribute(key, value);
|
|
|
|
|
2010-06-22 00:27:12 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2010-05-28 00:25:14 +00:00
|
|
|
// ----------
|
|
|
|
// Function: css
|
2010-07-20 17:17:29 +00:00
|
|
|
// Sets or gets CSS properties on the receiver. When setting certain numerical properties,
|
2010-08-09 04:06:54 +00:00
|
|
|
// will automatically add "px". A property can be removed by setting it to null.
|
2010-07-19 22:27:19 +00:00
|
|
|
//
|
2010-07-20 17:17:29 +00:00
|
|
|
// Possible call patterns:
|
2010-07-19 22:27:19 +00:00
|
|
|
// a: object, b: undefined - sets with properties from a
|
|
|
|
// a: string, b: undefined - gets property specified by a
|
2010-07-20 17:17:29 +00:00
|
|
|
// a: string, b: string/number - sets property specified by a to b
|
2010-09-08 17:02:08 +00:00
|
|
|
css: function iQClass_css(a, b) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let properties = null;
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-12 00:54:42 +00:00
|
|
|
if (typeof a === 'string') {
|
2010-07-29 03:33:43 +00:00
|
|
|
let key = a;
|
2011-01-17 17:31:39 +00:00
|
|
|
if (b === undefined) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(this.length == 1, 'retrieval does not support multi-objects (or null objects)');
|
2010-06-10 00:30:02 +00:00
|
|
|
|
2010-08-10 13:22:38 +00:00
|
|
|
return window.getComputedStyle(this[0], null).getPropertyValue(key);
|
2010-05-28 00:25:14 +00:00
|
|
|
}
|
2010-07-11 23:48:05 +00:00
|
|
|
properties = {};
|
|
|
|
properties[key] = b;
|
2011-01-12 15:18:18 +00:00
|
|
|
} else if (a instanceof Rect) {
|
|
|
|
properties = {
|
|
|
|
left: a.left,
|
|
|
|
top: a.top,
|
|
|
|
width: a.width,
|
|
|
|
height: a.height
|
|
|
|
};
|
2010-07-11 23:48:05 +00:00
|
|
|
} else {
|
2010-05-28 00:25:14 +00:00
|
|
|
properties = a;
|
2010-07-11 23:48:05 +00:00
|
|
|
}
|
2010-05-28 00:25:14 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
let pixels = {
|
2010-07-11 23:48:05 +00:00
|
|
|
'left': true,
|
|
|
|
'top': true,
|
|
|
|
'right': true,
|
|
|
|
'bottom': true,
|
|
|
|
'width': true,
|
|
|
|
'height': true
|
|
|
|
};
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
|
|
|
for (let key in properties) {
|
|
|
|
let value = properties[key];
|
2011-01-12 15:20:28 +00:00
|
|
|
|
2010-08-10 23:31:12 +00:00
|
|
|
if (pixels[key] && typeof value != 'string')
|
2010-06-03 22:31:18 +00:00
|
|
|
value += 'px';
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-08-09 04:06:54 +00:00
|
|
|
if (value == null) {
|
|
|
|
elem.style.removeProperty(key);
|
|
|
|
} else if (key.indexOf('-') != -1)
|
2010-06-03 22:31:18 +00:00
|
|
|
elem.style.setProperty(key, value, '');
|
|
|
|
else
|
|
|
|
elem.style[key] = value;
|
2010-07-14 04:03:47 +00:00
|
|
|
}
|
2010-05-28 22:56:00 +00:00
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
|
|
|
return this;
|
2010-05-28 00:25:14 +00:00
|
|
|
},
|
2010-05-28 22:56:00 +00:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: animate
|
2010-07-18 15:58:10 +00:00
|
|
|
// Uses CSS transitions to animate the element.
|
|
|
|
//
|
|
|
|
// Parameters:
|
2010-06-07 23:16:55 +00:00
|
|
|
// css - an object map of the CSS properties to change
|
|
|
|
// options - an object with various properites (see below)
|
|
|
|
//
|
2010-07-18 15:58:10 +00:00
|
|
|
// Possible "options" properties:
|
2010-06-07 23:16:55 +00:00
|
|
|
// duration - how long to animate, in milliseconds
|
2010-07-30 09:54:30 +00:00
|
|
|
// easing - easing function to use. Possibilities include
|
2010-07-29 19:37:25 +00:00
|
|
|
// "tabviewBounce", "easeInQuad". Default is "ease".
|
2010-07-30 09:54:30 +00:00
|
|
|
// complete - function to call once the animation is done, takes nothing
|
2010-07-29 03:33:43 +00:00
|
|
|
// in, but "this" is set to the element that was animated.
|
2010-09-08 17:02:08 +00:00
|
|
|
animate: function iQClass_animate(css, options) {
|
2010-08-11 17:06:49 +00:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-06-07 23:16:55 +00:00
|
|
|
|
2010-08-11 17:06:49 +00:00
|
|
|
if (!options)
|
|
|
|
options = {};
|
2010-06-10 21:35:15 +00:00
|
|
|
|
2010-08-11 17:06:49 +00:00
|
|
|
let easings = {
|
2010-08-13 00:37:22 +00:00
|
|
|
tabviewBounce: "cubic-bezier(0.0, 0.63, .6, 1.29)",
|
2010-08-11 17:06:49 +00:00
|
|
|
easeInQuad: 'ease-in', // TODO: make it a real easeInQuad, or decide we don't care
|
|
|
|
fast: 'cubic-bezier(0.7,0,1,1)'
|
|
|
|
};
|
2010-06-04 23:39:33 +00:00
|
|
|
|
2010-08-11 17:06:49 +00:00
|
|
|
let duration = (options.duration || 400);
|
|
|
|
let easing = (easings[options.easing] || 'ease');
|
|
|
|
|
2011-01-12 15:18:18 +00:00
|
|
|
if (css instanceof Rect) {
|
|
|
|
css = {
|
|
|
|
left: css.left,
|
|
|
|
top: css.top,
|
|
|
|
width: css.width,
|
|
|
|
height: css.height
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-11 17:06:49 +00:00
|
|
|
// The latest versions of Firefox do not animate from a non-explicitly
|
|
|
|
// set css properties. So for each element to be animated, go through
|
|
|
|
// and explicitly define 'em.
|
|
|
|
let rupper = /([A-Z])/g;
|
|
|
|
this.each(function(elem) {
|
|
|
|
let cStyle = window.getComputedStyle(elem, null);
|
|
|
|
for (let prop in css) {
|
|
|
|
prop = prop.replace(rupper, "-$1").toLowerCase();
|
|
|
|
iQ(elem).css(prop, cStyle.getPropertyValue(prop));
|
|
|
|
}
|
|
|
|
});
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-08-11 17:06:49 +00:00
|
|
|
this.css({
|
2012-07-11 02:13:55 +00:00
|
|
|
'transition-property': Object.keys(css).join(", "),
|
|
|
|
'transition-duration': (duration / 1000) + 's',
|
|
|
|
'transition-timing-function': easing
|
2010-08-11 17:06:49 +00:00
|
|
|
});
|
2010-06-10 19:04:39 +00:00
|
|
|
|
2010-08-11 17:06:49 +00:00
|
|
|
this.css(css);
|
|
|
|
|
|
|
|
let self = this;
|
|
|
|
setTimeout(function() {
|
|
|
|
self.css({
|
2012-07-11 02:13:55 +00:00
|
|
|
'transition-property': 'none',
|
|
|
|
'transition-duration': '',
|
|
|
|
'transition-timing-function': ''
|
2010-08-11 17:06:49 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
if (typeof options.complete == "function")
|
|
|
|
options.complete.apply(self);
|
|
|
|
}, duration);
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 00:11:13 +00:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 00:11:13 +00:00
|
|
|
// ----------
|
|
|
|
// Function: fadeOut
|
2010-07-20 17:17:29 +00:00
|
|
|
// Animates the receiver to full transparency. Calls callback on completion.
|
2010-09-08 17:02:08 +00:00
|
|
|
fadeOut: function iQClass_fadeOut(callback) {
|
2011-01-17 17:31:39 +00:00
|
|
|
Utils.assert(typeof callback == "function" || callback === undefined,
|
2010-08-10 18:13:10 +00:00
|
|
|
'does not yet support duration');
|
2010-07-30 09:54:30 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
this.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, {
|
|
|
|
duration: 400,
|
|
|
|
complete: function() {
|
|
|
|
iQ(this).css({display: 'none'});
|
|
|
|
if (typeof callback == "function")
|
|
|
|
callback.apply(this);
|
|
|
|
}
|
|
|
|
});
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 00:11:13 +00:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 00:11:13 +00:00
|
|
|
// ----------
|
|
|
|
// Function: fadeIn
|
2010-07-20 17:17:29 +00:00
|
|
|
// Animates the receiver to full opacity.
|
2010-09-08 17:02:08 +00:00
|
|
|
fadeIn: function iQClass_fadeIn() {
|
2010-08-10 23:31:12 +00:00
|
|
|
this.css({display: ''});
|
|
|
|
this.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, {
|
|
|
|
duration: 400
|
|
|
|
});
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 00:11:13 +00:00
|
|
|
return this;
|
2010-05-28 22:56:00 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 19:34:03 +00:00
|
|
|
// ----------
|
|
|
|
// Function: hide
|
2010-07-19 22:27:19 +00:00
|
|
|
// Hides the receiver.
|
2010-09-08 17:02:08 +00:00
|
|
|
hide: function iQClass_hide() {
|
2010-08-10 23:31:12 +00:00
|
|
|
this.css({display: 'none', opacity: 0});
|
2010-06-04 19:34:03 +00:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-04 19:34:03 +00:00
|
|
|
// ----------
|
|
|
|
// Function: show
|
2010-07-19 22:27:19 +00:00
|
|
|
// Shows the receiver.
|
2010-09-08 17:02:08 +00:00
|
|
|
show: function iQClass_show() {
|
2010-08-10 23:31:12 +00:00
|
|
|
this.css({display: '', opacity: 1});
|
2010-06-04 19:34:03 +00:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-28 00:25:14 +00:00
|
|
|
// ----------
|
|
|
|
// Function: bind
|
2010-07-18 15:58:10 +00:00
|
|
|
// Binds the given function to the given event type. Also wraps the function
|
2010-06-08 00:24:55 +00:00
|
|
|
// in a try/catch block that does a Utils.log on any errors.
|
2010-09-08 17:02:08 +00:00
|
|
|
bind: function iQClass_bind(type, func) {
|
2010-08-11 17:06:49 +00:00
|
|
|
let handler = function(event) func.apply(this, [event]);
|
2010-05-28 22:56:00 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
2010-07-12 00:54:42 +00:00
|
|
|
if (!elem.iQEventData)
|
2010-06-08 00:20:15 +00:00
|
|
|
elem.iQEventData = {};
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-12 00:54:42 +00:00
|
|
|
if (!elem.iQEventData[type])
|
2010-06-08 00:20:15 +00:00
|
|
|
elem.iQEventData[type] = [];
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-08 00:20:15 +00:00
|
|
|
elem.iQEventData[type].push({
|
2010-07-18 15:58:10 +00:00
|
|
|
original: func,
|
2010-06-08 00:20:15 +00:00
|
|
|
modified: handler
|
|
|
|
});
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-08 00:20:15 +00:00
|
|
|
elem.addEventListener(type, handler, false);
|
2010-05-28 00:25:14 +00:00
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
|
|
|
return this;
|
2010-05-28 22:56:00 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-28 22:56:00 +00:00
|
|
|
// ----------
|
|
|
|
// Function: one
|
2010-07-20 17:17:29 +00:00
|
|
|
// Binds the given function to the given event type, but only for one call;
|
2010-07-19 22:27:19 +00:00
|
|
|
// automatically unbinds after the event fires once.
|
2010-09-08 17:02:08 +00:00
|
|
|
one: function iQClass_one(type, func) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(typeof func == "function", 'does not support eventData argument');
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 03:33:43 +00:00
|
|
|
let handler = function(e) {
|
2010-05-28 22:56:00 +00:00
|
|
|
iQ(this).unbind(type, handler);
|
2010-06-04 23:39:33 +00:00
|
|
|
return func.apply(this, [e]);
|
2010-05-28 22:56:00 +00:00
|
|
|
};
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-28 22:56:00 +00:00
|
|
|
return this.bind(type, handler);
|
2010-05-28 00:25:14 +00:00
|
|
|
},
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-05-28 00:25:14 +00:00
|
|
|
// ----------
|
|
|
|
// Function: unbind
|
2010-07-20 17:17:29 +00:00
|
|
|
// Unbinds the given function from the given event type.
|
2010-09-08 17:02:08 +00:00
|
|
|
unbind: function iQClass_unbind(type, func) {
|
2010-08-10 18:13:10 +00:00
|
|
|
Utils.assert(typeof func == "function", 'Must provide a function');
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-07-29 04:40:55 +00:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let elem = this[i];
|
|
|
|
let handler = func;
|
2010-07-12 00:54:42 +00:00
|
|
|
if (elem.iQEventData && elem.iQEventData[type]) {
|
2010-07-29 03:33:43 +00:00
|
|
|
let count = elem.iQEventData[type].length;
|
|
|
|
for (let a = 0; a < count; a++) {
|
|
|
|
let pair = elem.iQEventData[type][a];
|
2010-07-12 00:54:42 +00:00
|
|
|
if (pair.original == func) {
|
2010-07-18 15:58:10 +00:00
|
|
|
handler = pair.modified;
|
2010-06-08 00:20:15 +00:00
|
|
|
elem.iQEventData[type].splice(a, 1);
|
2012-01-25 12:40:11 +00:00
|
|
|
if (!elem.iQEventData[type].length) {
|
|
|
|
delete elem.iQEventData[type];
|
|
|
|
if (!Object.keys(elem.iQEventData).length)
|
|
|
|
delete elem.iQEventData;
|
|
|
|
}
|
2010-06-08 00:20:15 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2010-06-08 00:20:15 +00:00
|
|
|
elem.removeEventListener(type, handler, false);
|
2010-05-28 00:25:14 +00:00
|
|
|
}
|
2010-07-18 15:58:10 +00:00
|
|
|
|
2011-06-22 08:03:32 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: unbindAll
|
|
|
|
// Unbinds all event handlers.
|
|
|
|
unbindAll: function iQClass_unbindAll() {
|
|
|
|
for (let i = 0; this[i] != null; i++) {
|
|
|
|
let elem = this[i];
|
|
|
|
|
|
|
|
for (let j = 0; j < elem.childElementCount; j++)
|
|
|
|
iQ(elem.children[j]).unbindAll();
|
|
|
|
|
|
|
|
if (!elem.iQEventData)
|
|
|
|
continue;
|
|
|
|
|
2012-01-25 12:40:11 +00:00
|
|
|
Object.keys(elem.iQEventData).forEach(function (type) {
|
|
|
|
while (elem.iQEventData && elem.iQEventData[type])
|
2011-06-22 08:03:32 +00:00
|
|
|
this.unbind(type, elem.iQEventData[type][0].original);
|
2012-01-25 12:40:11 +00:00
|
|
|
}, this);
|
2011-06-22 08:03:32 +00:00
|
|
|
}
|
|
|
|
|
2010-07-18 15:58:10 +00:00
|
|
|
return this;
|
2010-05-27 00:04:56 +00:00
|
|
|
}
|
2010-05-26 00:04:59 +00:00
|
|
|
};
|
|
|
|
|
2010-05-28 22:56:00 +00:00
|
|
|
// ----------
|
|
|
|
// Create various event aliases
|
2010-07-29 03:33:43 +00:00
|
|
|
let events = [
|
|
|
|
'keyup',
|
|
|
|
'keydown',
|
2010-11-17 10:49:59 +00:00
|
|
|
'keypress',
|
2010-07-29 03:33:43 +00:00
|
|
|
'mouseup',
|
|
|
|
'mousedown',
|
|
|
|
'mouseover',
|
|
|
|
'mouseout',
|
|
|
|
'mousemove',
|
|
|
|
'click',
|
2012-02-03 13:10:30 +00:00
|
|
|
'dblclick',
|
2010-07-29 03:33:43 +00:00
|
|
|
'resize',
|
|
|
|
'change',
|
|
|
|
'blur',
|
|
|
|
'focus'
|
|
|
|
];
|
|
|
|
|
|
|
|
events.forEach(function(event) {
|
|
|
|
iQClass.prototype[event] = function(func) {
|
|
|
|
return this.bind(event, func);
|
|
|
|
};
|
|
|
|
});
|