|
1 |
| -var Main, |
2 |
| - _ = require( "underscore" ), |
3 |
| - Config = require( "./lib/config" ); |
| 1 | +module.exports = { |
| 2 | + /** |
| 3 | + * The Builder class. |
| 4 | + */ |
| 5 | + Builder: require( "./lib/builder" ), |
4 | 6 |
|
5 |
| -/** |
6 |
| - * Main( options ) -- or require( "download.jqueryui.com" )( options ) |
7 |
| - * - options [ Object ]: key-value pairs detailed below. |
8 |
| - * |
9 |
| - * options |
10 |
| - * - config [ Object ]: optional, if present used instead of the `config.json` file; |
11 |
| - * - env [ String ]: optional, specify whether in development or production environment. Default: "development". |
12 |
| - * - host [ String ]: optional, specify the host where download.jqueryui.com server is running. Default: "" (empty string). |
13 |
| - * |
14 |
| - * attributes |
15 |
| - * - frontend [ Object ]: for more details see `frontend.js`. |
16 |
| - * |
17 |
| - */ |
18 |
| -module.exports = function( options ) { |
19 |
| - return new Main( options ); |
20 |
| -}; |
| 7 | + /** |
| 8 | + * The JqueryUi class. |
| 9 | + */ |
| 10 | + JqueryUi: require( "./lib/jquery-ui" ), |
21 | 11 |
|
22 |
| -Main = function( options ) { |
23 |
| - options = _.extend( {}, Main.defaults, options ); |
24 |
| - if ( options.config && typeof options.config === "object" ) { |
25 |
| - Config.get = function() { |
26 |
| - return options.config; |
27 |
| - }; |
28 |
| - } |
29 |
| - this.frontend = new ( require( "./frontend" ) )( options ); |
30 |
| -}; |
| 12 | + /** |
| 13 | + * The JqueryUi class. |
| 14 | + */ |
| 15 | + Packer: require( "./lib/packer" ), |
31 | 16 |
|
32 |
| -Main.defaults = { |
33 |
| - // Empty, check frontend.js's. |
34 |
| -}; |
| 17 | + /** |
| 18 | + * The Util object. |
| 19 | + */ |
| 20 | + util: require( "./lib/util" ), |
35 | 21 |
|
36 |
| -Main.prototype = { |
| 22 | + /** |
| 23 | + * frontend( options ) |
| 24 | + * - options [ Object ]: see `frontend.js` for more details. |
| 25 | + * |
| 26 | + * Returns a frontend instance. |
| 27 | + */ |
| 28 | + frontend: function( options ) { |
| 29 | + return new ( require( "./frontend" ) )( options ); |
| 30 | + }, |
37 | 31 |
|
38 | 32 | /**
|
39 |
| - * Main#buildThemesBundle( callback ) |
40 |
| - * - callback( err, bundleFiles ): bundleFiles is an Array of { path:<path>, data:<data> }'s. |
| 33 | + * themeGallery( jqueryUi ) |
| 34 | + * - jqueryUi [ instanceof JqueryUi ]: see `frontend.js` for more details. |
41 | 35 | *
|
42 |
| - * Generates the theme bundle with base and all themes from themegallery. |
| 36 | + * Returns themeGallery using jqueryUi's version. |
43 | 37 | */
|
44 |
| - buildThemesBundle: function( callback ) { |
45 |
| - var allComponents, jqueryUi, success, |
46 |
| - async = require( "async" ), |
47 |
| - Builder = require( "./lib/builder" ), |
48 |
| - Packer = require( "./lib/packer" ), |
49 |
| - bundleFiles = [], |
50 |
| - JqueryUi = require( "./lib/jquery-ui" ), |
51 |
| - themeGallery = require( "./lib/themeroller.themegallery" )(); |
52 |
| - |
53 |
| - jqueryUi = JqueryUi.getStable(); |
54 |
| - allComponents = jqueryUi.components().map(function( component ) { |
55 |
| - return component.name; |
56 |
| - }); |
57 |
| - |
58 |
| - async.mapSeries( themeGallery, function( theme, callback ) { |
59 |
| - var build = new Builder( jqueryUi, allComponents ), |
60 |
| - packer = new Packer( build, theme, { skipDocs: true } ), |
61 |
| - folderName = theme.folderName(); |
62 |
| - packer.pack(function( err, files ) { |
63 |
| - if ( err ) { |
64 |
| - return callback( err ); |
65 |
| - } |
66 |
| - // Add theme files. |
67 |
| - files |
68 |
| - // Pick only theme files we need on the bundle. |
69 |
| - .filter(function( file ) { |
70 |
| - var themeCssOnlyRe = new RegExp( "development-bundle/themes/" + folderName + "/jquery.ui.theme.css" ), |
71 |
| - themeDirRe = new RegExp( "css/" + folderName ); |
72 |
| - if ( themeCssOnlyRe.test( file.path ) || themeDirRe.test( file.path ) ) { |
73 |
| - return true; |
74 |
| - } |
75 |
| - return false; |
76 |
| - }) |
77 |
| - // Convert paths the way bundle needs and add it into bundleFiles. |
78 |
| - .forEach(function( file ) { |
79 |
| - // 1: Remove initial package name eg. "jquery-ui-1.10.0.custom". |
80 |
| - // 2: Make jquery-ui-1.10.0.custom.css into jquery-ui.css, or jquery-ui-1.10.0.custom.min.css into jquery-ui.min.css |
81 |
| - file.path = file.path |
82 |
| - .split( "/" ).slice( 1 ).join( "/" ) /* 1 */ |
83 |
| - .replace( /development-bundle\/themes/, "css" ) |
84 |
| - .replace( /css/, "themes" ) |
85 |
| - .replace( /jquery-ui-.*?(\.min)*\.css/, "jquery-ui$1.css" ); /* 2 */ |
86 |
| - bundleFiles.push( file ); |
87 |
| - }); |
88 |
| - |
89 |
| - callback( null, files ); |
90 |
| - }); |
91 |
| - }, function( err ) { |
92 |
| - callback( err, bundleFiles ); |
93 |
| - }); |
| 38 | + themeGallery: function( jqueryUi ) { |
| 39 | + return require( "./lib/themeroller.themegallery" )( jqueryUi ); |
94 | 40 | }
|
95 | 41 | };
|
96 |
| - |
0 commit comments