diff --git a/Source/Browser/Browser.js b/Source/Browser/Browser.js index 276b6b670..6232fbe9b 100644 --- a/Source/Browser/Browser.js +++ b/Source/Browser/Browser.js @@ -14,10 +14,10 @@ provides: [Browser, Window, Document] ... */ -(function(){ +(function(global){ -var document = this.document; -var window = document.window = this; +var document = global.document; +var window = document.window = global; var parse = function(ua, platform){ ua = ua.toLowerCase(); @@ -52,9 +52,9 @@ if (Browser.name == 'ie'){ Browser.extend({ Features: { xpath: !!(document.evaluate), - air: !!(window.runtime), + air: !!(global.runtime), query: !!(document.querySelector), - json: !!(window.JSON) + json: !!(global.JSON) }, parseUA: parse }); @@ -131,8 +131,8 @@ Browser.Plugins = { Browser.exec = function(text){ if (!text) return text; - if (window.execScript){ - window.execScript(text); + if (global.execScript){ + global.execScript(text); } else { var script = document.createElement('script'); script.setAttribute('type', 'text/javascript'); @@ -163,15 +163,15 @@ Browser.extend({ Event: this.Event }); -this.Window = this.$constructor = new Type('Window', function(){}); +global.Window = global.$constructor = new Type('Window', function(){}); -this.$family = Function.from('window').hide(); +global.$family = Function.from('window').hide(); Window.mirror(function(name, method){ - window[name] = method; + global[name] = method; }); -this.Document = document.$constructor = new Type('Document', function(){}); +global.Document = document.$constructor = new Type('Document', function(){}); document.$family = Function.from('document').hide(); @@ -187,12 +187,12 @@ if (document.execCommand) try { } catch (e){} /**/ -if (this.attachEvent && !this.addEventListener){ +if (global.attachEvent && !global.addEventListener){ var unloadEvent = function(){ - this.detachEvent('onunload', unloadEvent); + global.detachEvent('onunload', unloadEvent); document.head = document.html = document.window = null; }; - this.attachEvent('onunload', unloadEvent); + global.attachEvent('onunload', unloadEvent); } // IE fails on collections and ) @@ -278,8 +278,8 @@ if (Browser.name == 'unknown'){ } } -this.$exec = Browser.exec; +global.$exec = Browser.exec; // -})(); +})(this); diff --git a/Source/Core/Core.js b/Source/Core/Core.js index 772a31aea..7019014e3 100644 --- a/Source/Core/Core.js +++ b/Source/Core/Core.js @@ -20,16 +20,16 @@ provides: [Core, MooTools, Type, typeOf, instanceOf, Native] ... */ -(function(){ +(function(global){ -this.MooTools = { +global.MooTools = { version: '1.5.1-dev', build: '%build%' }; // typeOf, instanceOf -var typeOf = this.typeOf = function(item){ +var typeOf = global.typeOf = function(item){ if (item == null) return 'null'; if (item.$family != null) return item.$family(); @@ -44,7 +44,7 @@ var typeOf = this.typeOf = function(item){ return typeof item; }; -var instanceOf = this.instanceOf = function(item, object){ +var instanceOf = global.instanceOf = function(item, object){ if (item == null) return false; var constructor = item.$constructor || item.constructor; while (constructor){ @@ -59,7 +59,7 @@ var instanceOf = this.instanceOf = function(item, object){ // Function overloading -var Function = this.Function; +var Function = global.Function; var enumerables = true; for (var i in {toString: 1}) enumerables = null; @@ -149,7 +149,7 @@ Function.implement({ // Type -var Type = this.Type = function(name, object){ +var Type = global.Type = function(name, object){ if (name){ var lower = name.toLowerCase(); var typeCheck = function(item){ @@ -400,7 +400,7 @@ String.extend('uniqueID', function(){ //<1.2compat> -var Hash = this.Hash = new Type('Hash', function(object){ +var Hash = global.Hash = new Type('Hash', function(object){ if (typeOf(object) == 'hash') object = Object.clone(object.getClean()); for (var key in object) this[key] = object[key]; return this; @@ -434,7 +434,7 @@ Hash.alias('each', 'forEach'); Object.type = Type.isObject; -var Native = this.Native = function(properties){ +var Native = global.Native = function(properties){ return new Type(properties.name, properties.initialize); }; @@ -450,64 +450,64 @@ Array.type = function(item){ return instanceOf(item, Array) || arrayType(item); }; -this.$A = function(item){ +global.$A = function(item){ return Array.from(item).slice(); }; -this.$arguments = function(i){ +global.$arguments = function(i){ return function(){ return arguments[i]; }; }; -this.$chk = function(obj){ +global.$chk = function(obj){ return !!(obj || obj === 0); }; -this.$clear = function(timer){ +global.$clear = function(timer){ clearTimeout(timer); clearInterval(timer); return null; }; -this.$defined = function(obj){ +global.$defined = function(obj){ return (obj != null); }; -this.$each = function(iterable, fn, bind){ +global.$each = function(iterable, fn, bind){ var type = typeOf(iterable); ((type == 'arguments' || type == 'collection' || type == 'array' || type == 'elements') ? Array : Object).each(iterable, fn, bind); }; -this.$empty = function(){}; +global.$empty = function(){}; -this.$extend = function(original, extended){ +global.$extend = function(original, extended){ return Object.append(original, extended); }; -this.$H = function(object){ +global.$H = function(object){ return new Hash(object); }; -this.$merge = function(){ +global.$merge = function(){ var args = Array.slice(arguments); args.unshift({}); return Object.merge.apply(null, args); }; -this.$lambda = Function.from; -this.$mixin = Object.merge; -this.$random = Number.random; -this.$splat = Array.from; -this.$time = Date.now; +global.$lambda = Function.from; +global.$mixin = Object.merge; +global.$random = Number.random; +global.$splat = Array.from; +global.$time = Date.now; -this.$type = function(object){ +global.$type = function(object){ var type = typeOf(object); if (type == 'elements') return 'array'; return (type == 'null') ? false : type; }; -this.$unlink = function(object){ +global.$unlink = function(object){ switch (typeOf(object)){ case 'object': return Object.clone(object); case 'array': return Array.clone(object); @@ -518,4 +518,4 @@ this.$unlink = function(object){ // -})(); +})(this); diff --git a/Source/Element/Element.Delegation.js b/Source/Element/Element.Delegation.js index 5be2305fd..ce5c5c610 100644 --- a/Source/Element/Element.Delegation.js +++ b/Source/Element/Element.Delegation.js @@ -14,9 +14,9 @@ provides: [Element.Delegation] ... */ -(function(){ +(function(global){ -var eventListenerSupport = !!window.addEventListener; +var eventListenerSupport = !!global.addEventListener; Element.NativeEvents.focusin = Element.NativeEvents.focusout = 2; @@ -198,4 +198,4 @@ var delegation = { removeEvent: relay(removeEvent, delegation.removeEvent) }); -})(); +})(this); diff --git a/Source/Element/Element.Dimensions.js b/Source/Element/Element.Dimensions.js index e9d507d49..f85c57cb0 100644 --- a/Source/Element/Element.Dimensions.js +++ b/Source/Element/Element.Dimensions.js @@ -18,7 +18,7 @@ provides: [Element.Dimensions] ... */ -(function(){ +(function(global){ var element = document.createElement('div'), child = document.createElement('div'); @@ -32,7 +32,7 @@ var heightComponents = ['height', 'paddingTop', 'paddingBottom', 'borderTopWidth var svgCalculateSize = function(el){ - var gCS = window.getComputedStyle(el), + var gCS = global.getComputedStyle(el), bounds = {x: 0, y: 0}; heightComponents.each(function(css){ @@ -69,7 +69,7 @@ Element.implement({ // // This if clause is because IE8- cannot calculate getBoundingClientRect of elements with visibility hidden. - if (!window.getComputedStyle) return {x: this.offsetWidth, y: this.offsetHeight}; + if (!global.getComputedStyle) return {x: this.offsetWidth, y: this.offsetHeight}; // // This svg section under, calling `svgCalculateSize()`, can be removed when FF fixed the svg size bug. @@ -274,7 +274,7 @@ function getCompatElement(element){ return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body; } -})(); +})(this); //aliases Element.alias({position: 'setPosition'}); //compatability diff --git a/Source/Element/Element.Event.js b/Source/Element/Element.Event.js index 7e1cd2ba1..a6318f166 100644 --- a/Source/Element/Element.Event.js +++ b/Source/Element/Element.Event.js @@ -14,7 +14,7 @@ provides: Element.Event ... */ -(function(){ +(function(global){ Element.Properties.events = {set: function(events){ this.addEvents(events); @@ -171,7 +171,7 @@ if ('onmouseenter' in document.documentElement){ } /**/ -if (!window.addEventListener){ +if (!global.addEventListener){ Element.NativeEvents.propertychange = 2; Element.Events.change = { base: function(){ @@ -191,4 +191,4 @@ Element.Events = new Hash(Element.Events); // -})(); +})(this); diff --git a/Source/Element/Element.Style.js b/Source/Element/Element.Style.js index 30b838c86..61efdf463 100644 --- a/Source/Element/Element.Style.js +++ b/Source/Element/Element.Style.js @@ -14,7 +14,7 @@ provides: Element.Style ... */ -(function(){ +(function(global){ var html = document.html, el; @@ -32,7 +32,7 @@ var returnsBordersInWrongOrder = el.style.border != border; el = null; // -var hasGetComputedStyle = !!window.getComputedStyle, +var hasGetComputedStyle = !!global.getComputedStyle, supportBorderRadius = document.createElement('div').style.borderRadius != null; Element.Properties.styles = {set: function(styles){ @@ -260,4 +260,4 @@ Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, bor }); if (hasBackgroundPositionXY) Element.ShortStyles.backgroundPosition = {backgroundPositionX: '@', backgroundPositionY: '@'}; -})(); +})(this); diff --git a/Source/Element/Element.js b/Source/Element/Element.js index de82bf1b3..98cd5c852 100644 --- a/Source/Element/Element.js +++ b/Source/Element/Element.js @@ -13,8 +13,8 @@ provides: [Element, Elements, $, $$, IFrame, Selectors] ... */ - -var Element = this.Element = function(tag, props){ +(function(global){ +var Element = global.Element = function(tag, props){ var konstructor = Element.Constructors[tag]; if (konstructor) return konstructor(props); if (typeof tag != 'string') return document.id(tag).set(props); @@ -89,7 +89,7 @@ Element.Constructors = new Hash; // -var IFrame = new Type('IFrame', function(){ +var IFrame = global.IFrame = new Type('IFrame', function(){ var params = Array.link(arguments, { properties: Type.isObject, iframe: function(obj){ @@ -108,12 +108,12 @@ var IFrame = new Type('IFrame', function(){ onload.call(iframe.contentWindow); }; - if (window.frames[props.id]) onLoad(); + if (global.frames[props.id]) onLoad(); else iframe.addListener('load', onLoad); return iframe; }); -var Elements = this.Elements = function(nodes){ +var Elements = global.Elements = function(nodes){ if (nodes && nodes.length){ var uniques = {}, node; for (var i = 0; node = nodes[i++];){ @@ -184,6 +184,8 @@ Elements.alias('extend', 'append'); // +})(this); + (function(){ // FF, IE @@ -259,9 +261,9 @@ Document.implement({ })(); -(function(){ +(function(global){ -Slick.uidOf(window); +Slick.uidOf(global); Slick.uidOf(document); Document.implement({ @@ -321,7 +323,7 @@ Document.implement({ }); -if (window.$ == null) Window.implement('$', function(el, nc){ +if (global.$ == null) Window.implement('$', function(el, nc){ return document.id(el, nc, this.document); }); @@ -364,8 +366,8 @@ Element.implement('hasChild', function(element){ (function(search, find, match){ - this.Selectors = {}; - var pseudos = this.Selectors.Pseudo = new Hash(); + global.Selectors = {}; + var pseudos = global.Selectors.Pseudo = new Hash(); var addSlickPseudos = function(){ for (var name in pseudos) if (pseudos.hasOwnProperty(name)){ @@ -459,7 +461,7 @@ Element.implement({ //<1.2compat> -if (window.$$ == null) Window.implement('$$', function(selector){ +if (global.$$ == null) Window.implement('$$', function(selector){ var elements = new Elements; if (arguments.length == 1 && typeof selector == 'string') return Slick.search(this.document, selector, elements); var args = Array.flatten(arguments); @@ -475,7 +477,7 @@ if (window.$$ == null) Window.implement('$$', function(selector){ // -if (window.$$ == null) Window.implement('$$', function(selector){ +if (global.$$ == null) Window.implement('$$', function(selector){ if (arguments.length == 1){ if (typeof selector == 'string') return Slick.search(this.document, selector, new Elements); else if (Type.isEnumerable(selector)) return new Elements(selector); @@ -986,7 +988,7 @@ Element.implement({ [Element, Window, Document].invoke('implement', { addListener: function(type, fn){ - if (window.attachEvent && !window.addEventListener){ + if (global.attachEvent && !global.addEventListener){ collected[Slick.uidOf(this)] = this; } if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]); @@ -1021,13 +1023,13 @@ Element.implement({ }); /**/ -if (window.attachEvent && !window.addEventListener){ +if (global.attachEvent && !global.addEventListener){ var gc = function(){ Object.each(collected, clean); - if (window.CollectGarbage) CollectGarbage(); - window.removeListener('unload', gc); + if (global.CollectGarbage) CollectGarbage(); + global.removeListener('unload', gc); } - window.addListener('unload', gc); + global.addListener('unload', gc); } /**/ @@ -1191,4 +1193,4 @@ if (document.createElement('div').getAttributeNode('id')) Element.Properties.id }; /**/ -})(); +})(this); diff --git a/Source/Fx/Fx.js b/Source/Fx/Fx.js index 0db234ecf..76f0eac9d 100644 --- a/Source/Fx/Fx.js +++ b/Source/Fx/Fx.js @@ -14,9 +14,9 @@ provides: Fx ... */ -(function(){ +(function(global){ -var Fx = this.Fx = new Class({ +var Fx = global.Fx = new Class({ Implements: [Chain, Events, Options], @@ -180,4 +180,4 @@ var pullInstance = function(fps){ } }; -})(); +})(this); diff --git a/Source/Request/Request.js b/Source/Request/Request.js index cb27a0558..661f0226c 100644 --- a/Source/Request/Request.js +++ b/Source/Request/Request.js @@ -14,12 +14,12 @@ provides: Request ... */ -(function(){ +(function(global){ var empty = function(){}, progressSupport = ('onprogress' in new Browser.Request); -var Request = this.Request = new Class({ +var Request = global.Request = new Class({ Implements: [Chain, Events, Options], @@ -282,4 +282,4 @@ Element.implement({ }); -})(); +})(this); diff --git a/Source/Slick/Slick.Finder.js b/Source/Slick/Slick.Finder.js index f560800ae..52817104c 100644 --- a/Source/Slick/Slick.Finder.js +++ b/Source/Slick/Slick.Finder.js @@ -7,7 +7,7 @@ requires: Slick.Parser ... */ -;(function(){ +;(function(global){ var local = {}, featuresCache = {}, @@ -897,7 +897,7 @@ attributeGetters.MAXLENGTH = attributeGetters.maxLength = attributeGetters.maxle // Slick -var Slick = local.Slick = (this.Slick || {}); +var Slick = local.Slick = (global.Slick || {}); Slick.version = '1.1.7'; @@ -980,6 +980,6 @@ Slick.uidOf = function(node){ return local.getUIDHTML(node); }; -if (!this.Slick) this.Slick = Slick; +if (!global.Slick) global.Slick = Slick; -}).apply(/**/(typeof exports != 'undefined') ? exports : /**/this); +})(/**/(typeof exports != 'undefined') ? exports : /**/this); diff --git a/Source/Slick/Slick.Parser.js b/Source/Slick/Slick.Parser.js index e9e78f7a3..b504caff4 100644 --- a/Source/Slick/Slick.Parser.js +++ b/Source/Slick/Slick.Parser.js @@ -6,7 +6,7 @@ provides: Slick.Parser ... */ -;(function(){ +;(function(global){ var parsed, separatorIndex, @@ -217,7 +217,7 @@ function parser( // Slick NS -var Slick = (this.Slick || {}); +var Slick = (global.Slick || {}); Slick.parse = function(expression){ return parse(expression); @@ -225,6 +225,6 @@ Slick.parse = function(expression){ Slick.escapeRegExp = escapeRegExp; -if (!this.Slick) this.Slick = Slick; +if (!global.Slick) global.Slick = Slick; -}).apply(/**/(typeof exports != 'undefined') ? exports : /**/this); +})(/**/(typeof exports != 'undefined') ? exports : /**/this); diff --git a/Source/Types/DOMEvent.js b/Source/Types/DOMEvent.js index 21d18c65b..4e06380ec 100644 --- a/Source/Types/DOMEvent.js +++ b/Source/Types/DOMEvent.js @@ -14,12 +14,12 @@ provides: Event ... */ -(function() { +(function(global) { var _keys = {}; -var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){ - if (!win) win = window; +var DOMEvent = global.DOMEvent = new Type('DOMEvent', function(event, win){ + if (!win) win = global; event = event || win.event; if (event.$extended) return event; this.event = event; @@ -111,10 +111,8 @@ DOMEvent.defineKeys({ '46': 'delete', '13': 'enter' }); -})(); - /*<1.3compat>*/ -var Event = DOMEvent; +global.Event = DOMEvent; Event.Keys = {}; /**/ @@ -123,3 +121,4 @@ Event.Keys = {}; Event.Keys = new Hash(Event.Keys); /**/ +})(this); diff --git a/Source/Types/Function.js b/Source/Types/Function.js index 092ca44da..a9eb66923 100644 --- a/Source/Types/Function.js +++ b/Source/Types/Function.js @@ -14,6 +14,8 @@ provides: Function ... */ +(function(global){ + Function.extend({ attempt: function(){ @@ -88,7 +90,7 @@ Function.implement({ return function(event){ var args = options.arguments; args = (args != null) ? Array.from(args) : Array.slice(arguments, (options.event) ? 1 : 0); - if (options.event) args = [event || window.event].extend(args); + if (options.event) args = [event || global.event].extend(args); var returns = function(){ return self.apply(options.bind || null, args); }; @@ -123,6 +125,8 @@ Function.implement({ if (Object.create == Function.prototype.create) Object.create = null; -var $try = Function.attempt; +global.$try = Function.attempt; // + +})(this); diff --git a/Source/Utilities/DOMReady.js b/Source/Utilities/DOMReady.js index 9327bb1df..15514a898 100644 --- a/Source/Utilities/DOMReady.js +++ b/Source/Utilities/DOMReady.js @@ -14,7 +14,7 @@ provides: [DOMReady, DomReady] ... */ -(function(window, document){ +(function(global, document){ var ready, loaded, @@ -30,7 +30,7 @@ var domready = function(){ document.removeListener('DOMContentLoaded', domready).removeListener('readystatechange', check); document.fireEvent('domready'); - window.fireEvent('domready'); + global.fireEvent('domready'); }; var check = function(){ @@ -86,10 +86,10 @@ Element.Events.domready = { Element.Events.load = { base: 'load', onAdd: function(fn){ - if (loaded && this == window) fn.call(this); + if (loaded && this == global) fn.call(this); }, condition: function(){ - if (this == window){ + if (this == global){ domready(); delete Element.Events.load; } @@ -98,8 +98,8 @@ Element.Events.load = { }; // This is based on the custom load event -window.addEvent('load', function(){ +global.addEvent('load', function(){ loaded = true; }); -})(window, document); +})(this, document);