<commit_before>// imports
var _ = require('lodash');
// gruntfile
module.exports = function (grunt) {
    'use strict';

        // development folders and files
    var SOURCE_PATH             =   'src/',
        SASS_PATH               =   SOURCE_PATH + 'styles/',
        JAVASCRIPT_PATH         =   SOURCE_PATH + 'scripts/',
        TEMPLATES_PATH          =   SOURCE_PATH + 'templates/',
        TEMPLATES_LAYOUTS_PATH  =   TEMPLATES_PATH + 'layouts/',
        TEMPLATES_PAGES_PATH    =   TEMPLATES_PATH + 'pages/',
        TEMPLATES_PARTIALS_PATH =   TEMPLATES_PATH + 'parts/',
        TEMPLATES_DATA_PATH     =   TEMPLATES_PATH + 'data/',
        HTML5_BOILERPLATE_PATH  =   'lib/html5-boilerplate/',
        JAVASCRIPT_LIBS         =   'lib/js/',
        NODE_MODULES_PATH       =   'node_modules/',
        JAVASCRIPT_LIBS_NODE    =   ['requirejs/require.js'],

        SASS_FILES              =   [SASS_PATH + '**/*.scss'],
        SCRIPTS_TO_IGNORE       =   ['!build.js', '!main-built.js'],
        JAVASCRIPT_SOURCES      =   ['*.js',
                                     JAVASCRIPT_PATH + '**/*.js'
                                    ].concat(SCRIPTS_TO_IGNORE),

        HTACCESS_BASE_FILE      =   HTML5_BOILERPLATE_PATH + '.htaccess',
        HTACCESS_FILE           =   SOURCE_PATH + 'htaccess.conf',
        MANIFEST_WEBAPP_NAME    =   'manifest.webapp',

        // build generated output
        BUILD_PATH              =   'build/',
        HTDOCS_PATH             =   BUILD_PATH + 'www/',
        CSS_PATH                =   HTDOCS_PATH + 'css/',
        FONTS_PATH              =   HTDOCS_PATH + 'fonts/',
        JS_PATH                 =   HTDOCS_PATH + 'js/',
        CSS_FILES               =   [CSS_PATH + '**/*.css'],
        HTML_FILES              =   [HTDOCS_PATH + '**/*.html'],
        JS_FILES                =   [JS_PATH + '**/*.js'],
        FILES_TO_CACHE          =   HTML_FILES.concat(CSS_FILES, JS_FILES),

        //themes
        POMPIERE_FONT_PATH      =   'lib/Pompiere',
        UBUNTU_THEME_PATH       =   'lib/ubuntu-html5-theme/0.1/ambiance/',

        // browser compatibility
        BROWSER_SUPPORT = [
            'last 2 version',
            'ff >= 18'
        ],

        // linters
        JSLINT_GLOBALS = [
            'module',
            'require',
            'console',
            'requirejs',
            'define',
            'window',
            'document',
            'onTouchStart',
            'onTouchMove',
            'onTouchEnd'
        ],
        JSLINT_DIRECTIVES = {
            nomen: true,
            predef: JSLINT_GLOBALS
        },
        GJSLINT_DISABLE = [
            '1',  //Extra space after "function" (Error 1)
            '6',  //Wrong indentation: expected x but got y (Error 6)
            '220' //No docs found for member (Error 220)
        ],
        GJSLINT_OPTIONS = {
            flags: [
                '--disable ' + GJSLINT_DISABLE.join(','),
                '--strict'
            ],
            reporter: {
                name: 'console'
            }
        },
        JS_LINTER = 'jshint',
        LIVE_RELOAD_ENABLED = true;

// Grunt tasks
// ---------------------------------------------------------------------------
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // Stylesheets
        compass: {
            options: {
                sassDir: SASS_PATH,
                cssDir: CSS_PATH,
                bundleExec: true,
                relativeAssets: true,
                fontsDir: FONTS_PATH
            },
            dev: {
                options: {
                    environment: 'development'
                }
            }
        },
        autoprefixer: {
            all: {
                options: {
                    browsers: BROWSER_SUPPORT
                },
                files: [{
                    expand: true,
                    cwd: CSS_PATH,
                    src: '*.css',
                    dest: CSS_PATH
                }]
            }
        },

        // Javascript
        jsvalidate: {
            all: JAVASCRIPT_SOURCES
        },
        jshint: {
            all: {
                src: JAVASCRIPT_SOURCES
            }
        },
        jslint: {
            all: {
                src: JAVASCRIPT_SOURCES,
                directives: JSLINT_DIRECTIVES
            }
        },

        gjslint: {
            options: GJSLINT_OPTIONS,
            all: {
                src: JAVASCRIPT_SOURCES
            }
        },

        // Apache Config
        concat: {
            htaccess: {
                files: [{
                    src: [
                        HTACCESS_BASE_FILE,
                        HTACCESS_FILE
                    ],
                    dest: HTDOCS_PATH + '.htaccess'
                }]
            }
        },

        // Templates
        assemble: {
            options: {
                flatten: true,
                layoutdir: TEMPLATES_LAYOUTS_PATH,
                partials: [TEMPLATES_PARTIALS_PATH + '**/*.hbs'],
                data: [TEMPLATES_DATA_PATH + '**/*.{json,yml}'],
                pkg: '<%= pkg %>'
            },
            pages: {
                files: [{
                    src: [
                        TEMPLATES_PAGES_PATH + '/**/*.hbs'
                    ],
                    dest: HTDOCS_PATH
                }]
            }
        },

        // Open Web App Manifest
        openwebapp: {
            options: {
                name: '<%= pkg.fullName %>',
                version: '<%= pkg.version %>',
                description: '<%= pkg.description %>',
                launch_path: '/app.html',
                developer: {
                    name: '<%= pkg.author.name %>',
                    url: '<%= pkg.author.url %>'
                },
                // icons: {
                //     "128": "/img/icons/app_128.png"
                // },
                installs_allowed_from: ['*']
            },
            all: {
                dest: HTDOCS_PATH + MANIFEST_WEBAPP_NAME
            }
        },

        //HTML indentation for generated pages
        prettify: {
            options: {
                indent: 4,
                indent_char: ' ',
                wrap_line_length: 78,
                brace_style: 'expand',
                unformatted: ['a', 'sub', 'sup', 'b', 'i', 'u']
            },
            all: {
                expand: true,
                cwd: HTDOCS_PATH,
                ext: '.html',
                src: ['**/*.html'],
                dest: HTDOCS_PATH
            }
        },

        //HTML Validation
        validation: {
            options: {
                reportpath: '.temp/validation-report.json',
                path: '.temp/validation-staus.json'
            },
            all: {
                options: {
                    reset: true
                },
                files: [{
                    src: HTML_FILES
                }]
            },
            repeat: {
                files: [{
                    src: HTML_FILES
                }]
            }
        },
        //Javascript modules concatenation
        requirejs: {
            compile: {
                options: {
                    almond: true,
                    baseUrl: "./build/www/js/lib",
                    paths: {
                        "main": '../main',
                        'domReady': 'requirejs/domReady',
                        'counter': 'mnmo/counter',
                        'counterSet': 'mnmo/counterSet',
                        'behavior': 'mnmo/behavior'
                    },
                    name: "main",
                    out: "./build/www/js/main-built.js"
                }
            }
        },
        // Theme assets
        copy: {
            ubuntu_fonts: {
                files: [{
                    expand: true,
                    src: [UBUNTU_THEME_PATH + 'fonts/**/*.{ttf,woff,svg,eot}'],
                    dest: HTDOCS_PATH + 'fonts/ubuntu/',
                    flatten: true
                }]
            },
            ubuntu_css: {
                files: [{
                    expand: true,
                    src: [UBUNTU_THEME_PATH + 'css/**/*.css'],
                    dest: HTDOCS_PATH + 'css/ubuntu/',
                    flatten: true
                }]
            },
            ubuntu_img: {
                files: [{
                    expand: true,
                    src: [UBUNTU_THEME_PATH + 'img/**/*'],
                    dest: HTDOCS_PATH + 'img/ubuntu/',
                    flatten: true
                }]
            },
            pompiere_fonts: {
                files: [{
                    expand: true,
                    src: [POMPIERE_FONT_PATH + '/**/*.{ttf,woff,svg,eot}'],
                    dest: HTDOCS_PATH + 'fonts/Pompiere/',
                    flatten: true
                }]

            },
            images: {
                files: [{
                    expand: true,
                    src: [SOURCE_PATH + 'img/**/*'],
                    dest: HTDOCS_PATH + 'img/',
                    flatten: true
                }]
            },
            js_libs: {
                files: [{
                    expand: true,
                    cwd: JAVASCRIPT_LIBS,
                    src: ['**/*.js'],
                    dest: HTDOCS_PATH + 'js/lib/'
                }]
            },
            js_libs_node: {
                files: [{
                    expand: true,
                    cwd: NODE_MODULES_PATH,
                    src: JAVASCRIPT_LIBS_NODE,
                    dest: HTDOCS_PATH + 'js/lib/'
                }]
            },
            scripts: {
                files: [{
                    expand: true,
                    cwd: JAVASCRIPT_PATH,
                    src: ['**/*.js'],
                    dest: HTDOCS_PATH + 'js/'
                }]
            }
        },

        'regex-replace': {
            ubuntu_assets_url: {
                src: [HTDOCS_PATH + 'css/ubuntu/**/*.css'],
                actions: [
                    {
                        name: 'img_paths',
                        search: '../img/',
                        replace: '../../img/ubuntu/',
                        flags: 'g'
                    }
                ]
            }
        },

        // Appcache
        manifest: {
            generate: {
                options: {
                    network: [
                    ],
                    process: function (path) {
                        // remove documentRoot part of the cached files paths
                        return path.substring(HTDOCS_PATH.length);
                    },
                    hash: true,
                    timestamp: false,
                    basePath: ''
                },
                src: FILES_TO_CACHE,
                dest: HTDOCS_PATH + 'manifest.appcache'
            }
        },

        // Watch
        watch: {
            options: {
                spawn: false
            },
            javascript: {
                files: JAVASCRIPT_SOURCES,
                tasks: ['jsvalidate', JS_LINTER, 'copy:scripts', 'requirejs'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED
                }
            },
            css: {
                files: CSS_FILES,
                tasks: ['autoprefixer'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED,
                    spawn: true
                }
            },
            html: {
                files: HTML_FILES,
                // tasks: ['prettify', 'validation:repeat'],
                tasks: ['validation:repeat'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED,
                    spawn: true
                }
            },
            assemble: {
                files: [
                    TEMPLATES_PATH + '/**/*.hbs',
                    TEMPLATES_DATA_PATH + '**/*.{json,yml}'
                ],
                tasks: ['assemble'],
                options: {
                    spawn: true
                }
            },
            update_htaccess: {
                files: HTACCESS_FILE,
                tasks: ['concat:htaccess']
            },
            sass: {
                files: SASS_FILES,
                tasks: ['compass'],
                options: {
                    spawn: true
                }
            },
            cache: {
                files: FILES_TO_CACHE,
                tasks: ['manifest'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED
                }
            }
        },
        // to grab dependencies
        curl: {
            'lib/requirejs/domReady.js':
            'https://raw.github.com/requirejs/domReady/latest/domReady.js'
        }
    });

    // on watch events configure certain tasks to only run on changed file
    grunt.event.on('watch', function (action, filepath) {
        if (action === 'deleted') { return; }
        grunt.config(['jsvalidate', 'all'], filepath);
        grunt.config(['jshint', 'all'], filepath);
        grunt.config(['jslint', 'all'], filepath);
        grunt.config(['gjslint', 'all'], filepath);
        grunt.config(['copy:scripts'], filepath);
        grunt.config(['autoprefixer', 'all'], filepath);
    });

    //run grunt.loadNpmTasks on each grunt plugin found in your package.json
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    grunt.loadNpmTasks('assemble');

    grunt.registerMultiTask(
        'openwebapp',
        'generate manifest.webapp file',
        function () {
            var task_options = {},
                target_options,
                done = this.async();
            if (grunt.config(this.name).options) {
                task_options = grunt.config(this.name).options;
            }
            if (this.target) {
                target_options = grunt.config([this.name, this.target]).options;
                // merge ("extend") the two option objects
                _.assign(task_options, target_options);
            }
            this.files.forEach(function (item) {
                if (item.dest) {
                    grunt.file.write(item.dest,
                        JSON.stringify(task_options, null, 4));
                    grunt.log.writeln('File "' + item.dest + '" created.');
                }
            });
            done(true);
        }
    );

    // the default task can be run just by typing "grunt" on the command line
    grunt.registerTask('default', [
        'jsvalidate',
        JS_LINTER,
        'assemble',
        'compass',
        'prettify',
        'validation:all',
        'copy:pompiere_fonts',
        'copy:images',
        'copy:js_libs',
        'copy:js_libs_node',
        'copy:scripts',
        'requirejs',
        'autoprefixer',
        'concat:htaccess',
        'openwebapp',
        'manifest'
    ]);

    // the default task can be run just by typing "grunt" on the command line
    grunt.registerTask('with-ubuntu', [
        'jsvalidate',
        JS_LINTER,
        'assemble',
        'compass',
        'prettify',
        'validation:all',
        'copy',
        'autoprefixer',
        'regex-replace',
        'concat:htaccess',
        'openwebapp',
        'manifest'
    ]);

    // lint js files on all linters
    grunt.registerTask('lint', [
        'jsvalidate',
        'jshint',
        'gjslint',
        'jslint'
    ]);
};
<commit_msg>wrong path :(<commit_after>// imports
var _ = require('lodash');
// gruntfile
module.exports = function (grunt) {
    'use strict';

        // development folders and files
    var SOURCE_PATH             =   'src/',
        SASS_PATH               =   SOURCE_PATH + 'styles/',
        JAVASCRIPT_PATH         =   SOURCE_PATH + 'scripts/',
        TEMPLATES_PATH          =   SOURCE_PATH + 'templates/',
        TEMPLATES_LAYOUTS_PATH  =   TEMPLATES_PATH + 'layouts/',
        TEMPLATES_PAGES_PATH    =   TEMPLATES_PATH + 'pages/',
        TEMPLATES_PARTIALS_PATH =   TEMPLATES_PATH + 'parts/',
        TEMPLATES_DATA_PATH     =   TEMPLATES_PATH + 'data/',
        HTML5_BOILERPLATE_PATH  =   'lib/html5-boilerplate/',
        JAVASCRIPT_LIBS         =   'lib/js/',
        NODE_MODULES_PATH       =   'node_modules/',
        JAVASCRIPT_LIBS_NODE    =   ['requirejs/require.js'],

        SASS_FILES              =   [SASS_PATH + '**/*.scss'],
        SCRIPTS_TO_IGNORE       =   ['!build.js', '!main-built.js'],
        JAVASCRIPT_SOURCES      =   ['*.js',
                                     JAVASCRIPT_PATH + '**/*.js'
                                    ].concat(SCRIPTS_TO_IGNORE),

        HTACCESS_BASE_FILE      =   HTML5_BOILERPLATE_PATH + '.htaccess',
        HTACCESS_FILE           =   SOURCE_PATH + 'htaccess.conf',
        MANIFEST_WEBAPP_NAME    =   'manifest.webapp',

        // build generated output
        BUILD_PATH              =   'build/',
        HTDOCS_PATH             =   BUILD_PATH + 'www/',
        CSS_PATH                =   HTDOCS_PATH + 'css/',
        FONTS_PATH              =   HTDOCS_PATH + 'fonts/',
        JS_PATH                 =   HTDOCS_PATH + 'js/',
        CSS_FILES               =   [CSS_PATH + '**/*.css'],
        HTML_FILES              =   [HTDOCS_PATH + '**/*.html'],
        JS_FILES                =   [JS_PATH + '**/*.js'],
        FILES_TO_CACHE          =   HTML_FILES.concat(CSS_FILES, JS_FILES),

        //themes
        POMPIERE_FONT_PATH      =   'lib/Pompiere',
        UBUNTU_THEME_PATH       =   'lib/ubuntu-html5-theme/0.1/ambiance/',

        // browser compatibility
        BROWSER_SUPPORT = [
            'last 2 version',
            'ff >= 18'
        ],

        // linters
        JSLINT_GLOBALS = [
            'module',
            'require',
            'console',
            'requirejs',
            'define',
            'window',
            'document',
            'onTouchStart',
            'onTouchMove',
            'onTouchEnd'
        ],
        JSLINT_DIRECTIVES = {
            nomen: true,
            predef: JSLINT_GLOBALS
        },
        GJSLINT_DISABLE = [
            '1',  //Extra space after "function" (Error 1)
            '6',  //Wrong indentation: expected x but got y (Error 6)
            '220' //No docs found for member (Error 220)
        ],
        GJSLINT_OPTIONS = {
            flags: [
                '--disable ' + GJSLINT_DISABLE.join(','),
                '--strict'
            ],
            reporter: {
                name: 'console'
            }
        },
        JS_LINTER = 'jshint',
        LIVE_RELOAD_ENABLED = true;

// Grunt tasks
// ---------------------------------------------------------------------------
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),

        // Stylesheets
        compass: {
            options: {
                sassDir: SASS_PATH,
                cssDir: CSS_PATH,
                bundleExec: true,
                relativeAssets: true,
                fontsDir: FONTS_PATH
            },
            dev: {
                options: {
                    environment: 'development'
                }
            }
        },
        autoprefixer: {
            all: {
                options: {
                    browsers: BROWSER_SUPPORT
                },
                files: [{
                    expand: true,
                    cwd: CSS_PATH,
                    src: '*.css',
                    dest: CSS_PATH
                }]
            }
        },

        // Javascript
        jsvalidate: {
            all: JAVASCRIPT_SOURCES
        },
        jshint: {
            all: {
                src: JAVASCRIPT_SOURCES
            }
        },
        jslint: {
            all: {
                src: JAVASCRIPT_SOURCES,
                directives: JSLINT_DIRECTIVES
            }
        },

        gjslint: {
            options: GJSLINT_OPTIONS,
            all: {
                src: JAVASCRIPT_SOURCES
            }
        },

        // Apache Config
        concat: {
            htaccess: {
                files: [{
                    src: [
                        HTACCESS_BASE_FILE,
                        HTACCESS_FILE
                    ],
                    dest: HTDOCS_PATH + '.htaccess'
                }]
            }
        },

        // Templates
        assemble: {
            options: {
                flatten: true,
                layoutdir: TEMPLATES_LAYOUTS_PATH,
                partials: [TEMPLATES_PARTIALS_PATH + '**/*.hbs'],
                data: [TEMPLATES_DATA_PATH + '**/*.{json,yml}'],
                pkg: '<%= pkg %>'
            },
            pages: {
                files: [{
                    src: [
                        TEMPLATES_PAGES_PATH + '/**/*.hbs'
                    ],
                    dest: HTDOCS_PATH
                }]
            }
        },

        // Open Web App Manifest
        openwebapp: {
            options: {
                name: '<%= pkg.fullName %>',
                version: '<%= pkg.version %>',
                description: '<%= pkg.description %>',
                launch_path: '/app.html',
                developer: {
                    name: '<%= pkg.author.name %>',
                    url: '<%= pkg.author.url %>'
                },
                // icons: {
                //     "128": "/img/icons/app_128.png"
                // },
                installs_allowed_from: ['*']
            },
            all: {
                dest: HTDOCS_PATH + MANIFEST_WEBAPP_NAME
            }
        },

        //HTML indentation for generated pages
        prettify: {
            options: {
                indent: 4,
                indent_char: ' ',
                wrap_line_length: 78,
                brace_style: 'expand',
                unformatted: ['a', 'sub', 'sup', 'b', 'i', 'u']
            },
            all: {
                expand: true,
                cwd: HTDOCS_PATH,
                ext: '.html',
                src: ['**/*.html'],
                dest: HTDOCS_PATH
            }
        },

        //HTML Validation
        validation: {
            options: {
                reportpath: '.temp/validation-report.json',
                path: '.temp/validation-staus.json'
            },
            all: {
                options: {
                    reset: true
                },
                files: [{
                    src: HTML_FILES
                }]
            },
            repeat: {
                files: [{
                    src: HTML_FILES
                }]
            }
        },
        //Javascript modules concatenation
        requirejs: {
            compile: {
                options: {
                    almond: true,
                    baseUrl: "./build/www/js/lib",
                    paths: {
                        "main": '../main',
                        'domReady': 'requirejs/domReady',
                        'counter': 'mnmo/counter',
                        'counterSet': 'mnmo/counterSet',
                        'behavior': 'mnmo/behavior'
                    },
                    name: "main",
                    out: "./build/www/js/main-built.js"
                }
            }
        },
        // Theme assets
        copy: {
            ubuntu_fonts: {
                files: [{
                    expand: true,
                    src: [UBUNTU_THEME_PATH + 'fonts/**/*.{ttf,woff,svg,eot}'],
                    dest: HTDOCS_PATH + 'fonts/ubuntu/',
                    flatten: true
                }]
            },
            ubuntu_css: {
                files: [{
                    expand: true,
                    src: [UBUNTU_THEME_PATH + 'css/**/*.css'],
                    dest: HTDOCS_PATH + 'css/ubuntu/',
                    flatten: true
                }]
            },
            ubuntu_img: {
                files: [{
                    expand: true,
                    src: [UBUNTU_THEME_PATH + 'img/**/*'],
                    dest: HTDOCS_PATH + 'img/ubuntu/',
                    flatten: true
                }]
            },
            pompiere_fonts: {
                files: [{
                    expand: true,
                    src: [POMPIERE_FONT_PATH + '/**/*.{ttf,woff,svg,eot}'],
                    dest: HTDOCS_PATH + 'fonts/Pompiere/',
                    flatten: true
                }]

            },
            images: {
                files: [{
                    expand: true,
                    src: [SOURCE_PATH + 'img/**/*'],
                    dest: HTDOCS_PATH + 'img/',
                    flatten: true
                }]
            },
            js_libs: {
                files: [{
                    expand: true,
                    cwd: JAVASCRIPT_LIBS,
                    src: ['**/*.js'],
                    dest: HTDOCS_PATH + 'js/lib/'
                }]
            },
            js_libs_node: {
                files: [{
                    expand: true,
                    cwd: NODE_MODULES_PATH,
                    src: JAVASCRIPT_LIBS_NODE,
                    dest: HTDOCS_PATH + 'js/lib/'
                }]
            },
            scripts: {
                files: [{
                    expand: true,
                    cwd: JAVASCRIPT_PATH,
                    src: ['**/*.js'],
                    dest: HTDOCS_PATH + 'js/'
                }]
            }
        },

        'regex-replace': {
            ubuntu_assets_url: {
                src: [HTDOCS_PATH + 'css/ubuntu/**/*.css'],
                actions: [
                    {
                        name: 'img_paths',
                        search: '../img/',
                        replace: '../../img/ubuntu/',
                        flags: 'g'
                    }
                ]
            }
        },

        // Appcache
        manifest: {
            generate: {
                options: {
                    network: [
                    ],
                    process: function (path) {
                        // remove documentRoot part of the cached files paths
                        return path.substring(HTDOCS_PATH.length);
                    },
                    hash: true,
                    timestamp: false,
                    basePath: ''
                },
                src: FILES_TO_CACHE,
                dest: HTDOCS_PATH + 'manifest.appcache'
            }
        },

        // Watch
        watch: {
            options: {
                spawn: false
            },
            javascript: {
                files: JAVASCRIPT_SOURCES,
                tasks: ['jsvalidate', JS_LINTER, 'copy:scripts', 'requirejs'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED
                }
            },
            css: {
                files: CSS_FILES,
                tasks: ['autoprefixer'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED,
                    spawn: true
                }
            },
            html: {
                files: HTML_FILES,
                // tasks: ['prettify', 'validation:repeat'],
                tasks: ['validation:repeat'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED,
                    spawn: true
                }
            },
            assemble: {
                files: [
                    TEMPLATES_PATH + '/**/*.hbs',
                    TEMPLATES_DATA_PATH + '**/*.{json,yml}'
                ],
                tasks: ['assemble'],
                options: {
                    spawn: true
                }
            },
            update_htaccess: {
                files: HTACCESS_FILE,
                tasks: ['concat:htaccess']
            },
            sass: {
                files: SASS_FILES,
                tasks: ['compass'],
                options: {
                    spawn: true
                }
            },
            cache: {
                files: FILES_TO_CACHE,
                tasks: ['manifest'],
                options: {
                    livereload: LIVE_RELOAD_ENABLED
                }
            }
        },
        // to grab dependencies
        curl: {
            'lib/js/requirejs/domReady.js':
            'https://raw.github.com/requirejs/domReady/latest/domReady.js'
        }
    });

    // on watch events configure certain tasks to only run on changed file
    grunt.event.on('watch', function (action, filepath) {
        if (action === 'deleted') { return; }
        grunt.config(['jsvalidate', 'all'], filepath);
        grunt.config(['jshint', 'all'], filepath);
        grunt.config(['jslint', 'all'], filepath);
        grunt.config(['gjslint', 'all'], filepath);
        grunt.config(['copy:scripts'], filepath);
        grunt.config(['autoprefixer', 'all'], filepath);
    });

    //run grunt.loadNpmTasks on each grunt plugin found in your package.json
    require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
    grunt.loadNpmTasks('assemble');

    grunt.registerMultiTask(
        'openwebapp',
        'generate manifest.webapp file',
        function () {
            var task_options = {},
                target_options,
                done = this.async();
            if (grunt.config(this.name).options) {
                task_options = grunt.config(this.name).options;
            }
            if (this.target) {
                target_options = grunt.config([this.name, this.target]).options;
                // merge ("extend") the two option objects
                _.assign(task_options, target_options);
            }
            this.files.forEach(function (item) {
                if (item.dest) {
                    grunt.file.write(item.dest,
                        JSON.stringify(task_options, null, 4));
                    grunt.log.writeln('File "' + item.dest + '" created.');
                }
            });
            done(true);
        }
    );

    // the default task can be run just by typing "grunt" on the command line
    grunt.registerTask('default', [
        'jsvalidate',
        JS_LINTER,
        'assemble',
        'compass',
        'prettify',
        'validation:all',
        'copy:pompiere_fonts',
        'copy:images',
        'copy:js_libs',
        'copy:js_libs_node',
        'copy:scripts',
        'requirejs',
        'autoprefixer',
        'concat:htaccess',
        'openwebapp',
        'manifest'
    ]);

    // the default task can be run just by typing "grunt" on the command line
    grunt.registerTask('with-ubuntu', [
        'jsvalidate',
        JS_LINTER,
        'assemble',
        'compass',
        'prettify',
        'validation:all',
        'copy',
        'autoprefixer',
        'regex-replace',
        'concat:htaccess',
        'openwebapp',
        'manifest'
    ]);

    // lint js files on all linters
    grunt.registerTask('lint', [
        'jsvalidate',
        'jshint',
        'gjslint',
        'jslint'
    ]);
};
<|endoftext|>


