diff --git a/README.md b/README.md index 3f5de5b..d1d39f7 100644 --- a/README.md +++ b/README.md @@ -934,6 +934,16 @@ requirement, you are probably building a "Web Page" and not a "Web Application". Director on the client is meant for script-heavy Web Applications. +# Development + +Server/CLI tests are run via `npm test`. + +Browser testing relies on `gulp` so do `gulp` & open: + +- http://localhost:8080/test/browser/browserify-harness.html +- http://localhost:8080/test/browser/html5-routes-harness.html +- http://localhost:8080/test/browser/routes-harness.html + # Licence (The MIT License) diff --git a/bin/build b/bin/build deleted file mode 100755 index 6be431b..0000000 --- a/bin/build +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env node - -var Codesurgeon = require('codesurgeon').Codesurgeon; -var surgeon = new Codesurgeon(); - -var path = require('path'); - -var root = path.join(__dirname, '..'); -var lib = path.join(root, 'lib', 'director'); - -// -// Distill and package the browser version. -// -surgeon - // - .configure({ - package: root + '/package.json', - owner: 'Nodejitsu, Inc (Using Codesurgeon).', - noVersion: true - }) - .read( - path.join(lib, 'browser.js') - ) - // - // We want everything so far. specify extract with no - // parameters to get everything into the output buffer. - // - .extract() - // - // Clear the input so far, but don't clear the output. - // - .clear('inputs') - // - // Read the `router.js` file - // - .read( - path.join(lib, 'router.js') - ) - // - // The current input buffer contains stuff that we dont - // want in the browser build, so let's cherry pick from - // the buffer. - // - .extract( - '_every', - '_flatten', - '_asyncEverySeries', - 'paramifyString', - 'regifyString', - 'terminator', - 'QUERY_SEPARATOR', - 'Router.prototype.configure', - 'Router.prototype.param', - 'Router.prototype.on', - 'Router.prototype.path', - 'Router.prototype.dispatch', - 'Router.prototype.invoke', - 'Router.prototype.traverse', - 'Router.prototype.insert', - 'Router.prototype.insertEx', - 'Router.prototype.extend', - 'Router.prototype.runlist', - 'Router.prototype.mount' - ) - // - // Wrap everything that is in the current buffer with a - // closure so that we don't get any collisions with other - // libraries. - // - .wrap() - // - // Write the debuggable version of the file. This file will - // get renamed to include the version from the package.json. - // - .write(root + '/build/director.js') - // - // Make a minified version for production use. - // - .uglify() - .write(root + '/build/director.min.js') -; diff --git a/build/director.js b/build/director.js index fe62960..dff1999 100644 --- a/build/director.js +++ b/build/director.js @@ -1,725 +1 @@ - - -// -// Generated on Wed Nov 05 2014 22:50:42 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon). -// Version 1.2.4 -// - -(function (exports) { - -/* - * browser.js: Browser specific functionality for director. - * - * (C) 2011, Nodejitsu Inc. - * MIT LICENSE - * - */ - -var dloc = document.location; - -function dlocHashEmpty() { - // Non-IE browsers return '' when the address bar shows '#'; Director's logic - // assumes both mean empty. - return dloc.hash === '' || dloc.hash === '#'; -} - -var listener = { - mode: 'modern', - hash: dloc.hash, - history: false, - - check: function () { - var h = dloc.hash; - if (h != this.hash) { - this.hash = h; - this.onHashChanged(); - } - }, - - fire: function () { - if (this.mode === 'modern') { - this.history === true ? window.onpopstate() : window.onhashchange(); - } - else { - this.onHashChanged(); - } - }, - - init: function (fn, history) { - var self = this; - this.history = history; - - if (!Router.listeners) { - Router.listeners = []; - } - - function onchange(onChangeEvent) { - for (var i = 0, l = Router.listeners.length; i < l; i++) { - Router.listeners[i](onChangeEvent); - } - } - - //note IE8 is being counted as 'modern' because it has the hashchange event - if ('onhashchange' in window && (document.documentMode === undefined - || document.documentMode > 7)) { - // At least for now HTML5 history is available for 'modern' browsers only - if (this.history === true) { - // There is an old bug in Chrome that causes onpopstate to fire even - // upon initial page load. Since the handler is run manually in init(), - // this would cause Chrome to run it twise. Currently the only - // workaround seems to be to set the handler after the initial page load - // http://code.google.com/p/chromium/issues/detail?id=63040 - setTimeout(function() { - window.onpopstate = onchange; - }, 500); - } - else { - window.onhashchange = onchange; - } - this.mode = 'modern'; - } - else { - // - // IE support, based on a concept by Erik Arvidson ... - // - var frame = document.createElement('iframe'); - frame.id = 'state-frame'; - frame.style.display = 'none'; - document.body.appendChild(frame); - this.writeFrame(''); - - if ('onpropertychange' in document && 'attachEvent' in document) { - document.attachEvent('onpropertychange', function () { - if (event.propertyName === 'location') { - self.check(); - } - }); - } - - window.setInterval(function () { self.check(); }, 50); - - this.onHashChanged = onchange; - this.mode = 'legacy'; - } - - Router.listeners.push(fn); - - return this.mode; - }, - - destroy: function (fn) { - if (!Router || !Router.listeners) { - return; - } - - var listeners = Router.listeners; - - for (var i = listeners.length - 1; i >= 0; i--) { - if (listeners[i] === fn) { - listeners.splice(i, 1); - } - } - }, - - setHash: function (s) { - // Mozilla always adds an entry to the history - if (this.mode === 'legacy') { - this.writeFrame(s); - } - - if (this.history === true) { - window.history.pushState({}, document.title, s); - // Fire an onpopstate event manually since pushing does not obviously - // trigger the pop event. - this.fire(); - } else { - dloc.hash = (s[0] === '/') ? s : '/' + s; - } - return this; - }, - - writeFrame: function (s) { - // IE support... - var f = document.getElementById('state-frame'); - var d = f.contentDocument || f.contentWindow.document; - d.open(); - d.write(" + - +
-Note: in order to execute HTML5 mode test this file needs to be served with provided nodejs backend. Start the server from director/test/browser/backend and go to http://localhost:8080/ to launch the tests.
+Note: in order to execute HTML5 mode test this file needs to be served with provided nodejs backend. Start the server with gulp and go to http://localhost:8080/ to launch the tests.
@@ -15,9 +15,9 @@ var HTML5TEST = true; - - - - + + + +diff --git a/test/browser/helpers/api.js b/test/browser/helpers/api.js index d784700..372b944 100644 --- a/test/browser/helpers/api.js +++ b/test/browser/helpers/api.js @@ -19,9 +19,7 @@ module("Director.js", { var shared; function createTest(name, config, use, test, initialRoute) { - // We rename to `RouterAlias` for the browserify tests, since we want to be - // sure that no code is depending on `window.Router` being available. - var Router = window.Router || window.RouterAlias; + var Router = window.Router; if (typeof use === 'function') { test = use; diff --git a/test/browser/html5-routes-harness.html b/test/browser/html5-routes-harness.html index eaf8ffc..6683532 100644 --- a/test/browser/html5-routes-harness.html +++ b/test/browser/html5-routes-harness.html @@ -3,10 +3,10 @@
- +