From 3a0054591b550b7693318593665b26811968b958 Mon Sep 17 00:00:00 2001 From: kokujin Date: Wed, 15 Jan 2014 09:42:28 +0100 Subject: [PATCH] Added basic bower reg file. Made PathJS AMD module compatible --- bower.json | 11 ++ path.js | 361 +++++++++++++++++++++++++++------------------------- path.min.js | 2 +- 3 files changed, 203 insertions(+), 171 deletions(-) create mode 100644 bower.json diff --git a/bower.json b/bower.json new file mode 100644 index 0000000..d086353 --- /dev/null +++ b/bower.json @@ -0,0 +1,11 @@ +{ + "name": "mtrpcic/pathjs", + "version": "0.8.4", + "main": "path/to/main.css", + "description": "PathJS is a lightweight, client-side routing library that allows you to create "single page" applications using Hashbangs and/or HTML5 pushState.", + "license": "MIT", + "ignore": [ + ".jshintrc", + "**/*.txt" + ] +} diff --git a/path.js b/path.js index d56a2d8..fa5df3c 100644 --- a/path.js +++ b/path.js @@ -1,192 +1,213 @@ -var Path = { - 'version': "0.8.4", - 'map': function (path) { - if (Path.routes.defined.hasOwnProperty(path)) { - return Path.routes.defined[path]; +(function(window) { + (function(factory) { + if (typeof define === 'function' && define.amd) { + define(factory); } else { - return new Path.core.route(path); - } - }, - 'root': function (path) { - Path.routes.root = path; - }, - 'rescue': function (fn) { - Path.routes.rescue = fn; - }, - 'history': { - 'initial':{}, // Empty container for "Initial Popstate" checking variables. - 'pushState': function(state, title, path){ - if(Path.history.supported){ - if(Path.dispatch(path)){ - history.pushState(state, title, path); - } - } else { - if(Path.history.fallback){ - window.location.hash = "#" + path; + // No module loader (plain