Browse Source

Merge pull request #436 from twbs/jscs

Add JSCS support
pull/437/head
XhmikosR 11 years ago
parent
commit
e9bad869d3
  1. 19
      Gruntfile.js
  2. 5
      dist/js/ratchet.js
  3. 2
      docs/assets/css/docs.min.css
  4. 6
      docs/assets/js/docs.js
  5. 5
      docs/dist/js/ratchet.js
  6. 26
      js/.jscsrc
  7. 7
      js/.jshintrc
  8. 2
      js/segmented-controllers.js
  9. 4
      js/toggles.js
  10. 1
      package.json

19
Gruntfile.js

@ -39,7 +39,7 @@ module.exports = function(grunt) {
clean: {
dist: ['dist', 'docs/dist']
},
concat: {
ratchet: {
options: {
@ -186,6 +186,21 @@ module.exports = function(grunt) {
}
},
jscs: {
options: {
config: 'js/.jscsrc'
},
grunt: {
src: '<%= jshint.grunt.src %>'
},
src: {
src: '<%= jshint.src.src %>'
},
docs: {
src: '<%= jshint.docs.src %>'
}
},
csslint: {
options: {
csslintrc: 'sass/.csslintrc'
@ -243,7 +258,7 @@ module.exports = function(grunt) {
grunt.registerTask('validate-html', ['jekyll', 'validation']);
grunt.registerTask('build', ['dist']);
grunt.registerTask('default', ['dist']);
grunt.registerTask('test', ['dist', 'jshint', 'validate-html']);
grunt.registerTask('test', ['dist', 'jshint', 'jscs', 'validate-html']);
// Version numbering task.
// grunt change-version-number --oldver=A.B.C --newver=X.Y.Z

5
dist/js/ratchet.js vendored

@ -670,6 +670,7 @@
window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} });
}());
/* ----------------------------------
* SLIDER v2.0.1
* Licensed under The MIT License
@ -879,7 +880,7 @@
handle.style.webkitTransform = 'translate3d(' + distanceX + 'px,0,0)';
toggle.classList[(distanceX > (toggleWidth/2 - handleWidth/2)) ? 'add' : 'remove']('active');
toggle.classList[(distanceX > (toggleWidth / 2 - handleWidth / 2)) ? 'add' : 'remove']('active');
});
window.addEventListener('touchend', function (e) {
@ -891,7 +892,7 @@
var toggleWidth = toggle.clientWidth;
var handleWidth = handle.clientWidth;
var offset = (toggleWidth - handleWidth);
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth/2 - handleWidth/2)));
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth / 2 - handleWidth / 2)));
if (slideOn) {
handle.style.webkitTransform = 'translate3d(' + offset + 'px,0,0)';

2
docs/assets/css/docs.min.css vendored

File diff suppressed because one or more lines are too long

6
docs/assets/js/docs.js

@ -51,7 +51,7 @@ $(function() {
if (windowWidth >= 768) {
device.initialLeft = device.offset().left;
device.initialTop = device.initialTop || device.offset().top;
device.dockingOffset = ($(window).height() - device.height())/2;
device.dockingOffset = ($(window).height() - device.height()) / 2;
}
checkDesktopContent();
@ -134,7 +134,7 @@ $(function() {
var contentSectionItem;
var currentTop = win.scrollTop();
if((device.initialTop - currentTop) <= device.dockingOffset) {
if ((device.initialTop - currentTop) <= device.dockingOffset) {
device[0].className = 'device device-fixed';
device.css({top: device.dockingOffset});
} else {
@ -175,7 +175,7 @@ $(function() {
var currentTop = win.scrollTop();
var headerHeight = $('.docs-sub-header').outerHeight();
if(currentTop >= headerHeight) {
if (currentTop >= headerHeight) {
toolbarToggle.addClass('visible');
} else if (currentTop <= headerHeight) {
toolbarToggle.removeClass('visible');

5
docs/dist/js/ratchet.js vendored

@ -670,6 +670,7 @@
window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} });
}());
/* ----------------------------------
* SLIDER v2.0.1
* Licensed under The MIT License
@ -879,7 +880,7 @@
handle.style.webkitTransform = 'translate3d(' + distanceX + 'px,0,0)';
toggle.classList[(distanceX > (toggleWidth/2 - handleWidth/2)) ? 'add' : 'remove']('active');
toggle.classList[(distanceX > (toggleWidth / 2 - handleWidth / 2)) ? 'add' : 'remove']('active');
});
window.addEventListener('touchend', function (e) {
@ -891,7 +892,7 @@
var toggleWidth = toggle.clientWidth;
var handleWidth = handle.clientWidth;
var offset = (toggleWidth - handleWidth);
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth/2 - handleWidth/2)));
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth / 2 - handleWidth / 2)));
if (slideOn) {
handle.style.webkitTransform = 'translate3d(' + offset + 'px,0,0)';

26
js/.jscsrc

@ -0,0 +1,26 @@
{
"disallowEmptyBlocks": true,
"disallowKeywords": ["with"],
"disallowLeftStickedOperators": ["?", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"disallowMixedSpacesAndTabs": true,
"disallowMultipleLineStrings": true,
"disallowRightStickedOperators": ["?", "/", "*", ":", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="],
"disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"],
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--"],
"disallowTrailingWhitespace": true,
"requireCamelCaseOrUpperCaseIdentifiers": true,
"requireCapitalizedConstructors": true,
"requireCommaBeforeLineBreak": true,
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch", "case", "default"],
"requireLeftStickedOperators": [","],
"requireLineFeedAtFileEnd": true,
"requireParenthesesAroundIIFE": true,
"requireRightStickedOperators": ["!"],
"requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="],
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"],
"requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="],
"requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true },
"validateIndentation": 2,
"validateLineBreaks": "LF",
"validateQuoteMarks": "'"
}

7
js/.jshintrc

@ -1,22 +1,15 @@
{
"bitwise" : true,
"browser" : true,
"camelcase" : true,
"curly" : true,
"devel" : true,
"eqeqeq" : true,
"eqnull" : true,
"expr" : true,
"forin" : true,
"freeze" : true,
"immed" : true,
"indent" : 2,
"latedef" : true,
"newcap" : true,
"nonbsp" : true,
"quotmark" : "single",
"strict" : true,
"trailing" : true,
"undef" : true,
"unused" : true
}

2
js/segmented-controllers.js

@ -58,4 +58,4 @@
});
window.addEventListener('click', function (e) { if (getTarget(e.target)) {e.preventDefault();} });
}());
}());

4
js/toggles.js

@ -76,7 +76,7 @@
handle.style.webkitTransform = 'translate3d(' + distanceX + 'px,0,0)';
toggle.classList[(distanceX > (toggleWidth/2 - handleWidth/2)) ? 'add' : 'remove']('active');
toggle.classList[(distanceX > (toggleWidth / 2 - handleWidth / 2)) ? 'add' : 'remove']('active');
});
window.addEventListener('touchend', function (e) {
@ -88,7 +88,7 @@
var toggleWidth = toggle.clientWidth;
var handleWidth = handle.clientWidth;
var offset = (toggleWidth - handleWidth);
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth/2 - handleWidth/2)));
var slideOn = (!touchMove && !toggle.classList.contains('active')) || (touchMove && (distanceX > (toggleWidth / 2 - handleWidth / 2)));
if (slideOn) {
handle.style.webkitTransform = 'translate3d(' + offset + 'px,0,0)';

1
package.json

@ -39,6 +39,7 @@
"grunt-csscomb": "~2.0.1",
"grunt-html-validation": "~0.1.13",
"grunt-jekyll": "~0.4.1",
"grunt-jscs-checker": "~0.4.0",
"grunt-sed": "~0.1.1",
"load-grunt-tasks": "~0.4.0"
}

Loading…
Cancel
Save