<commit_before>/**
 * The MIT License
 *
 * Copyright (c) 2012 Steven G. Brown
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * ----------------------------------------------------------------------------
 * UnitTestSuite
 * ----------------------------------------------------------------------------
 */

/**
 * @class Unit test suite.
 */
UnitTestSuite = {
  unitTestFunctions: []
};

/**
 * Add a test function to this suite.
 * @param {string} functionUnderTest The name of the function under test.
 * @param {function()} unitTestFunction The test function.
 */
UnitTestSuite.testFunctionFor = function(functionUnderTest, unitTestFunction) {
  UnitTestSuite.unitTestFunctions.push(
      {name: functionUnderTest, run: unitTestFunction});
};

/**
 * Run all of the test functions that have been added to this suite.
 * @return {UnitTestResult} The result of running this suite.
 */
UnitTestSuite.run = function() {
  UnitTestSuite.assertionsCount = 0;
  UnitTestSuite.failures = [];

  var iteration = function(unitTestFunction) {
    UnitTestSuite.unitTestFunctionName = unitTestFunction.name;
    try {
      unitTestFunction.run();
    } catch (ex) {
      this.failures.push(
          new UnitTestExceptionThrownFailure(
              UnitTestSuite.unitTestFunctionName, ex));
    }
  };

  UnitTestSuite.unitTestFunctions.forEach(iteration, UnitTestSuite);
  return new UnitTestResult(
      UnitTestSuite.assertionsCount, UnitTestSuite.failures);
};

