Commit 410b0357 authored by Arthur Verschaeve's avatar Arthur Verschaeve

Switch the jQuery example over to NPM

parent 0cb634d0
bower_components/jquery node_modules/jquery
!bower_components/jquery/dist/jquery.js !node_modules/jquery/dist/jquery.js
bower_components/director node_modules/director
!bower_components/director/build/director.js !node_modules/director/build/director.js
bower_components/handlebars node_modules/handlebars
!bower_components/handlebars/handlebars.js !node_modules/handlebars/handlebars.js
bower_components/todomvc-app-css node_modules/todomvc-app-css
!bower_components/todomvc-app-css/index.css !node_modules/todomvc-app-css/index.css
bower_components/todomvc-common node_modules/todomvc-common
!bower_components/todomvc-common/base.js !node_modules/todomvc-common/base.js
!bower_components/todomvc-common/base.css !node_modules/todomvc-common/base.css
...@@ -3,8 +3,8 @@ ...@@ -3,8 +3,8 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>jQuery • TodoMVC</title> <title>jQuery • TodoMVC</title>
<link rel="stylesheet" href="bower_components/todomvc-common/base.css"> <link rel="stylesheet" href="node_modules/todomvc-common/base.css">
<link rel="stylesheet" href="bower_components/todomvc-app-css/index.css"> <link rel="stylesheet" href="node_modules/todomvc-app-css/index.css">
<link rel="stylesheet" href="css/app.css"> <link rel="stylesheet" href="css/app.css">
</head> </head>
<body> <body>
...@@ -52,10 +52,10 @@ ...@@ -52,10 +52,10 @@
</ul> </ul>
{{#if completedTodos}}<button id="clear-completed">Clear completed ({{completedTodos}})</button>{{/if}} {{#if completedTodos}}<button id="clear-completed">Clear completed ({{completedTodos}})</button>{{/if}}
</script> </script>
<script src="bower_components/todomvc-common/base.js"></script> <script src="node_modules/todomvc-common/base.js"></script>
<script src="bower_components/jquery/dist/jquery.js"></script> <script src="node_modules/jquery/dist/jquery.js"></script>
<script src="bower_components/handlebars/handlebars.js"></script> <script src="node_modules/handlebars/dist/handlebars.js"></script>
<script src="bower_components/director/build/director.js"></script> <script src="node_modules/director/build/director.js"></script>
<script src="js/app.js"></script> <script src="js/app.js"></script>
</body> </body>
</html> </html>
// //
// Generated on Fri Dec 27 2013 12:02:11 GMT-0500 (EST) by Nodejitsu, Inc (Using Codesurgeon). // Generated on Tue Dec 16 2014 12:13:47 GMT+0100 (CET) by Charlie Robbins, Paolo Fragomeni & the Contributors (Using Codesurgeon).
// Version 1.2.2 // Version 1.2.6
// //
(function (exports) { (function (exports) {
...@@ -10,29 +10,11 @@ ...@@ -10,29 +10,11 @@
/* /*
* browser.js: Browser specific functionality for director. * browser.js: Browser specific functionality for director.
* *
* (C) 2011, Nodejitsu Inc. * (C) 2011, Charlie Robbins, Paolo Fragomeni, & the Contributors.
* MIT LICENSE * 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 dloc = document.location;
function dlocHashEmpty() { function dlocHashEmpty() {
...@@ -196,7 +178,8 @@ var Router = exports.Router = function (routes) { ...@@ -196,7 +178,8 @@ var Router = exports.Router = function (routes) {
}; };
Router.prototype.init = function (r) { Router.prototype.init = function (r) {
var self = this; var self = this
, routeTo;
this.handler = function(onChangeEvent) { this.handler = function(onChangeEvent) {
var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash; var newURL = onChangeEvent && onChangeEvent.newURL || window.location.hash;
var url = self.history === true ? self.getPath() : newURL.replace(/.*#/, ''); var url = self.history === true ? self.getPath() : newURL.replace(/.*#/, '');
...@@ -213,10 +196,17 @@ Router.prototype.init = function (r) { ...@@ -213,10 +196,17 @@ Router.prototype.init = function (r) {
} }
} }
else { else {
var routeTo = dlocHashEmpty() && r ? r : !dlocHashEmpty() ? dloc.hash.replace(/^#/, '') : null; if (this.convert_hash_in_init) {
// Use hash as route
routeTo = dlocHashEmpty() && r ? r : !dlocHashEmpty() ? dloc.hash.replace(/^#/, '') : null;
if (routeTo) { if (routeTo) {
window.history.replaceState({}, document.title, routeTo); window.history.replaceState({}, document.title, routeTo);
} }
}
else {
// Use canonical url
routeTo = this.getPath();
}
// Router has been initialized, but due to the chrome bug it will not // 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. // yet actually route HTML5 history state changes. Thus, decide if should route.
...@@ -351,7 +341,7 @@ function paramifyString(str, params, mod) { ...@@ -351,7 +341,7 @@ function paramifyString(str, params, mod) {
} }
} }
} }
return mod === str ? "([._a-zA-Z0-9-]+)" : mod; return mod === str ? "([._a-zA-Z0-9-%()]+)" : mod;
} }
function regifyString(str, params) { function regifyString(str, params) {
...@@ -397,6 +387,8 @@ function terminator(routes, delimiter, start, stop) { ...@@ -397,6 +387,8 @@ function terminator(routes, delimiter, start, stop) {
return routes; return routes;
} }
var QUERY_SEPARATOR = /\?.*/;
Router.prototype.configure = function(options) { Router.prototype.configure = function(options) {
options = options || {}; options = options || {};
for (var i = 0; i < this.methods.length; i++) { for (var i = 0; i < this.methods.length; i++) {
...@@ -410,6 +402,7 @@ Router.prototype.configure = function(options) { ...@@ -410,6 +402,7 @@ Router.prototype.configure = function(options) {
this.resource = options.resource; this.resource = options.resource;
this.history = options.html5history && this.historySupport || false; this.history = options.html5history && this.historySupport || false;
this.run_in_init = this.history === true && options.run_handler_in_init !== false; this.run_in_init = this.history === true && options.run_handler_in_init !== false;
this.convert_hash_in_init = this.history === true && options.convert_hash_in_init !== false;
this.every = { this.every = {
after: options.after || null, after: options.after || null,
before: options.before || null, before: options.before || null,
...@@ -426,6 +419,7 @@ Router.prototype.param = function(token, matcher) { ...@@ -426,6 +419,7 @@ Router.prototype.param = function(token, matcher) {
this.params[token] = function(str) { this.params[token] = function(str) {
return str.replace(compiled, matcher.source || matcher); return str.replace(compiled, matcher.source || matcher);
}; };
return this;
}; };
Router.prototype.on = Router.prototype.route = function(method, path, route) { Router.prototype.on = Router.prototype.route = function(method, path, route) {
...@@ -453,8 +447,20 @@ Router.prototype.on = Router.prototype.route = function(method, path, route) { ...@@ -453,8 +447,20 @@ Router.prototype.on = Router.prototype.route = function(method, path, route) {
this.insert(method, this.scope.concat(path), route); this.insert(method, this.scope.concat(path), route);
}; };
Router.prototype.path = function(path, routesFn) {
var self = this, length = this.scope.length;
if (path.source) {
path = path.source.replace(/\\\//ig, "/");
}
path = path.split(new RegExp(this.delimiter));
path = terminator(path, this.delimiter);
this.scope = this.scope.concat(path);
routesFn.call(this, this);
this.scope.splice(length, path.length);
};
Router.prototype.dispatch = function(method, path, callback) { Router.prototype.dispatch = function(method, path, callback) {
var self = this, fns = this.traverse(method, path, this.routes, ""), invoked = this._invoked, after; var self = this, fns = this.traverse(method, path.replace(QUERY_SEPARATOR, ""), this.routes, ""), invoked = this._invoked, after;
this._invoked = true; this._invoked = true;
if (!fns || fns.length === 0) { if (!fns || fns.length === 0) {
this.last = []; this.last = [];
...@@ -495,7 +501,7 @@ Router.prototype.invoke = function(fns, thisArg, callback) { ...@@ -495,7 +501,7 @@ Router.prototype.invoke = function(fns, thisArg, callback) {
if (Array.isArray(fn)) { if (Array.isArray(fn)) {
return _asyncEverySeries(fn, apply, next); return _asyncEverySeries(fn, apply, next);
} else if (typeof fn == "function") { } else if (typeof fn == "function") {
fn.apply(thisArg, fns.captures.concat(next)); fn.apply(thisArg, (fns.captures || []).concat(next));
} }
}; };
_asyncEverySeries(fns, apply, function() { _asyncEverySeries(fns, apply, function() {
......
{ {
"name": "todomvc-jquery", "name": "todomvc-jquery",
"description": "TodoMVC implementation in Ampersand.js",
"private": true,
"dependencies": { "dependencies": {
"todomvc-common": "~1.0.1", "todomvc-common": "~1.0.1",
"todomvc-app-css": "~1.0.1", "todomvc-app-css": "~1.0.1",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment