Skip to content

Instantly share code, notes, and snippets.

@c9s
Created June 25, 2009 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c9s/135815 to your computer and use it in GitHub Desktop.
Save c9s/135815 to your computer and use it in GitHub Desktop.
Index: share/plugins/Jifty/Plugin/SinglePage/web/static/js/singlepage/spa.js
===================================================================
--- share/plugins/Jifty/Plugin/SinglePage/web/static/js/singlepage/spa.js (revision 6773)
+++ share/plugins/Jifty/Plugin/SinglePage/web/static/js/singlepage/spa.js (working copy)
@@ -7,18 +7,49 @@
}
});
+//
+// first load.
+// reload.
+// click and back
+//
(function($) {
+ console.log('SPA init');
SPA = {
initialHash: null,
historyChange: function(newLocation, historyData, first) {
+ //console.info('history change');
+ //console.log( 'new location:' + newLocation );
+ //console.log( 'new historyData:' + historyData );
+ //console.log( 'new first:' + first );
if (first) {
dhtmlHistory.add(newLocation, historyData);
} else {
if (historyStorage.hasKey(newLocation)) {
+ console.info( 'historyStorage.hasKey:' + newLocation );
Jifty.update(historyStorage.get(newLocation), "");
- } else {
- Jifty.update({ "continuation": {}, "actions": {}, "fragments": [ { "mode": "Replace", "args": {}, "region": "__page", "path": SPA.initialHash } ], "action_arguments":{} }, "");
+ }
+ else if( newLocation ) {
+ Jifty.update({
+ "continuation": {}, "actions": {},
+ "fragments": [ {
+ "mode": "Replace",
+ "args": {},
+ "region": "__page",
+ "path": newLocation }
+ ],
+ "action_arguments":{}
+ }, "" );
}
+ else {
+ console.info( 'jifyt update empty');
+ Jifty.update({
+ "continuation": {}, "actions": {},
+ "fragments": [ { "mode": "Replace", "args": {},
+ "region": "__page",
+ "path": SPA.initialHash } ],
+ "action_arguments":{} }, ""
+ );
+ }
}
},
_sp_submit_form: function(elt, event, submit_to) {
@@ -68,9 +99,14 @@
};
$(document).ready(function(){
+ //console.log( 'document ready' );
+
SPA.initialHash = location.pathname + location.search;
+ //console.log( 'pathname:' + location.pathname + ' search:' + location.search + ' hash:' + location.hash );
dhtmlHistory.initialize();
dhtmlHistory.addListener(SPA.historyChange);
+
+
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment