diff --git a/bower.json b/bower.json index 9a5dc7e49..79c3c730b 100644 --- a/bower.json +++ b/bower.json @@ -1,54 +1,54 @@ { - "name": "amazeui", - "version": "1.0.0-beta2", - "description": "The first crossing screen front-end framework in China, for developing mobile first, responsive web projects.", - "keywords": [ - "css", - "js", - "less", - "mobile-first", - "responsive", - "front-end", - "framework", - "web", - "web-components" - ], - "homepage": "http://amazeui.org", - "main": [ - "less/amazeui.less", - "dist/css/amazeui.css", - "dist/css/amazeui.min.css", - "dist/js/amazeui.js", - "dist/js/amazeui.min.js" - ], - "ignore": [ - "/.*", - "composer.json", - "CONTRIBUTING.md", - "docs", - "vendor", - "tools", - "node_modules", - "nodemon.json" - ], - "authors": [ - { - "name": "Minwe", - "email": "minwe@yunshipei.com", - "homepage": "http://csspod.com" - }, - { - "name": "HZP", - "email": "hzp@yunshipei.com" - } - ], - "repository": { - "type": "git", - "url": "git://github.com/allmobilize/amazeui.git" + "name": "amazeui", + "version": "1.0.0-beta2", + "description": "The first crossing screen front-end framework in China, for developing mobile first, responsive web projects.", + "keywords": [ + "css", + "js", + "less", + "mobile-first", + "responsive", + "front-end", + "framework", + "web", + "web-components" + ], + "homepage": "http://amazeui.org", + "main": [ + "less/amazeui.less", + "dist/css/amazeui.css", + "dist/css/amazeui.min.css", + "dist/js/amazeui.js", + "dist/js/amazeui.min.js" + ], + "ignore": [ + "/.*", + "composer.json", + "CONTRIBUTING.md", + "docs", + "vendor", + "tools", + "node_modules", + "nodemon.json" + ], + "authors": [ + { + "name": "Minwe", + "email": "minwe@yunshipei.com", + "homepage": "http://csspod.com" }, - "dependencies": { - "zepto": "latest", - "handlebars": "latest" - }, - "license": "MIT" + { + "name": "HZP", + "email": "hzp@yunshipei.com" + } + ], + "repository": { + "type": "git", + "url": "git://github.com/allmobilize/amazeui.git" + }, + "dependencies": { + "zepto": "latest", + "handlebars": "latest" + }, + "license": "MIT" } diff --git a/composer.json b/composer.json index 06aae678a..947ec309d 100644 --- a/composer.json +++ b/composer.json @@ -1,31 +1,31 @@ { - "name": "allmobilize/amazeui", - "description": "The first crossing screen front-end framework in China, for developing mobile first, responsive web projects.", - "keywords": [ - "css", - "js", - "less", - "mobile-first", - "responsive", - "front-end", - "framework", - "web", - "web-components" - ], - "homepage": "http://amazeui.org", - "authors": [ - { - "name": "Minwe", - "email": "minwe@yunshipei.com", - "homepage": "http://csspod.com" - }, - { - "name": "HZP", - "email": "hzp@yunshipei.com" - } - ], - "support": { - "issues": "https://github.com/allmobilize/amazeui/issues" + "name": "allmobilize/amazeui", + "description": "The first crossing screen front-end framework in China, for developing mobile first, responsive web projects.", + "keywords": [ + "css", + "js", + "less", + "mobile-first", + "responsive", + "front-end", + "framework", + "web", + "web-components" + ], + "homepage": "http://amazeui.org", + "authors": [ + { + "name": "Minwe", + "email": "minwe@yunshipei.com", + "homepage": "http://csspod.com" }, - "license": "MIT" + { + "name": "HZP", + "email": "hzp@yunshipei.com" + } + ], + "support": { + "issues": "https://github.com/allmobilize/amazeui/issues" + }, + "license": "MIT" } \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 955a99150..23150b69f 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,3 +1,8 @@ +/* jshint -W097*/ +/* jshint node:true */ + +'use strict'; + var path = require('path'); var fs = require('fs-extra'); var _ = require('lodash'); @@ -11,348 +16,397 @@ var pkg = require('./package.json'); var transportDir = '.build/ts/'; var buildTmpDir = '.build/tmp/'; var jsPaths = { - widgets: [ - '*/src/*.js', - '!{powered_by,switch_mode,toolbar,tech_support,layout*,blank,container}/src/*.js'], - hbsHelper: ['vendor/amazeui.hbs.helper.js', 'vendor/amazeui.hbs.partials.js'] + widgets: [ + '*/src/*.js', + '!{powered_by,switch_mode,toolbar,tech_support,layout*,blank,container}' + + '/src/*.js'], + hbsHelper: [ + 'vendor/amazeui.hbs.helper.js', + 'vendor/amazeui.hbs.partials.js'] }; var dist = { - js: './dist/js', - css: './dist/css' + js: './dist/js', + css: './dist/css' }; var jsBase = [ - 'core.js', - 'util.fastclick.js', - 'util.hammer.js', - 'zepto.outerdemension.js', - 'zepto.extend.data.js', - 'zepto.extend.fx.js', - 'zepto.extend.selector.js' + 'core.js', + 'util.fastclick.js', + 'util.hammer.js', + 'zepto.outerdemension.js', + 'zepto.extend.data.js', + 'zepto.extend.fx.js', + 'zepto.extend.selector.js' ]; var dateFormat = 'UTC:yyyy-mm-dd"T"HH:mm:ss Z'; var banner = [ - '/*! <%= pkg.title %> v<%= pkg.version %><%=ver%>', - 'by Amaze UI Team', - '(c) ' + $.util.date(Date.now(), 'UTC:yyyy') + ' AllMobilize, Inc.', - 'Licensed under <%= pkg.license.type %>', - $.util.date(Date.now(), dateFormat) + ' */ \n' + '/*! <%= pkg.title %> v<%= pkg.version %><%=ver%>', + 'by Amaze UI Team', + '(c) ' + $.util.date(Date.now(), 'UTC:yyyy') + ' AllMobilize, Inc.', + 'Licensed under <%= pkg.license.type %>', + $.util.date(Date.now(), dateFormat) + ' */ \n' ].join(' | '); - var seajs = path.join(__dirname, 'vendor/seajs/sea.js'); -var seaUse = '', seaUseBasic = '', seaUseWidgets = '', jsWidgets = [], plugins, allPlugins, pluginsUsed, pluginsNotUsed, jsAll, jsAllSorted, jsBasic, jsBasicSorted, jsWidgetsSorted; +var seaUse = ''; +var seaUseBasic = ''; +var seaUseWidgets = ''; +var jsWidgets = []; +var plugins; +var allPlugins; +var pluginsUsed; +var pluginsNotUsed; +var jsAll; +var jsAllSorted; +var jsBasic; +var jsBasicSorted; +var jsWidgetsSorted; // write widgets style and tpl var preparingData = function() { - var fsOptions = {encoding: 'utf8'}; - var uiBase = fs.readFileSync('./less/amui.less', fsOptions); - var widgetsStyleDeps = []; - var widgetsStyle = ''; - var widgetsStyleWithDeps = ''; - var WIDGET_DIR = './widget'; - var rejectWidgets = ['.DS_Store', 'blank', 'layout2', 'layout3', 'layout4', 'container', 'powered_by', 'tech_support', 'toolbar', 'switch_mode']; - var allWidgets = _.reject(fs.readdirSync(WIDGET_DIR), function(widget) { - return rejectWidgets.indexOf(widget) > -1; + var fsOptions = {encoding: 'utf8'}; + var uiBase = fs.readFileSync('./less/amui.less', fsOptions); + var widgetsStyleDeps = []; + var widgetsStyle = ''; + var widgetsStyleWithDeps = ''; + var WIDGET_DIR = './widget'; + var rejectWidgets = ['.DS_Store', 'blank', 'layout2', 'layout3', 'layout4', + 'container', 'powered_by', 'tech_support', 'toolbar', 'switch_mode']; + var allWidgets = _.reject(fs.readdirSync(WIDGET_DIR), function(widget) { + return rejectWidgets.indexOf(widget) > -1; + }); + + var modules = []; + var modulesBasic = []; + var modulesWidgets = []; + + allPlugins = fs.readdirSync('./js'); + plugins = fs.readdirSync('./js'); + + var partials = '(function(undefined){\n'; + partials += ' \'use strict\';\n\n'; + partials += ' var registerAMUIPartials = function(hbs) {\n'; + + allWidgets.forEach(function(widget, i) { + // read widget package.json + var pkg = fs.readJsonFileSync(path. + join(WIDGET_DIR, widget, 'package.json')); + var srcPath = '../widget/' + widget + '/src/'; + + if (i === 0) { + widgetsStyleDeps = _.union(widgetsStyleDeps, pkg.styleBase); + } + + widgetsStyleDeps = _.union(widgetsStyleDeps, pkg.styleDependencies); + jsWidgets.push(pkg.script); + + jsWidgets = _.union(jsWidgets, pkg.jsDependencies); + + widgetsStyle += '\r\n// ' + widget + '\r\n'; + + widgetsStyle += '@import "' + srcPath + pkg.style + '";' + '\r\n'; + _.forEach(pkg.themes, function(item, index) { + if (!item.hidden && item.name) { + widgetsStyle += '@import "' + srcPath + widget + '.' + + item.name + '.less";' + '\r\n'; + } }); - var modules = []; - var modulesBasic = []; - var modulesWidgets = []; - - allPlugins = fs.readdirSync('./js'); - plugins = fs.readdirSync('./js'); - - var partials = '(function(undefined){\n'; - partials += ' var registerAMUIPartials = function(hbs) {\n'; - - allWidgets.forEach(function(widget, i) { - // read widget package.json - var pkg = fs.readJsonFileSync(path.join(WIDGET_DIR, widget, 'package.json')); - var srcPath = '../widget/' + widget + '/src/'; - - if (i === 0) { - widgetsStyleDeps = _.union( widgetsStyleDeps, pkg.styleBase); - } - - widgetsStyleDeps = _.union(widgetsStyleDeps, pkg.styleDependencies); - jsWidgets.push(pkg.script); - - jsWidgets = _.union(jsWidgets, pkg.jsDependencies); - - widgetsStyle += '\r\n// ' + widget + '\r\n'; - - widgetsStyle += '@import "' + srcPath + pkg.style + '";' + "\r\n"; - _.forEach(pkg.themes, function(item, index) { - if (!item.hidden && item.name) { - widgetsStyle += '@import "' + srcPath + widget + '.' + item.name + '.less";' + "\r\n"; - } - }); - - // read tpl - var tpl = fs.readFileSync(path.join(WIDGET_DIR, widget, 'src', widget + '.hbs'), fsOptions); - partials += format(' hbs.registerPartial("%s", %s); \n\n', widget, JSON.stringify(tpl)); - }); - - widgetsStyleDeps.forEach(function(dep) { - widgetsStyleWithDeps += format('@import "%s";\n', dep); - }); + // read tpl + var tpl = fs.readFileSync(path. + join(WIDGET_DIR, widget, 'src', widget + '.hbs'), fsOptions); + partials += format(' hbs.registerPartial(\'%s\', %s);\n\n', + widget, JSON.stringify(tpl)); + }); - fs.writeFileSync('./less/amazeui.less', uiBase + widgetsStyle); + widgetsStyleDeps.forEach(function(dep) { + widgetsStyleWithDeps += format('@import "%s";\n', dep); + }); - fs.writeFileSync('./less/amazeui.widgets.less', widgetsStyleWithDeps + widgetsStyle); + fs.writeFileSync('./less/amazeui.less', uiBase + widgetsStyle); + fs.writeFileSync('./less/amazeui.widgets.less', + widgetsStyleWithDeps + widgetsStyle); - /** - * Prepare JavaScript Data - */ + /** + * Prepare JavaScript Data + */ // for amazeui.basic.js - jsBasic = _.union(jsBase, allPlugins); + jsBasic = _.union(jsBase, allPlugins); - // for amazeui.js - jsAll = _.union(jsBasic, jsWidgets); + // for amazeui.js + jsAll = _.union(jsBasic, jsWidgets); - jsWidgets = _.union(jsBase, jsWidgets); + jsWidgets = _.union(jsBase, jsWidgets); - pluginsNotUsed = _.difference(plugins, jsWidgets); + pluginsNotUsed = _.difference(plugins, jsWidgets); - var pluginsUsed = _.remove(plugins, function(plugin) { - return pluginsNotUsed.indexOf(plugin) == -1; - }); + pluginsUsed = _.remove(plugins, function(plugin) { + return pluginsNotUsed.indexOf(plugin) == -1; + }); - jsWidgets = _.union(jsBase, pluginsUsed, jsWidgets); + jsWidgets = _.union(jsBase, pluginsUsed, jsWidgets); - // seajs.use[''...] - jsAll.forEach(function(js) { - var basename = path.basename(js, '.js'); - modules.push(basename); + // seajs.use[''...] + jsAll.forEach(function(js) { + var basename = path.basename(js, '.js'); + modules.push(basename); - if (jsWidgets.indexOf(js) > -1) { - modulesWidgets.push(basename) - } + if (jsWidgets.indexOf(js) > -1) { + modulesWidgets.push(basename); + } - if (jsBasic.indexOf(js) > -1) { - modulesBasic.push(basename) - } - }); + if (jsBasic.indexOf(js) > -1) { + modulesBasic.push(basename); + } + }); - seaUse = 'seajs.use(' + JSON.stringify(modules) + ');'; - seaUseBasic = 'seajs.use(' + JSON.stringify(modulesBasic) + ');'; - seaUseWidgets = 'seajs.use(' + JSON.stringify(modulesWidgets) + ');'; + seaUse = 'seajs.use(' + JSON.stringify(modules) + ');'; + seaUseBasic = 'seajs.use(' + JSON.stringify(modulesBasic) + ');'; + seaUseWidgets = 'seajs.use(' + JSON.stringify(modulesWidgets) + ');'; - // sort for concat - jsWidgetsSorted = _.union([seajs], jsWidgets, [seaUseWidgets]); + // sort for concat + jsWidgetsSorted = _.union([seajs], jsWidgets, [seaUseWidgets]); - jsAllSorted = _.union([seajs], jsAll); + jsAllSorted = _.union([seajs], jsAll); - jsBasicSorted = _.union([seajs], jsBasic, [seaUseBasic]); + jsBasicSorted = _.union([seajs], jsBasic, [seaUseBasic]); + partials += ' };\n\n'; + partials += ' if (typeof module !== \'undefined\' && module.exports) {\n'; + partials += ' module.exports = registerAMUIPartials;\n' + + ' }\n\n'; + partials += ' this.Handlebars && registerAMUIPartials(Handlebars);\n'; + partials += '}).call(this);\n'; - partials += ' }; \n\n'; - partials += ' if (typeof module !== \'undefined\' && module.exports) {\n'; - partials += ' module.exports = registerAMUIPartials;\n' + - ' }\n\n'; - partials += ' this.Handlebars && registerAMUIPartials(Handlebars);\n'; - partials += '}).call(this);\n'; - - // write partials - fs.writeFileSync(path.join('./vendor/amazeui.hbs.partials.js'), partials); + // write partials + fs.writeFileSync(path.join('./vendor/amazeui.hbs.partials.js'), partials); }; // build to dist dir gulp.task('buildLess', function() { - gulp.src(['./less/amui.less', './less/amazeui.widgets.less', './less/amazeui.less']) - .pipe($.header(banner, {pkg: pkg, ver: ''})) - .pipe($.less({ - paths: [path.join(__dirname, 'less'), path.join(__dirname, 'widget/*/src')] - })) - .pipe($.rename(function (path) { - if (path.basename === 'amui') { - path.basename = pkg.name + '.basic' - } - })) - .pipe(gulp.dest(dist.css)) - // Disable advanced optimizations - selector & property merging, reduction, etc. - // for Issue #19 https://github.com/allmobilize/amazeui/issues/19 - .pipe($.minifyCss({noAdvanced: true})) - .pipe($.rename({ - suffix: '.min', - extname: ".css" - })) - .pipe(gulp.dest(dist.css)); + gulp.src( + [ + './less/amui.less', + './less/amazeui.widgets.less', + './less/amazeui.less' + ]).pipe($.header(banner, {pkg: pkg, ver: ''})) + .pipe($.less({ + paths: [ + path.join(__dirname, 'less'), + path.join(__dirname, 'widget/*/src')] + })) + .pipe($.rename(function(path) { + if (path.basename === 'amui') { + path.basename = pkg.name + '.basic'; + } + })) + .pipe(gulp.dest(dist.css)) + // Disable advanced optimizations - selector & property merging, etc. + // for Issue #19 https://github.com/allmobilize/amazeui/issues/19 + .pipe($.minifyCss({noAdvanced: true})) + .pipe($.rename({ + suffix: '.min', + extname: '.css' + })) + .pipe(gulp.dest(dist.css)); }); gulp.task('bower', function() { - $.bower() - .pipe(gulp.dest('vendor/')) + $.bower(). + pipe(gulp.dest('vendor/')); }); // copy ui js files to build dir gulp.task('copyWidgetJs', function() { - $.util.log($.util.colors.yellow('Start copy UI js files to build dir....')); - return gulp.src(jsPaths.widgets, {cwd: './widget'}) - .pipe($.rename(function(path) { - path.dirname = ""; // remove widget dir - })) - .pipe(gulp.dest(buildTmpDir)); + $.util.log($.util.colors.yellow('Start copy UI js files to build dir....')); + return gulp.src(jsPaths.widgets, {cwd: './widget'}) + .pipe($.rename(function(path) { + path.dirname = ''; // remove widget dir + })) + .pipe(gulp.dest(buildTmpDir)); }); // copy widgets js files to build dir gulp.task('copyUIJs', ['copyWidgetJs'], function() { - return gulp.src(['*.js', '!./js/zepto.calendar.js'], { - cwd: './js' - }) - .pipe(gulp.dest(buildTmpDir)); + return gulp.src(['*.js', '!./js/zepto.calendar.js'], { + cwd: './js' + }) + .pipe(gulp.dest(buildTmpDir)); }); // gulp cmd transport gulp.task('transport', ['copyUIJs'], function() { - return gulp.src(['*.js'], {cwd: buildTmpDir}) - .pipe($.cmdTransport({paths: [buildTmpDir]})) - .pipe(gulp.dest(transportDir)); + return gulp.src(['*.js'], {cwd: buildTmpDir}) + .pipe($.cmdTransport({paths: [buildTmpDir]})) + .pipe(gulp.dest(transportDir)); }); // concat amazeui.js gulp.task('concatAll', ['transport'], function() { - return gulp.src(jsAllSorted, {cwd: transportDir}) - .pipe($.concat(pkg.name + '.js')) - .pipe($.header(banner, {pkg: pkg, ver: ''})) - .pipe($.footer('\n<%=use%>', {use: seaUse})) - .pipe(gulp.dest(dist.js)) - .pipe($.uglify({ - mangle: { - except: ['require'] - } - })) - .pipe($.header(banner, {pkg: pkg, ver: ''})) - .pipe($.rename({ - suffix: '.min', - extname: ".js" - })) - .pipe(gulp.dest(dist.js)); + return gulp.src(jsAllSorted, {cwd: transportDir}) + .pipe($.concat(pkg.name + '.js')) + .pipe($.header(banner, {pkg: pkg, ver: ''})) + .pipe($.footer('\n<%=use%>', {use: seaUse})) + .pipe(gulp.dest(dist.js)) + .pipe($.uglify({ + mangle: { + except: ['require'] + } + })) + .pipe($.header(banner, {pkg: pkg, ver: ''})) + .pipe($.rename({ + suffix: '.min', + extname: '.js' + })) + .pipe(gulp.dest(dist.js)); }); // concat amazeui.basic.js gulp.task('concatBasic', ['concatAll'], function() { - return gulp.src(jsBasicSorted, {cwd: transportDir}) - .pipe($.concat(pkg.name + '.basic.js')) - .pipe($.header(banner, {pkg: pkg, ver: ' ~ basic'})) - .pipe($.footer('\n<%=use%>', {use: seaUseBasic})) - .pipe(gulp.dest(dist.js)) - .pipe($.uglify({ - mangle: { - except: ['require'] - } - })) - .pipe($.header(banner, {pkg: pkg, ver: ' ~ basic'})) - .pipe($.rename({ - suffix: '.min', - extname: ".js" - })) - .pipe(gulp.dest(dist.js)) + return gulp.src(jsBasicSorted, {cwd: transportDir}) + .pipe($.concat(pkg.name + '.basic.js')) + .pipe($.header(banner, {pkg: pkg, ver: ' ~ basic'})) + .pipe($.footer('\n<%=use%>', {use: seaUseBasic})) + .pipe(gulp.dest(dist.js)) + .pipe($.uglify({ + mangle: { + except: ['require'] + } + })) + .pipe($.header(banner, {pkg: pkg, ver: ' ~ basic'})) + .pipe($.rename({ + suffix: '.min', + extname: '.js' + })) + .pipe(gulp.dest(dist.js)); }); // concat amazeui.widgets.js gulp.task('concatWidgets', ['concatBasic'], function() { - return gulp.src(jsWidgetsSorted, {cwd: transportDir}) - .pipe($.concat(pkg.name + '.widgets.js')) - .pipe($.header(banner, {pkg: pkg, ver: ' ~ widgets'})) - .pipe($.footer('\n<%=use%>', {use: seaUseWidgets})) - .pipe(gulp.dest(dist.js)) - .pipe($.uglify({ - mangle: { - except: ['require'] - } - })) - .pipe($.header(banner, {pkg: pkg, ver: ' ~ widgets'})) - .pipe($.rename({ - suffix: '.min', - extname: ".js" - })) - .pipe(gulp.dest(dist.js)) + return gulp.src(jsWidgetsSorted, {cwd: transportDir}) + .pipe($.concat(pkg.name + '.widgets.js')) + .pipe($.header(banner, {pkg: pkg, ver: ' ~ widgets'})) + .pipe($.footer('\n<%=use%>', {use: seaUseWidgets})) + .pipe(gulp.dest(dist.js)) + .pipe($.uglify({ + mangle: { + except: ['require'] + } + })) + .pipe($.header(banner, {pkg: pkg, ver: ' ~ widgets'})) + .pipe($.rename({ + suffix: '.min', + extname: '.js' + })) + .pipe(gulp.dest(dist.js)); }); gulp.task('concat', ['concatAll', 'concatBasic', 'concatWidgets']); gulp.task('clean', ['concatWidgets'], function() { - $.util.log($.util.colors.green('Finished build js, cleaning...')); - gulp.src('./.build', {read: false}) - .pipe($.clean({force: true})); + $.util.log($.util.colors.green('Finished build js, cleaning...')); + gulp.src('./.build', {read: false}) + .pipe($.clean({force: true})); }); gulp.task('hbsHelper', function() { - gulp.src(jsPaths.hbsHelper) - .pipe($.concat(pkg.name + '.widgets.helper.js')) - .pipe($.header(banner, {pkg: pkg, ver: ' ~ helper'})) - .pipe(gulp.dest(dist.js)) - .pipe($.uglify({ - mangle: { - except: ['require'] - } - })) - .pipe($.header(banner, {pkg: pkg, ver: ' ~ helper'})) - .pipe($.rename({ - suffix: '.min', - extname: ".js" - })) - .pipe(gulp.dest(dist.js)) + gulp.src(jsPaths.hbsHelper) + .pipe($.concat(pkg.name + '.widgets.helper.js')) + .pipe($.header(banner, {pkg: pkg, ver: ' ~ helper'})) + .pipe(gulp.dest(dist.js)) + .pipe($.uglify({ + mangle: { + except: ['require'] + } + })) + .pipe($.header(banner, {pkg: pkg, ver: ' ~ helper'})) + .pipe($.rename({ + suffix: '.min', + extname: '.js' + })) + .pipe(gulp.dest(dist.js)); }); gulp.task('preparing', preparingData); gulp.task('appServer', function() { - exec('npm start', function (err, stdout, stderr) { - console.log(stdout); - console.log(stderr); - }); + exec('npm start', function(err, stdout, stderr) { + console.log(stdout); + console.log(stderr); + }); }); - // Rerun the task when a file changes gulp.task('watch', function() { - gulp.watch(['js/*.js', 'widget/*/src/*.js'], ['buildJs']); - gulp.watch(['less/**/*.less', 'widget/*/src/*.less'], ['buildLess']); - gulp.watch(['dist/amui*js'], ['copyFiles']); - gulp.watch(['docs/assets/js/main.js'], ['amazeMain']); - gulp.watch(['widget/**/*.json', 'widget/**/*.hbs'], ['preparing']); - gulp.watch(jsPaths.hbsHelper, ['hbsHelper']); + gulp.watch(['js/*.js', 'widget/*/src/*.js'], ['buildJs']); + gulp.watch(['less/**/*.less', 'widget/*/src/*.less'], ['buildLess']); + gulp.watch(['dist/amui*js'], ['copyFiles']); + gulp.watch(['docs/assets/js/main.js'], ['amazeMain']); + gulp.watch(['widget/**/*.json', 'widget/**/*.hbs'], ['preparing']); + gulp.watch(jsPaths.hbsHelper, ['hbsHelper']); }); gulp.task('zipCopyCSS', function() { - return gulp.src('./dist/css/*.css') - .pipe(gulp.dest('./docs/examples/assets/css')); + return gulp.src('./dist/css/*.css') + .pipe(gulp.dest('./docs/examples/assets/css')); }); gulp.task('zipCopyJs', ['zipCopyCSS'], function() { - return gulp.src(['./dist/js/*.js', './vendor/handlebars/handlebars.min.js', './vendor/zepto/zepto.min.js']) - .pipe(gulp.dest('./docs/examples/assets/js')); + return gulp.src([ + './dist/js/*.js', + './vendor/handlebars/handlebars.min.js', + './vendor/zepto/zepto.min.js']) + .pipe(gulp.dest('./docs/examples/assets/js')); }); gulp.task('zipAdd', ['zipCopyJs'], function() { - return gulp.src(['docs/examples/**/*']) - .pipe($.replace(/\{\{assets\}\}/g, 'assets/', {skipBinary: true})) - .pipe($.zip(format('AmazeUI-%s-%s.zip', pkg.version, $.util.date(Date.now(), 'UTC:yyyymmdd')), {comment: 'Created on ' + $.util.date(Date.now(), dateFormat)})) - .pipe(gulp.dest('dist')); + return gulp.src(['docs/examples/**/*']) + .pipe($.replace(/\{\{assets\}\}/g, 'assets/', {skipBinary: true})) + .pipe($.zip(format('AmazeUI-%s-%s.zip', + pkg.version, $.util.date(Date.now(),'UTC:yyyymmdd')), + {comment: 'Created on ' + $.util.date(Date.now(), dateFormat)})) + .pipe(gulp.dest('dist')); }); gulp.task('zipClean', ['zipAdd'], function() { // zipClean - return gulp.src(['docs/examples/assets/*/amazeui.*', - './docs/examples/assets/js/handlebars.min.js', - './docs/examples/assets/js/zepto.min.js'], {read: false}) - .pipe($.clean({force: true})); + return gulp.src(['docs/examples/assets/*/amazeui.*', + './docs/examples/assets/js/handlebars.min.js', + './docs/examples/assets/js/zepto.min.js'], {read: false}) + .pipe($.clean({force: true})); }); gulp.task('zip', ['zipClean']); - -gulp.task('buildJs', ['copyWidgetJs', 'copyUIJs', 'transport', 'concat', 'clean']); +gulp.task('buildJs', + [ + 'copyWidgetJs', + 'copyUIJs', + 'transport', + 'concat', + 'clean' + ]); // gulp.task('init', ['bower', 'buildJs', 'hbsHelper', 'buildLess', 'watch']); -gulp.task('default', ['preparing', 'buildJs', 'buildLess', 'hbsHelper', 'watch']); - -gulp.task('preview', ['preparing', 'buildJs', 'buildLess', 'hbsHelper', 'watch', 'appServer']); +gulp.task('default', + [ + 'preparing', + 'buildJs', + 'buildLess', + 'hbsHelper', + 'watch' + ]); + +gulp.task('preview', + ['preparing', + 'buildJs', + 'buildLess', + 'hbsHelper', + 'watch', + 'appServer' + ]); diff --git a/nodemon.json b/nodemon.json index 51bdf45d4..e7f716312 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,20 +1,16 @@ { - "ignore": [ - ".git", - "node_modules/**/node_modules" - ], - - "verbose": true, - - "watch": [ - "tools/app/*", - "app.js", - "widget/**/*" - ], - - "env": { - "NODE_ENV": "development" - }, - - "ext": "js json hbs" + "ignore": [ + ".git", + "node_modules/**/node_modules" + ], + "verbose": true, + "watch": [ + "tools/app/*", + "app.js", + "widget/**/*" + ], + "env": { + "NODE_ENV": "development" + }, + "ext": "js json hbs" } \ No newline at end of file diff --git a/vendor/amazeui.hbs.helper.js b/vendor/amazeui.hbs.helper.js index ae95f5bcd..70b196e38 100644 --- a/vendor/amazeui.hbs.helper.js +++ b/vendor/amazeui.hbs.helper.js @@ -1,38 +1,38 @@ (function(undefined) { - var registerIfCondHelper = function(hbs) { - hbs.registerHelper('ifCond', function(v1, operator, v2, options) { - switch (operator) { - case '==': - return (v1 == v2) ? options.fn(this) : options.inverse(this); - break; - case '===': - return (v1 === v2) ? options.fn(this) : options.inverse(this); - break; - case '<': - return (v1 < v2) ? options.fn(this) : options.inverse(this); - break; - case '<=': - return (v1 <= v2) ? options.fn(this) : options.inverse(this); - break; - case '>': - return (v1 > v2) ? options.fn(this) : options.inverse(this); - break; - case '>=': - return (v1 >= v2) ? options.fn(this) : options.inverse(this); - break; - default: - return options.inverse(this) - break; - } - return options.inverse(this); - }); - }; + 'use strict'; - if (typeof module !== 'undefined' && module.exports) { - module.exports = registerIfCondHelper; - } + var registerIfCondHelper = function(hbs) { + hbs.registerHelper('ifCond', function(v1, operator, v2, options) { + switch (operator) { + case '==': + return (v1 == v2) ? options.fn(this) : options.inverse(this); + break; + case '===': + return (v1 === v2) ? options.fn(this) : options.inverse(this); + break; + case '<': + return (v1 < v2) ? options.fn(this) : options.inverse(this); + break; + case '<=': + return (v1 <= v2) ? options.fn(this) : options.inverse(this); + break; + case '>': + return (v1 > v2) ? options.fn(this) : options.inverse(this); + break; + case '>=': + return (v1 >= v2) ? options.fn(this) : options.inverse(this); + break; + default: + return options.inverse(this); + break; + } + return options.inverse(this); + }); + }; - this.Handlebars && registerIfCondHelper(Handlebars); + if (typeof module !== 'undefined' && module.exports) { + module.exports = registerIfCondHelper; + } + this.Handlebars && registerIfCondHelper(Handlebars); }).call(this); - diff --git a/vendor/amazeui.hbs.partials.js b/vendor/amazeui.hbs.partials.js index cd92c24d9..a602daf50 100644 --- a/vendor/amazeui.hbs.partials.js +++ b/vendor/amazeui.hbs.partials.js @@ -1,46 +1,48 @@ (function(undefined){ + 'use strict'; + var registerAMUIPartials = function(hbs) { - hbs.registerPartial("accordion", "{{#this}}\n
\n {{#each content}}\n
\n
\n {{{title}}}\n
\n
\n {{{content}}}\n
\n
\n {{/each}}\n
\n{{/this}}"); + hbs.registerPartial('accordion', "{{#this}}\n
\n {{#each content}}\n
\n
\n {{{title}}}\n
\n
\n {{{content}}}\n
\n
\n {{/each}}\n
\n{{/this}}"); - hbs.registerPartial("divider", "{{#this}}\n
\n{{/this}}\n"); + hbs.registerPartial('divider', "{{#this}}\n
\n{{/this}}\n"); - hbs.registerPartial("duoshuo", "{{#this}}\n
\n
\n
\n
\n{{/this}}"); + hbs.registerPartial('duoshuo', "{{#this}}\n
\n
\n
\n
\n{{/this}}"); - hbs.registerPartial("figure", "{{#this}}\n
\n {{#if content.link}}{{/if}}\n\n {{#if options.figcaptionPosition}}\n {{#ifCond options.figcaptionPosition '==' 'top'}}\n {{#if content.figcaption}}\n
\n {{content.figcaption}}\n
\n {{/if}}\n {{/ifCond}}\n {{/if}}\n\n {{#if content.img}}\n \"{{#if\n {{/if}}\n {{#if options.figcaptionPosition}}\n {{#ifCond options.figcaptionPosition '==' 'bottom'}}\n {{#if content.figcaption}}\n
\n {{content.figcaption}}\n
\n {{/if}}\n {{/ifCond}}\n {{else}}\n {{#if content.figcaption}}\n
\n {{content.figcaption}}\n
\n {{/if}}\n {{/if}}\n\n {{#if content.link}}
{{/if}}\n
\n{{/this}}"); + hbs.registerPartial('figure', "{{#this}}\n
\n {{#if content.link}}{{/if}}\n\n {{#if options.figcaptionPosition}}\n {{#ifCond options.figcaptionPosition '==' 'top'}}\n {{#if content.figcaption}}\n
\n {{content.figcaption}}\n
\n {{/if}}\n {{/ifCond}}\n {{/if}}\n\n {{#if content.img}}\n \"{{#if\n {{/if}}\n {{#if options.figcaptionPosition}}\n {{#ifCond options.figcaptionPosition '==' 'bottom'}}\n {{#if content.figcaption}}\n
\n {{content.figcaption}}\n
\n {{/if}}\n {{/ifCond}}\n {{else}}\n {{#if content.figcaption}}\n
\n {{content.figcaption}}\n
\n {{/if}}\n {{/if}}\n\n {{#if content.link}}
{{/if}}\n
\n{{/this}}"); - hbs.registerPartial("footer", "{{#this}}\n \n\n \n{{/this}}\n"); + hbs.registerPartial('footer', "{{#this}}\n \n\n \n{{/this}}\n"); - hbs.registerPartial("gallery", "{{#this}}\n \n{{/this}}\n"); + hbs.registerPartial('gallery', "{{#this}}\n \n{{/this}}\n"); - hbs.registerPartial("gotop", "{{#this}}\n
\n \n {{#if content.title}}\n {{content.title}}\n {{/if}}\n {{#if content.customIcon}}\n \n {{else}}\n {{#if content.icon}}\n \n {{else}}\n \n {{/if}}\n {{/if}}\n \n
\n{{/this}}"); + hbs.registerPartial('gotop', "{{#this}}\n
\n \n {{#if content.title}}\n {{content.title}}\n {{/if}}\n {{#if content.customIcon}}\n \n {{else}}\n {{#if content.icon}}\n \n {{else}}\n \n {{/if}}\n {{/if}}\n \n
\n{{/this}}"); - hbs.registerPartial("header", "{{#this}}\n
\n {{#if content.left}}\n
\n {{#each content.left}}\n \n {{#if title}}\n \n {{title}}\n \n {{/if}}\n\n {{# if customIcon}}\n \"\"/\n {{else}}\n {{#if icon}}\n \n {{/if}}\n {{/if}}\n \n {{/each}}\n
\n {{/if}}\n\n {{#if content.title}}\n

\n {{#if content.link}}\n \n {{{content.title}}}\n \n {{else}}\n {{{content.title}}}\n {{/if}}\n

\n {{/if}}\n\n {{#if content.right}}\n
\n {{#each content.right}}\n \n {{#if title}}\n \n {{title}}\n \n {{/if}}\n\n {{# if customIcon}}\n \"\"/\n {{else}}\n {{#if icon}}\n \n {{/if}}\n {{/if}}\n \n {{/each}}\n
\n {{/if}}\n
\n{{/this}}"); + hbs.registerPartial('header', "{{#this}}\n
\n {{#if content.left}}\n
\n {{#each content.left}}\n \n {{#if title}}\n \n {{title}}\n \n {{/if}}\n\n {{# if customIcon}}\n \"\"/\n {{else}}\n {{#if icon}}\n \n {{/if}}\n {{/if}}\n \n {{/each}}\n
\n {{/if}}\n\n {{#if content.title}}\n

\n {{#if content.link}}\n \n {{{content.title}}}\n \n {{else}}\n {{{content.title}}}\n {{/if}}\n

\n {{/if}}\n\n {{#if content.right}}\n
\n {{#each content.right}}\n \n {{#if title}}\n \n {{title}}\n \n {{/if}}\n\n {{# if customIcon}}\n \"\"/\n {{else}}\n {{#if icon}}\n \n {{/if}}\n {{/if}}\n \n {{/each}}\n
\n {{/if}}\n
\n{{/this}}"); - hbs.registerPartial("intro", "{{#this }}\n
\n {{#if content.title}}\n
\n

{{{content.title}}}

\n {{#if content.more.link}}\n {{#ifCond options.position '==' 'top'}}\n {{content.more.title}}\n {{/ifCond}}\n {{/if}}\n
\n {{/if}}\n\n
\n {{#if content.left}}\n {{{content.left}}}
\n {{/if}}\n {{#if content.right}}\n {{{content.right}}}
\n {{/if}}\n \n {{#ifCond options.position '==' 'bottom'}}\n
\n {{content.more.title}}\n
\n {{/ifCond}}\n \n{{/this}}"); + hbs.registerPartial('intro', "{{#this }}\n
\n {{#if content.title}}\n
\n

{{{content.title}}}

\n {{#if content.more.link}}\n {{#ifCond options.position '==' 'top'}}\n {{content.more.title}}\n {{/ifCond}}\n {{/if}}\n
\n {{/if}}\n\n
\n {{#if content.left}}\n {{{content.left}}}
\n {{/if}}\n {{#if content.right}}\n {{{content.right}}}
\n {{/if}}\n \n {{#ifCond options.position '==' 'bottom'}}\n
\n {{content.more.title}}\n
\n {{/ifCond}}\n \n{{/this}}"); - hbs.registerPartial("list_news", "{{#this}}\n
\n \n {{#if content.header.title}}\n
\n {{#if content.header.link}} \n \n

{{{content.header.title}}}

\n {{#ifCond content.header.morePosition '==' 'top'}}\n {{{content.header.moreText}}}\n {{/ifCond}}\n
\n {{else}} \n

{{{content.header.title}}}

\n {{/if}}\n
\n {{/if}}\n\n
\n \n
\n\n {{#ifCond content.header.morePosition '==' 'bottom'}}\n {{#if content.header.link}}\n
\n {{{content.header.moreText}}}\n
\n {{/if}}\n {{/ifCond}}\n
\n{{/this}}"); + hbs.registerPartial('list_news', "{{#this}}\n
\n \n {{#if content.header.title}}\n
\n {{#if content.header.link}} \n \n

{{{content.header.title}}}

\n {{#ifCond content.header.morePosition '==' 'top'}}\n {{{content.header.moreText}}}\n {{/ifCond}}\n
\n {{else}} \n

{{{content.header.title}}}

\n {{/if}}\n
\n {{/if}}\n\n
\n \n
\n\n {{#ifCond content.header.morePosition '==' 'bottom'}}\n {{#if content.header.link}}\n
\n {{{content.header.moreText}}}\n
\n {{/if}}\n {{/ifCond}}\n
\n{{/this}}"); - hbs.registerPartial("map", "{{#this}}\n
\n
\n
\n{{/this}}"); + hbs.registerPartial('map', "{{#this}}\n
\n
\n
\n{{/this}}"); - hbs.registerPartial("mechat", "{{#this}}\n
\n
\n
\n{{/this}}"); + hbs.registerPartial('mechat', "{{#this}}\n
\n
\n
\n{{/this}}"); - hbs.registerPartial("menu", "{{#this}}\n \n{{/this}}\n"); + hbs.registerPartial('menu', "{{#this}}\n \n{{/this}}\n"); - hbs.registerPartial("navbar", "{{#this}}\n
\n {{#if content}}\n \n {{/if}}\n
\n{{/this}}\n"); + hbs.registerPartial('navbar', "{{#this}}\n
\n {{#if content}}\n \n {{/if}}\n
\n{{/this}}\n"); - hbs.registerPartial("pagination", "{{#this}}\n \n{{/this}}"); + hbs.registerPartial('pagination', "{{#this}}\n \n{{/this}}"); - hbs.registerPartial("paragraph", "{{#this}}\n
\n\n {{#if content}}\n {{{ content.content }}}\n {{/if}}\n
\n{{/this}}\n"); + hbs.registerPartial('paragraph', "{{#this}}\n
\n\n {{#if content}}\n {{{ content.content }}}\n {{/if}}\n
\n{{/this}}\n"); - hbs.registerPartial("slider", "{{#this}}\n
\n \n
\n{{/this}}"); + hbs.registerPartial('slider', "{{#this}}\n
\n \n
\n{{/this}}"); - hbs.registerPartial("sohucs", "{{#this}}\n
\n
\n
\n{{/this}}"); + hbs.registerPartial('sohucs', "{{#this}}\n
\n
\n
\n{{/this}}"); - hbs.registerPartial("tabs", "{{#this }}\n
\n {{#if content}}\n \n
\n {{#each content}}\n
\n {{{content}}}\n
\n {{/each}}\n
\n {{/if}}\n
\n{{/this }}"); + hbs.registerPartial('tabs', "{{#this }}\n
\n {{#if content}}\n \n
\n {{#each content}}\n
\n {{{content}}}\n
\n {{/each}}\n
\n {{/if}}\n
\n{{/this }}"); - hbs.registerPartial("titlebar", "{{#this}}\n
\n {{#if content.title}}\n

\n {{#if content.link}}\n {{{content.title}}}\n {{else}}\n {{{content.title}}}\n {{/if}}\n

\n {{/if}}\n\n {{#if content.nav}}\n \n {{/if}}\n
\n{{/this}}"); + hbs.registerPartial('titlebar', "{{#this}}\n
\n {{#if content.title}}\n

\n {{#if content.link}}\n {{{content.title}}}\n {{else}}\n {{{content.title}}}\n {{/if}}\n

\n {{/if}}\n\n {{#if content.nav}}\n \n {{/if}}\n
\n{{/this}}"); - }; + }; if (typeof module !== 'undefined' && module.exports) { module.exports = registerAMUIPartials;