/**
 * Assert that the actual value equals the expected value.
 * @param {string} description A description of the assertion.
 * @param {*} actual The actual value.
 * @param {*} expected The expected value.
 */
UnitTestSuite.assertThat = function(description, actual, expected) {
  if (!UnitTestSuite._equals(expected, actual)) {
    var failure = new UnitTestAssertionFailure(
        UnitTestSuite.unitTestFunctionName, description, actual, expected);
    UnitTestSuite.failures.push(failure);
  }
  UnitTestSuite.assertionsCount++;
};

/**
 * Has no effect; intended to make calls to the {@link UnitTestSuite.assertThat}
 * and {@link UnitTestSuite.assertThatEval} functions more readable.
 *

 * Example: assertThat(theSky, is(blue));
 * @param {*} value Any value.
 * @return {*} The value paramter (unchanged).
 */
UnitTestSuite.is = function(value) {
  return value;
};

/**
 * Quotes the given string value in the same way as the Console or Error Log.
 * @param {string} stringValue The string value.
 * @return {string} The quoted string.
 */
UnitTestSuite.quote = function(stringValue) {
  if (stringValue || stringValue === '') {
    return '\'' + stringValue + '\'';
  }
  return stringValue;
};

/**
 * Used by the {@link UnitTestSuite} assertion functions to determine if two
 * objects are equal.
 * @param {*} one The first object.
 * @param {*} two The second object.
 * @return {boolean} Whether the two objects are equal.
 */
