mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
+ Filled out iQ.js comments
This commit is contained in:
parent
f7eee2b556
commit
69b9f27b74
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
// **********
|
// **********
|
||||||
// Title: iq.js
|
// Title: iq.js
|
||||||
// jQuery, hacked down to just the bits we need, with a bunch of other stuff added.
|
// Various helper functions, in the vein of jQuery.
|
||||||
|
|
||||||
(function( window, undefined ) {
|
(function( window, undefined ) {
|
||||||
|
|
||||||
@ -239,6 +239,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: addClass
|
// Function: addClass
|
||||||
|
// Adds the given class(es) to the receiver.
|
||||||
addClass: function( value ) {
|
addClass: function( value ) {
|
||||||
if ( iQ.isFunction(value) ) {
|
if ( iQ.isFunction(value) ) {
|
||||||
Utils.assert('does not support function argument', false);
|
Utils.assert('does not support function argument', false);
|
||||||
@ -261,6 +262,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: removeClass
|
// Function: removeClass
|
||||||
|
// Removes the given class(es) from the receiver.
|
||||||
removeClass: function( value ) {
|
removeClass: function( value ) {
|
||||||
if ( iQ.isFunction(value) ) {
|
if ( iQ.isFunction(value) ) {
|
||||||
Utils.assert('does not support function argument', false);
|
Utils.assert('does not support function argument', false);
|
||||||
@ -287,6 +289,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: hasClass
|
// Function: hasClass
|
||||||
|
// Returns true is the receiver has the given css class.
|
||||||
hasClass: function( selector ) {
|
hasClass: function( selector ) {
|
||||||
for ( var i = 0, l = this.length; i < l; i++ ) {
|
for ( var i = 0, l = this.length; i < l; i++ ) {
|
||||||
if ( this[i].classList.contains( selector ) ) {
|
if ( this[i].classList.contains( selector ) ) {
|
||||||
@ -298,6 +301,8 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: find
|
// Function: find
|
||||||
|
// Searches the receiver and its children, returning a new iQ object with
|
||||||
|
// elements that match the given selector.
|
||||||
find: function( selector ) {
|
find: function( selector ) {
|
||||||
var ret = [], length = 0;
|
var ret = [], length = 0;
|
||||||
|
|
||||||
@ -327,6 +332,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: remove
|
// Function: remove
|
||||||
|
// Removes the receiver from the DOM.
|
||||||
remove: function(unused) {
|
remove: function(unused) {
|
||||||
Utils.assert('does not accept a selector', unused === undefined);
|
Utils.assert('does not accept a selector', unused === undefined);
|
||||||
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
||||||
@ -340,6 +346,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: empty
|
// Function: empty
|
||||||
|
// Removes all of the reciever's children and HTML content from the DOM.
|
||||||
empty: function() {
|
empty: function() {
|
||||||
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
|
||||||
while ( elem.firstChild ) {
|
while ( elem.firstChild ) {
|
||||||
@ -352,6 +359,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: width
|
// Function: width
|
||||||
|
// Returns the width of the receiver.
|
||||||
width: function(unused) {
|
width: function(unused) {
|
||||||
Utils.assert('does not yet support setting', unused === undefined);
|
Utils.assert('does not yet support setting', unused === undefined);
|
||||||
return parseInt(this.css('width'));
|
return parseInt(this.css('width'));
|
||||||
@ -359,6 +367,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: height
|
// Function: height
|
||||||
|
// Returns the height of the receiver.
|
||||||
height: function(unused) {
|
height: function(unused) {
|
||||||
Utils.assert('does not yet support setting', unused === undefined);
|
Utils.assert('does not yet support setting', unused === undefined);
|
||||||
return parseInt(this.css('height'));
|
return parseInt(this.css('height'));
|
||||||
@ -366,6 +375,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: position
|
// Function: position
|
||||||
|
// Returns an object with the receiver's position in left and top properties.
|
||||||
position: function(unused) {
|
position: function(unused) {
|
||||||
Utils.assert('does not yet support setting', unused === undefined);
|
Utils.assert('does not yet support setting', unused === undefined);
|
||||||
return {
|
return {
|
||||||
@ -376,6 +386,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: bounds
|
// Function: bounds
|
||||||
|
// Returns a <Rect> with the receiver's bounds.
|
||||||
bounds: function(unused) {
|
bounds: function(unused) {
|
||||||
Utils.assert('does not yet support setting', unused === undefined);
|
Utils.assert('does not yet support setting', unused === undefined);
|
||||||
var p = this.position();
|
var p = this.position();
|
||||||
@ -384,6 +395,8 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: data
|
// Function: data
|
||||||
|
// Pass in both key and value to attach some data to the receiver;
|
||||||
|
// pass in just key to retrieve it.
|
||||||
data: function(key, value) {
|
data: function(key, value) {
|
||||||
var data = null;
|
var data = null;
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
@ -406,6 +419,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: html
|
// Function: html
|
||||||
|
// Given a value, sets the receiver's innerHTML to it; otherwise returns what's already there.
|
||||||
// TODO: security
|
// TODO: security
|
||||||
html: function(value) {
|
html: function(value) {
|
||||||
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
||||||
@ -418,6 +432,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: text
|
// Function: text
|
||||||
|
// Given a value, sets the receiver's textContent to it; otherwise returns what's already there.
|
||||||
text: function(value) {
|
text: function(value) {
|
||||||
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
@ -429,6 +444,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: val
|
// Function: val
|
||||||
|
// Given a value, sets the receiver's value to it; otherwise returns what's already there.
|
||||||
val: function(value) {
|
val: function(value) {
|
||||||
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
@ -441,6 +457,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: appendTo
|
// Function: appendTo
|
||||||
|
// Appends the receiver to the result of iQ(selector).
|
||||||
appendTo: function(selector) {
|
appendTo: function(selector) {
|
||||||
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
||||||
iQ(selector).append(this);
|
iQ(selector).append(this);
|
||||||
@ -449,6 +466,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: append
|
// Function: append
|
||||||
|
// Appends the result of iQ(selector) to the receiver.
|
||||||
append: function(selector) {
|
append: function(selector) {
|
||||||
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
Utils.assert('does not yet support multi-objects (or null objects)', this.length == 1);
|
||||||
var object = iQ(selector);
|
var object = iQ(selector);
|
||||||
@ -479,6 +497,13 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: css
|
// Function: css
|
||||||
|
// Sets or gets CSS properties on the receiver. When setting certain numerical properties,
|
||||||
|
// will automatically add "px".
|
||||||
|
//
|
||||||
|
// Possible call patterns:
|
||||||
|
// a: object, b: undefined - sets with properties from a
|
||||||
|
// a: string, b: undefined - gets property specified by a
|
||||||
|
// a: string, b: string/number - sets property specified by a to b
|
||||||
css: function(a, b) {
|
css: function(a, b) {
|
||||||
var properties = null;
|
var properties = null;
|
||||||
|
|
||||||
@ -596,6 +621,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: fadeOut
|
// Function: fadeOut
|
||||||
|
// Animates the receiver to full transparency. Calls callback on completion.
|
||||||
fadeOut: function(callback) {
|
fadeOut: function(callback) {
|
||||||
try {
|
try {
|
||||||
Utils.assert('does not yet support duration', iQ.isFunction(callback) || callback === undefined);
|
Utils.assert('does not yet support duration', iQ.isFunction(callback) || callback === undefined);
|
||||||
@ -618,6 +644,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: fadeIn
|
// Function: fadeIn
|
||||||
|
// Animates the receiver to full opacity.
|
||||||
fadeIn: function() {
|
fadeIn: function() {
|
||||||
try {
|
try {
|
||||||
this.css({display: ''});
|
this.css({display: ''});
|
||||||
@ -635,6 +662,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: hide
|
// Function: hide
|
||||||
|
// Hides the receiver.
|
||||||
hide: function() {
|
hide: function() {
|
||||||
try {
|
try {
|
||||||
this.css({display: 'none', opacity: 0});
|
this.css({display: 'none', opacity: 0});
|
||||||
@ -647,6 +675,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: show
|
// Function: show
|
||||||
|
// Shows the receiver.
|
||||||
show: function() {
|
show: function() {
|
||||||
try {
|
try {
|
||||||
this.css({display: '', opacity: 1});
|
this.css({display: '', opacity: 1});
|
||||||
@ -692,6 +721,8 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: one
|
// Function: one
|
||||||
|
// Binds the given function to the given event type, but only for one call;
|
||||||
|
// automatically unbinds after the event fires once.
|
||||||
one: function(type, func) {
|
one: function(type, func) {
|
||||||
Utils.assert('does not support eventData argument', iQ.isFunction(func));
|
Utils.assert('does not support eventData argument', iQ.isFunction(func));
|
||||||
|
|
||||||
@ -705,6 +736,7 @@ iQ.fn = iQ.prototype = {
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: unbind
|
// Function: unbind
|
||||||
|
// Unbinds the given function from the given event type.
|
||||||
unbind: function(type, func) {
|
unbind: function(type, func) {
|
||||||
Utils.assert('Must provide a function', iQ.isFunction(func));
|
Utils.assert('Must provide a function', iQ.isFunction(func));
|
||||||
|
|
||||||
@ -732,8 +764,13 @@ iQ.fn = iQ.prototype = {
|
|||||||
// Give the init function the iQ prototype for later instantiation
|
// Give the init function the iQ prototype for later instantiation
|
||||||
iQ.fn.init.prototype = iQ.fn;
|
iQ.fn.init.prototype = iQ.fn;
|
||||||
|
|
||||||
|
// ##########
|
||||||
|
// Class: iQ
|
||||||
|
// Additional utility functions.
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: extend
|
// Function: extend
|
||||||
|
// Pass several objects in and it will combine them all into the first object and return it.
|
||||||
iQ.extend = iQ.fn.extend = function() {
|
iQ.extend = iQ.fn.extend = function() {
|
||||||
// copy reference to target object
|
// copy reference to target object
|
||||||
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
|
var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
|
||||||
@ -790,35 +827,24 @@ iQ.extend = iQ.fn.extend = function() {
|
|||||||
return target;
|
return target;
|
||||||
};
|
};
|
||||||
|
|
||||||
// ##########
|
|
||||||
// Class: iQ
|
|
||||||
// Singleton
|
|
||||||
iQ.extend({
|
iQ.extend({
|
||||||
// ----------
|
|
||||||
// Variable: animationCount
|
|
||||||
// For internal use only
|
|
||||||
animationCount: 0,
|
|
||||||
|
|
||||||
// ----------
|
|
||||||
// Function: isAnimating
|
|
||||||
isAnimating: function() {
|
|
||||||
return (this.animationCount != 0);
|
|
||||||
},
|
|
||||||
|
|
||||||
// -----------
|
// -----------
|
||||||
// Function: isFunction
|
// Function: isFunction
|
||||||
|
// Returns true if the given object is a function.
|
||||||
isFunction: function( obj ) {
|
isFunction: function( obj ) {
|
||||||
return toString.call(obj) === "[object Function]";
|
return toString.call(obj) === "[object Function]";
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: isArray
|
// Function: isArray
|
||||||
|
// Returns true if the given object is an array.
|
||||||
isArray: function( obj ) {
|
isArray: function( obj ) {
|
||||||
return toString.call(obj) === "[object Array]";
|
return toString.call(obj) === "[object Array]";
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: isPlainObject
|
// Function: isPlainObject
|
||||||
|
// Check to see if an object is a plain object (created using "{}" or "new Object").
|
||||||
isPlainObject: function( obj ) {
|
isPlainObject: function( obj ) {
|
||||||
// Must be an Object.
|
// Must be an Object.
|
||||||
// Because of IE, we also have to check the presence of the constructor property.
|
// Because of IE, we also have to check the presence of the constructor property.
|
||||||
@ -845,6 +871,7 @@ iQ.extend({
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: isEmptyObject
|
// Function: isEmptyObject
|
||||||
|
// Returns true if the given object has no members.
|
||||||
isEmptyObject: function( obj ) {
|
isEmptyObject: function( obj ) {
|
||||||
for ( var name in obj ) {
|
for ( var name in obj ) {
|
||||||
return false;
|
return false;
|
||||||
@ -854,6 +881,7 @@ iQ.extend({
|
|||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: merge
|
// Function: merge
|
||||||
|
// Merge two arrays and return the result.
|
||||||
merge: function( first, second ) {
|
merge: function( first, second ) {
|
||||||
var i = first.length, j = 0;
|
var i = first.length, j = 0;
|
||||||
|
|
||||||
|
@ -159,8 +159,7 @@ function ImmutableArray(baseArray) {
|
|||||||
// Class: Extension
|
// Class: Extension
|
||||||
// Singleton
|
// Singleton
|
||||||
var Extension = {
|
var Extension = {
|
||||||
// === {{{Extension.addUnloadMethod()}}} ===
|
// Function: addUnloadMethod
|
||||||
//
|
|
||||||
// This attaches a given method called 'unload' to the given object.
|
// This attaches a given method called 'unload' to the given object.
|
||||||
// The method is also tied to the Extension page's lifetime, so if
|
// The method is also tied to the Extension page's lifetime, so if
|
||||||
// the unload method isn't called before the page is unloaded, it is
|
// the unload method isn't called before the page is unloaded, it is
|
||||||
@ -168,7 +167,6 @@ var Extension = {
|
|||||||
// don't propagate past Extension page reloads, and it can also help
|
// don't propagate past Extension page reloads, and it can also help
|
||||||
// developers find objects that aren't being properly cleaned up
|
// developers find objects that aren't being properly cleaned up
|
||||||
// before the page is unloaded.
|
// before the page is unloaded.
|
||||||
|
|
||||||
addUnloadMethod: function addUnloadMethod(obj, unloader) {
|
addUnloadMethod: function addUnloadMethod(obj, unloader) {
|
||||||
function unloadWrapper() {
|
function unloadWrapper() {
|
||||||
window.removeEventListener("unload", unloadWrapper, true);
|
window.removeEventListener("unload", unloadWrapper, true);
|
||||||
@ -186,6 +184,8 @@ var Extension = {
|
|||||||
function EventListenerMixIns(mixInto) {
|
function EventListenerMixIns(mixInto) {
|
||||||
var mixIns = {};
|
var mixIns = {};
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
// Function: add
|
||||||
this.add = function add(options) {
|
this.add = function add(options) {
|
||||||
if (mixIns) {
|
if (mixIns) {
|
||||||
if (options.name in mixIns)
|
if (options.name in mixIns)
|
||||||
@ -195,6 +195,8 @@ function EventListenerMixIns(mixInto) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
// Function: bubble
|
||||||
this.bubble = function bubble(name, target, event) {
|
this.bubble = function bubble(name, target, event) {
|
||||||
if (mixIns)
|
if (mixIns)
|
||||||
mixIns[name].trigger(target, event);
|
mixIns[name].trigger(target, event);
|
||||||
@ -256,6 +258,8 @@ function EventListenerMixIn(options) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// ----------
|
||||||
|
// Function: trigger
|
||||||
this.trigger = function trigger(target, event) {
|
this.trigger = function trigger(target, event) {
|
||||||
onEvent(event, target);
|
onEvent(event, target);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user