Make WordPress Core

Ticket #31823: 31823.5.diff

File 31823.5.diff, 21.4 KB (added by netweb, 8 years ago)
  • Gruntfile.js

     
    1 /* jshint node:true */
    2 module.exports = function(grunt) {
    3         var path = require('path'),
     1/* global module, require, __dirname */
     2module.exports = function( grunt ) {
     3        var path = require( 'path' ),
    44                fs = require( 'fs' ),
    55                SOURCE_DIR = 'src/',
    66                BUILD_DIR = 'build/',
    7                 autoprefixer = require('autoprefixer'),
     7                autoprefixer = require( 'autoprefixer' ),
    88                mediaConfig = {},
    9                 mediaBuilds = ['audiovideo', 'grid', 'models', 'views'];
     9                mediaBuilds = [ 'audiovideo', 'grid', 'models', 'views' ];
    1010
    1111        // Load tasks.
    12         require('matchdep').filterDev(['grunt-*', '!grunt-legacy-util']).forEach( grunt.loadNpmTasks );
     12        require( 'matchdep' ).filterDev([ 'grunt-*', '!grunt-legacy-util' ]).forEach( grunt.loadNpmTasks );
     13
    1314        // Load legacy utils
    14         grunt.util = require('grunt-legacy-util');
     15        grunt.util = require( 'grunt-legacy-util' );
    1516
    16         mediaBuilds.forEach( function ( build ) {
     17        mediaBuilds.forEach( function( build ) {
    1718                var path = SOURCE_DIR + 'wp-includes/js/media';
    18                 mediaConfig[ build ] = { files : {} };
     19                mediaConfig[ build ] = { files: {} };
    1920                mediaConfig[ build ].files[ path + '-' + build + '.js' ] = [ path + '/' + build + '.manifest.js' ];
    20         } );
     21        });
    2122
    2223        // Project configuration.
    2324        grunt.initConfig({
     
    5758                        }
    5859                },
    5960                clean: {
    60                         all: [BUILD_DIR],
     61                        all: [ BUILD_DIR ],
    6162                        dynamic: {
    6263                                dot: true,
    6364                                expand: true,
    6465                                cwd: BUILD_DIR,
    6566                                src: []
    6667                        },
    67                         tinymce: ['<%= concat.tinymce.dest %>'],
    68                         qunit: ['tests/qunit/compiled.html']
     68                        tinymce: [ '<%= concat.tinymce.dest %>' ],
     69                        qunit: [ 'tests/qunit/compiled.html' ]
    6970                },
    7071                copy: {
    7172                        files: {
     
    115116                                                dest: BUILD_DIR + 'wp-admin/css/wp-admin.min.css'
    116117                                        },
    117118                                        {
    118                                                 src:  BUILD_DIR + 'wp-admin/css/wp-admin-rtl.css',
     119                                                src: BUILD_DIR + 'wp-admin/css/wp-admin-rtl.css',
    119120                                                dest: BUILD_DIR + 'wp-admin/css/wp-admin-rtl.min.css'
    120121                                        }
    121122                                ]
     
    130131                                                        version = version.replace( /-[\d]{5}$/, '-' + grunt.template.today( 'yyyymmdd.HHMMss' ) );
    131132
    132133                                                        /* jshint quotmark: true */
    133                                                         return "$wp_version = '" + version + "';";
     134                                                        return '$wp_version = \'' + version + '\';';
    134135                                                });
    135136                                        }
    136137                                },
     
    149150                                dest: 'tests/qunit/compiled.html',
    150151                                options: {
    151152                                        processContent: function( src ) {
    152                                                 return src.replace( /(\".+?\/)src(\/.+?)(?:.min)?(.js\")/g , function( match, $1, $2, $3 ) {
     153                                                return src.replace( /(\".+?\/)src(\/.+?)(?:.min)?(.js\")/g, function( match, $1, $2, $3 ) {
     154
    153155                                                        // Don't add `.min` to files that don't have it.
    154156                                                        return $1 + 'build' + $2 + ( /jquery$/.test( $2 ) ? '' : '.min' ) + $3;
    155                                                 } );
     157                                                });
    156158                                        }
    157159                                }
    158160                        }
     
    164166                                cwd: SOURCE_DIR,
    165167                                dest: BUILD_DIR,
    166168                                ext: '.css',
    167                                 src: ['wp-admin/css/colors/*/colors.scss'],
     169                                src: [ 'wp-admin/css/colors/*/colors.scss' ],
    168170                                options: {
    169171                                        outputStyle: 'expanded'
    170172                                }
     
    209211                },
    210212                rtlcss: {
    211213                        options: {
     214
    212215                                // rtlcss options
    213216                                opts: {
    214217                                        clean: false,
     
    240243                                                        {
    241244                                                                expr: /content/im,
    242245                                                                action: function( prop, value ) {
    243                                                                         if ( value === '"\\f141"' ) { // dashicons-arrow-left
     246                                                                        if ( '"\\f141"' === value ) { // dashicons-arrow-left
    244247                                                                                value = '"\\f139"';
    245                                                                         } else if ( value === '"\\f340"' ) { // dashicons-arrow-left-alt
     248                                                                        } else if ( '"\\f340"' === value ) { // dashicons-arrow-left-alt
    246249                                                                                value = '"\\f344"';
    247                                                                         } else if ( value === '"\\f341"' ) { // dashicons-arrow-left-alt2
     250                                                                        } else if ( '"\\f341"' === value ) { // dashicons-arrow-left-alt2
    248251                                                                                value = '"\\f345"';
    249                                                                         } else if ( value === '"\\f139"' ) { // dashicons-arrow-right
     252                                                                        } else if ( '"\\f139"' === value ) { // dashicons-arrow-right
    250253                                                                                value = '"\\f141"';
    251                                                                         } else if ( value === '"\\f344"' ) { // dashicons-arrow-right-alt
     254                                                                        } else if ( '"\\f344"' === value ) { // dashicons-arrow-right-alt
    252255                                                                                value = '"\\f340"';
    253                                                                         } else if ( value === '"\\f345"' ) { // dashicons-arrow-right-alt2
     256                                                                        } else if ( '"\\f345"' === value ) { // dashicons-arrow-right-alt2
    254257                                                                                value = '"\\f341"';
    255258                                                                        }
    256259                                                                        return { prop: prop, value: value };
     
    292295                                src: []
    293296                        }
    294297                },
     298                eslint: {
     299                        grunt: {
     300                                options: {
     301                                        configFile: 'node_modules/eslint-config-wordpress/index.js'
     302                                },
     303                                src: [ 'Gruntfile.js' ]
     304                        },
     305                        core: {
     306                                options: {
     307                                        configFile: 'node_modules/eslint-config-wordpress/index.js'
     308                                },
     309                                cwd: SOURCE_DIR,
     310                                src: [
     311                                        'wp-admin/js/*.js',
     312                                        'wp-includes/js/*.js',
     313
     314                                        // Built scripts.
     315                                        '!wp-includes/js/media-*',
     316
     317                                        // WordPress scripts inside directories
     318                                        'wp-includes/js/jquery/jquery.table-hotkeys.js',
     319                                        'wp-includes/js/mediaelement/wp-mediaelement.js',
     320                                        'wp-includes/js/mediaelement/wp-playlist.js',
     321                                        'wp-includes/js/plupload/handlers.js',
     322                                        'wp-includes/js/plupload/wp-plupload.js',
     323                                        'wp-includes/js/tinymce/plugins/wordpress/plugin.js',
     324                                        'wp-includes/js/tinymce/plugins/wp*/plugin.js',
     325
     326                                        // Third party scripts
     327                                        '!wp-admin/js/farbtastic.js',
     328                                        '!wp-includes/js/backbone*.js',
     329                                        '!wp-includes/js/swfobject.js',
     330                                        '!wp-includes/js/underscore*.js',
     331                                        '!wp-includes/js/colorpicker.js',
     332                                        '!wp-includes/js/hoverIntent.js',
     333                                        '!wp-includes/js/json2.js',
     334                                        '!wp-includes/js/tw-sack.js',
     335                                        '!wp-includes/js/twemoji.js',
     336                                        '!**/*.min.js'
     337                                ]
     338                        },
     339                        themes: {
     340                                options: {
     341                                        configFile: 'node_modules/eslint-config-wordpress/index.js'
     342                                },
     343                                expand: true,
     344                                cwd: SOURCE_DIR + 'wp-content/themes',
     345                                src: [
     346                                        'twenty*/**/*.js',
     347                                        '!twenty{eleven,twelve,thirteen}/**',
     348
     349                                        // Third party scripts
     350                                        '!twenty{fourteen,fifteen,sixteen,seventeen}/**/html5.js',
     351                                        '!twentyseventeen/assets/js/jquery.scrollTo.js'
     352                                ]
     353                        }
     354                },
    295355                jshint: {
    296                         options: grunt.file.readJSON('.jshintrc'),
     356                        options: grunt.file.readJSON( '.jshintrc' ),
    297357                        grunt: {
    298                                 src: ['Gruntfile.js']
     358                                src: [ 'Gruntfile.js' ]
    299359                        },
    300360                        tests: {
    301361                                src: [
     
    303363                                        '!tests/qunit/vendor/*',
    304364                                        '!tests/qunit/editor/**'
    305365                                ],
    306                                 options: grunt.file.readJSON('tests/qunit/.jshintrc')
     366                                options: grunt.file.readJSON( 'tests/qunit/.jshintrc' )
    307367                        },
    308368                        themes: {
    309369                                expand: true,
     
    311371                                src: [
    312372                                        'twenty*/**/*.js',
    313373                                        '!twenty{eleven,twelve,thirteen}/**',
     374
    314375                                        // Third party scripts
    315376                                        '!twenty{fourteen,fifteen,sixteen}/js/html5.js',
    316377                                        '!twentyseventeen/assets/js/html5.js',
     
    331392                                src: [
    332393                                        'wp-admin/js/**/*.js',
    333394                                        'wp-includes/js/*.js',
     395
    334396                                        // Built scripts.
    335397                                        '!wp-includes/js/media-*',
     398
    336399                                        // WordPress scripts inside directories
    337400                                        'wp-includes/js/jquery/jquery.table-hotkeys.js',
    338401                                        'wp-includes/js/mediaelement/wp-mediaelement.js',
     
    341404                                        'wp-includes/js/plupload/wp-plupload.js',
    342405                                        'wp-includes/js/tinymce/plugins/wordpress/plugin.js',
    343406                                        'wp-includes/js/tinymce/plugins/wp*/plugin.js',
     407
    344408                                        // Third party scripts
    345409                                        '!wp-admin/js/farbtastic.js',
    346410                                        '!wp-includes/js/backbone*.js',
     
    353417                                        '!wp-includes/js/twemoji.js',
    354418                                        '!**/*.min.js'
    355419                                ],
     420
    356421                                // Remove once other JSHint errors are resolved
    357422                                options: {
    358423                                        curly: false,
    359424                                        eqeqeq: false
    360425                                },
     426
    361427                                // Limit JSHint's run to a single specified file:
    362428                                //
    363429                                //    grunt jshint:core --file=filename.js
     
    367433                                //    grunt jshint:core --file=path/to/filename.js
    368434                                //
    369435                                filter: function( filepath ) {
    370                                         var index, file = grunt.option( 'file' );
     436                                        var index,
     437file = grunt.option( 'file' );
    371438
    372439                                        // Don't filter when no target file is specified
    373440                                        if ( ! file ) {
     
    393460                                        '**/*.js',
    394461                                        '!**/*.min.js'
    395462                                ],
     463
    396464                                // Limit JSHint's run to a single specified plugin directory:
    397465                                //
    398466                                //    grunt jshint:plugins --dir=foldername
    399467                                //
    400468                                filter: function( dirpath ) {
    401                                         var index, dir = grunt.option( 'dir' );
     469                                        var index,
     470dir = grunt.option( 'dir' );
    402471
    403472                                        // Don't filter when no target folder is specified
    404473                                        if ( ! dir ) {
     
    426495                phpunit: {
    427496                        'default': {
    428497                                cmd: 'phpunit',
    429                                 args: ['--verbose', '-c', 'phpunit.xml.dist']
     498                                args: [ '--verbose', '-c', 'phpunit.xml.dist' ]
    430499                        },
    431500                        ajax: {
    432501                                cmd: 'phpunit',
    433                                 args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'ajax']
     502                                args: [ '--verbose', '-c', 'phpunit.xml.dist', '--group', 'ajax' ]
    434503                        },
    435504                        multisite: {
    436505                                cmd: 'phpunit',
    437                                 args: ['--verbose', '-c', 'tests/phpunit/multisite.xml']
     506                                args: [ '--verbose', '-c', 'tests/phpunit/multisite.xml' ]
    438507                        },
    439508                        'external-http': {
    440509                                cmd: 'phpunit',
    441                                 args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'external-http']
     510                                args: [ '--verbose', '-c', 'phpunit.xml.dist', '--group', 'external-http' ]
    442511                        },
    443512                        'restapi-jsclient': {
    444513                                cmd: 'phpunit',
    445                                 args: ['--verbose', '-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient']
     514                                args: [ '--verbose', '-c', 'phpunit.xml.dist', '--group', 'restapi-jsclient' ]
    446515                        }
    447516                },
    448517                uglify: {
     
    488557                                cwd: SOURCE_DIR,
    489558                                dest: BUILD_DIR,
    490559                                ext: '.min.js',
    491                                 src: ['wp-includes/js/wp-embed.js']
     560                                src: [ 'wp-includes/js/wp-embed.js' ]
    492561                        },
    493562                        media: {
    494563                                expand: true,
     
    504573                        },
    505574                        jqueryui: {
    506575                                options: {
     576
    507577                                        // Preserve comments that start with a bang.
    508578                                        preserveComments: /^!/
    509579                                },
     
    511581                                cwd: SOURCE_DIR,
    512582                                dest: BUILD_DIR,
    513583                                ext: '.min.js',
    514                                 src: ['wp-includes/js/jquery/ui/*.js']
     584                                src: [ 'wp-includes/js/jquery/ui/*.js' ]
    515585                        },
    516586                        bookmarklet: {
    517587                                options: {
     
    524594                        },
    525595                        masonry: {
    526596                                options: {
     597
    527598                                        // Preserve comments that start with a bang.
    528599                                        preserveComments: /^!/
    529600                                },
     
    571642                                dest: BUILD_DIR + 'wp-includes/js/tinymce/wp-tinymce.js.gz'
    572643                        }
    573644                },
    574                 jsvalidate:{
     645                jsvalidate: {
    575646                        options: {
    576647                                globals: {},
    577                                 esprimaOptions:{},
     648                                esprimaOptions: {},
    578649                                verbose: false
    579650                        },
    580651                        build: {
     
    612683                                files: [
    613684                                        SOURCE_DIR + '**',
    614685                                        '!' + SOURCE_DIR + 'wp-includes/js/media/**',
     686
    615687                                        // Ignore version control directories.
    616688                                        '!' + SOURCE_DIR + '**/.{svn,git}/**'
    617689                                ],
    618                                 tasks: ['clean:dynamic', 'copy:dynamic'],
     690                                tasks: [ 'clean:dynamic', 'copy:dynamic' ],
    619691                                options: {
    620692                                        dot: true,
    621693                                        spawn: false,
     
    626698                                files: 'Gruntfile.js'
    627699                        },
    628700                        colors: {
    629                                 files: [SOURCE_DIR + 'wp-admin/css/colors/**'],
    630                                 tasks: ['sass:colors']
     701                                files: [ SOURCE_DIR + 'wp-admin/css/colors/**' ],
     702                                tasks: [ 'sass:colors' ]
    631703                        },
    632704                        rtl: {
    633705                                files: [
    634706                                        SOURCE_DIR + 'wp-admin/css/*.css',
    635707                                        SOURCE_DIR + 'wp-includes/css/*.css'
    636708                                ],
    637                                 tasks: ['rtlcss:dynamic'],
     709                                tasks: [ 'rtlcss:dynamic' ],
    638710                                options: {
    639711                                        spawn: false,
    640712                                        interval: 2000
     
    645717                                        'tests/qunit/**',
    646718                                        '!tests/qunit/editor/**'
    647719                                ],
    648                                 tasks: ['qunit']
     720                                tasks: [ 'qunit' ]
    649721                        }
    650722                }
    651723        });
    652724
    653725        // Allow builds to be minimal
    654         if( grunt.option( 'minimal-copy' ) ) {
     726        if ( grunt.option( 'minimal-copy' ) ) {
    655727                var copyFilesOptions = grunt.config.get( 'copy.files.files' );
    656728                copyFilesOptions[0].src.push( '!wp-content/plugins/**' );
    657729                copyFilesOptions[0].src.push( '!wp-content/themes/!(twenty*)/**' );
     
    662734        // Register tasks.
    663735
    664736        // RTL task.
    665         grunt.registerTask('rtl', ['rtlcss:core', 'rtlcss:colors']);
     737        grunt.registerTask( 'rtl', [ 'rtlcss:core', 'rtlcss:colors' ]);
    666738
    667739        // Color schemes task.
    668         grunt.registerTask('colors', ['sass:colors', 'postcss:colors']);
     740        grunt.registerTask( 'colors', [ 'sass:colors', 'postcss:colors' ]);
    669741
    670742        // JSHint task.
    671743        grunt.registerTask( 'jshint:corejs', [
     
    674746                'jshint:themes',
    675747                'jshint:core',
    676748                'jshint:media'
    677         ] );
     749        ]);
    678750
    679751        grunt.registerTask( 'restapi-jsclient', [
    680752                'phpunit:restapi-jsclient',
    681753                'qunit:compiled'
    682         ] );
     754        ]);
    683755
    684756        grunt.renameTask( 'watch', '_watch' );
    685757
    686758        grunt.registerTask( 'watch', function() {
    687                 if ( ! this.args.length || this.args.indexOf( 'browserify' ) > -1 ) {
     759                if ( ! this.args.length || -1 < this.args.indexOf( 'browserify' ) ) {
    688760                        grunt.config( 'browserify.options', {
    689761                                browserifyOptions: {
    690762                                        debug: true
    691763                                },
    692764                                watch: true
    693                         } );
     765                        });
    694766
    695767                        grunt.task.run( 'browserify' );
    696768                }
    697769
    698770                grunt.task.run( '_' + this.nameArgs );
    699         } );
     771        });
    700772
    701773        grunt.registerTask( 'precommit:image', [
    702774                'imagemin:core'
    703         ] );
     775        ]);
    704776
    705777        grunt.registerTask( 'precommit:js', [
    706778                'browserify',
     
    708780                'uglify:bookmarklet',
    709781                'uglify:masonry',
    710782                'qunit:compiled'
    711         ] );
     783        ]);
    712784
    713785        grunt.registerTask( 'precommit:css', [
    714786                'postcss:core'
    715         ] );
     787        ]);
    716788
    717789        grunt.registerTask( 'precommit:php', [
    718790                'phpunit'
    719         ] );
     791        ]);
    720792
    721793        grunt.registerTask( 'precommit', 'Runs test and build tasks in preparation for a commit', function() {
    722794                var done = this.async();
     
    725797                        git: 'git status --short'
    726798                };
    727799
    728                 find( [
     800                find([
    729801                        __dirname + '/.svn',
    730802                        __dirname + '/.git',
    731803                        path.dirname( __dirname ) + '/.svn'
    732                 ] );
     804                ]);
    733805
    734806                function find( set ) {
    735807                        var dir;
    736808
    737809                        if ( set.length ) {
    738810                                fs.stat( dir = set.shift(), function( error ) {
    739                                         error ? find( set ) : run( path.basename( dir ).substr( 1 ) );
    740                                 } );
     811                                        if ( error ) {
     812                                                find( set );
     813                                        } else {
     814                                                run( path.basename( dir ).substr( 1 ) );
     815                                        }
     816                                });
    741817                        } else {
    742818                                grunt.fatal( 'This WordPress install is not under version control.' );
    743819                        }
     
    746822                function run( type ) {
    747823                        var command = map[ type ].split( ' ' );
    748824
    749                         grunt.util.spawn( {
     825                        grunt.util.spawn({
    750826                                cmd: command.shift(),
    751827                                args: command
    752828                        }, function( error, result, code ) {
    753829                                var taskList = [];
    754830
    755                                 if ( code !== 0 ) {
     831                                if ( 0 !== code ) {
    756832                                        grunt.fatal( 'The `' +  map[ type ] + '` command returned a non-zero exit code.', code );
    757833                                }
    758834
     
    768844                                        return regex.test( result.stdout );
    769845                                }
    770846
    771                                 if ( [ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
     847                                if ([ 'package.json', 'Gruntfile.js' ].some( testPath ) ) {
    772848                                        grunt.log.writeln( 'Configuration files modified. Running `prerelease`.' );
    773849                                        taskList.push( 'prerelease' );
    774850                                } else {
    775                                         if ( [ 'png', 'jpg', 'gif', 'jpeg' ].some( testExtension ) ) {
     851                                        if ([ 'png', 'jpg', 'gif', 'jpeg' ].some( testExtension ) ) {
    776852                                                grunt.log.writeln( 'Image files modified. Minifying.' );
    777853                                                taskList.push( 'precommit:image' );
    778854                                        }
     
    782858                                                        grunt.log.writeln( extension.toUpperCase() + ' files modified. ' + extension.toUpperCase() + ' tests will be run.' );
    783859                                                        taskList.push( 'precommit:' + extension );
    784860                                                }
    785                                         } );
     861                                        });
    786862                                }
    787863
    788864                                grunt.task.run( taskList );
    789865
    790866                                done();
    791                         } );
     867                        });
    792868                }
    793         } );
     869        });
    794870
    795871        grunt.registerTask( 'copy:all', [
    796872                'copy:files',
    797873                'copy:wp-admin-css-compat-rtl',
    798874                'copy:wp-admin-css-compat-min',
    799875                'copy:version'
    800         ] );
     876        ]);
    801877
    802878        grunt.registerTask( 'build', [
    803879                'clean:all',
     
    817893                'includes:emoji',
    818894                'includes:embed',
    819895                'jsvalidate:build'
    820         ] );
     896        ]);
    821897
    822898        grunt.registerTask( 'prerelease', [
    823899                'precommit:php',
    824900                'precommit:js',
    825901                'precommit:css',
    826902                'precommit:image'
    827         ] );
     903        ]);
    828904
    829905        // Testing tasks.
    830         grunt.registerMultiTask('phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() {
     906        grunt.registerMultiTask( 'phpunit', 'Runs PHPUnit tests, including the ajax, external-http, and multisite tests.', function() {
    831907                grunt.util.spawn({
    832908                        cmd: this.data.cmd,
    833909                        args: this.data.args,
    834910                        opts: {stdio: 'inherit'}
    835                 }, this.async());
     911                }, this.async() );
    836912        });
    837913
    838         grunt.registerTask('qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.',
    839                 ['build', 'copy:qunit', 'qunit']);
     914        grunt.registerTask( 'qunit:compiled', 'Runs QUnit tests on compiled as well as uncompiled scripts.',
     915                [ 'build', 'copy:qunit', 'qunit' ]);
    840916
    841         grunt.registerTask('test', 'Runs all QUnit and PHPUnit tasks.', ['qunit:compiled', 'phpunit']);
     917        grunt.registerTask( 'test', 'Runs all QUnit and PHPUnit tasks.', [ 'qunit:compiled', 'phpunit' ]);
    842918
    843919        // Travis CI tasks.
    844         grunt.registerTask('travis:js', 'Runs Javascript Travis CI tasks.', [ 'jshint:corejs', 'qunit:compiled' ]);
    845         grunt.registerTask('travis:phpunit', 'Runs PHPUnit Travis CI tasks.', 'phpunit');
     920        grunt.registerTask( 'travis:js', 'Runs Javascript Travis CI tasks.', [ 'jshint:corejs', 'qunit:compiled' ]);
     921        grunt.registerTask( 'travis:phpunit', 'Runs PHPUnit Travis CI tasks.', 'phpunit' );
    846922
    847923        // Patch task.
    848         grunt.renameTask('patch_wordpress', 'patch');
     924        grunt.renameTask( 'patch_wordpress', 'patch' );
    849925
    850926        // Add an alias `apply` of the `patch` task name.
    851         grunt.registerTask('apply', 'patch');
     927        grunt.registerTask( 'apply', 'patch' );
    852928
    853929        // Default task.
    854         grunt.registerTask('default', ['build']);
     930        grunt.registerTask( 'default', [ 'build' ]);
    855931
    856932        /*
    857933         * Automatically updates the `:dynamic` configurations
    858934         * so that only the changed files are updated.
    859935         */
    860         grunt.event.on('watch', function( action, filepath, target ) {
     936        grunt.event.on( 'watch', function( action, filepath, target ) {
    861937                var src;
    862938
    863                 if ( [ 'all', 'rtl', 'browserify' ].indexOf( target ) === -1 ) {
     939                if ( -1 === [ 'all', 'rtl', 'browserify' ].indexOf( target ) ) {
    864940                        return;
    865941                }
    866942
    867943                src = [ path.relative( SOURCE_DIR, filepath ) ];
    868944
    869                 if ( action === 'deleted' ) {
    870                         grunt.config( [ 'clean', 'dynamic', 'src' ], src );
     945                if ( 'deleted' === action ) {
     946                        grunt.config([ 'clean', 'dynamic', 'src' ], src );
    871947                } else {
    872                         grunt.config( [ 'copy', 'dynamic', 'src' ], src );
     948                        grunt.config([ 'copy', 'dynamic', 'src' ], src );
    873949
    874                         if ( target === 'rtl' ) {
    875                                 grunt.config( [ 'rtlcss', 'dynamic', 'src' ], src );
     950                        if ( 'rtl' === target ) {
     951                                grunt.config([ 'rtlcss', 'dynamic', 'src' ], src );
    876952                        }
    877953                }
    878954        });
  • package.json

     
    1313  "license": "GPL-2.0+",
    1414  "devDependencies": {
    1515    "autoprefixer": "^6.5.1",
     16    "eslint": "~3.19.0",
     17    "eslint-config-wordpress": "~2.0.0",
    1618    "grunt": "~0.4.5",
    1719    "grunt-browserify": "~5.0.0",
    1820    "grunt-contrib-clean": "~1.0.0",
     
    2527    "grunt-contrib-qunit": "^1.2.0",
    2628    "grunt-contrib-uglify": "~2.0.0",
    2729    "grunt-contrib-watch": "~1.0.0",
     30    "grunt-eslint": "~19.0.0",
    2831    "grunt-includes": "~0.5.1",
    2932    "grunt-jsvalidate": "~0.2.2",
    3033    "grunt-legacy-util": "^0.2.0",
  • src/wp-content/themes/twentyfourteen/js/slider.js

     
    2020                // Make variables public.
    2121                slider.vars = $.extend( {}, $.featuredslider.defaults, options );
    2222
    23                 namespace = slider.vars.namespace,
     23                namespace = slider.vars.namespace;
    2424
    2525                // Store a reference to the slider object.
    2626                $.data( el, 'featuredslider', slider );
     
    105105                                        var type = 'control-paging',
    106106                                                j = 1,
    107107                                                item,
    108                                                 slide,
    109108                                                i;
    110109
    111110                                        slider.controlNavScaffold = $( '<ol class="' + namespace + 'control-nav ' + namespace + type + '"></ol>' );
    112111
    113112                                        if ( slider.pagingCount > 1 ) {
    114113                                                for ( i = 0; i < slider.pagingCount; i++ ) {
    115                                                         slide = slider.slides.eq( i );
    116114                                                        item = '<a>' + j + '</a>';
    117115                                                        slider.controlNavScaffold.append( '<li>' + item + '</li>' );
    118116                                                        j++;
     
    120118                                        }
    121119
    122120                                        // CONTROLSCONTAINER
    123                                         ( slider.controlsContainer ) ? $( slider.controlsContainer ).append( slider.controlNavScaffold ) : slider.append( slider.controlNavScaffold );
     121                                        if ( slider.controlsContainer ) {
     122                                                $( slider.controlsContainer ).append( slider.controlNavScaffold );
     123                                        } else {
     124                                                slider.append( slider.controlNavScaffold );
     125                                        }
    124126                                        methods.controlNav.set();
    125127
    126128                                        methods.controlNav.active();
     
    162164                                                slider.controlNav.eq( pos ).closest( 'li' ).remove();
    163165                                        }
    164166                                        methods.controlNav.set();
    165                                         ( slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length ) ? slider.update( pos, action ) : methods.controlNav.active();
     167                                        if ( slider.pagingCount > 1 && slider.pagingCount !== slider.controlNav.length ) {
     168                                                slider.update( pos, action );
     169                                        } else {
     170                                                methods.controlNav.active();
     171                                        }
    166172                                }
    167173                        },
    168174
     
    315321                                                return;
    316322                                        }
    317323
    318                                         transX = -e.translationX,
     324                                        transX = -e.translationX;
    319325                                        transY = -e.translationY;
    320326
    321327                                        // Accumulate translations.
     
    349355                                        }
    350356
    351357                                        if ( slider.animatingTo === slider.currentSlide && ! scrolling && dx !== null ) {
    352                                                 updateDx = dx,
     358                                                updateDx = dx;
    353359                                                target = ( updateDx > 0 ) ? slider.getTarget( 'next' ) : slider.getTarget( 'prev' );
    354360
    355361                                                slider.featureAnimate( target );
     
    376382
    377383                        smoothHeight: function( dur ) {
    378384                                var $obj = slider.viewport;
    379                                 ( dur ) ? $obj.animate( { 'height': slider.slides.eq( slider.animatingTo ).height() }, dur ) : $obj.height( slider.slides.eq( slider.animatingTo ).height() );
     385                                if ( dur ) {
     386                                        $obj.animate( { 'height': slider.slides.eq( slider.animatingTo ).height() }, dur );
     387                                } else {
     388                                        $obj.height( slider.slides.eq( slider.animatingTo ).height() );
     389                                }
    380390                        },
    381391
    382392                        setToClearWatchedEvent: function() {