From f5d25e42591e58a618bc59bd0709525ebf072954 Mon Sep 17 00:00:00 2001 From: Rafael Xavier de Souza Date: Tue, 13 May 2014 18:26:53 -0700 Subject: [PATCH] Packer: Simplify jQuery UI 1.11 package Closes gh-207 --- app/src/download.js | 8 +- download.js | 5 + lib/builder-1-11.js | 82 +--- lib/packer-1-10.js | 239 ++++++++++ lib/packer-1-11.js | 137 ++++++ lib/packer.js | 241 +--------- template/download/index.html | 2 +- template/download/theme.html | 8 +- template/zip/{index.html => index-1-10.html} | 0 template/zip/index-1-11.html | 467 +++++++++++++++++++ test/packer.js | 373 ++------------- 11 files changed, 917 insertions(+), 645 deletions(-) create mode 100644 lib/packer-1-10.js create mode 100644 lib/packer-1-11.js rename template/zip/{index.html => index-1-10.html} (100%) create mode 100644 template/zip/index-1-11.html diff --git a/app/src/download.js b/app/src/download.js index 339e4f20..a1a8dc48 100644 --- a/app/src/download.js +++ b/app/src/download.js @@ -268,6 +268,8 @@ model.defaults[ "version" ] = $( "#download-builder [name=version][checked]" ).val(); model.on( "change", function( changed, created ) { + var versionElement; + if ( "folderName" in changed && !model.get( "folderName" ).length ) { delete model.attributes.folderName; delete changed.folderName; @@ -316,7 +318,11 @@ }); if ( "version" in changed ) { - $( "#download-builder [name=version][value=\"" + model.get( "version" ) + "\"]" ).trigger( "click" ); + versionElement = $( "#download-builder [name=version][value=\"" + model.get( "version" ) + "\"]" ); + versionElement.trigger( "click" ); + themesLoad.done(function() { + $( ".advanced-settings .folder-name-area" ).toggle( !versionElement.data( "no-theme-folder" ) ); + }); if ( created.version ) { initComponents( initialComponents ); } else { diff --git a/download.js b/download.js index c00cffea..61e6098f 100644 --- a/download.js +++ b/download.js @@ -7,6 +7,7 @@ var downloadLogger, jqueryUis, logger = require( "simple-log" ).init( "download.jqueryui.com" ), Packer = require( "./lib/packer" ), querystring = require( "querystring" ), + semver = require( "semver" ), themeGallery = require( "./lib/themeroller-themegallery" )(), ThemeRoller = require( "./lib/themeroller" ), winston = require( "winston" ); @@ -26,6 +27,10 @@ Handlebars.registerHelper( "isVersionChecked", function( jqueryUi ) { return JqueryUi.getStable().pkg.version === jqueryUi.pkg.version ? " checked=\"checked\"" : ""; }); +Handlebars.registerHelper( "isThereThemeFolder", function( jqueryUi ) { + return semver.gte( jqueryUi.pkg.version, "1.11.0-a" ) ? " data-no-theme-folder=\"true\"" : ""; +}); + Handlebars.registerHelper( "join", function( array, sep, options ) { return array.map(function( item ) { return options.fn( item ); diff --git a/lib/builder-1-11.js b/lib/builder-1-11.js index 12d02831..4fe190ea 100644 --- a/lib/builder-1-11.js +++ b/lib/builder-1-11.js @@ -93,7 +93,7 @@ function rjsConfig( attributes ) { * Builder 1.11 */ function Builder_1_11_0( build, jqueryUi, components, options, callback ) { - var _bundleCss, baseCss, baseCssMin, cssComponentFileNames, docsCategories, existingCss, selectedDemoRe, selectedRe, + var _bundleCss, cssComponentFileNames, docsCategories, existingCss, selectedDemoRe, selectedRe, structureCss, structureCssBanner, structureCssMin, files = jqueryUi.files(), min = function( file ) { return files.min( file ); @@ -111,9 +111,6 @@ function Builder_1_11_0( build, jqueryUi, components, options, callback ) { build.files = files; build.pkg = jqueryUi.pkg; - build.baseTheme = util.stripBanner( files.get( "themes/base/theme.css" ) ); - build.baseThemeMin = util.stripBanner( files.min( files.get( "themes/base/theme.css" ) ) ); - build.commonFiles = files.commonFiles; build.componentFiles = files.componentFiles.filter( selected ); @@ -121,31 +118,14 @@ function Builder_1_11_0( build, jqueryUi, components, options, callback ) { return (/^ui\//).test( file.path ); }).map( min ); - build.baseThemeFiles = files.baseThemeFiles; - build.baseThemeMinFiles = files.baseThemeFiles.filter( selected ).map( min ); - - build.baseThemeExceptThemeOrImages = files.baseThemeFiles.filter(function( file ) { - if ( (/theme\W|jquery-ui|images/).test( file.path ) ) { - return false; - } - if ( (/all|base/).test( file.path ) ) { - return true; - } - return selected( file ); - }); - - build.baseThemeImages = files.baseThemeFiles.filter(function( file ) { - return (/images/).test( file.path ); - }); - // Bundle CSS (and minified) existingCss = function( component ) { return files.get( "themes/base/" + component + ".css" ) !== undefined; }; - baseCss = components.filter( existingCss ).reduce(function( sum, component ) { + structureCss = components.filter( existingCss ).reduce(function( sum, component ) { return sum + stripBanner( files.get( "themes/base/" + component + ".css" ) ); }, "" ); - baseCssMin = components.filter( existingCss ).reduce(function( sum, component ) { + structureCssMin = components.filter( existingCss ).reduce(function( sum, component ) { return sum + stripBanner( files.min( files.get( "themes/base/" + component + ".css" ) ) ); }, "" ); cssComponentFileNames = components.filter( existingCss ).map(function( component ) { @@ -153,13 +133,9 @@ function Builder_1_11_0( build, jqueryUi, components, options, callback ) { }); if ( options.scope ) { // Scope all rules due to specificity issue with tabs (see #gt87) - baseCss = util.scope( baseCss, options.scope ); - baseCssMin = util.scope( baseCssMin, options.scope ); + structureCss = util.scope( structureCss, options.scope ); + structureCssMin = util.scope( structureCssMin, options.scope ); } - build.baseThemeMinFiles.push({ - path: "themes/base/theme.min.css", - data: banner( jqueryUi.pkg, null, { minify: true } ) + build.baseCssMin - }); _bundleCss = function( base, theme, options ) { var bundleCss = base, fileNames = cssComponentFileNames; @@ -182,60 +158,22 @@ function Builder_1_11_0( build, jqueryUi, components, options, callback ) { } return banner( jqueryUi.pkg, fileNames, options ) + bundleCss; }; + structureCssBanner = files.baseThemeCss.data.replace( /\*\/[\s\S]*/, "*/" ).replace( /\n.*\n.*themeroller.*/, "" ); + build.structureCss = structureCssBanner + "\n\n" + structureCss; + build.structureCssMin = banner( jqueryUi.pkg, null, { minify: true } ) + structureCssMin; build.bundleCss = function( theme ) { return Files({ path: "jquery-ui.css", - data: _bundleCss( baseCss, theme ) + data: _bundleCss( structureCss, theme ) }); }; build.bundleCssMin = function( theme ) { return Files({ path: "jquery-ui.min.css", - data: _bundleCss( baseCssMin, theme, { minify: true } ) + data: _bundleCss( structureCssMin, theme, { minify: true } ) }); }; - // Demo files - selectedDemoRe = new RegExp( components.join( "|" ) ); - build.demoFiles = files.demoFiles.filter(function( file ) { - var componentSubdir = file.path.split( "/" )[ 1 ]; - return selectedDemos( componentSubdir ); - }); - build.demoFiles.push({ - path: "demos/index.html", - data: demoIndexTemplate({ - demos: files.demoSubdirs.filter( selectedDemos ) - }) - }); - - // Doc files - if ( files.docFiles.length && files.docsCategories ) { - build.docFiles = jqueryUi.components().filter( selected ).map(function( component ) { - return component.docs; - }).map(function( doc ) { - var slug; - // Expand categories's pages and posts - if ( (/\/category\//).test( doc ) ) { - slug = path.basename( doc ); - return files.docsCategories[ slug ].posts; - } - return doc; - }).reduce( flatten, [] ).reduce(function( sum, doc ) { - var filename = path.basename( doc ) + ".html", - file = files.get( path.join( "docs", filename ) ); - if ( file ) { - sum.push({ - path: file.path, - data: docsTemplate({ - component: path.basename( file.path ).replace( /\..*/, "" ), - body: file.data - }) - }); - } - return sum; - }, Files() ); - } - // Test files build.testFiles = files.testFiles; diff --git a/lib/packer-1-10.js b/lib/packer-1-10.js new file mode 100644 index 00000000..c115940e --- /dev/null +++ b/lib/packer-1-10.js @@ -0,0 +1,239 @@ +var indexTemplate, pack, themeImagesCache, + async = require( "async" ), + banner = require( "./banner" ), + Files = require( "./files" ), + fs = require( "fs" ), + handlebars = require( "handlebars" ), + path = require( "path" ), + semver = require( "semver" ), + sqwish = require( "sqwish" ), + util = require( "./util" ); + +indexTemplate = handlebars.compile( fs.readFileSync( __dirname + "/../template/zip/index-1-10.html", "utf8" ) ); + +function stripThemeImport( src ) { + if ( src instanceof Buffer ) { + src = src.toString( "utf8" ); + } + return src.replace( /@import "jquery\.ui\.theme\.css";\n/, "" ); +} + +/** + * Generates a build array [ , ... ], where + * build-item = { + * path: String:package destination filepath, + * data: String/Buffer:the content itself + * } + */ +pack = function( callback ) { + var build, + add = function( file ) { + if ( arguments.length === 2 ) { + file = { + path: arguments[ 0 ], + data: arguments[ 1 ] + }; + } + output.push({ + path: path.join( basedir, file.path ), + data: file.data + }); + }, + basedir = this.basedir, + builder = this.builder, + options = this.options, + output = [], + theme = this.theme, + themeImagesCache = this.themeImagesCache; + + function _build( callback ) { + builder.build(function( error, _build ) { + if ( error ) { + return callback( error ); + } + build = _build; + callback(); + }); + } + + function pack( callback ) { + // Common and component files (includes baseThemeFiles) + build.commonFiles.into( "development-bundle/" ).forEach( add ); + build.componentFiles.into( "development-bundle/" ).forEach( add ); + + build.componentMinFiles + .rename( /^ui/, "ui/minified" ) + .into( "development-bundle/" ).forEach( add ); + + // Base theme (baseThemeFiles have been included by componentFiles) + build.baseThemeMinFiles + .rename( /^themes\/base/, "themes/base/minified" ) + .into( "development-bundle/" ).forEach( add ); + + build.baseThemeImages + .rename( /^themes\/base\/images/, "themes/base/minified/images" ) + .into( "development-bundle/" ).forEach( add ); + + // I18n + build.i18nFiles.into( "development-bundle/" ).forEach( add ); + build.i18nMinFiles + .rename( /^ui\/i18n/, "ui/minified/i18n" ) + .into( "development-bundle/" ).forEach( add ); + build.bundleI18n.into( "development-bundle/ui/i18n/" ).forEach( add ); + build.bundleI18nMin.into( "development-bundle/ui/minified/i18n/" ).forEach( add ); + + // Bundle JS (and minified) + build.bundleJs + .rename( /^jquery-ui/, "jquery-ui" + options.bundleSuffix ) + .into( "development-bundle/ui/" ).forEach( add ); + + build.bundleJs + .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) + .into( "js/" ).forEach( add ); + + build.bundleJsMin + .rename( /^jquery-ui/, "jquery-ui" + options.bundleSuffix ) + .into( "development-bundle/ui/minified/" ).forEach( add ); + + build.bundleJsMin + .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) + .into( "js/" ).forEach( add ); + + // Bundle CSS (and minified) + build.bundleCss( build.baseTheme ).into( "development-bundle/themes/base/" ).forEach( add ); + build.bundleCssMin( build.baseThemeMin ).into( "development-bundle/themes/base/minified/" ).forEach( add ); + if ( !options.skipTheme ) { + build.bundleCss( theme ) + .tee(function( clone ) { + clone.into( "development-bundle/themes/" + theme.folderName() + "/" ).forEach( add ); + }) + .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) + .into( "css/" + theme.folderName() + "/" ).forEach( add ); + + build.bundleCssMin( theme ) + .tee(function( clone ) { + clone.into( "development-bundle/themes/" + theme.folderName() + "/minified/" ).forEach( add ); + }) + .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) + .into( "css/" + theme.folderName() + "/" ).forEach( add ); + } + + // Demo files + build.demoFiles.into( "development-bundle/" ).forEach( add ); + + // Doc files + if ( !options.skipDocs ) { + if ( !build.docFiles ) { + throw new Error( "Missing docFiles" ); + } + build.docFiles.into( "development-bundle/" ).forEach( add ); + } + + // Test files + if ( options.addTests ) { + build.testFiles.into( "development-bundle/" ).forEach( add ); + } + + // Ad hoc + build.jqueryCore.into( "js/" ).forEach( add ); + add( "index.html", indexTemplate({ + bundleCss: "jquery-ui-" + build.pkg.version + options.bundleSuffix + ".css", + bundleJs: "jquery-ui-" + build.pkg.version + options.bundleSuffix + ".js", + jqueryCore: build.jqueryCore[ 0 ].path, + ui: build.components.reduce(function( sum, component ) { + sum[ component ] = true; + return sum; + }, {}), + themeFolderName: theme.folderName(), + version: build.pkg.version + })); + + // Custom theme files + if ( !options.skipTheme ) { + build.baseThemeExceptThemeOrImages.forEach(function( file ) { + if ( theme.isNull && (/all.css/).test( file.path ) ) { + add( "development-bundle/themes/" + theme.folderName() + "/" + path.basename( file.path ), stripThemeImport( file.data ) ); + } else { + add( file.path.replace( "themes/base", "development-bundle/themes/" + theme.folderName() ), options.scope ? util.scope( file.data.toString( "utf8" ), options.scope ) : file.data ); + } + }); + // minified custom theme + build.baseThemeMinFiles.filter(function( file ) { + return !(/theme\W/).test( file.path ); + }).map(function( file ) { + return options.scope ? { path: file.path, data: util.scope( file.data, options.scope ) } : file; + }).rename( /^themes\/base/, "themes/" + theme.folderName() + "/minified" ).into( "development-bundle/" ).forEach( add ); + } + if ( !theme.isNull ) { + add( "development-bundle/themes/" + theme.folderName() + "/jquery.ui.theme.css", theme.css() ); + add( "development-bundle/themes/" + theme.folderName() + "/minified/jquery.ui.theme.min.css", banner( build.pkg, null, { minify: true } ) + sqwish.minify( util.stripBanner({ data: theme.css() }) ) ); + } + + // Custom theme image files + if ( theme.isNull ) { + callback( null, output ); + } + else { + async.series([ + function( callback ) { + var themeImages = Files(); + if ( semver.gte( build.pkg.version, "1.10.0" ) ) { + themeImages.push({ + path: "animated-overlay.gif", + data: build.get( "themes/base/images/animated-overlay.gif" ).data + }); + } + if ( themeImagesCache[ theme.name ] ) { + // Cached + callback( null, themeImages.concat( themeImagesCache[ theme.name ] ) ); + } else { + // Not cached, fetch them + theme.generateImages(function( err, imageFiles ) { + if ( err ) { + callback( err, null ); + return; + } + callback( null, themeImages.concat( imageFiles ) ); + }); + } + } + ], function( err, themeImages ) { + if ( err ) { + callback( err, null ); + } + themeImages[ 0 ].into( [ "css/" + theme.folderName() + "/images/", "development-bundle/themes/" + theme.folderName() + "/images/", "development-bundle/themes/" + theme.folderName() + "/minified/images/" ] ).forEach( add ); + callback( null, output ); + }); + } + } + + async.series([ + _build, + pack + ], function( error ) { + callback( error, output ); + }); +}; + + +/** + * Packer( builder, theme, options ) + * - builder [ instanceof Builder ]: jQuery UI builder object. + * - theme [ instanceof ThemeRoller ]: theme object. + * - options: details below. + * + * options: + * - addTests [ Boolean ]: Include test files on package. Default is false. + * - bundleSuffix [ String ]: Change bundle filename suffix. Default is ".custom". + * - scope [ String ]: Insert a scope string on the css selectors. + * - skipDocs [ Boolean ]: Skip doc files on package. Default is false. + * - skipTheme [ Boolean ]: Skip theme files on package. Default is false. + */ +function Packer_1_10( builder, theme, options ) { + if ( options.skipTheme ) { + this.theme = new ( require( "./themeroller" ) )({ vars: null }); + } + this.pack = pack; +} + +module.exports = Packer_1_10; diff --git a/lib/packer-1-11.js b/lib/packer-1-11.js new file mode 100644 index 00000000..cfcd32fa --- /dev/null +++ b/lib/packer-1-11.js @@ -0,0 +1,137 @@ +var pack, indexTemplate, stripBanner, + async = require( "async" ), + banner = require( "./banner" ), + Files = require( "./files" ), + fs = require( "fs" ), + handlebars = require( "handlebars" ), + path = require( "path" ), + sqwish = require( "sqwish" ), + util = require( "./util" ); + +indexTemplate = handlebars.compile( fs.readFileSync( __dirname + "/../template/zip/index-1-11.html", "utf8" ) ); + +stripBanner = util.stripBanner; + +/** + * Generates a build array [ , ... ], where + * build-item = { + * path: String:package destination filepath, + * data: String/Buffer:the content itself + * } + */ +pack = function( callback ) { + var build, + add = function( file ) { + if ( arguments.length === 2 ) { + file = { + path: arguments[ 0 ], + data: arguments[ 1 ] + }; + } + output.push({ + path: path.join( basedir, file.path ), + data: file.data + }); + }, + basedir = this.basedir, + builder = this.builder, + options = this.options, + output = [], + theme = this.theme, + themeImagesCache = this.themeImagesCache; + + function _build( callback ) { + builder.build(function( error, _build ) { + if ( error ) { + return callback( error ); + } + build = _build; + callback(); + }); + } + + function pack( callback ) { + // Bundle JS + build.bundleJs.forEach( add ); + build.bundleJsMin.forEach( add ); + + // Theme files + if ( !options.skipTheme ) { + add( "jquery-ui.structure.css", build.structureCss ); + add( "jquery-ui.structure.min.css", build.structureCssMin ); + + if ( !theme.isNull ) { + add( "jquery-ui.theme.css", theme.css() ); + add( "jquery-ui.theme.min.css", banner( build.pkg, null, { minify: true } ) + sqwish.minify( util.stripBanner({ data: theme.css() }) ) ); + } + + // Bundle CSS + build.bundleCss( theme ).forEach( add ); + build.bundleCssMin( theme ).forEach( add ); + } + + // Ad hoc + build.jqueryCore.forEach( add ); + add( "index.html", indexTemplate({ + ui: build.components.reduce(function( sum, component ) { + sum[ component ] = true; + return sum; + }, {}), + version: build.pkg.version + })); + + // Theme image files + if ( theme.isNull ) { + callback( null, output ); + } + else { + async.series([ + function( callback ) { + var themeImages = Files(); + themeImages.push({ + path: "animated-overlay.gif", + data: build.get( "themes/base/images/animated-overlay.gif" ).data + }); + if ( themeImagesCache[ theme.name ] ) { + // Cached + callback( null, themeImages.concat( themeImagesCache[ theme.name ] ) ); + } else { + // Not cached, fetch them + theme.generateImages(function( err, imageFiles ) { + if ( err ) { + callback( err, null ); + return; + } + callback( null, themeImages.concat( imageFiles ) ); + }); + } + } + ], function( err, themeImages ) { + if ( err ) { + callback( err, null ); + } + themeImages[ 0 ].into( "images/" ).forEach( add ); + callback( null, output ); + }); + } + } + + async.series([ + _build, + pack + ], function( error ) { + callback( error, output ); + }); +}; + + +/** + * Packer( builder, theme, options ) + * - builder [ instanceof Builder ]: jQuery UI builder object. + * - theme [ instanceof ThemeRoller ]: theme object. + */ +function Packer_1_10( builder, theme ) { + this.pack = pack; +} + +module.exports = Packer_1_10; diff --git a/lib/packer.js b/lib/packer.js index dd36bd52..3fe9fc61 100644 --- a/lib/packer.js +++ b/lib/packer.js @@ -1,26 +1,11 @@ -var indexTemplate, themeImagesCache, +var themeImagesCache, async = require( "async" ), - banner = require( "./banner" ), - Files = require( "./files" ), - fs = require( "fs" ), - handlebars = require( "handlebars" ), - JqueryUi = require( "./jquery-ui" ), logger = require( "simple-log" ).init( "download.jqueryui.com" ), - path = require( "path" ), semver = require( "semver" ), - sqwish = require( "sqwish" ), - util = require( "./util" ); + util = require( "util" ); -indexTemplate = handlebars.compile( fs.readFileSync( __dirname + "/../template/zip/index.html", "utf8" ) ); themeImagesCache = {}; -function stripThemeImport( src ) { - if ( src instanceof Buffer ) { - src = src.toString( "utf8" ); - } - return src.replace( /@import "jquery\.ui\.theme\.css";\n/, "" ); -} - /** * Packer( builder, theme, options ) @@ -29,24 +14,25 @@ function stripThemeImport( src ) { * - options: details below. * * options: - * - addTests [ Boolean ]: Include test files on package. Default is false. * - bundleSuffix [ String ]: Change bundle filename suffix. Default is ".custom". - * - scope [ String ]: Insert a scope string on the css selectors. - * - skipDocs [ Boolean ]: Skip doc files on package. Default is false. - * - skipTheme [ Boolean ]: Skip theme files on package. Default is false. + * + * Other options may be available, see Packer 1.10 or 1.11. */ function Packer( builder, theme, options ) { this.options = options = options || {}; if ( typeof options.bundleSuffix === "undefined" ) { - options.bundleSuffix = ".custom"; + options.bundleSuffix = ".custom"; } this.basedir = "jquery-ui-" + builder.jqueryUi.pkg.version + options.bundleSuffix; this.builder = builder; this.theme = theme; + this.themeImagesCache = themeImagesCache; - if ( options.skipTheme ) { - this.theme = new ( require( "./themeroller" ) )({ vars: null }); + if ( semver.gte( this.builder.jqueryUi.pkg.version, "1.11.0-a" ) ) { + require( "./packer-1-11" ).call( this, builder, theme, options ); + } else { + require( "./packer-1-10" ).call( this, builder, theme, options ); } } @@ -65,206 +51,9 @@ Packer.cacheThemeGalleryImages = function() { }); }; -Packer.prototype = { - /** - * Generates a build array [ , ... ], where - * build-item = { - * path: String:package destination filepath, - * data: String/Buffer:the content itself - * } - */ - pack: function( callback ) { - var build, - add = function( file ) { - if ( arguments.length === 2 ) { - file = { - path: arguments[ 0 ], - data: arguments[ 1 ] - }; - } - output.push({ - path: path.join( basedir, file.path ), - data: file.data - }); - }, - basedir = this.basedir, - builder = this.builder, - options = this.options, - output = [], - theme = this.theme; - - function _build( callback ) { - builder.build(function( error, _build ) { - if ( error ) { - return callback( error ); - } - build = _build; - callback(); - }); - } - - function pack( callback ) { - // Common and component files (includes baseThemeFiles) - build.commonFiles.into( "development-bundle/" ).forEach( add ); - build.componentFiles.into( "development-bundle/" ).forEach( add ); - - build.componentMinFiles - .rename( /^ui/, "ui/minified" ) - .into( "development-bundle/" ).forEach( add ); - - // Base theme (baseThemeFiles have been included by componentFiles) - build.baseThemeMinFiles - .rename( /^themes\/base/, "themes/base/minified" ) - .into( "development-bundle/" ).forEach( add ); - - build.baseThemeImages - .rename( /^themes\/base\/images/, "themes/base/minified/images" ) - .into( "development-bundle/" ).forEach( add ); - - // I18n - build.i18nFiles.into( "development-bundle/" ).forEach( add ); - build.i18nMinFiles - .rename( /^ui\/i18n/, "ui/minified/i18n" ) - .into( "development-bundle/" ).forEach( add ); - build.bundleI18n.into( "development-bundle/ui/i18n/" ).forEach( add ); - build.bundleI18nMin.into( "development-bundle/ui/minified/i18n/" ).forEach( add ); - - // Bundle JS (and minified) - build.bundleJs - .rename( /^jquery-ui/, "jquery-ui" + options.bundleSuffix ) - .into( "development-bundle/ui/" ).forEach( add ); - - build.bundleJs - .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) - .into( "js/" ).forEach( add ); - - build.bundleJsMin - .rename( /^jquery-ui/, "jquery-ui" + options.bundleSuffix ) - .into( "development-bundle/ui/minified/" ).forEach( add ); - - build.bundleJsMin - .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) - .into( "js/" ).forEach( add ); - - // Bundle CSS (and minified) - build.bundleCss( build.baseTheme ).into( "development-bundle/themes/base/" ).forEach( add ); - build.bundleCssMin( build.baseThemeMin ).into( "development-bundle/themes/base/minified/" ).forEach( add ); - if ( !options.skipTheme ) { - build.bundleCss( theme ) - .tee(function( clone ) { - clone.into( "development-bundle/themes/" + theme.folderName() + "/" ).forEach( add ); - }) - .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) - .into( "css/" + theme.folderName() + "/" ).forEach( add ); - - build.bundleCssMin( theme ) - .tee(function( clone ) { - clone.into( "development-bundle/themes/" + theme.folderName() + "/minified/" ).forEach( add ); - }) - .rename( /^jquery-ui/, "jquery-ui-" + build.pkg.version + options.bundleSuffix ) - .into( "css/" + theme.folderName() + "/" ).forEach( add ); - } - - // Demo files - build.demoFiles.into( "development-bundle/" ).forEach( add ); - - // Doc files - if ( !options.skipDocs ) { - if ( !build.docFiles ) { - throw new Error( "Missing docFiles" ); - } - build.docFiles.into( "development-bundle/" ).forEach( add ); - } - - // Test files - if ( options.addTests ) { - build.testFiles.into( "development-bundle/" ).forEach( add ); - } - - // Ad hoc - build.jqueryCore.into( "js/" ).forEach( add ); - add( "index.html", indexTemplate({ - bundleCss: "jquery-ui-" + build.pkg.version + options.bundleSuffix + ".css", - bundleJs: "jquery-ui-" + build.pkg.version + options.bundleSuffix + ".js", - jqueryCore: build.jqueryCore[ 0 ].path, - ui: build.components.reduce(function( sum, component ) { - sum[ component ] = true; - return sum; - }, {}), - themeFolderName: theme.folderName(), - version: build.pkg.version - })); - - // Custom theme files - if ( !options.skipTheme ) { - build.baseThemeExceptThemeOrImages.forEach(function( file ) { - if ( theme.isNull && (/all.css/).test( file.path ) ) { - add( "development-bundle/themes/" + theme.folderName() + "/" + path.basename( file.path ), stripThemeImport( file.data ) ); - } else { - add( file.path.replace( "themes/base", "development-bundle/themes/" + theme.folderName() ), options.scope ? util.scope( file.data.toString( "utf8" ), options.scope ) : file.data ); - } - }); - // minified custom theme - build.baseThemeMinFiles.filter(function( file ) { - return !(/theme\W/).test( file.path ); - }).map(function( file ) { - return options.scope ? { path: file.path, data: util.scope( file.data, options.scope ) } : file; - }).rename( /^themes\/base/, "themes/" + theme.folderName() + "/minified" ).into( "development-bundle/" ).forEach( add ); - } - if ( !theme.isNull ) { - if ( semver.gte( build.pkg.version, "1.11.0-a" ) ) { - add( "development-bundle/themes/" + theme.folderName() + "/theme.css", theme.css() ); - add( "development-bundle/themes/" + theme.folderName() + "/minified/theme.min.css", banner( build.pkg, null, { minify: true } ) + sqwish.minify( util.stripBanner({ data: theme.css() }) ) ); - } else { - add( "development-bundle/themes/" + theme.folderName() + "/jquery.ui.theme.css", theme.css() ); - add( "development-bundle/themes/" + theme.folderName() + "/minified/jquery.ui.theme.min.css", banner( build.pkg, null, { minify: true } ) + sqwish.minify( util.stripBanner({ data: theme.css() }) ) ); - } - } - - // Custom theme image files - if ( theme.isNull ) { - callback( null, output ); - } - else { - async.series([ - function( callback ) { - var themeImages = Files(); - if ( semver.gte( build.pkg.version, "1.10.0" ) ) { - themeImages.push({ - path: "animated-overlay.gif", - data: build.get( "themes/base/images/animated-overlay.gif" ).data - }); - } - if ( themeImagesCache[ theme.name ] ) { - // Cached - callback( null, themeImages.concat( themeImagesCache[ theme.name ] ) ); - } else { - // Not cached, fetch them - theme.generateImages(function( err, imageFiles ) { - if ( err ) { - callback( err, null ); - return; - } - callback( null, themeImages.concat( imageFiles ) ); - }); - } - } - ], function( err, themeImages ) { - if ( err ) { - callback( err, null ); - } - themeImages[ 0 ].into( [ "css/" + theme.folderName() + "/images/", "development-bundle/themes/" + theme.folderName() + "/images/", "development-bundle/themes/" + theme.folderName() + "/minified/images/" ] ).forEach( add ); - callback( null, output ); - }); - } - } - - async.series([ - _build, - pack - ], function( error ) { - callback( error, output ); - }); +util._extend( Packer.prototype, { + pack: function() { + throw new Error( "implement me" ); }, filename: function() { @@ -276,9 +65,9 @@ Packer.prototype = { if ( err ) { return callback( err, null ); } - util.createZip( files, target, callback ); + require( "./util" ).createZip( files, target, callback ); }); } -}; +}); module.exports = Packer; diff --git a/template/download/index.html b/template/download/index.html index 9668cc88..0a40fa4c 100644 --- a/template/download/index.html +++ b/template/download/index.html @@ -16,7 +16,7 @@

Version

{{#each jqueryUis}}
diff --git a/template/download/theme.html b/template/download/theme.html index 2873e358..576d1d43 100644 --- a/template/download/theme.html +++ b/template/download/theme.html @@ -8,9 +8,11 @@
- - -

This field allows you to specify a name for the theme folder in your download. This is helpful if you plan to use multiple themes on a page. It defaults to "theme".

+
+ + +

This field allows you to specify a name for the theme folder in your download. This is helpful if you plan to use multiple themes on a page. It defaults to "theme".

+
diff --git a/template/zip/index.html b/template/zip/index-1-10.html similarity index 100% rename from template/zip/index.html rename to template/zip/index-1-10.html diff --git a/template/zip/index-1-11.html b/template/zip/index-1-11.html new file mode 100644 index 00000000..a334ce8a --- /dev/null +++ b/template/zip/index-1-11.html @@ -0,0 +1,467 @@ + + + + + jQuery UI Example Page + + + + + +

Welcome to jQuery UI!

+ +
+

This page demonstrates the widgets you downloaded using the theme you selected in the download builder. We've included and linked to a version of jQuery (jquery.js), your personalized jQuery UI (jquery-ui.js), and the entire jQuery UI CSS Framework (jquery-ui.css).

+

You've downloaded components and a theme that are compatible with jQuery 1.6+. Please make sure you are using jQuery 1.6+ in your production environment.

+
+ +

YOUR COMPONENTS:

+ +{{#if ui.accordion}} + +

Accordion

+
+

First

+
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
+

Second

+
Phasellus mattis tincidunt nibh.
+

Third

+
Nam dui erat, auctor a, dignissim quis.
+
+{{/if}} + +{{#if ui.autocomplete}} + +

Autocomplete

+
+ +
+{{/if}} + +{{#if ui.button}} + +

Button

+ +
+
+ + + +
+
+{{/if}} + +{{#if ui.tabs}} + +

Tabs

+
+ +
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
+
Phasellus mattis tincidunt nibh. Cras orci urna, blandit id, pretium vel, aliquet ornare, felis. Maecenas scelerisque sem non nisl. Fusce sed lorem in enim dictum bibendum.
+
Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.
+
+{{/if}} + +{{#if ui.dialog}} + +

Dialog

+

Open Dialog

+ +

Overlay and Shadow Classes (not currently used in UI widgets)

+
+

Lorem ipsum dolor sit amet, Nulla nec tortor. Donec id elit quis purus consectetur consequat.

Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci.

Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat.

Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante. Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam.

Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi. Aliquam ante.

Suspendisse scelerisque dui nec velit. Duis augue augue, gravida euismod, vulputate ac, facilisis id, sem. Morbi in orci. Nulla purus lacus, pulvinar vel, malesuada ac, mattis nec, quam. Nam molestie scelerisque quam. Nullam feugiat cursus lacus.orem ipsum dolor sit amet, consectetur adipiscing elit. Donec libero risus, commodo vitae, pharetra mollis, posuere eu, pede. Nulla nec tortor. Donec id elit quis purus consectetur consequat. Nam congue semper tellus. Sed erat dolor, dapibus sit amet, venenatis ornare, ultrices ut, nisi.

+ + +
+
+
+

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

+
+
+ +
+ + +
+

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

+
+{{/if}} + + +

Framework Icons (content color preview)

+
    +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
  • +
+ +{{#if ui.slider}} + +

Slider

+
+{{/if}} + +{{#if ui.datepicker}} + +

Datepicker

+
+{{/if}} + +{{#if ui.progressbar}} + +

Progressbar

+
+{{/if}} + +{{#if ui.selectmenu}} + +

Selectmenu

+ +{{/if}} + + +

Highlight / Error

+
+
+

+ Hey! Sample ui-state-highlight style.

+
+
+
+
+
+

+ Alert: Sample ui-state-error style.

+
+
+ + + + + + diff --git a/test/packer.js b/test/packer.js index d3794f0f..d42c874c 100644 --- a/test/packer.js +++ b/test/packer.js @@ -44,346 +44,45 @@ function replace( variable, value ) { }; } -function stripBanner( src ) { - if ( src instanceof Buffer ) { - src = src.toString( "utf-8" ); - } - return src.replace( /^\s*\/\*[\s\S]*?\*\/\s*/g, "" ); -} - var commonFiles = [ - "index.html", - "development-bundle/AUTHORS.txt", - "development-bundle/Gruntfile.js", - "development-bundle/MIT-LICENSE.txt", - "development-bundle/package.json", - "development-bundle/README.md", - /development-bundle\/jquery.js/, - "development-bundle/package.json", - "development-bundle/demos/demos.css", - "development-bundle/demos/images/demo-spindown-open.gif", - "development-bundle/demos/images/pbar-ani.gif", - "development-bundle/demos/images/demo-config-on-tile.gif", - "development-bundle/demos/images/icon-docs-info.gif", - "development-bundle/demos/images/demo-spindown-closed.gif", - "development-bundle/demos/images/demo-config-on.gif", - "development-bundle/demos/images/calendar.gif", - "development-bundle/external/globalize.culture.de-DE.js", - "development-bundle/external/globalize.culture.ja-JP.js", - "development-bundle/external/globalize.js", - "development-bundle/external/jquery.mousewheel.js", - "development-bundle/external/jshint.js", - "development-bundle/external/qunit.css", - "development-bundle/themes/base/all.css", - "development-bundle/themes/base/base.css", - "development-bundle/themes/base/theme.css", - "development-bundle/themes/base/jquery-ui.css", - "development-bundle/themes/base/images/animated-overlay.gif", - "development-bundle/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png", - "development-bundle/themes/base/images/ui-bg_flat_75_ffffff_40x100.png", - "development-bundle/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png", - "development-bundle/themes/base/images/ui-bg_glass_65_ffffff_1x400.png", - "development-bundle/themes/base/images/ui-bg_glass_75_dadada_1x400.png", - "development-bundle/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png", - "development-bundle/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png", - "development-bundle/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png", - "development-bundle/themes/base/images/ui-icons_2e83ff_256x240.png", - "development-bundle/themes/base/images/ui-icons_222222_256x240.png", - "development-bundle/themes/base/images/ui-icons_454545_256x240.png", - "development-bundle/themes/base/images/ui-icons_888888_256x240.png", - "development-bundle/themes/base/images/ui-icons_cd0a0a_256x240.png", - "development-bundle/themes/base/minified/theme.min.css", - "development-bundle/themes/base/minified/jquery-ui.min.css", - "development-bundle/themes/base/minified/images/animated-overlay.gif", - "development-bundle/themes/base/minified/images/ui-bg_flat_0_aaaaaa_40x100.png", - "development-bundle/themes/base/minified/images/ui-bg_flat_75_ffffff_40x100.png", - "development-bundle/themes/base/minified/images/ui-bg_glass_55_fbf9ee_1x400.png", - "development-bundle/themes/base/minified/images/ui-bg_glass_65_ffffff_1x400.png", - "development-bundle/themes/base/minified/images/ui-bg_glass_75_dadada_1x400.png", - "development-bundle/themes/base/minified/images/ui-bg_glass_75_e6e6e6_1x400.png", - "development-bundle/themes/base/minified/images/ui-bg_glass_95_fef1ec_1x400.png", - "development-bundle/themes/base/minified/images/ui-bg_highlight-soft_75_cccccc_1x100.png", - "development-bundle/themes/base/minified/images/ui-icons_2e83ff_256x240.png", - "development-bundle/themes/base/minified/images/ui-icons_222222_256x240.png", - "development-bundle/themes/base/minified/images/ui-icons_454545_256x240.png", - "development-bundle/themes/base/minified/images/ui-icons_888888_256x240.png", - "development-bundle/themes/base/minified/images/ui-icons_cd0a0a_256x240.png", - "development-bundle/ui/jquery-ui.custom.js", - "development-bundle/ui/minified/jquery-ui.custom.min.js", - /js\/jquery.js/, - /js\/jquery-ui-[^\.]*\.[^\.]*\.[^\.]*.*?\.custom\.js/, - /js\/jquery-ui-[^\.]*\.[^\.]*\.[^\.]*.*?\.custom\.min\.js/ -]; -var skipFiles = [ - "development-bundle/MANIFEST", - "development-bundle/demos/addClass/*", - "development-bundle/demos/animate/*", - "development-bundle/demos/hide/*", - "development-bundle/demos/removeClass/*", - "development-bundle/demos/show/*", - "development-bundle/demos/switchClass/*", - "development-bundle/demos/toggle/*", - "development-bundle/demos/toggleClass/*" + "jquery.js", + "jquery-ui.js", + "jquery-ui.min.js" ]; -var COMMON_FILES_TESTCASES = commonFiles.length + skipFiles.length; +var COMMON_FILES_TESTCASES = commonFiles.length; function commonFilesCheck( test, files ) { commonFiles.forEach(function( filepath ) { test.ok( filePresent( files, filepath ), "Missing a common file \"" + filepath + "\"." ); }); - skipFiles.forEach(function( filepath ) { - test.ok( !filePresent( files, filepath ), "Should not include \"" + filepath + "\"." ); - }); -} - - -var componentFiles = { - "all": [ - "development-bundle/ui.{component}.jquery.json", - "development-bundle/ui/{component}.js", - "development-bundle/ui/minified/{component}.min.js" - ], - "widget": [ - "development-bundle/demos/widget/*", - "development-bundle/docs/jQuery.widget.html" - ], - "core": [ - "development-bundle/docs/data-selector.html", - "development-bundle/docs/disableSelection.html", - "development-bundle/docs/enableSelection.html", - "development-bundle/docs/focus.html", - "development-bundle/docs/focusable-selector.html", - "development-bundle/docs/jQuery.ui.keyCode.html", - "development-bundle/docs/removeUniqueId.html", - "development-bundle/docs/scrollParent.html", - "development-bundle/docs/tabbable-selector.html", - "development-bundle/docs/uniqueId.html", - "development-bundle/docs/zIndex.html" - ], - "mouse": [], - "position": [ - "development-bundle/demos/position/*", - "development-bundle/docs/position.html" - ], - "draggable": [ - "development-bundle/demos/draggable/*", - "development-bundle/docs/draggable.html" - ], - "droppable": [ - "development-bundle/demos/droppable/*", - "development-bundle/docs/droppable.html" - ], - "resizable": [ - "development-bundle/demos/resizable/*", - "development-bundle/docs/resizable.html", - "development-bundle/themes/base/resizable.css", - "development-bundle/themes/base/minified/resizable.min.css" - ], - "selectable": [ - "development-bundle/demos/selectable/*", - "development-bundle/docs/selectable.html", - "development-bundle/themes/base/selectable.css", - "development-bundle/themes/base/minified/selectable.min.css" - ], - "sortable": [ - "development-bundle/demos/sortable/*", - "development-bundle/docs/sortable.html" - ], - "accordion": [ - "development-bundle/demos/accordion/*", - "development-bundle/docs/accordion.html", - "development-bundle/themes/base/accordion.css", - "development-bundle/themes/base/minified/accordion.min.css" - ], - "autocomplete": [ - "development-bundle/demos/autocomplete/*", - "development-bundle/docs/autocomplete.html", - "development-bundle/themes/base/autocomplete.css", - "development-bundle/themes/base/minified/autocomplete.min.css" - ], - "button": [ - "development-bundle/demos/button/*", - "development-bundle/docs/button.html", - "development-bundle/themes/base/button.css", - "development-bundle/themes/base/minified/button.min.css" - ], - "datepicker": [ - "development-bundle/demos/datepicker/*", - "development-bundle/docs/datepicker.html", - "development-bundle/themes/base/datepicker.css", - "development-bundle/themes/base/minified/datepicker.min.css", - "development-bundle/ui/i18n/*", - "development-bundle/ui/i18n/datepicker-*.js", - "development-bundle/ui/i18n/jquery-ui-i18n.js" - ], - "dialog": [ - "development-bundle/demos/dialog/*", - "development-bundle/docs/dialog.html", - "development-bundle/themes/base/dialog.css", - "development-bundle/themes/base/minified/dialog.min.css" - ], - "menu": [ - "development-bundle/demos/menu/*", - "development-bundle/docs/menu.html", - "development-bundle/themes/base/menu.css", - "development-bundle/themes/base/minified/menu.min.css" - ], - "progressbar": [ - "development-bundle/demos/progressbar/*", - "development-bundle/docs/progressbar.html", - "development-bundle/themes/base/progressbar.css", - "development-bundle/themes/base/minified/progressbar.min.css" - ], - "slider": [ - "development-bundle/demos/slider/*", - "development-bundle/docs/slider.html", - "development-bundle/themes/base/slider.css", - "development-bundle/themes/base/minified/slider.min.css" - ], - "spinner": [ - "development-bundle/demos/spinner/*", - "development-bundle/docs/spinner.html", - "development-bundle/themes/base/spinner.css", - "development-bundle/themes/base/minified/spinner.min.css" - ], - "tabs": [ - "development-bundle/demos/tabs/*", - "development-bundle/docs/tabs.html", - "development-bundle/themes/base/tabs.css", - "development-bundle/themes/base/minified/tabs.min.css" - ], - "tooltip": [ - "development-bundle/demos/tooltip/*", - "development-bundle/docs/tooltip.html", - "development-bundle/themes/base/tooltip.css", - "development-bundle/themes/base/minified/tooltip.min.css" - ], - "effect": [ - "development-bundle/demos/effect/*", - "development-bundle/docs/addClass.html", - "development-bundle/docs/color-animation.html", - "development-bundle/docs/effect.html", - "development-bundle/docs/hide.html", - "development-bundle/docs/removeClass.html", - "development-bundle/docs/show.html", - "development-bundle/docs/switchClass.html", - "development-bundle/docs/toggle.html", - "development-bundle/docs/toggleClass.html" - ], - "effect-blind": [ - "development-bundle/docs/blind-effect.html" - ], - "effect-bounce": [ - "development-bundle/docs/bounce-effect.html" - ], - "effect-clip": [ - "development-bundle/docs/clip-effect.html" - ], - "effect-drop": [ - "development-bundle/docs/drop-effect.html" - ], - "effect-explode": [ - "development-bundle/docs/explode-effect.html" - ], - "effect-fade": [ - "development-bundle/docs/fade-effect.html" - ], - "effect-fold": [ - "development-bundle/docs/fold-effect.html" - ], - "effect-highlight": [ - "development-bundle/docs/highlight-effect.html" - ], - "effect-puff": [ - "development-bundle/docs/puff-effect.html" - ], - "effect-pulsate": [ - "development-bundle/docs/pulsate-effect.html" - ], - "effect-scale": [ - "development-bundle/docs/scale-effect.html" - ], - "effect-size": [ - "development-bundle/docs/size-effect.html" - ], - "effect-shake": [ - "development-bundle/docs/shake-effect.html" - ], - "effect-slide": [ - "development-bundle/docs/slide-effect.html" - ], - "effect-transfer": [ - "development-bundle/docs/transfer-effect.html" - ] -}; -var COMPONENT_FILES_TESTCASES = Object.keys( componentFiles ).reduce(function( sum, component ) { - return sum + componentFiles.all.length + componentFiles[ component ].length; -}, 0 ); -function componentFilesCheck( test, files, components ) { - Object.keys( componentFiles ).forEach(function( component ) { - if ( components.indexOf( component ) >= 0 ) { - componentFiles.all.map( replace( "component", component ) ).concat( componentFiles[ component ] ).forEach(function( filepath ) { - test.ok( filePresent( files, filepath ), "Missing a \"" + component + "\" file \"" + filepath + "\"." ); - }); - } else { - componentFiles.all.map( replace( "component", component ) ).concat( componentFiles[ component ] ).forEach(function( filepath ) { - test.ok( !filePresent( files, filepath ), "Should not include a \"" + component + "\" file \"" + filepath + "\"." ); - }); - } - }); } var themeFiles = { "all": [ - /css\/\{folder_name\}\/jquery-ui-[^\.]*\.[^\.]*\.[^\.]*.*?\.custom\.css/, - /css\/\{folder_name\}\/jquery-ui-[^\.]*\.[^\.]*\.[^\.]*.*?\.custom\.min\.css/, - "development-bundle/themes/{folder_name}/all.css", - "development-bundle/themes/{folder_name}/base.css", - "development-bundle/themes/{folder_name}/{component}.css", - "development-bundle/themes/{folder_name}/jquery-ui.css", - "development-bundle/themes/{folder_name}/minified/{component}.min.css", - "development-bundle/themes/{folder_name}/minified/jquery-ui.min.css" + "jquery-ui.css", + "jquery-ui.min.css", + "jquery-ui.structure.css", + "jquery-ui.structure.min.css" ], "anyTheme": [ - "css/{folder_name}/images/animated-overlay.gif", - "css/{folder_name}/images/ui-icons*png", - "css/{folder_name}/images/ui-bg*png", - "development-bundle/themes/{folder_name}/theme.css", - "development-bundle/themes/{folder_name}/images/animated-overlay.gif", - "development-bundle/themes/{folder_name}/images/ui-icons*png", - "development-bundle/themes/{folder_name}/images/ui-bg*png", - "development-bundle/themes/{folder_name}/minified/theme.min.css", - "development-bundle/themes/{folder_name}/minified/images/animated-overlay.gif", - "development-bundle/themes/{folder_name}/minified/images/ui-icons*png", - "development-bundle/themes/{folder_name}/minified/images/ui-bg*png" + "jquery-ui.theme.css", + "jquery-ui.theme.min.css", + "images/animated-overlay.gif", + "images/ui-icons*png", + "images/ui-bg*png" ] }; -var themeComponents = "accordion autocomplete button core datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip".split( " " ), - themeComponentsRe = new RegExp( themeComponents.join( "|" ) ); -function themeComponentOnly( component ) { - return themeComponentsRe.test( component ); -} -var THEME_FILES_TESTCASES = function( components ) { +var themeComponents = "accordion autocomplete button core datepicker dialog menu progressbar resizable selectable slider spinner tabs tooltip".split( " " ); +var THEME_FILES_TESTCASES = function() { return Object.keys( themeFiles ).reduce(function( sum, group ) { - return sum + themeFiles[ group ].reduce(function( sum, themeFile ) { - return sum + ( (/\{component\}/).test( themeFile.toString() ) ? components.filter( themeComponentOnly ).length : 1 ); - }, 0); + return sum + themeFiles[ group ].length; }, 0 ); }; function themeFilesCheck( test, files, components, theme ) { - var expandComponents = function( themeFile ) { - // For every themeFile that has a {component} variable, replicate themeFile for each component (expanding each component). - if ( (/\{component\}/).test( themeFile.toString() ) ) { - return components.filter( themeComponentOnly ).map(function( component ) { - return replace( "component", component )( themeFile ); - }); - } - return themeFile; - }; - themeFiles.all.map( replace( "folder_name", theme.folderName() ) ).map( expandComponents ).reduce( flatten, [] ).forEach(function( filepath ) { + themeFiles.all.reduce( flatten, [] ).forEach(function( filepath ) { test.ok( filePresent( files, filepath ), "Missing a theme file \"" + filepath + "\"." ); }); - themeFiles.anyTheme.map( replace( "folder_name", theme.folderName() ) ).map( expandComponents ).reduce( flatten, [] ).forEach(function( filepath ) { + themeFiles.anyTheme.reduce( flatten, [] ).forEach(function( filepath ) { if ( theme.isNull ) { test.ok( !filePresent( files, filepath ), "Should not include the theme file \"" + filepath + "\"." ); } else { @@ -398,14 +97,13 @@ var tests = { "with a theme": function( test ) { var components = this.allComponents, theme = this.theme; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES + THEME_FILES_TESTCASES( components ) ); + test.expect( COMMON_FILES_TESTCASES + THEME_FILES_TESTCASES() ); pack( this.jqueryUi, components, theme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); themeFilesCheck( test, files, components, theme ); test.done(); } @@ -414,14 +112,13 @@ var tests = { "with a named theme": function( test ) { var components = this.allComponents, namedTheme = this.namedTheme; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES + THEME_FILES_TESTCASES( components ) ); + test.expect( COMMON_FILES_TESTCASES + THEME_FILES_TESTCASES() ); pack( this.jqueryUi, components, namedTheme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); themeFilesCheck( test, files, components, namedTheme ); test.done(); } @@ -430,14 +127,13 @@ var tests = { "no theme": function( test ) { var components = this.allComponents, noTheme = this.noTheme; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES + THEME_FILES_TESTCASES( components ) ); + test.expect( COMMON_FILES_TESTCASES + THEME_FILES_TESTCASES() ); pack( this.jqueryUi, components, noTheme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); themeFilesCheck( test, files, components, noTheme ); test.done(); } @@ -446,28 +142,26 @@ var tests = { }, "test: select all widgets": function( test ) { var components = this.allWidgets; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES ); + test.expect( COMMON_FILES_TESTCASES ); pack( this.jqueryUi, components, this.theme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); test.done(); } }); }, "test: select all effects": function( test ) { var components = this.allEffects; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES ); + test.expect( COMMON_FILES_TESTCASES ); pack( this.jqueryUi, components, this.theme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); test.done(); } }); @@ -476,14 +170,13 @@ var tests = { "with a theme": function( test ) { var components = someWidgets1, theme = this.theme; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES + THEME_FILES_TESTCASES( components ) ); + test.expect( COMMON_FILES_TESTCASES + THEME_FILES_TESTCASES() ); pack( this.jqueryUi, components, theme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); themeFilesCheck( test, files, components, theme ); test.done(); } @@ -492,14 +185,13 @@ var tests = { "with a named theme": function( test ) { var components = someWidgets1, namedTheme = this.namedTheme; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES + THEME_FILES_TESTCASES( components ) ); + test.expect( COMMON_FILES_TESTCASES + THEME_FILES_TESTCASES() ); pack( this.jqueryUi, components, namedTheme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); themeFilesCheck( test, files, components, namedTheme ); test.done(); } @@ -509,14 +201,13 @@ var tests = { function( test ) { var components = someWidgets1, noTheme = this.noTheme; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES + THEME_FILES_TESTCASES( components ) ); + test.expect( COMMON_FILES_TESTCASES + THEME_FILES_TESTCASES() ); pack( this.jqueryUi, components, noTheme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); themeFilesCheck( test, files, components, noTheme ); test.done(); } @@ -525,28 +216,26 @@ var tests = { }, "test: select some widgets (2)": function( test ) { var components = someWidgets2; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES ); + test.expect( COMMON_FILES_TESTCASES ); pack( this.jqueryUi, components, this.theme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); test.done(); } }); }, "test: select no components": function( test ) { var components = noComponents; - test.expect( COMMON_FILES_TESTCASES + COMPONENT_FILES_TESTCASES ); + test.expect( COMMON_FILES_TESTCASES ); pack( this.jqueryUi, components, this.theme, function( err, files ) { if ( err ) { test.ok( false, err.message ); test.done(); } else { commonFilesCheck( test, files ); - componentFilesCheck( test, files, components ); test.done(); } }); @@ -555,8 +244,8 @@ var tests = { var builder, packer, components = [ "core", "widget", "tabs" ], filesToCheck = [ - new RegExp( "development-bundle/themes/smoothness/tabs.css" ), - /css\/smoothness\/jquery-ui-.*\.custom\.min\.css/ + /jquery-ui\.css/, + /jquery-ui\.min\.css/ ], scope = "#wrapper"; test.expect( filesToCheck.length ); @@ -571,7 +260,7 @@ var tests = { return filepath.test( file.path ); }); }).forEach(function( file ) { - test.ok( (new RegExp( "^" + scope )).test( stripBanner( file.data ) ), "Builder should scope any other-than-theme CSS. But, failed to scope \"" + file.path + "\"." ); + test.ok( (new RegExp( scope )).test( file.data ), "Builder should scope any other-than-theme CSS. But, failed to scope \"" + file.path + "\"." ); }); } test.done();