Skip to content

Commit

Permalink
jQuery UI Themes Packer: Extend it and export API
Browse files Browse the repository at this point in the history
Extend ThemesPacker with includeJs option, so it builds the CDN package.

Export ThemesPacker API, so release script is able to use it.

Fixes #9743
Closes gh-202
  • Loading branch information
rxaviers committed Apr 6, 2014
1 parent 87c34ba commit 723ffb4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,15 +375,14 @@ function buildPackages( folder, callback ) {

// For each jQuery UI release specified in the config file:
async.forEachSeries( JqueryUi.all(), function( jqueryUi, callback ) {
var builder = new Builder( jqueryUi, ":all:" ),
themeGallery = new ThemeGallery( jqueryUi );
var builder = new Builder( jqueryUi, ":all:" );

async.series([

// (a) Build jquery-ui-[VERSION].zip;
function( callback ) {
var stream,
theme = themeGallery[ 0 ],
theme = new ThemeGallery( jqueryUi )[ 0 ],
packer = new Packer( builder, theme, { bundleSuffix: "" }),
filename = path.join( folder, packer.filename() );
grunt.log.ok( "Building \"" + filename + "\"" );
Expand Down
1 change: 1 addition & 0 deletions lib/themeroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function ThemeRoller( options ) {
this.vars = {};
return;
} else if ( vars ) {
vars = _.clone( vars );
this._folderName = vars.folderName;
this.name = vars.name;
this.scope = vars.scope;
Expand Down
31 changes: 29 additions & 2 deletions lib/themes-packer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ var async = require( "async" ),


/**
* ThemesPacker( builder )
* ThemesPacker( builder, options )
* - builder [ instanceof Builder ]: jQuery UI builder object.
* - options: details below.
*
* options:
* - includeJs [ Boolean ]: Includes JavaScript files (used at CDN package). Default is false.
*/
function ThemesPacker( builder ) {
function ThemesPacker( builder, options ) {
this.basedir = "jquery-ui-themes-" + builder.jqueryUi.pkg.version;
this.builder = builder;
this.options = options || {};
this.themeGallery = ThemeGallery( builder.jqueryUi );
}

Expand Down Expand Up @@ -40,6 +45,7 @@ ThemesPacker.prototype = {
},
basedir = this.basedir,
builder = this.builder,
options = this.options,
output = [],
themeGallery = this.themeGallery;

Expand All @@ -59,6 +65,27 @@ ThemesPacker.prototype = {
return (/AUTHORS.txt|MIT-LICENSE.txt|package.json/).test( file.path );
}).forEach( add );

if ( options.includeJs ) {
// "ui/*.js"
build.componentFiles.filter(function( file ) {
return (/^ui\//).test( file.path );
}).forEach( add );

// "ui/*.min.js"
build.componentMinFiles.filter(function( file ) {
return (/^ui\//).test( file.path );
}).forEach( add );

// "i18n/*.js"
build.i18nFiles.rename( /^ui\//, "" ).forEach( add );
build.i18nMinFiles.rename( /^ui\//, "" ).forEach( add );
build.bundleI18n.into( "i18n/" ).forEach( add );
build.bundleI18nMin.into( "i18n/" ).forEach( add );

build.bundleJs.forEach( add );
build.bundleJsMin.forEach( add );
}

async.mapSeries( themeGallery, function( theme, callback ) {
// Bundle CSS (and minified)
build.bundleCss( theme ).into( "themes/" + theme.folderName() + "/" ).forEach( add );
Expand Down
7 changes: 6 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@ module.exports = {
JqueryUi: require( "./lib/jquery-ui" ),

/**
* The JqueryUi class.
* The jQuery UI Packer class.
*/
Packer: require( "./lib/packer" ),

/**
* The jQuery UI Themes Packer class.
*/
ThemesPacker: require( "./lib/themes-packer" ),

/**
* The Util object.
*/
Expand Down

0 comments on commit 723ffb4

Please sign in to comment.