From f3990ce3bf28d8095c5ef3a2d8f5e99151664bc2 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Tue, 24 Dec 2013 17:00:59 +0100 Subject: [PATCH 01/28] chore: ignore dist and out directory --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6cb1e35b..c5817e81 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ bower_components/ node_modules/ -.rcs -*.swp \ No newline at end of file +out/ From 1836b40d8d0ead48d0d553567caa1b0f7270f75f Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Wed, 4 Dec 2013 22:32:47 +0100 Subject: [PATCH 02/28] chore(grunt): adds load-grunt-tasks module kills lines of code :) --- gruntFile.js | 11 ++--------- package.json | 3 ++- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/gruntFile.js b/gruntFile.js index d7c20010..0c3320b1 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -3,14 +3,7 @@ module.exports = function (grunt) { var initConfig; // Loading external tasks - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-karma'); - + require('load-grunt-tasks')(grunt); /** * Custom task to inline a generated file at a certain moment... @@ -135,4 +128,4 @@ module.exports = function (grunt) { }; grunt.initConfig(initConfig); -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index b773e5be..767e99f1 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ "grunt-contrib-jshint": "~0.5.4", "grunt-contrib-uglify": "~0.2.1", "grunt-contrib-watch": "~0.4.3", - "grunt-karma": "~0.6.2" + "grunt-karma": "~0.6.2", + "load-grunt-tasks": "~0.2.0" }, "scripts": {}, "repository": { From 4cea7ea5bb4c47ad74c4f5123121a2896bf6f717 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 13:36:33 +0100 Subject: [PATCH 03/28] feat(publisher): add and config component-publisher system --- .gitignore | 4 +++ gruntFile.js | 44 +++++++++++++++++++------------- modules/include/demo/index.html | 2 +- package.json | 1 + publish.js | 45 +++++++++++++++++++++++++++++++++ 5 files changed, 77 insertions(+), 19 deletions(-) create mode 100644 publish.js diff --git a/.gitignore b/.gitignore index c5817e81..2e5abdae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ bower_components/ node_modules/ out/ +dist/ + +# don't track generated/copied html demo files +demo/*.html diff --git a/gruntFile.js b/gruntFile.js index 0c3320b1..0f3ae4f4 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -9,15 +9,33 @@ module.exports = function (grunt) { * Custom task to inline a generated file at a certain moment... */ grunt.registerTask('UGF', 'Use Generated Files.', function() { - initConfig.meta.view.demoHTML= grunt.file.read( grunt.template.process("<%= dist %>/demos.html")); + initConfig.meta.view.demoHTML= grunt.file.read(grunt.template.process("<%= dist %>/demos.html")); }); // Default task. grunt.registerTask('default', ['jshint', 'karma:unit']); - grunt.registerTask('build', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify']); grunt.registerTask('build-doc', ['build', 'concat:html_doc', 'UGF', 'copy']); grunt.registerTask('server', ['karma:start']); + grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify', 'concat:html_doc', 'copy']); + // HACK TO ACCESS TO THE COMPONENT-PUBLISHER + function fakeTargetTask(prefix){ + return function(){ + + if (this.args.length !== 1) return grunt.log.fail('Just give the name of the ' + prefix + ' you want like :\ngrunt ' + prefix + ':bower'); + + var done = this.async(); + var spawn = require('child_process').spawn; + spawn('./node_modules/.bin/gulp', [ prefix, '--branch='+this.args[0] ].concat(grunt.option.flags()), { + cwd : './node_modules/component-publisher', + stdio: 'inherit' + }).on('close', done); + }; + } + + grunt.registerTask('build', fakeTargetTask('build')); + grunt.registerTask('publish', fakeTargetTask('publish')); + // var testConfig = function(configFile, customOptions) { var options = { configFile: configFile, singleRun: true }; @@ -67,7 +85,7 @@ module.exports = function (grunt) { ].join('\n '), footer : ''}, src: [ 'modules/**/demo/index.html'], - dest: '<%= dist %>/demos.html' + dest: 'demo/demos.html' }, tmp: { files: { 'tmp/dep.js': [ 'modules/**/*.js', '!modules/utils.js', '!modules/ie-shiv/*.js', '!modules/**/test/*.js']} @@ -75,8 +93,8 @@ module.exports = function (grunt) { modules: { options: {banner: '<%= meta.banner %>'}, files: { - '<%= meta.destName %>.js': ['tmp/dep.js', 'modules/utils.js'], - '<%= meta.destName %>-ieshiv.js' : ['modules/ie-shiv/*.js'] + 'dist/main/ui-utils.js': ['tmp/dep.js', 'modules/utils.js'], + 'dist/main/ui-utils-ieshiv.js' : ['modules/ie-shiv/*.js'] } } }, @@ -84,8 +102,8 @@ module.exports = function (grunt) { options: {banner: '<%= meta.banner %>'}, build: { files: { - '<%= meta.destName %>.min.js': ['<%= meta.destName %>.js'], - '<%= meta.destName %>-ieshiv.min.js': ['<%= meta.destName %>-ieshiv.js'] + 'dist/main/ui-utils.min.js': ['dist/main/ui-utils.js'], + 'dist/main/ui-utils-ieshiv.min.js': ['dist/main/ui-utils-ieshiv.js'] } } }, @@ -110,18 +128,8 @@ module.exports = function (grunt) { copy: { main: { files: [ - {src: ['demo/demo.js'], dest: '<%= dist %>/core/demo.js', filter: 'isFile'}, - // UI.Include needs a external html source. - {src: ['modules/include/demo/fragments.html'], dest: '<%= dist %>/assets/fragments.html', filter: 'isFile'} - ] - }, - template : { - options : {processContent : function(content){ - return grunt.template.process(content); - }}, - files: [ - {src: ['<%= dist %>/.tmpl/index.tmpl'], dest: '<%= dist %>/index.html'} + {src: ['modules/include/demo/fragments.html'], dest: 'demo/fragments.html', filter: 'isFile'} ] } } diff --git a/modules/include/demo/index.html b/modules/include/demo/index.html index 5c17d919..f0e83c76 100644 --- a/modules/include/demo/index.html +++ b/modules/include/demo/index.html @@ -40,7 +40,7 @@

Demo


Fragment content (fragment="'{{uiIncludeFragment}}'"):
- +
diff --git a/package.json b/package.json index 767e99f1..7ba9fac9 100644 --- a/package.json +++ b/package.json @@ -7,6 +7,7 @@ "homepage": "http://angular-ui.github.com", "dependencies": {}, "devDependencies": { + "component-publisher": "git://github.com/douglasduteil/component-publisher", "grunt": "~0.4.1", "grunt-contrib-clean": "~0.4.1", "grunt-contrib-concat": "~0.3.0", diff --git a/publish.js b/publish.js new file mode 100644 index 00000000..928c252b --- /dev/null +++ b/publish.js @@ -0,0 +1,45 @@ +/* jshint node:true */ + +'use strict'; + +var fs = require('fs'); + +module.exports = function() { + + //var modulesName = grunt.file.expand({ cwd: "modules" }, ["*","!utils.js"]); + var modulesName = fs.readdirSync(__dirname + '/modules'); + + function makingComponentData(memo, name){ + if(name === 'utils.js') return memo; + + memo[name] = { + fullName : 'angular-ui-' + name, + main : './ui-' + name + '.js', + src : name + '.js' + }; + + return memo; + } + + return { + // gh-pages stuff + humaName : 'UI.Utils', + repoName : 'ui-utils', + inlineHTML : fs.readFileSync(__dirname + '/demo/demos.html'), + inlineJS : fs.readFileSync(__dirname + '/demo/demo.js'), + // gh-pages css dependencies + // css : [] + // gh-pages js dependencies + js : ['dist/ui-utils.js'], + + + // HACK... + main_dist_dir: 'main', + + + // The sub-components + subcomponent : modulesName.reduce(makingComponentData, {}), + // HACK... + sub_dist_dir: 'sub' + }; +}; From 12d97d3bf88da86875141093fc164f1537d0dfe2 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 13:39:30 +0100 Subject: [PATCH 04/28] feat(publisher): change travis scripts to work with the component-publisher system --- .travis.yml | 10 ++++++---- bower.json | 3 +-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5437b0ea..51589f69 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,17 @@ --- language: node_js node_js: -- '0.8' +- '0.10' before_install: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start - npm install -g bower grunt-cli - npm install -- bower install -before_script: bower_components/angular-ui-docs/.travis/before_script.sh -after_success: bower_components/angular-ui-docs/.travis/after_success.sh +- bower install --force +- bower install --force +after_success: +- "./node_modules/component-publisher/travis/authentication.sh --branch=develop || exit 1" +- "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower" script: grunt env: global: diff --git a/bower.json b/bower.json index 6a640708..6808aee0 100644 --- a/bower.json +++ b/bower.json @@ -10,7 +10,6 @@ }, "devDependencies": { "angular-mocks": "~1.0.5", - "jquery": ">=1.6", - "angular-ui-docs": "angular-ui/angular-ui-docs" + "jquery": ">=1.6" } } From 08121f8529985dd21b24d36251dba00a4ab121e4 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 14:19:31 +0100 Subject: [PATCH 05/28] chore(grunt): clean up unused tasks --- gruntFile.js | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/gruntFile.js b/gruntFile.js index 0f3ae4f4..ceebefa1 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -5,16 +5,8 @@ module.exports = function (grunt) { // Loading external tasks require('load-grunt-tasks')(grunt); - /** - * Custom task to inline a generated file at a certain moment... - */ - grunt.registerTask('UGF', 'Use Generated Files.', function() { - initConfig.meta.view.demoHTML= grunt.file.read(grunt.template.process("<%= dist %>/demos.html")); - }); - // Default task. grunt.registerTask('default', ['jshint', 'karma:unit']); - grunt.registerTask('build-doc', ['build', 'concat:html_doc', 'UGF', 'copy']); grunt.registerTask('server', ['karma:start']); grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify', 'concat:html_doc', 'copy']); @@ -55,16 +47,7 @@ module.exports = function (grunt) { ' * @link <%= pkg.homepage %>', ' * @license <%= pkg.license %>', ' */', - ''].join('\n'), - view : { - humaName : "UI Utils", - repoName : "ui-utils", - demoJS : grunt.file.read("demo/demo.js"), - js : [ - 'build/<%= meta.view.repoName %>.min.js' - ] - }, - destName : '<%= dist %>/build/<%= meta.view.repoName %>' + ''].join('\n') }, watch: { karma: { From 783140abe1b8d6c0f842eceb7fc24a0f16d73ca5 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 15:02:29 +0100 Subject: [PATCH 06/28] feat(grunt): add ngmin build all subcomponents in dist/sub --- gruntFile.js | 30 ++++++++++++++++++++++++++++-- package.json | 3 ++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/gruntFile.js b/gruntFile.js index ceebefa1..8185d7a5 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -29,6 +29,23 @@ module.exports = function (grunt) { grunt.registerTask('publish', fakeTargetTask('publish')); // + + // + var moduleNames = grunt.file.expand({ cwd: 'modules' }, ['*','!utils.js']); + function ngMinModulesConfig(memo, moduleName){ + + memo[moduleName]= { + expand: true, + cwd: 'modules/' + moduleName, + src: [moduleName + '.js'], + dest: 'dist/sub/' + moduleName + }; + + return memo; + } + // + + var testConfig = function(configFile, customOptions) { var options = { configFile: configFile, singleRun: true }; var travisOptions = process.env.TRAVIS && { browsers: ['Firefox', 'PhantomJS'], reporters: ['dots'] }; @@ -83,11 +100,18 @@ module.exports = function (grunt) { }, uglify: { options: {banner: '<%= meta.banner %>'}, - build: { + main: { files: { 'dist/main/ui-utils.min.js': ['dist/main/ui-utils.js'], 'dist/main/ui-utils-ieshiv.min.js': ['dist/main/ui-utils-ieshiv.js'] } + }, + sub: { + expand: true, + cwd: 'dist/sub/', + src: ['**/*.js'], + ext: '.min.js', + dest: 'dist/sub/' } }, clean: { @@ -115,7 +139,9 @@ module.exports = function (grunt) { {src: ['modules/include/demo/fragments.html'], dest: 'demo/fragments.html', filter: 'isFile'} ] } - } + }, + + ngmin: moduleNames.reduce(ngMinModulesConfig, {}) }; grunt.initConfig(initConfig); diff --git a/package.json b/package.json index 7ba9fac9..3fbaa5cc 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "grunt-contrib-uglify": "~0.2.1", "grunt-contrib-watch": "~0.4.3", "grunt-karma": "~0.6.2", - "load-grunt-tasks": "~0.2.0" + "load-grunt-tasks": "~0.2.0", + "grunt-ngmin": "0.0.3" }, "scripts": {}, "repository": { From 93ba905fadfd4d0970d384f7978e19a3561cea65 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 16:56:34 +0100 Subject: [PATCH 07/28] feat(grunt): use ngmin in the 'dist' task --- gruntFile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gruntFile.js b/gruntFile.js index 8185d7a5..2155650b 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -8,7 +8,7 @@ module.exports = function (grunt) { // Default task. grunt.registerTask('default', ['jshint', 'karma:unit']); grunt.registerTask('server', ['karma:start']); - grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify', 'concat:html_doc', 'copy']); + grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'ngmin', 'uglify', 'concat:html_doc', 'copy']); // HACK TO ACCESS TO THE COMPONENT-PUBLISHER function fakeTargetTask(prefix){ From 5dcdc3794efe66112522415aafe9ebe965a274f6 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 16:57:54 +0100 Subject: [PATCH 08/28] fix(publisher): rename sub componenet stuff --- publish.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/publish.js b/publish.js index 928c252b..62405d82 100644 --- a/publish.js +++ b/publish.js @@ -6,16 +6,12 @@ var fs = require('fs'); module.exports = function() { - //var modulesName = grunt.file.expand({ cwd: "modules" }, ["*","!utils.js"]); - var modulesName = fs.readdirSync(__dirname + '/modules'); + var modulesName = fs.readdirSync(__dirname + '/dist/sub'); function makingComponentData(memo, name){ - if(name === 'utils.js') return memo; - - memo[name] = { - fullName : 'angular-ui-' + name, - main : './ui-' + name + '.js', - src : name + '.js' + memo[name] = { + name: 'angular-ui-' + name, + main: './' + name + '.js' }; return memo; @@ -38,7 +34,7 @@ module.exports = function() { // The sub-components - subcomponent : modulesName.reduce(makingComponentData, {}), + subcomponents : modulesName.reduce(makingComponentData, {}), // HACK... sub_dist_dir: 'sub' }; From 0d64db00a5c50816cbf0b022aa5607fee29d5e2a Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Wed, 25 Dec 2013 17:03:57 +0100 Subject: [PATCH 09/28] feat(travis): add sub component auto publishing :) --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 51589f69..c5894501 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ before_install: - bower install --force after_success: - "./node_modules/component-publisher/travis/authentication.sh --branch=develop || exit 1" -- "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower" +- "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower build:subbower publish:subbower" script: grunt env: global: From 332ebff1fdc7edf4d44d64f4796ec2f70e90947f Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 11:16:51 +0100 Subject: [PATCH 10/28] feat(grunt): quality code more strict --- .jshintrc | 23 +++++++++++++++++++++++ gruntFile.js | 38 ++++++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 12 deletions(-) create mode 100644 .jshintrc diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 00000000..ad23bccc --- /dev/null +++ b/.jshintrc @@ -0,0 +1,23 @@ +{ + "boss": true, + "browser": true, + "eqnull": true, + "expr": true, + "globalstrict": true, + "immed": true, + "laxbreak": true, + "loopfunc": true, + "newcap": true, + "noarg": true, + "noempty": true, + "nonew": true, + "quotmark": true, + "smarttabs": true, + "sub": true, + "trailing": true, + "undef": true, + "unused": true, + "globals": { + "angular": false + } +} diff --git a/gruntFile.js b/gruntFile.js index 2155650b..d5ab4a68 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -118,18 +118,32 @@ module.exports = function (grunt) { rm_tmp: {src: ['tmp']} }, jshint: { - files:['modules/**/*.js', 'gruntFile.js', 'test/**/*Spec.js', 'demo/**/*.js'], - options: { - curly: true, - eqeqeq: true, - immed: true, - latedef: true, - newcap: true, - noarg: true, - sub: true, - boss: true, - eqnull: true, - globals: {} + src: { + files:{ src : ['modules/**/*.js', '!modules/**/test/*Spec.js','demo/**/*.js'] }, + options: { jshintrc: '.jshintrc' } + }, + test: { + files:{ src : [ 'modules/**/test/*Spec.js', 'gruntFile.js'] }, + options: grunt.util._.extend({}, grunt.file.readJSON('.jshintrc'), { + node: true, + globals: { + angular: false, + inject: false, + jQuery: false, + + jasmine: false, + afterEach: false, + beforeEach: false, + ddescribe: false, + describe: false, + expect: false, + iit: false, + it: false, + spyOn: false, + xdescribe: false, + xit: false + } + }) } }, copy: { From bd31923668c0ea80311b9dbe7d72bfbe55956325 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 14:38:13 +0100 Subject: [PATCH 11/28] fix(publisher): don't throw error when 'dist/sub' don't exist --- publish.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/publish.js b/publish.js index 62405d82..fae15f0f 100644 --- a/publish.js +++ b/publish.js @@ -6,7 +6,10 @@ var fs = require('fs'); module.exports = function() { - var modulesName = fs.readdirSync(__dirname + '/dist/sub'); + var modulesName = []; + if (fs.existsSync(__dirname + '/dist/sub')){ + modulesName = fs.readdirSync(__dirname + '/dist/sub'); + } function makingComponentData(memo, name){ memo[name] = { From a18ed32ce134acabe7adc79b41e82ed6c52109ed Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 14:42:22 +0100 Subject: [PATCH 12/28] feat(grunt): new 'serve' task - add livereload on the builded gh-page - fix the existing watch task --- gruntFile.js | 37 ++++++++++++++++++++++++++++++++----- package.json | 1 + 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/gruntFile.js b/gruntFile.js index d5ab4a68..964564e7 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -7,7 +7,7 @@ module.exports = function (grunt) { // Default task. grunt.registerTask('default', ['jshint', 'karma:unit']); - grunt.registerTask('server', ['karma:start']); + grunt.registerTask('serve', [ 'karma:continuous', 'dist', 'build:gh-pages', 'connect:continuous', 'watch']); grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'ngmin', 'uglify', 'concat:html_doc', 'copy']); // HACK TO ACCESS TO THE COMPONENT-PUBLISHER @@ -66,16 +66,43 @@ module.exports = function (grunt) { ' */', ''].join('\n') }, + watch: { - karma: { - files: ['modules/**/*.js'], - tasks: ['karma:unit:run'] //NOTE the :run flag + + src: { + files: ['modules/**/*.js', '!modules/**/test/*Spec.js', 'demo/**/*.js'], + tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages'] + }, + test: { + files: ['modules/**/test/*Spec.js'], + tasks: ['jshint:test', 'karma:unit:run'] + }, + demo: { + files: ['modules/**/demo/*'], + tasks: ['jshint:src', 'concat:html_doc', 'copy', 'build:gh-pages'] + }, + livereload: { + files: ['out/built/gh-pages/**/*'], + options: { livereload: true } } }, + + connect: { + options: { + base : 'out/built/gh-pages', + open: true, + livereload: true + }, + server: { options: { keepalive: true } }, + continuous: { options: { keepalive: false } } + }, + karma: { unit: testConfig('test/karma.conf.js'), - start: {configFile: 'test/karma.conf.js'} + server: {configFile: 'test/karma.conf.js'}, + continuous: {configFile: 'test/karma.conf.js', background: true } }, + concat: { html_doc: { options: { diff --git a/package.json b/package.json index 3fbaa5cc..a3dd7091 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "grunt": "~0.4.1", "grunt-contrib-clean": "~0.4.1", "grunt-contrib-concat": "~0.3.0", + "grunt-contrib-connect": "~0.5.0", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-jshint": "~0.5.4", "grunt-contrib-uglify": "~0.2.1", From ed4cb33d9bcc2bc5049bf0434b85e4083cf013f7 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 15:36:58 +0100 Subject: [PATCH 13/28] style(jshint): first global strict correction - boss : "Use '!==' to compare with 'null'" - globalstrict : "Missing 'use strict' statement" --- demo/demo.js | 1 + modules/alias/alias.js | 4 +++- modules/event/event.js | 2 ++ modules/format/format.js | 1 + modules/highlight/highlight.js | 2 ++ modules/ie-shiv/ie-shiv.js | 1 + modules/include/include.js | 2 ++ modules/indeterminate/indeterminate.js | 2 ++ modules/inflector/inflector.js | 2 ++ modules/jq/jq.js | 2 ++ modules/keypress/keypress.js | 4 +++- modules/mask/mask.js | 5 ++++- modules/reset/reset.js | 2 ++ modules/route/route.js | 4 +++- modules/scroll/ui-scroll-jqlite.js | 4 +++- modules/scroll/ui-scroll.js | 5 ++--- modules/scrollfix/scrollfix.js | 5 ++--- modules/showhide/showhide.js | 2 ++ modules/unique/unique.js | 2 ++ modules/validate/validate.js | 2 ++ 20 files changed, 43 insertions(+), 11 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index 567f32b1..d848981b 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -1,3 +1,4 @@ +'use strict'; angular.module('doc.ui-utils', ['ui.utils', 'prettifyDirective' ]); diff --git a/modules/alias/alias.js b/modules/alias/alias.js index 184a0cf7..6048b1f9 100644 --- a/modules/alias/alias.js +++ b/modules/alias/alias.js @@ -1,3 +1,5 @@ +'use strict'; + angular.module('ui.alias', []).config(['$compileProvider', 'uiAliasConfig', function($compileProvider, uiAliasConfig){ uiAliasConfig = uiAliasConfig || {}; angular.forEach(uiAliasConfig, function(config, alias){ @@ -11,4 +13,4 @@ angular.module('ui.alias', []).config(['$compileProvider', 'uiAliasConfig', func return config; }); }); -}]); \ No newline at end of file +}]); diff --git a/modules/event/event.js b/modules/event/event.js index ba265e26..1a1a2aed 100644 --- a/modules/event/event.js +++ b/modules/event/event.js @@ -1,3 +1,5 @@ +'use strict'; + /** * General-purpose Event binding. Bind any event not natively supported by Angular * Pass an object with keynames for events to ui-event diff --git a/modules/format/format.js b/modules/format/format.js index 005c10ec..7842c6bd 100644 --- a/modules/format/format.js +++ b/modules/format/format.js @@ -1,3 +1,4 @@ +'use strict'; /** * A replacement utility for internationalization very similar to sprintf. diff --git a/modules/highlight/highlight.js b/modules/highlight/highlight.js index b799018d..e00d51b8 100644 --- a/modules/highlight/highlight.js +++ b/modules/highlight/highlight.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Wraps the * @param text {string} haystack to search through diff --git a/modules/ie-shiv/ie-shiv.js b/modules/ie-shiv/ie-shiv.js index 17ce3eff..750b28f3 100644 --- a/modules/ie-shiv/ie-shiv.js +++ b/modules/ie-shiv/ie-shiv.js @@ -13,6 +13,7 @@ // (function (window, document) { + "use strict"; var debug = window.ieShivDebug || false, tags = [ "ngInclude", "ngPluralize", "ngView", "ngSwitch", "uiCurrency", "uiCodemirror", "uiDate", "uiEvent", diff --git a/modules/include/include.js b/modules/include/include.js index e7cb0048..445fccd0 100644 --- a/modules/include/include.js +++ b/modules/include/include.js @@ -1,3 +1,5 @@ +'use strict'; + // modeled after: angular-1.0.7/src/ng/directive/ngInclude.js angular.module('ui.include',[]) .directive('uiInclude', ['$http', '$templateCache', '$anchorScroll', '$compile', diff --git a/modules/indeterminate/indeterminate.js b/modules/indeterminate/indeterminate.js index f466a3fb..63184e5e 100644 --- a/modules/indeterminate/indeterminate.js +++ b/modules/indeterminate/indeterminate.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Provides an easy way to toggle a checkboxes indeterminate property * diff --git a/modules/inflector/inflector.js b/modules/inflector/inflector.js index 3ea6ceed..47dd6358 100644 --- a/modules/inflector/inflector.js +++ b/modules/inflector/inflector.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Converts variable-esque naming conventions to something presentational, capitalized words separated by space. * @param {String} value The value to be parsed and prettified. diff --git a/modules/jq/jq.js b/modules/jq/jq.js index 958060bf..29ab281c 100644 --- a/modules/jq/jq.js +++ b/modules/jq/jq.js @@ -1,3 +1,5 @@ +'use strict'; + /** * General-purpose jQuery wrapper. Simply pass the plugin name as the expression. * diff --git a/modules/keypress/keypress.js b/modules/keypress/keypress.js index 52378e2f..22cd9207 100644 --- a/modules/keypress/keypress.js +++ b/modules/keypress/keypress.js @@ -1,3 +1,5 @@ +'use strict'; + angular.module('ui.keypress',[]). factory('keypressHelper', ['$parse', function keypress($parse){ var keysByCode = { @@ -111,4 +113,4 @@ angular.module('ui.keypress').directive('uiKeyup', ['keypressHelper', function(k keypressHelper('keyup', scope, elm, attrs); } }; -}]); \ No newline at end of file +}]); diff --git a/modules/mask/mask.js b/modules/mask/mask.js index 4bc0099d..39b25a5a 100644 --- a/modules/mask/mask.js +++ b/modules/mask/mask.js @@ -1,3 +1,5 @@ +'use strict'; + /* Attaches input mask onto input element */ @@ -297,11 +299,13 @@ angular.module('ui.mask', []) iElement.bind('mousedown mouseup', mouseDownUpHandler); function mouseoutHandler(){ + /*jshint validthis: true */ oldSelectionLength = getSelectionLength(this); iElement.unbind('mouseout', mouseoutHandler); } function eventHandler(e){ + /*jshint validthis: true */ e = e || {}; // Allows more efficient minification var eventWhich = e.which, @@ -455,7 +459,6 @@ angular.module('ui.mask', []) // https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Array/indexOf if (!Array.prototype.indexOf) { Array.prototype.indexOf = function (searchElement /*, fromIndex */){ - "use strict"; if (this === null) { throw new TypeError(); } diff --git a/modules/reset/reset.js b/modules/reset/reset.js index 6d2c393d..5ea88d85 100755 --- a/modules/reset/reset.js +++ b/modules/reset/reset.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Add a clear button to form inputs to reset their value */ diff --git a/modules/route/route.js b/modules/route/route.js index 3dbca39f..d0ae049f 100644 --- a/modules/route/route.js +++ b/modules/route/route.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Set a $uiRoute boolean to see if the current route matches */ @@ -69,7 +71,7 @@ angular.module('ui.route', []).directive('uiRoute', ['$location', '$parse', func $scope.$on('$routeChangeSuccess', function(){ watcher(); }); - + //Added for compatibility with ui-router $scope.$on('$stateChangeSuccess', function(){ watcher(); diff --git a/modules/scroll/ui-scroll-jqlite.js b/modules/scroll/ui-scroll-jqlite.js index 932091e3..f37c9867 100644 --- a/modules/scroll/ui-scroll-jqlite.js +++ b/modules/scroll/ui-scroll-jqlite.js @@ -1,3 +1,4 @@ +'use strict'; angular.module('ui.scroll.jqlite', ['ui.scroll']).service('jqLiteExtras', [ '$log', '$window', function(console, window) { @@ -175,6 +176,7 @@ angular.module('ui.scroll.jqlite', ['ui.scroll']).service('jqLiteExtras', [ return self; } else { return setOffset; + } } box = { @@ -187,7 +189,7 @@ angular.module('ui.scroll.jqlite', ['ui.scroll']).service('jqLiteExtras', [ return; } docElem = doc.documentElement; - if (elem.getBoundingClientRect != null) { + if (elem.getBoundingClientRect) { box = elem.getBoundingClientRect(); } win = doc.defaultView || doc.parentWindow; diff --git a/modules/scroll/ui-scroll.js b/modules/scroll/ui-scroll.js index a33f7c66..e66a4f17 100644 --- a/modules/scroll/ui-scroll.js +++ b/modules/scroll/ui-scroll.js @@ -1,5 +1,5 @@ +'use strict'; /* - globals: angular, window List of used element methods available in JQuery but not in JQuery Lite @@ -52,8 +52,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ return viewport.height() * Math.max(0.1, +$attr.padding || 0.1); }; scrollHeight = function(elem) { - var _ref; - return (_ref = elem[0].scrollHeight) != null ? _ref : elem[0].document.documentElement.scrollHeight; + return elem[0].scrollHeight || elem[0].document.documentElement.scrollHeight; }; adapter = null; linker(tempScope = $scope.$new(), function(template) { diff --git a/modules/scrollfix/scrollfix.js b/modules/scrollfix/scrollfix.js index 647b2710..11b6dd98 100644 --- a/modules/scrollfix/scrollfix.js +++ b/modules/scrollfix/scrollfix.js @@ -1,11 +1,11 @@ -/*global angular, $, document*/ +'use strict'; + /** * Adds a 'ui-scrollfix' class to the element when the page scrolls past it's position. * @param [offset] {int} optional Y-offset to override the detected offset. * Takes 300 (absolute) or -300 or +300 (relative to detected) */ angular.module('ui.scrollfix',[]).directive('uiScrollfix', ['$window', function ($window) { - 'use strict'; return { require: '^?uiScrollfixTarget', link: function (scope, elm, attrs, uiScrollfixTarget) { @@ -48,7 +48,6 @@ angular.module('ui.scrollfix',[]).directive('uiScrollfix', ['$window', function } }; }]).directive('uiScrollfixTarget', [function () { - 'use strict'; return { controller: ['$element', function($element) { this.$element = $element; diff --git a/modules/showhide/showhide.js b/modules/showhide/showhide.js index 683d868e..c4021b36 100644 --- a/modules/showhide/showhide.js +++ b/modules/showhide/showhide.js @@ -1,3 +1,5 @@ +'use strict'; + /** * uiShow Directive * diff --git a/modules/unique/unique.js b/modules/unique/unique.js index e81bacf6..ded107ea 100644 --- a/modules/unique/unique.js +++ b/modules/unique/unique.js @@ -1,3 +1,5 @@ +'use strict'; + /** * Filters out all duplicate items from an array by checking the specified key * @param [key] {string} the name of the attribute of each object to compare for uniqueness diff --git a/modules/validate/validate.js b/modules/validate/validate.js index 966203d7..83b43277 100644 --- a/modules/validate/validate.js +++ b/modules/validate/validate.js @@ -1,3 +1,5 @@ +'use strict'; + /** * General-purpose validator for ngModel. * angular.js comes with several built-in validation mechanism for input fields (ngRequired, ngPattern etc.) but using From 223801e6420175a25822d619e98c17f7cb9162cb Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 15:45:40 +0100 Subject: [PATCH 14/28] style(jshint): Mixed double and single quotes correction. --- demo/demo.js | 2 +- modules/ie-shiv/ie-shiv.js | 4 ++-- modules/mask/mask.js | 8 +++---- modules/scroll/ui-scroll-jqlite.js | 2 +- modules/scroll/ui-scroll.js | 28 ++++++++++++------------ modules/scrollfix/scrollfix.js | 2 +- modules/utils.js | 34 +++++++++++++++--------------- 7 files changed, 40 insertions(+), 40 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index d848981b..169214f3 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -10,7 +10,7 @@ angular.module('ui.scroll') var i, result, _i, _ref; result = []; for (i = _i = index, _ref = index + count - 1; index <= _ref ? _i <= _ref : _i >= _ref; i = index <= _ref ? ++_i : --_i) { - result.push("item #" + i); + result.push('item #' + i); } return success(result); }, 100); diff --git a/modules/ie-shiv/ie-shiv.js b/modules/ie-shiv/ie-shiv.js index 750b28f3..839b0cc5 100644 --- a/modules/ie-shiv/ie-shiv.js +++ b/modules/ie-shiv/ie-shiv.js @@ -30,7 +30,7 @@ var dashed = str.replace(/([A-Z])/g, function ($1) { return " " + $1.toLowerCase(); }); - var tokens = dashed.split(' '); + var tokens = dashed.split(" "); // If a token is just a single name (i.e. no namespace) then we juse define the elements the name given if (tokens.length === 1) { @@ -41,7 +41,7 @@ result.push("data-" + name); } else { var ns = tokens[0]; - var dirname = tokens.slice(1).join('-'); + var dirname = tokens.slice(1).join("-"); // this is finite list and it seemed senseless to create a custom method result.push(ns + ":" + dirname); diff --git a/modules/mask/mask.js b/modules/mask/mask.js index 39b25a5a..3109ccbc 100644 --- a/modules/mask/mask.js +++ b/modules/mask/mask.js @@ -215,10 +215,10 @@ angular.module('ui.mask', []) function getPlaceholderChar(i) { var placeholder = iAttrs.placeholder; - if (typeof placeholder !== "undefined" && placeholder[i]) { + if (typeof placeholder !== 'undefined' && placeholder[i]) { return placeholder[i]; } else { - return "_"; + return '_'; } } @@ -245,7 +245,7 @@ angular.module('ui.mask', []) minRequiredLength = 0; var isOptional = false, - splitMask = mask.split(""); + splitMask = mask.split(''); angular.forEach(splitMask, function (chr, i){ if (linkOptions.maskDefinitions[chr]) { @@ -260,7 +260,7 @@ angular.module('ui.mask', []) minRequiredLength++; } } - else if (chr === "?") { + else if (chr === '?') { isOptional = true; } else { diff --git a/modules/scroll/ui-scroll-jqlite.js b/modules/scroll/ui-scroll-jqlite.js index f37c9867..2d54ca39 100644 --- a/modules/scroll/ui-scroll-jqlite.js +++ b/modules/scroll/ui-scroll-jqlite.js @@ -56,7 +56,7 @@ angular.module('ui.scroll.jqlite', ['ui.scroll']).service('jqLiteExtras', [ convertToPx = function(elem, value) { var core_pnum, left, result, rnumnonpx, rs, rsLeft, style; core_pnum = /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/.source; - rnumnonpx = new RegExp("^(" + core_pnum + ")(?!px)[a-z%]+$", "i"); + rnumnonpx = new RegExp('^(' + core_pnum + ')(?!px)[a-z%]+$', 'i'); if (!rnumnonpx.test(value)) { return parseFloat(value); } else { diff --git a/modules/scroll/ui-scroll.js b/modules/scroll/ui-scroll.js index e66a4f17..c6a3d3b4 100644 --- a/modules/scroll/ui-scroll.js +++ b/modules/scroll/ui-scroll.js @@ -33,7 +33,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ var adapter, adjustBuffer, adjustRowHeight, bof, bottomVisiblePos, buffer, bufferPadding, bufferSize, clipBottom, clipTop, datasource, datasourceName, enqueueFetch, eof, eventListener, fetch, finalize, first, insert, isDatasource, isLoading, itemName, loading, match, next, pending, reload, removeFromBuffer, resizeHandler, scrollHandler, scrollHeight, shouldLoadBottom, shouldLoadTop, tempScope, topVisiblePos, viewport; match = $attr.ngScroll.match(/^\s*(\w+)\s+in\s+(\w+)\s*$/); if (!match) { - throw new Error("Expected ngScroll in form of '_item_ in _datasource_' but got '" + $attr.ngScroll + "'"); + throw new Error('Expected ngScroll in form of "item_ in _datasource_" but got "' + $attr.ngScroll + '"'); } itemName = match[1]; datasourceName = match[2]; @@ -44,7 +44,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ if (!isDatasource(datasource)) { datasource = $injector.get(datasourceName); if (!isDatasource(datasource)) { - throw new Error("" + datasourceName + " is not a valid datasource"); + throw new Error(datasourceName + ' is not a valid datasource'); } } bufferSize = Math.max(3, +$attr.bufferSize || 10); @@ -59,7 +59,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ var bottomPadding, createPadding, padding, repeaterType, topPadding, viewport; repeaterType = template[0].localName; if (repeaterType === 'dl') { - throw new Error("ng-scroll directive does not support <" + template[0].localName + "> as a repeating tag: " + template[0].outerHTML); + throw new Error('ng-scroll directive does not support <' + template[0].localName + '> as a repeating tag: ' + template[0].outerHTML); } if (repeaterType !== 'li' && repeaterType !== 'tr') { repeaterType = 'div'; @@ -81,7 +81,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ }; return result; default: - result = angular.element("<" + repeaterType + ">"); + result = angular.element('<' + repeaterType + '>'); result.paddingHeight = result.height; return result; } @@ -175,7 +175,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ adapter.bottomPadding(adapter.bottomPadding() + bottomHeight); removeFromBuffer(buffer.length - overage, buffer.length); next -= overage; - return console.log("clipped off bottom " + overage + " bottom padding " + (adapter.bottomPadding())); + return console.log('clipped off bottom ' + overage + ' bottom padding ' + (adapter.bottomPadding())); } }; shouldLoadTop = function() { @@ -200,7 +200,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ adapter.topPadding(adapter.topPadding() + topHeight); removeFromBuffer(0, overage); first += overage; - return console.log("clipped off top " + overage + " top padding " + (adapter.topPadding())); + return console.log('clipped off top ' + overage + ' top padding ' + (adapter.topPadding())); } }; enqueueFetch = function(direction, scrolling) { @@ -260,7 +260,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ adjustBuffer = function(scrolling, newItems, finalize) { var doAdjustment; doAdjustment = function() { - console.log("top {actual=" + (adapter.topDataPos()) + " visible from=" + (topVisiblePos()) + " bottom {visible through=" + (bottomVisiblePos()) + " actual=" + (adapter.bottomDataPos()) + "}"); + console.log('top {actual=' + (adapter.topDataPos()) + ' visible from=' + (topVisiblePos()) + ' bottom {visible through=' + (bottomVisiblePos()) + ' actual=' + (adapter.bottomDataPos()) + '}'); if (shouldLoadBottom()) { enqueueFetch(true, scrolling); } else { @@ -309,14 +309,14 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ if (result.length === 0) { eof = true; adapter.bottomPadding(0); - console.log("appended: requested " + bufferSize + " records starting from " + next + " recieved: eof"); + console.log('appended: requested ' + bufferSize + ' records starting from ' + next + ' recieved: eof'); } else { clipTop(); for (_i = 0, _len = result.length; _i < _len; _i++) { item = result[_i]; newItems.push(insert(++next, item)); } - console.log("appended: requested " + bufferSize + " received " + result.length + " buffer size " + buffer.length + " first " + first + " next " + next); + console.log('appended: requested ' + bufferSize + ' received ' + result.length + ' buffer size ' + buffer.length + ' first ' + first + ' next ' + next); } return finalize(scrolling, newItems); }); @@ -331,13 +331,13 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ if (result.length === 0) { bof = true; adapter.topPadding(0); - console.log("prepended: requested " + bufferSize + " records starting from " + (first - bufferSize) + " recieved: bof"); + console.log('prepended: requested ' + bufferSize + ' records starting from ' + (first - bufferSize) + ' recieved: bof'); } else { clipBottom(); for (i = _i = _ref = result.length - 1; _ref <= 0 ? _i <= 0 : _i >= 0; i = _ref <= 0 ? ++_i : --_i) { newItems.unshift(insert(--first, result[i])); } - console.log("prepended: requested " + bufferSize + " received " + result.length + " buffer size " + buffer.length + " first " + first + " next " + next); + console.log('prepended: requested ' + bufferSize + ' received ' + result.length + ' buffer size ' + buffer.length + ' first ' + first + ' next ' + next); } return finalize(scrolling, newItems); }); @@ -371,7 +371,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ viewport.unbind('resize', resizeHandler); return viewport.unbind('scroll', scrollHandler); }); - eventListener.$on("update.items", function(event, locator, newItem) { + eventListener.$on('update.items', function(event, locator, newItem) { var wrapper, _fn, _i, _len, _ref; if (angular.isFunction(locator)) { _fn = function(wrapper) { @@ -388,7 +388,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ } return null; }); - eventListener.$on("delete.items", function(event, locator) { + eventListener.$on('delete.items', function(event, locator) { var i, item, temp, wrapper, _fn, _i, _j, _k, _len, _len1, _len2, _ref; if (angular.isFunction(locator)) { temp = []; @@ -418,7 +418,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ } return adjustBuffer(false); }); - return eventListener.$on("insert.item", function(event, locator, item) { + return eventListener.$on('insert.item', function(event, locator, item) { var i, inserted, temp, wrapper, _fn, _i, _j, _k, _len, _len1, _len2, _ref; inserted = []; if (angular.isFunction(locator)) { diff --git a/modules/scrollfix/scrollfix.js b/modules/scrollfix/scrollfix.js index 11b6dd98..77be62bd 100644 --- a/modules/scrollfix/scrollfix.js +++ b/modules/scrollfix/scrollfix.js @@ -29,7 +29,7 @@ angular.module('ui.scrollfix',[]).directive('uiScrollfix', ['$window', function if (angular.isDefined($window.pageYOffset)) { offset = $window.pageYOffset; } else { - var iebody = (document.compatMode && document.compatMode !== "BackCompat") ? document.documentElement : document.body; + var iebody = (document.compatMode && document.compatMode !== 'BackCompat') ? document.documentElement : document.body; offset = iebody.scrollTop; } if (!elm.hasClass('ui-scrollfix') && offset > attrs.uiScrollfix) { diff --git a/modules/utils.js b/modules/utils.js index 1be809ad..82c900be 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -1,19 +1,19 @@ angular.module('ui.utils', [ - "ui.event", - "ui.format", - "ui.highlight", - "ui.include", - "ui.indeterminate", - "ui.inflector", - "ui.jq", - "ui.keypress", - "ui.mask", - "ui.reset", - "ui.route", - "ui.scrollfix", - "ui.scroll", - "ui.scroll.jqlite", - "ui.showhide", - "ui.unique", - "ui.validate" + 'ui.event', + 'ui.format', + 'ui.highlight', + 'ui.include', + 'ui.indeterminate', + 'ui.inflector', + 'ui.jq', + 'ui.keypress', + 'ui.mask', + 'ui.reset', + 'ui.route', + 'ui.scrollfix', + 'ui.scroll', + 'ui.scroll.jqlite', + 'ui.showhide', + 'ui.unique', + 'ui.validate' ]); From 5440d6fa8514ee86efc480b0abbf66cf244889ad Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 15:55:56 +0100 Subject: [PATCH 15/28] fix(mark): TypeError: input is undefined --- modules/mask/mask.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/mask/mask.js b/modules/mask/mask.js index 3109ccbc..dfafa12c 100644 --- a/modules/mask/mask.js +++ b/modules/mask/mask.js @@ -416,6 +416,7 @@ angular.module('ui.mask', []) function isValidCaretPosition(pos){ return maskCaretMap.indexOf(pos) > -1; } function getCaretPosition(input){ + if (!input) return 0; if (input.selectionStart !== undefined) { return input.selectionStart; } else if (document.selection) { @@ -429,6 +430,7 @@ angular.module('ui.mask', []) } function setCaretPosition(input, pos){ + if (!input) return 0; if (input.offsetWidth === 0 || input.offsetHeight === 0) { return; // Input's hidden } @@ -447,6 +449,7 @@ angular.module('ui.mask', []) } function getSelectionLength(input){ + if (!input) return 0; if (input.selectionStart !== undefined) { return (input.selectionEnd - input.selectionStart); } From 3b1c85b8351619e7c38a78cd464db50a58dba734 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 16:04:55 +0100 Subject: [PATCH 16/28] style(jshint): remove unused variables --- demo/demo.js | 2 +- modules/ie-shiv/ie-shiv.js | 3 +-- modules/indeterminate/indeterminate.js | 2 +- modules/inflector/inflector.js | 2 +- modules/jq/jq.js | 2 +- modules/scroll/ui-scroll.js | 6 +++--- modules/showhide/showhide.js | 6 +++--- modules/unique/unique.js | 4 ++-- modules/validate/validate.js | 4 ++-- 9 files changed, 15 insertions(+), 16 deletions(-) diff --git a/demo/demo.js b/demo/demo.js index 169214f3..4d5686e6 100644 --- a/demo/demo.js +++ b/demo/demo.js @@ -4,7 +4,7 @@ angular.module('doc.ui-utils', ['ui.utils', 'prettifyDirective' ]); angular.module('ui.scroll') .factory('datasource', [ - '$log', '$timeout', '$rootScope', function(console, $timeout, $rootScope) { + '$log', '$timeout', function(console, $timeout) { var get = function(index, count, success) { return $timeout(function() { var i, result, _i, _ref; diff --git a/modules/ie-shiv/ie-shiv.js b/modules/ie-shiv/ie-shiv.js index 839b0cc5..a077f37d 100644 --- a/modules/ie-shiv/ie-shiv.js +++ b/modules/ie-shiv/ie-shiv.js @@ -15,8 +15,7 @@ (function (window, document) { "use strict"; - var debug = window.ieShivDebug || false, - tags = [ "ngInclude", "ngPluralize", "ngView", "ngSwitch", "uiCurrency", "uiCodemirror", "uiDate", "uiEvent", + var tags = [ "ngInclude", "ngPluralize", "ngView", "ngSwitch", "uiCurrency", "uiCodemirror", "uiDate", "uiEvent", "uiKeypress", "uiKeyup", "uiKeydown", "uiMask", "uiMapInfoWindow", "uiMapMarker", "uiMapPolyline", "uiMapPolygon", "uiMapRectangle", "uiMapCircle", "uiMapGroundOverlay", "uiModal", "uiReset", "uiScrollfix", "uiSelect2", "uiShow", "uiHide", "uiToggle", "uiSortable", "uiTinymce" diff --git a/modules/indeterminate/indeterminate.js b/modules/indeterminate/indeterminate.js index 63184e5e..797ed4a2 100644 --- a/modules/indeterminate/indeterminate.js +++ b/modules/indeterminate/indeterminate.js @@ -14,7 +14,7 @@ angular.module('ui.indeterminate',[]).directive('uiIndeterminate', [ } return function ($scope, elm, attrs) { - $scope.$watch(attrs.uiIndeterminate, function(newVal, oldVal) { + $scope.$watch(attrs.uiIndeterminate, function(newVal) { elm[0].indeterminate = !!newVal; }); }; diff --git a/modules/inflector/inflector.js b/modules/inflector/inflector.js index 47dd6358..1345cd63 100644 --- a/modules/inflector/inflector.js +++ b/modules/inflector/inflector.js @@ -35,7 +35,7 @@ angular.module('ui.inflector',[]).filter('inflector', function () { } }; - return function (text, inflector, separator) { + return function (text, inflector) { if (inflector !== false && angular.isString(text)) { inflector = inflector || 'humanize'; return inflectors[inflector](text); diff --git a/modules/jq/jq.js b/modules/jq/jq.js index 29ab281c..6584a2b8 100644 --- a/modules/jq/jq.js +++ b/modules/jq/jq.js @@ -57,7 +57,7 @@ angular.module('ui.jq',[]). // If ui-refresh is used, re-fire the the method upon every change if (attrs.uiRefresh) { - scope.$watch(attrs.uiRefresh, function(newVal) { + scope.$watch(attrs.uiRefresh, function() { callPlugin(); }); } diff --git a/modules/scroll/ui-scroll.js b/modules/scroll/ui-scroll.js index c6a3d3b4..93d6425b 100644 --- a/modules/scroll/ui-scroll.js +++ b/modules/scroll/ui-scroll.js @@ -12,7 +12,7 @@ */ angular.module('ui.scroll', []).directive('ngScrollViewport', [ - '$log', function(console) { + '$log', function() { return { controller: [ '$scope', '$element', function(scope, element) { @@ -127,7 +127,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ pending = []; eof = false; bof = false; - loading = datasource.loading || function(value) {}; + loading = datasource.loading || function() {}; isLoading = false; removeFromBuffer = function(start, stop) { var i, _i; @@ -431,7 +431,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ var j, newItems, _k, _len2, _results; if (newItems = locator(wrapper.scope)) { insert = function(index, newItem) { - insert(index, item); + insert(index, newItem); return next++; }; if (isArray(newItems)) { diff --git a/modules/showhide/showhide.js b/modules/showhide/showhide.js index c4021b36..18e1e96f 100644 --- a/modules/showhide/showhide.js +++ b/modules/showhide/showhide.js @@ -11,7 +11,7 @@ angular.module('ui.showhide',[]) .directive('uiShow', [function () { return function (scope, elm, attrs) { - scope.$watch(attrs.uiShow, function (newVal, oldVal) { + scope.$watch(attrs.uiShow, function (newVal) { if (newVal) { elm.addClass('ui-show'); } else { @@ -31,7 +31,7 @@ angular.module('ui.showhide',[]) */ .directive('uiHide', [function () { return function (scope, elm, attrs) { - scope.$watch(attrs.uiHide, function (newVal, oldVal) { + scope.$watch(attrs.uiHide, function (newVal) { if (newVal) { elm.addClass('ui-hide'); } else { @@ -52,7 +52,7 @@ angular.module('ui.showhide',[]) */ .directive('uiToggle', [function () { return function (scope, elm, attrs) { - scope.$watch(attrs.uiToggle, function (newVal, oldVal) { + scope.$watch(attrs.uiToggle, function (newVal) { if (newVal) { elm.removeClass('ui-hide').addClass('ui-show'); } else { diff --git a/modules/unique/unique.js b/modules/unique/unique.js index ded107ea..c9fff1e1 100644 --- a/modules/unique/unique.js +++ b/modules/unique/unique.js @@ -16,7 +16,7 @@ angular.module('ui.unique',[]).filter('unique', ['$parse', function ($parse) { } if ((filterOn || angular.isUndefined(filterOn)) && angular.isArray(items)) { - var hashCheck = {}, newItems = [], + var newItems = [], get = angular.isString(filterOn) ? $parse(filterOn) : function (item) { return item; }; var extractValueToCompare = function (item) { @@ -24,7 +24,7 @@ angular.module('ui.unique',[]).filter('unique', ['$parse', function ($parse) { }; angular.forEach(items, function (item) { - var valueToCheck, isDuplicate = false; + var isDuplicate = false; for (var i = 0; i < newItems.length; i++) { if (angular.equals(extractValueToCompare(newItems[i]), extractValueToCompare(item))) { diff --git a/modules/validate/validate.js b/modules/validate/validate.js index 83b43277..fb315351 100644 --- a/modules/validate/validate.js +++ b/modules/validate/validate.js @@ -22,8 +22,8 @@ angular.module('ui.validate',[]).directive('uiValidate', function () { restrict: 'A', require: 'ngModel', link: function (scope, elm, attrs, ctrl) { - var validateFn, watch, validators = {}, - validateExpr = scope.$eval(attrs.uiValidate); + var validateFn, validators = {}, + validateExpr = scope.$eval(attrs.uiValidate); if (!validateExpr){ return;} From 32140e04be176c4b2a5954d2cf8e9ec3c48a6f5c Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 16:10:01 +0100 Subject: [PATCH 17/28] fix(ui-scroll): 'setOffset' is not defined. I have no idea of what it supposed to do. I fixed it by returning the value given in the function argument but I bet that it's not the behavior we want -_- --- modules/scroll/ui-scroll-jqlite.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/scroll/ui-scroll-jqlite.js b/modules/scroll/ui-scroll-jqlite.js index 2d54ca39..29bc5120 100644 --- a/modules/scroll/ui-scroll-jqlite.js +++ b/modules/scroll/ui-scroll-jqlite.js @@ -175,7 +175,7 @@ angular.module('ui.scroll.jqlite', ['ui.scroll']).service('jqLiteExtras', [ if (value === void 0) { return self; } else { - return setOffset; + return value; } } From 3fd7fc47de7d05460a55ca42e4afec60d8e8cc4d Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 16:17:22 +0100 Subject: [PATCH 18/28] fix(ui-scroll): 'isArray' is not defined. I guess that we want angular.isArray here --- modules/scroll/ui-scroll.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/scroll/ui-scroll.js b/modules/scroll/ui-scroll.js index 93d6425b..3c54ac85 100644 --- a/modules/scroll/ui-scroll.js +++ b/modules/scroll/ui-scroll.js @@ -434,7 +434,7 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ insert(index, newItem); return next++; }; - if (isArray(newItems)) { + if (angular.isArray(newItems)) { _results = []; for (j = _k = 0, _len2 = newitems.length; _k < _len2; j = ++_k) { item = newitems[j]; From 796e310a26ac43a248c0c732877242890fdda2be Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 16:18:34 +0100 Subject: [PATCH 19/28] fix(ui-scroll): 'newitems' is not defined. Must be a typo --- modules/scroll/ui-scroll.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/scroll/ui-scroll.js b/modules/scroll/ui-scroll.js index 3c54ac85..1c2f625b 100644 --- a/modules/scroll/ui-scroll.js +++ b/modules/scroll/ui-scroll.js @@ -436,8 +436,8 @@ angular.module('ui.scroll', []).directive('ngScrollViewport', [ }; if (angular.isArray(newItems)) { _results = []; - for (j = _k = 0, _len2 = newitems.length; _k < _len2; j = ++_k) { - item = newitems[j]; + for (j = _k = 0, _len2 = newItems.length; _k < _len2; j = ++_k) { + item = newItems[j]; _results.push(inserted.push(insert(i + j, item))); } return _results; From 42a82507f48b813d5ba37c599b1d89fe6b40ddd4 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 16:51:46 +0100 Subject: [PATCH 20/28] chore(grunt): the initial config is no longer variable --- gruntFile.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/gruntFile.js b/gruntFile.js index 964564e7..df5418e2 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -1,6 +1,6 @@ -module.exports = function (grunt) { +'use strict'; - var initConfig; +module.exports = function (grunt) { // Loading external tasks require('load-grunt-tasks')(grunt); @@ -10,6 +10,7 @@ module.exports = function (grunt) { grunt.registerTask('serve', [ 'karma:continuous', 'dist', 'build:gh-pages', 'connect:continuous', 'watch']); grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'ngmin', 'uglify', 'concat:html_doc', 'copy']); + // HACK TO ACCESS TO THE COMPONENT-PUBLISHER function fakeTargetTask(prefix){ return function(){ @@ -30,7 +31,7 @@ module.exports = function (grunt) { // - // + // HACK TO LIST ALL THE MODULE NAMES var moduleNames = grunt.file.expand({ cwd: 'modules' }, ['*','!utils.js']); function ngMinModulesConfig(memo, moduleName){ @@ -46,14 +47,17 @@ module.exports = function (grunt) { // + // HACK TO MAKE TRAVIS WORK var testConfig = function(configFile, customOptions) { var options = { configFile: configFile, singleRun: true }; var travisOptions = process.env.TRAVIS && { browsers: ['Firefox', 'PhantomJS'], reporters: ['dots'] }; return grunt.util._.extend(options, customOptions, travisOptions); }; + // + // Project configuration. - initConfig = { + grunt.initConfig({ bower: 'bower_components', dist : '<%= bower %>/angular-ui-docs', pkg: grunt.file.readJSON('package.json'), @@ -183,7 +187,6 @@ module.exports = function (grunt) { }, ngmin: moduleNames.reduce(ngMinModulesConfig, {}) - }; - grunt.initConfig(initConfig); + }); }; From 869d4313319e9fc9f860dd78aa49f8d407f75127 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 17:03:07 +0100 Subject: [PATCH 21/28] style(jshint): global use strict in specs - fix(mask): ReferenceError: c is not defined - fix(indeterminate): ReferenceError: assignment to undeclared variable elm --- modules/event/test/eventSpec.js | 4 +++- modules/format/test/formatSpec.js | 4 +++- modules/highlight/test/highlightSpec.js | 4 +++- modules/include/test/includeSpec.js | 2 ++ modules/indeterminate/test/indeterminateSpec.js | 6 ++++-- modules/inflector/test/inflectorSpec.js | 4 +++- modules/jq/test/jqSpec.js | 2 ++ modules/keypress/test/keydownSpec.js | 5 +++-- modules/keypress/test/keypressSpec.js | 6 +++--- modules/keypress/test/keyupSpec.js | 5 +++-- modules/mask/test/maskSpec.js | 2 +- modules/unique/test/uniqueSpec.js | 4 +++- modules/validate/test/validateSpec.js | 2 ++ 13 files changed, 35 insertions(+), 15 deletions(-) diff --git a/modules/event/test/eventSpec.js b/modules/event/test/eventSpec.js index 96bf8ce4..aded0675 100644 --- a/modules/event/test/eventSpec.js +++ b/modules/event/test/eventSpec.js @@ -1,4 +1,6 @@ describe('uiEvent', function () { + 'use strict'; + var $scope, $rootScope, $compile; beforeEach(module('ui.event')); @@ -76,4 +78,4 @@ describe('uiEvent', function () { }); }); -}); \ No newline at end of file +}); diff --git a/modules/format/test/formatSpec.js b/modules/format/test/formatSpec.js index 9ca86c2d..6068d1b9 100644 --- a/modules/format/test/formatSpec.js +++ b/modules/format/test/formatSpec.js @@ -1,4 +1,6 @@ describe('format', function() { + 'use strict'; + var formatFilter; beforeEach(module('ui.format')); @@ -30,4 +32,4 @@ describe('format', function() { it('should do nothing if tokens are undefined', function() { expect(formatFilter('Hello There')).toEqual('Hello There'); }); -}); \ No newline at end of file +}); diff --git a/modules/highlight/test/highlightSpec.js b/modules/highlight/test/highlightSpec.js index fd234f17..205a98e2 100644 --- a/modules/highlight/test/highlightSpec.js +++ b/modules/highlight/test/highlightSpec.js @@ -1,4 +1,6 @@ describe('highlight', function () { + 'use strict'; + var highlightFilter, testPhrase = 'Prefix Highlight Suffix'; beforeEach(module('ui.highlight')); @@ -45,4 +47,4 @@ describe('highlight', function () { it('should highlight nothing if empty filter string passed - issue #114', function () { expect(highlightFilter(testPhrase, '')).toEqual(testPhrase); }); -}); \ No newline at end of file +}); diff --git a/modules/include/test/includeSpec.js b/modules/include/test/includeSpec.js index 3196ba2f..626b5c44 100644 --- a/modules/include/test/includeSpec.js +++ b/modules/include/test/includeSpec.js @@ -1,5 +1,7 @@ // modeled after: angular.js/test/ng/directive/ngIncludeSpec.js describe('uiInclude', function() { + 'use strict'; + var scope, $compile, $templateCache, element; afterEach(function() { diff --git a/modules/indeterminate/test/indeterminateSpec.js b/modules/indeterminate/test/indeterminateSpec.js index 4e4b3231..88c4ea2c 100644 --- a/modules/indeterminate/test/indeterminateSpec.js +++ b/modules/indeterminate/test/indeterminateSpec.js @@ -1,5 +1,7 @@ describe('uiIndeterminate', function () { - var $scope, $compile; + 'use strict'; + + var $scope, $compile, elm; beforeEach(module('ui.indeterminate')); beforeEach(inject(function (_$rootScope_, _$compile_) { @@ -28,4 +30,4 @@ describe('uiIndeterminate', function () { $scope.$apply(); expect(elm[0].indeterminate).toBeFalsy(); }); -}); \ No newline at end of file +}); diff --git a/modules/inflector/test/inflectorSpec.js b/modules/inflector/test/inflectorSpec.js index a4ea1e19..a6f20fb3 100644 --- a/modules/inflector/test/inflectorSpec.js +++ b/modules/inflector/test/inflectorSpec.js @@ -1,4 +1,6 @@ describe('inflector', function () { + 'use strict'; + var inflectorFilter, testPhrase = 'here isMy_phone_number'; beforeEach(module('ui.inflector')); @@ -36,4 +38,4 @@ describe('inflector', function () { expect(inflectorFilter("hereIsMyPhoneNumber", 'variable')).toEqual('hereIsMyPhoneNumber'); }); }); -}); \ No newline at end of file +}); diff --git a/modules/jq/test/jqSpec.js b/modules/jq/test/jqSpec.js index 04795f0e..05cc201a 100644 --- a/modules/jq/test/jqSpec.js +++ b/modules/jq/test/jqSpec.js @@ -1,4 +1,6 @@ describe('uiJq', function () { + 'use strict'; + var scope, compile, timeout; scope = null; beforeEach(module('ui.jq')); diff --git a/modules/keypress/test/keydownSpec.js b/modules/keypress/test/keydownSpec.js index 51a0806a..e7d53f19 100644 --- a/modules/keypress/test/keydownSpec.js +++ b/modules/keypress/test/keydownSpec.js @@ -1,4 +1,5 @@ describe('uiKeydown', function () { + 'use strict'; var $scope, $compile; @@ -38,7 +39,7 @@ describe('uiKeydown', function () { createElement({'ctrl-shift-13': 'event=true'}).trigger(createKeyEvent(13, false, true, true, false)); expect($scope.event).toBe(true); }); - + it('should support alternative combinations', function () { $scope.event = 0; createElement({'ctrl-shift-14 ctrl-shift-13': 'event=event+1'}).trigger(createKeyEvent(13, false, true, true, false)).trigger(createKeyEvent(14, false, true, true, false)); @@ -72,4 +73,4 @@ describe('uiKeydown', function () { element.trigger(createKeyEvent(13)); expect($scope.event2.keyCode).toBe(13); }); -}); \ No newline at end of file +}); diff --git a/modules/keypress/test/keypressSpec.js b/modules/keypress/test/keypressSpec.js index daea9d91..1ab72a8c 100644 --- a/modules/keypress/test/keypressSpec.js +++ b/modules/keypress/test/keypressSpec.js @@ -1,5 +1,5 @@ - describe('uiKeypress', function () { + 'use strict'; var $scope, $compile; @@ -39,7 +39,7 @@ describe('uiKeypress', function () { createElement({'ctrl-shift-13': 'event=true'}).trigger(createKeyEvent(13, false, true, true, false)); expect($scope.event).toBe(true); }); - + it('should support alternative combinations', function () { $scope.event = 0; createElement({'ctrl-shift-14 ctrl-shift-13': 'event=event+1'}).trigger(createKeyEvent(13, false, true, true, false)).trigger(createKeyEvent(14, false, true, true, false)); @@ -73,4 +73,4 @@ describe('uiKeypress', function () { element.trigger(createKeyEvent(13)); expect($scope.event2.keyCode).toBe(13); }); -}); \ No newline at end of file +}); diff --git a/modules/keypress/test/keyupSpec.js b/modules/keypress/test/keyupSpec.js index 5c104451..23b0dcc6 100644 --- a/modules/keypress/test/keyupSpec.js +++ b/modules/keypress/test/keyupSpec.js @@ -1,4 +1,5 @@ describe('uiKeyup', function () { + 'use strict'; var $scope, $compile; @@ -38,7 +39,7 @@ describe('uiKeyup', function () { createElement({'ctrl-shift-13': 'event=true'}).trigger(createKeyEvent(13, false, true, true, false)); expect($scope.event).toBe(true); }); - + it('should support alternative combinations', function () { $scope.event = 0; createElement({'ctrl-shift-14 ctrl-shift-13': 'event=event+1'}).trigger(createKeyEvent(13, false, true, true, false)).trigger(createKeyEvent(14, false, true, true, false)); @@ -72,4 +73,4 @@ describe('uiKeyup', function () { element.trigger(createKeyEvent(13)); expect($scope.event2.keyCode).toBe(13); }); -}); \ No newline at end of file +}); diff --git a/modules/mask/test/maskSpec.js b/modules/mask/test/maskSpec.js index c15b498e..7d8976ba 100644 --- a/modules/mask/test/maskSpec.js +++ b/modules/mask/test/maskSpec.js @@ -1,4 +1,5 @@ describe('uiMask', function () { + 'use strict'; var formHtml = "
"; var inputHtml = ""; @@ -6,7 +7,6 @@ describe('uiMask', function () { beforeEach(module('ui.mask')); beforeEach(inject(function ($rootScope, $compile, uiMaskConfig) { - c = console.log; scope = $rootScope; config = uiMaskConfig; compileElement = function(html) { diff --git a/modules/unique/test/uniqueSpec.js b/modules/unique/test/uniqueSpec.js index 241981b0..547d24ed 100644 --- a/modules/unique/test/uniqueSpec.js +++ b/modules/unique/test/uniqueSpec.js @@ -1,4 +1,6 @@ describe('unique', function () { + 'use strict'; + var uniqueFilter; beforeEach(module('ui.unique')); @@ -90,4 +92,4 @@ describe('unique', function () { expect(uniqueFilter(arrayToFilter, false)).toEqual(arrayToFilter); }); -}); \ No newline at end of file +}); diff --git a/modules/validate/test/validateSpec.js b/modules/validate/test/validateSpec.js index e6ce1985..cdbb5f2d 100644 --- a/modules/validate/test/validateSpec.js +++ b/modules/validate/test/validateSpec.js @@ -1,4 +1,6 @@ describe('uiValidate', function ($compile) { + 'use strict'; + var scope, compileAndDigest; var trueValidator = function () { From edc5324ffaf4bc4e74886ec31b7af13818496b7d Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 17:29:08 +0100 Subject: [PATCH 22/28] style(jshint): Mixed double and single quotes correction in specs --- modules/include/test/includeSpec.js | 4 +- modules/inflector/test/inflectorSpec.js | 2 +- modules/jq/test/jqSpec.js | 6 +- modules/keypress/test/keydownSpec.js | 4 +- modules/keypress/test/keypressSpec.js | 4 +- modules/keypress/test/keyupSpec.js | 4 +- modules/mask/test/maskSpec.js | 142 ++++++++++++------------ modules/unique/test/uniqueSpec.js | 4 +- 8 files changed, 85 insertions(+), 85 deletions(-) diff --git a/modules/include/test/includeSpec.js b/modules/include/test/includeSpec.js index 626b5c44..95b0b142 100644 --- a/modules/include/test/includeSpec.js +++ b/modules/include/test/includeSpec.js @@ -22,14 +22,14 @@ describe('uiInclude', function() { it('should include on external file', function () { putIntoCache('myUrl', '{{name}}'); element = $compile('
')(scope); - scope.$apply("name = 'misko'"); + scope.$apply('name = "misko"'); expect(element.text()).toEqual('misko'); }); it('should work with a fragment selector', function () { putIntoCache('myUrl', 'foo {{name}}bar {{name}}baz {{name}}'); element = $compile('
')(scope); - scope.$apply("name = 'misko'"); + scope.$apply('name = "misko"'); expect(element.text()).toEqual('bar misko'); }); diff --git a/modules/inflector/test/inflectorSpec.js b/modules/inflector/test/inflectorSpec.js index a6f20fb3..6ee890e2 100644 --- a/modules/inflector/test/inflectorSpec.js +++ b/modules/inflector/test/inflectorSpec.js @@ -35,7 +35,7 @@ describe('inflector', function () { expect(inflectorFilter(testPhrase, 'variable')).toEqual('hereIsMyPhoneNumber'); }); it('should do nothing if already formatted properly', function () { - expect(inflectorFilter("hereIsMyPhoneNumber", 'variable')).toEqual('hereIsMyPhoneNumber'); + expect(inflectorFilter('hereIsMyPhoneNumber', 'variable')).toEqual('hereIsMyPhoneNumber'); }); }); }); diff --git a/modules/jq/test/jqSpec.js b/modules/jq/test/jqSpec.js index 05cc201a..05bfe01e 100644 --- a/modules/jq/test/jqSpec.js +++ b/modules/jq/test/jqSpec.js @@ -20,14 +20,14 @@ describe('uiJq', function () { describe('function or plugin isn\'t found', function () { it('should throw an error', function () { expect(function () { - compile("
")(scope); + compile('
')(scope); }).toThrow(); }); }); describe('calling a jQuery element function', function () { it('should just like, sort of work and junk', function () { spyOn(jQuery.fn, 'foo'); - compile("
")(scope); + compile('
')(scope); timeout.flush(); expect(jQuery.fn.foo).toHaveBeenCalled(); }); @@ -38,7 +38,7 @@ describe('uiJq', function () { // console.log(length); }; scope.$apply('items=[1, 2]'); - compile("
")(scope); + compile('
')(scope); scope.$apply(); timeout.flush(); expect(length).toBe(2); diff --git a/modules/keypress/test/keydownSpec.js b/modules/keypress/test/keydownSpec.js index e7d53f19..5b3851a4 100644 --- a/modules/keypress/test/keydownSpec.js +++ b/modules/keypress/test/keydownSpec.js @@ -4,7 +4,7 @@ describe('uiKeydown', function () { var $scope, $compile; var createKeyEvent = function (mainKey, alt, ctrl, shift, meta) { - var keyEvent = jQuery.Event("keydown"); + var keyEvent = jQuery.Event('keydown'); keyEvent.keyCode = mainKey; keyEvent.altKey = alt; @@ -17,7 +17,7 @@ describe('uiKeydown', function () { var createElement = function (elementDef) { var elementStr = angular.isString(elementDef) ? elementDef : angular.toJson(elementDef); - return $compile("")($scope); + return $compile('')($scope); }; beforeEach(module('ui.keypress')); diff --git a/modules/keypress/test/keypressSpec.js b/modules/keypress/test/keypressSpec.js index 1ab72a8c..32244377 100644 --- a/modules/keypress/test/keypressSpec.js +++ b/modules/keypress/test/keypressSpec.js @@ -4,7 +4,7 @@ describe('uiKeypress', function () { var $scope, $compile; var createKeyEvent = function (mainKey, alt, ctrl, shift, meta) { - var keyEvent = jQuery.Event("keypress"); + var keyEvent = jQuery.Event('keypress'); keyEvent.keyCode = mainKey; keyEvent.altKey = alt; @@ -17,7 +17,7 @@ describe('uiKeypress', function () { var createElement = function (elementDef) { var elementStr = angular.isString(elementDef) ? elementDef : angular.toJson(elementDef); - return $compile("")($scope); + return $compile('')($scope); }; beforeEach(module('ui.keypress')); diff --git a/modules/keypress/test/keyupSpec.js b/modules/keypress/test/keyupSpec.js index 23b0dcc6..56faa174 100644 --- a/modules/keypress/test/keyupSpec.js +++ b/modules/keypress/test/keyupSpec.js @@ -4,7 +4,7 @@ describe('uiKeyup', function () { var $scope, $compile; var createKeyEvent = function (mainKey, alt, ctrl, shift, meta) { - var keyEvent = jQuery.Event("keyup"); + var keyEvent = jQuery.Event('keyup'); keyEvent.keyCode = mainKey; keyEvent.altKey = alt; @@ -17,7 +17,7 @@ describe('uiKeyup', function () { var createElement = function (elementDef) { var elementStr = angular.isString(elementDef) ? elementDef : angular.toJson(elementDef); - return $compile("")($scope); + return $compile('')($scope); }; beforeEach(module('ui.keypress')); diff --git a/modules/mask/test/maskSpec.js b/modules/mask/test/maskSpec.js index 7d8976ba..1c0a87a1 100644 --- a/modules/mask/test/maskSpec.js +++ b/modules/mask/test/maskSpec.js @@ -1,11 +1,11 @@ -describe('uiMask', function () { - 'use strict'; +describe("uiMask", function () { + "use strict"; var formHtml = "
"; var inputHtml = ""; var compileElement, scope, config; - beforeEach(module('ui.mask')); + beforeEach(module("ui.mask")); beforeEach(inject(function ($rootScope, $compile, uiMaskConfig) { scope = $rootScope; config = uiMaskConfig; @@ -14,145 +14,145 @@ describe('uiMask', function () { }; })); - describe('initialization', function () { + describe("initialization", function () { it("should not not happen if the mask is undefined or invalid", function() { var input = compileElement(inputHtml); scope.$apply("x = 'abc123'"); - expect(input.val()).toBe('abc123'); + expect(input.val()).toBe("abc123"); scope.$apply("mask = '()_abc123'"); - expect(input.val()).toBe('abc123'); + expect(input.val()).toBe("abc123"); }); it("should mask the value only if it's valid", function() { var input = compileElement(inputHtml); scope.$apply("x = 'abc123'"); scope.$apply("mask = '(A) * 9'"); - expect(input.val()).toBe('(a) b 1'); + expect(input.val()).toBe("(a) b 1"); scope.$apply("mask = '(A) * 9 A'"); - expect(input.val()).toBe(''); + expect(input.val()).toBe(""); }); it("should not dirty or invalidate the input", function() { var input = compileElement(inputHtml); scope.$apply("x = 'abc123'"); scope.$apply("mask = '(9) * A'"); - expect(input.hasClass('ng-pristine ng-valid')).toBeTruthy(); + expect(input.hasClass("ng-pristine ng-valid")).toBeTruthy(); scope.$apply("mask = '(9) * A 9'"); - expect(input.hasClass('ng-pristine ng-valid')).toBeTruthy(); + expect(input.hasClass("ng-pristine ng-valid")).toBeTruthy(); }); it("should not change the model value", function() { var input = compileElement(inputHtml); scope.$apply("x = 'abc123'"); scope.$apply("mask = '(A) * 9'"); - expect(scope.x).toBe('abc123'); + expect(scope.x).toBe("abc123"); scope.$apply("mask = '(A) * 9 A'"); - expect(scope.x).toBe('abc123'); + expect(scope.x).toBe("abc123"); }); it("should set ngModelController.$viewValue to match input value", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = 'abc123'"); scope.$apply("mask = '(A) * 9'"); - expect(scope.test.input.$viewValue).toBe('(a) b 1'); + expect(scope.test.input.$viewValue).toBe("(a) b 1"); scope.$apply("mask = '(A) * 9 A'"); - expect(scope.test.input.$viewValue).toBe(''); + expect(scope.test.input.$viewValue).toBe(""); }); }); - describe('user input', function () { + describe("user input", function () { it("should mask-as-you-type", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = ''"); scope.$apply("mask = '(A) * 9'"); - input.val('a').triggerHandler('input'); - expect(input.val()).toBe('(a) _ _'); - input.val('ab').triggerHandler('input'); - expect(input.val()).toBe('(a) b _'); - input.val('ab1').triggerHandler('input'); - expect(input.val()).toBe('(a) b 1'); + input.val("a").triggerHandler("input"); + expect(input.val()).toBe("(a) _ _"); + input.val("ab").triggerHandler("input"); + expect(input.val()).toBe("(a) b _"); + input.val("ab1").triggerHandler("input"); + expect(input.val()).toBe("(a) b 1"); }); it("should set ngModelController.$viewValue to match input value", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = ''"); scope.$apply("mask = '(A) * 9'"); - input.val('a').triggerHandler('input'); - input.triggerHandler('change'); // Because IE8 and below are terrible - expect(scope.test.input.$viewValue).toBe('(a) _ _'); + input.val("a").triggerHandler("input"); + input.triggerHandler("change"); // Because IE8 and below are terrible + expect(scope.test.input.$viewValue).toBe("(a) _ _"); }); it("should parse unmasked value to model", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = ''"); scope.$apply("mask = '(A) * 9'"); - input.val('abc123').triggerHandler('input'); - input.triggerHandler('change'); // Because IE8 and below are terrible - expect(scope.x).toBe('ab1'); + input.val("abc123").triggerHandler("input"); + input.triggerHandler("change"); // Because IE8 and below are terrible + expect(scope.x).toBe("ab1"); }); it("should set model to undefined if masked value is invalid", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = ''"); scope.$apply("mask = '(A) * 9'"); - input.val('a').triggerHandler('input'); - input.triggerHandler('change'); // Because IE8 and below are terrible + input.val("a").triggerHandler("input"); + input.triggerHandler("change"); // Because IE8 and below are terrible expect(scope.x).toBeUndefined(); }); it("should not set model to an empty mask", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = ''"); scope.$apply("mask = '(A) * 9'"); - input.triggerHandler('input'); - expect(scope.x).toBe(''); + input.triggerHandler("input"); + expect(scope.x).toBe(""); }); }); - describe('changes from the model', function () { + describe("changes from the model", function () { it("should set the correct ngModelController.$viewValue", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("mask = '(A) * 9'"); scope.$apply("x = ''"); expect(scope.test.input.$viewValue).not.toBeDefined(); scope.$apply("x = 'abc'"); expect(scope.test.input.$viewValue).not.toBeDefined(); scope.$apply("x = 'abc123'"); - expect(scope.test.input.$viewValue).toBe('(a) b 1'); + expect(scope.test.input.$viewValue).toBe("(a) b 1"); }); }); - describe('default mask definitions', function () { + describe("default mask definitions", function () { it("should accept optional mask after '?'", function (){ var input = compileElement(inputHtml); scope.$apply("x = ''"); scope.$apply("mask = '**?9'"); - input.val('aa').triggerHandler('input'); - input.triggerHandler('blur'); - expect(input.val()).toBe('aa_'); + input.val("aa").triggerHandler("input"); + input.triggerHandler("blur"); + expect(input.val()).toBe("aa_"); - input.val('99a').triggerHandler('input'); - input.triggerHandler('blur'); - expect(input.val()).toBe('99_'); + input.val("99a").triggerHandler("input"); + input.triggerHandler("blur"); + expect(input.val()).toBe("99_"); - input.val('992').triggerHandler('input'); - input.triggerHandler('blur'); - expect(input.val()).toBe('992'); + input.val("992").triggerHandler("input"); + input.triggerHandler("blur"); + expect(input.val()).toBe("992"); }); }); - describe('placeholders', function () { + describe("placeholders", function () { it("should have default placeholder functionality", function() { var input = compileElement(inputHtml); @@ -174,7 +174,7 @@ describe('uiMask', function () { input.val("12").triggerHandler("input"); - expect(input.val()).toBe('12/DD/YYYY'); + expect(input.val()).toBe("12/DD/YYYY"); }); it("should update mask substitutions via the placeholder attribute", function() { @@ -200,53 +200,53 @@ describe('uiMask', function () { }); - describe('configuration', function () { + describe("configuration", function () { it("should accept the new mask definition set globally", function() { - config.maskDefinitions['@'] = /[fz]/; + config.maskDefinitions["@"] = /[fz]/; var input = compileElement(inputHtml); scope.$apply("x = ''"); scope.$apply("mask = '@193'"); - input.val('f123').triggerHandler('input'); - input.triggerHandler('blur'); - expect(input.val()).toBe('f123'); + input.val("f123").triggerHandler("input"); + input.triggerHandler("blur"); + expect(input.val()).toBe("f123"); }); it("should accept the new mask definition set per element", function() { - delete config.maskDefinitions['@']; + delete config.maskDefinitions["@"]; scope.input = { - options: {maskDefinitions: {'@': /[fz]/}} + options: {maskDefinitions: {"@": /[fz]/}} }; - var input = compileElement(''); + var input = compileElement(""); scope.$apply("x = ''"); scope.$apply("mask = '@999'"); - input.val('f111').triggerHandler('input'); - input.triggerHandler('blur'); - expect(input.val()).toBe('f111'); + input.val("f111").triggerHandler("input"); + input.triggerHandler("blur"); + expect(input.val()).toBe("f111"); }); }); - describe('blurring', function () { + describe("blurring", function () { it("should clear an invalid value from the input", function() { var input = compileElement(inputHtml); scope.$apply("x = ''"); scope.$apply("mask = '(9) * A'"); - input.val('a').triggerHandler('input'); - input.triggerHandler('blur'); - expect(input.val()).toBe(''); + input.val("a").triggerHandler("input"); + input.triggerHandler("blur"); + expect(input.val()).toBe(""); }); it("should clear an invalid value from the ngModelController.$viewValue", function() { var form = compileElement(formHtml); - var input = form.find('input'); + var input = form.find("input"); scope.$apply("x = ''"); scope.$apply("mask = '(A) * 9'"); - input.val('a').triggerHandler('input'); - input.triggerHandler('blur'); - expect(scope.test.input.$viewValue).toBe(''); + input.val("a").triggerHandler("input"); + input.triggerHandler("blur"); + expect(scope.test.input.$viewValue).toBe(""); }); }); diff --git a/modules/unique/test/uniqueSpec.js b/modules/unique/test/uniqueSpec.js index 547d24ed..0550d23c 100644 --- a/modules/unique/test/uniqueSpec.js +++ b/modules/unique/test/uniqueSpec.js @@ -73,11 +73,11 @@ describe('unique', function () { }); it('should work correctly for arrays of mixed elements and object equality', function () { - expect(uniqueFilter([1, {key: 'value'}, 1, {key: 'value'}, 2, "string", 3])).toEqual([1, {key: 'value'}, 2, "string", 3]); + expect(uniqueFilter([1, {key: 'value'}, 1, {key: 'value'}, 2, 'string', 3])).toEqual([1, {key: 'value'}, 2, 'string', 3]); }); it('should work correctly for arrays of mixed elements and a key specified', function () { - expect(uniqueFilter([1, {key: 'value'}, 1, {key: 'value'}, 2, "string", 3], 'key')).toEqual([1, {key: 'value'}, 2, "string", 3]); + expect(uniqueFilter([1, {key: 'value'}, 1, {key: 'value'}, 2, 'string', 3], 'key')).toEqual([1, {key: 'value'}, 2, 'string', 3]); }); it('should return unmodified object if not array', function () { From 8a0ca4621b03348bc2b335838fce9cacfc0dcdc4 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 17:38:19 +0100 Subject: [PATCH 23/28] style(jshint): remove unused variables in specs --- modules/mask/test/maskSpec.js | 7 ++----- modules/reset/test/resetSpec.js | 4 ++-- modules/route/test/routeSpec.js | 5 ++--- modules/scroll/test/ScrollerSpec.js | 21 ++++++++------------- modules/scroll/test/jqliteExtrasSpec.js | 9 +-------- modules/validate/test/validateSpec.js | 2 +- 6 files changed, 16 insertions(+), 32 deletions(-) diff --git a/modules/mask/test/maskSpec.js b/modules/mask/test/maskSpec.js index 1c0a87a1..1f469070 100644 --- a/modules/mask/test/maskSpec.js +++ b/modules/mask/test/maskSpec.js @@ -43,7 +43,6 @@ describe("uiMask", function () { }); it("should not change the model value", function() { - var input = compileElement(inputHtml); scope.$apply("x = 'abc123'"); scope.$apply("mask = '(A) * 9'"); expect(scope.x).toBe("abc123"); @@ -52,8 +51,7 @@ describe("uiMask", function () { }); it("should set ngModelController.$viewValue to match input value", function() { - var form = compileElement(formHtml); - var input = form.find("input"); + compileElement(formHtml); scope.$apply("x = 'abc123'"); scope.$apply("mask = '(A) * 9'"); expect(scope.test.input.$viewValue).toBe("(a) b 1"); @@ -119,8 +117,7 @@ describe("uiMask", function () { describe("changes from the model", function () { it("should set the correct ngModelController.$viewValue", function() { - var form = compileElement(formHtml); - var input = form.find("input"); + compileElement(formHtml); scope.$apply("mask = '(A) * 9'"); scope.$apply("x = ''"); expect(scope.test.input.$viewValue).not.toBeDefined(); diff --git a/modules/reset/test/resetSpec.js b/modules/reset/test/resetSpec.js index f59b8f8f..3ff9fd5e 100755 --- a/modules/reset/test/resetSpec.js +++ b/modules/reset/test/resetSpec.js @@ -4,7 +4,7 @@ describe('uiReset', function () { var scope, $compile; beforeEach(module('ui.reset')); - beforeEach(inject(function (_$rootScope_, _$compile_, _$window_) { + beforeEach(inject(function (_$rootScope_, _$compile_) { scope = _$rootScope_.$new(); $compile = _$compile_; })); @@ -52,4 +52,4 @@ describe('uiReset', function () { expect(element.val()).toBe('i was reset'); }); }); -}); \ No newline at end of file +}); diff --git a/modules/route/test/routeSpec.js b/modules/route/test/routeSpec.js index fa2c2af4..ab062173 100644 --- a/modules/route/test/routeSpec.js +++ b/modules/route/test/routeSpec.js @@ -1,10 +1,9 @@ -/*global describe, beforeEach, module, inject, it, spyOn, expect, $ */ describe('uiRoute', function () { 'use strict'; var scope, $compile, $location; beforeEach(module('ui.route')); - beforeEach(inject(function (_$rootScope_, _$compile_, _$window_, _$location_) { + beforeEach(inject(function (_$rootScope_, _$compile_, _$location_) { scope = _$rootScope_.$new(); $compile = _$compile_; $location = _$location_; @@ -36,7 +35,7 @@ describe('uiRoute', function () { if (routeModel){ elm.attr('ng-model', routeModel);} return $compile(elm[0])(scope); } - + describe('with uiRoute defined', function(){ it('should use the uiRoute property', function(){ compileRoute('
'); diff --git a/modules/scroll/test/ScrollerSpec.js b/modules/scroll/test/ScrollerSpec.js index 6c8f9973..aa327078 100644 --- a/modules/scroll/test/ScrollerSpec.js +++ b/modules/scroll/test/ScrollerSpec.js @@ -4,9 +4,8 @@ describe('uiScroll', function () { angular.module('ui.scroll.test', []) .factory('myEmptyDatasource', [ - '$log', '$timeout', '$rootScope', function(console, $timeout, $rootScope) { - var current, get, loading, revision; - get = function(index, count, success) { + function() { + var get = function(index, count, success) { success([]); }; @@ -17,9 +16,8 @@ describe('uiScroll', function () { ]) .factory('myOnePageDatasource', [ - '$log', '$timeout', '$rootScope', function(console, $timeout, $rootScope) { - var current, get, loading, revision; - get = function(index, count, success) { + function() { + var get = function(index, count, success) { if (index === 1) { success(['one', 'two', 'three']); } else { @@ -34,9 +32,8 @@ describe('uiScroll', function () { ]) .factory('myMultipageDatasource', [ - '$log', '$timeout', '$rootScope', function(console, $timeout, $rootScope) { - var current, get, loading, revision; - get = function(index, count, success) { + function() { + var get = function(index, count, success) { var result = []; for (var i = index; i0 && i<=20) { @@ -52,8 +49,6 @@ describe('uiScroll', function () { } ]); - var sandbox = angular.element('
'); - beforeEach(module('ui.scroll')); beforeEach(module('ui.scroll.test')); @@ -209,7 +204,7 @@ describe('uiScroll', function () { spy = spyOn(myMultipageDatasource, 'get').andCallThrough(); }); runTest(html, - function($window, sandbox) { + function() { expect(spy.calls.length).toBe(3); expect(spy.calls[0].args[0]).toBe(1); @@ -388,4 +383,4 @@ describe('uiScroll', function () { }); -}); \ No newline at end of file +}); diff --git a/modules/scroll/test/jqliteExtrasSpec.js b/modules/scroll/test/jqliteExtrasSpec.js index 0ef21abd..fe6f1089 100644 --- a/modules/scroll/test/jqliteExtrasSpec.js +++ b/modules/scroll/test/jqliteExtrasSpec.js @@ -93,13 +93,6 @@ describe('\njqLite: testing against jQuery\n', function () { '
some text w line height
' ], function(element) { - function validateHeight(element) { - expect(extras.prototype.height.call(element)).toBe(element.height()); - var h = element.height(); - extras.prototype.height.call(element, h*2); - expect(extras.prototype.height.call(element)).toBe(h*2); - } - it('height(value) for ' + element, function() { (function (element) { expect(extras.prototype.height.call(element)).toBe(element.height()); @@ -182,4 +175,4 @@ describe('\njqLite: testing against jQuery\n', function () { }); -}); \ No newline at end of file +}); diff --git a/modules/validate/test/validateSpec.js b/modules/validate/test/validateSpec.js index cdbb5f2d..35275a22 100644 --- a/modules/validate/test/validateSpec.js +++ b/modules/validate/test/validateSpec.js @@ -1,4 +1,4 @@ -describe('uiValidate', function ($compile) { +describe('uiValidate', function () { 'use strict'; var scope, compileAndDigest; From 36cfbe28bfab37239617e66a8c5132813b35737a Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Thu, 26 Dec 2013 17:40:59 +0100 Subject: [PATCH 24/28] style(jshint): add $ as a global --- modules/scroll/test/jqliteExtrasSpec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/scroll/test/jqliteExtrasSpec.js b/modules/scroll/test/jqliteExtrasSpec.js index fe6f1089..3d42674f 100644 --- a/modules/scroll/test/jqliteExtrasSpec.js +++ b/modules/scroll/test/jqliteExtrasSpec.js @@ -1,3 +1,4 @@ +/* global $: false*/ describe('\njqLite: testing against jQuery\n', function () { 'use strict'; From 33579c837c1aa781fb9fd1df15637414a1cc2684 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Fri, 27 Dec 2013 10:01:40 +0100 Subject: [PATCH 25/28] chore(grunt): separate the distribution tasks The sub components don't have to be recreated every time. --- gruntFile.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/gruntFile.js b/gruntFile.js index df5418e2..bbd885a6 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -7,8 +7,12 @@ module.exports = function (grunt) { // Default task. grunt.registerTask('default', ['jshint', 'karma:unit']); - grunt.registerTask('serve', [ 'karma:continuous', 'dist', 'build:gh-pages', 'connect:continuous', 'watch']); - grunt.registerTask('dist', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'ngmin', 'uglify', 'concat:html_doc', 'copy']); + grunt.registerTask('serve', [ 'karma:continuous', 'dist:main', 'dist:demo', 'build:gh-pages', 'connect:continuous', 'watch']); + + grunt.registerTask('dist', ['dist:main', 'dist:sub', 'dist:demo']); + grunt.registerTask('dist:main', ['concat:tmp', 'concat:modules', 'clean:rm_tmp', 'uglify:main']); + grunt.registerTask('dist:sub', ['ngmin', 'uglify:sub']); + grunt.registerTask('dist:demo', ['concat:html_doc', 'copy']); // HACK TO ACCESS TO THE COMPONENT-PUBLISHER @@ -75,7 +79,7 @@ module.exports = function (grunt) { src: { files: ['modules/**/*.js', '!modules/**/test/*Spec.js', 'demo/**/*.js'], - tasks: ['jshint:src', 'karma:unit:run', 'dist', 'build:gh-pages'] + tasks: ['jshint:src', 'karma:unit:run', 'dist:main', 'dist:demo', 'build:gh-pages'] }, test: { files: ['modules/**/test/*Spec.js'], @@ -83,7 +87,7 @@ module.exports = function (grunt) { }, demo: { files: ['modules/**/demo/*'], - tasks: ['jshint:src', 'concat:html_doc', 'copy', 'build:gh-pages'] + tasks: ['jshint:src', 'dist:demo', 'build:gh-pages'] }, livereload: { files: ['out/built/gh-pages/**/*'], From 56775b1f953447f1ac51e091ea980bda2bfde2a2 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Fri, 27 Dec 2013 10:46:22 +0100 Subject: [PATCH 26/28] chore(README): Update the README --- README.md | 85 +++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/README.md b/README.md index e258f9a9..901c6d70 100644 --- a/README.md +++ b/README.md @@ -1,56 +1,87 @@ -# AngularUI - The companion suite for AngularJS +# UI.Utils [![Build Status](https://travis-ci.org/angular-ui/ui-utils.png?branch=master)](https://travis-ci.org/angular-ui/ui-utils) -*** +The companion suite for AngularJS -[![Build Status](https://travis-ci.org/angular-ui/ui-utils.png?branch=master)](https://travis-ci.org/angular-ui/ui-utils) +## Requirements + +- AngularJS ## Usage -### Requirements -* **AngularJS v1.0.0+** is currently required. -* **jQuery*** Until the refactor is complete, some directives still require jQuery +You can get it from [Bower](http://bower.io/) + +```sh +# All the modules +bower install angular-ui-utils\#bower + +# A specific module +# bower install angular-ui-utils\#bower- +bower install angular-ui-utils\#bower-event +bower install angular-ui-utils\#bower-keypress +... + +# A specific version +bower install angular-ui-utils\#v0.0.4 +# A specific module version +bower install angular-ui-utils\#event-0.0.4 +bower install angular-ui-utils\#keypress-0.0.4 +... + +# If you want the sources with it +bower install angular-ui-utils +# or for a specific source version +bower install angular-ui-utils\#src0.0.4 +``` + +This will copy the UI.Utils files into a `bower_components` folder, along with its dependencies. Load the script files in your application: + +```html + + + -## Installation + + + + +``` Add the specific modules to your dependencies, or add the entire lib by depending on `ui.utils` ```javascript angular.module('myApp', ['ui.keypress', 'ui.event', ...]) // or if ALL modules are loaded along with modules/utils.js -angular.module('myApp', ['ui.utils']) +var myAppModule = angular.module('MyApp', ['ui.utils']); ``` Each directive and filter is now it's own module and will have a relevant README.md in their respective folders ## Development -At this time, we do not have a build script. You must include all `.js` files you wish to work on. -We will likely be adding a `Gruntfile.js` in the near future for this +We use Karma and jshint to ensure the quality of the code. The easiest way to run these checks is to use grunt: -### Requirements +```sh +npm install -g grunt-cli +npm install && bower install +grunt +``` -0. Install [Node.js](http://nodejs.org/) and NPM (should come with) +The karma task will try to open Firefox and Chrome as browser in which to run the tests. Make sure this is available or change the configuration in `test\karma.conf.js` -1. Install global dependencies `grunt-cli`, `bower`, and `karma`: - ```bash - $ npm install -g karma grunt-cli bower - ``` +### Grunt Serve -2. Install local dependencies: +We have one task to serve them all ! - ```bash - $ npm install - $ bower install - ``` +```sh +grunt serve +``` -### Running Tests +It's equal to run separately: -Make sure all tests pass in order for your Pull Request to be accepted +* `grunt connect:server` : giving you a development server at [http://127.0.0.1:8000/](http://127.0.0.1:8000/). -You can choose what browsers to test in: `Chrome,ChromeCanary,Firefox,PhantomJS` +* `grunt karma:server` : giving you a Karma server to run tests (at [http://localhost:9876/](http://localhost:9876/) by default). You can force a test on this server with `grunt karma:unit:run`. -```bash -$ karma start --browsers=Chrome,Firefox test/karma.conf.js --single-run=true -``` +* `grunt watch` : will automatically test your code and build your demo. You can demo generation with `grunt build:gh-pages`. From 28d9122a1767a3cd3e591359a1caa90f5450b0a8 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Fri, 27 Dec 2013 14:04:12 +0100 Subject: [PATCH 27/28] chore(publisher): use the official one --- .travis.yml | 2 +- gruntFile.js | 2 +- package.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5894501..83cbbf84 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,7 @@ before_install: - bower install --force - bower install --force after_success: -- "./node_modules/component-publisher/travis/authentication.sh --branch=develop || exit 1" +- "./node_modules/angular-ui-publisher/travis/authentication.sh || exit 0" - "grunt dist build:gh-pages publish:gh-pages build:bower publish:bower build:subbower publish:subbower" script: grunt env: diff --git a/gruntFile.js b/gruntFile.js index bbd885a6..78f41086 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -24,7 +24,7 @@ module.exports = function (grunt) { var done = this.async(); var spawn = require('child_process').spawn; spawn('./node_modules/.bin/gulp', [ prefix, '--branch='+this.args[0] ].concat(grunt.option.flags()), { - cwd : './node_modules/component-publisher', + cwd : './node_modules/angular-ui-publisher', stdio: 'inherit' }).on('close', done); }; diff --git a/package.json b/package.json index a3dd7091..867a2e95 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "homepage": "http://angular-ui.github.com", "dependencies": {}, "devDependencies": { - "component-publisher": "git://github.com/douglasduteil/component-publisher", + "angular-ui-publisher": "~1.x", "grunt": "~0.4.1", "grunt-contrib-clean": "~0.4.1", "grunt-contrib-concat": "~0.3.0", From 2c6fcab1693a52429c60ef4a22c2570a8c7d47e0 Mon Sep 17 00:00:00 2001 From: Douglas Duteil Date: Sun, 29 Dec 2013 03:15:13 +0100 Subject: [PATCH 28/28] chore(travis): be quiet npm --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 83cbbf84..8a22e711 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ node_js: before_install: - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start -- npm install -g bower grunt-cli -- npm install +- npm install -qg bower grunt-cli +- npm install -q - bower install --force - bower install --force after_success: