From 48376db0efc83598a5162c4a07cdc993921919d7 Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Sun, 4 May 2014 08:16:31 +0200 Subject: [PATCH 01/33] Update workflow/conventions/tools --- .gitignore | 1 + .jscs.json | 249 ++++++++++++++++++++++++++--------------------- .jshintrc | 4 +- Gulpfile.js | 35 +++++++ README.md | 40 ++++---- package.json | 2 +- tests/todo,sorry | 0 7 files changed, 199 insertions(+), 132 deletions(-) create mode 100644 Gulpfile.js delete mode 100644 tests/todo,sorry diff --git a/.gitignore b/.gitignore index c2658d7..646ac51 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.DS_Store node_modules/ diff --git a/.jscs.json b/.jscs.json index a03292c..e4169a9 100644 --- a/.jscs.json +++ b/.jscs.json @@ -1,112 +1,143 @@ { - "excludeFiles": [ - ] - , "requireCurlyBraces": [ - "if" - , "else" - , "for" - , "while" - , "do" - , "try" - , "catch" - ] - , "requireSpaceAfterKeywords": [ - "if" - , "else" - , "for" - , "while" - , "do" - , "switch" - , "return" - , "try" - , "catch" - ] - , "requireSpacesInFunctionExpression": { - "beforeOpeningCurlyBrace": true - } - , "disallowSpacesInFunctionExpression": { - "beforeOpeningRoundBrace": true - } - , "disallowEmptyBlocks": true - , "disallowSpacesInsideObjectBrackets": true - , "disallowSpacesInsideArrayBrackets": true - , "disallowSpacesInsideParentheses": true - , "disallowSpaceAfterObjectKeys": true - , "disallowCommaBeforeLineBreak": true - , "requireOperatorBeforeLineBreak": [ - "?" - , "+" - , "-" - , "/" - , "*" - , "=" - , "==" - , "===" - , "!=" - , "!==" - , ">" - , ">=" - , "<" - , "<=" - ] - , "disallowSpaceAfterPrefixUnaryOperators": [ - "++" - , "--" - , "+" - , "-" - , "~" - , "!" - ] - , "disallowSpaceBeforePostfixUnaryOperators": [ - "++" - , "--" - ] - , "requireSpaceBeforeBinaryOperators": [ - "+" - , "-" - , "/" - , "*" - , "=" - , "==" - , "===" - , "!=" - , "!==" - ] - , "requireSpaceAfterBinaryOperators": [ - "+" - , "-" - , "/" - , "*" - , "=" - , "==" - , "===" - , "!=" - , "!==" - ] - , "disallowImplicitTypeConversion": [ - "numeric" - , "boolean" - , "binary" - , "string" - ] - , "disallowKeywords": [ - "with" - ] - , "disallowMultipleLineStrings": true - - , "validateQuoteMarks": "\"" - , "disallowMixedSpacesAndTabs": true - , "disallowTrailingWhitespace": true - - , "requireKeywordsOnNewLine": [ - ] - , "requireLineFeedAtFileEnd": true - , "requireCapitalizedConstructors": true - , "safeContextKeyword": "that" - - , "validateJSDoc": { - "checkParamNames": true - , "checkRedundantParams": true - , "requireParamTypes": true + "excludeFiles": [], + "requireCurlyBraces": [ + "if", + "else", + "for", + "while", + "do", + "try", + "catch" + ], + "requireSpaceAfterKeywords": [ + "if", + "else", + "for", + "while", + "do", + "switch", + "return", + "try", + "catch" + ], + "requireSpacesInFunctionExpression": { + "beforeOpeningCurlyBrace": true + }, + "disallowSpacesInFunctionExpression": { + "beforeOpeningRoundBrace": true + }, + "disallowEmptyBlocks": true, + "disallowSpacesInsideParentheses": true, + "disallowSpacesInsideObjectBrackets": true, + "disallowSpacesInsideArrayBrackets": true, + "disallowQuotedKeysInObjects": "allButReserved", + "disallowSpaceAfterObjectKeys": true, + "requireCommaBeforeLineBreak": true, + "requireOperatorBeforeLineBreak": [ + "?", + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==", + ">", + ">=", + "<", + "<=" + ], + "disallowLeftStickedOperators": [ + "?", + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==", + ">", + ">=", + "<", + "<=" + ], + "requireRightStickedOperators": [ + "!" + ], + "disallowRightStickedOperators": [ + "?", + "+", + "/", + "*", + ":", + "=", + "==", + "===", + "!=", + "!==", + ">", + ">=", + "<", + "<=" + ], + "disallowSpaceAfterPrefixUnaryOperators": [ + "++", + "--", + "+", + "-", + "~", + "!" + ], + "disallowSpaceBeforePostfixUnaryOperators": [ + "++", + "--" + ], + "requireSpaceBeforeBinaryOperators": [ + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==" + ], + "requireSpaceAfterBinaryOperators": [ + "+", + "-", + "/", + "*", + "=", + "==", + "===", + "!=", + "!==" + ], + "disallowImplicitTypeConversion": [ + "numeric", + "boolean", + "binary", + "string" + ], + "disallowKeywords": [ + "with" + ], + "disallowMultipleLineStrings": true, + "validateQuoteMarks": "\"", + "disallowMixedSpacesAndTabs": true, + "disallowTrailingWhitespace": true, + "requireKeywordsOnNewLine": [], + "requireLineFeedAtFileEnd": true, + "requireCapitalizedConstructors": true, + "safeContextKeyword": "that", + "validateJSDoc": { + "checkParamNames": true, + "checkRedundantParams": true, + "requireParamTypes": true } } diff --git a/.jshintrc b/.jshintrc index 7568631..182e34d 100644 --- a/.jshintrc +++ b/.jshintrc @@ -1,4 +1,4 @@ { - "asi": true - , "laxcomma": true + "asi": true, + "laxcomma": true } diff --git a/Gulpfile.js b/Gulpfile.js new file mode 100644 index 0000000..2c52c96 --- /dev/null +++ b/Gulpfile.js @@ -0,0 +1,35 @@ +var gulp = require("gulp") +var server = require("./tasks/server") + +gulp.task("clean", require("./tasks/clean")) + +// html +// @todo + +// static assets + +// generated assets +gulp.task("scripts:linting", require("./tasks/scripts-linting")) +gulp.task("scripts", ["scripts:linting"], require("./tasks/scripts")) +// gulp.task("stylesheets", require("./tasks/stylesheets")) + +// build +// gulp.task("dist", ["clean", "static", "scripts", "stylesheets"]) +gulp.task("dist", ["clean", "scripts"]) + +// publish +gulp.task("publish", ["dist"], require("./tasks/publish")) + +// dev tasks +// gulp.task("server", ["dist"], server.start) +// gulp.task("default", ["dist", "server", "watch" ]) +gulp.task("default", ["dist", "watch" ]) +gulp.task("test", ["dist"]) + +gulp.task("watch", ["dist"], function() { + gulp.watch("./styles/**/*.css", ["stylesheets"]) + gulp.watch("./scripts/**/*.js", ["scripts"]) + gulp.watch("./tasks/**/*.js", ["scripts:linting"]) + + // gulp.watch("./dist/**/*").on("change", server.livereload) +}) diff --git a/README.md b/README.md index e9f4ba0..02ef9ca 100644 --- a/README.md +++ b/README.md @@ -135,8 +135,8 @@ Let's talk more about the most basic way to get started: ```js new Pjax({ - elements: "a" // default is "a[href], form[action]" -, selectors: ["title", ".my-Header", ".my-Content", ".my-Sidebar"] + elements: "a", // default is "a[href], form[action]" + selectors: ["title", ".my-Header", ".my-Content", ".my-Sidebar"] }) ``` @@ -203,8 +203,8 @@ Examples: ```js new Pjax({ - selectors: ["title", ".Navbar", ".js-Pjax"] -, switches: { + selectors: ["title", ".Navbar", ".js-Pjax"], + switches: { // "title": Pjax.switches.outerHTML // default behavior ".Navbar": function(oldEl, newEl, options) { // here it's a stupid example since it's the default behavior too @@ -249,23 +249,23 @@ with or without [WOW.js](https://github.com/matthieua/WOW). ```js new Pjax({ - selectors: ["title", ".js-Pjax"] -, switches: { + selectors: ["title", ".js-Pjax"], + switches: { ".js-Pjax": Pjax.switches.sideBySide - } -, switchesOptions: { + }, + switchesOptions: { ".js-Pjax": { classNames: { // class added on the element that will be removed - remove: "Animated Animated--reverse Animate--fast Animate--noDelay" + remove: "Animated Animated--reverse Animate--fast Animate--noDelay", // class added on the element that will be added - , add: "Animated" + add: "Animated", // class added on the element when it go backward - , backward: "Animate--slideInRight" + backward: "Animate--slideInRight", // class added on the element when it go forward (used for new page too) - , forward: "Animate--slideInLeft" - } - , callbacks: { + forward: "Animate--slideInLeft" + }, + callbacks: { // to make a nice transition with 2 pages as the same time // we are playing with absolute positioning for element we are removing // & we need live metrics to have something great @@ -495,9 +495,9 @@ wrapper on each page (to avoid differences of DOM between pages) ```html diff --git a/tests/scripts/lib/clone.js b/tests/lib/clone.js similarity index 87% rename from tests/scripts/lib/clone.js rename to tests/lib/clone.js index d991e24..9997943 100644 --- a/tests/scripts/lib/clone.js +++ b/tests/lib/clone.js @@ -1,6 +1,6 @@ var tape = require("tape") -var clone = require("../../../src/scripts/lib/clone") +var clone = require("../../lib/clone") tape("test clone method", function(t) { var obj = {one: 1, two: 2} diff --git a/tests/scripts/lib/eval-scripts.js b/tests/lib/eval-scripts.js similarity index 90% rename from tests/scripts/lib/eval-scripts.js rename to tests/lib/eval-scripts.js index 2d53544..43113b9 100644 --- a/tests/scripts/lib/eval-scripts.js +++ b/tests/lib/eval-scripts.js @@ -1,6 +1,6 @@ var tape = require("tape") -var evalScript = require("../../../src/scripts/lib/eval-script") +var evalScript = require("../../lib/eval-script") tape("test evalScript method", function(t) { document.body.className = "" diff --git a/tests/scripts/lib/events.js b/tests/lib/events.js similarity index 94% rename from tests/scripts/lib/events.js rename to tests/lib/events.js index d979c8d..f13e112 100644 --- a/tests/scripts/lib/events.js +++ b/tests/lib/events.js @@ -1,8 +1,8 @@ var tape = require("tape") -var on = require("../../../src/scripts/lib/events/on") -var off = require("../../../src/scripts/lib/events/off") -var trigger = require("../../../src/scripts/lib/events/trigger") +var on = require("../../lib/events/on") +var off = require("../../lib/events/off") +var trigger = require("../../lib/events/trigger") var el = document.createElement("div") var el2 = document.createElement("span") diff --git a/tests/scripts/lib/execute-scripts.js b/tests/lib/execute-scripts.js similarity index 88% rename from tests/scripts/lib/execute-scripts.js rename to tests/lib/execute-scripts.js index fb4a421..bfea9b1 100644 --- a/tests/scripts/lib/execute-scripts.js +++ b/tests/lib/execute-scripts.js @@ -1,6 +1,6 @@ var tape = require("tape") -var executeScripts = require("../../../src/scripts/lib/execute-scripts") +var executeScripts = require("../../lib/execute-scripts") tape("test executeScripts method", function(t) { document.body.className = "" diff --git a/tests/scripts/lib/foreach-els.js b/tests/lib/foreach-els.js similarity index 94% rename from tests/scripts/lib/foreach-els.js rename to tests/lib/foreach-els.js index ea6aa15..7212626 100644 --- a/tests/scripts/lib/foreach-els.js +++ b/tests/lib/foreach-els.js @@ -1,6 +1,6 @@ var tape = require("tape") -var forEachEls = require("../../../src/scripts/lib/foreach-els.js") +var forEachEls = require("../../lib/foreach-els.js") var div = document.createElement("div") var span = document.createElement("span") diff --git a/tests/scripts/lib/foreach-selectors.js b/tests/lib/foreach-selectors.js similarity index 91% rename from tests/scripts/lib/foreach-selectors.js rename to tests/lib/foreach-selectors.js index 5668a4e..1175b32 100644 --- a/tests/scripts/lib/foreach-selectors.js +++ b/tests/lib/foreach-selectors.js @@ -1,6 +1,6 @@ var tape = require("tape") -var forEachEls = require("../../../src/scripts/lib/foreach-selectors.js") +var forEachEls = require("../../lib/foreach-selectors.js") var cb = function(el) { el.className = "modified" diff --git a/tests/scripts/lib/is-supported.js b/tests/lib/is-supported.js similarity index 71% rename from tests/scripts/lib/is-supported.js rename to tests/lib/is-supported.js index 7ca141b..d24f2c3 100644 --- a/tests/scripts/lib/is-supported.js +++ b/tests/lib/is-supported.js @@ -1,6 +1,6 @@ var tape = require("tape") -var isSupported = require("../../../src/scripts/lib/is-supported.js") +var isSupported = require("../../lib/is-supported.js") tape("test isSupported method", function(t) { t.true(isSupported(), "well, we run test on supported browser, so it should be ok here") diff --git a/tests/scripts/lib/proto/attach-link.js b/tests/lib/proto/attach-link.js similarity index 89% rename from tests/scripts/lib/proto/attach-link.js rename to tests/lib/proto/attach-link.js index b5272f9..aa66a88 100644 --- a/tests/scripts/lib/proto/attach-link.js +++ b/tests/lib/proto/attach-link.js @@ -1,8 +1,8 @@ var tape = require("tape") -var on = require("../../../../src/scripts/lib/events/on") -var trigger = require("../../../../src/scripts/lib/events/trigger") -var attachLink = require("../../../../src/scripts/lib/proto/attach-link") +var on = require("../../../lib/events/on") +var trigger = require("../../../lib/events/trigger") +var attachLink = require("../../../lib/proto/attach-link") var a = document.createElement("a") var attr = "data-pjax-click-state" diff --git a/tests/scripts/lib/proto/parse-element.js b/tests/lib/proto/parse-element.js similarity index 85% rename from tests/scripts/lib/proto/parse-element.js rename to tests/lib/proto/parse-element.js index 79d0d8a..69de686 100644 --- a/tests/scripts/lib/proto/parse-element.js +++ b/tests/lib/proto/parse-element.js @@ -1,6 +1,6 @@ var tape = require("tape") -var parseElement = require("../../../../src/scripts/lib/proto/parse-element") +var parseElement = require("../../../lib/proto/parse-element") var protoMock = {attachLink: function() { return true}} tape("test parse element prototype method", function(t) { diff --git a/tests/scripts/lib/request.js b/tests/lib/request.js similarity index 84% rename from tests/scripts/lib/request.js rename to tests/lib/request.js index 87d9020..41f8252 100644 --- a/tests/scripts/lib/request.js +++ b/tests/lib/request.js @@ -1,6 +1,6 @@ var tape = require("tape") -var request = require("../../../src/scripts/lib/request.js") +var request = require("../../lib/request.js") tape("test xhr request", function(t) { var xhr = request("https://api.github.com/", function(result) { diff --git a/tests/scripts/lib/switch-selectors.js b/tests/lib/switch-selectors.js similarity index 54% rename from tests/scripts/lib/switch-selectors.js rename to tests/lib/switch-selectors.js index 0d5bb80..19830da 100644 --- a/tests/scripts/lib/switch-selectors.js +++ b/tests/lib/switch-selectors.js @@ -1,6 +1,6 @@ var tape = require("tape") -var switchesSelectors = require("../../../src/scripts/lib/switches-selectors.js") +var switchesSelectors = require("../../lib/switches-selectors.js") tape("test switchesSelectors", function(t) { t.fail() -- 2.49.1 From 74e224c01891e1ae9fcb962176bd26b6df19e301 Mon Sep 17 00:00:00 2001 From: Maxime Thirouin Date: Tue, 14 Oct 2014 08:24:50 +0200 Subject: [PATCH 33/33] Merge wip --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index c3e97ac..efe5461 100644 --- a/README.md +++ b/README.md @@ -15,11 +15,6 @@ Especially for user that have low bandwidth connection._ **No more full page reload. No more lots of HTTP request.** -## No tests yet ? - -~~There is still some work to make this repo sexy with tests & simple demo.~~ -Actually there is a [WIP branch where I'm adding lot of tests](https://github.com/MoOx/pjax/tree/testling) - ## Demo [You can see this running on my website](http://moox.io), with sexy CSS animations when switching pages. -- 2.49.1