<commit_before>/*global module, require */

// Generated on 2014-05-07 using generator-angular 0.8.0

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function (grunt) {

    'use strict';

    // Load grunt tasks automatically
    require('load-grunt-tasks')(grunt);

    // Time how long tasks take. Can help when optimizing build times
    require('time-grunt')(grunt);

    // Define the configuration for all the tasks
    grunt.initConfig({

        pkg   : grunt.file.readJSON('package.json'),

        // Project settings
        yeoman: {
            // configurable paths
            app : require('./bower.json').appPath || 'app',
            dist: 'dist'
        },

        ngdocs       : {
            options: {
                dest     : 'docs',
                html5Mode: true,
                startPage: '/api/Volusion.toolboxCommon',
                title    : 'Volusion Toolbox Common Reference',
                titleLink: '/api/Volusion.toolboxCommon',
                bestMatch: true
            },
            api    : {
                src  : ['app/scripts/**/*.js'],
                title: 'Volusion Toolbox Common Reference'
            }
        },

        protractor: {
            options: {
                keepAlive: false,
                configFile: './protractor.conf.js'
            },
            singlerun: {},
            auto: {
                keepAlive: true,
                options: {
                    args: {
                        seleniumPort: 4444
                    }
                }
            }
        },

        // Watches files for changes and runs tasks based on the changed files
        watch        : {
            bower     : {
                files: ['bower.json'],
                tasks: ['bowerInstall']
            },
            js        : {
                files  : ['<%= yeoman.app %>/scripts/{,*/}*.js', 'test/spec/{,*/}*.js'],
                tasks  : ['newer:jshint:all', 'test_no_coverage'],
                options: {
                    livereload: true
                }
            },
            jsTest    : {
                files: ['test/spec/{,*/}*.js'],
                tasks: ['newer:jshint:test']
            },
            compass   : {
                files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                tasks: ['compass:server', 'autoprefixer']
            },
            gruntfile : {
                files: ['Gruntfile.js']
            },
            livereload: {
                options: {
                    livereload: '<%= connect.options.livereload %>'
                },
                files  : [
                    '<%= yeoman.app %>/{,*/}*.html',
                    '.tmp/styles/{,*/}*.css',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
                ]
            }
        },

        // The actual grunt server settings
        connect      : {
            options   : {
                port      : 9000,
                // Change this to '0.0.0.0' to access the server from outside.
                hostname  : 'localhost',
                livereload: 35729
            },
            livereload: {
                options: {
                    open: true,
                    base: [
                        '.tmp',
                        '<%= yeoman.app %>'
                    ]
                }
            },
            test      : {
                options: {
                    port: 9001,
                    base: [
                        '.tmp',
                        'test',
                        '<%= yeoman.app %>'
                    ]
                }
            },
            dist      : {
                options: {
                    base: '<%= yeoman.dist %>'
                }
            }
        },

        // Make sure code styles are up to par and there are no obvious mistakes
        jshint       : {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all    : [
                'Gruntfile.js',
                '<%= yeoman.app %>/scripts/{,*/}*.js'
            ],
            test   : {
                options: {
                    jshintrc: 'test/.jshintrc'
                },
                src    : ['test/spec/{,*/}*.js']
            }
        },

        // Empties folders to start fresh
        clean        : {
            dist  : {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            '<%= yeoman.dist %>/*',
                            '!<%= yeoman.dist %>/.git*',
                            'coverage/*'
                        ]
                    }
                ]
            },
            server: {
                files: [
                    {
                        dot: true,
                        src: [
                            '.tmp',
                            'coverage/*'
                        ]
                    }
                ]
            }
        },

        // Add vendor prefixed styles
        autoprefixer : {
            options: {
                browsers: ['last 1 version']
            },
            dist   : {
                files: [
                    {
                        expand: true,
                        cwd   : '.tmp/styles/',
                        src   : '{,*/}*.css',
                        dest  : '.tmp/styles/'
                    }
                ]
            }
        },

        // Automatically inject Bower components into the app
        bowerInstall : {
            app : {
                src       : ['<%= yeoman.app %>/index.html'],
                ignorePath: '<%= yeoman.app %>/'
            },
            sass: {
                src       : ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
                ignorePath: '<%= yeoman.app %>/bower_components/'
            }
        },

        // Compiles Sass to CSS and generates necessary files if requested
        compass      : {
            options: {
                sassDir                : '<%= yeoman.app %>/styles',
                cssDir                 : '.tmp/styles',
                generatedImagesDir     : '.tmp/images/generated',
                imagesDir              : '<%= yeoman.app %>/images',
                javascriptsDir         : '<%= yeoman.app %>/scripts',
                fontsDir               : '<%= yeoman.app %>/styles/fonts',
                importPath             : '<%= yeoman.app %>/bower_components',
                httpImagesPath         : '/images',
                httpGeneratedImagesPath: '/images/generated',
                httpFontsPath          : '/styles/fonts',
                relativeAssets         : false,
                assetCacheBuster       : false,
                raw                    : 'Sass::Script::Number.precision = 10\n',
                outputStyle            : 'compact'
            },
            dist   : {
                options: {
                    generatedImagesDir: '<%= yeoman.dist %>/images/generated',
                    environment       : 'production'
                }
            },
            server : {
                options: {
                }
            }
        },

        // Renames files for browser caching purposes
        rev          : {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
                        '<%= yeoman.dist %>/styles/fonts/*'
                    ]
                }
            }
        },

        // Reads HTML for usemin blocks to enable smart builds that automatically
        // concat, minify and revision files. Creates configurations in memory so
        // additional tasks can operate on them
        useminPrepare: {
            html   : '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>',
                flow: {
                    html: {
                        steps: {
                            //js : ['concat', 'uglifyjs'],
                            //js : ['concat'],
                            //css: ['cssmin']
                            //css: ['concat']
                        },
                        post : {}
                    }
                }
            }
        },

        // Performs rewrites based on rev and the useminPrepare configuration
        usemin       : {
            html   : ['<%= yeoman.dist %>/{,*/}*.html'],
            css    : ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                assetsDirs: ['<%= yeoman.dist %>']
            }
        },

        // The following *-min tasks produce minified files in the dist folder
        cssmin       : {
            options: {
                root: '<%= yeoman.app %>'
            }
        },

        imagemin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd   : '<%= yeoman.app %>/images',
                        src   : '{,*/}*.{png,jpg,jpeg,gif}',
                        dest  : '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },

        svgmin: {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd   : '<%= yeoman.app %>/images',
                        src   : '{,*/}*.svg',
                        dest  : '<%= yeoman.dist %>/images'
                    }
                ]
            }
        },

        htmlmin   : {
            dist: {
                options: {
                    collapseWhitespace       : true,
                    collapseBooleanAttributes: true,
                    removeCommentsFromCDATA  : true,
                    removeOptionalTags       : true
                },
                files  : [
                    {
                        expand: true,
                        cwd   : '<%= yeoman.dist %>',
                        src   : ['*.html', 'views/{,*/}*.html'],
                        dest  : '<%= yeoman.dist %>'
                    }
                ]
            }
        },

        // ngmin tries to make the code safe for minification automatically by
        // using the Angular long form for dependency injection. It doesn't work on
        // things like resolve or inject so those have to be done manually.
        ngmin     : {
            dist: {
                files: [
                    {
                        expand: true,
                        cwd   : '.tmp/concat/scripts',
                        src   : '*.js',
                        dest  : '.tmp/concat/scripts'
                    }
                ]
            }
        },

        // Replace Google CDN references
        cdnify    : {
            dist: {
                html: ['<%= yeoman.dist %>/*.html']
            }
        },

        // Copies remaining files to places other tasks can use
        copy      : {
            dist  : {
                files: [
                    {
                        expand: true,
                        dot   : true,
                        cwd   : '<%= yeoman.app %>',
                        dest  : '<%= yeoman.dist %>',
                        src   : [
                            '!*.{ico,png,txt}',
                            '!.htaccess',
                            '!*.html',
                            'views/widgets/*.html',
                            'images/{,*/}*.{webp}',
                            'fonts/*'
                        ]
                    },
                    {
                        expand: true,
                        cwd   : '.tmp/images',
                        dest  : '<%= yeoman.dist %>/images',
                        src   : ['generated/*']
                    }
                ]
            },
            styles: {
                expand: true,
                cwd   : '<%= yeoman.app %>/styles',
                dest  : '.tmp/styles/',
                src   : '{,*/}*.css'
            }
        },

        // Run some tasks in parallel to speed up the build process
        concurrent: {
            server: [
                'compass:server'
            ],
            test  : [
                'compass'
            ],
            dist  : [
                'compass:dist',
                'imagemin',
                'svgmin'
            ]
        },

        coverage: {
            options: {
                thresholds: {
                    'statements': 0,
                    'branches'  : 0,
                    'lines'     : 0,
                    'functions' : 40
                },
                dir       : 'coverage'
            }
        },

        concat: {
            options: {
                stripBanners: {
                    block: true,
                    line : false
                },
                banner      : '\n/*! <%= pkg.name %> - ver.<%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>) */\n\n'
            },
            dist   : {
                files: [
                    {src   : [
                        '<%= yeoman.app %>/scripts/{,*/}*.js',
                        '!<%= yeoman.app %>/scripts/app.js',
                        '!<%= yeoman.app %>/scripts/{,*/}main.js'
                    ], dest: '<%= yeoman.dist %>/<%= pkg.name %>.js' },
                    {src   : [
                        '.tmp/styles/{,*/}*.css',
                        '!.tmp/styles/{,*/}main.css'
                    ], dest: '<%= yeoman.dist %>/<%= pkg.name %>-styles.css' }
                ]
            }
        },

        // Test settings
        karma : {
            unit: {
                configFile: 'karma.conf.js',
                singleRun : true
            }
        }
    });

    grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'connect:dist:keepalive']);
        }

        grunt.task.run([
            'clean:server',
            'bowerInstall',
            'concurrent:server',
            //'autoprefixer',
            'connect:livereload',
            'watch'
        ]);
    });

    grunt.registerTask('server', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve:' + target]);
    });

    grunt.registerTask('test_no_coverage', [
        'clean:server',
        'concurrent:test',
        //'autoprefixer',
        'connect:test',
        'karma'
    ]);

    grunt.registerTask('test', [
        'test_no_coverage',
        'coverage'
    ]);

    grunt.registerTask('test:e2e', [
        'protractor:singlerun'
    ]);

    grunt.registerTask('build', [
        'clean:dist',
        'bowerInstall',
        //'useminPrepare',
        'concurrent:dist',
        //'autoprefixer',
        'concat',
        //'ngmin',
        'copy:dist',
        //'cdnify',
        'cssmin'//,
        //'uglify'//,
        //'rev',
        //'usemin'//,
        //'htmlmin'
    ]);

    grunt.registerTask('default', [
        'newer:jshint',
        'test',
        'build'
    ]);

    grunt.registerTask('docs', [
        'ngdocs'
    ]);
};
<commit_msg>Format Gruntfile<commit_after>/*global module, require */

// Generated on 2014-05-07 using generator-angular 0.8.0

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to recursively match all subfolders:
// 'test/spec/**/*.js'

module.exports = function(grunt) {

	'use strict';

	// Load grunt tasks automatically
	require('load-grunt-tasks')(grunt);

	// Time how long tasks take. Can help when optimizing build times
	require('time-grunt')(grunt);

	// Define the configuration for all the tasks
	grunt.initConfig({
		pkg: grunt.file.readJSON('package.json'),

		// Project settings
		yeoman: {
			// configurable paths
			app: require('./bower.json').appPath || 'app',
			dist: 'dist'
		},

		ngdocs: {
			options: {
				dest: 'docs',
				html5Mode: true,
				startPage: '/api/Volusion.toolboxCommon',
				title: 'Volusion Toolbox Common Reference',
				titleLink: '/api/Volusion.toolboxCommon',
				bestMatch: true
			},
			api: {
				src: ['app/scripts/**/*.js'],
				title: 'Volusion Toolbox Common Reference'
			}
		},

		protractor: {
			options: {
				keepAlive: false,
				configFile: './protractor.conf.js'
			},
			singlerun: {},
			auto: {
				keepAlive: true,
				options: {
					args: {
						seleniumPort: 4444
					}
				}
			}
		},

		// Watches files for changes and runs tasks based on the changed files
		watch: {
			bower: {
				files: ['bower.json'],
				tasks: ['bowerInstall']
			},
			js: {
				files: ['<%= yeoman.app %>/scripts/{,*/}*.js', 'test/spec/{,*/}*.js'],
				tasks: ['newer:jshint:all', 'test_no_coverage'],
				options: {
					livereload: true
				}
			},
			jsTest: {
				files: ['test/spec/{,*/}*.js'],
				tasks: ['newer:jshint:test']
			},
			compass: {
				files: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
				tasks: ['compass:server', 'autoprefixer']
			},
			gruntfile: {
				files: ['Gruntfile.js']
			},
			livereload: {
				options: {
					livereload: '<%= connect.options.livereload %>'
				},
				files: [
					'<%= yeoman.app %>/{,*/}*.html',
					'.tmp/styles/{,*/}*.css',
					'<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}'
				]
			}
		},

		// The actual grunt server settings
		connect: {
			options: {
				port: 9000,
				// Change this to '0.0.0.0' to access the server from outside.
				hostname: 'localhost',
				livereload: 35729
			},
			livereload: {
				options: {
					open: true,
					base: [
						'.tmp',
						'<%= yeoman.app %>'
					]
				}
			},
			test: {
				options: {
					port: 9001,
					base: [
						'.tmp',
						'test',
						'<%= yeoman.app %>'
					]
				}
			},
			dist: {
				options: {
					base: '<%= yeoman.dist %>'
				}
			}
		},

		// Make sure code styles are up to par and there are no obvious mistakes
		jshint: {
			options: {
				jshintrc: '.jshintrc',
				reporter: require('jshint-stylish')
			},
			all: [
				'Gruntfile.js',
				'<%= yeoman.app %>/scripts/{,*/}*.js'
			],
			test: {
				options: {
					jshintrc: 'test/.jshintrc'
				},
				src: ['test/spec/{,*/}*.js']
			}
		},

		// Empties folders to start fresh
		clean: {
			dist: {
				files: [
					{
						dot: true,
						src: [
							'.tmp',
							'<%= yeoman.dist %>/*',
							'!<%= yeoman.dist %>/.git*',
							'coverage/*'
						]
					}
				]
			},
			server: {
				files: [
					{
						dot: true,
						src: [
							'.tmp',
							'coverage/*'
						]
					}
				]
			}
		},

		// Add vendor prefixed styles
		autoprefixer: {
			options: {
				browsers: ['last 1 version']
			},
			dist: {
				files: [
					{
						expand: true,
						cwd: '.tmp/styles/',
						src: '{,*/}*.css',
						dest: '.tmp/styles/'
					}
				]
			}
		},

		// Automatically inject Bower components into the app
		bowerInstall: {
			app: {
				src: ['<%= yeoman.app %>/index.html'],
				ignorePath: '<%= yeoman.app %>/'
			},
			sass: {
				src: ['<%= yeoman.app %>/styles/{,*/}*.{scss,sass}'],
				ignorePath: '<%= yeoman.app %>/bower_components/'
			}
		},

		// Compiles Sass to CSS and generates necessary files if requested
		compass: {
			options: {
				sassDir: '<%= yeoman.app %>/styles',
				cssDir: '.tmp/styles',
				generatedImagesDir: '.tmp/images/generated',
				imagesDir: '<%= yeoman.app %>/images',
				javascriptsDir: '<%= yeoman.app %>/scripts',
				fontsDir: '<%= yeoman.app %>/styles/fonts',
				importPath: '<%= yeoman.app %>/bower_components',
				httpImagesPath: '/images',
				httpGeneratedImagesPath: '/images/generated',
				httpFontsPath: '/styles/fonts',
				relativeAssets: false,
				assetCacheBuster: false,
				raw: 'Sass::Script::Number.precision = 10\n',
				outputStyle: 'compact'
			},
			dist: {
				options: {
					generatedImagesDir: '<%= yeoman.dist %>/images/generated',
					environment: 'production'
				}
			},
			server: {
				options: {

				}
			}
		},

		// Renames files for browser caching purposes
		rev: {
			dist: {
				files: {
					src: [
						'<%= yeoman.dist %>/scripts/{,*/}*.js',
						'<%= yeoman.dist %>/styles/{,*/}*.css',
						'<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp,svg}',
						'<%= yeoman.dist %>/styles/fonts/*'
					]
				}
			}
		},

		// Reads HTML for usemin blocks to enable smart builds that automatically
		// concat, minify and revision files. Creates configurations in memory so
		// additional tasks can operate on them
		useminPrepare: {
			html: '<%= yeoman.app %>/index.html',
			options: {
				dest: '<%= yeoman.dist %>',
				flow: {
					html: {
						steps: {
							//js : ['concat', 'uglifyjs'],
							//js : ['concat'],
							//css: ['cssmin']
							//css: ['concat']

						},
						post: {}
					}
				}
			}
		},

		// Performs rewrites based on rev and the useminPrepare configuration
		usemin: {
			html: ['<%= yeoman.dist %>/{,*/}*.html'],
			css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
			options: {
				assetsDirs: ['<%= yeoman.dist %>']
			}
		},

		// The following *-min tasks produce minified files in the dist folder
		cssmin: {
			options: {
				root: '<%= yeoman.app %>'
			}
		},

		imagemin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>/images',
						src: '{,*/}*.{png,jpg,jpeg,gif}',
						dest: '<%= yeoman.dist %>/images'
					}
				]
			}
		},

		svgmin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.app %>/images',
						src: '{,*/}*.svg',
						dest: '<%= yeoman.dist %>/images'
					}
				]
			}
		},

		htmlmin: {
			dist: {
				options: {
					collapseWhitespace: true,
					collapseBooleanAttributes: true,
					removeCommentsFromCDATA: true,
					removeOptionalTags: true
				},
				files: [
					{
						expand: true,
						cwd: '<%= yeoman.dist %>',
						src: ['*.html', 'views/{,*/}*.html'],
						dest: '<%= yeoman.dist %>'
					}
				]
			}
		},

		// ngmin tries to make the code safe for minification automatically by
		// using the Angular long form for dependency injection. It doesn't work on
		// things like resolve or inject so those have to be done manually.
		ngmin: {
			dist: {
				files: [
					{
						expand: true,
						cwd: '.tmp/concat/scripts',
						src: '*.js',
						dest: '.tmp/concat/scripts'
					}
				]
			}
		},

		// Replace Google CDN references
		cdnify: {
			dist: {
				html: ['<%= yeoman.dist %>/*.html']
			}
		},

		// Copies remaining files to places other tasks can use
		copy: {
			dist: {
				files: [
					{
						expand: true,
						dot: true,
						cwd: '<%= yeoman.app %>',
						dest: '<%= yeoman.dist %>',
						src: [
							'!*.{ico,png,txt}',
							'!.htaccess',
							'!*.html',
							'views/widgets/*.html',
							'images/{,*/}*.{webp}',
							'fonts/*'
						]
					},
					{
						expand: true,
						cwd: '.tmp/images',
						dest: '<%= yeoman.dist %>/images',
						src: ['generated/*']
					}
				]
			},
			styles: {
				expand: true,
				cwd: '<%= yeoman.app %>/styles',
				dest: '.tmp/styles/',
				src: '{,*/}*.css'
			}
		},

		// Run some tasks in parallel to speed up the build process
		concurrent: {
			server: [
				'compass:server'
			],
			test: [
				'compass'
			],
			dist: [
				'compass:dist',
				'imagemin',
				'svgmin'
			]
		},

		coverage: {
			options: {
				thresholds: {
					'statements': 0,
					'branches': 0,
					'lines': 0,
					'functions': 40
				},
				dir: 'coverage'
			}
		},

		concat: {
			options: {
				stripBanners: {
					block: true,
					line: false
				},
				banner: '\n/*! <%= pkg.name %> - ver.<%= pkg.version %> (<%= grunt.template.today("yyyy-mm-dd") %>) */\n\n'
			},
			dist: {
				files: [
					{
						src: [
							'<%= yeoman.app %>/scripts/{,*/}*.js',
							'!<%= yeoman.app %>/scripts/app.js',
							'!<%= yeoman.app %>/scripts/{,*/}main.js'
						],
						dest: '<%= yeoman.dist %>/<%= pkg.name %>.js'
					},
					{
						src: [
							'.tmp/styles/{,*/}*.css',
							'!.tmp/styles/{,*/}main.css'
						],
						dest: '<%= yeoman.dist %>/<%= pkg.name %>-styles.css'
					}
				]
			}
		},

		// Test settings
		karma: {
			unit: {
				configFile: 'karma.conf.js',
				singleRun: true
			}
		}
	});

	grunt.registerTask('serve', function(target) {
		if (target === 'dist') {
			return grunt.task.run(['build', 'connect:dist:keepalive']);
		}

		grunt.task.run([
			'clean:server',
			'bowerInstall',
			'concurrent:server',
			//'autoprefixer',
			'connect:livereload',
			'watch'
		]);
	});

	grunt.registerTask('server', function(target) {
		grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
		grunt.task.run(['serve:' + target]);
	});

	grunt.registerTask('test_no_coverage', [
		'clean:server',
		'concurrent:test',
		//'autoprefixer',
		'connect:test',
		'karma'
	]);

	grunt.registerTask('test', [
		'test_no_coverage',
		'coverage'
	]);

	grunt.registerTask('test:e2e', [
		'protractor:singlerun'
	]);

	grunt.registerTask('build', [
		'clean:dist',
		'bowerInstall',
		//'useminPrepare',
		'concurrent:dist',
		//'autoprefixer',
		'concat',
		//'ngmin',
		'copy:dist',
		//'cdnify',
		'cssmin' //,
		//'uglify'//,
		//'rev',
		//'usemin'//,
		//'htmlmin'
	]);

	grunt.registerTask('default', [
		'newer:jshint',
		'test',
		'build'
	]);

	grunt.registerTask('docs', [
		'ngdocs'
	]);
};
<|endoftext|>


<commit_before>var srcFiles = 'app/**/*.js';
var specFiles = 'spec/**/*.js';
var specE2eFiles = 'spec-e2e/**/*.js';

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-protractor-webdriver');
  grunt.loadNpmTasks('grunt-protractor-runner');
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jasmine: {
      src: srcFiles,
      options: {
        specs: specFiles,
        // helpers: 'spec/*Helper.js',
        // template: 'custom.tmpl'
      }
    },
    watch: {
      files: [srcFiles, specFiles],
      tasks: 'karma:spec:run'
    },
    jshint: {
      all: ['*.js', srcFiles, specFiles]
    },
    karma: {
      spec: {
        autoWatch: false,
        singleRun: true,
        options: {
          files : [
            './bower_components/angular/angular.js',
            './bower_components/angular-mocks/angular-mocks.js',
            srcFiles,
            specFiles
          ],
          frameworks: ['jasmine'],
          browsers : ['PhantomJS'],
          plugins : [
            'karma-chrome-launcher',
            'karma-phantomjs-launcher',
            'karma-firefox-launcher',
            'karma-jasmine'
          ],
        }
      },
    },
    protractor: {
      options: {
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false, // If true, protractor will not use colors in its output.
        args: {
          specs: [ specE2eFiles ],
          capabilities: {
            'browserName': 'chrome'
          },
          seleniumAddress: "127.0.0.1:4444/wd/hub",
          // seleniumServerJar: ""
          // Arguments passed to the command
          framework: "jasmine",
          jasmineNodeOpts: {
            showColors: true, // Use colors in the command line report.
          }
        }
      },
    },
    protractor_webdriver: {
      startSelenium: {
        options: {
          command: 'webdriver-manager start'
        },
      },
    }
  });

  grunt.registerTask('default', ['karma:spec', 'jshint']);
};
<commit_msg>Fix grunt protractor task<commit_after>var srcFiles = 'app/**/*.js';
var specFiles = 'spec/**/*.js';
var specE2eFiles = 'spec-e2e/**/*.js';

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-jshint');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-protractor-webdriver');
  grunt.loadNpmTasks('grunt-protractor-runner');
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    jasmine: {
      src: srcFiles,
      options: {
        specs: specFiles,
        // helpers: 'spec/*Helper.js',
        // template: 'custom.tmpl'
      }
    },
    watch: {
      files: [srcFiles, specFiles],
      tasks: 'karma:spec:run'
    },
    jshint: {
      all: ['*.js', srcFiles, specFiles]
    },
    karma: {
      spec: {
        autoWatch: false,
        singleRun: true,
        options: {
          files : [
            './bower_components/angular/angular.js',
            './bower_components/angular-mocks/angular-mocks.js',
            srcFiles,
            specFiles
          ],
          frameworks: ['jasmine'],
          browsers : ['PhantomJS'],
          plugins : [
            'karma-chrome-launcher',
            'karma-phantomjs-launcher',
            'karma-firefox-launcher',
            'karma-jasmine'
          ],
        }
      },
    },
    protractor: {
      options: {
        configFile: "protractorConf.js",
        keepAlive: true, // If false, the grunt process stops when the test fails.
        noColor: false // If true, protractor will not use colors in its output.
      },
      all: {}, // A target needs to be defined, otherwise protractor won't run
    },
    protractor_webdriver: {
      startSelenium: {
        options: {
          command: 'webdriver-manager start'
        },
      },
    }
  });

  grunt.registerTask('default', ['karma:spec', 'jshint']);
};
<|endoftext|>


<commit_before>/*global module, require*/

module.exports = function(grunt) {

	var removeLogginhg = grunt.option('debug')
	// URI paths for our tasks to use.
	grunt.uri = './';
	grunt.uriStatic = grunt.uri + 'web/';
	grunt.uriDist = grunt.uriStatic + 'dist/';
	grunt.uriSrc = grunt.uriStatic + 'src/';
	grunt.uriTask = grunt.uri + 'script/grunt/';

	// Our task object where we'll store our configuration.
	var tasks = {};
	tasks.concat = {};
	tasks.pkg = grunt.file.readJSON('package.json')

	// Lint Tasks
	tasks = require(grunt.uriTask + 'css-lint.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'html-lint.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'js-lint.js')(grunt, tasks);

	// Concatenation Tasks
	tasks = require(grunt.uriTask + 'css-concat.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'js-concat.js')(grunt, tasks);

	// Minify Tasks
	tasks = require(grunt.uriTask + 'css-minify.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'html-minify.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'js-minify.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'start-server.js')(grunt,tasks);
	tasks = require(grunt.uriTask + 'html-build.js')(grunt,tasks);

	grunt.loadNpmTasks('grunt-contrib-watch');
	// config watch, rebuild html file if changed
	tasks.watch = {
		dev: {
			files: [
				grunt.uriSrc+'/index.tpl.html',
				grunt.uriSrc+'scripts/*.js',
				grunt.uriStatic+'/assets/**'
			],
			tasks: ['htmlbuild:dev','prettify:dev'],
			options: {
      			event: ['all'] //all | deleted | changed | added
      		}
    	}
  	};

  	grunt.loadNpmTasks('grunt-prettify')
  	tasks.prettify = {
  		dev : {
  			options :{
  				"indent": 2,
  				"indent_char": " ",
  				"indent_scripts": "normal",
  				"wrap_line_length": 0,
  				"brace_style": "collapse",
  				"preserve_newlines": true,
  				"max_preserve_newlines": 1,
  				"unformatted": [
  					"a",
  					"code",
  					"pre"
  				]
  			},
  			html : { files: {} }
  		}
	}

	grunt.loadNpmTasks('grunt-strip-debug')
	tasks.stripDebug = {
        dist: {
            files: {
                'dist/app.js': 'src/app.js'
            }

    	}
	};

	grunt.loadNpmTasks('grunt-contrib-jasmine');
	tasks.jasmine = {
    	pivotal: {
      		src: 'web/src/**/*.js',
      		options: {
        		specs: 'spec/*3Spec.js',
        		helpers: 'spec/*Helper.js',
        		vendor: [
          			"web/lib/*.js",
          			 "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"
        		]
      		}
      	}
    }

    // log stripper
    grunt.loadNpmTasks("grunt-remove-logging");
    	removelogging: {
        dist: {
          src  : grunt.uriSrc+"/scripts/*.js",
          dest : grunt.uriSrc+"/scripts/*-clean.js",

          options: {
            // see below for options. this is optional.
          }
        }
      }
    });

    // configure cleaning of files
    grunt.loadNpmTasks('grunt-contrib-clean');
    tasks.clean: {
  		build: ["path/to/dir/one", "path/to/dir/two"],
  		release: ["path/to/another/dir/one", "path/to/another/dir/two"]
	},

  	tasks.prettify.dev.html.files[ grunt.uriStatic+'index.html'] = [grunt.uriStatic+'index.html'];
  	console.log(tasks.watch.dev);
	// Register The Tasks
	grunt.registerTask('lint', ['csslint', 'htmllint', 'jshint']);
	grunt.registerTask('minify', ['cssmin', 'htmlmin', 'uglify']);
	grunt.registerTask('default', ['lint', 'concat', 'minify']);
	grunt.registerTask('start-server',['connect']);
	grunt.registerTask('start-dev',['htmlbuild:dev','prettify:dev','start-server','watch:dev']);

	grunt.event.on('watch', function(action, filepath, target) {
		grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
	});

	// Initialize The Grunt Configuration
	grunt.initConfig(tasks);
};
<commit_msg>Added an --debug to taks<commit_after>/*global module, require*/

