Permalink
Browse files

feat #441 history enhancement

Singleton class aria.utils.History provides a cross-browser implementation of HTML5 native history API. With respect to the previous version, this one is more compliant with the standard behaviour:

- the onpopstate class event is not raised after a pushState or replaceState.
- the state property is available on the singleton and it corresponds to window.history.state.
- support for page reload and external navigation is supported also in browsers for which hash-based navigation fallback occurs (with the exception of IE7, for which the previous history is not kept after reloading, but only the current state is available).

However, the new version is backward compatible with the previous one. In order to disable backward compatibility, set aria.utils.History.isBackwardCompatible to false right after loading the class.
  • Loading branch information...
1 parent be08a8e commit 26779d7c8b934b441ebabdd6a262b8f8b1f8dcd8 @flongo committed Mar 28, 2013
Showing with 1,245 additions and 2,030 deletions.
  1. +2 −1 src/aria/utils/Event.js
  2. +6 −5 src/aria/utils/FrameATLoader.js
  3. +1 −1 src/aria/utils/FrameATLoaderHTML.html
  4. +709 −1,850 src/aria/utils/History.js
  5. +527 −173 test/aria/utils/History.js
View
@@ -87,7 +87,7 @@
// call unload listeners
// Keep a local copy of the reference to unloadListeners because it is possible that a listener calls
// aria.utils.Event.reset (that's what AriaWindow is doing).
- var list = unloadListeners;
+ var list = unloadListeners.slice();
for (var i = 0, len = list.length; i < len; ++i) {
var l = list[i];
if (l) {
@@ -96,6 +96,7 @@
l = null;
}
}
+ list = null;
},
/**
@@ -69,7 +69,8 @@ Aria.classDefinition({
/**
* Load Aria Templates in the given frame and call the callback. This replaces the content of the frame.
* @param {DOMElement} frame frame
- * @param {aria.core.CfgBeans.Callback} cb callback. The first argument is an object containing success information.
+ * @param {aria.core.CfgBeans.Callback} cb callback. The first argument is an object containing success
+ * information.
*/
loadAriaTemplatesInFrame : function (frame, cb) {
this.loadBootstrap({
@@ -101,7 +102,7 @@ Aria.classDefinition({
});
var docUrl = [aria.core.DownloadMgr.resolveURL("aria/utils/FrameATLoaderHTML.html"), '?',
encodeURIComponent(Aria.$frameworkWindow.location.href.replace(/(\?|\#).*$/, "")), '#', callbackId].join('');
- var window = args.frame.contentWindow;
+ var window = args.frame.contentWindow || args.frame;
window.location = docUrl;
},
@@ -111,14 +112,14 @@ Aria.classDefinition({
* @param {Object} args object containing the frame and callback
*/
_loadATInFrameCb2 : function (res, args) {
- var window = args.frame.contentWindow;
+ var window = args.frame.contentWindow || args.frame;
var document = window.document;
var iFrameAria = window.Aria;
iFrameAria.rootFolderPath = this.bootRootFolderPath;
iFrameAria.debug = Aria.debug;
iFrameAria.memCheckMode = Aria.memCheckMode;
window.Aria["eval"](this.frameworkJS); // note that using window.eval leads to strange errors in FF
- document.write('<script type="text/javascript">parent.aria.utils.FrameATLoader.callFromFrame('
+ document.write('<script type="text/javascript">(opener || parent).aria.utils.FrameATLoader.callFromFrame('
+ this._createCallbackId({
fn : this._loadATInFrameCb3,
scope : this,
@@ -132,7 +133,7 @@ Aria.classDefinition({
* @param {Object} args object containing the frame and callback
*/
_loadATInFrameCb3 : function (res, args) {
- var window = args.frame.contentWindow;
+ var window = args.frame.contentWindow || args.frame;
if (window.aria == null) {
this.$callback(args.cb, {
success : false
@@ -20,7 +20,7 @@
var hash = window.location.hash.substring(1);
window.location.hash = "";
- parent.aria.utils.FrameATLoader.callFromFrame(hash);
+ (opener || parent).aria.utils.FrameATLoader.callFromFrame(hash);
})()
</script>
</body>
Oops, something went wrong.

0 comments on commit 26779d7

Please sign in to comment.