From 6d16184e074499cac9e72e1eba130aed3ddcae53 Mon Sep 17 00:00:00 2001 From: vsn4ik Date: Sun, 20 Sep 2015 20:58:51 +0300 Subject: [PATCH] Add jscs --- .gitattributes | 13 +++++---- Gruntfile.js | 13 ++++++++- bower.json | 4 +-- dist/css/bootstrap-submenu.css | 2 +- dist/css/bootstrap-submenu.min.css | 2 +- dist/js/bootstrap-submenu.js | 6 ++--- dist/js/bootstrap-submenu.min.js | 4 +-- docs/assets/js/docs.js | 2 ++ js/.jscsrc | 42 ++++++++++++++++++++++++++++++ js/bootstrap-submenu.js | 4 +-- package.json | 9 +++---- 11 files changed, 76 insertions(+), 25 deletions(-) create mode 100644 js/.jscsrc diff --git a/.gitattributes b/.gitattributes index bc70b57..5a6a4bd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,8 +1,7 @@ # Export-ignore files for composer (with --prefer-dist) -.gitattributes export-ignore -.gitignore export-ignore -.travis.yml export-ignore -Gruntfile.js export-ignore -README.md export-ignore -bower.json export-ignore -package.json export-ignore +# Dont add bower.json, otherwise it is not loaded in the Bower package +docs export-ignore +.* export-ignore +Gruntfile.js export-ignore +README.md export-ignore +package.json export-ignore diff --git a/Gruntfile.js b/Gruntfile.js index 5db7fb2..b42332a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -114,6 +114,16 @@ module.exports = function(grunt) { src: 'docs/assets/js/' } }, + jscs: { + options: { + config: 'js/.jscsrc' + }, + core: 'js/', + grunt: 'Gruntfile.js', + docs: { + src: 'docs/assets/js/' + } + }, uglify: { core: { expand: true, @@ -143,7 +153,7 @@ module.exports = function(grunt) { cwd: 'docs', src: 'index.html', dest: '_gh_pages/' - }, + } }, compress: { dist: { @@ -168,6 +178,7 @@ module.exports = function(grunt) { 'less', 'cssmin', 'jshint', + 'jscs', 'copy:core', 'uglify', 'usebanner' diff --git a/bower.json b/bower.json index 9bbdd01..41643a3 100644 --- a/bower.json +++ b/bower.json @@ -25,9 +25,7 @@ ], "ignore": [ "docs", - ".gitattributes", - ".gitignore", - ".travis.yml", + "/.*", "Gruntfile.js", "README.md", "_config.yml", diff --git a/dist/css/bootstrap-submenu.css b/dist/css/bootstrap-submenu.css index 21db0e1..6265a5b 100644 --- a/dist/css/bootstrap-submenu.css +++ b/dist/css/bootstrap-submenu.css @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v2.0.0 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v2.0.1 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2015 Vasily A. (https://github.com/vsn4ik) * Licensed under the MIT license */ diff --git a/dist/css/bootstrap-submenu.min.css b/dist/css/bootstrap-submenu.min.css index 4d683bb..c6eab90 100644 --- a/dist/css/bootstrap-submenu.min.css +++ b/dist/css/bootstrap-submenu.min.css @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v2.0.0 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v2.0.1 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2015 Vasily A. (https://github.com/vsn4ik) * Licensed under the MIT license */ diff --git a/dist/js/bootstrap-submenu.js b/dist/js/bootstrap-submenu.js index d0c226f..27460cf 100644 --- a/dist/js/bootstrap-submenu.js +++ b/dist/js/bootstrap-submenu.js @@ -1,5 +1,5 @@ /*! - * Bootstrap-submenu v2.0.0 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v2.0.1 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2015 Vasily A. (https://github.com/vsn4ik) * Licensed under the MIT license */ @@ -122,7 +122,7 @@ Submenupicker.prototype = { init: function() { this.$menu.off('keydown.bs.dropdown.data-api'); - this.$menu.on('keydown', $.proxy(this, 'item_keydown')); + this.$menu.on('keydown', $.proxy(this, 'itemKeydown')); this.$menu.find('li > a').each(function() { new Item(this); @@ -137,7 +137,7 @@ hidden: function() { this.$items.trigger('hide.bs.submenu'); }, - item_keydown: function(event) { + itemKeydown: function(event) { // 38: Arrow up, 40: Arrow down if ($.inArray(event.keyCode, [38, 40]) != -1) { diff --git a/dist/js/bootstrap-submenu.min.js b/dist/js/bootstrap-submenu.min.js index cad10a3..f5ec5c1 100644 --- a/dist/js/bootstrap-submenu.min.js +++ b/dist/js/bootstrap-submenu.min.js @@ -1,7 +1,7 @@ /*! - * Bootstrap-submenu v2.0.0 (http://vsn4ik.github.io/bootstrap-submenu) + * Bootstrap-submenu v2.0.1 (http://vsn4ik.github.io/bootstrap-submenu) * Copyright 2015 Vasily A. (https://github.com/vsn4ik) * Licensed under the MIT license */ -"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function b(b){this.$element=a(b),this.$menu=this.$element.closest(".dropdown-menu"),this.$main=this.$menu.parent(),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}function c(b){this.$element=a(b),this.$main=this.$element.parent(),this.$menu=this.$main.children(".dropdown-menu"),this.$subs=this.$main.siblings(".dropdown-submenu"),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}function d(b){this.$element=a(b),this.$main=this.$element.parent(),this.$menu=this.$main.children(".dropdown-menu"),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}return b.prototype={init:function(){this.$element.on("keydown",a.proxy(this,"keydown"))},close:function(){this.$main.removeClass("open"),this.$items.trigger("hide.bs.submenu")},keydown:function(a){27==a.keyCode&&(a.stopPropagation(),this.close(),this.$main.children("a, button").trigger("focus"))}},a.extend(c.prototype,b.prototype,{init:function(){this.$element.on({click:a.proxy(this,"click"),keydown:a.proxy(this,"keydown")}),this.$main.on("hide.bs.submenu",a.proxy(this,"hide"))},click:function(a){a.stopPropagation(),this.toggle()},hide:function(a){a.stopPropagation(),this.close()},open:function(){this.$main.addClass("open"),this.$subs.trigger("hide.bs.submenu")},toggle:function(){this.$main.hasClass("open")?this.close():this.open()},keydown:function(b){32==b.keyCode&&b.preventDefault(),-1!=a.inArray(b.keyCode,[13,32])&&this.toggle()}}),d.prototype={init:function(){this.$menu.off("keydown.bs.dropdown.data-api"),this.$menu.on("keydown",a.proxy(this,"item_keydown")),this.$menu.find("li > a").each(function(){new b(this)}),this.$menu.find(".dropdown-submenu > a").each(function(){new c(this)}),this.$main.on("hidden.bs.dropdown",a.proxy(this,"hidden"))},hidden:function(){this.$items.trigger("hide.bs.submenu")},item_keydown:function(b){if(-1!=a.inArray(b.keyCode,[38,40])){b.preventDefault(),b.stopPropagation();var c=this.$menu.find("li:not(.disabled):visible > a"),d=c.index(b.target);if(38==b.keyCode&&0!==d)d--;else{if(40!=b.keyCode||d===c.length-1)return;d++}c.eq(d).trigger("focus")}}},a.fn.submenupicker=function(b){var c=this instanceof a?this:a(b);return c.each(function(){var b=a.data(this,"bs.submenu");b||(b=new d(this),a.data(this,"bs.submenu",b))})}}); \ No newline at end of file +"use strict";!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){function b(b){this.$element=a(b),this.$menu=this.$element.closest(".dropdown-menu"),this.$main=this.$menu.parent(),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}function c(b){this.$element=a(b),this.$main=this.$element.parent(),this.$menu=this.$main.children(".dropdown-menu"),this.$subs=this.$main.siblings(".dropdown-submenu"),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}function d(b){this.$element=a(b),this.$main=this.$element.parent(),this.$menu=this.$main.children(".dropdown-menu"),this.$items=this.$menu.children(".dropdown-submenu"),this.init()}return b.prototype={init:function(){this.$element.on("keydown",a.proxy(this,"keydown"))},close:function(){this.$main.removeClass("open"),this.$items.trigger("hide.bs.submenu")},keydown:function(a){27==a.keyCode&&(a.stopPropagation(),this.close(),this.$main.children("a, button").trigger("focus"))}},a.extend(c.prototype,b.prototype,{init:function(){this.$element.on({click:a.proxy(this,"click"),keydown:a.proxy(this,"keydown")}),this.$main.on("hide.bs.submenu",a.proxy(this,"hide"))},click:function(a){a.stopPropagation(),this.toggle()},hide:function(a){a.stopPropagation(),this.close()},open:function(){this.$main.addClass("open"),this.$subs.trigger("hide.bs.submenu")},toggle:function(){this.$main.hasClass("open")?this.close():this.open()},keydown:function(b){32==b.keyCode&&b.preventDefault(),-1!=a.inArray(b.keyCode,[13,32])&&this.toggle()}}),d.prototype={init:function(){this.$menu.off("keydown.bs.dropdown.data-api"),this.$menu.on("keydown",a.proxy(this,"itemKeydown")),this.$menu.find("li > a").each(function(){new b(this)}),this.$menu.find(".dropdown-submenu > a").each(function(){new c(this)}),this.$main.on("hidden.bs.dropdown",a.proxy(this,"hidden"))},hidden:function(){this.$items.trigger("hide.bs.submenu")},itemKeydown:function(b){if(-1!=a.inArray(b.keyCode,[38,40])){b.preventDefault(),b.stopPropagation();var c=this.$menu.find("li:not(.disabled):visible > a"),d=c.index(b.target);if(38==b.keyCode&&0!==d)d--;else{if(40!=b.keyCode||d===c.length-1)return;d++}c.eq(d).trigger("focus")}}},a.fn.submenupicker=function(b){var c=this instanceof a?this:a(b);return c.each(function(){var b=a.data(this,"bs.submenu");b||(b=new d(this),a.data(this,"bs.submenu",b))})}}); \ No newline at end of file diff --git a/docs/assets/js/docs.js b/docs/assets/js/docs.js index 6bed26e..4445491 100644 --- a/docs/assets/js/docs.js +++ b/docs/assets/js/docs.js @@ -1,3 +1,5 @@ +// jscs:disable requireCamelCaseOrUpperCaseIdentifiers + 'use strict'; $(function() { diff --git a/js/.jscsrc b/js/.jscsrc new file mode 100644 index 0000000..be687a0 --- /dev/null +++ b/js/.jscsrc @@ -0,0 +1,42 @@ +{ + "esnext": true, + "disallowEmptyBlocks": true, + "disallowKeywords": ["with"], + "disallowMixedSpacesAndTabs": true, + "disallowMultipleLineStrings": true, + "disallowMultipleVarDecl": true, + "disallowQuotedKeysInObjects": "allButReserved", + "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], + "disallowSpaceBeforeBinaryOperators": [","], + "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], + "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, + "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, + "disallowSpacesInsideArrayBrackets": true, + "disallowSpacesInsideParentheses": true, + "disallowTrailingComma": true, + "disallowTrailingWhitespace": true, + "requireCamelCaseOrUpperCaseIdentifiers": true, + "requireCapitalizedConstructors": true, + "requireCommaBeforeLineBreak": true, + "requireDollarBeforejQueryAssignment": true, + "requireDotNotation": true, + "requireLineFeedAtFileEnd": true, + "requirePaddingNewLinesAfterUseStrict": true, + "requirePaddingNewLinesBeforeExport": true, + "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], + "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], + "requireSpaceAfterLineComment": true, + "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], + "requireSpaceBetweenArguments": true, + "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "requireSpacesInConditionalExpression": true, + "requireSpacesInForStatement": true, + "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, + "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, + "requireSpacesInsideObjectBrackets": "allButNested", + "validateAlignedFunctionParameters": true, + "validateIndentation": 2, + "validateLineBreaks": "LF", + "validateQuoteMarks": "'" +} diff --git a/js/bootstrap-submenu.js b/js/bootstrap-submenu.js index 4b0deba..6e6770d 100644 --- a/js/bootstrap-submenu.js +++ b/js/bootstrap-submenu.js @@ -116,7 +116,7 @@ Submenupicker.prototype = { init: function() { this.$menu.off('keydown.bs.dropdown.data-api'); - this.$menu.on('keydown', $.proxy(this, 'item_keydown')); + this.$menu.on('keydown', $.proxy(this, 'itemKeydown')); this.$menu.find('li > a').each(function() { new Item(this); @@ -131,7 +131,7 @@ hidden: function() { this.$items.trigger('hide.bs.submenu'); }, - item_keydown: function(event) { + itemKeydown: function(event) { // 38: Arrow up, 40: Arrow down if ($.inArray(event.keyCode, [38, 40]) != -1) { diff --git a/package.json b/package.json index c4359de..d972dac 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bootstrap-submenu", - "version": "2.0.0", + "version": "2.0.1", "description": "Bootstrap Sub-Menus", "keywords": [ "bootstrap", @@ -17,7 +17,7 @@ "license": "MIT", "files": [ "dist", - "js", + "js/**/*.js", "less", "LICENSE" ], @@ -37,6 +37,7 @@ "grunt-contrib-less": "~1.0.1", "grunt-contrib-uglify": "~0.9.2", "grunt-ejs": "~0.3.0", + "grunt-jscs": "~1.8.0", "highlight.js": "~8.8.0", "jquery": "~2.1.4", "load-grunt-tasks": "~3.2.0", @@ -49,9 +50,7 @@ "main": "dist/js/bootstrap-submenu.js", "ignore": [ "docs", - ".gitattributes", - ".gitignore", - ".travis.yml", + ".*", "Gruntfile.js", "README.md", "_config.yml",