module.exports = function(grunt) {

	var removeLogging = !grunt.option('debug');
	// URI paths for our tasks to use.
	grunt.uri = './';
	grunt.uriStatic = grunt.uri + 'web/';
	grunt.uriDist = grunt.uriStatic + 'dist/';
	grunt.uriSrc = grunt.uriStatic + 'src/';
	grunt.uriTask = grunt.uri + 'script/grunt/';

	// Our task object where we'll store our configuration.
	var tasks = {};
	tasks.concat = {};
	tasks.pkg = grunt.file.readJSON('package.json')

	// Lint Tasks
	tasks = require(grunt.uriTask + 'css-lint.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'html-lint.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'js-lint.js')(grunt, tasks);

	// Concatenation Tasks
	tasks = require(grunt.uriTask + 'css-concat.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'js-concat.js')(grunt, tasks);

	// Minify Tasks
	tasks = require(grunt.uriTask + 'css-minify.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'html-minify.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'js-minify.js')(grunt, tasks);
	tasks = require(grunt.uriTask + 'start-server.js')(grunt,tasks);
	tasks = require(grunt.uriTask + 'html-build.js')(grunt,tasks);

	grunt.loadNpmTasks('grunt-contrib-watch');
	// config watch, rebuild html file if changed
	tasks.watch = {
		dev: {
			files: [
				grunt.uriSrc+'/index.tpl.html',
				grunt.uriSrc+'scripts/*.js',
				grunt.uriStatic+'/assets/**'
			],
			tasks: ['htmlbuild:dev','prettify:dev'],
			options: {
      			event: ['all'] //all | deleted | changed | added
      		}
    	}
  	};

  	grunt.loadNpmTasks('grunt-prettify')
  	tasks.prettify = {
  		dev : {
  			options :{
  				"indent": 2,
  				"indent_char": " ",
  				"indent_scripts": "normal",
  				"wrap_line_length": 0,
  				"brace_style": "collapse",
  				"preserve_newlines": true,
  				"max_preserve_newlines": 1,
  				"unformatted": [
  					"a",
  					"code",
  					"pre"
  				]
  			},
  			html : { files: {} }
  		}
	}

	grunt.loadNpmTasks('grunt-strip-debug')
	tasks.stripDebug = {
        dist: {
            files: {
                'dist/app.js': 'src/app.js'
            }

    	}
	};

	grunt.loadNpmTasks('grunt-contrib-jasmine');
	tasks.jasmine = {
    	pivotal: {
      		src: 'web/src/**/*.js',
      		options: {
        		specs: 'spec/*3Spec.js',
        		helpers: 'spec/*Helper.js',
        		vendor: [
          			"web/lib/*.js",
          			 "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"
        		]
      		}
      	}
    }

    // log stripper
    grunt.loadNpmTasks("grunt-remove-logging");
    tasks.removelogging = {
        test: {
          	src  : grunt.uriSrc+"/scripts/*.js",
          	dest : grunt.uriSrc+"/scripts/stripped/",
          	expand : true,
          	flatten : true,
          	options: {
             // set github repository if needed
          	}
        }
    };

    // cleaning of file
    grunt.loadNpmTasks('grunt-contrib-clean');
    tasks.clean = {
  		test: [grunt.uriSrc+"/scripts/stripped/"],
	};

  	tasks.prettify.dev.html.files[ grunt.uriStatic+'index.html'] = [grunt.uriStatic+'index.html'];
	// Register The Tasks
	grunt.registerTask('lint', ['csslint', 'htmllint', 'jshint']);
	grunt.registerTask('minify', ['cssmin', 'htmlmin', 'uglify']);
	grunt.registerTask('default', ['lint', 'concat', 'minify']);
	grunt.registerTask('start-server',['connect']);
	grunt.registerTask('start-dev',['htmlbuild:dev','prettify:dev','start-server','watch:dev']);

	if (removeLogging) {
		grunt.registerTask('unit',['removelogging:test','jasmine','clean:test']);
	} else {
		grunt.registerTask('unit',['jasmine']);
	}

	grunt.event.on('watch', function(action, filepath, target) {
		grunt.log.writeln(target + ': ' + filepath + ' has ' + action);
	});

	// Initialize The Grunt Configuration
	grunt.initConfig(tasks);
};
<|endoftext|>


<commit_before>/**
 * @file Gruntfile.js
 * @version 0.0.1
 *
 * @copyright 2014 CoNWeT Lab., Universidad Politécnica de Madrid
 * @license Apache v2 (https://github.com/Wirecloud/room-manager-src/blob/master/LICENSE)
 */

module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    banner: ' * @version <%= pkg.version %>\n' +
            ' * \n' +
            ' * @copyright 2014 <%= pkg.author %>\n' +
            ' * @license <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */',

    compress: {
      widget: {
        options: {
          mode: 'zip',
          archive: 'build/<%= pkg.vendor %>_<%= pkg.name %>_<%= pkg.version %>-dev.wgt'
        },
        files: [
          {expand: true, src: ['lib/**/*', 'config.xml', 'index.html'], cwd: 'src'},
          {expand: true, src: ['js/**/*', 'css/**/*'], cwd: 'build'},
          {expand: true, src: ['jquery.min.map', 'jquery.min.js'], dest: 'lib/js', cwd: 'node_modules/jquery/dist'}
        ]
      }
    },

    jasmine: {
      src: ['src/js/*.js'],
      options: {
        specs: 'src/test/js/*Spec.js',
        helpers: ['src/test/helpers/*.js'],
        vendor: ['node_modules/jquery/dist/jquery.js',
                'src/lib/js/jquery.dataTables.js',
                'node_modules/jasmine-jquery/lib/jasmine-jquery.js']
      }
    },

    replace: {
      version: {
        src: ['src/config.xml'],
        overwrite: true,
        replacements: [{
          from: /version=\"[0-9]+\.[0-9]+\.[0-9]+(-dev)?\"/g,
          to: 'version="<%= pkg.version %>"'
        }]
      }
    },

    clean: ['build'],

    jshint: {
      all: ['src/js/**/*', 'src/test/**/*', 'Gruntfile.js']
    }

  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  grunt.registerTask('js', ['concat:dist', 'uglify:dist']);
  grunt.registerTask('jsConcat', 'concat:dist');
  grunt.registerTask('css', ['less:dist', 'cssmin:dist']);
  grunt.registerTask('zip', 'compress:widget');
  grunt.registerTask('version', ['replace:version']);

  // grunt.registerTask('default', ['jshint', 'js', 'css', 'version', 'jasmine', 'zip']);
  grunt.registerTask('default', ['jshint', 'jsConcat', 'css', 'version', 'jasmine', 'zip']);
};
<commit_msg>Remove unused tasks<commit_after>/**
 * @file Gruntfile.js
 * @version 0.0.1
 *
 * @copyright 2014 CoNWeT Lab., Universidad Politécnica de Madrid
 * @license Apache v2 (https://github.com/Wirecloud/room-manager-src/blob/master/LICENSE)
 */

module.exports = function(grunt) {

  'use strict';

  grunt.initConfig({

    pkg: grunt.file.readJSON('package.json'),

    banner: ' * @version <%= pkg.version %>\n' +
            ' * \n' +
            ' * @copyright 2014 <%= pkg.author %>\n' +
            ' * @license <%= pkg.license.type %> (<%= pkg.license.url %>)\n' +
            ' */',

    compress: {
      widget: {
        options: {
          mode: 'zip',
          archive: 'build/<%= pkg.vendor %>_<%= pkg.name %>_<%= pkg.version %>-dev.wgt'
        },
        files: [
          {expand: true, src: ['lib/**/*', 'config.xml', 'index.html'], cwd: 'src'},
          {expand: true, src: ['js/**/*', 'css/**/*'], cwd: 'build'},
          {expand: true, src: ['jquery.min.map', 'jquery.min.js'], dest: 'lib/js', cwd: 'node_modules/jquery/dist'}
        ]
      }
    },

    jasmine: {
      src: ['src/js/*.js'],
      options: {
        specs: 'src/test/js/*Spec.js',
        helpers: ['src/test/helpers/*.js'],
        vendor: ['node_modules/jquery/dist/jquery.js',
                'src/lib/js/jquery.dataTables.js',
                'node_modules/jasmine-jquery/lib/jasmine-jquery.js']
      }
    },

    replace: {
      version: {
        src: ['src/config.xml'],
        overwrite: true,
        replacements: [{
          from: /version=\"[0-9]+\.[0-9]+\.[0-9]+(-dev)?\"/g,
          to: 'version="<%= pkg.version %>"'
        }]
      }
    },

    clean: ['build'],

    jshint: {
      all: ['src/js/**/*', 'src/test/**/*', 'Gruntfile.js', '!src/test/fixtures/']
    }

  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-jasmine');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-cssmin');
  grunt.loadNpmTasks('grunt-text-replace');
  grunt.loadNpmTasks('grunt-contrib-clean');
  grunt.loadNpmTasks('grunt-contrib-compress');
  grunt.loadNpmTasks('grunt-contrib-jshint');

  grunt.registerTask('zip', 'compress:widget');
  grunt.registerTask('version', ['replace:version']);

  grunt.registerTask('default', ['jshint', 'version', 'jasmine', 'zip']);
};
<|endoftext|>


<commit_before>/*global require*/
'use strict';
var LIVERELOAD_PORT = 35729;
var SERVER_PORT = 9000;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to match all subfolders:
// 'test/spec/**/*.js'
// templateFramework: 'lodash'

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    // configurable paths
    var yeomanConfig = {
        app: 'app',
        dist: 'dist'
    };

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            options: {
                nospawn: true,
                livereload: true
            },
            livereload: {
                options: {
                    livereload: grunt.option('livereloadport') || LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                    '<%= yeoman.app %>/scripts/templates/*.{ejs,mustache,hbs}',
                    'test/spec/**/*.js'
                ]
            },
            jst: {
                files: [
                    '<%= yeoman.app %>/scripts/templates/*.ejs'
                ],
                tasks: ['jst']
            },
            test: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js', 'test/spec/**/*.js'],
                tasks: ['test:true']
            }
        },
        connect: {
            options: {
                port: grunt.option('port') || SERVER_PORT,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, yeomanConfig.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            },
            test: {
                path: 'http://localhost:<%= connect.test.options.port %>'
            }
        },
        clean: {
            dist: ['.tmp', '<%= yeoman.dist %>/*'],
            server: '.tmp',
            coveralls: 'test/output/lcov.info'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                '<%= yeoman.app %>/scripts/{,*/}*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },
        blanket_mocha: {
            all: {
                options: {
                    run: false,
                    urls: ['http://localhost:<%= connect.test.options.port %>/index.html'],
                    threshold: 95
                },
                dest: 'test/output/lcov.info'
            }
        },
        coveralls: {
          options: {
            // LCOV coverage file relevant to every target
            src: 'test/output/lcov.info',

            // When true, grunt-coveralls will only print a warning rather than
            // an error, to prevent CI builds from failing unnecessarily (e.g. if
            // coveralls.io is down). Optional, defaults to false.
            force: true
          }
        },
        // not enabled since usemin task does concat and uglify
        // check index.html to edit your build targets
        // enable this task if you prefer defining your build targets here
        /*uglify: {
            dist: {}
        },*/
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/styles/main.css': [
                        '.tmp/styles/{,*/}*.css',
                        '<%= yeoman.app %>/styles/{,*/}*.css'
                    ]
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,txt}',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/{,*/}*.*',
                    ]
                }, {
                    expand: true,
                    dot: true,
                    flatten: true,
                    cwd: '<%= yeoman.app %>',
                    src: 'bower_components/bootstrap/fonts/*.*',
                    dest: '<%= yeoman.dist %>/fonts/'
                }, {
                    src: 'node_modules/apache-server-configs/dist/.htaccess',
                    dest: '<%= yeoman.dist %>/.htaccess'
                }]
            }
        },
        jst: {
            compile: {
                files: {
                    '.tmp/scripts/templates.js': ['<%= yeoman.app %>/scripts/templates/*.ejs']
                }
            }
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                        '/styles/fonts/{,*/}*.*',
                    ]
                }
            }
        },
        docco: {
            dist: {
                src: ['app/scripts/**/*.js'],
                options: {
                    output: 'dist/docs/js/'
                }
            }
        }
    });

    grunt.registerTask('createDefaultTemplate', function () {
        grunt.file.write('.tmp/scripts/templates.js', 'this.JST = this.JST || {};');
    });

    grunt.registerTask('server', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve' + (target ? ':' + target : '')]);
    });

    grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open:server', 'connect:dist:keepalive']);
        }

        if (target === 'test') {
            return grunt.task.run([
                'clean:server',
                'createDefaultTemplate',
                'jst',
                'connect:test',
                'open:test',
                'watch'
            ]);
        }

        grunt.task.run([
            'clean:server',
            'createDefaultTemplate',
            'jst',
            'connect:livereload',
            'open:server',
            'watch'
        ]);
    });

    grunt.registerTask('test', function (isConnected) {
        isConnected = Boolean(isConnected);
        var testTasks = [
                'clean:server',
                'clean:coveralls',
                'createDefaultTemplate',
                'jst',
                'connect:test',
                'blanket_mocha',
                'coveralls'
            ];

        if(!isConnected) {
            return grunt.task.run(testTasks);
        } else {
            // already connected so not going to connect again, remove the connect:test task
            testTasks.splice(testTasks.indexOf('connect:test'), 1);
            return grunt.task.run(testTasks);
        }
    });

    grunt.registerTask('build', [
        'clean:dist',
        'createDefaultTemplate',
        'jst',
        'useminPrepare',
        'imagemin',
        'htmlmin',
        'concat',
        'cssmin',
        'uglify',
        'copy',
        'rev',
        'usemin',
        'docco:dist'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<commit_msg>Revert "fix jshint overzealotry"<commit_after>'use strict';
var LIVERELOAD_PORT = 35729;
var SERVER_PORT = 9000;
var lrSnippet = require('connect-livereload')({port: LIVERELOAD_PORT});
var mountFolder = function (connect, dir) {
    return connect.static(require('path').resolve(dir));
};

// # Globbing
// for performance reasons we're only matching one level down:
// 'test/spec/{,*/}*.js'
// use this if you want to match all subfolders:
// 'test/spec/**/*.js'
// templateFramework: 'lodash'

module.exports = function (grunt) {
    // show elapsed time at the end
    require('time-grunt')(grunt);
    // load all grunt tasks
    require('load-grunt-tasks')(grunt);

    // configurable paths
    var yeomanConfig = {
        app: 'app',
        dist: 'dist'
    };

    grunt.initConfig({
        yeoman: yeomanConfig,
        watch: {
            options: {
                nospawn: true,
                livereload: true
            },
            livereload: {
                options: {
                    livereload: grunt.option('livereloadport') || LIVERELOAD_PORT
                },
                files: [
                    '<%= yeoman.app %>/*.html',
                    '{.tmp,<%= yeoman.app %>}/styles/{,*/}*.css',
                    '{.tmp,<%= yeoman.app %>}/scripts/{,*/}*.js',
                    '<%= yeoman.app %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                    '<%= yeoman.app %>/scripts/templates/*.{ejs,mustache,hbs}',
                    'test/spec/**/*.js'
                ]
            },
            jst: {
                files: [
                    '<%= yeoman.app %>/scripts/templates/*.ejs'
                ],
                tasks: ['jst']
            },
            test: {
                files: ['<%= yeoman.app %>/scripts/{,*/}*.js', 'test/spec/**/*.js'],
                tasks: ['test:true']
            }
        },
        connect: {
            options: {
                port: grunt.option('port') || SERVER_PORT,
                // change this to '0.0.0.0' to access the server from outside
                hostname: 'localhost'
            },
            livereload: {
                options: {
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            test: {
                options: {
                    port: 9001,
                    middleware: function (connect) {
                        return [
                            lrSnippet,
                            mountFolder(connect, '.tmp'),
                            mountFolder(connect, 'test'),
                            mountFolder(connect, yeomanConfig.app)
                        ];
                    }
                }
            },
            dist: {
                options: {
                    middleware: function (connect) {
                        return [
                            mountFolder(connect, yeomanConfig.dist)
                        ];
                    }
                }
            }
        },
        open: {
            server: {
                path: 'http://localhost:<%= connect.options.port %>'
            },
            test: {
                path: 'http://localhost:<%= connect.test.options.port %>'
            }
        },
        clean: {
            dist: ['.tmp', '<%= yeoman.dist %>/*'],
            server: '.tmp',
            coveralls: 'test/output/lcov.info'
        },
        jshint: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require('jshint-stylish')
            },
            all: [
                '<%= yeoman.app %>/scripts/{,*/}*.js',
                '!<%= yeoman.app %>/scripts/vendor/*',
                'test/spec/{,*/}*.js'
            ]
        },
        blanket_mocha: {
            all: {
                options: {
                    run: false,
                    urls: ['http://localhost:<%= connect.test.options.port %>/index.html'],
                    threshold: 95
                },
                dest: 'test/output/lcov.info'
            }
        },
        coveralls: {
          options: {
            // LCOV coverage file relevant to every target
            src: 'test/output/lcov.info',

            // When true, grunt-coveralls will only print a warning rather than
            // an error, to prevent CI builds from failing unnecessarily (e.g. if
            // coveralls.io is down). Optional, defaults to false.
            force: true
          }
        },
        // not enabled since usemin task does concat and uglify
        // check index.html to edit your build targets
        // enable this task if you prefer defining your build targets here
        /*uglify: {
            dist: {}
        },*/
        useminPrepare: {
            html: '<%= yeoman.app %>/index.html',
            options: {
                dest: '<%= yeoman.dist %>'
            }
        },
        usemin: {
            html: ['<%= yeoman.dist %>/{,*/}*.html'],
            css: ['<%= yeoman.dist %>/styles/{,*/}*.css'],
            options: {
                dirs: ['<%= yeoman.dist %>']
            }
        },
        imagemin: {
            dist: {
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>/images',
                    src: '{,*/}*.{png,jpg,jpeg}',
                    dest: '<%= yeoman.dist %>/images'
                }]
            }
        },
        cssmin: {
            dist: {
                files: {
                    '<%= yeoman.dist %>/styles/main.css': [
                        '.tmp/styles/{,*/}*.css',
                        '<%= yeoman.app %>/styles/{,*/}*.css'
                    ]
                }
            }
        },
        htmlmin: {
            dist: {
                options: {
                    /*removeCommentsFromCDATA: true,
                    // https://github.com/yeoman/grunt-usemin/issues/44
                    //collapseWhitespace: true,
                    collapseBooleanAttributes: true,
                    removeAttributeQuotes: true,
                    removeRedundantAttributes: true,
                    useShortDoctype: true,
                    removeEmptyAttributes: true,
                    removeOptionalTags: true*/
                },
                files: [{
                    expand: true,
                    cwd: '<%= yeoman.app %>',
                    src: '*.html',
                    dest: '<%= yeoman.dist %>'
                }]
            }
        },
        copy: {
            dist: {
                files: [{
                    expand: true,
                    dot: true,
                    cwd: '<%= yeoman.app %>',
                    dest: '<%= yeoman.dist %>',
                    src: [
                        '*.{ico,txt}',
                        'images/{,*/}*.{webp,gif}',
                        'styles/fonts/{,*/}*.*',
                    ]
                }, {
                    expand: true,
                    dot: true,
                    flatten: true,
                    cwd: '<%= yeoman.app %>',
                    src: 'bower_components/bootstrap/fonts/*.*',
                    dest: '<%= yeoman.dist %>/fonts/'
                }, {
                    src: 'node_modules/apache-server-configs/dist/.htaccess',
                    dest: '<%= yeoman.dist %>/.htaccess'
                }]
            }
        },
        jst: {
            compile: {
                files: {
                    '.tmp/scripts/templates.js': ['<%= yeoman.app %>/scripts/templates/*.ejs']
                }
            }
        },
        rev: {
            dist: {
                files: {
                    src: [
                        '<%= yeoman.dist %>/scripts/{,*/}*.js',
                        '<%= yeoman.dist %>/styles/{,*/}*.css',
                        '<%= yeoman.dist %>/images/{,*/}*.{png,jpg,jpeg,gif,webp}',
                        '/styles/fonts/{,*/}*.*',
                    ]
                }
            }
        },
        docco: {
            dist: {
                src: ['app/scripts/**/*.js'],
                options: {
                    output: 'dist/docs/js/'
                }
            }
        }
    });

    grunt.registerTask('createDefaultTemplate', function () {
        grunt.file.write('.tmp/scripts/templates.js', 'this.JST = this.JST || {};');
    });

    grunt.registerTask('server', function (target) {
        grunt.log.warn('The `server` task has been deprecated. Use `grunt serve` to start a server.');
        grunt.task.run(['serve' + (target ? ':' + target : '')]);
    });

    grunt.registerTask('serve', function (target) {
        if (target === 'dist') {
            return grunt.task.run(['build', 'open:server', 'connect:dist:keepalive']);
        }

        if (target === 'test') {
            return grunt.task.run([
                'clean:server',
                'createDefaultTemplate',
                'jst',
                'connect:test',
                'open:test',
                'watch'
            ]);
        }

        grunt.task.run([
            'clean:server',
            'createDefaultTemplate',
            'jst',
            'connect:livereload',
            'open:server',
            'watch'
        ]);
    });

    grunt.registerTask('test', function (isConnected) {
        isConnected = Boolean(isConnected);
        var testTasks = [
                'clean:server',
                'clean:coveralls',
                'createDefaultTemplate',
                'jst',
                'connect:test',
                'blanket_mocha',
                'coveralls'
            ];

        if(!isConnected) {
            return grunt.task.run(testTasks);
        } else {
            // already connected so not going to connect again, remove the connect:test task
            testTasks.splice(testTasks.indexOf('connect:test'), 1);
            return grunt.task.run(testTasks);
        }
    });

    grunt.registerTask('build', [
        'clean:dist',
        'createDefaultTemplate',
        'jst',
        'useminPrepare',
        'imagemin',
        'htmlmin',
        'concat',
        'cssmin',
        'uglify',
        'copy',
        'rev',
        'usemin',
        'docco:dist'
    ]);

    grunt.registerTask('default', [
        'jshint',
        'test',
        'build'
    ]);
};
<|endoftext|>


