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

📄 mootools-1.2-core-src.js

📁 mootools 1.2版本 ajax的几个热门框架之一。
💻 JS
📖 第 1 页 / 共 3 页
字号:
	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: Element.js	One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser,	time-saver methods to let you easily work with HTML Elements.License:	MIT-style license.*/Document.implement({	newElement: function(tag, props){		if (Browser.Engine.trident && props){			['name', 'type', 'checked'].each(function(attribute){				if (!props[attribute]) return;				tag += ' ' + attribute + '="' + props[attribute] + '"';				if (attribute != 'checked') delete props[attribute];			});			tag = '<' + tag + '>';		}		return $.element(this.createElement(tag)).set(props);	},	newTextNode: function(text){		return this.createTextNode(text);	},	getDocument: function(){		return this;	},	getWindow: function(){		return this.defaultView || this.parentWindow;	},	purge: function(){		var elements = this.getElementsByTagName('*');		for (var i = 0, l = elements.length; i < l; i++) Browser.freeMem(elements[i]);	}});var Element = new Native({	name: 'Element',	legacy: window.Element,	initialize: function(tag, props){		var konstructor = Element.Constructors.get(tag);		if (konstructor) return konstructor(props);		if (typeof tag == 'string') return document.newElement(tag, props);		return $(tag).set(props);	},	afterImplement: function(key, value){		if (!Array[key]) Elements.implement(key, Elements.multi(key));		Element.Prototype[key] = value;	}});Element.Prototype = {$family: {name: 'element'}};Element.Constructors = new Hash;var IFrame = new Native({	name: 'IFrame',	generics: false,	initialize: function(){		var params = Array.link(arguments, {properties: Object.type, iframe: $defined});		var props = params.properties || {};		var iframe = $(params.iframe) || false;		var onload = props.onload || $empty;		delete props.onload;		props.id = props.name = $pick(props.id, props.name, iframe.id, iframe.name, 'IFrame_' + $time());		iframe = new Element(iframe || 'iframe', props);		var onFrameLoad = function(){			var host = $try(function(){				return iframe.contentWindow.location.host;			});			if (host && host == window.location.host){				var win = new Window(iframe.contentWindow);				var doc = new Document(iframe.contentWindow.document);				$extend(win.Element.prototype, Element.Prototype);			}			onload.call(iframe.contentWindow, iframe.contentWindow.document);		};		(!window.frames[props.id]) ? iframe.addListener('load', onFrameLoad) : onFrameLoad();		return iframe;	}});var Elements = new Native({	initialize: function(elements, options){		options = $extend({ddup: true, cash: true}, options);		elements = elements || [];		if (options.ddup || options.cash){			var uniques = {}, returned = [];			for (var i = 0, l = elements.length; i < l; i++){				var el = $.element(elements[i], !options.cash);				if (options.ddup){					if (uniques[el.uid]) continue;					uniques[el.uid] = true;				}				returned.push(el);			}			elements = returned;		}		return (options.cash) ? $extend(elements, this) : elements;	}});Elements.implement({	filter: function(filter, bind){		if (!filter) return this;		return new Elements(Array.filter(this, (typeof filter == 'string') ? function(item){			return item.match(filter);		} : filter, bind));	}});Elements.multi = function(property){	return function(){		var items = [];		var elements = true;		for (var i = 0, j = this.length; i < j; i++){			var returns = this[i][property].apply(this[i], arguments);			items.push(returns);			if (elements) elements = ($type(returns) == 'element');		}		return (elements) ? new Elements(items) : items;	};};Window.implement({	$: function(el, nocash){		if (el && el.$family && el.uid) return el;		var type = $type(el);		return ($[type]) ? $[type](el, nocash, this.document) : null;	},	$$: function(selector){		if (arguments.length == 1 && typeof selector == 'string') return this.document.getElements(selector);		var elements = [];		var args = Array.flatten(arguments);		for (var i = 0, l = args.length; i < l; i++){			var item = args[i];			switch ($type(item)){				case 'element': item = [item]; break;				case 'string': item = this.document.getElements(item, true); break;				default: item = false;			}			if (item) elements.extend(item);		}		return new Elements(elements);	},	getDocument: function(){		return this.document;	},	getWindow: function(){		return this;	}});$.string = function(id, nocash, doc){	id = doc.getElementById(id);	return (id) ? $.element(id, nocash) : null;};$.element = function(el, nocash){	$uid(el);	if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){

⌨️ 快捷键说明

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