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

Commit d888fd5

Browse files
committed
fixing bug with viewall pages and history
1 parent 3b47006 commit d888fd5

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

builder/lib/builder.lib.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ protected function generateViewAllPages() {
214214

215215
// get all the rendered partials that match
216216
$sid = $this->gatherPartialsByMatch($patternType, $patternSubType);
217+
$sid["patternPartial"] = $subItem["patternPartial"];
217218

218219
// render the viewall template
219220
$v = $this->mfs->render('viewall',$sid);

public/styleguide/js/styleguide.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ function receiveIframeMessage(event) {
503503
} else if (event.data.patternpartial != undefined) {
504504

505505
if (!urlHandler.skipBack) {
506-
507506
var iFramePath = urlHandler.getFileName(event.data.patternpartial);
508507
urlHandler.pushPattern(event.data.patternpartial);
509508
if (wsnConnected) {

public/styleguide/js/url-handler.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,14 @@ var urlHandler = {
119119
* @param {String} the shorthand partials syntax for a given pattern
120120
*/
121121
pushPattern: function (pattern) {
122-
console.log("pushed");
123122
var data = { "pattern": pattern };
124-
history.pushState(data, "", window.location.protocol+"//"+window.location.host+window.location.pathname+"?p="+pattern);
123+
var path = window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+urlHandler.getFileName(pattern);
124+
if (document.getElementById("sg-viewport").contentWindow.location.toString() != path) {
125+
urlHandler.skipBack = true;
126+
document.getElementById("sg-viewport").contentWindow.location.replace(path);
127+
} else {
128+
history.pushState(data, "", window.location.protocol+"//"+window.location.host+window.location.pathname.replace("index.html","")+"?p="+pattern);
129+
}
125130
},
126131

127132
/**

source/_patternlab-files/viewall.mustache

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,23 @@
2424

2525
</div><!--end .sg-main-->
2626
<script>
27+
2728
var body = document.getElementsByTagName('body');
2829
body[0].onclick = function() {
29-
parent.postMessage({"bodyclick":"bodyclick"},window.location.protocol+"//"+window.location.host)
30+
parent.postMessage( { "bodyclick":"bodyclick" }, window.location.protocol+"//"+window.location.host)
3031
};
32+
3133
var els = document.getElementsByClassName("patternLink");
3234
for (i in els) {
3335
els[i].onclick = function() {
34-
parent.postMessage({"patternpartial":this.getAttribute("data-patternpartial")},window.location.protocol+"//"+window.location.host);
36+
parent.postMessage( { "patternpartial": this.getAttribute("data-patternpartial") }, window.location.protocol+"//"+window.location.host);
3537
return false;
3638
}
3739
}
40+
41+
// alert the iframe parent that the pattern has loaded. for page follow.
42+
parent.postMessage( { "url": window.location.host, "patternpartial": "{{ patternPartial }}" },window.location.protocol+"//"+window.location.host);
43+
3844
</script>
3945
</body>
4046
</html>

0 commit comments

Comments
 (0)