📄 mootools-1.2-core.js.svn-base
字号:
delete this[mutator]; } this.constructor = klass; if (empty === $empty) return this; var self = (this.initialize) ? this.initialize.apply(this, arguments) : this; if (this.options && this.options.initialize) this.options.initialize.call(this); return self; }; $extend(klass, this); klass.constructor = Class; klass.prototype = properties; return klass; }});Class.implement({ implement: function(){ Class.Mutators.Implements(this.prototype, Array.slice(arguments)); return this; }});Class.Mutators = { Implements: function(self, klasses){ $splat(klasses).each(function(klass){ $extend(self, ($type(klass) == 'class') ? new klass($empty) : klass); }); }, Extends: function(self, klass){ var instance = new klass($empty); delete instance.parent; delete instance.parentOf; for (var key in instance){ var current = self[key], previous = instance[key]; if (current == undefined){ self[key] = previous; continue; } var ctype = $type(current), ptype = $type(previous); if (ctype != ptype) continue; switch (ctype){ case 'function': // this code will be only executed if the current browser does not support function.caller (currently only opera). // we replace the function code with brute force. Not pretty, but it will only be executed if function.caller is not supported. if (!arguments.callee.caller) self[key] = eval('(' + String(current).replace(/\bthis\.parent\(\s*(\))?/g, function(full, close){ return 'arguments.callee._parent_.call(this' + (close || ', '); }) + ')'); // end "opera" code self[key]._parent_ = previous; break; case 'object': self[key] = $merge(previous, current); } } self.parent = function(){ return arguments.callee.caller._parent_.apply(this, arguments); }; self.parentOf = function(descendant){ return descendant._parent_.apply(this, Array.slice(arguments, 1)); }; } };/*Script: Class.Extras.js Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.License: MIT-style license.*/var Chain = new Class({ chain: function(){ this.$chain = (this.$chain || []).extend(arguments); return this; }, callChain: function(){ return (this.$chain && this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false; }, clearChain: function(){ if (this.$chain) this.$chain.empty(); return this; }});var Events = new Class({ addEvent: function(type, fn, internal){ type = Events.removeOn(type); if (fn != $empty){ this.$events = this.$events || {}; this.$events[type] = this.$events[type] || []; this.$events[type].include(fn); if (internal) fn.internal = true; } return this; }, addEvents: function(events){ for (var type in events) this.addEvent(type, events[type]); return this; }, fireEvent: function(type, args, delay){ type = Events.removeOn(type); if (!this.$events || !this.$events[type]) return this; this.$events[type].each(function(fn){ fn.create({'bind': this, 'delay': delay, 'arguments': args})(); }, this); return this; }, removeEvent: function(type, fn){ type = Events.removeOn(type); if (!this.$events || !this.$events[type]) return this; if (!fn.internal) this.$events[type].erase(fn); return this; }, removeEvents: function(type){ for (var e in this.$events){ if (type && type != e) continue; var fns = this.$events[e]; for (var i = fns.length; i--; i) this.removeEvent(e, fns[i]); } return this; }});Events.removeOn = function(string){ return string.replace(/^on([A-Z])/, function(full, first) { return first.toLowerCase(); });};var Options = new Class({ setOptions: function(){ this.options = $merge.run([this.options].extend(arguments)); if (!this.addEvent) return this; for (var option in this.options){ if ($type(this.options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue; this.addEvent(option, this.options[option]); delete this.options[option]; } 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)){ var proto = Element.Prototype; for (var p in proto) el[p] = proto[p]; }; return el;};$.object = function(obj, nocash, doc){ if (obj.toElement) return $.element(obj.toElement(doc), nocash); return null;};$.textnode = $.whitespace = $.window = $.document = $arguments(0);Native.implement([Element, Document], { getElement: function(selector, nocash){ return $(this.getElements(selector, true)[0] || null, nocash); }, getElements: function(tags, nocash){ tags = tags.split(','); var elements = []; var ddup = (tags.length > 1); tags.each(function(tag){ var partial = this.getElementsByTagName(tag.trim()); (ddup) ? elements.extend(partial) : elements = partial; }, this); return new Elements(elements, {ddup: ddup, cash: !nocash}); }});Element.Storage = { get: function(uid){ return (this[uid] || (this[uid] = {})); }};Element.Inserters = new Hash({ before: function(context, element){ if (element.parentNode) element.parentNode.insertBefore(context, element); }, after: function(context, element){ if (!element.parentNode) return; var next = element.nextSibling; (next) ? element.parentNode.insertBefore(context, next) : element.parentNode.appendChild(context); }, bottom: function(context, element){ element.appendChild(context); }, top: function(context, element){ var first = element.firstChild; (first) ? element.insertBefore(context, first) : element.appendChild(context); }});Element.Inserters.inside = Element.Inserters.bottom;Element.Inserters.each(function(value, key){ var Key = key.capitalize(); Element.implement('inject' + Key, function(el){ value(this, $(el, true)); return this; }); Element.implement('grab' + Key, function(el){ value($(el, true), this); return this; });});Element.implement({ getDocument: function(){ return this.ownerDocument; }, getWindow: function(){ return this.ownerDocument.getWindow(); }, getElementById: function(id, nocash){ var el = this.ownerDocument.getElementById(id); if (!el) return null; for (var parent = el.parentNode; parent != this; parent = parent.parentNode){ if (!parent) return null; } return $.element(el, nocash); }, set: function(prop, value){ switch ($type(prop)){ case 'object': for (var p in prop) this.set(p, prop[p]); break; case 'string': var property = Element.Properties.get(prop); (property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value); } return this; }, get: function(prop){ var property = Element.Properties.get(prop); return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop); }, erase: function(prop){ var property = Element.Properties.get(prop); (property && property.erase) ? property.erase.apply(this, Array.slice(arguments, 1)) : this.removeProperty(prop); return this; }, match: function(tag){ return (!tag || Element.get(this, 'tag') == tag); }, inject: function(el, where){ Element.Inserters.get(where || 'bottom')(this, $(el, true)); return this; }, wraps: function(el, where){ el = $(el, true); return this.replaces(el).grab(el, where); }, grab: function(el, where){ Element.Inserters.get(where || 'bottom')($(el, true), this); return this; }, appendText: function(text, where){ return this.grab(this.getDocument().newTextNode(text), where); }, adopt: function(){ Array.flatten(arguments).each(function(element){ element = $(element, true);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -