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

📄 mootools-1.2-core.js.svn-base

📁 mooltools源码很不错的源码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
			if (element) this.appendChild(element);		}, this);		return this;	},	dispose: function(){		return (this.parentNode) ? this.parentNode.removeChild(this) : this;	},	clone: function(contents, keepid){		switch ($type(this)){			case 'element':				var attributes = {};				for (var j = 0, l = this.attributes.length; j < l; j++){					var attribute = this.attributes[j], key = attribute.nodeName.toLowerCase();					if (Browser.Engine.trident && (/input/i).test(this.tagName) && (/width|height/).test(key)) continue;					var value = (key == 'style' && this.style) ? this.style.cssText : attribute.nodeValue;					if (!$chk(value) || key == 'uid' || (key == 'id' && !keepid)) continue;					if (value != 'inherit' && ['string', 'number'].contains($type(value))) attributes[key] = value;				}				var element = new Element(this.nodeName.toLowerCase(), attributes);				if (contents !== false){					for (var i = 0, k = this.childNodes.length; i < k; i++){						var child = Element.clone(this.childNodes[i], true, keepid);						if (child) element.grab(child);					}				}				return element;			case 'textnode': return document.newTextNode(this.nodeValue);		}		return null;	},	replaces: function(el){		el = $(el, true);		el.parentNode.replaceChild(this, el);		return this;	},	hasClass: function(className){		return this.className.contains(className, ' ');	},	addClass: function(className){		if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();		return this;	},	removeClass: function(className){		this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1').clean();		return this;	},	toggleClass: function(className){		return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);	},	getComputedStyle: function(property){		if (this.currentStyle) return this.currentStyle[property.camelCase()];		var computed = this.getWindow().getComputedStyle(this, null);		return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;	},	empty: function(){		$A(this.childNodes).each(function(node){			Browser.freeMem(node);			Element.empty(node);			Element.dispose(node);		}, this);		return this;	},	destroy: function(){		Browser.freeMem(this.empty().dispose());		return null;	},	getSelected: function(){		return new Elements($A(this.options).filter(function(option){			return option.selected;		}));	},	toQueryString: function(){		var queryString = [];		this.getElements('input, select, textarea').each(function(el){			if (!el.name || el.disabled) return;			var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){				return opt.value;			}) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;			$splat(value).each(function(val){				if (val) queryString.push(el.name + '=' + encodeURIComponent(val));			});		});		return queryString.join('&');	},	getProperty: function(attribute){		var EA = Element.Attributes, key = EA.Props[attribute];		var value = (key) ? this[key] : this.getAttribute(attribute, 2);		return (EA.Bools[attribute]) ? !!value : (key) ? value : value || null;	},	getProperties: function(){		var args = $A(arguments);		return args.map(function(attr){			return this.getProperty(attr);		}, this).associate(args);	},	setProperty: function(attribute, value){		var EA = Element.Attributes, key = EA.Props[attribute], hasValue = $defined(value);		if (key && EA.Bools[attribute]) value = (value || !hasValue) ? true : false;		else if (!hasValue) return this.removeProperty(attribute);		(key) ? this[key] = value : this.setAttribute(attribute, value);		return this;	},	setProperties: function(attributes){		for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);		return this;	},	removeProperty: function(attribute){		var EA = Element.Attributes, key = EA.Props[attribute], isBool = (key && EA.Bools[attribute]);		(key) ? this[key] = (isBool) ? false : '' : this.removeAttribute(attribute);		return this;	},	removeProperties: function(){		Array.each(arguments, this.removeProperty, this);		return this;	}});(function(){var walk = function(element, walk, start, match, all, nocash){	var el = element[start || walk];	var elements = [];	while (el){		if (el.nodeType == 1 && (!match || Element.match(el, match))){			elements.push(el);			if (!all) break;		}		el = el[walk];	}	return (all) ? new Elements(elements, {ddup: false, cash: !nocash}) : $(elements[0], nocash);};Element.implement({	getPrevious: function(match, nocash){		return walk(this, 'previousSibling', null, match, false, nocash);	},	getAllPrevious: function(match, nocash){		return walk(this, 'previousSibling', null, match, true, nocash);	},	getNext: function(match, nocash){		return walk(this, 'nextSibling', null, match, false, nocash);	},	getAllNext: function(match, nocash){		return walk(this, 'nextSibling', null, match, true, nocash);	},	getFirst: function(match, nocash){		return walk(this, 'nextSibling', 'firstChild', match, false, nocash);	},	getLast: function(match, nocash){		return walk(this, 'previousSibling', 'lastChild', match, false, nocash);	},	getParent: function(match, nocash){		return walk(this, 'parentNode', null, match, false, nocash);	},	getParents: function(match, nocash){		return walk(this, 'parentNode', null, match, true, nocash);	},	getChildren: function(match, nocash){		return walk(this, 'nextSibling', 'firstChild', match, true, nocash);	},	hasChild: function(el){		el = $(el, true);		return (!!el && $A(this.getElementsByTagName(el.tagName)).contains(el));	}});})();Element.Properties = new Hash;Element.Properties.style = {	set: function(style){		this.style.cssText = style;	},	get: function(){		return this.style.cssText;	},	erase: function(){		this.style.cssText = '';	}};Element.Properties.tag = {get: function(){	return this.tagName.toLowerCase();}};Element.Properties.href = {get: function(){	return (!this.href) ? null : this.href.replace(new RegExp('^' + document.location.protocol + '\/\/' + document.location.host), '');}};Element.Properties.html = {set: function(){	return this.innerHTML = Array.flatten(arguments).join('');}};Native.implement([Element, Window, Document], {	addListener: function(type, fn){		if (this.addEventListener) this.addEventListener(type, fn, false);		else this.attachEvent('on' + type, fn);		return this;	},	removeListener: function(type, fn){		if (this.removeEventListener) this.removeEventListener(type, fn, false);		else this.detachEvent('on' + type, fn);		return this;	},	retrieve: function(property, dflt){		var storage = Element.Storage.get(this.uid);		var prop = storage[property];		if ($defined(dflt) && !$defined(prop)) prop = storage[property] = dflt;		return $pick(prop);	},	store: function(property, value){		var storage = Element.Storage.get(this.uid);		storage[property] = value;		return this;	},	eliminate: function(property){		var storage = Element.Storage.get(this.uid);		delete storage[property];		return this;	}});Element.Attributes = new Hash({	Props: {'html': 'innerHTML', 'class': 'className', 'for': 'htmlFor', 'text': (Browser.Engine.trident) ? 'innerText' : 'textContent'},	Bools: ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'],	Camels: ['value', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap']});Browser.freeMem = function(item){	if (!item) return;	if (Browser.Engine.trident && (/object/i).test(item.tagName)){		for (var p in item){			if (typeof item[p] == 'function') item[p] = $empty;		}		Element.dispose(item);	}	if (item.uid && item.removeEvents) item.removeEvents();};(function(EA){	var EAB = EA.Bools, EAC = EA.Camels;	EA.Bools = EAB = EAB.associate(EAB);	Hash.extend(Hash.combine(EA.Props, EAB), EAC.associate(EAC.map(function(v){		return v.toLowerCase();	})));	EA.erase('Camels');})(Element.Attributes);window.addListener('unload', function(){	window.removeListener('unload', arguments.callee);	document.purge();	if (Browser.Engine.trident) CollectGarbage();});/*
Script: Element.Event.js
	Contains Element methods for dealing with events, and custom Events.

License:
	MIT-style license.
*/

Element.Properties.events = {set: function(events){
	this.addEvents(events);
}};

Native.implement([Element, Window, Document], {

	addEvent: function(type, fn){
		var events = this.retrieve('events', {});
		events[type] = events[type] || {'keys': [], 'values': []};
		if (events[type].keys.contains(fn)) return this;
		events[type].keys.push(fn);
		var realType = type, custom = Element.Events.get(type), condition = fn, self = this;
		if (custom){
			if (custom.onAdd) custom.onAdd.call(this, fn);
			if (custom.condition){
				condition = function(event){
					if (custom.condition.call(this, event)) return fn.call(this, event);
					return false;
				};
			}
			realType = custom.base || realType;
		}
		var defn = function(){
			return fn.call(self);
		};
		var nativeEvent = Element.NativeEvents[realType] || 0;
		if (nativeEvent){
			if (nativeEvent == 2){
				defn = function(event){
					event = new Event(event, self.getWindow());
					if (condition.call(self, event) === false) event.stop();
				};
			}
			this.addListener(realType, defn);
		}
		events[type].values.push(defn);
		return this;
	},

	removeEvent: function(type, fn){
		var events = this.retrieve('events');
		if (!events || !events[type]) return this;
		var pos = events[type].keys.indexOf(fn);
		if (pos == -1) return this;
		var key = events[type].keys.splice(pos, 1)[0];
		var value = events[type].values.splice(pos, 1)[0];
		var custom = Element.Events.get(type);
		if (custom){
			if (custom.onRemove) custom.onRemove.call(this, fn);
			type = custom.base || type;
		}
		return (Element.NativeEvents[type]) ? this.removeListener(type, value) : this;
	},

	addEvents: function(events){
		for (var event in events) this.addEvent(event, events[event]);
		return this;
	},

	removeEvents: function(type){
		var events = this.retrieve('events');
		if (!events) return this;
		if (!type){
			for (var evType in events) this.removeEvents(evType);
			events = null;
		} else if (events[type]){
			while (events[type].keys[0]) this.removeEvent(type, events[type].keys[0]);
			events[type] = null;
		}
		return this;
	},

	fireEvent: function(type, args, delay){
		var events = this.retrieve('events');
		if (!events || !events[type]) return this;
		events[type].keys.each(function(fn){
			fn.create({'bind': this, 'delay': delay, 'arguments': args})();
		}, this);
		return this;
	},

	cloneEvents: function(from, type){
		from = $(from);
		var fevents = from.retrieve('events');
		if (!fevents) return this;
		if (!type){
			for (var evType in fevents) this.cloneEvents(from, evType);
		} else if (fevents[type]){
			fevents[type].keys.each(function(fn){
				this.addEvent(type, fn);
			}, this);
		}
		return this;
	}

});

Element.NativeEvents = {
	click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons
	mousewheel: 2, DOMMouseScroll: 2, //mouse wheel
	mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement
	keydown: 2, keypress: 2, keyup: 2, //keyboard
	focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements
	load: 1, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window
	error: 1, abort: 1, scroll: 1 //misc
};

(function(){

var $check = function(event){
	var related = event.relatedTarget;
	if (related == undefined) return true;
	if (related === false) return false;
	return ($type(this) != 'document' && related != this && related.prefix != 'xul' && !this.hasChild(related));
};

Element.Events = new Hash({

	mouseenter: {
		base: 'mouseover',
		condition: $check
	},

	mouseleave: {
		base: 'mouseout',
		condition: $check
	},

	mousewheel: {
		base: (Browser.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel'
	}

});

})();/*Script: Element.Style.js	Contains methods for interacting with the styles of Elements in a fashionable way.License:	MIT-style license.*/Element.Properties.styles = {set: function(styles){	this.setStyles(styles);}};Element.Properties.opacity = {	set: function(opacity, novisibility){		if (!novisibility){			if (opacity == 0){				if (this.style.visibility != 'hidden') this.style.visibility = 'hidden';			} else {				if (this.style.visibility != 'visible') this.style.visibility = 'visible';			}		}		if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1;		if (Browser.Engine.trident) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';		this.style.opacity = opacity;		this.store('opacity', opacity);	},	get: function(){		return this.retrieve('opacity', 1);	}};Element.implement({		setOpacity: function(value){		return this.set('opacity', value, true);	},		getOpacity: function(){		return this.get('opacity');	},	setStyle: function(property, value){		switch (property){			case 'opacity': return this.set('opacity', parseFloat(value));			case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';		}		property = property.camelCase();		if ($type(value) != 'string'){			var map = (Element.Styles.get(property) || '@').split(' ');			value = $splat(value).map(function(val, i){				if (!map[i]) return '';				return ($type(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;			}).join(' ');		} else if (value == String(Number(value))){			value = Math.round(value);		}		this.style[property] = value;		return this;	},	getStyle: function(property){		switch (property){

⌨️ 快捷键说明

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