<commit_before>// Include gulp
var gulp = require('gulp');
var fs = require('fs');
var pkg = JSON.parse(fs.readFileSync('./package.json'));
var beep = require('beepbeep');
var onError = function (err) { beep(); };

// Include Our Plugins
var appcache = require('gulp-appcache');
var clone      = require('gulp-clone');
var concat     = require('gulp-concat');
var imageResize= require('gulp-image-resize');
var jshint     = require('gulp-jshint');
var livereload = require('gulp-livereload');
var plumber    = require('gulp-plumber');
var postcss    = require('gulp-postcss');
var rename     = require("gulp-rename");
var replace    = require('gulp-replace');
var sass       = require('gulp-sass');
var shell      = require('gulp-shell');
var sourcemaps = require('gulp-sourcemaps');
var uglify     = require('gulp-uglify');

// Lint Task
gulp.task('jshint', function() {
  return gulp.src([
      pkg.directories.js_src + '/**/*.js',
      '!' + pkg.directories.js_src + '/vendor/*.js'
    ])
    .pipe(plumber({errorHandler: onError}))
    .pipe(jshint({ // see https://github.com/jshint/jshint/blob/master/examples/.jshintrc
      browser: true,
      jquery: true,
      strict: true,
      curly: true,
      undef: true
    }))
    .pipe(jshint.reporter('default'))
    .pipe(jshint.reporter('fail'))
  ;
});

// Concatenate & Minify JS
gulp.task('uglify', function() {
  return gulp.src([
      pkg.directories.js_src + '/vendor/*.js', // disable this line by prepending '!' - in case of errors
      pkg.directories.js_src + '/modules/*.js',
      pkg.directories.js_src + '/main.js'
    ])
    .pipe(concat('scripts.js'))
    .pipe(uglify({output: {
      max_line_len: 9000
    }}))
    .pipe(gulp.dest(pkg.directories.js))
    .pipe(livereload());
  ;
});

// Sass
gulp.task('sass', function(cb) {
  return gulp.src(pkg.directories.sass + '/**/*.scss')
    .pipe(plumber({errorHandler: onError}))
    .pipe(sass({outputStyle: 'compact'}).on('error', sass.logError))
    .pipe(gulp.dest(pkg.directories.css))
  ;
  cb(err);
});

// PostCSS
gulp.task('postcss',['sass'], function (cb) {
  return gulp.src(pkg.directories.css + '/styles.css')
    .pipe( postcss([ require('autoprefixer')({browsers: ['last 2 versions', '> 2%', 'ie 8', 'ie 9']})]) )
    .pipe( gulp.dest(pkg.directories.css) )
    .pipe( postcss([ require('rtlcss')]) )
    .pipe(rename('rtl.css'))
    .pipe( gulp.dest(pkg.directories.css) )
  ;
  cb(err);
});

