Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 8dc5bc5

Browse files
committed
re-instated the webkit-friendly history pattern
1 parent ea07acb commit 8dc5bc5

File tree

3 files changed

+6
-106
lines changed

3 files changed

+6
-106
lines changed

public/styleguide/js/url-handler.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,20 +119,20 @@ var urlHandler = {
119119
* @param {String} the shorthand partials syntax for a given pattern
120120
*/
121121
pushPattern: function (pattern) {
122+
console.log("pushed");
122123
var data = { "pattern": pattern };
123-
history.pushState(data, "", "/?p="+pattern);
124+
history.pushState(data, "", window.location.protocol+"//"+window.location.host+window.location.pathname+"?p="+pattern);
124125
},
125126

126127
/**
127128
* based on a click forward or backward modify the url and iframe source
128129
* @param {Object} event info like state and properties set in pushState()
129130
*/
130-
popPattern: function () {
131+
popPattern: function (e) {
131132

132-
var state = history.state;
133+
var state = e.state;
133134

134135
if (state == null) {
135-
alert("null state");
136136
var rVars = this.getRequestVars();
137137
if ((rVars.p != undefined) || (rVars.pattern != undefined)) {
138138
var patternName = (rVars.p != undefined) ? rVars.p : rVars.pattern;
@@ -141,7 +141,6 @@ var urlHandler = {
141141
return;
142142
}
143143
} else if (state != null) {
144-
alert(state.pattern);
145144
var patternName = state.pattern;
146145
}
147146

@@ -157,21 +156,14 @@ var urlHandler = {
157156
wsn.send( '{"url": "'+iFramePath+'", "patternpartial": "'+patternName+'" }' );
158157
}
159158

160-
},
161-
162-
init: function () {
163-
urlHandler.skipBack = true;
164-
urlHandler.popPattern();
165159
}
166160

167161
}
168162

169163
/**
170164
* handle the onpopstate event
171165
*/
172-
window.addEventListener("popstate", urlHandler.init, false);
173-
174-
/*window.onpopstate = function (event) {
166+
window.onpopstate = function (event) {
175167
urlHandler.skipBack = true;
176168
urlHandler.popPattern(event);
177-
}*/
169+
}

public/test.html

Lines changed: 0 additions & 47 deletions
This file was deleted.

public/test2.html

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)