UnitTestSuite._equals = function(one, two) {
  if (one instanceof Array && two instanceof Array) {
    if (one.length !== two.length) {
      return false;
    }
    var equalsFunction = arguments.callee;
    return one.every(function(oneItem, index) {
      var twoItem = two[index];
      return equalsFunction(oneItem, twoItem);
    });
  }
  if (one === undefined) {
    return two === undefined;
  }
  if (one === null) {
    return two === null;
  }
  return one === two || (one.equals && one.equals(two));
};

/**#@+
 * Function declared in the global scope as a convenience for test functions;
 * calls through to a function of the same name declared on the {UnitTestSuite}
 * object.
 */

/**
 */
var assertThat = UnitTestSuite.assertThat;

/**
 */
var assertThatEval = UnitTestSuite.assertThatEval;

/**
 */
var is = UnitTestSuite.is;

/**#@-
 */

/*
 * ----------------------------------------------------------------------------
 * UnitTestResult
 * ----------------------------------------------------------------------------
 */

/**
 * Unit test result returned by {@link UnitTestSuite#run}.
 * @param {number} numberOfAssertions The total number of unit test assertions.
 * @param {Array.<UnitTestAssertionFailure|UnitTestExceptionThrownFailure>}
 *     failures The assertion failures.
 * @constructor
 */
UnitTestResult = function(numberOfAssertions, failures) {
  this.numberOfAssertions = numberOfAssertions;
  this.failures = failures;
};

/**
 * @return {string} A description of this unit test result.
 */
UnitTestResult.prototype.toString = function() {
  var result = '';
  if (this.failures.length >= 1) {
    result += 'Unit test FAILED: ';
  }
  result +=
      this.numberOfAssertions - this.failures.length +
      ' of ' +
      this.numberOfAssertions +
      ' unit test assertions passed.\n';
  this.failures.forEach(function(unitTestFailure) {
    result += '\n' + unitTestFailure + '\n';
  });
  return result;
};

/*
 * ----------------------------------------------------------------------------
 * UnitTestAssertionFailure
 * ----------------------------------------------------------------------------
 */

/**
 * A unit test failure due to a failed assertion.
 * @param {string} functionUnderTestName The name of the function under test.
 * @param {string} description The description of the test case.
 * @param {*} actual The actual value.
 * @param {*} expected The expected value.
 * @constructor
 */
UnitTestAssertionFailure = function(
    functionUnderTestName, description, actual, expected) {
  this.functionUnderTestName = functionUnderTestName;
  this.description = description;
  this.actual = actual;
  this.expected = expected;
};

/**
 * @return {string} A description of this unit test failure.
 */
UnitTestAssertionFailure.prototype.toString = function() {
  var failureString = this.functionUnderTestName + '\n';
  if (this.description) {
    failureString += this.description + '\n';
  }
  failureString += 'Expected "' + this.expected + '"' +
                   ' but was "' + this.actual + '"';
  return failureString;
};

/*
 * ----------------------------------------------------------------------------
 * UnitTestExceptionThrownFailure
 * ----------------------------------------------------------------------------
 */

/**
 * A unit test failure due to a thrown exception.
 * @param {string} functionUnderTestName The name of the function under test.
 * @param {*} exception The exception that was thrown.
 * @constructor
 */
UnitTestExceptionThrownFailure = function(functionUnderTestName, exception) {
  this.functionUnderTestName = functionUnderTestName;
  this.exception = exception;
};

/**
 * @return {string} A description of this unit test failure.
 */
UnitTestExceptionThrownFailure.prototype.toString = function() {
  return this.functionUnderTestName + '\n' + this.exception;
};

<commit_msg>Improve readability of the test output<commit_after>/**
 * The MIT License
 *
 * Copyright (c) 2012 Steven G. Brown
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use,
 * copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following
 * conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 */

/*
 * ----------------------------------------------------------------------------
 * UnitTestSuite
 * ----------------------------------------------------------------------------
 */

/**
 * @class Unit test suite.
 */
UnitTestSuite = {
  unitTestFunctions: []
};

/**
 * Add a test function to this suite.
 * @param {string} functionUnderTest The name of the function under test.
 * @param {function()} unitTestFunction The test function.
 */
UnitTestSuite.testFunctionFor = function(functionUnderTest, unitTestFunction) {
  UnitTestSuite.unitTestFunctions.push(
      {name: functionUnderTest, run: unitTestFunction});
};

/**
 * Run all of the test functions that have been added to this suite.
 * @return {UnitTestResult} The result of running this suite.
 */
UnitTestSuite.run = function() {
  UnitTestSuite.assertionsCount = 0;
  UnitTestSuite.failures = [];

  var iteration = function(unitTestFunction) {
    UnitTestSuite.unitTestFunctionName = unitTestFunction.name;
    try {
      unitTestFunction.run();
    } catch (ex) {
      this.failures.push(
          new UnitTestExceptionThrownFailure(
              UnitTestSuite.unitTestFunctionName, ex));
    }
  };

  UnitTestSuite.unitTestFunctions.forEach(iteration, UnitTestSuite);
  return new UnitTestResult(
      UnitTestSuite.assertionsCount, UnitTestSuite.failures);
};

/**
 * Assert that the actual value equals the expected value.
 * @param {string} description A description of the assertion.
 * @param {*} actual The actual value.
 * @param {*} expected The expected value.
 */
UnitTestSuite.assertThat = function(description, actual, expected) {
  if (!UnitTestSuite._equals(expected, actual)) {
    var failure = new UnitTestAssertionFailure(
        UnitTestSuite.unitTestFunctionName, description, actual, expected);
    UnitTestSuite.failures.push(failure);
  }
  UnitTestSuite.assertionsCount++;
};

/**
 * Has no effect; intended to make calls to the {@link UnitTestSuite.assertThat}
 * and {@link UnitTestSuite.assertThatEval} functions more readable.
 *

 * Example: assertThat(theSky, is(blue));
 * @param {*} value Any value.
 * @return {*} The value paramter (unchanged).
 */
UnitTestSuite.is = function(value) {
  return value;
};

/**
 * Quotes the given string value in the same way as the Console or Error Log.
 * @param {string} stringValue The string value.
 * @return {string} The quoted string.
 */
UnitTestSuite.quote = function(stringValue) {
  if (stringValue || stringValue === '') {
    return '\'' + stringValue + '\'';
  }
  return stringValue;
};

/**
 * Used by the {@link UnitTestSuite} assertion functions to determine if two
 * objects are equal.
 * @param {*} one The first object.
 * @param {*} two The second object.
 * @return {boolean} Whether the two objects are equal.
 */
UnitTestSuite._equals = function(one, two) {
  if (one instanceof Array && two instanceof Array) {
    if (one.length !== two.length) {
      return false;
    }
    var equalsFunction = arguments.callee;
    return one.every(function(oneItem, index) {
      var twoItem = two[index];
      return equalsFunction(oneItem, twoItem);
    });
  }
  if (one === undefined) {
    return two === undefined;
  }
  if (one === null) {
    return two === null;
  }
  return one === two || (one.equals && one.equals(two));
};

/**#@+
 * Function declared in the global scope as a convenience for test functions;
 * calls through to a function of the same name declared on the {UnitTestSuite}
 * object.
 */

/**
 */
