2010-05-25 17:04:59 -07:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
2010-06-16 17:19:11 -07:00
|
|
|
* The Original Code is iq.js.
|
2010-05-25 17:04:59 -07:00
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Ian Gilman <ian@iangilman.com>.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2010
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2010-05-27 19:17:01 -07:00
|
|
|
* Aza Raskin <aza@mozilla.com>
|
2010-06-16 17:19:11 -07:00
|
|
|
* Michael Yoshitaka Erlewine <mitcho@mitcho.com>
|
2010-05-25 17:04:59 -07:00
|
|
|
*
|
2010-08-02 13:29:46 -07:00
|
|
|
* This file incorporates work from:
|
|
|
|
* jQuery JavaScript Library v1.4.2: http://code.jquery.com/jquery-1.4.2.js
|
|
|
|
* This incorporated work is covered by the following copyright and
|
|
|
|
* permission notice:
|
2010-05-25 17:04:59 -07:00
|
|
|
* Copyright 2010, John Resig
|
|
|
|
* Dual licensed under the MIT or GPL Version 2 licenses.
|
|
|
|
* http://jquery.org/license
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
2010-06-16 17:19:11 -07:00
|
|
|
// **********
|
2010-05-25 17:04:59 -07:00
|
|
|
// Title: iq.js
|
2010-07-20 10:17:29 -07:00
|
|
|
// Various helper functions, in the vein of jQuery.
|
2010-06-16 17:19:11 -07:00
|
|
|
|
2010-07-28 20:33:43 -07: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-28 21:40:55 -07:00
|
|
|
return new iQClass(selector, context);
|
2010-07-28 20:33:43 -07:00
|
|
|
};
|
2010-05-25 17:04:59 -07:00
|
|
|
|
2010-07-28 20:33:43 -07: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-25 17:04:59 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// Match a standalone tag
|
|
|
|
let rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/;
|
2010-05-26 17:04:56 -07:00
|
|
|
|
2010-05-25 17:04:59 -07:00
|
|
|
// ##########
|
2010-07-28 20:33:43 -07: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().
|
|
|
|
let iQClass = function(selector, context) {
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// Handle $(""), $(null), or $(undefined)
|
2010-07-28 21:40:55 -07:00
|
|
|
if (!selector) {
|
2010-07-28 20:33:43 -07:00
|
|
|
return this;
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// Handle $(DOMElement)
|
2010-07-28 21:40:55 -07:00
|
|
|
if (selector.nodeType) {
|
2010-07-28 20:33:43 -07:00
|
|
|
this.context = selector;
|
|
|
|
this[0] = selector;
|
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// The body element only exists once, optimize finding it
|
2010-07-28 21:40:55 -07:00
|
|
|
if (selector === "body" && !context) {
|
2010-07-28 20:33:43 -07:00
|
|
|
this.context = document;
|
|
|
|
this[0] = document.body;
|
|
|
|
this.selector = "body";
|
|
|
|
this.length = 1;
|
|
|
|
return this;
|
|
|
|
}
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// Handle HTML strings
|
2010-07-28 21:40:55 -07:00
|
|
|
if (typeof selector === "string") {
|
2010-07-28 20:33:43 -07:00
|
|
|
// Are we dealing with HTML string or an ID?
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
let match = quickExpr.exec(selector);
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// Verify a match, and that no context was specified for #id
|
2010-07-28 21:40:55 -07:00
|
|
|
if (match && (match[1] || !context)) {
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// HANDLE $(html) -> $(array)
|
2010-07-28 21:40:55 -07:00
|
|
|
if (match[1]) {
|
2010-07-28 20:33:43 -07: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-28 21:40:55 -07:00
|
|
|
let ret = rsingleTag.exec(selector);
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
if (ret) {
|
|
|
|
if (Utils.isPlainObject(context)) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(false, 'does not support HTML creation with context');
|
2010-07-11 16:48:05 -07:00
|
|
|
} else {
|
2010-07-28 21:40:55 -07:00
|
|
|
selector = [doc.createElement(ret[1])];
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-11 16:48:05 -07:00
|
|
|
} else {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(false, 'does not support complex HTML creation');
|
2010-07-28 20:33:43 -07:00
|
|
|
}
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
return Utils.merge(this, selector);
|
2010-07-28 20:33:43 -07:00
|
|
|
|
|
|
|
// HANDLE $("#id")
|
|
|
|
} else {
|
2010-07-28 21:40:55 -07:00
|
|
|
let elem = document.getElementById(match[2]);
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
if (elem) {
|
2010-07-28 20:33:43 -07:00
|
|
|
this.length = 1;
|
|
|
|
this[0] = elem;
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
this.context = document;
|
2010-07-28 20:33:43 -07:00
|
|
|
this.selector = selector;
|
|
|
|
return this;
|
|
|
|
}
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// HANDLE $("TAG")
|
2010-07-28 21:40:55 -07:00
|
|
|
} else if (!context && /^\w+$/.test(selector)) {
|
2010-07-28 20:33:43 -07:00
|
|
|
this.selector = selector;
|
|
|
|
this.context = document;
|
2010-07-28 21:40:55 -07:00
|
|
|
selector = document.getElementsByTagName(selector);
|
|
|
|
return Utils.merge(this, selector);
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// HANDLE $(expr, $(...))
|
2010-07-28 21:40:55 -07:00
|
|
|
} else if (!context || context.iq) {
|
|
|
|
return (context || iQ(document)).find(selector);
|
2010-07-11 16:48:05 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
// HANDLE $(expr, context)
|
|
|
|
// (which is just equivalent to: $(context).find(expr)
|
|
|
|
} else {
|
2010-07-28 21:40:55 -07:00
|
|
|
return iQ(context).find(selector);
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
|
|
|
|
2010-07-28 20:33:43 -07: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 16:48:05 -07:00
|
|
|
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof selector.selector !== "undefined") {
|
2010-07-28 20:33:43 -07:00
|
|
|
this.selector = selector.selector;
|
|
|
|
this.context = selector.context;
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let ret = this || [];
|
2010-07-28 21:40:55 -07:00
|
|
|
if (selector != null) {
|
2010-07-28 20:33:43 -07:00
|
|
|
// The window, strings (and functions) also have 'length'
|
|
|
|
if (selector.length == null || typeof selector == "string" || selector.setInterval) {
|
2010-07-28 21:40:55 -07:00
|
|
|
Array.push(ret, selector);
|
2010-07-28 20:33:43 -07:00
|
|
|
} else {
|
2010-07-28 21:40:55 -07:00
|
|
|
Utils.merge(ret, selector);
|
2010-07-28 20:33:43 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
iQClass.prototype = {
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-11 16:48:05 -07:00
|
|
|
// Start with an empty selector
|
|
|
|
selector: "",
|
|
|
|
|
|
|
|
// The current version of iQ being used
|
|
|
|
iq: "1.4.2",
|
|
|
|
|
|
|
|
// The default length of a iQ object is 0
|
2010-07-18 08:58:10 -07:00
|
|
|
length: 0,
|
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: each
|
2010-07-11 16:48:05 -07:00
|
|
|
// Execute a callback for every element in the matched set.
|
2010-07-28 21:40:55 -07:00
|
|
|
each: function(callback) {
|
2010-07-23 19:29:32 -07:00
|
|
|
if (typeof callback != "function") {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(false, "each's argument must be a function");
|
2010-07-13 21:08:45 -07:00
|
|
|
return null;
|
|
|
|
}
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
callback(this[i]);
|
2010-07-13 21:03:47 -07:00
|
|
|
}
|
2010-07-13 21:08:45 -07:00
|
|
|
return this;
|
2010-07-11 16:48:05 -07:00
|
|
|
},
|
2010-05-26 17:04:56 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: addClass
|
2010-07-20 10:17:29 -07:00
|
|
|
// Adds the given class(es) to the receiver.
|
2010-07-28 21:40:55 -07:00
|
|
|
addClass: function(value) {
|
|
|
|
if (typeof value != "string" || !value) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(false, 'requires a valid string argument');
|
2010-07-11 16:48:05 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let length = this.length;
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; i < length; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
2010-07-28 21:40:55 -07:00
|
|
|
if (elem.nodeType === 1) {
|
|
|
|
value.split(/\s+/).forEach(function(className) {
|
2010-07-28 20:33:43 -07:00
|
|
|
elem.classList.add(className);
|
|
|
|
});
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-26 17:04:56 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: removeClass
|
2010-07-20 10:17:29 -07:00
|
|
|
// Removes the given class(es) from the receiver.
|
2010-07-28 21:40:55 -07:00
|
|
|
removeClass: function(value) {
|
|
|
|
if (typeof value != "string" || !value) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(false, 'does not support function argument');
|
2010-07-11 16:48:05 -07:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let length = this.length;
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; i < length; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
2010-07-28 21:40:55 -07:00
|
|
|
if (elem.nodeType === 1 && elem.className) {
|
|
|
|
value.split(/\s+/).forEach(function(className) {
|
2010-07-28 20:33:43 -07:00
|
|
|
elem.classList.remove(className);
|
|
|
|
});
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-26 17:04:56 -07:00
|
|
|
|
2010-05-27 17:25:14 -07:00
|
|
|
// ----------
|
|
|
|
// Function: hasClass
|
2010-07-20 10:17:29 -07:00
|
|
|
// Returns true is the receiver has the given css class.
|
2010-07-28 21:40:55 -07:00
|
|
|
hasClass: function(singleClassName) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let length = this.length;
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
if (this[i].classList.contains(singleClassName)) {
|
2010-07-11 16:48:05 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
},
|
2010-05-27 17:25:14 -07:00
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: find
|
2010-07-20 10:17:29 -07:00
|
|
|
// Searches the receiver and its children, returning a new iQ object with
|
|
|
|
// elements that match the given selector.
|
2010-07-28 21:40:55 -07:00
|
|
|
find: function(selector) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let ret = [];
|
|
|
|
let length = 0;
|
2010-05-26 17:04:56 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let l = this.length;
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; i < l; i++) {
|
2010-07-11 16:48:05 -07:00
|
|
|
length = ret.length;
|
2010-05-26 17:04:56 -07:00
|
|
|
try {
|
2010-07-28 21:40:55 -07:00
|
|
|
Utils.merge(ret, this[i].querySelectorAll(selector));
|
2010-05-26 17:04:56 -07:00
|
|
|
} catch(e) {
|
|
|
|
Utils.log('iQ.find error (bad selector)', e);
|
|
|
|
}
|
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
if (i > 0) {
|
2010-07-11 16:48:05 -07:00
|
|
|
// Make sure that the results are unique
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let n = length; n < ret.length; n++) {
|
|
|
|
for (let r = 0; r < length; r++) {
|
|
|
|
if (ret[r] === ret[n]) {
|
2010-07-11 16:48:05 -07:00
|
|
|
ret.splice(n--, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return iQ(ret);
|
|
|
|
},
|
2010-05-26 17:04:56 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: remove
|
2010-07-20 10:17:29 -07:00
|
|
|
// Removes the receiver from the DOM.
|
2010-07-29 17:23:49 -07:00
|
|
|
remove: function() {
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
2010-07-28 21:40:55 -07:00
|
|
|
if (elem.parentNode) {
|
|
|
|
elem.parentNode.removeChild(elem);
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-26 17:04:56 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: empty
|
2010-07-19 15:27:19 -07:00
|
|
|
// Removes all of the reciever's children and HTML content from the DOM.
|
2010-07-11 16:48:05 -07:00
|
|
|
empty: function() {
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
2010-07-28 21:40:55 -07:00
|
|
|
while (elem.firstChild) {
|
|
|
|
elem.removeChild(elem.firstChild);
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
},
|
2010-05-26 17:04:56 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: width
|
2010-07-20 10:17:29 -07:00
|
|
|
// Returns the width of the receiver.
|
2010-07-29 17:23:49 -07:00
|
|
|
width: function() {
|
2010-08-10 06:22:38 -07:00
|
|
|
let bounds = this.bounds();
|
|
|
|
return bounds.width
|
2010-05-26 17:04:56 -07:00
|
|
|
},
|
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: height
|
2010-07-19 15:27:19 -07:00
|
|
|
// Returns the height of the receiver.
|
2010-07-29 17:23:49 -07:00
|
|
|
height: function() {
|
2010-08-10 06:22:38 -07:00
|
|
|
let bounds = this.bounds();
|
|
|
|
return bounds.height;
|
2010-05-26 17:04:56 -07:00
|
|
|
},
|
|
|
|
|
2010-05-28 15:56:00 -07:00
|
|
|
// ----------
|
|
|
|
// Function: position
|
2010-07-30 02:54:30 -07:00
|
|
|
// Returns an object with the receiver's position in left and top
|
2010-07-28 20:33:43 -07:00
|
|
|
// properties.
|
2010-07-29 17:23:49 -07:00
|
|
|
position: function() {
|
2010-08-10 06:22:38 -07:00
|
|
|
let bounds = this.bounds();
|
|
|
|
return new Point(bounds.left, bounds.top);
|
2010-05-28 15:56:00 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: bounds
|
2010-07-20 10:17:29 -07:00
|
|
|
// Returns a <Rect> with the receiver's bounds.
|
2010-07-28 20:33:43 -07:00
|
|
|
bounds: function() {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-08-10 06:22:38 -07: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-26 17:04:56 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: data
|
2010-07-20 10:17:29 -07:00
|
|
|
// Pass in both key and value to attach some data to the receiver;
|
|
|
|
// pass in just key to retrieve it.
|
2010-05-26 17:04:56 -07:00
|
|
|
data: function(key, value) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let data = null;
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof value === "undefined") {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-06-25 16:00:51 -07:00
|
|
|
data = this[0].iQData;
|
2010-07-28 20:33:43 -07:00
|
|
|
if (data)
|
|
|
|
return data[key];
|
|
|
|
else
|
|
|
|
return null;
|
2010-06-04 15:08:24 -07:00
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
2010-06-25 16:00:51 -07:00
|
|
|
data = elem.iQData;
|
2010-06-04 15:08:24 -07:00
|
|
|
|
2010-07-11 17:54:42 -07:00
|
|
|
if (!data)
|
2010-06-04 15:08:24 -07:00
|
|
|
data = elem.iQData = {};
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-04 15:08:24 -07:00
|
|
|
data[key] = value;
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
|
|
|
return this;
|
2010-05-26 17:04:56 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: html
|
2010-07-28 20:33:43 -07:00
|
|
|
// Given a value, sets the receiver's innerHTML to it; otherwise returns
|
|
|
|
// what's already there.
|
2010-05-26 17:04:56 -07:00
|
|
|
html: function(value) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof value === "undefined")
|
2010-05-26 17:04:56 -07:00
|
|
|
return this[0].innerHTML;
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
this[0].innerHTML = value;
|
|
|
|
return this;
|
2010-07-18 08:58:10 -07:00
|
|
|
},
|
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: text
|
2010-07-28 20:33:43 -07:00
|
|
|
// Given a value, sets the receiver's textContent to it; otherwise returns
|
|
|
|
// what's already there.
|
2010-05-26 17:04:56 -07:00
|
|
|
text: function(value) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof value === "undefined") {
|
2010-05-26 17:04:56 -07:00
|
|
|
return this[0].textContent;
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
return this.empty().append((this[0] && this[0].ownerDocument || document).createTextNode(value));
|
2010-07-18 08:58:10 -07:00
|
|
|
},
|
|
|
|
|
2010-06-03 15:31:18 -07:00
|
|
|
// ----------
|
|
|
|
// Function: val
|
2010-07-20 10:17:29 -07:00
|
|
|
// Given a value, sets the receiver's value to it; otherwise returns what's already there.
|
2010-06-03 15:31:18 -07:00
|
|
|
val: function(value) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof value === "undefined") {
|
2010-06-03 15:31:18 -07:00
|
|
|
return this[0].value;
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
|
|
|
this[0].value = value;
|
2010-07-11 16:48:05 -07:00
|
|
|
return this;
|
2010-07-18 08:58:10 -07:00
|
|
|
},
|
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: appendTo
|
2010-07-20 10:17:29 -07:00
|
|
|
// Appends the receiver to the result of iQ(selector).
|
2010-05-26 17:04:56 -07:00
|
|
|
appendTo: function(selector) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-05-26 17:04:56 -07:00
|
|
|
iQ(selector).append(this);
|
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-26 17:04:56 -07:00
|
|
|
// ----------
|
|
|
|
// Function: append
|
2010-07-20 10:17:29 -07:00
|
|
|
// Appends the result of iQ(selector) to the receiver.
|
2010-05-26 17:04:56 -07:00
|
|
|
append: function(selector) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let object = iQ(selector);
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(object.length == 1 && this.length == 1,
|
|
|
|
'does not yet support multi-objects (or null objects)');
|
2010-05-26 17:04:56 -07:00
|
|
|
this[0].appendChild(object[0]);
|
|
|
|
return this;
|
2010-05-27 17:25:14 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-21 17:27:12 -07:00
|
|
|
// ----------
|
|
|
|
// Function: attr
|
|
|
|
// Sets or gets an attribute on the element(s).
|
|
|
|
attr: function(key, value) {
|
|
|
|
try {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(typeof key === 'string', 'string key');
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof value === "undefined") {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'retrieval does not support multi-objects (or null objects)');
|
2010-06-21 17:27:12 -07:00
|
|
|
return this[0].getAttribute(key);
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
this[i].setAttribute(key, value);
|
2010-07-18 08:58:10 -07:00
|
|
|
}
|
2010-06-21 17:27:12 -07:00
|
|
|
} catch(e) {
|
|
|
|
Utils.log(e);
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-21 17:27:12 -07:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2010-05-27 17:25:14 -07:00
|
|
|
// ----------
|
|
|
|
// Function: css
|
2010-07-20 10:17:29 -07:00
|
|
|
// Sets or gets CSS properties on the receiver. When setting certain numerical properties,
|
2010-08-08 21:06:54 -07:00
|
|
|
// will automatically add "px". A property can be removed by setting it to null.
|
2010-07-19 15:27:19 -07:00
|
|
|
//
|
2010-07-20 10:17:29 -07:00
|
|
|
// Possible call patterns:
|
2010-07-19 15:27:19 -07:00
|
|
|
// a: object, b: undefined - sets with properties from a
|
|
|
|
// a: string, b: undefined - gets property specified by a
|
2010-07-20 10:17:29 -07:00
|
|
|
// a: string, b: string/number - sets property specified by a to b
|
2010-05-27 17:25:14 -07:00
|
|
|
css: function(a, b) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let properties = null;
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-11 17:54:42 -07:00
|
|
|
if (typeof a === 'string') {
|
2010-07-28 20:33:43 -07:00
|
|
|
let key = a;
|
2010-07-29 17:23:49 -07:00
|
|
|
if (typeof b === "undefined") {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'retrieval does not support multi-objects (or null objects)');
|
2010-06-09 17:30:02 -07:00
|
|
|
|
2010-08-10 06:22:38 -07:00
|
|
|
return window.getComputedStyle(this[0], null).getPropertyValue(key);
|
2010-05-27 17:25:14 -07:00
|
|
|
}
|
2010-07-11 16:48:05 -07:00
|
|
|
properties = {};
|
|
|
|
properties[key] = b;
|
|
|
|
} else {
|
2010-05-27 17:25:14 -07:00
|
|
|
properties = a;
|
2010-07-11 16:48:05 -07:00
|
|
|
}
|
2010-05-27 17:25:14 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let pixels = {
|
2010-07-11 16:48:05 -07:00
|
|
|
'left': true,
|
|
|
|
'top': true,
|
|
|
|
'right': true,
|
|
|
|
'bottom': true,
|
|
|
|
'width': true,
|
|
|
|
'height': true
|
|
|
|
};
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
|
|
|
for (let key in properties) {
|
|
|
|
let value = properties[key];
|
2010-07-18 08:58:10 -07:00
|
|
|
if (pixels[key] && typeof(value) != 'string')
|
2010-06-03 15:31:18 -07:00
|
|
|
value += 'px';
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-08-08 21:06:54 -07:00
|
|
|
if (value == null) {
|
|
|
|
elem.style.removeProperty(key);
|
|
|
|
} else if (key.indexOf('-') != -1)
|
2010-06-03 15:31:18 -07:00
|
|
|
elem.style.setProperty(key, value, '');
|
|
|
|
else
|
|
|
|
elem.style[key] = value;
|
2010-07-13 21:03:47 -07:00
|
|
|
}
|
2010-05-28 15:56:00 -07:00
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
|
|
|
return this;
|
2010-05-27 17:25:14 -07:00
|
|
|
},
|
2010-05-28 15:56:00 -07:00
|
|
|
|
|
|
|
// ----------
|
|
|
|
// Function: animate
|
2010-07-18 08:58:10 -07:00
|
|
|
// Uses CSS transitions to animate the element.
|
|
|
|
//
|
|
|
|
// Parameters:
|
2010-06-07 16:16:55 -07:00
|
|
|
// css - an object map of the CSS properties to change
|
|
|
|
// options - an object with various properites (see below)
|
|
|
|
//
|
2010-07-18 08:58:10 -07:00
|
|
|
// Possible "options" properties:
|
2010-06-07 16:16:55 -07:00
|
|
|
// duration - how long to animate, in milliseconds
|
2010-07-30 02:54:30 -07:00
|
|
|
// easing - easing function to use. Possibilities include
|
2010-07-29 12:37:25 -07:00
|
|
|
// "tabviewBounce", "easeInQuad". Default is "ease".
|
2010-07-30 02:54:30 -07:00
|
|
|
// complete - function to call once the animation is done, takes nothing
|
2010-07-28 20:33:43 -07:00
|
|
|
// in, but "this" is set to the element that was animated.
|
2010-06-07 16:16:55 -07:00
|
|
|
animate: function(css, options) {
|
2010-05-28 15:56:00 -07:00
|
|
|
try {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(this.length == 1, 'does not yet support multi-objects (or null objects)');
|
2010-06-07 16:16:55 -07:00
|
|
|
|
2010-07-11 17:54:42 -07:00
|
|
|
if (!options)
|
2010-06-07 16:16:55 -07:00
|
|
|
options = {};
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let easings = {
|
2010-08-09 14:57:34 -07:00
|
|
|
tabviewBounce: "cubic-bezier(0.0, 0.63, .6, 1.0)",
|
|
|
|
// TODO: change 1.0 above to 1.29 after bug 575672 is fixed
|
|
|
|
|
2010-06-11 17:57:02 -07: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-07 16:16:55 -07:00
|
|
|
};
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let duration = (options.duration || 400);
|
|
|
|
let easing = (easings[options.easing] || 'ease');
|
2010-06-07 16:16:55 -07:00
|
|
|
|
2010-07-30 02:54:30 -07: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
|
2010-07-28 20:33:43 -07:00
|
|
|
// and explicitly define 'em.
|
|
|
|
let rupper = /([A-Z])/g;
|
2010-07-30 02:54:30 -07:00
|
|
|
this.each(function(elem) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let cStyle = window.getComputedStyle(elem, null);
|
2010-07-30 02:54:30 -07:00
|
|
|
for (let prop in css) {
|
2010-07-28 21:40:55 -07:00
|
|
|
prop = prop.replace(rupper, "-$1").toLowerCase();
|
2010-07-13 21:03:47 -07:00
|
|
|
iQ(elem).css(prop, cStyle.getPropertyValue(prop));
|
2010-07-18 08:58:10 -07:00
|
|
|
}
|
2010-06-10 14:35:15 -07:00
|
|
|
});
|
|
|
|
|
2010-06-04 16:39:33 -07:00
|
|
|
this.css({
|
2010-07-18 08:58:10 -07:00
|
|
|
'-moz-transition-property': 'all', // TODO: just animate the properties we're changing
|
|
|
|
'-moz-transition-duration': (duration / 1000) + 's',
|
2010-06-07 16:16:55 -07:00
|
|
|
'-moz-transition-timing-function': easing
|
2010-06-04 16:39:33 -07:00
|
|
|
});
|
|
|
|
|
2010-06-07 16:16:55 -07:00
|
|
|
this.css(css);
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let self = this;
|
2010-08-10 06:30:23 -07:00
|
|
|
setTimeout(function() {
|
2010-06-10 12:04:39 -07:00
|
|
|
self.css({
|
2010-07-18 08:58:10 -07:00
|
|
|
'-moz-transition-property': 'none',
|
|
|
|
'-moz-transition-duration': '',
|
2010-06-10 12:04:39 -07:00
|
|
|
'-moz-transition-timing-function': ''
|
|
|
|
});
|
|
|
|
|
2010-07-23 19:29:32 -07:00
|
|
|
if (typeof options.complete == "function")
|
2010-06-10 12:04:39 -07:00
|
|
|
options.complete.apply(self);
|
2010-06-07 16:16:55 -07:00
|
|
|
}, duration);
|
2010-05-28 15:56:00 -07:00
|
|
|
} catch(e) {
|
2010-06-07 16:16:55 -07:00
|
|
|
Utils.log(e);
|
2010-05-28 15:56:00 -07:00
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-03 17:11:13 -07:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-03 17:11:13 -07:00
|
|
|
// ----------
|
|
|
|
// Function: fadeOut
|
2010-07-20 10:17:29 -07:00
|
|
|
// Animates the receiver to full transparency. Calls callback on completion.
|
2010-06-04 15:08:24 -07:00
|
|
|
fadeOut: function(callback) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(typeof callback == "function" || typeof callback === "undefined",
|
|
|
|
'does not yet support duration');
|
2010-07-30 02:54:30 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
this.animate({
|
|
|
|
opacity: 0
|
|
|
|
}, {
|
|
|
|
duration: 400,
|
|
|
|
complete: function() {
|
|
|
|
iQ(this).css({display: 'none'});
|
|
|
|
if (typeof callback == "function")
|
|
|
|
callback.apply(this);
|
|
|
|
}
|
|
|
|
});
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-03 17:11:13 -07:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-03 17:11:13 -07:00
|
|
|
// ----------
|
|
|
|
// Function: fadeIn
|
2010-07-20 10:17:29 -07:00
|
|
|
// Animates the receiver to full opacity.
|
2010-06-03 17:11:13 -07:00
|
|
|
fadeIn: function() {
|
|
|
|
try {
|
|
|
|
this.css({display: ''});
|
2010-06-08 17:13:19 -07:00
|
|
|
this.animate({
|
|
|
|
opacity: 1
|
|
|
|
}, {
|
|
|
|
duration: 400
|
2010-07-18 08:58:10 -07:00
|
|
|
});
|
2010-06-03 17:11:13 -07:00
|
|
|
} catch(e) {
|
|
|
|
Utils.log(e);
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-03 17:11:13 -07:00
|
|
|
return this;
|
2010-05-28 15:56:00 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-04 12:34:03 -07:00
|
|
|
// ----------
|
|
|
|
// Function: hide
|
2010-07-19 15:27:19 -07:00
|
|
|
// Hides the receiver.
|
2010-06-04 12:34:03 -07:00
|
|
|
hide: function() {
|
|
|
|
try {
|
|
|
|
this.css({display: 'none', opacity: 0});
|
|
|
|
} catch(e) {
|
|
|
|
Utils.log(e);
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-04 12:34:03 -07:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-04 12:34:03 -07:00
|
|
|
// ----------
|
|
|
|
// Function: show
|
2010-07-19 15:27:19 -07:00
|
|
|
// Shows the receiver.
|
2010-06-04 12:34:03 -07:00
|
|
|
show: function() {
|
|
|
|
try {
|
|
|
|
this.css({display: '', opacity: 1});
|
|
|
|
} catch(e) {
|
|
|
|
Utils.log(e);
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-04 12:34:03 -07:00
|
|
|
return this;
|
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-27 17:25:14 -07:00
|
|
|
// ----------
|
|
|
|
// Function: bind
|
2010-07-18 08:58:10 -07:00
|
|
|
// Binds the given function to the given event type. Also wraps the function
|
2010-06-07 17:24:55 -07:00
|
|
|
// in a try/catch block that does a Utils.log on any errors.
|
2010-05-27 17:25:14 -07:00
|
|
|
bind: function(type, func) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(typeof func == "function", 'does not support eventData argument');
|
2010-05-28 15:56:00 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let handler = function(event) {
|
2010-05-28 15:56:00 -07:00
|
|
|
try {
|
2010-06-25 16:00:51 -07:00
|
|
|
return func.apply(this, [event]);
|
2010-05-28 15:56:00 -07:00
|
|
|
} catch(e) {
|
|
|
|
Utils.log(e);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
2010-07-11 17:54:42 -07:00
|
|
|
if (!elem.iQEventData)
|
2010-06-07 17:20:15 -07:00
|
|
|
elem.iQEventData = {};
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-11 17:54:42 -07:00
|
|
|
if (!elem.iQEventData[type])
|
2010-06-07 17:20:15 -07:00
|
|
|
elem.iQEventData[type] = [];
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-07 17:20:15 -07:00
|
|
|
elem.iQEventData[type].push({
|
2010-07-18 08:58:10 -07:00
|
|
|
original: func,
|
2010-06-07 17:20:15 -07:00
|
|
|
modified: handler
|
|
|
|
});
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-07 17:20:15 -07:00
|
|
|
elem.addEventListener(type, handler, false);
|
2010-05-27 17:25:14 -07:00
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
|
|
|
return this;
|
2010-05-28 15:56:00 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-28 15:56:00 -07:00
|
|
|
// ----------
|
|
|
|
// Function: one
|
2010-07-20 10:17:29 -07:00
|
|
|
// Binds the given function to the given event type, but only for one call;
|
2010-07-19 15:27:19 -07:00
|
|
|
// automatically unbinds after the event fires once.
|
2010-05-28 15:56:00 -07:00
|
|
|
one: function(type, func) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(typeof func == "function", 'does not support eventData argument');
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 20:33:43 -07:00
|
|
|
let handler = function(e) {
|
2010-05-28 15:56:00 -07:00
|
|
|
iQ(this).unbind(type, handler);
|
2010-06-04 16:39:33 -07:00
|
|
|
return func.apply(this, [e]);
|
2010-05-28 15:56:00 -07:00
|
|
|
};
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-28 15:56:00 -07:00
|
|
|
return this.bind(type, handler);
|
2010-05-27 17:25:14 -07:00
|
|
|
},
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-05-27 17:25:14 -07:00
|
|
|
// ----------
|
|
|
|
// Function: unbind
|
2010-07-20 10:17:29 -07:00
|
|
|
// Unbinds the given function from the given event type.
|
2010-05-27 17:25:14 -07:00
|
|
|
unbind: function(type, func) {
|
2010-08-10 11:13:10 -07:00
|
|
|
Utils.assert(typeof func == "function", 'Must provide a function');
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-07-28 21:40:55 -07:00
|
|
|
for (let i = 0; this[i] != null; i++) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let elem = this[i];
|
|
|
|
let handler = func;
|
2010-07-11 17:54:42 -07:00
|
|
|
if (elem.iQEventData && elem.iQEventData[type]) {
|
2010-07-28 20:33:43 -07:00
|
|
|
let count = elem.iQEventData[type].length;
|
|
|
|
for (let a = 0; a < count; a++) {
|
|
|
|
let pair = elem.iQEventData[type][a];
|
2010-07-11 17:54:42 -07:00
|
|
|
if (pair.original == func) {
|
2010-07-18 08:58:10 -07:00
|
|
|
handler = pair.modified;
|
2010-06-07 17:20:15 -07:00
|
|
|
elem.iQEventData[type].splice(a, 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
2010-06-07 17:20:15 -07:00
|
|
|
elem.removeEventListener(type, handler, false);
|
2010-05-27 17:25:14 -07:00
|
|
|
}
|
2010-07-18 08:58:10 -07:00
|
|
|
|
|
|
|
return this;
|
2010-05-26 17:04:56 -07:00
|
|
|
}
|
2010-05-25 17:04:59 -07:00
|
|
|
};
|
|
|
|
|
2010-05-28 15:56:00 -07:00
|
|
|
// ----------
|
|
|
|
// Create various event aliases
|
2010-07-28 20:33:43 -07:00
|
|
|
let events = [
|
|
|
|
'keyup',
|
|
|
|
'keydown',
|
|
|
|
'mouseup',
|
|
|
|
'mousedown',
|
|
|
|
'mouseover',
|
|
|
|
'mouseout',
|
|
|
|
'mousemove',
|
|
|
|
'click',
|
|
|
|
'resize',
|
|
|
|
'change',
|
|
|
|
'blur',
|
|
|
|
'focus'
|
|
|
|
];
|
|
|
|
|
|
|
|
events.forEach(function(event) {
|
|
|
|
iQClass.prototype[event] = function(func) {
|
|
|
|
return this.bind(event, func);
|
|
|
|
};
|
|
|
|
});
|