|
6 | 6 |
|
7 | 7 | var doc = w.document, |
8 | 8 | docElem = doc.documentElement, |
9 | | - head = doc.head || doc.getElementsByTagName( "head" )[ 0 ]; |
| 9 | + head = doc.head || doc.getElementsByTagName( "head" )[ 0 ], |
| 10 | + ejs = {}; |
10 | 11 |
|
11 | 12 | //ejs object for ejs-specific functions |
12 | | - w.ejs = {}; |
| 13 | + w.ejs = ejs; |
13 | 14 |
|
14 | 15 | // hasClass function - check if element has a class |
15 | 16 | ejs.hasClass = function( elem, cls ){ |
16 | | - return elem.className.indexOf( cls ) > -1 |
17 | | - } |
| 17 | + return elem.className.indexOf( cls ) > -1; |
| 18 | + }; |
18 | 19 |
|
19 | 20 | // Callback for running logic dependent on a property being defined |
20 | 21 | // You can use isDefined to run code as soon as the document.body is defined, for example, for body-dependent scripts |
21 | 22 | // or, for a script that's loaded asynchronously that depends on other scripts, such as jQuery. |
22 | 23 | // First argument is the property that must be defined, second is the callback function |
23 | 24 | ejs.onDefine = function( prop, callback ){ |
24 | | - var callbackStack = []; |
| 25 | + var callbackStack = []; |
25 | 26 |
|
26 | 27 | if( callback ){ |
27 | 28 | callbackStack.push( callback ); |
|
34 | 35 | } |
35 | 36 | } |
36 | 37 | else{ |
37 | | - setTimeout(checkRun, 15); |
| 38 | + setTimeout(checkRun, 15); |
38 | 39 | } |
39 | | - }; |
| 40 | + } |
40 | 41 |
|
41 | 42 | checkRun(); |
42 | 43 | }; |
43 | 44 |
|
44 | | - // shortcut of isDefine body-specific |
| 45 | + // shortcut of isDefine body-specific |
45 | 46 | ejs.bodyReady = function( callback ){ |
46 | 47 | ejs.onDefine( "document.body", callback ); |
47 | 48 | }; |
|
79 | 80 | } else { |
80 | 81 | head.appendChild( script ); |
81 | 82 | } |
82 | | - }; |
| 83 | + }; |
83 | 84 |
|
84 | 85 | // Define base directory paths for referencing js, css, img files. Optional. |
85 | 86 | ejs.basepath = { |
|
88 | 89 | }; |
89 | 90 |
|
90 | 91 | // Define arrays to contain JS and CSS files that are available |
91 | | - ejs.files = { |
| 92 | + ejs.files = { |
92 | 93 | js: {}, |
93 | 94 | css: {} |
94 | | - }; |
| 95 | + }; |
95 | 96 |
|
96 | 97 | // Define arrays to contain JS and CSS files that will be loaded |
97 | 98 | ejs.jsToLoad = []; |
98 | 99 | ejs.cssToLoad = []; |
99 | 100 |
|
100 | | - // Function for adding files to the queue for loading. |
101 | | - // CSS or JS is discovered by file path. |
| 101 | + // Function for adding files to the queue for loading. |
| 102 | + // CSS or JS is discovered by file path. |
102 | 103 | // Files should not include base paths, if already defined in ejs.basepath. |
103 | 104 | ejs.addFile = function( file ){ |
104 | 105 | var js = file.indexOf( ".js" ) > -1; |
|
110 | 111 | return ( url.indexOf( ".js" ) > -1 ? ejs.loadJS : ejs.loadCSS )( url ); |
111 | 112 | }; |
112 | 113 |
|
113 | | - // concatSyntax is a function that decorates a URL in whatever way necessary for a concatenator API. |
| 114 | + // concatSyntax is a function that decorates a URL in whatever way necessary for a concatenator API. |
114 | 115 | // To configure, just define it as a function with a url argument, and return that url decorated any way your concatenator expects. |
115 | 116 | // by default, Enhance uses the url pattern suggested in the QuickConcat project: https://github.com/filamentgroup/quickconcat |
116 | 117 | ejs.concatSyntax = function( url ){ |
|
0 commit comments