var assertThat = UnitTestSuite.assertThat;

/**
 */
var assertThatEval = UnitTestSuite.assertThatEval;

/**
 */
var is = UnitTestSuite.is;

/**#@-
 */

/*
 * ----------------------------------------------------------------------------
 * UnitTestResult
 * ----------------------------------------------------------------------------
 */

/**
 * Unit test result returned by {@link UnitTestSuite#run}.
 * @param {number} numberOfAssertions The total number of unit test assertions.
 * @param {Array.<UnitTestAssertionFailure|UnitTestExceptionThrownFailure>}
 *     failures The assertion failures.
 * @constructor
 */
UnitTestResult = function(numberOfAssertions, failures) {
  this.numberOfAssertions = numberOfAssertions;
  this.failures = failures;
};

/**
 * @return {string} A description of this unit test result.
 */
UnitTestResult.prototype.toString = function() {
  var result = '';
  if (this.failures.length >= 1) {
    result += '' + this.failures.length + ' of ' +
        this.numberOfAssertions + ' assertions FAILED
';
  } else {
    result += 'All ' + this.numberOfAssertions +
        ' unit test assertions passed.
';
  }
  this.failures.forEach(function(unitTestFailure) {
    result += unitTestFailure + '
';
  });
  return result;
};

/*
 * ----------------------------------------------------------------------------
 * UnitTestAssertionFailure
 * ----------------------------------------------------------------------------
 */

/**
 * A unit test failure due to a failed assertion.
 * @param {string} functionUnderTestName The name of the function under test.
 * @param {string} description The description of the test case.
 * @param {*} actual The actual value.
 * @param {*} expected The expected value.
 * @constructor
 */
UnitTestAssertionFailure = function(
    functionUnderTestName, description, actual, expected) {
  this.functionUnderTestName = functionUnderTestName;
  this.description = description;
  this.actual = actual;
  this.expected = expected;
};

/**
 * @return {string} A description of this unit test failure.
 */
UnitTestAssertionFailure.prototype.toString = function() {
  var failureString = '' + this.functionUnderTestName + '
';
  if (this.description) {
    failureString += this.description + '
';
  }
  failureString += 'Expected
"' + this.expected + '"
' +
                   'but was
"' + this.actual + '"';
  return failureString;
};

/*
 * ----------------------------------------------------------------------------
 * UnitTestExceptionThrownFailure
 * ----------------------------------------------------------------------------
 */

/**
 * A unit test failure due to a thrown exception.
 * @param {string} functionUnderTestName The name of the function under test.
 * @param {*} exception The exception that was thrown.
 * @constructor
 */
UnitTestExceptionThrownFailure = function(functionUnderTestName, exception) {
  this.functionUnderTestName = functionUnderTestName;
  this.exception = exception;
};

/**
 * @return {string} A description of this unit test failure.
 */
UnitTestExceptionThrownFailure.prototype.toString = function() {
  return this.functionUnderTestName + '\n' + this.exception;
};

<|endoftext|>


<commit_before>/**
 * Created by EXTIGLGCORREAG on 13/05/2014.
 */