gulp.task('oldie',['postcss'], function () {
  var css = gulp.src(pkg.directories.css + '/*.css')
    .pipe(replace(/(\n)\s*\n/g, '$1'))
  ;

  var oldie = css.pipe(clone())
    .pipe(replace(/\/\*#.+?\*\//g, ''))
    .pipe(replace(/@media[^\{]+tty[^\{]+\{ (.+ \}) \}(\s*)/g, '$1$2'))
    .pipe(replace(/(@media[^\{]+device-pixel-ratio[^\{]+\{ [\s\S]+? \} \}\s*)/g, ''))
    .pipe(replace(/(@media screen) [^\{]+ \(max-width: \d+px\)( \{ [\s\S]+? \} \}\s*)/g, ''))
    .pipe(replace(/(@media screen) and \(.+?\)( \{ [\s\S]+? \} \}\s*)/g, '$1$2'))
    .pipe(replace(/-(moz|webkit)-[^\{]+?:.+?;\s*/g, ''))
    .pipe(replace(/(transition|border-[\S]*radius):.+?;\s*/g, ''))
    .pipe(replace(/opacity: 0;\s*/g, 'visibility: hidden; '))
    .pipe(replace(/opacity: 1;\s*/g, 'visibility: visible; '))
    .pipe(replace(/rgba(\(.+?),\s?[\d\.]+(\))/g, 'rgb$1$2'))
    .pipe(replace(/\s\S+\s?\{\s+\}/g, ''))
    .pipe(replace(/([\d\.]+)vw/g, function (regexMatches) {
      return Math.round(parseFloat(regexMatches[0]) * 10.24) + 'px'; // matches 1024px
    }))
    .pipe(replace(/([\d\.]+)vh/g, function (regexMatches) {
      return Math.round(parseFloat(regexMatches[0]) * 7.68) + 'px'; // matches 768 px
    }))
    .pipe(replace(/([\d\.]+)rem/g, function (regexMatches) {
      return Math.round(parseFloat(regexMatches[0]) * 12) + 'px'; // matches $fontsize-default
    }))
    .pipe( gulp.dest(pkg.directories.css + '/oldie') )
  ;

  return css
    .pipe(replace(/(@media[^\{]+tty[^\{]+\{ [\s\S]+? \} \}\s*)/g, ''))
    .pipe( gulp.dest(pkg.directories.css) )
    .pipe(livereload());
  ;
});

gulp.task('appcache', function(){
  gulp.src([
    pkg.directories.template + '/**/*',
    '!'+pkg.directories.template + '/*.html',
    '!'+pkg.directories.images + '/article*/*',
    '!'+pkg.directories.images + '/originals/*',
    '!'+pkg.directories.css + '/oldie/*'
  ])
  .pipe(appcache({
    //relativePath: pkg.directories.template,
    hash: true,
    preferOnline: true,
    filename: 'manifest.appcache',
    exclude: 'manifest.appcache'
  }))
  .pipe(gulp.dest(pkg.directories.template));
});

gulp.task('logo', function() {
  var logo = gulp.src(pkg.directories.images + '/logo.png');

  [
    {
      width: 32,
      height: 32,
      name: 'favicon.ico',
      directory: pkg.directories.template
    },{
      width: 96,
      height: 96,
      name: 'favicon-96x96.png',
      directory: pkg.directories.template
    },{
      width: 152,
      height: 152,
      name: 'apple-touch-icon-precomposed.png',
      directory: pkg.directories.template
    },{
      width: 196,
      height: 196,
      name: 'favicon-196x196.png',
      directory: pkg.directories.template
    },{
      width: 128,
      height: 128,
      name: 'tile-128x128.png',
      directory: pkg.directories.images
    },{
      width: 270,
      height: 270,
      name: 'tile-270x270.png',
      directory: pkg.directories.images
    },{
      width: 558,
      height: 270,
      name: 'tile-558x270.png',
      directory: pkg.directories.images
    },{
      width: 558,
      height: 558,
      name: 'tile-558x558.png',
      directory: pkg.directories.images
    }
  ].forEach(function(i) {
    logo.pipe(clone())
      .pipe(imageResize({
        width: i.width,
        height: i.height,
        crop: true,
        quality: 0.7,
        gravity: 'Center',
        imageMagick: true
      }))
      .pipe(rename(i.name))
      .pipe(gulp.dest(i.directory))
    ;
  })
  return logo;
});

gulp.task('article_images', function() {
  var article_images = gulp.src(pkg.directories.images + '/originals/*.jpg');

  [{ width: 640, height: 360 },{ width: 1280, height: 720 }].forEach(function(i) {
    article_images.pipe(clone())
      .pipe(imageResize({
        width: i.width,
        height: i.height,
        crop: true,
        quality: 0.7,
        gravity: 'Center',
        imageMagick: true
      }))
      .pipe(gulp.dest(pkg.directories.images + '/articles-'+i.width))
    ;
  });
  return article_images;
});

gulp.task('deploy_live', shell.task([
  pkg.directories.build + '/deploy.sh live'
]));
gulp.task('vagrant_up', shell.task([
  'cd ' + pkg.directories.build + '/vagrant && vagrant up && cd -'
]));
gulp.task('vagrant_suspend', shell.task([
  'cd ' + pkg.directories.build + '/vagrant && vagrant suspend && cd -'
]));

// Watch Files For Changes
gulp.task('watch', function() {
  livereload.listen();
  gulp.watch(['gulpfile.js','package.json'], process.exit);
  gulp.watch(pkg.directories.js_src + '/**/*.js', ['build-js']);
  gulp.watch(pkg.directories.sass + '/**/*.scss', ['build-sass']);
  gulp.watch(pkg.directories.images + '/logo.png', ['build-icons']);
  gulp.watch(pkg.directories.images + '/originals/*.jpg', ['build-article-images']);
});

// Default Task
gulp.task('default',     ['build-js','build-sass','build-icons']);
gulp.task('build-sass',  ['sass','postcss','oldie','appcache']);
gulp.task('build-js',    ['jshint','uglify','appcache']);
gulp.task('build-icons', ['logo','appcache']);
gulp.task('build-article-images',    ['article_images','appcache']);
<commit_msg>Performance improvements by only requiring stuff once<commit_after>// Include gulp
var gulp = require('gulp');
var fs = require('fs');
var pkg = JSON.parse(fs.readFileSync('./package.json'));
var beep = require('beepbeep');
var onError = function (err) { beep(); };

// Include Our Plugins
var appcache = require('gulp-appcache');
var clone      = require('gulp-clone');
var concat     = require('gulp-concat');
var imageResize= require('gulp-image-resize');
var jshint     = require('gulp-jshint');
var livereload = require('gulp-livereload');
var plumber    = require('gulp-plumber');
var postcss    = require('gulp-postcss');
var rename     = require("gulp-rename");
var replace    = require('gulp-replace');
var sass       = require('gulp-sass');
var shell      = require('gulp-shell');
var sourcemaps = require('gulp-sourcemaps');
var uglify     = require('gulp-uglify');
var autoprefixer = require('autoprefixer');
var rtlcss       = require('rtlcss');

// Lint Task
gulp.task('jshint', function() {
  return gulp.src([
      pkg.directories.js_src + '/**/*.js',
      '!' + pkg.directories.js_src + '/vendor/*.js'
    ])
    .pipe(plumber({errorHandler: onError}))
    .pipe(jshint({ // see https://github.com/jshint/jshint/blob/master/examples/.jshintrc
      browser: true,
      jquery: true,
      strict: true,
      curly: true,
      undef: true
    }))
    .pipe(jshint.reporter('default'))
    .pipe(jshint.reporter('fail'))
  ;
});

// Concatenate & Minify JS
gulp.task('uglify', function() {
  return gulp.src([
      pkg.directories.js_src + '/vendor/*.js', // disable this line by prepending '!' - in case of errors
      pkg.directories.js_src + '/modules/*.js',
      pkg.directories.js_src + '/main.js'
    ])
    .pipe(concat('scripts.js'))
    .pipe(uglify({output: {
      max_line_len: 9000
    }}))
    .pipe(gulp.dest(pkg.directories.js))
    .pipe(livereload());
  ;
});

// Sass
gulp.task('sass', function(cb) {
  return gulp.src(pkg.directories.sass + '/**/*.scss')
    .pipe(plumber({errorHandler: onError}))
    .pipe(sass({outputStyle: 'compact'}).on('error', sass.logError))
    .pipe(gulp.dest(pkg.directories.css))
  ;
  cb(err);
});

// PostCSS
gulp.task('postcss',['sass'], function (cb) {
  return gulp.src(pkg.directories.css + '/styles.css')
    .pipe( postcss([ autoprefixer({browsers: ['last 2 versions', '> 2%', 'ie 8', 'ie 9']})]) )
    .pipe( gulp.dest(pkg.directories.css) )
    .pipe( postcss([ rtlcss ]) )
    .pipe(rename('rtl.css'))
    .pipe( gulp.dest(pkg.directories.css) )
  ;
  cb(err);
});

gulp.task('oldie',['postcss'], function () {
  var css = gulp.src(pkg.directories.css + '/*.css')
    .pipe(replace(/(\n)\s*\n/g, '$1'))
  ;

  var oldie = css.pipe(clone())
    .pipe(replace(/\/\*#.+?\*\//g, ''))
    .pipe(replace(/@media[^\{]+tty[^\{]+\{ (.+ \}) \}(\s*)/g, '$1$2'))
    .pipe(replace(/(@media[^\{]+device-pixel-ratio[^\{]+\{ [\s\S]+? \} \}\s*)/g, ''))
    .pipe(replace(/(@media screen) [^\{]+ \(max-width: \d+px\)( \{ [\s\S]+? \} \}\s*)/g, ''))
    .pipe(replace(/(@media screen) and \(.+?\)( \{ [\s\S]+? \} \}\s*)/g, '$1$2'))
    .pipe(replace(/-(moz|webkit)-[^\{]+?:.+?;\s*/g, ''))
    .pipe(replace(/(transition|border-[\S]*radius):.+?;\s*/g, ''))
    .pipe(replace(/opacity: 0;\s*/g, 'visibility: hidden; '))
    .pipe(replace(/opacity: 1;\s*/g, 'visibility: visible; '))
    .pipe(replace(/rgba(\(.+?),\s?[\d\.]+(\))/g, 'rgb$1$2'))
    .pipe(replace(/\s\S+\s?\{\s+\}/g, ''))
    .pipe(replace(/([\d\.]+)vw/g, function (regexMatches) {
      return Math.round(parseFloat(regexMatches[0]) * 10.24) + 'px'; // matches 1024px
    }))
    .pipe(replace(/([\d\.]+)vh/g, function (regexMatches) {
      return Math.round(parseFloat(regexMatches[0]) * 7.68) + 'px'; // matches 768 px
    }))
    .pipe(replace(/([\d\.]+)rem/g, function (regexMatches) {
      return Math.round(parseFloat(regexMatches[0]) * 12) + 'px'; // matches $fontsize-default
    }))
    .pipe( gulp.dest(pkg.directories.css + '/oldie') )
  ;

  return css
    .pipe(replace(/(@media[^\{]+tty[^\{]+\{ [\s\S]+? \} \}\s*)/g, ''))
    .pipe( gulp.dest(pkg.directories.css) )
    .pipe(livereload());
  ;
});

gulp.task('appcache', function(){
  gulp.src([
    pkg.directories.template + '/**/*',
    '!'+pkg.directories.template + '/*.html',
    '!'+pkg.directories.images + '/article*/*',
    '!'+pkg.directories.images + '/originals/*',
    '!'+pkg.directories.css + '/oldie/*'
  ])
  .pipe(appcache({
    //relativePath: pkg.directories.template,
    hash: true,
    preferOnline: true,
    filename: 'manifest.appcache',
    exclude: 'manifest.appcache'
  }))
  .pipe(gulp.dest(pkg.directories.template));
});

gulp.task('logo', function() {
  var logo = gulp.src(pkg.directories.images + '/logo.png');

  [
    {
      width: 32,
      height: 32,
      name: 'favicon.ico',
      directory: pkg.directories.template
    },{
      width: 96,
      height: 96,
      name: 'favicon-96x96.png',
      directory: pkg.directories.template
    },{
      width: 152,
      height: 152,
      name: 'apple-touch-icon-precomposed.png',
      directory: pkg.directories.template
    },{
      width: 196,
      height: 196,
      name: 'favicon-196x196.png',
      directory: pkg.directories.template
    },{
      width: 128,
      height: 128,
      name: 'tile-128x128.png',
      directory: pkg.directories.images
    },{
      width: 270,
      height: 270,
      name: 'tile-270x270.png',
      directory: pkg.directories.images
    },{
      width: 558,
      height: 270,
      name: 'tile-558x270.png',
      directory: pkg.directories.images
    },{
      width: 558,
      height: 558,
      name: 'tile-558x558.png',
      directory: pkg.directories.images
    }
  ].forEach(function(i) {
    logo.pipe(clone())
      .pipe(imageResize({
        width: i.width,
        height: i.height,
        crop: true,
        quality: 0.7,
        gravity: 'Center',
        imageMagick: true
      }))
      .pipe(rename(i.name))
      .pipe(gulp.dest(i.directory))
    ;
  })
  return logo;
});

gulp.task('article_images', function() {
  var article_images = gulp.src(pkg.directories.images + '/originals/*.jpg');

  [{ width: 640, height: 360 },{ width: 1280, height: 720 }].forEach(function(i) {
    article_images.pipe(clone())
      .pipe(imageResize({
        width: i.width,
        height: i.height,
        crop: true,
        quality: 0.7,
        gravity: 'Center',
        imageMagick: true
      }))
      .pipe(gulp.dest(pkg.directories.images + '/articles-'+i.width))
    ;
  });
  return article_images;
});

gulp.task('deploy_live', shell.task([
  pkg.directories.build + '/deploy.sh live'
]));
gulp.task('vagrant_up', shell.task([
  'cd ' + pkg.directories.build + '/vagrant && vagrant up && cd -'
]));
gulp.task('vagrant_suspend', shell.task([
  'cd ' + pkg.directories.build + '/vagrant && vagrant suspend && cd -'
]));

// Watch Files For Changes
gulp.task('watch', function() {
  livereload.listen();
  gulp.watch(['gulpfile.js','package.json'], process.exit);
  gulp.watch(pkg.directories.js_src + '/**/*.js', ['build-js']);
  gulp.watch(pkg.directories.sass + '/**/*.scss', ['build-sass']);
  gulp.watch(pkg.directories.images + '/logo.png', ['build-icons']);
  gulp.watch(pkg.directories.images + '/originals/*.jpg', ['build-article-images']);
});

// Default Task
gulp.task('default',     ['build-js','build-sass','build-icons']);
gulp.task('build-sass',  ['sass','postcss','oldie','appcache']);
gulp.task('build-js',    ['jshint','uglify','appcache']);
gulp.task('build-icons', ['logo','appcache']);
gulp.task('build-article-images',    ['article_images','appcache']);
<|endoftext|>


<commit_before>(function(){
	'use strict';

	var gulp = require('gulp'),
		Merge = require('streamqueue'),
		argv = require('yargs').argv,
		$ = require('gulp-load-plugins')({
			rename: {
				'gulp-sass': 'sass',
				'gulp-minify-css': 'minifycss'
			},
			lazy: false
		});

	/* Combine Sass / Libraries */
	gulp.task('styles', function() {
		var style = gulp.src('src/scss/*.scss');

		return style
			.pipe($.sass({ outputStyle: 'compressed', errLogToConsole: true }))
			.pipe($.autoprefixer({ browsers: ['last 2 version'] }))
			.pipe($.if(argv.prod, $.minifycss()))
			.pipe(gulp.dest('dist/css'))
			.pipe($.notify({ message: 'Styles Task Completed' }));
	});

	/* Main Script / Libraries */
	gulp.task('scripts-main', function() {
		var notify = gulp.src('src/js/play-midnight-notify.js'),
				utils = gulp.src('src/js/play-midnight-utils.js'),
				script = gulp.src('src/js/play-midnight.js'),
				merged;

		merged = new Merge({ objectMode: true });
		merged.queue(utils);
		merged.queue(notify);
		merged.queue(script);

		return merged.done()
			.pipe($.jshint())
			.pipe($.jshint.reporter('default'))
			.pipe($.concat('play-midnight.js'))
			.pipe($.if(argv.prod, $.uglify()))
			.pipe(gulp.dest('dist/js'))
			.pipe($.notify({ message: 'Main Scripts Task Completed' }));
	});

	/* Background Script */
	gulp.task('scripts-bg', function() {
		var script = gulp.src('src/js/background.js');

		return script
			.pipe($.jshint())
			.pipe($.jshint.reporter('default'))
			.pipe($.if(argv.prod, $.uglify()))
			.pipe(gulp.dest('dist/js'))
			.pipe($.notify({ message: 'Background Scripts Task Completed' }));
	});

	/* Images Script */
	gulp.task('images', function() {
		var images = gulp.src('src/images/**/*');

		return images
			.pipe(gulp.dest('dist/images'))
			.pipe($.notify({ message: 'Images Task Completed' }));
	});

	/* HTML Script */
	gulp.task('html', function() {
		var html = gulp.src('src/**/*.html');

		return html
			.pipe(gulp.dest('dist'))
			.pipe($.notify({ message: 'HTML Task Completed' }));
	});

	/* Watch File Changes */
	gulp.task('watch', function() {
		gulp.watch('src/scss/**/*.scss', ['styles']);
		gulp.watch('src/js/**/play-midnight*.js', ['scripts-main']);
		gulp.watch('src/js/**/background.js', ['scripts-bg']);
		gulp.watch('src/images/**/*', ['images']);
		gulp.watch('src/**/*.html', ['html']);
	});

	/* Default Task */
	gulp.task('default', function() {
		gulp.start('styles', 'scripts-main', 'scripts-bg', 'images', 'html');
	});
}());
<commit_msg>Updated gulp for new utility files<commit_after>(function(){
	'use strict';

	var gulp = require('gulp'),
		Merge = require('streamqueue'),
		argv = require('yargs').argv,
		$ = require('gulp-load-plugins')({
			rename: {
				'gulp-sass': 'sass',
				'gulp-minify-css': 'minifycss'
			},
			lazy: false
		});

	/* Combine Sass / Libraries */
	gulp.task('styles', function() {
		var style = gulp.src('src/scss/*.scss');

		return style
			.pipe($.sass({ outputStyle: 'compressed', errLogToConsole: true }))
			.pipe($.autoprefixer({ browsers: ['last 2 version'] }))
			.pipe($.if(argv.prod, $.minifycss()))
			.pipe(gulp.dest('dist/css'))
			.pipe($.notify({ message: 'Styles Task Completed' }));
	});

	/* Main Script / Libraries */
	gulp.task('scripts-main', function() {
		var modal = gulp.src('src/js/play-midnight-modal.js'),
				options = gulp.src('src/js/play-midnight-options.js'),
				utils = gulp.src('src/js/play-midnight-utils.js'),
				script = gulp.src('src/js/play-midnight.js'),
				merged;

		merged = new Merge({ objectMode: true });
		merged.queue(utils);
		merged.queue(options);
		merged.queue(modal);
		merged.queue(script);

		return merged.done()
			.pipe($.jshint())
			.pipe($.jshint.reporter('default'))
			.pipe($.concat('play-midnight.js'))
			.pipe($.if(argv.prod, $.uglify()))
			.pipe(gulp.dest('dist/js'))
			.pipe($.notify({ message: 'Main Scripts Task Completed' }));
	});

	/* Background Script */
	gulp.task('scripts-bg', function() {
		var script = gulp.src('src/js/background.js');

		return script
			.pipe($.jshint())
			.pipe($.jshint.reporter('default'))
			.pipe($.if(argv.prod, $.uglify()))
			.pipe(gulp.dest('dist/js'))
			.pipe($.notify({ message: 'Background Scripts Task Completed' }));
	});

	/* Images Script */
	gulp.task('images', function() {
		var images = gulp.src('src/images/**/*');

		return images
			.pipe(gulp.dest('dist/images'))
			.pipe($.notify({ message: 'Images Task Completed' }));
	});

	/* HTML Script */
	gulp.task('html', function() {
		var html = gulp.src('src/**/*.html');

		return html
			.pipe(gulp.dest('dist'))
			.pipe($.notify({ message: 'HTML Task Completed' }));
	});

	/* Watch File Changes */
	gulp.task('watch', function() {
		gulp.watch('src/scss/**/*.scss', ['styles']);
		gulp.watch('src/js/**/play-midnight*.js', ['scripts-main']);
		gulp.watch('src/js/**/background.js', ['scripts-bg']);
		gulp.watch('src/images/**/*', ['images']);
		gulp.watch('src/**/*.html', ['html']);
	});

	/* Default Task */
	gulp.task('default', function() {
		gulp.start('styles', 'scripts-main', 'scripts-bg', 'images', 'html');
	});
}());
<|endoftext|>


<commit_before>/***
 * Contains basic SlickGrid editors.
 * @module Formatters
 * @namespace Slick
 */

(function ($) {
  // register namespace
  $.extend(true, window, {
    "Slick": {
      "Editors": {
        "Text": TextEditor,
        "Integer": IntegerEditor,
        "Date": DateEditor,
        "YesNoSelect": YesNoSelectEditor,
        "Checkbox": CheckboxEditor,
        "PercentComplete": PercentCompleteEditor,
        "LongText": LongTextEditor
      }
    }
  });

    function TextEditor(args) {
      var $input;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-text' />")
            .appendTo(args.container)
            .bind("keydown.nav", function (e) {
              if (e.keyCode === $.ui.keyCode.LEFT || e.keyCode === $.ui.keyCode.RIGHT) {
                e.stopImmediatePropagation();
              }
            })
            .focus()
            .select();
      };

      this.destroy = function () {
        $input.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.getValue = function () {
        return $input.val();
      };

      this.setValue = function (val) {
        $input.val(val);
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field] || "";
        $input.val(defaultValue);
        $input[0].defaultValue = defaultValue;
        $input.select();
      };

      this.serializeValue = function () {
        return $input.val();
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        if (args.column.validator) {
          var validationResults = args.column.validator($input.val());
          if (!validationResults.valid) {
            return validationResults;
          }
        }

        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function IntegerEditor(args) {
      var $input;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-text' />");

        $input.bind("keydown.nav", function (e) {
          if (e.keyCode === $.ui.keyCode.LEFT || e.keyCode === $.ui.keyCode.RIGHT) {
            e.stopImmediatePropagation();
          }
        });

        $input.appendTo(args.container);
        $input.focus().select();
      };

      this.destroy = function () {
        $input.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field];
        $input.val(defaultValue);
        $input[0].defaultValue = defaultValue;
        $input.select();
      };

      this.serializeValue = function () {
        return parseInt($input.val(), 10) || 0;
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        if (isNaN($input.val())) {
          return {
            valid: false,
            msg: "Please enter a valid integer"
          };
        }

        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function DateEditor(args) {
      var $input;
      var defaultValue;
      var scope = this;
      var calendarOpen = false;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-text' />");
        $input.appendTo(args.container);
        $input.focus().select();
        $input.datepicker({
          showOn: "button",
          buttonImageOnly: true,
          buttonImage: "../images/calendar.gif",
          beforeShow: function () {
            calendarOpen = true
          },
          onClose: function () {
            calendarOpen = false
          }
        });
        $input.width($input.width() - 18);
      };

      this.destroy = function () {
        $.datepicker.dpDiv.stop(true, true);
        $input.datepicker("hide");
        $input.datepicker("destroy");
        $input.remove();
      };

      this.show = function () {
        if (calendarOpen) {
          $.datepicker.dpDiv.stop(true, true).show();
        }
      };

      this.hide = function () {
        if (calendarOpen) {
          $.datepicker.dpDiv.stop(true, true).hide();
        }
      };

      this.position = function (position) {
        if (!calendarOpen) {
          return;
        }
        $.datepicker.dpDiv
            .css("top", position.top + 30)
            .css("left", position.left);
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field];
        $input.val(defaultValue);
        $input[0].defaultValue = defaultValue;
        $input.select();
      };

      this.serializeValue = function () {
        return $input.val();
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function YesNoSelectEditor(args) {
      var $select;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $select = $("<SELECT tabIndex='0' class='editor-yesno'><OPTION value='yes'>Yes</OPTION><OPTION value='no'>No</OPTION></SELECT>");
        $select.appendTo(args.container);
        $select.focus();
      };

      this.destroy = function () {
        $select.remove();
      };

      this.focus = function () {
        $select.focus();
      };

      this.loadValue = function (item) {
        $select.val((defaultValue = item[args.column.field]) ? "yes" : "no");
        $select.select();
      };

      this.serializeValue = function () {
        return ($select.val() == "yes");
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return ($select.val() != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function CheckboxEditor(args) {
      var $select;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $select = $("<INPUT type=checkbox value='true' class='editor-checkbox' hideFocus>");
        $select.appendTo(args.container);
        $select.focus();
      };

      this.destroy = function () {
        $select.remove();
      };

      this.focus = function () {
        $select.focus();
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field];
        if (defaultValue) {
          $select.attr("checked", "checked");
        } else {
          $select.removeAttr("checked");
        }
      };

      this.serializeValue = function () {
        return $select.attr("checked");
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return ($select.attr("checked") != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function PercentCompleteEditor(args) {
      var $input, $picker;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-percentcomplete' />");
        $input.width($(args.container).innerWidth() - 25);
        $input.appendTo(args.container);

        $picker = $("
").appendTo(args.container);
        $picker.append("

");

        $picker.find(".editor-percentcomplete-buttons").append("<button val=0>Not started</button>
<button val=50>In Progress</button>
<button val=100>Complete</button>");

        $input.focus().select();

        $picker.find(".editor-percentcomplete-slider").slider({
          orientation: "vertical",
          range: "min",
          value: defaultValue,
          slide: function (event, ui) {
            $input.val(ui.value)
          }
        });

        $picker.find(".editor-percentcomplete-buttons button").bind("click", function (e) {
          $input.val($(this).attr("val"));
          $picker.find(".editor-percentcomplete-slider").slider("value", $(this).attr("val"));
        })
      };

      this.destroy = function () {
        $input.remove();
        $picker.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        $input.val(defaultValue = item[args.column.field]);
        $input.select();
      };

      this.serializeValue = function () {
        return parseInt($input.val(), 10) || 0;
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ((parseInt($input.val(), 10) || 0) != defaultValue);
      };

      this.validate = function () {
        if (isNaN(parseInt($input.val(), 10))) {
          return {
            valid: false,
            msg: "Please enter a valid positive number"
          };
        }

        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    /*
     * An example of a "detached" editor.
     * The UI is added onto document BODY and .position(), .show() and .hide() are implemented.
     * KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
     */
    function LongTextEditor(args) {
      var $input, $wrapper;
      var defaultValue;
      var scope = this;

      this.init = function () {
        var $container = $("body");

        $wrapper = $("
")
            .appendTo($container);

        $input = $("<TEXTAREA hidefocus rows=5 style='backround:white;width:250px;height:80px;border:0;outline:0'>")
            .appendTo($wrapper);

        $("
<BUTTON>Save</BUTTON><BUTTON>Cancel</BUTTON>
")
            .appendTo($wrapper);

        $wrapper.find("button:first").bind("click", this.save);
        $wrapper.find("button:last").bind("click", this.cancel);
        $input.bind("keydown", this.handleKeyDown);

        scope.position(args.position);
        $input.focus().select();
      };

      this.handleKeyDown = function (e) {
        if (e.which == $.ui.keyCode.ENTER && e.ctrlKey) {
          scope.save();
        } else if (e.which == $.ui.keyCode.ESCAPE) {
          e.preventDefault();
          scope.cancel();
        } else if (e.which == $.ui.keyCode.TAB && e.shiftKey) {
          e.preventDefault();
          grid.navigatePrev();
        } else if (e.which == $.ui.keyCode.TAB) {
          e.preventDefault();
          grid.navigateNext();
        }
      };

      this.save = function () {
        args.commitChanges();
      };

      this.cancel = function () {
        $input.val(defaultValue);
        args.cancelChanges();
      };

      this.hide = function () {
        $wrapper.hide();
      };

      this.show = function () {
        $wrapper.show();
      };

      this.position = function (position) {
        $wrapper
            .css("top", position.top - 5)
            .css("left", position.left - 5)
      };

      this.destroy = function () {
        $wrapper.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        $input.val(defaultValue = item[args.column.field]);
        $input.select();
      };

      this.serializeValue = function () {
        return $input.val();
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }
})(jQuery);
<commit_msg>Corrected a copy'n'paste error.<commit_after>/***
 * Contains basic SlickGrid editors.
 * @module Editors
 * @namespace Slick
 */

(function ($) {
  // register namespace
  $.extend(true, window, {
    "Slick": {
      "Editors": {
        "Text": TextEditor,
        "Integer": IntegerEditor,
        "Date": DateEditor,
        "YesNoSelect": YesNoSelectEditor,
        "Checkbox": CheckboxEditor,
        "PercentComplete": PercentCompleteEditor,
        "LongText": LongTextEditor
      }
    }
  });

    function TextEditor(args) {
      var $input;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-text' />")
            .appendTo(args.container)
            .bind("keydown.nav", function (e) {
              if (e.keyCode === $.ui.keyCode.LEFT || e.keyCode === $.ui.keyCode.RIGHT) {
                e.stopImmediatePropagation();
              }
            })
            .focus()
            .select();
      };

      this.destroy = function () {
        $input.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.getValue = function () {
        return $input.val();
      };

      this.setValue = function (val) {
        $input.val(val);
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field] || "";
        $input.val(defaultValue);
        $input[0].defaultValue = defaultValue;
        $input.select();
      };

      this.serializeValue = function () {
        return $input.val();
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        if (args.column.validator) {
          var validationResults = args.column.validator($input.val());
          if (!validationResults.valid) {
            return validationResults;
          }
        }

        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function IntegerEditor(args) {
      var $input;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-text' />");

        $input.bind("keydown.nav", function (e) {
          if (e.keyCode === $.ui.keyCode.LEFT || e.keyCode === $.ui.keyCode.RIGHT) {
            e.stopImmediatePropagation();
          }
        });

        $input.appendTo(args.container);
        $input.focus().select();
      };

      this.destroy = function () {
        $input.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field];
        $input.val(defaultValue);
        $input[0].defaultValue = defaultValue;
        $input.select();
      };

      this.serializeValue = function () {
        return parseInt($input.val(), 10) || 0;
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        if (isNaN($input.val())) {
          return {
            valid: false,
            msg: "Please enter a valid integer"
          };
        }

        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function DateEditor(args) {
      var $input;
      var defaultValue;
      var scope = this;
      var calendarOpen = false;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-text' />");
        $input.appendTo(args.container);
        $input.focus().select();
        $input.datepicker({
          showOn: "button",
          buttonImageOnly: true,
          buttonImage: "../images/calendar.gif",
          beforeShow: function () {
            calendarOpen = true
          },
          onClose: function () {
            calendarOpen = false
          }
        });
        $input.width($input.width() - 18);
      };

      this.destroy = function () {
        $.datepicker.dpDiv.stop(true, true);
        $input.datepicker("hide");
        $input.datepicker("destroy");
        $input.remove();
      };

      this.show = function () {
        if (calendarOpen) {
          $.datepicker.dpDiv.stop(true, true).show();
        }
      };

      this.hide = function () {
        if (calendarOpen) {
          $.datepicker.dpDiv.stop(true, true).hide();
        }
      };

      this.position = function (position) {
        if (!calendarOpen) {
          return;
        }
        $.datepicker.dpDiv
            .css("top", position.top + 30)
            .css("left", position.left);
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field];
        $input.val(defaultValue);
        $input[0].defaultValue = defaultValue;
        $input.select();
      };

      this.serializeValue = function () {
        return $input.val();
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function YesNoSelectEditor(args) {
      var $select;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $select = $("<SELECT tabIndex='0' class='editor-yesno'><OPTION value='yes'>Yes</OPTION><OPTION value='no'>No</OPTION></SELECT>");
        $select.appendTo(args.container);
        $select.focus();
      };

      this.destroy = function () {
        $select.remove();
      };

      this.focus = function () {
        $select.focus();
      };

      this.loadValue = function (item) {
        $select.val((defaultValue = item[args.column.field]) ? "yes" : "no");
        $select.select();
      };

      this.serializeValue = function () {
        return ($select.val() == "yes");
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return ($select.val() != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function CheckboxEditor(args) {
      var $select;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $select = $("<INPUT type=checkbox value='true' class='editor-checkbox' hideFocus>");
        $select.appendTo(args.container);
        $select.focus();
      };

      this.destroy = function () {
        $select.remove();
      };

      this.focus = function () {
        $select.focus();
      };

      this.loadValue = function (item) {
        defaultValue = item[args.column.field];
        if (defaultValue) {
          $select.attr("checked", "checked");
        } else {
          $select.removeAttr("checked");
        }
      };

      this.serializeValue = function () {
        return $select.attr("checked");
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return ($select.attr("checked") != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    function PercentCompleteEditor(args) {
      var $input, $picker;
      var defaultValue;
      var scope = this;

      this.init = function () {
        $input = $("<INPUT type=text class='editor-percentcomplete' />");
        $input.width($(args.container).innerWidth() - 25);
        $input.appendTo(args.container);

        $picker = $("
").appendTo(args.container);
        $picker.append("

");

        $picker.find(".editor-percentcomplete-buttons").append("<button val=0>Not started</button>
<button val=50>In Progress</button>
<button val=100>Complete</button>");

        $input.focus().select();

        $picker.find(".editor-percentcomplete-slider").slider({
          orientation: "vertical",
          range: "min",
          value: defaultValue,
          slide: function (event, ui) {
            $input.val(ui.value)
          }
        });

        $picker.find(".editor-percentcomplete-buttons button").bind("click", function (e) {
          $input.val($(this).attr("val"));
          $picker.find(".editor-percentcomplete-slider").slider("value", $(this).attr("val"));
        })
      };

      this.destroy = function () {
        $input.remove();
        $picker.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        $input.val(defaultValue = item[args.column.field]);
        $input.select();
      };

      this.serializeValue = function () {
        return parseInt($input.val(), 10) || 0;
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ((parseInt($input.val(), 10) || 0) != defaultValue);
      };

      this.validate = function () {
        if (isNaN(parseInt($input.val(), 10))) {
          return {
            valid: false,
            msg: "Please enter a valid positive number"
          };
        }

        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }

    /*
     * An example of a "detached" editor.
     * The UI is added onto document BODY and .position(), .show() and .hide() are implemented.
     * KeyDown events are also handled to provide handling for Tab, Shift-Tab, Esc and Ctrl-Enter.
     */
    function LongTextEditor(args) {
      var $input, $wrapper;
      var defaultValue;
      var scope = this;

      this.init = function () {
        var $container = $("body");

        $wrapper = $("
")
            .appendTo($container);

        $input = $("<TEXTAREA hidefocus rows=5 style='backround:white;width:250px;height:80px;border:0;outline:0'>")
            .appendTo($wrapper);

        $("
<BUTTON>Save</BUTTON><BUTTON>Cancel</BUTTON>
")
            .appendTo($wrapper);

        $wrapper.find("button:first").bind("click", this.save);
        $wrapper.find("button:last").bind("click", this.cancel);
        $input.bind("keydown", this.handleKeyDown);

        scope.position(args.position);
        $input.focus().select();
      };

      this.handleKeyDown = function (e) {
        if (e.which == $.ui.keyCode.ENTER && e.ctrlKey) {
          scope.save();
        } else if (e.which == $.ui.keyCode.ESCAPE) {
          e.preventDefault();
          scope.cancel();
        } else if (e.which == $.ui.keyCode.TAB && e.shiftKey) {
          e.preventDefault();
          grid.navigatePrev();
        } else if (e.which == $.ui.keyCode.TAB) {
          e.preventDefault();
          grid.navigateNext();
        }
      };

      this.save = function () {
        args.commitChanges();
      };

      this.cancel = function () {
        $input.val(defaultValue);
        args.cancelChanges();
      };

      this.hide = function () {
        $wrapper.hide();
      };

      this.show = function () {
        $wrapper.show();
      };

      this.position = function (position) {
        $wrapper
            .css("top", position.top - 5)
            .css("left", position.left - 5)
      };

      this.destroy = function () {
        $wrapper.remove();
      };

      this.focus = function () {
        $input.focus();
      };

      this.loadValue = function (item) {
        $input.val(defaultValue = item[args.column.field]);
        $input.select();
      };

      this.serializeValue = function () {
        return $input.val();
      };

      this.applyValue = function (item, state) {
        item[args.column.field] = state;
      };

      this.isValueChanged = function () {
        return (!($input.val() == "" && defaultValue == null)) && ($input.val() != defaultValue);
      };

      this.validate = function () {
        return {
          valid: true,
          msg: null
        };
      };

      this.init();
    }
})(jQuery);
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    path = require('path'),
    es = require('event-stream'),
    jshint = require('gulp-jshint'),
    clean = require('gulp-clean'),
    less = require('gulp-less'),
    rebaseUrls = require('gulp-css-rebase-urls'),
    urlAdjuster = require('gulp-css-url-adjuster'),
    minifyCSS = require('gulp-minify-css'),
    autoprefix = require('gulp-autoprefixer'),
    browserify = require('browserify'),
    source = require('vinyl-source-stream'),
    inject = require('gulp-inject'),
    sourcemaps = require('gulp-sourcemaps'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    ngMin = require('gulp-ngmin'),
    html2js = require('gulp-html2js'),
    minifyHTML = require('gulp-minify-html'),
    runSequence = require('run-sequence'),
    watch = require('gulp-watch'),
    changed = require('gulp-changed'),
    livereload = require('gulp-livereload');

var pkg = require('./package.json'),
    cfg = require('./build.config.js');

//------------------------------------------------------------------------------
// DEFAULT
//------------------------------------------------------------------------------

gulp.task('default', ['compile']);

//------------------------------------------------------------------------------
// BUILD
//------------------------------------------------------------------------------

gulp.task('build-clean', function () {
    return gulp.src(cfg.build_dir, {read: false}).pipe(clean());
});

gulp.task('build-vendor', function () {

    var bowerAssets = gulp.src(cfg.vendor_files.assets, {cwd: cfg.bower_dir + '/**'});
    var bowerCSS = gulp.src(cfg.vendor_files.css, {cwd: cfg.bower_dir + '/**'});
    var bowerJS = gulp.src(cfg.vendor_files.js, {cwd: cfg.bower_dir + '/**'});

    return es.merge( bowerAssets, bowerCSS, bowerJS )
        .pipe(gulp.dest(cfg.build_dir + '/vendor'));
});

gulp.task('build-assets', function () {

    return gulp.src(cfg.source_files.assets)
        .pipe(changed(cfg.build_dir + '/assets'))
        .pipe(gulp.dest(cfg.build_dir + '/assets'));
});

gulp.task('build-css', function () {

    return gulp.src( cfg.source_files.less.all )
        //.pipe(changed(cfg.build_dir))
        .pipe(sourcemaps.init())
        .pipe(less({
            paths: [ path.join( __dirname, 'less', 'includes' ) ]
        }))
        .pipe(autoprefix('last 2 versions'))
        .pipe(concat(pkg.name + '-' + pkg.version + '.css'))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(cfg.build_dir));
});

gulp.task('build-templates', function () {

    gulp.src( cfg.source_files.html.tpl )
        .pipe(html2js({
            base: 'src',
            outputModuleName: 'appTemplates'
        }))
        .pipe( concat(pkg.name + '-' + pkg.version + '-templates.js') )
        .pipe( gulp.dest( cfg.build_dir ) );
});

gulp.task('build-lint', function () {

    return gulp.src( cfg.source_files.js.all )
        .pipe(changed(cfg.build_dir))
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('build-js', ['build-lint'], function () {

    return gulp.src( cfg.source_files.js.all )
        .pipe(changed(cfg.build_dir))
        .pipe(gulp.dest(cfg.build_dir));
});

gulp.task('build-index', function () {

    var vendorCSS = gulp.src( cfg.vendor_files.css, {cwd: path.join(__dirname, cfg.build_dir, 'vendor'), read: false} );
    var vendorJS = gulp.src( cfg.vendor_files.js, {cwd: path.join(__dirname, cfg.build_dir, 'vendor'), read: false} );
    var appCSS = gulp.src([cfg.build_dir + '/**/*.css', '!' + cfg.build_dir + '/vendor/**/*'], {read: false});
    var appJS = gulp.src([cfg.build_dir + '/**/*.js', '!' + cfg.build_dir + '/vendor/**/*'], {read: false});

    return gulp.src( cfg.source_files.html.index )
        .pipe( inject( es.merge( vendorCSS, vendorJS ), { addPrefix: 'vendor', addRootSlash: false, starttag: '<!-- inject:vendor:{{ext}} -->' } ))
        .pipe( inject( es.merge( appCSS, appJS ), { ignorePath: cfg.build_dir, addRootSlash: false } ))
        .pipe(gulp.dest(cfg.build_dir));
});

gulp.task('build', function ( cb ) {
    runSequence(
        'build-clean',
        ['build-vendor', 'build-assets', 'build-css', 'build-templates', 'build-js'],
        'build-index',
        cb
    );
});

//------------------------------------------------------------------------------
// WATCH
//------------------------------------------------------------------------------

gulp.task('watch', ['build'], function () {

    livereload.listen();

    gulp.watch(cfg.source_files.assets, ['build-assets'])
    .on('change', function ( event ) {
        if( event.type === 'renamed' || event.type === 'deleted' ) {
            var pathParts = (event.old || event.path).split(path.sep);
            var deletePath = pathParts.slice(pathParts.indexOf('src') + 1).join(path.sep);
            gulp.src(deletePath, {cwd: cfg.build_dir}).pipe(clean());
        }
    });
    gulp.watch(cfg.source_files.less.all, ['build-css']);
    gulp.watch(cfg.source_files.html.tpl, ['build-templates']);
    gulp.watch(cfg.source_files.js.all, [])
    .on('change', function ( event ) {
        if( event.type === 'added' || event.type === 'renamed' || event.type === 'deleted' ) {
            if( event.type === 'renamed' || event.type === 'deleted' ) {
                var pathParts = (event.old || event.path).split(path.sep);
                var deletePath = pathParts.slice(pathParts.indexOf('src') + 1).join(path.sep);
                gulp.src(deletePath, {cwd: cfg.build_dir}).pipe(clean());
            }
            runSequence( 'build-js', 'build-index', function(){} );
        } else {
            runSequence( 'build-js', function(){} );
        }
    });
    gulp.watch(cfg.source_files.html.index, ['build-index']);

    gulp.watch(cfg.build_dir + '/**', livereload.changed);
});

//------------------------------------------------------------------------------
// COMPILE
//------------------------------------------------------------------------------

// Clear the compile directory.
gulp.task('compile-clean', function () {
    return gulp.src(cfg.compile_dir, {read: false}).pipe(clean());
});

gulp.task('assets', function () {

    var bowerAssets = gulp.src(cfg.vendor_files.assets, {cwd: cfg.bower_dir + '/**'});

    var appAssets = gulp.src(cfg.source_files.assets);

    return es.merge( bowerAssets, appAssets )
        .pipe(gulp.dest(cfg.compile_dir + '/assets'));
});

gulp.task('css', function () {

    var bowerCSS = gulp.src(cfg.vendor_files.css, {cwd: cfg.bower_dir})
        .pipe(rebaseUrls())
        .pipe(urlAdjuster({prepend: 'assets/'}));

    var appCSS = gulp.src( cfg.source_files.less.all )
        .pipe(less({
            paths: [ path.join( __dirname, 'less', 'includes' ) ]
        }))
        .pipe(autoprefix('last 2 versions'));

    return es.merge( bowerCSS, appCSS )
        .pipe(concat(pkg.name + '-' + pkg.version + '.min.css'))
        .pipe(minifyCSS({ keepSpecialComments: 0 }))
        .pipe(gulp.dest(cfg.compile_dir));

});

gulp.task('lint', function () {

    return gulp.src( cfg.source_files.js.all )
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('js', ['lint'], function () {

    var bowerJS = gulp.src(cfg.vendor_files.js, {cwd: cfg.bower_dir});

    var templateJS = gulp.src( cfg.source_files.html.tpl )
        .pipe(minifyHTML({empty: true}))
        .pipe(html2js({
            base: 'src',
            outputModuleName: 'appTemplates'
        }));

    var appJS = gulp.src( cfg.source_files.js.all )
        .pipe(ngMin());

    return es.merge( bowerJS, templateJS, appJS )
        .pipe(concat(pkg.name + '-' + pkg.version + '.min.js'))
        .pipe(uglify({mangle: false}))
        .pipe(gulp.dest(cfg.compile_dir));
});

gulp.task('index', function () {
    return gulp.src(cfg.source_files.html.index)
        .pipe(inject(
            gulp.src(cfg.compile_dir + '/**/*.{css,js}', {read: false}),
            {
                addRootSlash: false,
                ignorePath: cfg.compile_dir
            }
        ))
        .pipe(minifyHTML({empty: true}))
        .pipe(gulp.dest(cfg.compile_dir));
});

gulp.task('compile', function ( cb ) {
    runSequence(
        'compile-clean',
        ['assets', 'css', 'js'],
        ['index'],
        cb
    );
});<commit_msg>Fix build_dir watching so livereload won't be triggered by root level file changes.<commit_after>var gulp = require('gulp'),
    path = require('path'),
    es = require('event-stream'),
    jshint = require('gulp-jshint'),
    clean = require('gulp-clean'),
    less = require('gulp-less'),
    rebaseUrls = require('gulp-css-rebase-urls'),
    urlAdjuster = require('gulp-css-url-adjuster'),
    minifyCSS = require('gulp-minify-css'),
    autoprefix = require('gulp-autoprefixer'),
    browserify = require('browserify'),
    source = require('vinyl-source-stream'),
    inject = require('gulp-inject'),
    sourcemaps = require('gulp-sourcemaps'),
    concat = require('gulp-concat'),
    uglify = require('gulp-uglify'),
    ngMin = require('gulp-ngmin'),
    html2js = require('gulp-html2js'),
    minifyHTML = require('gulp-minify-html'),
    runSequence = require('run-sequence'),
    watch = require('gulp-watch'),
    changed = require('gulp-changed'),
    livereload = require('gulp-livereload');

var pkg = require('./package.json'),
    cfg = require('./build.config.js');

//------------------------------------------------------------------------------
// DEFAULT
//------------------------------------------------------------------------------

gulp.task('default', ['compile']);

//------------------------------------------------------------------------------
// BUILD
//------------------------------------------------------------------------------

gulp.task('build-clean', function () {
    return gulp.src(cfg.build_dir, {read: false}).pipe(clean());
});

gulp.task('build-vendor', function () {

    var bowerAssets = gulp.src(cfg.vendor_files.assets, {cwd: cfg.bower_dir + '/**'});
    var bowerCSS = gulp.src(cfg.vendor_files.css, {cwd: cfg.bower_dir + '/**'});
    var bowerJS = gulp.src(cfg.vendor_files.js, {cwd: cfg.bower_dir + '/**'});

    return es.merge( bowerAssets, bowerCSS, bowerJS )
        .pipe(gulp.dest(cfg.build_dir + '/vendor'));
});

gulp.task('build-assets', function () {

    return gulp.src(cfg.source_files.assets)
        .pipe(changed(cfg.build_dir + '/assets'))
        .pipe(gulp.dest(cfg.build_dir + '/assets'));
});

gulp.task('build-css', function () {

    return gulp.src( cfg.source_files.less.all )
        //.pipe(changed(cfg.build_dir))
        .pipe(sourcemaps.init())
        .pipe(less({
            paths: [ path.join( __dirname, 'less', 'includes' ) ]
        }))
        .pipe(autoprefix('last 2 versions'))
        .pipe(concat(pkg.name + '-' + pkg.version + '.css'))
        .pipe(sourcemaps.write())
        .pipe(gulp.dest(cfg.build_dir));
});

gulp.task('build-templates', function () {

    gulp.src( cfg.source_files.html.tpl )
        .pipe(html2js({
            base: 'src',
            outputModuleName: 'appTemplates'
        }))
        .pipe( concat(pkg.name + '-' + pkg.version + '-templates.js') )
        .pipe( gulp.dest( cfg.build_dir ) );
});

gulp.task('build-lint', function () {

    return gulp.src( cfg.source_files.js.all )
        .pipe(changed(cfg.build_dir))
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('build-js', ['build-lint'], function () {

    return gulp.src( cfg.source_files.js.all )
        .pipe(changed(cfg.build_dir))
        .pipe(gulp.dest(cfg.build_dir));
});

gulp.task('build-index', function () {

    var vendorCSS = gulp.src( cfg.vendor_files.css, {cwd: path.join(__dirname, cfg.build_dir, 'vendor'), read: false} );
    var vendorJS = gulp.src( cfg.vendor_files.js, {cwd: path.join(__dirname, cfg.build_dir, 'vendor'), read: false} );
    var appCSS = gulp.src([cfg.build_dir + '/**/*.css', '!' + cfg.build_dir + '/vendor/**/*'], {read: false});
    var appJS = gulp.src([cfg.build_dir + '/**/*.js', '!' + cfg.build_dir + '/vendor/**/*'], {read: false});

    return gulp.src( cfg.source_files.html.index )
        .pipe( inject( es.merge( vendorCSS, vendorJS ), { addPrefix: 'vendor', addRootSlash: false, starttag: '<!-- inject:vendor:{{ext}} -->' } ))
        .pipe( inject( es.merge( appCSS, appJS ), { ignorePath: cfg.build_dir, addRootSlash: false } ))
        .pipe(gulp.dest(cfg.build_dir));
});

gulp.task('build', function ( cb ) {
    runSequence(
        'build-clean',
        ['build-vendor', 'build-assets', 'build-css', 'build-templates', 'build-js'],
        'build-index',
        cb
    );
});

//------------------------------------------------------------------------------
// WATCH
//------------------------------------------------------------------------------

gulp.task('watch', ['build'], function () {

    livereload.listen();

    gulp.watch(cfg.source_files.assets, ['build-assets'])
    .on('change', function ( event ) {
        if( event.type === 'renamed' || event.type === 'deleted' ) {
            var pathParts = (event.old || event.path).split(path.sep);
            var deletePath = pathParts.slice(pathParts.indexOf('src') + 1).join(path.sep);
            gulp.src(deletePath, {cwd: cfg.build_dir}).pipe(clean());
        }
    });
    gulp.watch(cfg.source_files.less.all, ['build-css']);
    gulp.watch(cfg.source_files.html.tpl, ['build-templates']);
    gulp.watch(cfg.source_files.js.all, [])
    .on('change', function ( event ) {
        if( event.type === 'added' || event.type === 'renamed' || event.type === 'deleted' ) {
            if( event.type === 'renamed' || event.type === 'deleted' ) {
                var pathParts = (event.old || event.path).split(path.sep);
                var deletePath = pathParts.slice(pathParts.indexOf('src') + 1).join(path.sep);
                gulp.src(deletePath, {cwd: cfg.build_dir}).pipe(clean());
            }
            runSequence( 'build-js', 'build-index', function(){} );
        } else {
            runSequence( 'build-js', function(){} );
        }
    });
    gulp.watch(cfg.source_files.html.index, ['build-index']);

    gulp.watch(cfg.build_dir + '/**/*', livereload.changed);
});

//------------------------------------------------------------------------------
// COMPILE
//------------------------------------------------------------------------------

// Clear the compile directory.
gulp.task('compile-clean', function () {
    return gulp.src(cfg.compile_dir, {read: false}).pipe(clean());
});

gulp.task('assets', function () {

    var bowerAssets = gulp.src(cfg.vendor_files.assets, {cwd: cfg.bower_dir + '/**'});

    var appAssets = gulp.src(cfg.source_files.assets);

    return es.merge( bowerAssets, appAssets )
        .pipe(gulp.dest(cfg.compile_dir + '/assets'));
});

gulp.task('css', function () {

    var bowerCSS = gulp.src(cfg.vendor_files.css, {cwd: cfg.bower_dir})
        .pipe(rebaseUrls())
        .pipe(urlAdjuster({prepend: 'assets/'}));

    var appCSS = gulp.src( cfg.source_files.less.all )
        .pipe(less({
            paths: [ path.join( __dirname, 'less', 'includes' ) ]
        }))
        .pipe(autoprefix('last 2 versions'));

    return es.merge( bowerCSS, appCSS )
        .pipe(concat(pkg.name + '-' + pkg.version + '.min.css'))
        .pipe(minifyCSS({ keepSpecialComments: 0 }))
        .pipe(gulp.dest(cfg.compile_dir));

});

gulp.task('lint', function () {

    return gulp.src( cfg.source_files.js.all )
        .pipe(jshint())
        .pipe(jshint.reporter('default'));
});

gulp.task('js', ['lint'], function () {

    var bowerJS = gulp.src(cfg.vendor_files.js, {cwd: cfg.bower_dir});

    var templateJS = gulp.src( cfg.source_files.html.tpl )
        .pipe(minifyHTML({empty: true}))
        .pipe(html2js({
            base: 'src',
            outputModuleName: 'appTemplates'
        }));

    var appJS = gulp.src( cfg.source_files.js.all )
        .pipe(ngMin());

    return es.merge( bowerJS, templateJS, appJS )
        .pipe(concat(pkg.name + '-' + pkg.version + '.min.js'))
        .pipe(uglify({mangle: false}))
        .pipe(gulp.dest(cfg.compile_dir));
});

gulp.task('index', function () {
    return gulp.src(cfg.source_files.html.index)
        .pipe(inject(
            gulp.src(cfg.compile_dir + '/**/*.{css,js}', {read: false}),
            {
                addRootSlash: false,
                ignorePath: cfg.compile_dir
            }
        ))
        .pipe(minifyHTML({empty: true}))
        .pipe(gulp.dest(cfg.compile_dir));
});

gulp.task('compile', function ( cb ) {
    runSequence(
        'compile-clean',
        ['assets', 'css', 'js'],
        ['index'],
        cb
    );
});<|endoftext|>


<commit_before>// include gulp
var gulp = require('gulp');

// include plug-ins
//var gulpif = require('gulp-if');
//var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
//var gutil = require('gulp-util');

//buildConfig:
var buildConf = require('./build.json');
var sources = ['index.js','{component,application,helper,network,router,store,util,definition}/**/*'];
/**********************
  Linting files
**********************/

// JS and coffee lint task
gulp.task('lint', function() {
  var jshint = require('gulp-jshint');
  var stylish = require('jshint-stylish');
  var coffeelint = require('gulp-coffeelint');
  //Js linting.
  gulp
    .src('./lib/*/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
  //Coffee linting
  gulp
    .src('./lib/*/*.coffee')
    .pipe(coffeelint())
    .pipe(coffeelint.reporter());
});

//Eslint

gulp.task('eslint', function() {
  //gulp eslint 2>lint/lintErrors.txt
  var eslint = require('gulp-eslint');
  var options = {
    "globals": {
      "jQuery": false,
      "$": true,
      "require": true,
      "Backbone": true,
      "Fmk": true,
      "_": true,
      "Promise": true,
      "module": true
    },
    "env": {
      "browser": true,
      "node": true
    },
    rules: {
      "valid-jsdoc": [2, {
      /*  "prefer": {
          "return": "return"
        },*/
        "requireParamDescription": true
      }],
      "quotes": [0]
    }
  };
  var format = "compact"; //"compact", "checkstyle", "jslint-xml", "junit" and "tap".
  gulp
    .src(sources)
    .pipe(eslint(options))
  //.pipe(eslint.format(undefined, process.stdout))
  //.pipe(eslint.failOnError())
  .pipe(eslint.formatEach(format, process.stderr));
  //.on('error', gutil.log);
});

/*********************
Documentation generation using jsDoc
***/
// JS and coffee lint task
gulp.task('jsdoc', function() {
  var jsdoc = require('gulp-jsdoc');
  var infos = require('./package.json');
  var name = 'focus';
  //Js linting.
  gulp.src([
    './lib/helpers/binder_helper.js',
    "lib/views/consult-edit-view.js",
    "lib/views/core-view.js",
    "lib/views/index.js",
    "lib/views/search-view.js"
    ])
    .pipe(jsdoc.parser(infos, name))
    .pipe(jsdoc.generator('./jsDoc/'));
});
var concat = require("gulp-concat");

gulp.task("markdox", function(){

  var markdox = require("gulp-markdox");

  gulp.src([
    './lib/helpers/binder_helper.js'
    ])
    .pipe(markdox())
    .pipe(concat("doc.md"))
    .pipe(gulp.dest("./doc"));
});

/**********************
  Building css files
**********************/
gulp.task('style', function() {
  gulp.src('./lib/styles/*.css')
    .pipe(concat('focus.css'))
    .pipe(gulp.dest('./example/app/css/'))
    .pipe(gulp.dest('./dist/'))
    .pipe(gulp.dest(buildConf.spaDirectory));
});
/**********************
  Building js files
**********************/

gulp.task('browserify', function(){
  var babelify = require("babelify"); //es6
  var browserify = require('browserify'); //build the source
  var source = require('vinyl-source-stream');
    var literalify = require('literalify');
    return browserify(({
        entries: ['./index.js'],
        extensions: ['.jsx'],
        standalone: "focus"
      }))
      .transform(
        {global:true},
        literalify.configure({
        react: 'window.React'
      }))
      .transform(babelify)
      .bundle()
      //Pass desired output filename to vinyl-source-stream
      //.pipe(source("focus-"+require('./package.json').version+".js"))
      .pipe(source("focus.js"))
      .pipe(gulp.dest('./dist/'))
      .pipe(gulp.dest('../focus-components/dist'));
});

//Grouping build tasks.
//Async build
gulp.task('build', ['style', 'browserify'], function() {

});
/*gulp.task('build', function (callback) {
    var runSequence = require('run-sequence');
    console.log('runSequence');
    runSequence('infos','css-build','templates', ['browser-build', 'node-build'],callback);
});*/

/**********************
  Example templates
**********************/

//Gulp build example templates into a template.js file for the example.
gulp.task('templatesExample', function() {
  var handlebars = require('gulp-handlebars');
  var defineModule = require('gulp-define-module');
  var declare = require('gulp-declare');

  gulp.src(['example/app/templates/*.hbs', "lib/templates/*.hbs"])
    .pipe(handlebars())
    .pipe(defineModule('plain'))
    .pipe(declare({
      namespace: 'Example.templates'
    }))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('example/app/js/'));
});

//Build focus components into the other repositories.
gulp.task('focus-npm', function() {
  var react = require('gulp-react');
  var babel = require('gulp-babel');
  var gulpif = require('gulp-if');
  gulp.src(['package.json','index.js','{component,application,helper,network,router,store,util,definition}/**/*'])
  .pipe(gulpif(/[.]js$/, react({harmony: true})))
  .pipe(gulpif(/[.]js$/, babel()))
  .pipe(gulp.dest('../focus-components/node_modules/focus/'))
  .pipe(gulp.dest('../rodolphe/app/node_modules/focus/'));
});

/**********************
  Documentation
**********************/
/*
gulp.task('doc', function() {
  var docco = require("gulp-docco");
  gulp.src(['./lib/main.js', './lib/helpers/*','./lib/models/*', './lib/views/*'])
    .pipe(docco({layout: "linear"}))
    //.pipe(gulpif(/[*helpers]$/, gulp.dest('./doc/helpers')))
    .pipe(gulpif(/[*models]$/, gulp.dest('./doc/models')))
    .pipe(gulpif(/[*views]$/, gulp.dest('./doc/views')));
});

*/
/**********************
  Local example server
**********************/

var browserSync = require('browser-sync');
var reload = browserSync.reload;
// Watch Files For Changes & Reload
gulp.task('serve', ['build'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['example/app']
    }
  });

  gulp.watch(['lib/**/*.{json,js, coffee}'],['browserify',reload]);
  gulp.watch(['lib/styles/*.{styl,css}'], ['style', reload]);
  gulp.watch(['package.json'], ['browserify',reload]);
  //gulp.watch(['app/scripts/**/*.js'], jshint);
  //gulp.watch(['app/images/**/*'], reload);
});

// The default task (called when you run `gulp` from cli)
gulp.task('default', ['build']);
<commit_msg>Build focus generated fil into focus-component.<commit_after>// include gulp
var gulp = require('gulp');

// include plug-ins
//var gulpif = require('gulp-if');
//var coffee = require('gulp-coffee');
var concat = require('gulp-concat');
//var gutil = require('gulp-util');

//buildConfig:
var buildConf = require('./build.json');
var sources = ['index.js','{component,application,helper,network,router,store,util,definition}/**/*'];
/**********************
  Linting files
**********************/

// JS and coffee lint task
gulp.task('lint', function() {
  var jshint = require('gulp-jshint');
  var stylish = require('jshint-stylish');
  var coffeelint = require('gulp-coffeelint');
  //Js linting.
  gulp
    .src('./lib/*/*.js')
    .pipe(jshint())
    .pipe(jshint.reporter(stylish));
  //Coffee linting
  gulp
    .src('./lib/*/*.coffee')
    .pipe(coffeelint())
    .pipe(coffeelint.reporter());
});

//Eslint

gulp.task('eslint', function() {
  //gulp eslint 2>lint/lintErrors.txt
  var eslint = require('gulp-eslint');
  var options = {
    "globals": {
      "jQuery": false,
      "$": true,
      "require": true,
      "Backbone": true,
      "Fmk": true,
      "_": true,
      "Promise": true,
      "module": true
    },
    "env": {
      "browser": true,
      "node": true
    },
    rules: {
      "valid-jsdoc": [2, {
      /*  "prefer": {
          "return": "return"
        },*/
        "requireParamDescription": true
      }],
      "quotes": [0]
    }
  };
  var format = "compact"; //"compact", "checkstyle", "jslint-xml", "junit" and "tap".
  gulp
    .src(sources)
    .pipe(eslint(options))
  //.pipe(eslint.format(undefined, process.stdout))
  //.pipe(eslint.failOnError())
  .pipe(eslint.formatEach(format, process.stderr));
  //.on('error', gutil.log);
});

/*********************
Documentation generation using jsDoc
***/
// JS and coffee lint task
gulp.task('jsdoc', function() {
  var jsdoc = require('gulp-jsdoc');
  var infos = require('./package.json');
  var name = 'focus';
  //Js linting.
  gulp.src([
    './lib/helpers/binder_helper.js',
    "lib/views/consult-edit-view.js",
    "lib/views/core-view.js",
    "lib/views/index.js",
    "lib/views/search-view.js"
    ])
    .pipe(jsdoc.parser(infos, name))
    .pipe(jsdoc.generator('./jsDoc/'));
});
var concat = require("gulp-concat");

gulp.task("markdox", function(){

  var markdox = require("gulp-markdox");

  gulp.src([
    './lib/helpers/binder_helper.js'
    ])
    .pipe(markdox())
    .pipe(concat("doc.md"))
    .pipe(gulp.dest("./doc"));
});

/**********************
  Building css files
**********************/
gulp.task('style', function() {
  gulp.src('./lib/styles/*.css')
    .pipe(concat('focus.css'))
    .pipe(gulp.dest('./example/app/css/'))
    .pipe(gulp.dest('./dist/'))
    .pipe(gulp.dest(buildConf.spaDirectory));
});
/**********************
  Building js files
**********************/

gulp.task('browserify', function(){
  var babelify = require("babelify"); //es6
  var browserify = require('browserify'); //build the source
  var source = require('vinyl-source-stream');
    var literalify = require('literalify');
    return browserify(({
        entries: ['./index.js'],
        extensions: ['.jsx'],
        standalone: "focus"
      }))
      .transform(
        {global:true},
        literalify.configure({
        react: 'window.React'
      }))
      .transform(babelify)
      .bundle()
      //Pass desired output filename to vinyl-source-stream
      //.pipe(source("focus-"+require('./package.json').version+".js"))
      .pipe(source("focus.js"))
      .pipe(gulp.dest('./dist/'))
      .pipe(gulp.dest('../focus-components/dist/js'));
});

//Grouping build tasks.
//Async build
gulp.task('build', ['style', 'browserify'], function() {

});
/*gulp.task('build', function (callback) {
    var runSequence = require('run-sequence');
    console.log('runSequence');
    runSequence('infos','css-build','templates', ['browser-build', 'node-build'],callback);
});*/

/**********************
  Example templates
**********************/

//Gulp build example templates into a template.js file for the example.
gulp.task('templatesExample', function() {
  var handlebars = require('gulp-handlebars');
  var defineModule = require('gulp-define-module');
  var declare = require('gulp-declare');

  gulp.src(['example/app/templates/*.hbs', "lib/templates/*.hbs"])
    .pipe(handlebars())
    .pipe(defineModule('plain'))
    .pipe(declare({
      namespace: 'Example.templates'
    }))
    .pipe(concat('templates.js'))
    .pipe(gulp.dest('example/app/js/'));
});

//Build focus components into the other repositories.
gulp.task('focus-npm', function() {
  var react = require('gulp-react');
  var babel = require('gulp-babel');
  var gulpif = require('gulp-if');
  gulp.src(['package.json','index.js','{component,application,helper,network,router,store,util,definition}/**/*'])
  .pipe(gulpif(/[.]js$/, react({harmony: true})))
  .pipe(gulpif(/[.]js$/, babel()))
  .pipe(gulp.dest('../focus-components/node_modules/focus/'))
  .pipe(gulp.dest('../rodolphe/app/node_modules/focus/'));
});

/**********************
  Documentation
**********************/
/*
gulp.task('doc', function() {
  var docco = require("gulp-docco");
  gulp.src(['./lib/main.js', './lib/helpers/*','./lib/models/*', './lib/views/*'])
    .pipe(docco({layout: "linear"}))
    //.pipe(gulpif(/[*helpers]$/, gulp.dest('./doc/helpers')))
    .pipe(gulpif(/[*models]$/, gulp.dest('./doc/models')))
    .pipe(gulpif(/[*views]$/, gulp.dest('./doc/views')));
});

*/
/**********************
  Local example server
**********************/

var browserSync = require('browser-sync');
var reload = browserSync.reload;
// Watch Files For Changes & Reload
gulp.task('serve', ['build'], function () {
  browserSync({
    notify: false,
    // Run as an https by uncommenting 'https: true'
    // Note: this uses an unsigned certificate which on first access
    //       will present a certificate warning in the browser.
    // https: true,
    server: {
      baseDir: ['example/app']
    }
  });

  gulp.watch(['lib/**/*.{json,js, coffee}'],['browserify',reload]);
  gulp.watch(['lib/styles/*.{styl,css}'], ['style', reload]);
  gulp.watch(['package.json'], ['browserify',reload]);
  //gulp.watch(['app/scripts/**/*.js'], jshint);
  //gulp.watch(['app/images/**/*'], reload);
});

// The default task (called when you run `gulp` from cli)
gulp.task('default', ['build']);
<|endoftext|>


<commit_before>var gulp = require('gulp'),
    sass = require('gulp-sass'),
    rename = require('gulp-rename'),
    minifyCss = require('gulp-minify-css'),
    autoprefixer = require('gulp-autoprefixer'),
    browserSync = require('browser-sync').create();

gulp.task('dependencies', function() {
  gulp.src('bower_components/normalize-css/normalize.css')
  .pipe(rename('_normalize.scss'))
  .pipe(gulp.dest('scss/libs'));
});

gulp.task('sass', function() {
    gulp.src('scss/style.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
        browsers: ['last 20 versions'],
        cascade: false
    }))
    .pipe(gulp.dest('./css/'))
    .pipe(minifyCss())
    .pipe(rename('style.min.css'))
    .pipe(gulp.dest('./css/'));
});

gulp.task('dist', function() {
  gulp.src(['index.html'])
  .pipe(gulp.dest('./'));
});

gulp.task('watch', function() {
    browserSync.init({
        server: "./"
    });
    gulp.watch('scss/**/*.scss', ['sass']).on('change', browserSync.reload);
    gulp.watch('index.html', ['dist']).on('change', browserSync.reload);
    gulp.watch('js/*.js', ['dist']).on('change', browserSync.reload);

});

gulp.task('default', ['clean', 'dependencies', 'sass'], function() {
  gulp.start('dist');
});
<commit_msg>Remove clean function of gulp default<commit_after>var gulp = require('gulp'),
    sass = require('gulp-sass'),
    rename = require('gulp-rename'),
    minifyCss = require('gulp-minify-css'),
    autoprefixer = require('gulp-autoprefixer'),
    browserSync = require('browser-sync').create();

gulp.task('dependencies', function() {
  gulp.src('bower_components/normalize-css/normalize.css')
  .pipe(rename('_normalize.scss'))
  .pipe(gulp.dest('scss/libs'));
});

gulp.task('sass', function() {
    gulp.src('scss/style.scss')
    .pipe(sass().on('error', sass.logError))
    .pipe(autoprefixer({
        browsers: ['last 20 versions'],
        cascade: false
    }))
    .pipe(gulp.dest('./css/'))
    .pipe(minifyCss())
    .pipe(rename('style.min.css'))
    .pipe(gulp.dest('./css/'));
});

gulp.task('dist', function() {
  gulp.src(['index.html'])
  .pipe(gulp.dest('./'));
});

gulp.task('watch', function() {
    browserSync.init({
        server: "./"
    });
    gulp.watch('scss/**/*.scss', ['sass']).on('change', browserSync.reload);
    gulp.watch('index.html', ['dist']).on('change', browserSync.reload);
    gulp.watch('js/*.js', ['dist']).on('change', browserSync.reload);

});

gulp.task('default', ['dependencies', 'sass'], function() {
  gulp.start('dist');
});
<|endoftext|>