⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mootools.svn.js

📁 基于MOOnTOOLs所开发的一个导航拦仅供参考
💻 JS
📖 第 1 页 / 共 5 页
字号:
		>myFunction.delay(50, myElement) //wait 50 milliseconds, then call myFunction and bind myElement to it		>(function(){alert('one second later...')}).delay(1000); //wait a second and alert	*/	delay: function(delay, bind, args){		return this.create({'delay': delay, 'bind': bind, 'arguments': args})();	},	/*	Property: periodical		Executes a function in the specified intervals of time	Arguments:		interval - the duration of the intervals between executions.		bind - optional, the object that the "this" of the function will refer to.		args - optional, the arguments passed. must be an array if arguments > 1	*/	periodical: function(interval, bind, args){		return this.create({'periodical': interval, 'bind': bind, 'arguments': args})();	}});/*Script: Number.js	Contains the Number prototypes.License:	MIT-style license.*//*Class: Number	A collection of The Number Object prototype methods.*/Number.extend({	/*	Property: toInt		Returns this number; useful because toInt must work on both Strings and Numbers.	*/	toInt: function(){		return parseInt(this);	},	/*	Property: toFloat		Returns this number as a float; useful because toFloat must work on both Strings and Numbers.	*/	toFloat: function(){		return parseFloat(this);	},	/*	Property: limit		Limits the number.	Arguments:		min - number, minimum value		max - number, maximum value	Returns:		the number in the given limits.	Example:		>(12).limit(2, 6.5)  // returns 6.5		>(-4).limit(2, 6.5)  // returns 2		>(4.3).limit(2, 6.5) // returns 4.3	*/	limit: function(min, max){		return Math.min(max, Math.max(min, this));	},	/*	Property: round		Returns the number rounded to specified precision.	Arguments:		precision - integer, number of digits after the decimal point. Can also be negative or zero (default).	Example:		>12.45.round() // returns 12		>12.45.round(1) // returns 12.5		>12.45.round(-1) // returns 10	Returns:		The rounded number.	*/	round: function(precision){		precision = Math.pow(10, precision || 0);		return Math.round(this * precision) / precision;	},	/*	Property: times		Executes a passed in function the specified number of times	Arguments:		function - the function to be executed on each iteration of the loop	Example:		>(4).times(alert);	*/	times: function(fn){		for (var i = 0; i < this; i++) fn(i);	}});/*Script: Element.js	Contains useful Element prototypes, to be used with the dollar function <$>.License:	MIT-style license.Credits:	- Some functions are inspired by those found in prototype.js <http://prototype.conio.net/> (c) 2005 Sam Stephenson sam [at] conio [dot] net, MIT-style license*//*Class: Element	Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.*/var Element = new Class({	/*	Property: initialize		Creates a new element of the type passed in.	Arguments:		el - string; the tag name for the element you wish to create. you can also pass in an element reference, in which case it will be extended.		props - object; the properties you want to add to your element.		Accepts the same keys as <Element.setProperties>, but also allows events and styles	Props:		the key styles will be used as setStyles, the key events will be used as addEvents. any other key is used as setProperty.	Example:		(start code)		new Element('a', {			'styles': {				'display': 'block',				'border': '1px solid black'			},			'events': {				'click': function(){					//aaa				},				'mousedown': function(){					//aaa				}			},			'class': 'myClassSuperClass',			'href': 'http://mad4milk.net'		});		(end)	*/	initialize: function(el, props){		if ($type(el) == 'string'){			if (window.ie && props && (props.name || props.type)){				var name = (props.name) ? ' name="' + props.name + '"' : '';				var type = (props.type) ? ' type="' + props.type + '"' : '';				delete props.name;				delete props.type;				el = '<' + el + name + type + '>';			}			el = document.createElement(el);		}		el = $(el);		return (!props || !el) ? el : el.set(props);	}});/*Class: Elements	- Every dom function such as <$$>, or in general every function that returns a collection of nodes in mootools, returns them as an Elements class.	- The purpose of the Elements class is to allow <Element> methods to work also on <Elements> array.	- Elements is also an Array, so it accepts all the <Array> methods.	- Every node of the Elements instance is already extended with <$>.Example:	>$$('myselector').each(function(el){	> //...	>});	some iterations here, $$('myselector') is also an array.	>$$('myselector').setStyle('color', 'red');	every element returned by $$('myselector') also accepts <Element> methods, in this example every element will be made red.*/var Elements = new Class({	initialize: function(elements){		return (elements) ? $extend(elements, this) : this;	}});Elements.extend = function(props){	for (var prop in props){		this.prototype[prop] = props[prop];		this[prop] = $native.generic(prop);	}};/*Section: Utility FunctionsFunction: $	returns the element passed in with all the Element prototypes applied.Arguments:	el - a reference to an actual element or a string representing the id of an elementExample:	>$('myElement') // gets a DOM element by id with all the Element prototypes applied.	>var div = document.getElementById('myElement');	>$(div) //returns an Element also with all the mootools extentions applied.	You'll use this when you aren't sure if a variable is an actual element or an id, as	well as just shorthand for document.getElementById().Returns:	a DOM element or false (if no id was found).Note:	you need to call $ on an element only once to get all the prototypes.	But its no harm to call it multiple times, as it will detect if it has been already extended.*/function $(el){	if (!el) return null;	if (el.htmlElement) return Garbage.collect(el);	if ([window, document].contains(el)) return el;	var type = $type(el);	if (type == 'string'){		el = document.getElementById(el);		type = (el) ? 'element' : false;	}	if (type != 'element') return null;	if (el.htmlElement) return Garbage.collect(el);	if (['object', 'embed'].contains(el.tagName.toLowerCase())) return el;	$extend(el, Element.prototype);	el.htmlElement = function(){};	return Garbage.collect(el);};/*Function: $$	Selects, and extends DOM elements. Elements arrays returned with $$ will also accept all the <Element> methods.	The return type of element methods run through $$ is always an array. If the return array is only made by elements,	$$ will be applied automatically.Arguments:	HTML Collections, arrays of elements, arrays of strings as element ids, elements, strings as selectors.	Any number of the above as arguments are accepted.Note:	if you load <Element.Selectors.js>, $$ will also accept CSS Selectors, otherwise the only selectors supported are tag names.Example:	>$$('a') //an array of all anchor tags on the page	>$$('a', 'b') //an array of all anchor and bold tags on the page	>$$('#myElement') //array containing only the element with id = myElement. (only with <Element.Selectors.js>)	>$$('#myElement a.myClass') //an array of all anchor tags with the class "myClass"	>//within the DOM element with id "myElement" (only with <Element.Selectors.js>)	>$$(myelement, myelement2, 'a', ['myid', myid2, 'myid3'], document.getElementsByTagName('div')) //an array containing:	>// the element referenced as myelement if existing,	>// the element referenced as myelement2 if existing,	>// all the elements with a as tag in the page,	>// the element with id = myid if existing	>// the element with id = myid2 if existing	>// the element with id = myid3 if existing	>// all the elements with div as tag in the pageReturns:	array - array of all the dom elements matched, extended with <$>.  Returns as <Elements>.*/document.getElementsBySelector = document.getElementsByTagName;function $$(){	var elements = [];	for (var i = 0, j = arguments.length; i < j; i++){		var selector = arguments[i];		switch($type(selector)){			case 'element': elements.push(selector);			case 'boolean': break;			case false: break;			case 'string': selector = document.getElementsBySelector(selector, true);			default: elements.extend(selector);		}	}	return $$.unique(elements);};$$.unique = function(array){	var elements = [];	for (var i = 0, l = array.length; i < l; i++){		if (array[i].$included) continue;		var element = $(array[i]);		if (element && !element.$included){			element.$included = true;			elements.push(element);		}	}	for (var n = 0, d = elements.length; n < d; n++) elements[n].$included = null;	return new Elements(elements);};Elements.Multi = function(property){	return function(){		var args = arguments;		var items = [];		var elements = true;		for (var i = 0, j = this.length, returns; i < j; i++){			returns = this[i][property].apply(this[i], args);			if ($type(returns) != 'element') elements = false;			items.push(returns);		};		return (elements) ? $$.unique(items) : items;	};};Element.extend = function(properties){	for (var property in properties){		HTMLElement.prototype[property] = properties[property];		Element.prototype[property] = properties[property];		Element[property] = $native.generic(property);		var elementsProperty = (Array.prototype[property]) ? property + 'Elements' : property;		Elements.prototype[elementsProperty] = Elements.Multi(property);	}};/*Class: Element	Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.*/Element.extend({	/*	Property: set		you can set events, styles and properties with this shortcut. same as calling new Element.	*/	set: function(props){		for (var prop in props){			var val = props[prop];			switch(prop){				case 'styles': this.setStyles(val); break;				case 'events': if (this.addEvents) this.addEvents(val); break;				case 'properties': this.setProperties(val); break;				default: this.setProperty(prop, val);			}		}		return this;	},	inject: function(el, where){		el = $(el);		switch(where){			case 'before': el.parentNode.insertBefore(this, el); break;			case 'after':				var next = el.getNext();				if (!next) el.parentNode.appendChild(this);				else el.parentNode.insertBefore(this, next);				break;			case 'top':				var first = el.firstChild;				if (first){					el.insertBefore(this, first);					break;				}			default: el.appendChild(this);		}		return this;	},	/*	Property: injectBefore		Inserts the Element before the passed element.	Arguments:		el - an element reference or the id of the element to be injected in.	Example:		>html:		><div id="myElement"></div>		><div id="mySecondElement"></div>		>js:		>$('mySecondElement').injectBefore('myElement');		>resulting html:		><div id="mySecondElement"></div>		><div id="myElement"></div>	*/	injectBefore: function(el){		return this.inject(el, 'before');	},	/*	Property: injectAfter		Same as <Element.injectBefore>, but inserts the element after.	*/	injectAfter: function(el){		return this.inject(el, 'after');	},	/*	Property: injectInside		Same as <Element.injectBefore>, but inserts the element inside.	*/	injectInside: function(el){		return this.inject(el, 'bottom');	},	/*	Property: injectTop		Same as <Element.injectInside>, but inserts the element inside, at the top.	*/	injectTop: function(el){		return this.inject(el, 'top');	},	/*	Property: adopt		Inserts the passed elements inside the Element.	Arguments:		accepts elements references, element ids as string, selectors ($$('stuff')) / array of elements, array of ids as strings and collections.	*/	adopt: function(){		var elements = [];		$each(arguments, function(argument){			elements = elements.concat(argument);		});		$$(elements).inject(this);		return this;	},	/*	Property: remove		Removes the Element from the DOM.	Example:		>$('myElement').remove() //bye bye	*/	remove: function(){		return this.parentNode.removeChild(this);	},	/*	Property: clone		Clones the Element and returns the cloned one.	Arguments:		contents - boolean, when true the Element is cloned with childNodes, default true	Returns:		the cloned element	Example:		>var clone = $('myElement').clone().injectAfter('myElement');		>//clones the Element and append the clone after the Element.	*/	clone: function(contents){		var el = $(this.cloneNode(contents !== false));		if (!el.$events) return el;		el.$events = {};		for (var type in this.$events) el.$events[type] = {			'keys': $A(this.$events[type].keys),			'values': $A(this.$events[type].values)		};		return el.removeEvents();	},	/*	Property: replaceWith		Replaces the Element with an element passed.	Arguments:		el - a string representing the element to be injected in (myElementId, or div), or an element reference.		If you pass div or another tag, the element will be created.	Returns:		the passed in element	Example:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -