Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[dist] Version bump v1.1.4

  • Loading branch information...
commit 3f611351ecc6078159968c50caf5e004f9ae03fa 1 parent 0216231
@pksunkara pksunkara authored
View
677 build/director-1.1.3.js
@@ -1,677 +0,0 @@
-
-
-//
-// Generated on Thu Jul 26 2012 15:11:38 GMT-0400 (EDT) by Nodejitsu, Inc (Using Codesurgeon).
-// Version 1.1.3
-//
-
-(function (exports) {
-
-
-/*
- * browser.js: Browser specific functionality for director.
- *
- * (C) 2011, Nodejitsu Inc.
- * MIT LICENSE
- *
- */
-
-if (!Array.prototype.filter) {
- Array.prototype.filter = function(filter, that) {
- var other = [], v;
- for (var i = 0, n = this.length; i < n; i++) {
- if (i in this && filter.call(that, v = this[i], i, this)) {
- other.push(v);
- }
- }
- return other;
- };
-}
-
-if (!Array.isArray){
- Array.isArray = function(obj) {
- return Object.prototype.toString.call(obj) === '[object Array]';
- };
-}
-
-var dloc = document.location;
-
-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 (!window.Router.listeners) {
- window.Router.listeners = [];
- }
-
- function onchange(onChangeEvent) {
- for (var i = 0, l = window.Router.listeners.length; i < l; i++) {
- window.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';
- }
-
- window.Router.listeners.push(fn);
-
- return this.mode;
- },
-
- destroy: function (fn) {
- if (!window.Router || !window.Router.listeners) {
- return;
- }
-
- var listeners = window.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("<script>_hash = '" + s + "'; onload = parent.listener.syncHash;<script>");
- d.close();
- },
-
- syncHash: function () {
- // IE support...
- var s = this._hash;
- if (s != dloc.hash) {
- dloc.hash = s;
- }
- return this;
- },
-
- onHashChanged: function () {}
-};
-
-var Router = exports.Router = function (routes) {
- if (!(this instanceof Router)) return new Router(routes);
-
- this.params = {};
- this.routes = {};
- this.methods = ['on', 'once', 'after', 'before'];
- this._methods = {};
-
- this._insert = this.insert;
- this.insert = this.insertEx;
-
- this.historySupport = (window.history != null ? window.history.pushState : null) != null
-
- this.configure();
- this.mount(routes || {});
-};
-
-Router.prototype.init = function (r) {
- var self = this;
- this.handler = function(onChangeEvent) {
- var url = self.history === true ? self.getPath() : onChangeEvent.newURL.replace(/.*#/, '');
- self.dispatch('on', url);
- };
-
- listener.init(this.handler, this.history);
-
- if (this.history === false) {
- if (dloc.hash === '' && r) {
- dloc.hash = r;
- } else if (dloc.hash.length > 0) {
- self.dispatch('on', dloc.hash.replace(/^#/, ''));
- }
- }
- else {
- routeTo = dloc.hash === '' && r ? r : dloc.hash.length > 0 ? dloc.hash.replace(/^#/, '') : null;
- if (routeTo) {
- window.history.replaceState({}, document.title, routeTo);
- }
-
- // Router has been initialized, but due to the chrome bug it will not
- // yet actually route HTML5 history state changes. Thus, decide if should route.
- if (routeTo || this.run_in_init === true) {
- this.handler();
- }
- }
-
- return this;
-};
-
-Router.prototype.explode = function () {
- var v = this.history === true ? this.getPath() : dloc.hash;
- if (v[1] === '/') { v=v.slice(1) }
- return v.slice(1, v.length).split("/");
-};
-
-Router.prototype.setRoute = function (i, v, val) {
- var url = this.explode();
-
- if (typeof i === 'number' && typeof v === 'string') {
- url[i] = v;
- }
- else if (typeof val === 'string') {
- url.splice(i, v, s);
- }
- else {
- url = [i];
- }
-
- listener.setHash(url.join('/'));
- return url;
-};
-
-//
-// ### function insertEx(method, path, route, parent)
-// #### @method {string} Method to insert the specific `route`.
-// #### @path {Array} Parsed path to insert the `route` at.
-// #### @route {Array|function} Route handlers to insert.
-// #### @parent {Object} **Optional** Parent "routes" to insert into.
-// insert a callback that will only occur once per the matched route.
-//
-Router.prototype.insertEx = function(method, path, route, parent) {
- if (method === "once") {
- method = "on";
- route = function(route) {
- var once = false;
- return function() {
- if (once) return;
- once = true;
- return route.apply(this, arguments);
- };
- }(route);
- }
- return this._insert(method, path, route, parent);
-};
-
-Router.prototype.getRoute = function (v) {
- var ret = v;
-
- if (typeof v === "number") {
- ret = this.explode()[v];
- }
- else if (typeof v === "string"){
- var h = this.explode();
- ret = h.indexOf(v);
- }
- else {
- ret = this.explode();
- }
-
- return ret;
-};
-
-Router.prototype.destroy = function () {
- listener.destroy(this.handler);
- return this;
-};
-
-Router.prototype.getPath = function () {
- var path = window.location.pathname;
- if (path.substr(0, 1) !== '/') {
- path = '/' + path;
- }
- return path;
-};
-function _every(arr, iterator) {
- for (var i = 0; i < arr.length; i += 1) {
- if (iterator(arr[i], i, arr) === false) {
- return;
- }
- }
-}
-
-function _flatten(arr) {
- var flat = [];
- for (var i = 0, n = arr.length; i < n; i++) {
- flat = flat.concat(arr[i]);
- }
- return flat;
-}
-
-function _asyncEverySeries(arr, iterator, callback) {
- if (!arr.length) {
- return callback();
- }
- var completed = 0;
- (function iterate() {
- iterator(arr[completed], function(err) {
- if (err || err === false) {
- callback(err);
- callback = function() {};
- } else {
- completed += 1;
- if (completed === arr.length) {
- callback();
- } else {
- iterate();
- }
- }
- });
- })();
-}
-
-function paramifyString(str, params, mod) {
- mod = str;
- for (var param in params) {
- if (params.hasOwnProperty(param)) {
- mod = params[param](str);
- if (mod !== str) {
- break;
- }
- }
- }
- return mod === str ? "([._a-zA-Z0-9-]+)" : mod;
-}
-
-function regifyString(str, params) {
- if (~str.indexOf("*")) {
- str = str.replace(/\*/g, "([_.()!\\ %@&a-zA-Z0-9-]+)");
- }
- var captures = str.match(/:([^\/]+)/ig), length;
- if (captures) {
- length = captures.length;
- for (var i = 0; i < length; i++) {
- str = str.replace(captures[i], paramifyString(captures[i], params));
- }
- }
- return str;
-}
-
-Router.prototype.configure = function(options) {
- options = options || {};
- for (var i = 0; i < this.methods.length; i++) {
- this._methods[this.methods[i]] = true;
- }
- this.recurse = options.recurse || this.recurse || false;
- this.async = options.async || false;
- this.delimiter = options.delimiter || "/";
- this.strict = typeof options.strict === "undefined" ? true : options.strict;
- this.notfound = options.notfound;
- this.resource = options.resource;
- this.history = options.html5history && this.historySupport || false;
- this.run_in_init = this.history === true && options.run_handler_in_init !== false;
- this.every = {
- after: options.after || null,
- before: options.before || null,
- on: options.on || null
- };
- return this;
-};
-
-Router.prototype.param = function(token, matcher) {
- if (token[0] !== ":") {
- token = ":" + token;
- }
- var compiled = new RegExp(token, "g");
- this.params[token] = function(str) {
- return str.replace(compiled, matcher.source || matcher);
- };
-};
-
-Router.prototype.on = Router.prototype.route = function(method, path, route) {
- var self = this;
- if (!route && typeof path == "function") {
- route = path;
- path = method;
- method = "on";
- }
- if (Array.isArray(path)) {
- return path.forEach(function(p) {
- self.on(method, p, route);
- });
- }
- if (path.source) {
- path = path.source.replace(/\\\//ig, "/");
- }
- if (Array.isArray(method)) {
- return method.forEach(function(m) {
- self.on(m.toLowerCase(), path, route);
- });
- }
- this.insert(method, this.scope.concat(path.split(new RegExp(this.delimiter))), route);
-};
-
-Router.prototype.dispatch = function(method, path, callback) {
- var self = this, fns = this.traverse(method, path, this.routes, ""), invoked = this._invoked, after;
- this._invoked = true;
- if (!fns || fns.length === 0) {
- this.last = [];
- if (typeof this.notfound === "function") {
- this.invoke([ this.notfound ], {
- method: method,
- path: path
- }, callback);
- }
- return false;
- }
- if (this.recurse === "forward") {
- fns = fns.reverse();
- }
- function updateAndInvoke() {
- self.last = fns.after;
- self.invoke(self.runlist(fns), self, callback);
- }
- after = this.every && this.every.after ? [ this.every.after ].concat(this.last) : [ this.last ];
- if (after && after.length > 0 && invoked) {
- if (this.async) {
- this.invoke(after, this, updateAndInvoke);
- } else {
- this.invoke(after, this);
- updateAndInvoke();
- }
- return true;
- }
- updateAndInvoke();
- return true;
-};
-
-Router.prototype.invoke = function(fns, thisArg, callback) {
- var self = this;
- if (this.async) {
- _asyncEverySeries(fns, function apply(fn, next) {
- if (Array.isArray(fn)) {
- return _asyncEverySeries(fn, apply, next);
- } else if (typeof fn == "function") {
- fn.apply(thisArg, fns.captures.concat(next));
- }
- }, function() {
- if (callback) {
- callback.apply(thisArg, arguments);
- }
- });
- } else {
- _every(fns, function apply(fn) {
- if (Array.isArray(fn)) {
- return _every(fn, apply);
- } else if (typeof fn === "function") {
- return fn.apply(thisArg, fns.captures || null);
- } else if (typeof fn === "string" && self.resource) {
- self.resource[fn].apply(thisArg, fns.captures || null);
- }
- });
- }
-};
-
-Router.prototype.traverse = function(method, path, routes, regexp, filter) {
- var fns = [], current, exact, match, next, that;
- function filterRoutes(routes) {
- if (!filter) {
- return routes;
- }
- function deepCopy(source) {
- var result = [];
- for (var i = 0; i < source.length; i++) {
- result[i] = Array.isArray(source[i]) ? deepCopy(source[i]) : source[i];
- }
- return result;
- }
- function applyFilter(fns) {
- for (var i = fns.length - 1; i >= 0; i--) {
- if (Array.isArray(fns[i])) {
- applyFilter(fns[i]);
- if (fns[i].length === 0) {
- fns.splice(i, 1);
- }
- } else {
- if (!filter(fns[i])) {
- fns.splice(i, 1);
- }
- }
- }
- }
- var newRoutes = deepCopy(routes);
- newRoutes.matched = routes.matched;
- newRoutes.captures = routes.captures;
- newRoutes.after = routes.after.filter(filter);
- applyFilter(newRoutes);
- return newRoutes;
- }
- if (path === this.delimiter && routes[method]) {
- next = [ [ routes.before, routes[method] ].filter(Boolean) ];
- next.after = [ routes.after ].filter(Boolean);
- next.matched = true;
- next.captures = [];
- return filterRoutes(next);
- }
- for (var r in routes) {
- if (routes.hasOwnProperty(r) && (!this._methods[r] || this._methods[r] && typeof routes[r] === "object" && !Array.isArray(routes[r]))) {
- current = exact = regexp + this.delimiter + r;
- if (!this.strict) {
- exact += "[" + this.delimiter + "]?";
- }
- match = path.match(new RegExp("^" + exact));
- if (!match) {
- continue;
- }
- if (match[0] && match[0] == path && routes[r][method]) {
- next = [ [ routes[r].before, routes[r][method] ].filter(Boolean) ];
- next.after = [ routes[r].after ].filter(Boolean);
- next.matched = true;
- next.captures = match.slice(1);
- if (this.recurse && routes === this.routes) {
- next.push([ routes.before, routes.on ].filter(Boolean));
- next.after = next.after.concat([ routes.after ].filter(Boolean));
- }
- return filterRoutes(next);
- }
- next = this.traverse(method, path, routes[r], current);
- if (next.matched) {
- if (next.length > 0) {
- fns = fns.concat(next);
- }
- if (this.recurse) {
- fns.push([ routes[r].before, routes[r].on ].filter(Boolean));
- next.after = next.after.concat([ routes[r].after ].filter(Boolean));
- if (routes === this.routes) {
- fns.push([ routes["before"], routes["on"] ].filter(Boolean));
- next.after = next.after.concat([ routes["after"] ].filter(Boolean));
- }
- }
- fns.matched = true;
- fns.captures = next.captures;
- fns.after = next.after;
- return filterRoutes(fns);
- }
- }
- }
- return false;
-};
-
-Router.prototype.insert = function(method, path, route, parent) {
- var methodType, parentType, isArray, nested, part;
- path = path.filter(function(p) {
- return p && p.length > 0;
- });
- parent = parent || this.routes;
- part = path.shift();
- if (/\:|\*/.test(part) && !/\\d|\\w/.test(part)) {
- part = regifyString(part, this.params);
- }
- if (path.length > 0) {
- parent[part] = parent[part] || {};
- return this.insert(method, path, route, parent[part]);
- }
- if (!part && !path.length && parent === this.routes) {
- methodType = typeof parent[method];
- switch (methodType) {
- case "function":
- parent[method] = [ parent[method], route ];
- return;
- case "object":
- parent[method].push(route);
- return;
- case "undefined":
- parent[method] = route;
- return;
- }
- return;
- }
- parentType = typeof parent[part];
- isArray = Array.isArray(parent[part]);
- if (parent[part] && !isArray && parentType == "object") {
- methodType = typeof parent[part][method];
- switch (methodType) {
- case "function":
- parent[part][method] = [ parent[part][method], route ];
- return;
- case "object":
- parent[part][method].push(route);
- return;
- case "undefined":
- parent[part][method] = route;
- return;
- }
- } else if (parentType == "undefined") {
- nested = {};
- nested[method] = route;
- parent[part] = nested;
- return;
- }
- throw new Error("Invalid route context: " + parentType);
-};
-
-
-
-Router.prototype.extend = function(methods) {
- var self = this, len = methods.length, i;
- function extend(method) {
- self._methods[method] = true;
- self[method] = function() {
- var extra = arguments.length === 1 ? [ method, "" ] : [ method ];
- self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
- };
- }
- for (i = 0; i < len; i++) {
- extend(methods[i]);
- }
-};
-
-Router.prototype.runlist = function(fns) {
- var runlist = this.every && this.every.before ? [ this.every.before ].concat(_flatten(fns)) : _flatten(fns);
- if (this.every && this.every.on) {
- runlist.push(this.every.on);
- }
- runlist.captures = fns.captures;
- runlist.source = fns.source;
- return runlist;
-};
-
-Router.prototype.mount = function(routes, path) {
- if (!routes || typeof routes !== "object" || Array.isArray(routes)) {
- return;
- }
- var self = this;
- path = path || [];
- if (!Array.isArray(path)) {
- path = path.split(self.delimiter);
- }
- function insertOrMount(route, local) {
- var rename = route, parts = route.split(self.delimiter), routeType = typeof routes[route], isRoute = parts[0] === "" || !self._methods[parts[0]], event = isRoute ? "on" : rename;
- if (isRoute) {
- rename = rename.slice((rename.match(new RegExp(self.delimiter)) || [ "" ])[0].length);
- parts.shift();
- }
- if (isRoute && routeType === "object" && !Array.isArray(routes[route])) {
- local = local.concat(parts);
- self.mount(routes[route], local);
- return;
- }
- if (isRoute) {
- local = local.concat(rename.split(self.delimiter));
- }
- self.insert(event, local, routes[route]);
- }
- for (var route in routes) {
- if (routes.hasOwnProperty(route)) {
- insertOrMount(route, path.slice(0));
- }
- }
-};
-
-
-
-}(typeof process !== "undefined" && process.title ? module : window));
View
7 build/director-1.1.3.min.js
@@ -1,7 +0,0 @@
-
-
-//
-// Generated on Thu Jul 26 2012 15:11:39 GMT-0400 (EDT) by Nodejitsu, Inc (Using Codesurgeon).
-// Version 1.1.3
-//
-(function(a){function i(a,b){~a.indexOf("*")&&(a=a.replace(/\*/g,"([_.()!\\ %@&a-zA-Z0-9-]+)"));var c=a.match(/:([^\/]+)/ig),d;if(c){d=c.length;for(var e=0;e<d;e++)a=a.replace(c[e],h(c[e],b))}return a}function h(a,b,c){c=a;for(var d in b)if(b.hasOwnProperty(d)){c=b[d](a);if(c!==a)break}return c===a?"([._a-zA-Z0-9-]+)":c}function g(a,b,c){if(!a.length)return c();var d=0;(function e(){b(a[d],function(b){b||b===!1?(c(b),c=function(){}):(d+=1,d===a.length?c():e())})})()}function f(a){var b=[];for(var c=0,d=a.length;c<d;c++)b=b.concat(a[c]);return b}function e(a,b){for(var c=0;c<a.length;c+=1)if(b(a[c],c,a)===!1)return}Array.prototype.filter||(Array.prototype.filter=function(a,b){var c=[],d;for(var e=0,f=this.length;e<f;e++)e in this&&a.call(b,d=this[e],e,this)&&c.push(d);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"});var b=document.location,c={mode:"modern",hash:b.hash,history:!1,check:function(){var a=b.hash;a!=this.hash&&(this.hash=a,this.onHashChanged())},fire:function(){this.mode==="modern"?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(a,b){function d(a){for(var b=0,c=window.Router.listeners.length;b<c;b++)window.Router.listeners[b](a)}var c=this;this.history=b,window.Router.listeners||(window.Router.listeners=[]);if("onhashchange"in window&&(document.documentMode===undefined||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=d},500):window.onhashchange=d,this.mode="modern";else{var e=document.createElement("iframe");e.id="state-frame",e.style.display="none",document.body.appendChild(e),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=d,this.mode="legacy"}window.Router.listeners.push(a);return this.mode},destroy:function(a){if(!!window.Router&&!!window.Router.listeners){var b=window.Router.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write("<script>_hash = '"+a+"'; onload = parent.listener.syncHash;<script>"),c.close()},syncHash:function(){var a=this._hash;a!=b.hash&&(b.hash=a);return this},onHashChanged:function(){}},d=a.Router=function(a){if(this instanceof d)this.params={},this.routes={},this.methods=["on","once","after","before"],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=(window.history!=null?window.history.pushState:null)!=null,this.configure(),this.mount(a||{});else return new d(a)};d.prototype.init=function(a){var d=this;this.handler=function(a){var b=d.history===!0?d.getPath():a.newURL.replace(/.*#/,"");d.dispatch("on",b)},c.init(this.handler,this.history),this.history===!1?b.hash===""&&a?b.hash=a:b.hash.length>0&&d.dispatch("on",b.hash.replace(/^#/,"")):(routeTo=b.hash===""&&a?a:b.hash.length>0?b.hash.replace(/^#/,""):null,routeTo&&window.history.replaceState({},document.title,routeTo),(routeTo||this.run_in_init===!0)&&this.handler());return this},d.prototype.explode=function(){var a=this.history===!0?this.getPath():b.hash;a[1]==="/"&&(a=a.slice(1));return a.slice(1,a.length).split("/")},d.prototype.setRoute=function(a,b,d){var e=this.explode();typeof a=="number"&&typeof b=="string"?e[a]=b:typeof d=="string"?e.splice(a,b,s):e=[a],c.setHash(e.join("/"));return e},d.prototype.insertEx=function(a,b,c,d){a==="once"&&(a="on",c=function(a){var b=!1;return function(){if(!b){b=!0;return a.apply(this,arguments)}}}(c));return this._insert(a,b,c,d)},d.prototype.getRoute=function(a){var b=a;if(typeof a=="number")b=this.explode()[a];else if(typeof a=="string"){var c=this.explode();b=c.indexOf(a)}else b=this.explode();return b},d.prototype.destroy=function(){c.destroy(this.handler);return this},d.prototype.getPath=function(){var a=window.location.pathname;a.substr(0,1)!=="/"&&(a="/"+a);return a},d.prototype.configure=function(a){a=a||{};for(var b=0;b<this.methods.length;b++)this._methods[this.methods[b]]=!0;this.recurse=a.recurse||this.recurse||!1,this.async=a.async||!1,this.delimiter=a.delimiter||"/",this.strict=typeof a.strict=="undefined"?!0:a.strict,this.notfound=a.notfound,this.resource=a.resource,this.history=a.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&a.run_handler_in_init!==!1,this.every={after:a.after||null,before:a.before||null,on:a.on||null};return this},d.prototype.param=function(a,b){a[0]!==":"&&(a=":"+a);var c=new RegExp(a,"g");this.params[a]=function(a){return a.replace(c,b.source||b)}},d.prototype.on=d.prototype.route=function(a,b,c){var d=this;!c&&typeof b=="function"&&(c=b,b=a,a="on");if(Array.isArray(b))return b.forEach(function(b){d.on(a,b,c)});b.source&&(b=b.source.replace(/\\\//ig,"/"));if(Array.isArray(a))return a.forEach(function(a){d.on(a.toLowerCase(),b,c)});this.insert(a,this.scope.concat(b.split(new RegExp(this.delimiter))),c)},d.prototype.dispatch=function(a,b,c){function h(){d.last=e.after,d.invoke(d.runlist(e),d,c)}var d=this,e=this.traverse(a,b,this.routes,""),f=this._invoked,g;this._invoked=!0;if(!e||e.length===0){this.last=[],typeof this.notfound=="function"&&this.invoke([this.notfound],{method:a,path:b},c);return!1}this.recurse==="forward"&&(e=e.reverse()),g=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last];if(g&&g.length>0&&f){this.async?this.invoke(g,this,h):(this.invoke(g,this),h());return!0}h();return!0},d.prototype.invoke=function(a,b,c){var d=this;this.async?g(a,function f(c,d){if(Array.isArray(c))return g(c,f,d);typeof c=="function"&&c.apply(b,a.captures.concat(d))},function(){c&&c.apply(b,arguments)}):e(a,function h(c){if(Array.isArray(c))return e(c,h);if(typeof c=="function")return c.apply(b,a.captures||null);typeof c=="string"&&d.resource&&d.resource[c].apply(b,a.captures||null)})},d.prototype.traverse=function(a,b,c,d,e){function l(a){function c(a){for(var b=a.length-1;b>=0;b--)Array.isArray(a[b])?(c(a[b]),a[b].length===0&&a.splice(b,1)):e(a[b])||a.splice(b,1)}function b(a){var c=[];for(var d=0;d<a.length;d++)c[d]=Array.isArray(a[d])?b(a[d]):a[d];return c}if(!e)return a;var d=b(a);d.matched=a.matched,d.captures=a.captures,d.after=a.after.filter(e),c(d);return d}var f=[],g,h,i,j,k;if(b===this.delimiter&&c[a]){j=[[c.before,c[a]].filter(Boolean)],j.after=[c.after].filter(Boolean),j.matched=!0,j.captures=[];return l(j)}for(var m in c)if(c.hasOwnProperty(m)&&(!this._methods[m]||this._methods[m]&&typeof c[m]=="object"&&!Array.isArray(c[m]))){g=h=d+this.delimiter+m,this.strict||(h+="["+this.delimiter+"]?"),i=b.match(new RegExp("^"+h));if(!i)continue;if(i[0]&&i[0]==b&&c[m][a]){j=[[c[m].before,c[m][a]].filter(Boolean)],j.after=[c[m].after].filter(Boolean),j.matched=!0,j.captures=i.slice(1),this.recurse&&c===this.routes&&(j.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)));return l(j)}j=this.traverse(a,b,c[m],g);if(j.matched){j.length>0&&(f=f.concat(j)),this.recurse&&(f.push([c[m].before,c[m].on].filter(Boolean)),j.after=j.after.concat([c[m].after].filter(Boolean)),c===this.routes&&(f.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)))),f.matched=!0,f.captures=j.captures,f.after=j.after;return l(f)}}return!1},d.prototype.insert=function(a,b,c,d){var e,f,g,h,j;b=b.filter(function(a){return a&&a.length>0}),d=d||this.routes,j=b.shift(),/\:|\*/.test(j)&&!/\\d|\\w/.test(j)&&(j=i(j,this.params));if(b.length>0){d[j]=d[j]||{};return this.insert(a,b,c,d[j])}{if(!!j||!!b.length||d!==this.routes){f=typeof d[j],g=Array.isArray(d[j]);if(d[j]&&!g&&f=="object"){e=typeof d[j][a];switch(e){case"function":d[j][a]=[d[j][a],c];return;case"object":d[j][a].push(c);return;case"undefined":d[j][a]=c;return}}else if(f=="undefined"){h={},h[a]=c,d[j]=h;return}throw new Error("Invalid route context: "+f)}e=typeof d[a];switch(e){case"function":d[a]=[d[a],c];return;case"object":d[a].push(c);return;case"undefined":d[a]=c;return}}},d.prototype.extend=function(a){function e(a){b._methods[a]=!0,b[a]=function(){var c=arguments.length===1?[a,""]:[a];b.on.apply(b,c.concat(Array.prototype.slice.call(arguments)))}}var b=this,c=a.length,d;for(d=0;d<c;d++)e(a[d])},d.prototype.runlist=function(a){var b=this.every&&this.every.before?[this.every.before].concat(f(a)):f(a);this.every&&this.every.on&&b.push(this.every.on),b.captures=a.captures,b.source=a.source;return b},d.prototype.mount=function(a,b){function d(b,d){var e=b,f=b.split(c.delimiter),g=typeof a[b],h=f[0]===""||!c._methods[f[0]],i=h?"on":e;h&&(e=e.slice((e.match(new RegExp(c.delimiter))||[""])[0].length),f.shift());h&&g==="object"&&!Array.isArray(a[b])?(d=d.concat(f),c.mount(a[b],d)):(h&&(d=d.concat(e.split(c.delimiter))),c.insert(i,d,a[b]))}if(!!a&&typeof a=="object"&&!Array.isArray(a)){var c=this;b=b||[],Array.isArray(b)||(b=b.split(c.delimiter));for(var e in a)a.hasOwnProperty(e)&&d(e,b.slice(0))}}})(typeof process!="undefined"&&process.title?module:window)
View
678 build/director-1.1.4.js
@@ -0,0 +1,678 @@
+
+
+//
+// Generated on Sun Aug 26 2012 00:02:21 GMT+0530 (IST) by Nodejitsu, Inc (Using Codesurgeon).
+// Version 1.1.4
+//
+
+(function (exports) {
+
+
+/*
+ * browser.js: Browser specific functionality for director.
+ *
+ * (C) 2011, Nodejitsu Inc.
+ * MIT LICENSE
+ *
+ */
+
+if (!Array.prototype.filter) {
+ Array.prototype.filter = function(filter, that) {
+ var other = [], v;
+ for (var i = 0, n = this.length; i < n; i++) {
+ if (i in this && filter.call(that, v = this[i], i, this)) {
+ other.push(v);
+ }
+ }
+ return other;
+ };
+}
+
+if (!Array.isArray){
+ Array.isArray = function(obj) {
+ return Object.prototype.toString.call(obj) === '[object Array]';
+ };
+}
+
+var dloc = document.location;
+
+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("<script>_hash = '" + s + "'; onload = parent.listener.syncHash;<script>");
+ d.close();
+ },
+
+ syncHash: function () {
+ // IE support...
+ var s = this._hash;
+ if (s != dloc.hash) {
+ dloc.hash = s;
+ }
+ return this;
+ },
+
+ onHashChanged: function () {}
+};
+
+var Router = exports.Router = function (routes) {
+ if (!(this instanceof Router)) return new Router(routes);
+
+ this.params = {};
+ this.routes = {};
+ this.methods = ['on', 'once', 'after', 'before'];
+ this._methods = {};
+
+ this._insert = this.insert;
+ this.insert = this.insertEx;
+
+ this.historySupport = (window.history != null ? window.history.pushState : null) != null
+
+ this.configure();
+ this.mount(routes || {});
+};
+
+Router.prototype.init = function (r) {
+ var self = this;
+ this.handler = function(onChangeEvent) {
+ var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash;
+ var url = self.history === true ? self.getPath() : newURL.replace(/.*#/, '');
+ self.dispatch('on', url);
+ };
+
+ listener.init(this.handler, this.history);
+
+ if (this.history === false) {
+ if (dloc.hash === '' && r) {
+ dloc.hash = r;
+ } else if (dloc.hash.length > 0) {
+ self.dispatch('on', dloc.hash.replace(/^#/, ''));
+ }
+ }
+ else {
+ routeTo = dloc.hash === '' && r ? r : dloc.hash.length > 0 ? dloc.hash.replace(/^#/, '') : null;
+ if (routeTo) {
+ window.history.replaceState({}, document.title, routeTo);
+ }
+
+ // Router has been initialized, but due to the chrome bug it will not
+ // yet actually route HTML5 history state changes. Thus, decide if should route.
+ if (routeTo || this.run_in_init === true) {
+ this.handler();
+ }
+ }
+
+ return this;
+};
+
+Router.prototype.explode = function () {
+ var v = this.history === true ? this.getPath() : dloc.hash;
+ if (v[1] === '/') { v=v.slice(1) }
+ return v.slice(1, v.length).split("/");
+};
+
+Router.prototype.setRoute = function (i, v, val) {
+ var url = this.explode();
+
+ if (typeof i === 'number' && typeof v === 'string') {
+ url[i] = v;
+ }
+ else if (typeof val === 'string') {
+ url.splice(i, v, s);
+ }
+ else {
+ url = [i];
+ }
+
+ listener.setHash(url.join('/'));
+ return url;
+};
+
+//
+// ### function insertEx(method, path, route, parent)
+// #### @method {string} Method to insert the specific `route`.
+// #### @path {Array} Parsed path to insert the `route` at.
+// #### @route {Array|function} Route handlers to insert.
+// #### @parent {Object} **Optional** Parent "routes" to insert into.
+// insert a callback that will only occur once per the matched route.
+//
+Router.prototype.insertEx = function(method, path, route, parent) {
+ if (method === "once") {
+ method = "on";
+ route = function(route) {
+ var once = false;
+ return function() {
+ if (once) return;
+ once = true;
+ return route.apply(this, arguments);
+ };
+ }(route);
+ }
+ return this._insert(method, path, route, parent);
+};
+
+Router.prototype.getRoute = function (v) {
+ var ret = v;
+
+ if (typeof v === "number") {
+ ret = this.explode()[v];
+ }
+ else if (typeof v === "string"){
+ var h = this.explode();
+ ret = h.indexOf(v);
+ }
+ else {
+ ret = this.explode();
+ }
+
+ return ret;
+};
+
+Router.prototype.destroy = function () {
+ listener.destroy(this.handler);
+ return this;
+};
+
+Router.prototype.getPath = function () {
+ var path = window.location.pathname;
+ if (path.substr(0, 1) !== '/') {
+ path = '/' + path;
+ }
+ return path;
+};
+function _every(arr, iterator) {
+ for (var i = 0; i < arr.length; i += 1) {
+ if (iterator(arr[i], i, arr) === false) {
+ return;
+ }
+ }
+}
+
+function _flatten(arr) {
+ var flat = [];
+ for (var i = 0, n = arr.length; i < n; i++) {
+ flat = flat.concat(arr[i]);
+ }
+ return flat;
+}
+
+function _asyncEverySeries(arr, iterator, callback) {
+ if (!arr.length) {
+ return callback();
+ }
+ var completed = 0;
+ (function iterate() {
+ iterator(arr[completed], function(err) {
+ if (err || err === false) {
+ callback(err);
+ callback = function() {};
+ } else {
+ completed += 1;
+ if (completed === arr.length) {
+ callback();
+ } else {
+ iterate();
+ }
+ }
+ });
+ })();
+}
+
+function paramifyString(str, params, mod) {
+ mod = str;
+ for (var param in params) {
+ if (params.hasOwnProperty(param)) {
+ mod = params[param](str);
+ if (mod !== str) {
+ break;
+ }
+ }
+ }
+ return mod === str ? "([._a-zA-Z0-9-]+)" : mod;
+}
+
+function regifyString(str, params) {
+ if (~str.indexOf("*")) {
+ str = str.replace(/\*/g, "([_.()!\\ %@&a-zA-Z0-9-]+)");
+ }
+ var captures = str.match(/:([^\/]+)/ig), length;
+ if (captures) {
+ length = captures.length;
+ for (var i = 0; i < length; i++) {
+ str = str.replace(captures[i], paramifyString(captures[i], params));
+ }
+ }
+ return str;
+}
+
+Router.prototype.configure = function(options) {
+ options = options || {};
+ for (var i = 0; i < this.methods.length; i++) {
+ this._methods[this.methods[i]] = true;
+ }
+ this.recurse = options.recurse || this.recurse || false;
+ this.async = options.async || false;
+ this.delimiter = options.delimiter || "/";
+ this.strict = typeof options.strict === "undefined" ? true : options.strict;
+ this.notfound = options.notfound;
+ this.resource = options.resource;
+ this.history = options.html5history && this.historySupport || false;
+ this.run_in_init = this.history === true && options.run_handler_in_init !== false;
+ this.every = {
+ after: options.after || null,
+ before: options.before || null,
+ on: options.on || null
+ };
+ return this;
+};
+
+Router.prototype.param = function(token, matcher) {
+ if (token[0] !== ":") {
+ token = ":" + token;
+ }
+ var compiled = new RegExp(token, "g");
+ this.params[token] = function(str) {
+ return str.replace(compiled, matcher.source || matcher);
+ };
+};
+
+Router.prototype.on = Router.prototype.route = function(method, path, route) {
+ var self = this;
+ if (!route && typeof path == "function") {
+ route = path;
+ path = method;
+ method = "on";
+ }
+ if (Array.isArray(path)) {
+ return path.forEach(function(p) {
+ self.on(method, p, route);
+ });
+ }
+ if (path.source) {
+ path = path.source.replace(/\\\//ig, "/");
+ }
+ if (Array.isArray(method)) {
+ return method.forEach(function(m) {
+ self.on(m.toLowerCase(), path, route);
+ });
+ }
+ this.insert(method, this.scope.concat(path.split(new RegExp(this.delimiter))), route);
+};
+
+Router.prototype.dispatch = function(method, path, callback) {
+ var self = this, fns = this.traverse(method, path, this.routes, ""), invoked = this._invoked, after;
+ this._invoked = true;
+ if (!fns || fns.length === 0) {
+ this.last = [];
+ if (typeof this.notfound === "function") {
+ this.invoke([ this.notfound ], {
+ method: method,
+ path: path
+ }, callback);
+ }
+ return false;
+ }
+ if (this.recurse === "forward") {
+ fns = fns.reverse();
+ }
+ function updateAndInvoke() {
+ self.last = fns.after;
+ self.invoke(self.runlist(fns), self, callback);
+ }
+ after = this.every && this.every.after ? [ this.every.after ].concat(this.last) : [ this.last ];
+ if (after && after.length > 0 && invoked) {
+ if (this.async) {
+ this.invoke(after, this, updateAndInvoke);
+ } else {
+ this.invoke(after, this);
+ updateAndInvoke();
+ }
+ return true;
+ }
+ updateAndInvoke();
+ return true;
+};
+
+Router.prototype.invoke = function(fns, thisArg, callback) {
+ var self = this;
+ if (this.async) {
+ _asyncEverySeries(fns, function apply(fn, next) {
+ if (Array.isArray(fn)) {
+ return _asyncEverySeries(fn, apply, next);
+ } else if (typeof fn == "function") {
+ fn.apply(thisArg, fns.captures.concat(next));
+ }
+ }, function() {
+ if (callback) {
+ callback.apply(thisArg, arguments);
+ }
+ });
+ } else {
+ _every(fns, function apply(fn) {
+ if (Array.isArray(fn)) {
+ return _every(fn, apply);
+ } else if (typeof fn === "function") {
+ return fn.apply(thisArg, fns.captures || []);
+ } else if (typeof fn === "string" && self.resource) {
+ self.resource[fn].apply(thisArg, fns.captures || []);
+ }
+ });
+ }
+};
+
+Router.prototype.traverse = function(method, path, routes, regexp, filter) {
+ var fns = [], current, exact, match, next, that;
+ function filterRoutes(routes) {
+ if (!filter) {
+ return routes;
+ }
+ function deepCopy(source) {
+ var result = [];
+ for (var i = 0; i < source.length; i++) {
+ result[i] = Array.isArray(source[i]) ? deepCopy(source[i]) : source[i];
+ }
+ return result;
+ }
+ function applyFilter(fns) {
+ for (var i = fns.length - 1; i >= 0; i--) {
+ if (Array.isArray(fns[i])) {
+ applyFilter(fns[i]);
+ if (fns[i].length === 0) {
+ fns.splice(i, 1);
+ }
+ } else {
+ if (!filter(fns[i])) {
+ fns.splice(i, 1);
+ }
+ }
+ }
+ }
+ var newRoutes = deepCopy(routes);
+ newRoutes.matched = routes.matched;
+ newRoutes.captures = routes.captures;
+ newRoutes.after = routes.after.filter(filter);
+ applyFilter(newRoutes);
+ return newRoutes;
+ }
+ if (path === this.delimiter && routes[method]) {
+ next = [ [ routes.before, routes[method] ].filter(Boolean) ];
+ next.after = [ routes.after ].filter(Boolean);
+ next.matched = true;
+ next.captures = [];
+ return filterRoutes(next);
+ }
+ for (var r in routes) {
+ if (routes.hasOwnProperty(r) && (!this._methods[r] || this._methods[r] && typeof routes[r] === "object" && !Array.isArray(routes[r]))) {
+ current = exact = regexp + this.delimiter + r;
+ if (!this.strict) {
+ exact += "[" + this.delimiter + "]?";
+ }
+ match = path.match(new RegExp("^" + exact));
+ if (!match) {
+ continue;
+ }
+ if (match[0] && match[0] == path && routes[r][method]) {
+ next = [ [ routes[r].before, routes[r][method] ].filter(Boolean) ];
+ next.after = [ routes[r].after ].filter(Boolean);
+ next.matched = true;
+ next.captures = match.slice(1);
+ if (this.recurse && routes === this.routes) {
+ next.push([ routes.before, routes.on ].filter(Boolean));
+ next.after = next.after.concat([ routes.after ].filter(Boolean));
+ }
+ return filterRoutes(next);
+ }
+ next = this.traverse(method, path, routes[r], current);
+ if (next.matched) {
+ if (next.length > 0) {
+ fns = fns.concat(next);
+ }
+ if (this.recurse) {
+ fns.push([ routes[r].before, routes[r].on ].filter(Boolean));
+ next.after = next.after.concat([ routes[r].after ].filter(Boolean));
+ if (routes === this.routes) {
+ fns.push([ routes["before"], routes["on"] ].filter(Boolean));
+ next.after = next.after.concat([ routes["after"] ].filter(Boolean));
+ }
+ }
+ fns.matched = true;
+ fns.captures = next.captures;
+ fns.after = next.after;
+ return filterRoutes(fns);
+ }
+ }
+ }
+ return false;
+};
+
+Router.prototype.insert = function(method, path, route, parent) {
+ var methodType, parentType, isArray, nested, part;
+ path = path.filter(function(p) {
+ return p && p.length > 0;
+ });
+ parent = parent || this.routes;
+ part = path.shift();
+ if (/\:|\*/.test(part) && !/\\d|\\w/.test(part)) {
+ part = regifyString(part, this.params);
+ }
+ if (path.length > 0) {
+ parent[part] = parent[part] || {};
+ return this.insert(method, path, route, parent[part]);
+ }
+ if (!part && !path.length && parent === this.routes) {
+ methodType = typeof parent[method];
+ switch (methodType) {
+ case "function":
+ parent[method] = [ parent[method], route ];
+ return;
+ case "object":
+ parent[method].push(route);
+ return;
+ case "undefined":
+ parent[method] = route;
+ return;
+ }
+ return;
+ }
+ parentType = typeof parent[part];
+ isArray = Array.isArray(parent[part]);
+ if (parent[part] && !isArray && parentType == "object") {
+ methodType = typeof parent[part][method];
+ switch (methodType) {
+ case "function":
+ parent[part][method] = [ parent[part][method], route ];
+ return;
+ case "object":
+ parent[part][method].push(route);
+ return;
+ case "undefined":
+ parent[part][method] = route;
+ return;
+ }
+ } else if (parentType == "undefined") {
+ nested = {};
+ nested[method] = route;
+ parent[part] = nested;
+ return;
+ }
+ throw new Error("Invalid route context: " + parentType);
+};
+
+
+
+Router.prototype.extend = function(methods) {
+ var self = this, len = methods.length, i;
+ function extend(method) {
+ self._methods[method] = true;
+ self[method] = function() {
+ var extra = arguments.length === 1 ? [ method, "" ] : [ method ];
+ self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
+ };
+ }
+ for (i = 0; i < len; i++) {
+ extend(methods[i]);
+ }
+};
+
+Router.prototype.runlist = function(fns) {
+ var runlist = this.every && this.every.before ? [ this.every.before ].concat(_flatten(fns)) : _flatten(fns);
+ if (this.every && this.every.on) {
+ runlist.push(this.every.on);
+ }
+ runlist.captures = fns.captures;
+ runlist.source = fns.source;
+ return runlist;
+};
+
+Router.prototype.mount = function(routes, path) {
+ if (!routes || typeof routes !== "object" || Array.isArray(routes)) {
+ return;
+ }
+ var self = this;
+ path = path || [];
+ if (!Array.isArray(path)) {
+ path = path.split(self.delimiter);
+ }
+ function insertOrMount(route, local) {
+ var rename = route, parts = route.split(self.delimiter), routeType = typeof routes[route], isRoute = parts[0] === "" || !self._methods[parts[0]], event = isRoute ? "on" : rename;
+ if (isRoute) {
+ rename = rename.slice((rename.match(new RegExp(self.delimiter)) || [ "" ])[0].length);
+ parts.shift();
+ }
+ if (isRoute && routeType === "object" && !Array.isArray(routes[route])) {
+ local = local.concat(parts);
+ self.mount(routes[route], local);
+ return;
+ }
+ if (isRoute) {
+ local = local.concat(rename.split(self.delimiter));
+ }
+ self.insert(event, local, routes[route]);
+ }
+ for (var route in routes) {
+ if (routes.hasOwnProperty(route)) {
+ insertOrMount(route, path.slice(0));
+ }
+ }
+};
+
+
+
+}(typeof process !== "undefined" && process.title ? module : window));
@domenic
domenic added a note

Um, it looks like this wasn't built with codesurgeon 0.3.4 :-/

@domenic
domenic added a note

Same problem with HEAD too btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
7 build/director-1.1.4.min.js
@@ -0,0 +1,7 @@
+
+
+//
+// Generated on Sun Aug 26 2012 00:02:21 GMT+0530 (IST) by Nodejitsu, Inc (Using Codesurgeon).
+// Version 1.1.4
+//
+(function(a){function i(a,b){~a.indexOf("*")&&(a=a.replace(/\*/g,"([_.()!\\ %@&a-zA-Z0-9-]+)"));var c=a.match(/:([^\/]+)/ig),d;if(c){d=c.length;for(var e=0;e<d;e++)a=a.replace(c[e],h(c[e],b))}return a}function h(a,b,c){c=a;for(var d in b)if(b.hasOwnProperty(d)){c=b[d](a);if(c!==a)break}return c===a?"([._a-zA-Z0-9-]+)":c}function g(a,b,c){if(!a.length)return c();var d=0;(function e(){b(a[d],function(b){b||b===!1?(c(b),c=function(){}):(d+=1,d===a.length?c():e())})})()}function f(a){var b=[];for(var c=0,d=a.length;c<d;c++)b=b.concat(a[c]);return b}function e(a,b){for(var c=0;c<a.length;c+=1)if(b(a[c],c,a)===!1)return}Array.prototype.filter||(Array.prototype.filter=function(a,b){var c=[],d;for(var e=0,f=this.length;e<f;e++)e in this&&a.call(b,d=this[e],e,this)&&c.push(d);return c}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"});var b=document.location,c={mode:"modern",hash:b.hash,history:!1,check:function(){var a=b.hash;a!=this.hash&&(this.hash=a,this.onHashChanged())},fire:function(){this.mode==="modern"?this.history===!0?window.onpopstate():window.onhashchange():this.onHashChanged()},init:function(a,b){function e(a){for(var b=0,c=d.listeners.length;b<c;b++)d.listeners[b](a)}var c=this;this.history=b,d.listeners||(d.listeners=[]);if("onhashchange"in window&&(document.documentMode===undefined||document.documentMode>7))this.history===!0?setTimeout(function(){window.onpopstate=e},500):window.onhashchange=e,this.mode="modern";else{var f=document.createElement("iframe");f.id="state-frame",f.style.display="none",document.body.appendChild(f),this.writeFrame(""),"onpropertychange"in document&&"attachEvent"in document&&document.attachEvent("onpropertychange",function(){event.propertyName==="location"&&c.check()}),window.setInterval(function(){c.check()},50),this.onHashChanged=e,this.mode="legacy"}d.listeners.push(a);return this.mode},destroy:function(a){if(!!d&&!!d.listeners){var b=d.listeners;for(var c=b.length-1;c>=0;c--)b[c]===a&&b.splice(c,1)}},setHash:function(a){this.mode==="legacy"&&this.writeFrame(a),this.history===!0?(window.history.pushState({},document.title,a),this.fire()):b.hash=a[0]==="/"?a:"/"+a;return this},writeFrame:function(a){var b=document.getElementById("state-frame"),c=b.contentDocument||b.contentWindow.document;c.open(),c.write("<script>_hash = '"+a+"'; onload = parent.listener.syncHash;<script>"),c.close()},syncHash:function(){var a=this._hash;a!=b.hash&&(b.hash=a);return this},onHashChanged:function(){}},d=a.Router=function(a){if(this instanceof d)this.params={},this.routes={},this.methods=["on","once","after","before"],this._methods={},this._insert=this.insert,this.insert=this.insertEx,this.historySupport=(window.history!=null?window.history.pushState:null)!=null,this.configure(),this.mount(a||{});else return new d(a)};d.prototype.init=function(a){var d=this;this.handler=function(a){var b=a&&a.newURL||window.location.hash,c=d.history===!0?d.getPath():b.replace(/.*#/,"");d.dispatch("on",c)},c.init(this.handler,this.history),this.history===!1?b.hash===""&&a?b.hash=a:b.hash.length>0&&d.dispatch("on",b.hash.replace(/^#/,"")):(routeTo=b.hash===""&&a?a:b.hash.length>0?b.hash.replace(/^#/,""):null,routeTo&&window.history.replaceState({},document.title,routeTo),(routeTo||this.run_in_init===!0)&&this.handler());return this},d.prototype.explode=function(){var a=this.history===!0?this.getPath():b.hash;a[1]==="/"&&(a=a.slice(1));return a.slice(1,a.length).split("/")},d.prototype.setRoute=function(a,b,d){var e=this.explode();typeof a=="number"&&typeof b=="string"?e[a]=b:typeof d=="string"?e.splice(a,b,s):e=[a],c.setHash(e.join("/"));return e},d.prototype.insertEx=function(a,b,c,d){a==="once"&&(a="on",c=function(a){var b=!1;return function(){if(!b){b=!0;return a.apply(this,arguments)}}}(c));return this._insert(a,b,c,d)},d.prototype.getRoute=function(a){var b=a;if(typeof a=="number")b=this.explode()[a];else if(typeof a=="string"){var c=this.explode();b=c.indexOf(a)}else b=this.explode();return b},d.prototype.destroy=function(){c.destroy(this.handler);return this},d.prototype.getPath=function(){var a=window.location.pathname;a.substr(0,1)!=="/"&&(a="/"+a);return a},d.prototype.configure=function(a){a=a||{};for(var b=0;b<this.methods.length;b++)this._methods[this.methods[b]]=!0;this.recurse=a.recurse||this.recurse||!1,this.async=a.async||!1,this.delimiter=a.delimiter||"/",this.strict=typeof a.strict=="undefined"?!0:a.strict,this.notfound=a.notfound,this.resource=a.resource,this.history=a.html5history&&this.historySupport||!1,this.run_in_init=this.history===!0&&a.run_handler_in_init!==!1,this.every={after:a.after||null,before:a.before||null,on:a.on||null};return this},d.prototype.param=function(a,b){a[0]!==":"&&(a=":"+a);var c=new RegExp(a,"g");this.params[a]=function(a){return a.replace(c,b.source||b)}},d.prototype.on=d.prototype.route=function(a,b,c){var d=this;!c&&typeof b=="function"&&(c=b,b=a,a="on");if(Array.isArray(b))return b.forEach(function(b){d.on(a,b,c)});b.source&&(b=b.source.replace(/\\\//ig,"/"));if(Array.isArray(a))return a.forEach(function(a){d.on(a.toLowerCase(),b,c)});this.insert(a,this.scope.concat(b.split(new RegExp(this.delimiter))),c)},d.prototype.dispatch=function(a,b,c){function h(){d.last=e.after,d.invoke(d.runlist(e),d,c)}var d=this,e=this.traverse(a,b,this.routes,""),f=this._invoked,g;this._invoked=!0;if(!e||e.length===0){this.last=[],typeof this.notfound=="function"&&this.invoke([this.notfound],{method:a,path:b},c);return!1}this.recurse==="forward"&&(e=e.reverse()),g=this.every&&this.every.after?[this.every.after].concat(this.last):[this.last];if(g&&g.length>0&&f){this.async?this.invoke(g,this,h):(this.invoke(g,this),h());return!0}h();return!0},d.prototype.invoke=function(a,b,c){var d=this;this.async?g(a,function f(c,d){if(Array.isArray(c))return g(c,f,d);typeof c=="function"&&c.apply(b,a.captures.concat(d))},function(){c&&c.apply(b,arguments)}):e(a,function h(c){if(Array.isArray(c))return e(c,h);if(typeof c=="function")return c.apply(b,a.captures||[]);typeof c=="string"&&d.resource&&d.resource[c].apply(b,a.captures||[])})},d.prototype.traverse=function(a,b,c,d,e){function l(a){function c(a){for(var b=a.length-1;b>=0;b--)Array.isArray(a[b])?(c(a[b]),a[b].length===0&&a.splice(b,1)):e(a[b])||a.splice(b,1)}function b(a){var c=[];for(var d=0;d<a.length;d++)c[d]=Array.isArray(a[d])?b(a[d]):a[d];return c}if(!e)return a;var d=b(a);d.matched=a.matched,d.captures=a.captures,d.after=a.after.filter(e),c(d);return d}var f=[],g,h,i,j,k;if(b===this.delimiter&&c[a]){j=[[c.before,c[a]].filter(Boolean)],j.after=[c.after].filter(Boolean),j.matched=!0,j.captures=[];return l(j)}for(var m in c)if(c.hasOwnProperty(m)&&(!this._methods[m]||this._methods[m]&&typeof c[m]=="object"&&!Array.isArray(c[m]))){g=h=d+this.delimiter+m,this.strict||(h+="["+this.delimiter+"]?"),i=b.match(new RegExp("^"+h));if(!i)continue;if(i[0]&&i[0]==b&&c[m][a]){j=[[c[m].before,c[m][a]].filter(Boolean)],j.after=[c[m].after].filter(Boolean),j.matched=!0,j.captures=i.slice(1),this.recurse&&c===this.routes&&(j.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)));return l(j)}j=this.traverse(a,b,c[m],g);if(j.matched){j.length>0&&(f=f.concat(j)),this.recurse&&(f.push([c[m].before,c[m].on].filter(Boolean)),j.after=j.after.concat([c[m].after].filter(Boolean)),c===this.routes&&(f.push([c.before,c.on].filter(Boolean)),j.after=j.after.concat([c.after].filter(Boolean)))),f.matched=!0,f.captures=j.captures,f.after=j.after;return l(f)}}return!1},d.prototype.insert=function(a,b,c,d){var e,f,g,h,j;b=b.filter(function(a){return a&&a.length>0}),d=d||this.routes,j=b.shift(),/\:|\*/.test(j)&&!/\\d|\\w/.test(j)&&(j=i(j,this.params));if(b.length>0){d[j]=d[j]||{};return this.insert(a,b,c,d[j])}{if(!!j||!!b.length||d!==this.routes){f=typeof d[j],g=Array.isArray(d[j]);if(d[j]&&!g&&f=="object"){e=typeof d[j][a];switch(e){case"function":d[j][a]=[d[j][a],c];return;case"object":d[j][a].push(c);return;case"undefined":d[j][a]=c;return}}else if(f=="undefined"){h={},h[a]=c,d[j]=h;return}throw new Error("Invalid route context: "+f)}e=typeof d[a];switch(e){case"function":d[a]=[d[a],c];return;case"object":d[a].push(c);return;case"undefined":d[a]=c;return}}},d.prototype.extend=function(a){function e(a){b._methods[a]=!0,b[a]=function(){var c=arguments.length===1?[a,""]:[a];b.on.apply(b,c.concat(Array.prototype.slice.call(arguments)))}}var b=this,c=a.length,d;for(d=0;d<c;d++)e(a[d])},d.prototype.runlist=function(a){var b=this.every&&this.every.before?[this.every.before].concat(f(a)):f(a);this.every&&this.every.on&&b.push(this.every.on),b.captures=a.captures,b.source=a.source;return b},d.prototype.mount=function(a,b){function d(b,d){var e=b,f=b.split(c.delimiter),g=typeof a[b],h=f[0]===""||!c._methods[f[0]],i=h?"on":e;h&&(e=e.slice((e.match(new RegExp(c.delimiter))||[""])[0].length),f.shift());h&&g==="object"&&!Array.isArray(a[b])?(d=d.concat(f),c.mount(a[b],d)):(h&&(d=d.concat(e.split(c.delimiter))),c.insert(i,d,a[b]))}if(!!a&&typeof a=="object"&&!Array.isArray(a)){var c=this;b=b||[],Array.isArray(b)||(b=b.split(c.delimiter));for(var e in a)a.hasOwnProperty(e)&&d(e,b.slice(0))}}})(typeof process!="undefined"&&process.title?module:window)
View
4 package.json
@@ -2,7 +2,7 @@
"name": "director",
"description": "A client Side/Server Side Router",
"author": "Nodejitsu Inc. <info@nodejitsu.com>",
- "version": "1.1.3",
+ "version": "1.1.4",
"maintainers": [
"hij1nx <paolo@nodejitsu.com>",
"indexzero <charlie@nodejitsu.com>"
@@ -30,7 +30,7 @@
"vows": "0.6.x"
},
"ender": "./build/ender.js",
- "browserify": "./build/director-1.1.3",
+ "browserify": "./build/director-1.1.4",
"main": "./lib/director",
"engines": {
"node": ">= 0.4.0"
View
2  test/browser/browserify-harness.html
@@ -14,7 +14,7 @@
<script src="browserified-bundle.js"></script>
<script>
var HTML5TEST = false;
- var RouterAlias = require('/director-1.1.3').Router;
+ var RouterAlias = require('/director-1.1.4').Router;
</script>
<script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
View
2  test/browser/html5-routes-harness.html
@@ -16,7 +16,7 @@
</script>
<script src="/files/node_modules/qunitjs/qunit/qunit.js"></script>
- <script src="/files/build/director-1.1.3.js"></script>
+ <script src="/files/build/director-1.1.4.js"></script>
<script src="/files/helpers/api.js"></script>
<script src="/files/html5-routes-test.js"></script>
</body>
View
2  test/browser/routes-harness.html
@@ -14,7 +14,7 @@
</script>
<script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
- <script src="../../build/director-1.1.3.js"></script>
+ <script src="../../build/director-1.1.4.js"></script>
<script src="helpers/api.js"></script>
<script src="routes-test.js"></script>
</body>
@domenic

Um, it looks like this wasn't built with codesurgeon 0.3.4 :-/

@domenic

Same problem with HEAD too btw

Please sign in to comment.
Something went wrong with that request. Please try again.