Skip to content

Commit

Permalink
chore(all): prepare release 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jan 6, 2015
1 parent ff2a572 commit 304995b
Show file tree
Hide file tree
Showing 8 changed files with 302 additions and 77 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "aurelia-history-browser",
"version": "0.1.1",
"version": "0.2.0",
"description": "An implementation of the Aurelia history interface based on standard browser hash change and push state mechanisms.",
"keywords": [
"aurelia",
Expand Down
47 changes: 21 additions & 26 deletions dist/amd/index.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {
"use strict";

var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
if (parent) child.__proto__ = parent;
};

var History = _aureliaHistory.History;
Expand All @@ -31,23 +34,8 @@ define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {
}
}

function extend(obj) {
var rest = Array.prototype.slice.call(arguments, 1);

for (var i = 0, length = rest.length; i < length; i++) {
var source = rest[i];

if (source) {
for (var prop in source) {
obj[prop] = source[prop];
}
}
}

return obj;
}

var BrowserHistory = (function (History) {
var BrowserHistory = (function () {
var _History = History;
var BrowserHistory = function BrowserHistory() {
this.interval = 50;
this.active = false;
Expand All @@ -60,18 +48,20 @@ define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {
}
};

_extends(BrowserHistory, History);
_inherits(BrowserHistory, _History);

BrowserHistory.prototype.getHash = function (window) {
var match = (window || this).location.href.match(/#(.*)$/);
return match ? match[1] : "";
};

BrowserHistory.prototype.getFragment = function (fragment, forcePushState) {
var root;

if (!fragment) {
if (this._hasPushState || !this._wantsHashChange || forcePushState) {
fragment = this.location.pathname + this.location.search;
var root = this.root.replace(trailingSlash, "");
root = this.root.replace(trailingSlash, "");
if (!fragment.indexOf(root)) {
fragment = fragment.substr(root.length);
}
Expand All @@ -90,7 +80,7 @@ define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {

this.active = true;

this.options = extend({}, { root: "/" }, this.options, options);
this.options = Object.assign({}, { root: "/" }, this.options, options);
this.root = this.options.root;
this._wantsHashChange = this.options.hashChange !== false;
this._wantsPushState = !!this.options.pushState;
Expand All @@ -102,7 +92,7 @@ define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {

if (this._hasPushState) {
window.onpopstate = this._checkUrlCallback;
} else if (this._wantsHashChange && ("onhashchange" in window)) {
} else if (this._wantsHashChange && "onhashchange" in window) {
window.addEventListener("hashchange", this._checkUrlCallback);
} else if (this._wantsHashChange) {
this._checkUrlInterval = setInterval(this._checkUrlCallback, this.interval);
Expand Down Expand Up @@ -199,7 +189,7 @@ define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {
} else if (this._wantsHashChange) {
updateHash(this.location, fragment, options.replace);

if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) {
if (this.iframe && fragment !== this.getFragment(this.getHash(this.iframe))) {
if (!options.replace) {
this.iframe.document.open().close();
}
Expand All @@ -222,7 +212,12 @@ define(["exports", "aurelia-history"], function (exports, _aureliaHistory) {
};

return BrowserHistory;
})(History);
})();

function install(aurelia) {
aurelia.withSingleton(History, BrowserHistory);
}

exports.BrowserHistory = BrowserHistory;
exports.install = install;
});
51 changes: 23 additions & 28 deletions dist/commonjs/index.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
"use strict";

var _extends = function (child, parent) {
child.prototype = Object.create(parent.prototype, {
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
child.__proto__ = parent;
if (parent) child.__proto__ = parent;
};

var History = require('aurelia-history').History;
var History = require("aurelia-history").History;
var routeStripper = /^[#\/]|\s+$/g;

var rootStripper = /^\/+|\/+$/g;
Expand All @@ -30,23 +33,8 @@ function updateHash(location, fragment, replace) {
}
}

function extend(obj) {
var rest = Array.prototype.slice.call(arguments, 1);

for (var i = 0, length = rest.length; i < length; i++) {
var source = rest[i];

if (source) {
for (var prop in source) {
obj[prop] = source[prop];
}
}
}

return obj;
}

var BrowserHistory = (function (History) {
var BrowserHistory = (function () {
var _History = History;
var BrowserHistory = function BrowserHistory() {
this.interval = 50;
this.active = false;
Expand All @@ -59,18 +47,20 @@ var BrowserHistory = (function (History) {
}
};

_extends(BrowserHistory, History);
_inherits(BrowserHistory, _History);

BrowserHistory.prototype.getHash = function (window) {
var match = (window || this).location.href.match(/#(.*)$/);
return match ? match[1] : "";
};

BrowserHistory.prototype.getFragment = function (fragment, forcePushState) {
var root;

if (!fragment) {
if (this._hasPushState || !this._wantsHashChange || forcePushState) {
fragment = this.location.pathname + this.location.search;
var root = this.root.replace(trailingSlash, "");
root = this.root.replace(trailingSlash, "");
if (!fragment.indexOf(root)) {
fragment = fragment.substr(root.length);
}
Expand All @@ -89,7 +79,7 @@ var BrowserHistory = (function (History) {

this.active = true;

this.options = extend({}, { root: "/" }, this.options, options);
this.options = Object.assign({}, { root: "/" }, this.options, options);
this.root = this.options.root;
this._wantsHashChange = this.options.hashChange !== false;
this._wantsPushState = !!this.options.pushState;
Expand All @@ -101,7 +91,7 @@ var BrowserHistory = (function (History) {

if (this._hasPushState) {
window.onpopstate = this._checkUrlCallback;
} else if (this._wantsHashChange && ("onhashchange" in window)) {
} else if (this._wantsHashChange && "onhashchange" in window) {
window.addEventListener("hashchange", this._checkUrlCallback);
} else if (this._wantsHashChange) {
this._checkUrlInterval = setInterval(this._checkUrlCallback, this.interval);
Expand Down Expand Up @@ -198,7 +188,7 @@ var BrowserHistory = (function (History) {
} else if (this._wantsHashChange) {
updateHash(this.location, fragment, options.replace);

if (this.iframe && (fragment !== this.getFragment(this.getHash(this.iframe)))) {
if (this.iframe && fragment !== this.getFragment(this.getHash(this.iframe))) {
if (!options.replace) {
this.iframe.document.open().close();
}
Expand All @@ -221,6 +211,11 @@ var BrowserHistory = (function (History) {
};

return BrowserHistory;
})(History);
})();

function install(aurelia) {
aurelia.withSingleton(History, BrowserHistory);
}

exports.BrowserHistory = BrowserHistory;
exports.BrowserHistory = BrowserHistory;
exports.install = install;
35 changes: 15 additions & 20 deletions dist/es6/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,7 @@ function updateHash(location, fragment, replace) {
}
}

function extend(obj) {
var rest = Array.prototype.slice.call(arguments, 1);

for (var i = 0, length = rest.length; i < length; i++) {
var source = rest[i];

if (source) {
for (var prop in source) {
obj[prop] = source[prop];
}
}
}

return obj;
}

export class BrowserHistory extends History {
class BrowserHistory extends History {
constructor(){
this.interval = 50;
this.active = false;
Expand All @@ -59,10 +43,12 @@ export class BrowserHistory extends History {
}

getFragment(fragment, forcePushState) {
var root;

if (!fragment) {
if (this._hasPushState || !this._wantsHashChange || forcePushState) {
fragment = this.location.pathname + this.location.search;
var root = this.root.replace(trailingSlash, '');
root = this.root.replace(trailingSlash, '');
if (!fragment.indexOf(root)) {
fragment = fragment.substr(root.length);
}
Expand All @@ -83,7 +69,7 @@ export class BrowserHistory extends History {

// Figure out the initial configuration. Do we need an iframe?
// Is pushState desired ... is it available?
this.options = extend({}, { root: '/' }, this.options, options);
this.options = Object.assign({}, { root: '/' }, this.options, options);
this.root = this.options.root;
this._wantsHashChange = this.options.hashChange !== false;
this._wantsPushState = !!this.options.pushState;
Expand Down Expand Up @@ -238,4 +224,13 @@ export class BrowserHistory extends History {
navigateBack() {
this.history.back();
}
}
}

function install(aurelia){
aurelia.withSingleton(History, BrowserHistory);
}

export {
BrowserHistory,
install
};
Loading

0 comments on commit 304995b

Please sign in to comment.