<commit_before>/**
	_moon.ContextualPopup_ is a popup window control with Moonstone visual styling
	applied.  It extends [enyo.Popup](#enyo.Popup) and is designed to be used with
	[moon.ContextualPopupDecorator](#moon.ContextualPopupDecorator).
*/
enyo.kind({
	name: "moon.ContextualPopup",
	kind: "enyo.Popup",
	//* @protected
	layoutKind: "ContextualLayout",
	classes: "moon-body-text moon-contextual-popup",
	handlers: {
		onRequestShowPopup: "requestShow",
		onRequestHidePopup: "requestHide",
		onActivate: "decorateActivateEvent",
		onSpotlightUp: "spotlightUp",
		onSpotlightDown: "spotlightDown",
		onSpotlightLeft: "spotlightLeft",
		onSpotlightRight: "spotlightRight",
		onSpotlightKeyDown: "spotKeyDown",
		onRequestScrollIntoView: "_preventEventBubble"
	},
	//* @public
	published: {
		/**
			When true, spotlight cannot leave the constraints of the _moon.Popup_
			unless it is explicitly closed.
		*/
		spotlightModal: false,
		/**
			When false, _closeButton_ is hidden; when true, it is shown. When
			_showCloseButton_ is set to "auto" (the default), _closeButton_ is shown
			when _spotlightModal_ is true.
		*/
		showCloseButton: "auto"
	},
	//* @protected
	spotlight: "container",
	_spotlight: null,
	floating:true,
	eventsToCapture: { down:1, tap:1, onSpotlightKeyDown:1 },
	/**
		Determines whether a scrim will appear when the popup is modal.
		Note that modal scrims are transparent, so you won't see them.
	*/
	scrimWhenModal: true,
	// Layout parameters

	//* Vertical flush layout margin
	vertFlushMargin:0,
	//* Horizontal flush layout margin
	horizFlushMargin:0,
	//* Popups wider than this value are considered wide (for layout purposes)
	widePopup: 200,
	//* Popups longer than this value are considered long (for layout purposes)
	longPopup: 200,
	//* Do not allow horizontal flush popups past spec'd amount of buffer space on left/right screen edge
	horizBuffer: 16,
	activator: null,
	tools: [
		{name: "client", classes: "moon-neutral moon-contextual-popup-client"},
		{name: "closeButton", kind: "moon.IconButton", icon: "closex", classes: "moon-popup-close", ontap: "closePopup", spotlight: false}
	],
	//* Creates chrome.
	initComponents: function() {
		this.createChrome(this.tools);
		this.inherited(arguments);
	},
	//* Renders the contextual popup.
	render: function() {
		this.allowHtmlChanged();
		this.contentChanged();
		this.inherited(arguments);
		this._spotlight = this.spotlight;
	},
	//* Performs control-specific tasks before/after showing _moon.ContextualPopup_.
	requestShow: function(inSender, inEvent) {
		var n = inEvent.activator.hasNode();
		this.activator = inEvent.activator;
		this.spotlight = this._spotlight;
		if (n) {
			this.activatorOffset = this.getPageOffset(n);
		}
		this.show();
		this.configCloseButton();
		this.configSpotlightBehavior(true);
		return true;
	},
	decorateActivateEvent: function(inSender, inEvent) {
		inEvent.sentFromPopup = this;
	},
	getPageOffset: function(inNode) {
		// getBoundingClientRect returns top/left values which are relative to the viewport and not absolute
		var r = inNode.getBoundingClientRect();

		var pageYOffset = (window.pageYOffset === undefined) ? document.documentElement.scrollTop : window.pageYOffset;
		var pageXOffset = (window.pageXOffset === undefined) ? document.documentElement.scrollLeft : window.pageXOffset;
		var rHeight = (r.height === undefined) ? (r.bottom - r.top) : r.height;
		var rWidth = (r.width === undefined) ? (r.right - r.left) : r.width;

		return {top: r.top + pageYOffset, left: r.left + pageXOffset, height: rHeight, width: rWidth};
	},
	//* Dismisses popup if Escape keypress is detected
	keydown: function(inSender, inEvent) {
		if (this.showing && this.autoDismiss && inEvent.keyCode == 27 /* escape */) {
			enyo.Spotlight.spot(this.activator);
			this.hide();
		}
	},
	closePopup: function(inSender, inEvent) {
		enyo.Spotlight.spot(this.activator);
		this.$.closeButton.removeClass("pressed");
		this.hide();
	},
	//* Determines whether to display _closeButton_.
	configCloseButton: function() {
		if (this.showCloseButton === true || (this.spotlightModal && this.showCloseButton !== false)) {
			this.activator.keepOpen = true;
			this.$.closeButton.show();
			this.$.closeButton.spotlight = true;
			this.addClass("reserve-close");
		} else {
			this.$.closeButton.hide();
			this.$.closeButton.spotlight = false;
			this.removeClass("reserve-close");
		}
	},
	contentChanged: function() {
		this.$.client.setContent(this.content);
	},
	allowHtmlChanged: function() {
		this.$.client.setAllowHtml(this.allowHtml);
	},
	//* Spotlights the first spottable control, if possible.
	configSpotlightBehavior: function(spotChild) {
		if (enyo.Spotlight.getChildren(this).length > 0) {
			if (spotChild) {
				enyo.Spotlight.spot(enyo.Spotlight.getFirstChild(this));
			}
		} else if (!this.spotlightModal) {
			this.activator.keepOpen = false;
			this.spotlight = false;
		}
	},
	//* Called when _this.spotlight_ changes.
	spotlightChanged: function() {
		this._spotlight = this.spotlight;
		this.configSpotlightBehavior(false);
	},
	//* Called when _this.spotlightModal_ changes.
	spotlightModalChanged: function() {
		this.configCloseButton();
	},
	//* Called when _this.showCloseButton_ changes.
	showCloseButtonChanged: function() {
		this.configCloseButton();
	},
	spotKeyDown: function(inSender, inEvent) {
		if (!inEvent.dispatchTarget.isDescendantOf(this)) {
			if (inEvent.keyCode == 13) {
				this.downEvent = inEvent;
			}
			return true;
		}
	},
	//* Checks whether to allow spotlight to move in a given direction.
	spotChecker: function(inDirection) {
		var neighbor = enyo.Spotlight.NearestNeighbor.getNearestNeighbor(inDirection);
		if (!enyo.Spotlight.Util.isChild(this, neighbor)) {
			if (this.spotlightModal) {
				return true;
			} else {
				enyo.Spotlight.spot(this.activator);
				this.hide();
			}
		}
	},
	/**
		When spotlight reaches top edge of popup, prevents user from
		continuing further.
	*/
	spotlightUp: function(inSender, inEvent) {
		return this.spotChecker("UP");
	},
	/**
		When spotlight reaches bottom edge of popup, prevents user from
		continuing further.
	*/
	spotlightDown: function(inSender, inEvent) {
		return this.spotChecker("DOWN");
	},
	/**
		When spotlight reaches left edge of popup, prevents user from
		continuing further.
	*/
	spotlightLeft: function(inSender, inEvent) {
		return this.spotChecker("LEFT");
	},
	/**
		When spotlight reaches right edge of popup, prevents user from
		continuing further.
	*/
	spotlightRight: function(inSender, inEvent) {
		return this.spotChecker("RIGHT");
	},
	_preventEventBubble: function(inSender, inEvent) {
		return true;
	},
	showHideScrim: function(inShow) {
		if (this.floating && (this.scrim || (this.modal && this.scrimWhenModal))) {
			var scrim = this.getScrim();
			if (inShow && this.modal && this.scrimWhenModal) {
				// move scrim to just under the popup to obscure rest of screen
				var i = this.getScrimZIndex();
				this._scrimZ = i;
				scrim.showAtZIndex(i);
			} else {
				scrim.hideAtZIndex(this._scrimZ);
			}
			enyo.call(scrim, "addRemoveClass", [this.scrimClassName, scrim.showing]);
		}
	},
	getScrimZIndex: function() {
		// Position scrim directly below popup
		return this.findZIndex()-1;
	},
	getScrim: function() {
		// show a transparent scrim for modal popups if scrimWhenModal is true
		// if scrim is true, then show a regular scrim.
		if (this.modal && this.scrimWhenModal) {
			return moon.scrimTransparent.make();
		}
		return moon.scrim.make();
	},
	findZIndex: function() {
		// a default z value
		var z = this.defaultZ;
		if (this._zIndex) {
			z = this._zIndex;
		} else if (this.hasNode()) {
			// Re-use existing zIndex if it has one
			z = Number(enyo.dom.getComputedStyleValue(this.node, "z-index")) || z;
		}
		this._zIndex = z;
		return this._zIndex;
	},
	showingChanged: function() {
		this.inherited(arguments);
		this.showHideScrim(this.showing);
	}
});
<commit_msg>GF-45055: Update to use newer capture API using callback. DCO-1.1-Signed-Off-By: Kevin Schaaf <kevin.schaaf@lge.com><commit_after>/**
	_moon.ContextualPopup_ is a popup window control with Moonstone visual styling
	applied.  It extends [enyo.Popup](#enyo.Popup) and is designed to be used with
	[moon.ContextualPopupDecorator](#moon.ContextualPopupDecorator).
*/
enyo.kind({
	name: "moon.ContextualPopup",
	kind: "enyo.Popup",
	//* @protected
	layoutKind: "ContextualLayout",
	classes: "moon-body-text moon-contextual-popup",
	handlers: {
		onRequestShowPopup: "requestShow",
		onRequestHidePopup: "requestHide",
		onActivate: "decorateActivateEvent",
		onSpotlightUp: "spotlightUp",
		onSpotlightDown: "spotlightDown",
		onSpotlightLeft: "spotlightLeft",
		onSpotlightRight: "spotlightRight",
		onRequestScrollIntoView: "_preventEventBubble"
	},
	//* @public
	published: {
		/**
			When true, spotlight cannot leave the constraints of the _moon.Popup_
			unless it is explicitly closed.
		*/
		spotlightModal: false,
		/**
			When false, _closeButton_ is hidden; when true, it is shown. When
			_showCloseButton_ is set to "auto" (the default), _closeButton_ is shown
			when _spotlightModal_ is true.
		*/
		showCloseButton: "auto"
	},
	//* @protected
	spotlight: "container",
	_spotlight: null,
	floating:true,
	eventsToCapture: { down:1, tap:1, onSpotlightKeyDown:1 },
	/**
		Determines whether a scrim will appear when the popup is modal.
		Note that modal scrims are transparent, so you won't see them.
	*/
	scrimWhenModal: true,
	// Layout parameters

	//* Vertical flush layout margin
	vertFlushMargin:0,
	//* Horizontal flush layout margin
	horizFlushMargin:0,
	//* Popups wider than this value are considered wide (for layout purposes)
	widePopup: 200,
	//* Popups longer than this value are considered long (for layout purposes)
	longPopup: 200,
	//* Do not allow horizontal flush popups past spec'd amount of buffer space on left/right screen edge
	horizBuffer: 16,
	activator: null,
	tools: [
		{name: "client", classes: "moon-neutral moon-contextual-popup-client"},
		{name: "closeButton", kind: "moon.IconButton", icon: "closex", classes: "moon-popup-close", ontap: "closePopup", spotlight: false}
	],
	//* Creates chrome.
	initComponents: function() {
		this.createChrome(this.tools);
		this.inherited(arguments);
	},
	//* Renders the contextual popup.
	render: function() {
		this.allowHtmlChanged();
		this.contentChanged();
		this.inherited(arguments);
		this._spotlight = this.spotlight;
	},
	//* Performs control-specific tasks before/after showing _moon.ContextualPopup_.
	requestShow: function(inSender, inEvent) {
		var n = inEvent.activator.hasNode();
		this.activator = inEvent.activator;
		this.spotlight = this._spotlight;
		if (n) {
			this.activatorOffset = this.getPageOffset(n);
		}
		this.show();
		this.configCloseButton();
		this.configSpotlightBehavior(true);
		return true;
	},
	decorateActivateEvent: function(inSender, inEvent) {
		inEvent.sentFromPopup = this;
	},
	getPageOffset: function(inNode) {
		// getBoundingClientRect returns top/left values which are relative to the viewport and not absolute
		var r = inNode.getBoundingClientRect();

		var pageYOffset = (window.pageYOffset === undefined) ? document.documentElement.scrollTop : window.pageYOffset;
		var pageXOffset = (window.pageXOffset === undefined) ? document.documentElement.scrollLeft : window.pageXOffset;
		var rHeight = (r.height === undefined) ? (r.bottom - r.top) : r.height;
		var rWidth = (r.width === undefined) ? (r.right - r.left) : r.width;

		return {top: r.top + pageYOffset, left: r.left + pageXOffset, height: rHeight, width: rWidth};
	},
	//* Dismisses popup if Escape keypress is detected
	keydown: function(inSender, inEvent) {
		if (this.showing && this.autoDismiss && inEvent.keyCode == 27 /* escape */) {
			enyo.Spotlight.spot(this.activator);
			this.hide();
		}
	},
	closePopup: function(inSender, inEvent) {
		enyo.Spotlight.spot(this.activator);
		this.$.closeButton.removeClass("pressed");
		this.hide();
	},
	//* Determines whether to display _closeButton_.
	configCloseButton: function() {
		if (this.showCloseButton === true || (this.spotlightModal && this.showCloseButton !== false)) {
			this.activator.keepOpen = true;
			this.$.closeButton.show();
			this.$.closeButton.spotlight = true;
			this.addClass("reserve-close");
		} else {
			this.$.closeButton.hide();
			this.$.closeButton.spotlight = false;
			this.removeClass("reserve-close");
		}
	},
	contentChanged: function() {
		this.$.client.setContent(this.content);
	},
	allowHtmlChanged: function() {
		this.$.client.setAllowHtml(this.allowHtml);
	},
	//* Spotlights the first spottable control, if possible.
	configSpotlightBehavior: function(spotChild) {
		if (enyo.Spotlight.getChildren(this).length > 0) {
			if (spotChild) {
				enyo.Spotlight.spot(enyo.Spotlight.getFirstChild(this));
			}
		} else if (!this.spotlightModal) {
			this.activator.keepOpen = false;
			this.spotlight = false;
		}
	},
	//* Called when _this.spotlight_ changes.
	spotlightChanged: function() {
		this._spotlight = this.spotlight;
		this.configSpotlightBehavior(false);
	},
	//* Called when _this.spotlightModal_ changes.
	spotlightModalChanged: function() {
		this.configCloseButton();
	},
	//* Called when _this.showCloseButton_ changes.
	showCloseButtonChanged: function() {
		this.configCloseButton();
	},
	capturedEvent: function(inEventName, inEvent, inSender) {
		if (inEventName == "onSpotlightKeyDown") {
			if (inEvent.keyCode == 13) {
				this.downEvent = inEvent;
			}
			return true;
		}
		this.inherited(arguments);
	},
	//* Checks whether to allow spotlight to move in a given direction.
	spotChecker: function(inDirection) {
		var neighbor = enyo.Spotlight.NearestNeighbor.getNearestNeighbor(inDirection);
		if (!enyo.Spotlight.Util.isChild(this, neighbor)) {
			if (this.spotlightModal) {
				return true;
			} else {
				enyo.Spotlight.spot(this.activator);
				this.hide();
			}
		}
	},
	/**
		When spotlight reaches top edge of popup, prevents user from
		continuing further.
	*/
	spotlightUp: function(inSender, inEvent) {
		return this.spotChecker("UP");
	},
	/**
		When spotlight reaches bottom edge of popup, prevents user from
		continuing further.
	*/
	spotlightDown: function(inSender, inEvent) {
		return this.spotChecker("DOWN");
	},
	/**
		When spotlight reaches left edge of popup, prevents user from
		continuing further.
	*/
	spotlightLeft: function(inSender, inEvent) {
		return this.spotChecker("LEFT");
	},
	/**
		When spotlight reaches right edge of popup, prevents user from
		continuing further.
	*/
	spotlightRight: function(inSender, inEvent) {
		return this.spotChecker("RIGHT");
	},
	_preventEventBubble: function(inSender, inEvent) {
		return true;
	},
	showHideScrim: function(inShow) {
		if (this.floating && (this.scrim || (this.modal && this.scrimWhenModal))) {
			var scrim = this.getScrim();
			if (inShow && this.modal && this.scrimWhenModal) {
				// move scrim to just under the popup to obscure rest of screen
				var i = this.getScrimZIndex();
				this._scrimZ = i;
				scrim.showAtZIndex(i);
			} else {
				scrim.hideAtZIndex(this._scrimZ);
			}
			enyo.call(scrim, "addRemoveClass", [this.scrimClassName, scrim.showing]);
		}
	},
	getScrimZIndex: function() {
		// Position scrim directly below popup
		return this.findZIndex()-1;
	},
	getScrim: function() {
		// show a transparent scrim for modal popups if scrimWhenModal is true
		// if scrim is true, then show a regular scrim.
		if (this.modal && this.scrimWhenModal) {
			return moon.scrimTransparent.make();
		}
		return moon.scrim.make();
	},
	findZIndex: function() {
		// a default z value
		var z = this.defaultZ;
		if (this._zIndex) {
			z = this._zIndex;
		} else if (this.hasNode()) {
			// Re-use existing zIndex if it has one
			z = Number(enyo.dom.getComputedStyleValue(this.node, "z-index")) || z;
		}
		this._zIndex = z;
		return this._zIndex;
	},
	showingChanged: function() {
		this.inherited(arguments);
		this.showHideScrim(this.showing);
	}
});
<|endoftext|>


<commit_before>module.exports = function(grunt) {

	var  path = require('path')
		,configPath = '_config/'
		,configFiles = [
			 'default'
			,'project'
			,'secret'
			,'local'
		]
		,cfg ,modulesPattern ,buildBaseDir
	;

	// For testing we need to override the default config, if options from the CLI were specified.
	configPath = grunt.option('config-path') || configPath;
	configFiles = grunt.option('config-files') && grunt.option('config-files').split(',') || configFiles;

	// Merge configuration data
	cfg = require('./lib/configure').merge(configPath, configFiles).get();

	modulesPattern = path.join(cfg.paths.modulesBaseDir, cfg.moduleDirName.replace('{{name}}', '*'))
	buildBaseDir = path.join(cfg.paths.staticBaseDir, cfg.static.build.baseDirName); // build.baseDirName may be empty

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json')

		,staticUriPrefix:   (cfg.staticUriPrefix || '') + '/'
		,staticUriPrefixCss:cfg.staticUriPrefix && cfg.staticUriPrefix + '/' || ''

		// Sources base paths

		,tcInline:          cfg.paths.inline
		,tcBase:            cfg.paths.base
		,tcModules:         modulesPattern
		,tcApplication:     cfg.paths.application
		,staticDir:         cfg.paths.staticBaseDir

		// Output destinations

		,baseDirName:       cfg.static.build.baseDirName
		,buildBaseDir:      buildBaseDir
		,tmp:               '<%=buildBaseDir%>/tmp'
		,destJs:            '<%=buildBaseDir%>'
		,destCss:           '<%=buildBaseDir%>'
		,destSpritesCss:    '<%=tcBase%>/css/sprites' // technically this should go in tmp, but we want the generated classes in our base css for easy lookup.
		,destSpritesImg:    '<%=buildBaseDir%>'

		// Directory names

		,skinsDirName:      cfg.skinsDirName

		// Sources patterns

		,sources: {
			inline_css: [
				 '<%=tcInline%>/css/lib/*.{less,css}'
				,'<%=tcInline%>/css/*.less'
			]
			,external_css: [
				 '<%=tcBase%>/css/sprites/*.less'
				,'<%=tcBase%>/css/lib/*.{less,css}'
				,'<%=tcBase%>/css/elements/*.less'
				,'<%=tcModules%>/*.less'
				,'<%=tcModules%>/<%=skinsDirName%>/*.less'
				,'<%=tcApplication%>/css/*.less'
			]
			,inline_js: [
				 '<%=tcInline%>/js/lib/*.js'
				,'<%=tcInline%>/js/*.js'
			]
			,external_js: [
				 '<%=tcBase%>/js/lib/*.js'
				,'<%=tcBase%>/js/*.js'
				,'<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,module_test_js: [
				 '<%=staticDir%>/test/*.js'
				,'<%=tcModules%>/test/*.js'
			]
			,jshint_inline: [
				 '<%=tcInline%>/js/*.js'
			]
			,jshint_external: [
				 '<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,jshint_module_test: [
				 '<%=staticDir%>/_static/test/*.js'
				,'<%=tcModules%>/test/*.js'
			]
			,sprites: [
				'<%=tcBase%>/css/sprites/'
				//,'<%=tcModules%>/sprites/'
			]
		}

		//////////////////////////////////////////////////////////////

		,glue: {
			icons: {
				src: '<%=sources.sprites%>'
				//,dest: '<%=destSpritesCss%>/00-sprites.less'
				,options: '--css=<%=destSpritesCss%> --img=<%=destSpritesImg%> --less --url=<%=staticUriPrefix%><%=baseDirName%> --namespace=s --sprite-namespace= --recursive --crop --optipng --force --debug'
			}
		}
		,less_imports: {
			inline: {
				 src: '<%=sources.inline_css%>'
				,dest: '<%=tmp%>/inline-imports.less'
			},
			external: {
				options: {}
				,src: '<%=sources.external_css%>'
				,dest: '<%=tmp%>/external-imports.less'
			}
		}
		,jshint: {
			options: {
				// report but don't fail
				force: true
				// enforce
				,latedef: true
				,undef: true
				//relax
				,laxcomma: true
				,smarttabs: true
				,expr: true
				,asi: true
				,loopfunc: true
				,nonew: true
				// environment
				,browser: true
				,jquery: true
				,globals: {
					$: true
					,Tc: true
					,xtc: true
					,log: true
					// QUnit ಠ_ಠ
					,asyncTest      : true
					,deepEqual      : true
					,equal          : true
					,expect         : true
					,module         : true
					,notDeepEqual   : true
					,notEqual       : true
					,notStrictEqual : true
					,ok             : true
					,QUnit          : true
					,raises         : true
					,start          : true
					,stop           : true
					,strictEqual    : true
					,test           : true
				}
			}
			,inline: ['<%=sources.jshint_inline%>']
			,external: ['<%=sources.jshint_external%>']
			,module_tests: ['<%=sources.jshint_module_test%>']
		}
		,concat: {
			inline_scripts: {
				options: {
					banner: '/*! Inline script dependencies for page bootstrapping */\n'
				}
				,src: '<%=sources.inline_js%>'
				,dest: '<%=destJs%>/inline.js'
			}
			,external_scripts: {
				 src: '<%=sources.external_js%>'
				,dest: '<%=destJs%>/external.js'
			}
			,module_tests: {
				 src: '<%=sources.module_test_js%>'
				,dest: '<%=destJs%>/test.js'
			}
		},
		uglify: {
			inline: {
				options: {
					preserveComments: 'some'
				}
				,src: '<%=destJs%>/inline.js'
				,dest: '<%=destJs%>/inline.min.js'
			},
			external: {
				 src: '<%=destJs%>/external.js'
				,dest: '<%=destJs%>/external.min.js'
			}
		}
		,less: {
			inline: {
				options: {
					 // cssmin will not create file if the output is empty. a special comment fixes this.
					 banner: '/*! Inline style dependencies for page bootstrapping */'
					,imports: {
						reference: ['<%=tcInline%>/css/lib/reference/*.less']
					}
				}
				,src: '<%=tmp%>/inline-imports.less'
				,dest: '<%=destCss%>/inline.css'
			}
			,external: {
				options: {
					 banner: "@static-prefix: '<%=staticUriPrefixCss%>';"
					,imports: {
						reference: ['<%=tcBase%>/css/lib/reference/*.less']
					}
				}
				,src: '<%=tmp%>/external-imports.less'
				,dest: '<%=destCss%>/external.css'
			}
		}
		,cssmin: {
			inline: {
				 src: '<%=destCss%>/inline.css'
				,dest: '<%=destCss%>/inline.min.css'
			},
			external: {
				 src: '<%=destCss%>/external.css'
				,dest: '<%=destCss%>/external.min.css'
			}
		}
		,watch: {
			sprites: {
				files: ['<%=sources.sprites%>*.{png,jpg}']
				,tasks: ['build-sprites', 'build-external-css']
			},
			inline_styles: {
				files: ['<%=sources.inline_css%>', '<%=tcInline%>/css/lib/reference/*.less']
				,tasks: ['build-inline-css']
			},
			external_styles: {
				files: ['<%=sources.external_css%>', '<%=tcBase%>/css/lib/reference/*.less']
				,tasks: ['build-external-css']
			}
			,inline_scripts: {
				files: ['<%=sources.inline_js%>']
				,tasks: ['build-inline-js']
			}
			,external_scripts: {
				files: ['<%=sources.external_js%>']
				,tasks: ['build-external-js']
			}
			,module_tests: {
				files: ['<%=sources.module_test_js%>']
				,tasks: ['build-module-tests']
			}
		}
	});

	// get dependencies
	grunt.loadNpmTasks('grunt-glue');
	grunt.loadNpmTasks('grunt-less-imports');
	grunt.loadNpmTasks('assemble-less');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-watch');

	// create build tasks                            // use actual task name (first part before colon)!
	grunt.registerTask('build-sprites',              ['glue']);

	grunt.registerTask('build-inline-js',            ['concat:inline_scripts', 'uglify:inline', 'jshint:inline']);
	grunt.registerTask('build-external-js',          ['concat:external_scripts', 'uglify:external', 'jshint:external',]);
	grunt.registerTask('build-inline-css',           ['less_imports:inline',   'less:inline',   'cssmin:inline']);
	grunt.registerTask('build-external-css',         ['less_imports:external', 'less:external', 'cssmin:external']);
	grunt.registerTask('build-module-tests',         ['concat:module_tests' , 'jshint:module_tests']);

	var defaultTask = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'
		,'watch'
	];

	// If sprites building is not enabled in the app config, remove it.
	!cfg.enableSpritesBuilding && defaultTask.shift();

	// aggregate default task
	grunt.registerTask('default', defaultTask);

};<commit_msg>Improve gruntfile readability.<commit_after>module.exports = function(grunt) {

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Read project configuration

	var  path = require('path')
		,configPath = '_config/'
		,configFiles = [
			 'default'
			,'project'
			,'secret'
			,'local'
		]
		,cfg ,modulesPattern ,buildBaseDir
	;

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Read test configuration (if testing)

	// Override project config, if command line options contain a config location.
	configPath = grunt.option('config-path') || configPath;
	configFiles = grunt.option('config-files') && grunt.option('config-files').split(',') || configFiles;

	// Merge configurations
	cfg = require('./lib/configure').merge(configPath, configFiles).get();

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Create vars from config

	modulesPattern = path.join(cfg.paths.modulesBaseDir, cfg.moduleDirName.replace('{{name}}', '*'))
	buildBaseDir = path.join(cfg.paths.staticBaseDir, cfg.static.build.baseDirName); // build.baseDirName may be empty

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define grunt config

	grunt.initConfig({

		pkg: grunt.file.readJSON('package.json')

		,staticUriPrefix        : (cfg.staticUriPrefix || '') + '/'
		,staticUriPrefixCss     : cfg.staticUriPrefix && cfg.staticUriPrefix + '/' || ''

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Sources base paths

		,tcInline               : cfg.paths.inline
		,tcBase                 : cfg.paths.base
		,tcModules              : modulesPattern
		,tcApplication          : cfg.paths.application
		,staticDir              : cfg.paths.staticBaseDir

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Output destinations

		,baseDirName            : cfg.static.build.baseDirName
		,buildBaseDir           : buildBaseDir
		,tmp                    : '<%=buildBaseDir%>/tmp'
		,destJs                 : '<%=buildBaseDir%>'
		,destCss                : '<%=buildBaseDir%>'
		,destSpritesCss         : '<%=tcBase%>/css/sprites' // technically this should go in tmp, but we want the generated classes in our base css for easy lookup.
		,destSpritesImg         : '<%=buildBaseDir%>'

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Directory names

		,skinsDirName           : cfg.skinsDirName

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Define source file patterns

		,sources: {
			inline_css: [
				 '<%=tcInline%>/css/lib/*.{less,css}'
				,'<%=tcInline%>/css/*.less'
			]
			,external_css: [
				 '<%=tcBase%>/css/sprites/*.less'
				,'<%=tcBase%>/css/lib/*.{less,css}'
				,'<%=tcBase%>/css/elements/*.less'
				,'<%=tcModules%>/*.less'
				,'<%=tcModules%>/<%=skinsDirName%>/*.less'
				,'<%=tcApplication%>/css/*.less'
			]
			,inline_js: [
				 '<%=tcInline%>/js/lib/*.js'
				,'<%=tcInline%>/js/*.js'
			]
			,external_js: [
				 '<%=tcBase%>/js/lib/*.js'
				,'<%=tcBase%>/js/*.js'
				,'<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,module_test_js: [
				 '<%=staticDir%>/test/*.js'
				,'<%=tcModules%>/test/*.js'
			]
			,jshint_inline: [
				 '<%=tcInline%>/js/*.js'
			]
			,jshint_external: [
				 '<%=tcModules%>/*.js'
				,'<%=tcModules%>/<%=skinsDirName%>/*.js'
				,'<%=tcApplication%>/js/*.js'
			]
			,jshint_module_test: [
				 '<%=staticDir%>/_static/test/*.js'
				,'<%=tcModules%>/test/*.js'
			]
			,sprites: [
				'<%=tcBase%>/css/sprites/'
				//,'<%=tcModules%>/sprites/' // not implemented
			]
		}

		////////////////////////////////////////////////////////////////////////////////////////////////////////////////
		// Configure Grunt plugins

		,glue: {
			icons: {
				src: '<%=sources.sprites%>'
				//,dest: '<%=destSpritesCss%>/00-sprites.less' // not implemented
				,options: '--css=<%=destSpritesCss%> --img=<%=destSpritesImg%> --less --url=<%=staticUriPrefix%><%=baseDirName%> --namespace=s --sprite-namespace= --recursive --crop --optipng --force --debug'
			}
		}

		,less_imports: {
			inline: {
				 src: '<%=sources.inline_css%>'
				,dest: '<%=tmp%>/inline-imports.less'
			},
			external: {
				options: {}
				,src: '<%=sources.external_css%>'
				,dest: '<%=tmp%>/external-imports.less'
			}
		}

		,concat: {
			inline_scripts: {
				options: {
					banner: '/*! Inline script dependencies for page bootstrapping */\n'
				}
				,src: '<%=sources.inline_js%>'
				,dest: '<%=destJs%>/inline.js'
			}
			,external_scripts: {
				 src: '<%=sources.external_js%>'
				,dest: '<%=destJs%>/external.js'
			}
			,module_tests: {
				 src: '<%=sources.module_test_js%>'
				,dest: '<%=destJs%>/test.js'
			}
		}

		,uglify: {
			inline: {
				options: {
					preserveComments: 'some'
				}
				,src: '<%=destJs%>/inline.js'
				,dest: '<%=destJs%>/inline.min.js'
			},
			external: {
				 src: '<%=destJs%>/external.js'
				,dest: '<%=destJs%>/external.min.js'
			}
		}

		,less: {
			inline: {
				options: {
					 // cssmin will not create file if the output is empty. a special comment fixes this.
					 banner: '/*! Inline style dependencies for page bootstrapping */'
					,imports: {
						reference: ['<%=tcInline%>/css/lib/reference/*.less']
					}
				}
				,src: '<%=tmp%>/inline-imports.less'
				,dest: '<%=destCss%>/inline.css'
			}
			,external: {
				options: {
					 banner: "@static-prefix: '<%=staticUriPrefixCss%>';"
					,imports: {
						reference: ['<%=tcBase%>/css/lib/reference/*.less']
					}
				}
				,src: '<%=tmp%>/external-imports.less'
				,dest: '<%=destCss%>/external.css'
			}
		}

		,cssmin: {
			inline: {
				 src: '<%=destCss%>/inline.css'
				,dest: '<%=destCss%>/inline.min.css'
			},
			external: {
				 src: '<%=destCss%>/external.css'
				,dest: '<%=destCss%>/external.min.css'
			}
		}

		,jshint: {
			options: {
				// report but don't fail
				force: true
				// enforce
				,latedef: true
				,undef: true
				//relax
				,laxcomma: true
				,smarttabs: true
				,expr: true
				,asi: true
				,loopfunc: true
				,nonew: true
				// environment
				,browser: true
				,jquery: true
				,globals: {
					$: true
					,Tc: true
					,xtc: true
					// Lawg
					,log: true
					,dir: true
					,info: true
					,debug: true
					,warn: true
					,error: true
					,table: true
					// QUnit ಠ_ಠ
					,asyncTest      : true
					,deepEqual      : true
					,equal          : true
					,expect         : true
					,module         : true
					,notDeepEqual   : true
					,notEqual       : true
					,notStrictEqual : true
					,ok             : true
					,QUnit          : true
					,raises         : true
					,start          : true
					,stop           : true
					,strictEqual    : true
					,test           : true
				}
			}
			,inline: ['<%=sources.jshint_inline%>']
			,external: ['<%=sources.jshint_external%>']
			,module_tests: ['<%=sources.jshint_module_test%>']
		}

		,watch: {
			sprites: {
				files: ['<%=sources.sprites%>*.{png,jpg}']
				,tasks: ['build-sprites', 'build-external-css']
			},
			inline_styles: {
				files: ['<%=sources.inline_css%>', '<%=tcInline%>/css/lib/reference/*.less']
				,tasks: ['build-inline-css']
			},
			external_styles: {
				files: ['<%=sources.external_css%>', '<%=tcBase%>/css/lib/reference/*.less']
				,tasks: ['build-external-css']
			}
			,inline_scripts: {
				files: ['<%=sources.inline_js%>']
				,tasks: ['build-inline-js']
			}
			,external_scripts: {
				files: ['<%=sources.external_js%>']
				,tasks: ['build-external-js']
			}
			,module_tests: {
				files: ['<%=sources.module_test_js%>']
				,tasks: ['build-module-tests']
			}
		}
	});

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define build tasks                            // use actual task name (first part before colon)!

	grunt.registerTask('build-sprites',              ['glue']);
	grunt.registerTask('build-inline-js',            ['concat:inline_scripts', 'uglify:inline', 'jshint:inline']);
	grunt.registerTask('build-external-js',          ['concat:external_scripts', 'uglify:external', 'jshint:external',]);
	grunt.registerTask('build-inline-css',           ['less_imports:inline',   'less:inline',   'cssmin:inline']);
	grunt.registerTask('build-external-css',         ['less_imports:external', 'less:external', 'cssmin:external']);
	grunt.registerTask('build-module-tests',         ['concat:module_tests' , 'jshint:module_tests']);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Define a default task

	var defaultTask = [
		 'build-sprites'
		,'build-external-css'
		,'build-external-js'
		,'build-inline-css'
		,'build-inline-js'
		,'build-module-tests'
		,'watch'
	];

	// If sprites building is not enabled in the app config, remove it.
	!cfg.enableSpritesBuilding && defaultTask.shift();
	grunt.registerTask('default', defaultTask);

	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Load grunt plugins

	grunt.loadNpmTasks('grunt-glue');
	grunt.loadNpmTasks('grunt-less-imports');
	grunt.loadNpmTasks('assemble-less');
	grunt.loadNpmTasks('grunt-contrib-concat');
	grunt.loadNpmTasks('grunt-contrib-uglify');
	grunt.loadNpmTasks('grunt-contrib-jshint');
	grunt.loadNpmTasks('grunt-contrib-cssmin');
	grunt.loadNpmTasks('grunt-contrib-watch');

};
<|endoftext|>