(ns, dependencies, func, global)
| 9685 | * @param {boolean=} global If true, the class will be added to the global scope (typically window unless you define a window.GreenSockGlobals object) |
| 9686 | */ |
| 9687 | Definition = function(ns, dependencies, func, global) { |
| 9688 | this.sc = (_defLookup[ns]) ? _defLookup[ns].sc : []; //subclasses |
| 9689 | _defLookup[ns] = this; |
| 9690 | this.gsClass = null; |
| 9691 | this.func = func; |
| 9692 | var _classes = []; |
| 9693 | this.check = function(init) { |
| 9694 | var i = dependencies.length, |
| 9695 | missing = i, |
| 9696 | cur, a, n, cl, hasModule; |
| 9697 | while (--i > -1) { |
| 9698 | if ((cur = _defLookup[dependencies[i]] || new Definition(dependencies[i], [])).gsClass) { |
| 9699 | _classes[i] = cur.gsClass; |
| 9700 | missing--; |
| 9701 | } else if (init) { |
| 9702 | cur.sc.push(this); |
| 9703 | } |
| 9704 | } |
| 9705 | if (missing === 0 && func) { |
| 9706 | a = ("com.greensock." + ns).split("."); |
| 9707 | n = a.pop(); |
| 9708 | cl = _namespace(a.join("."))[n] = this.gsClass = func.apply(func, _classes); |
| 9709 | |
| 9710 | //exports to multiple environments |
| 9711 | if (global) { |
| 9712 | _globals[n] = cl; //provides a way to avoid global namespace pollution. By default, the main classes like TweenLite, Power1, Strong, etc. are added to window unless a GreenSockGlobals is defined. So if you want to have things added to a custom object instead, just do something like window.GreenSockGlobals = {} before loading any GreenSock files. You can even set up an alias like window.GreenSockGlobals = windows.gs = {} so that you can access everything like gs.TweenLite. Also remember that ALL classes are added to the window.com.greensock object (in their respective packages, like com.greensock.easing.Power1, com.greensock.TweenLite, etc.) |
| 9713 | hasModule = (typeof(module) !== "undefined" && module.exports); |
| 9714 | if (!hasModule && typeof(define) === "function" && define.amd){ //AMD |
| 9715 | define((window.GreenSockAMDPath ? window.GreenSockAMDPath + "/" : "") + ns.split(".").pop(), [], function() { return cl; }); |
| 9716 | } else if (ns === moduleName && hasModule){ //node |
| 9717 | module.exports = cl; |
| 9718 | } |
| 9719 | } |
| 9720 | for (i = 0; i < this.sc.length; i++) { |
| 9721 | this.sc[i].check(); |
| 9722 | } |
| 9723 | } |
| 9724 | }; |
| 9725 | this.check(true); |
| 9726 | }, |
| 9727 | |
| 9728 | //used to create Definition instances (which basically registers a class that has dependencies). |
| 9729 | _gsDefine = window._gsDefine = function(ns, dependencies, func, global) { |
nothing calls this directly
no test coverage detected