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

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

📁 mooltools源码很不错的源码
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
		for (var i = this.length; i--; i){			if (this[i] === item) this.splice(i, 1);		}		return this;	},	empty: function(){		this.length = 0;		return this;	},	flatten: function(){		var array = [];		for (var i = 0, l = this.length; i < l; i++){			var type = $type(this[i]);			if (!type) continue;			array = array.concat((type == 'array' || type == 'collection' || type == 'arguments') ? Array.flatten(this[i]) : this[i]);		}		return array;	},	hexToRgb: function(array){		if (this.length != 3) return null;		var rgb = this.map(function(value){			if (value.length == 1) value += value;			return value.toInt(16);		});		return (array) ? rgb : 'rgb(' + rgb + ')';	},	rgbToHex: function(array){		if (this.length < 3) return null;		if (this.length == 4 && this[3] == 0 && !array) return 'transparent';		var hex = [];		for (var i = 0; i < 3; i++){			var bit = (this[i] - 0).toString(16);			hex.push((bit.length == 1) ? '0' + bit : bit);		}		return (array) ? hex : '#' + hex.join('');	}});/*
Script: Function.js
	Contains Function Prototypes like create, bind, pass, and delay.

License:
	MIT-style license.
*/

Function.implement({

	extend: function(properties){
		for (var property in properties) this[property] = properties[property];
		return this;
	},

	create: function(options){
		var self = this;
		options = options || {};
		return function(event){
			var args = options.arguments;
			args = (args != undefined) ? $splat(args) : Array.slice(arguments, (options.event) ? 1 : 0);
			if (options.event) args = [event || window.event].extend(args);
			var returns = function(){
				return self.apply(options.bind || null, args);
			};
			if (options.delay) return setTimeout(returns, options.delay);
			if (options.periodical) return setInterval(returns, options.periodical);
			if (options.attempt) return $try(returns);
			return returns();
		};
	},

	pass: function(args, bind){
		return this.create({arguments: args, bind: bind});
	},

	attempt: function(args, bind){
		return this.create({arguments: args, bind: bind, attempt: true})();
	},

	bind: function(bind, args){
		return this.create({bind: bind, arguments: args});
	},

	bindWithEvent: function(bind, args){
		return this.create({bind: bind, event: true, arguments: args});
	},

	delay: function(delay, bind, args){
		return this.create({delay: delay, bind: bind, arguments: args})();
	},

	periodical: function(interval, bind, args){
		return this.create({periodical: interval, bind: bind, arguments: args})();
	},

	run: function(args, bind){
		return this.apply(bind, $splat(args));
	}

});/*Script: Number.js	Contains Number Prototypes like limit, round, times, and ceil.License:	MIT-style license.*/Number.implement({	limit: function(min, max){		return Math.min(max, Math.max(min, this));	},	round: function(precision){		precision = Math.pow(10, precision || 0);		return Math.round(this * precision) / precision;	},	times: function(fn, bind){		for (var i = 0; i < this; i++) fn.call(bind, i, this);	},	toFloat: function(){		return parseFloat(this);	},	toInt: function(base){		return parseInt(this, base || 10);	}});Number.alias('times', 'each');(function(math){	var methods = {};	math.each(function(name){		if (!Number[name]) methods[name] = function(){			return Math[name].apply(null, [this].concat($A(arguments)));		};	});	Number.implement(methods);})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);/*Script: String.js	Contains String Prototypes like camelCase, capitalize, test, and toInt.License:	MIT-style license.*/String.implement({	test: function(regex, params){		return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this);	},	contains: function(string, separator){		return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;	},	trim: function(){		return this.replace(/^\s+|\s+$/g, '');	},	clean: function(){		return this.replace(/\s+/g, ' ').trim();	},	camelCase: function(){		return this.replace(/-\D/g, function(match){			return match.charAt(1).toUpperCase();		});	},	hyphenate: function(){		return this.replace(/[A-Z]/g, function(match){			return ('-' + match.charAt(0).toLowerCase());		});	},	capitalize: function(){		return this.replace(/\b[a-z]/g, function(match){			return match.toUpperCase();		});	},	escapeRegExp: function(){		return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');	},	toInt: function(base){		return parseInt(this, base || 10);	},	toFloat: function(){		return parseFloat(this);	},	hexToRgb: function(array){		var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);		return (hex) ? hex.slice(1).hexToRgb(array) : null;	},	rgbToHex: function(array){		var rgb = this.match(/\d{1,3}/g);		return (rgb) ? rgb.rgbToHex(array) : null;	},	stripScripts: function(option){		var scripts = '';		var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){			scripts += arguments[1] + '\n';			return '';		});		if (option === true) $exec(scripts);		else if ($type(option) == 'function') option(scripts, text);		return text;	},	substitute: function(object, regexp){		return this.replace(regexp || (/\\?\{([^}]+)\}/g), function(match, name){			if (match.charAt(0) == '\\') return match.slice(1);			return (object[name] != undefined) ? object[name] : '';		});	}});/*Script: Hash.js	Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects.License:	MIT-style license.*/Hash.implement({	has: Object.prototype.hasOwnProperty,	keyOf: function(value){		for (var key in this){			if (this.hasOwnProperty(key) && this[key] === value) return key;		}		return null;	},	hasValue: function(value){		return (Hash.keyOf(this, value) !== null);	},	extend: function(properties){		Hash.each(properties, function(value, key){			Hash.set(this, key, value);		}, this);		return this;	},	combine: function(properties){		Hash.each(properties, function(value, key){			Hash.include(this, key, value);		}, this);		return this;	},	erase: function(key){		if (this.hasOwnProperty(key)) delete this[key];		return this;	},	get: function(key){		return (this.hasOwnProperty(key)) ? this[key] : null;	},	set: function(key, value){		if (!this[key] || this.hasOwnProperty(key)) this[key] = value;		return this;	},	empty: function(){		Hash.each(this, function(value, key){			delete this[key];		}, this);		return this;	},	include: function(key, value){		var k = this[key];		if (k == undefined) this[key] = value;		return this;	},	map: function(fn, bind){		var results = new Hash;		Hash.each(this, function(value, key){			results.set(key, fn.call(bind, value, key, this));		}, this);		return results;	},	filter: function(fn, bind){		var results = new Hash;		Hash.each(this, function(value, key){			if (fn.call(bind, value, key, this)) results.set(key, value);		}, this);		return results;	},	every: function(fn, bind){		for (var key in this){			if (this.hasOwnProperty(key) && !fn.call(bind, this[key], key)) return false;		}		return true;	},	some: function(fn, bind){		for (var key in this){			if (this.hasOwnProperty(key) && fn.call(bind, this[key], key)) return true;		}		return false;	},	getKeys: function(){		var keys = [];		Hash.each(this, function(value, key){			keys.push(key);		});		return keys;	},	getValues: function(){		var values = [];		Hash.each(this, function(value){			values.push(value);		});		return values;	},		toQueryString: function(base){		var queryString = [];		Hash.each(this, function(value, key){			if (base) key = base + '[' + key + ']';			var result;			switch ($type(value)){				case 'object': result = Hash.toQueryString(value, key); break;				case 'array':					var qs = {};					value.each(function(val, i){						qs[i] = val;					});					result = Hash.toQueryString(qs, key);				break;				default: result = key + '=' + encodeURIComponent(value);			}			if (value != undefined) queryString.push(result);		});				return queryString.join('&');	}});Hash.alias({keyOf: 'indexOf', hasValue: 'contains'});/*Script: Event.js	Contains the Event Native, to make the event object completely crossbrowser.License:	MIT-style license.*/var Event = new Native({	name: 'Event',	initialize: function(event, win){		win = win || window;		var doc = win.document;		event = event || win.event;		if (event.$extended) return event;		this.$extended = true;		var type = event.type;		var target = event.target || event.srcElement;		while (target && target.nodeType == 3) target = target.parentNode;				if (type.test(/key/)){			var code = event.which || event.keyCode;			var key = Event.Keys.keyOf(code);			if (type == 'keydown'){				var fKey = code - 111;				if (fKey > 0 && fKey < 13) key = 'f' + fKey;			}			key = key || String.fromCharCode(code).toLowerCase();		} else if (type.match(/(click|mouse|menu)/i)){			doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;			var page = {				x: event.pageX || event.clientX + doc.scrollLeft,				y: event.pageY || event.clientY + doc.scrollTop			};			var client = {				x: (event.pageX) ? event.pageX - win.pageXOffset : event.clientX,				y: (event.pageY) ? event.pageY - win.pageYOffset : event.clientY			};			if (type.match(/DOMMouseScroll|mousewheel/)){				var wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;			}			var rightClick = (event.which == 3) || (event.button == 2);			var related = null;			if (type.match(/over|out/)){				switch (type){					case 'mouseover': related = event.relatedTarget || event.fromElement; break;					case 'mouseout': related = event.relatedTarget || event.toElement;				}				if (!(function(){					while (related && related.nodeType == 3) related = related.parentNode;					return true;				}).create({attempt: Browser.Engine.gecko})()) related = false;			}		}		return $extend(this, {			event: event,			type: type,						page: page,			client: client,			rightClick: rightClick,						wheel: wheel,						relatedTarget: related,			target: target,						code: code,			key: key,						shift: event.shiftKey,			control: event.ctrlKey,			alt: event.altKey,			meta: event.metaKey		});	}});Event.Keys = new Hash({	'enter': 13,	'up': 38,	'down': 40,	'left': 37,	'right': 39,	'esc': 27,	'space': 32,	'backspace': 8,	'tab': 9,	'delete': 46});Event.implement({	stop: function(){		return this.stopPropagation().preventDefault();	},	stopPropagation: function(){		if (this.event.stopPropagation) this.event.stopPropagation();		else this.event.cancelBubble = true;		return this;	},	preventDefault: function(){		if (this.event.preventDefault) this.event.preventDefault();		else this.event.returnValue = false;		return this;	}});/*Script: Class.js	Contains the Class Function for easily creating, extending, and implementing reusable Classes.License:	MIT-style license.*/var Class = new Native({	name: 'Class',	initialize: function(properties){		properties = properties || {};		var klass = function(empty){			for (var key in this) this[key] = $unlink(this[key]);			for (var mutator in Class.Mutators){				if (!this[mutator]) continue;				Class.Mutators[mutator](this, this[mutator]);

⌨️ 快捷键说明

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