'use strict';
module.exports = function(grunt) {
    var banner = '/*\n<%= pkg.name %> <%= pkg.version %>';
    banner += '- <%= pkg.description %>\n<%= pkg.repository.url %>\n';
    banner += 'Built on <%= grunt.template.today("yyyy-mm-dd") %>\n*/\n';
    var reportsFolder = 'reports';
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jslint: {
            // lint your project's server code
            server: {
                src: [ // some example files
                    'src/backend/*.js',
                    'src/backend/**/*.js'
                ],
                exclude: [

                ],
                directives: { // example directives
                    node: true,
                    todo: true
                },
                unparam: true,
                options: {
                    edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path
                    junit: reportsFolder + '/server-junit.xml', // write the output to a JUnit XML
                    log: reportsFolder + '/server-lint.log',
                    jslintXml: reportsFolder + '/server-jslint.xml',
                    errorsOnly: true, // only display errors
                    failOnError: false, // defaults to true
                    checkstyle: reportsFolder + '/server-checkstyle.xml', // write a checkstyle-XML
                    unparam: true
                }
            },
            test: {
                src: [ // some example files
                    'test/*.js',
                    'test/**/*.js'
                ],
                exclude: [

                ],
                directives: { // example directives
                    node: true,
                    todo: true
                },
                unparam: true,
                options: {
                    edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path
                    junit: reportsFolder + '/tests-junit.xml', // write the output to a JUnit XML
                    log: reportsFolder + '/tests-lint.log',
                    jslintXml: reportsFolder + '/tests-jslint.xml',
                    errorsOnly: true, // only display errors
                    failOnError: false, // defaults to true
                    checkstyle: reportsFolder + '/tests-checkstyle.xml', // write a checkstyle-XML
                    unparam: true
                }
            },
            // lint your project's client code
            client: {
                src: [
                    'src/client/**/*.js'
                ],
                directives: {
                    browser: true,
                    predef: [
                        'jQuery'
                    ]
                },
                options: {
                    junit: reportsFolder + '/client-junit.xml'
                }
            }
        },
        jshint: {
            files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },
        concat: {
            options: {
                separator: ';\n',
                banner: banner
            },
            build: {
                files: [{
                    src: ['src/*.js'],
                    dest: 'build/<%= pkg.name %>.js'
                }]
            }
        },
        uglify: {
            options: {
                banner: banner
            },
            build: {
                files: {
                    'build/<%= pkg.name %>.min.js':
                        ['build/<%= pkg.name %>.js'],
                }
            }
        },
        simplemocha: {
            options: {
                globals: ['expect'],
                timeout: 3000,
                ignoreLeaks: true,
                ui: 'bdd',
                reporter: 'tap'
            },
            all: { src: ['test/*.js'] }
        },
        coveralls: {
            options: {
                // LCOV coverage file relevant to every target
                src: reportsFolder + '/coverage/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: false
            }
        },
        mocha_istanbul: {
            coverage: {
                src: 'test', // the folder, not the files,
                options: {
                    mask: '*.spec.js',
                    dryRun: true,
                    coverageFolder: reportsFolder + '/coverage'
                }
            },
            cobertura: {
                src: 'test', // the folder, not the files
                options: {
                    coverage: true,
                    check: {
                        lines: 75,
                        statements: 75
                    },
                    coverageFolder: reportsFolder + '/coverage',
                    root: './src', // define where the cover task should consider the root of libraries that are covered by tests
                    reportFormats: ['cobertura','lcovonly', 'html']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-coveralls');
    grunt.loadNpmTasks('grunt-mocha-istanbul');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-simple-mocha');
    grunt.loadNpmTasks('grunt-jslint');

    grunt.registerTask('default', ['simplemocha', 'mocha_istanbul:coverage', 'coveralls']);
    grunt.registerTask('test', ['simplemocha', 'jshint', 'mocha_istanbul:coverage', 'coveralls']);
    grunt.registerTask('cobertura', ['mocha_istanbul:cobertura']);
};<commit_msg>remove jshint task<commit_after>/**
 * Created by EXTIGLGCORREAG on 13/05/2014.
 */
'use strict';
module.exports = function(grunt) {
    var banner = '/*\n<%= pkg.name %> <%= pkg.version %>';
    banner += '- <%= pkg.description %>\n<%= pkg.repository.url %>\n';
    banner += 'Built on <%= grunt.template.today("yyyy-mm-dd") %>\n*/\n';
    var reportsFolder = 'reports';
    grunt.initConfig({
        pkg: grunt.file.readJSON('package.json'),
        jslint: {
            // lint your project's server code
            server: {
                src: [ // some example files
                    'src/backend/*.js',
                    'src/backend/**/*.js'
                ],
                exclude: [

                ],
                directives: { // example directives
                    node: true,
                    todo: true
                },
                unparam: true,
                options: {
                    edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path
                    junit: reportsFolder + '/server-junit.xml', // write the output to a JUnit XML
                    log: reportsFolder + '/server-lint.log',
                    jslintXml: reportsFolder + '/server-jslint.xml',
                    errorsOnly: true, // only display errors
                    failOnError: false, // defaults to true
                    checkstyle: reportsFolder + '/server-checkstyle.xml', // write a checkstyle-XML
                    unparam: true
                }
            },
            test: {
                src: [ // some example files
                    'test/*.js',
                    'test/**/*.js'
                ],
                exclude: [

                ],
                directives: { // example directives
                    node: true,
                    todo: true
                },
                unparam: true,
                options: {
                    edition: 'latest', // specify an edition of jslint or use 'dir/mycustom-jslint.js' for own path
                    junit: reportsFolder + '/tests-junit.xml', // write the output to a JUnit XML
                    log: reportsFolder + '/tests-lint.log',
                    jslintXml: reportsFolder + '/tests-jslint.xml',
                    errorsOnly: true, // only display errors
                    failOnError: false, // defaults to true
                    checkstyle: reportsFolder + '/tests-checkstyle.xml', // write a checkstyle-XML
                    unparam: true
                }
            },
            // lint your project's client code
            client: {
                src: [
                    'src/client/**/*.js'
                ],
                directives: {
                    browser: true,
                    predef: [
                        'jQuery'
                    ]
                },
                options: {
                    junit: reportsFolder + '/client-junit.xml'
                }
            }
        },
        jshint: {
            files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
            options: {
                jshintrc: '.jshintrc'
            }
        },
        concat: {
            options: {
                separator: ';\n',
                banner: banner
            },
            build: {
                files: [{
                    src: ['src/*.js'],
                    dest: 'build/<%= pkg.name %>.js'
                }]
            }
        },
        uglify: {
            options: {
                banner: banner
            },
            build: {
                files: {
                    'build/<%= pkg.name %>.min.js':
                        ['build/<%= pkg.name %>.js'],
                }
            }
        },
        simplemocha: {
            options: {
                globals: ['expect'],
                timeout: 3000,
                ignoreLeaks: true,
                ui: 'bdd',
                reporter: 'tap'
            },
            all: { src: ['test/*.js'] }
        },
        coveralls: {
            options: {
                // LCOV coverage file relevant to every target
                src: reportsFolder + '/coverage/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: false
            }
        },
        mocha_istanbul: {
            coverage: {
                src: 'test', // the folder, not the files,
                options: {
                    mask: '*.spec.js',
                    dryRun: true,
                    coverageFolder: reportsFolder + '/coverage'
                }
            },
            cobertura: {
                src: 'test', // the folder, not the files
                options: {
                    coverage: true,
                    check: {
                        lines: 75,
                        statements: 75
                    },
                    coverageFolder: reportsFolder + '/coverage',
                    root: './src', // define where the cover task should consider the root of libraries that are covered by tests
                    reportFormats: ['cobertura','lcovonly', 'html']
                }
            }
        }
    });

    grunt.loadNpmTasks('grunt-coveralls');
    grunt.loadNpmTasks('grunt-mocha-istanbul');
    grunt.loadNpmTasks('grunt-contrib-jshint');
    grunt.loadNpmTasks('grunt-simple-mocha');
    grunt.loadNpmTasks('grunt-jslint');

    grunt.registerTask('default', ['simplemocha', 'mocha_istanbul:coverage', 'coveralls']);
    grunt.registerTask('test', ['simplemocha', 'mocha_istanbul:coverage', 'coveralls']);
    grunt.registerTask('cobertura', ['mocha_istanbul:cobertura']);
};<|endoftext|>


<commit_before>define([
    'layer/quadtree/RectRegion',
    'layer/set'
], function(
    RectRegion,
    Set
) {
    "use strict";

    var Math_floor = Math.floor;
    var Math_ceil = Math.ceil;

    var MAX_LEAF_NODES = 4;

    var Quadtree = function(region) {
        this.isLeaf = true;

        this.northWestNode = null;
        this.northEastNode = null;
        this.southWestNode = null;
        this.southEastNode = null;

        this.leafNodes = [];
        this.treeNodes = [];

        this.region = region;
    };

    Quadtree.prototype.subdivide = function() {
        var region;
        var parentRegion = this.region;
        var leafNodes = this.leafNodes;
        var treeNodes = this.treeNodes;
        var i = 0;
        var length = leafNodes.length;

        region = new RectRegion(
            parentRegion.x,
            parentRegion.y,
            Math_floor(parentRegion.width * .5),
            Math_floor(parentRegion.height * .5)
        );
        this.northWestNode = new Quadtree(region);
        treeNodes.push(this.northWestNode);

        region = new RectRegion(
            parentRegion.centerX,
            parentRegion.y,
            Math_ceil(parentRegion.width * .5),
            Math_floor(parentRegion.height * .5)
        );
        this.northEastNode = new Quadtree(region);
        treeNodes.push(this.northEastNode);

        region = new RectRegion(
            parentRegion.x,
            parentRegion.centerY,
            Math_floor(parentRegion.width * .5),
            Math_ceil(parentRegion.height * .5)
        );
        this.southWestNode = new Quadtree(region);
        treeNodes.push(this.southWestNode);

        region = new RectRegion(
            parentRegion.centerX,
            parentRegion.centerY,
            Math_ceil(parentRegion.width * .5),
            Math_ceil(parentRegion.height * .5)
        );
        this.southEastNode = new Quadtree(region);
        treeNodes.push(this.southEastNode);

        this.isLeaf = false;

        for (; i < length; i++) {
            this.insert(leafNodes[i]);
        }

        leafNodes.length = 0;
    };

    Quadtree.prototype.insert = function(region) {
        if (!this.region.hitTestRect(region)) {
            return false;
        }
        var leafNodes = this.leafNodes;

        var i = 0;

        if (leafNodes.length < MAX_LEAF_NODES) {
            leafNodes.push(region);
            return true;
        }

        var treeNodes = this.treeNodes;
        var length = treeNodes.length;

        if (length === 0) {
            this.subdivide();
            length = treeNodes.length;
        }

        var hasInserted = false;
        for (; i < length; i++) {
            var tree = treeNodes[i];

            if (treeNodes[i].insert(region)) {
                hasInserted = true;
            }
        }

        return hasInserted;
    };

    Quadtree.prototype.queryRegion = function(region) {
        var regions = new Set();
        if (!this.region.hitTestRect(region)) {
            return regions;
        }

        var i = 0;
        var length;
        var nodes;

        if (this.isLeaf) {
            nodes = this.leafNodes;
            length = nodes.length;

            for (; i < length; i++) {
                regions.addElement(nodes[i]);
            }
        } else {
            nodes = this.treeNodes;
            length = nodes.length;

            for (; i < length; i++) {
                regions.union(nodes[i].queryRegion(region));
            }
        }

        return regions;
    };

    return Quadtree;
});<commit_msg> * Added MIT header to quadtree<commit_after>/**
 * @fileOverview
 * Copyright (c) 2012 Adam Ranfelt
 *
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without restriction,
 * including without limitation the rights to use, copy, modify, merge,
 * publish, distribute, sublicense, and/or sell copies of the Software,
 * and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
 * OR OTHER DEALINGS IN THE SOFTWARE.
 *
 * Quadtree Module Definition
 * @author Adam Ranfelt <adamRenny@gmail.com>
 * @version 1.0
 */

define([
    'layer/quadtree/RectRegion',
    'layer/set'
], function(
    RectRegion,
    Set
) {
    "use strict";

    var Math_floor = Math.floor;
    var Math_ceil = Math.ceil;

    var MAX_LEAF_NODES = 4;

    var Quadtree = function(region) {
        this.isLeaf = true;

        this.northWestNode = null;
        this.northEastNode = null;
        this.southWestNode = null;
        this.southEastNode = null;

        this.leafNodes = [];
        this.treeNodes = [];

        this.region = region;
    };

    Quadtree.prototype.subdivide = function() {
        var region;
        var parentRegion = this.region;
        var leafNodes = this.leafNodes;
        var treeNodes = this.treeNodes;
        var i = 0;
        var length = leafNodes.length;

        region = new RectRegion(
            parentRegion.x,
            parentRegion.y,
            Math_floor(parentRegion.width * .5),
            Math_floor(parentRegion.height * .5)
        );
        this.northWestNode = new Quadtree(region);
        treeNodes.push(this.northWestNode);

        region = new RectRegion(
            parentRegion.centerX,
            parentRegion.y,
            Math_ceil(parentRegion.width * .5),
            Math_floor(parentRegion.height * .5)
        );
        this.northEastNode = new Quadtree(region);
        treeNodes.push(this.northEastNode);

        region = new RectRegion(
            parentRegion.x,
            parentRegion.centerY,
            Math_floor(parentRegion.width * .5),
            Math_ceil(parentRegion.height * .5)
        );
        this.southWestNode = new Quadtree(region);
        treeNodes.push(this.southWestNode);

        region = new RectRegion(
            parentRegion.centerX,
            parentRegion.centerY,
            Math_ceil(parentRegion.width * .5),
            Math_ceil(parentRegion.height * .5)
        );
        this.southEastNode = new Quadtree(region);
        treeNodes.push(this.southEastNode);

        this.isLeaf = false;

        for (; i < length; i++) {
            this.insert(leafNodes[i]);
        }

        leafNodes.length = 0;
    };

    Quadtree.prototype.insert = function(region) {
        if (!this.region.hitTestRect(region)) {
            return false;
        }
        var leafNodes = this.leafNodes;

        var i = 0;

        if (leafNodes.length < MAX_LEAF_NODES) {
            leafNodes.push(region);
            return true;
        }

        var treeNodes = this.treeNodes;
        var length = treeNodes.length;

        if (length === 0) {
            this.subdivide();
            length = treeNodes.length;
        }

        var hasInserted = false;
        for (; i < length; i++) {
            var tree = treeNodes[i];

            if (treeNodes[i].insert(region)) {
                hasInserted = true;
            }
        }

        return hasInserted;
    };

    Quadtree.prototype.queryRegion = function(region) {
        var regions = new Set();
        if (!this.region.hitTestRect(region)) {
            return regions;
        }

        var i = 0;
        var length;
        var nodes;

        if (this.isLeaf) {
            nodes = this.leafNodes;
            length = nodes.length;

            for (; i < length; i++) {
                regions.addElement(nodes[i]);
            }
        } else {
            nodes = this.treeNodes;
            length = nodes.length;

            for (; i < length; i++) {
                regions.union(nodes[i].queryRegion(region));
            }
        }

        return regions;
    };

    return Quadtree;
});<|endoftext|>


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

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'lib/emoji.js',
        dest: 'lib/emoji.min.js'
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true,
        browsers: ['PhantomJS'],
        logLevel: 'ERROR'
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-karma');

  grunt.registerTask('default', ['uglify']);

};
<commit_msg>grant task to upload coverage data to coveralls (dry-run mode currently)<commit_after>module.exports = function(grunt) {

  // Project configuration.
  grunt.initConfig({
    pkg: grunt.file.readJSON('package.json'),
    uglify: {
      options: {
        banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
      },
      build: {
        src: 'lib/emoji.js',
        dest: 'lib/emoji.min.js'
      }
    },
    karma: {
      unit: {
        configFile: 'karma.conf.js',
        singleRun: true,
        browsers: ['PhantomJS'],
        logLevel: 'ERROR'
      }
    },
    coveralls: {
      options: {
        debug: true,
        coverageDir: 'coverage/',
        dryRun: true,
        force: true,
        recursive: true
      }
    }
  });

  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-karma');
  grunt.loadNpmTasks('grunt-karma-coveralls');

  grunt.registerTask('default', ['uglify']);

};
<|endoftext|>


<commit_before>//Gruntfile
module.exports = function(grunt) {
  grunt.initConfig({
    concat: {
      options: {
        separator: ';',
      },
      app: {
        src: [
          './public/assets/bower/jquery/dist/jquery.js',
          './public/assets/bower/bootstrap/dist/js/bootstrap.js',
        ],
        dest: './public/assets/js/javascript.js',
      },
    },
    cssmin: {
      app: {
        src: [
          './public/assets/bower/bootstrap/dist/css/bootstrap.css',
        ],
        dest: './public/assets/css/stylesheet.css'
      }
    },
    uglify: {
      options: {
        mangle: false
      },
      app: {
        files: {
          './public/assets/js/javascript.js': './public/assets/js/javascript.js',
        }
      },
    },
    copy: {
      app: {
        files: [
          {
            expand: true,
            flatten: true,
            cwd: './public/assets/bower/bootstrap/fonts/',
            src: ['**'],
            dest: './public/assets/fonts/',
            filter: 'isFile'
          },
        ]
      }
    },
    watch: {
      app: {
        files: [
          './public/assets/bower/jquery/dist/jquery.js',
          './public/assets/bower/bootstrap/dist/js/bootstrap.js',
          './public/assets/bower/bootstrap/dist/css/bootstrap.css',
        ],
        tasks: ['concat:app','uglify:app','cssmin:app','copy:app'],
        options: {
          livereload: true
        }
      },
    }
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  grunt.registerTask('watch', ['watch']);
  grunt.registerTask('default', ['concat:app','uglify:app','cssmin:app','copy:app']);

};<commit_msg>use app as name of css and js<commit_after>//Gruntfile
module.exports = function(grunt) {
  grunt.initConfig({
    concat: {
      options: {
        separator: ';',
      },
      app: {
        src: [
          './public/assets/bower/jquery/dist/jquery.js',
          './public/assets/bower/bootstrap/dist/js/bootstrap.js',
        ],
        dest: './public/assets/js/app.js',
      },
    },
    cssmin: {
      app: {
        src: [
          './public/assets/bower/bootstrap/dist/css/bootstrap.css',
        ],
        dest: './public/assets/css/app.css'
      }
    },
    uglify: {
      options: {
        mangle: false
      },
      app: {
        files: {
          './public/assets/js/app.js': './public/assets/js/app.js',
        }
      },
    },
    copy: {
      app: {
        files: [
          {
            expand: true,
            flatten: true,
            cwd: './public/assets/bower/bootstrap/fonts/',
            src: ['**'],
            dest: './public/assets/fonts/',
            filter: 'isFile'
          },
        ]
      }
    },
    watch: {
      app: {
        files: [
          './public/assets/bower/jquery/dist/jquery.js',
          './public/assets/bower/bootstrap/dist/js/bootstrap.js',
          './public/assets/bower/bootstrap/dist/css/bootstrap.css',
        ],
        tasks: ['concat:app','uglify:app','cssmin:app','copy:app'],
        options: {
          livereload: true
        }
      },
    }
  });

  grunt.loadNpmTasks('grunt-contrib-concat');
  grunt.loadNpmTasks('grunt-contrib-watch');
  grunt.loadNpmTasks('grunt-contrib-less');
  grunt.loadNpmTasks('grunt-contrib-uglify');
  grunt.loadNpmTasks('grunt-contrib-copy');
  grunt.loadNpmTasks('grunt-contrib-cssmin');

  grunt.registerTask('watch', ['watch']);
  grunt.registerTask('default', ['concat:app','uglify:app','cssmin:app','copy:app']);

};
<|endoftext|>


<commit_before>// var buildData = function() {
//   var data = require('./data.json');
//   var html = '' +
//   '
' +
//   JSON.stringify(data) +
//   '
';
//   return html;
// };

//-------------------------------
//----Builders for page sections-
//-------------------------------

var buildHeader = function(pageTitle) {
  pageTitle = pageTitle || '';

  var html = '' +
  '' +
  '' +
  '<meta charset="UTF-8" />' +
  '<title>Roux - ' + pageTitle + '</title>' +
  "<link href='http://fonts.googleapis.com/css?family=Bree+Serif|Merriweather:400,300,300italic,400italic,700,700italic' rel='stylesheet' type='text/css'>" +
  "<link href='./lib/bootstrap/css/bootstrap.css' rel='stylesheet'>" +
  '' +
  '';

  return html;
};

var buildFooter = function() {
  var html = '' +
  '' +
  '' +
  '';

  return html;
};

var buildBodyIndex = function() {
  var html = '' +
  '
' +
  '
' +
  '
' +
  '
Main Content
' +
  '
' + loremText +
  '
' +
  '
' +
  '
' +
  '
Sidebar
' +
  '
' + loremText +
  '
' +
  '
' +
  '
' +
  '
';

  return html;

};

//-------------------------------
//----Builders for whole pages---
//-------------------------------

var buildPageIndex = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};
var buildPage404 = function() {
  var html = '' +
  buildHeader('404 page not found') +
  '
' +
  'Sorry this page does not exist
' +
  buildFooter();

  return html;
};
var buildPageFredrik = function() {
  var html = '' +
  buildHeader('404 page not found') +
  '
' +
  'Wowaweewa!  You got it working!
' +
  buildFooter();

  return html;
};

//-------------------------------
//----Exports Section------------
//-------------------------------

exports.createPage = function(key) {
  var pageFns = {
    index: buildPageIndex,
    fredrik: buildPageFredrik
  };

  if (pageFns[key] === undefined) {
    return buildPage404();
  }

  return pageFns[key]();
};

var loremText = 'Wowaweewa!  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod          tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,          quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo          consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse          cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non          proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
<commit_msg>Add placeholders for builder functions for rest of site<commit_after>// var buildData = function() {
//   var data = require('./data.json');
//   var html = '' +
//   '
' +
//   JSON.stringify(data) +
//   '
';
//   return html;
// };

//-------------------------------
//----Builders for page sections-
//-------------------------------

var buildHeader = function(pageTitle) {
  pageTitle = pageTitle || '';

  var html = '' +
  '' +
  '' +
  '<meta charset="UTF-8" />' +
  '<title>Roux - ' + pageTitle + '</title>' +
  "<link href='http://fonts.googleapis.com/css?family=Bree+Serif|Merriweather:400,300,300italic,400italic,700,700italic' rel='stylesheet' type='text/css'>" +
  "<link href='./lib/bootstrap/css/bootstrap.css' rel='stylesheet'>" +
  '' +
  '';

  return html;
};

var buildFooter = function() {
  var html = '' +
  '' +
  '' +
  '';

  return html;
};

var buildBodyIndex = function() {
  var html = '' +
  '
' +
  '
' +
  '
' +
  '
Main Content
' +
  '
' + loremText +
  '
' +
  '
' +
  '
' +
  '
Sidebar
' +
  '
' + loremText +
  '
' +
  '
' +
  '
' +
  '
';

  return html;

};

//-------------------------------
//----Builders for whole pages---
//-------------------------------

var buildPageIndex = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPageAbout = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPageArtists = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPagePrivacyPolicy = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPageRegister = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPageSchedule = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPageVenueTravel = function() {
  var html = '' +
  buildHeader('index') +
  buildBodyIndex() +
  buildFooter();

  return html;
};

var buildPage404 = function() {
  var html = '' +
  buildHeader('404 page not found') +
  '
' +
  'Sorry this page does not exist
' +
  buildFooter();

  return html;
};
var buildPageFredrik = function() {
  var html = '' +
  buildHeader('404 page not found') +
  '
' +
  'Wowaweewa!  You got it working!
' +
  buildFooter();

  return html;
};

//-------------------------------
//----Exports Section------------
//-------------------------------

exports.createPage = function(key) {
  var pageFns = {
    index: buildPageIndex,
    about: buildPageAbout,
    artists: buildPageArtists,
    privacypolicy: buildPagePrivacyPolicy,
    register: buildPageRegister,
    schedule: buildPageSchedule,
    venuetravel: buildPageVenueTravel,
    fredrik: buildPageFredrik
  };

  if (pageFns[key] === undefined) {
    return buildPage404();
  }

  return pageFns[key]();
};

var loremText = 'Wowaweewa!  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod          tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,          quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo          consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse          cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non          proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
<|endoftext|>


<commit_before>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

var React = require('react');
var stringify = require("json-stringify-pretty-compact");
var DocsArticle = require('../../DocsArticle');
var Search = require('grommet/components/Search');

var SIMPLE_SUGGESTIONS = ['item 1', 'item 2', 'item 3'];
var RICH_SUGGESTIONS = [
  {label: 'item 1', data: '/item-1'},
  {label: 'item 2', data: '/item-2'},
  {label: 'item 3', data: '/item-3'}
];

var SearchDoc = React.createClass({

  getInitialState: function () {
    return {
      value: "",
      simpleSuggestions: [],
      richSuggestions: []
    };
  },

  _onDOMChange: function (value) {
    var regexp = new RegExp('^' + value);
    var simpleSuggestions = SIMPLE_SUGGESTIONS.filter(function (suggestion) {
      return regexp.test(suggestion);
    });
    var richSuggestions = RICH_SUGGESTIONS.filter(function (suggestion) {
      return regexp.test(suggestion.label);
    });

    this.setState({
      value: value,
      simpleSuggestions: simpleSuggestions,
      richSuggestions: richSuggestions
    });
  },

  _onSelect: function (pseudoEvent, selected) {
    var value;
    if (pseudoEvent.suggestion.hasOwnProperty('label')) {
      value = pseudoEvent.suggestion.label;
    } else {
      value = pseudoEvent.suggestion;

    }
    this.setState({
      value: value,
      simpleSuggestions: [],
      richSuggestions: []
    });
  },

  render: function() {
    var inline =
    "<Search onDOMChange={...} onSelect={...} />";
    return (
      <DocsArticle title="Search" colorIndex="neutral-3">

A responsive search control.

{inline}

Options

defaultValue  {"{string}"}

What text to start with in the input.

dropAlign     {"{left: left|right, right: left|right, top: top|bottom, bottom: top|bottom}"}

Where to place the drop down.
              At most one of left or right and one of top or bottom should be specified.

inline        true|false

Indicates that the search input should always
              be visible.

onChange      {"function ({value: , label: }|{string}) {...}"}

Function that will be called when the user types some text
              into the input. This property is deprecated in favor of
              onDOMChange and onSelect.

onDOMChange   {"function (value) {...}"}

Function that will be called when the user types in the input.

onSelect      {"function ({target: , suggestion: }, selected) {...}"}

Function that will be called when the user selects a
              suggestion. The target corresponds to the embedded input element
              , allowing you to distinguish which component triggered the event
              . The suggestion contains the object chosen from the supplied
              suggestions. selected will be true when the user has chosen one
              of the suggestions, and false when the user presses enter after
              entering text (without selecting a suggestion).

placeHolder   {"{string}"}

Placeholder text to use when the input is empty.

responsive    true|false

Whether the search control is responsive (turns off inline search option for small screen sizes) . Defaults to true.

size          medium|large

The size of the Header. Defaults to medium.

suggestions   [{"{string}|{label: {string}, ...}"}, ...]

Suggestions to show, typically based on what the user has typed so far. You can pass an array of strings or objects. Objects must have a label: property but can have any other properties you like. This object will be given to the onSelect() handler (or onChange() handler) if the suggestion is selected.

value         {"{string}"}

What text to show in the input.

Examples

Default

            <Search onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search />"}

Left

            <Search onDOMChange={this._onDOMChange} onSelect={this._onSelect}  dropAlign={{right: 'right'}} />

{"<Search dropAlign={{right: \"right\"}} />"}

Suggestions and Value

            <Search value={this.state.value}
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search defaultValue=\"" +
            this.state.value + "\" suggestions={" +
            stringify(this.state.simpleSuggestions) + "} />"}

Inline

            <Search inline={true}/>

{"<Search inline={true}/>"}

Inline, Placeholder

            <Search inline={true} placeHolder="Search" />

{"<Search inline={true} placeHolder=\"Search\" />"}

Inline, Value, and Suggestions

            <Search inline={true} value={this.state.value}
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search inline={true} value=\"" +
            this.state.value + "\" suggestions={" +
            stringify(this.state.simpleSuggestions) + "}/>"}

Inline, Value, Rich Suggestions

            <Search inline={true} value={this.state.value}
              suggestions={this.state.richSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search inline={true} value=\"" +
            this.state.value + "\" suggestions={" +
            stringify(this.state.simpleSuggestions) + "}/>"}

Large

            <Search inline={true} value={this.state.value} size="large"
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search size=\"large\"> ..."}

          {/*}

Small

Avoid using this size as it is too small for touch devices.

            <Search inline={true} value={this.state.value} size="small"
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search size=\"small\"> ..."}

          {*/}

      </DocsArticle>
    );
  }
});

module.exports = SearchDoc;
<commit_msg>making lines < 80 characters<commit_after>// (C) Copyright 2014-2015 Hewlett Packard Enterprise Development LP

var React = require('react');
var stringify = require("json-stringify-pretty-compact");
var DocsArticle = require('../../DocsArticle');
var Search = require('grommet/components/Search');

var SIMPLE_SUGGESTIONS = ['item 1', 'item 2', 'item 3'];
var RICH_SUGGESTIONS = [
  {label: 'item 1', data: '/item-1'},
  {label: 'item 2', data: '/item-2'},
  {label: 'item 3', data: '/item-3'}
];

var SearchDoc = React.createClass({

  getInitialState: function () {
    return {
      value: "",
      simpleSuggestions: [],
      richSuggestions: []
    };
  },

  _onDOMChange: function (value) {
    var regexp = new RegExp('^' + value);
    var simpleSuggestions = SIMPLE_SUGGESTIONS.filter(function (suggestion) {
      return regexp.test(suggestion);
    });
    var richSuggestions = RICH_SUGGESTIONS.filter(function (suggestion) {
      return regexp.test(suggestion.label);
    });

    this.setState({
      value: value,
      simpleSuggestions: simpleSuggestions,
      richSuggestions: richSuggestions
    });
  },

  _onSelect: function (pseudoEvent, selected) {
    var value;
    if (pseudoEvent.suggestion.hasOwnProperty('label')) {
      value = pseudoEvent.suggestion.label;
    } else {
      value = pseudoEvent.suggestion;

    }
    this.setState({
      value: value,
      simpleSuggestions: [],
      richSuggestions: []
    });
  },

  render: function() {
    var inline =
    "<Search onDOMChange={...} onSelect={...} />";
    return (
      <DocsArticle title="Search" colorIndex="neutral-3">

A responsive search control.

{inline}

Options

defaultValue  {"{string}"}

What text to start with in the input.

dropAlign     {"{left: left|right, right: left|right, top: top|bottom, bottom: top|bottom}"}

Where to place the drop down.
              At most one of left or right and one of top or bottom should be specified.

inline        true|false

Indicates that the search input should always
              be visible.

onChange      {"function ({value: , label: }|{string}) {...}"}

Function that will be called when the user types some text
              into the input. This property is deprecated in favor of
              onDOMChange and onSelect.

onDOMChange   {"function (value) {...}"}

Function that will be called when the user types in the input.

onSelect      {"function ({target: , suggestion: }, selected) {...}"}

Function that will be called when the user selects a
              suggestion. The target corresponds to the embedded input element
              , allowing you to distinguish which component triggered the event
              . The suggestion contains the object chosen from the supplied
              suggestions. selected will be true when the user has chosen one
              of the suggestions, and false when the user presses enter after
              entering text (without selecting a suggestion).

placeHolder   {"{string}"}

Placeholder text to use when the input is empty.

responsive    true|false

Whether the search control is responsive (turns off inline
              search option for small screen sizes).
              Defaults to true.

size          medium|large

The size of the Header. Defaults to medium.

suggestions   [{"{string}|{label: {string}, ...}"}, ...]

Suggestions to show, typically based on what the user has
            typed so far. You can pass an array of strings or objects. Objects
            must have a label: property but can have any other properties you
            like. This object will be given to the onSelect() handler (or
            onChange() handler) if the suggestion is selected.

value         {"{string}"}

What text to show in the input.

Examples

Default

            <Search onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search />"}

Left

            <Search onDOMChange={this._onDOMChange} onSelect={this._onSelect}  dropAlign={{right: 'right'}} />

{"<Search dropAlign={{right: \"right\"}} />"}

Suggestions and Value

            <Search value={this.state.value}
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search defaultValue=\"" +
            this.state.value + "\" suggestions={" +
            stringify(this.state.simpleSuggestions) + "} />"}

Inline

            <Search inline={true}/>

{"<Search inline={true}/>"}

Inline, Placeholder

            <Search inline={true} placeHolder="Search" />

{"<Search inline={true} placeHolder=\"Search\" />"}

Inline, Value, and Suggestions

            <Search inline={true} value={this.state.value}
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search inline={true} value=\"" +
            this.state.value + "\" suggestions={" +
            stringify(this.state.simpleSuggestions) + "}/>"}

Inline, Value, Rich Suggestions

            <Search inline={true} value={this.state.value}
              suggestions={this.state.richSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search inline={true} value=\"" +
            this.state.value + "\" suggestions={" +
            stringify(this.state.simpleSuggestions) + "}/>"}

Large

            <Search inline={true} value={this.state.value} size="large"
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search size=\"large\"> ..."}

          {/*}

Small

Avoid using this size as it is too small for touch devices.

            <Search inline={true} value={this.state.value} size="small"
              suggestions={this.state.simpleSuggestions}
              onDOMChange={this._onDOMChange} onSelect={this._onSelect} />

{"<Search size=\"small\"> ..."}

          {*/}

      </DocsArticle>
    );
  }
});

module.exports = SearchDoc;
<|endoftext|>