Skip to content

Commit f327c91

Browse files
committed
adding proper support for bodyClick
1 parent b2a6c7d commit f327c91

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/js/postmessage.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,17 @@ if (self != top) {
4747
};
4848
}
4949

50+
// if there are clicks on the iframe make sure the nav in the iframe parent closes
51+
var body = document.getElementsByTagName('body');
52+
body[0].onclick = function() {
53+
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
54+
var obj = JSON.stringify({ "event": "patternLab.bodyClick", "bodyclick": "bodyclick" });
55+
parent.postMessage(obj,targetOrigin);
56+
};
57+
5058
}
5159

52-
// if there are clicks on the iframe make sure the nav in the iframe parent closes
53-
var body = document.getElementsByTagName('body');
54-
body[0].onclick = function() {
55-
var targetOrigin = (window.location.protocol == "file:") ? "*" : window.location.protocol+"//"+window.location.host;
56-
var obj = JSON.stringify({ "event": "patternLab.bodyClick", "bodyclick": "bodyclick" });
57-
parent.postMessage(obj,targetOrigin);
58-
};
60+
5961

6062
// watch the iframe source so that it can be sent back to everyone else.
6163
function receiveIframeMessage(event) {

src/js/styleguide.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@
575575

576576
if (data.event !== undefined) {
577577

578-
if (data.event == "patternLab.bodyclick") {
578+
if (data.event == "patternLab.bodyClick") {
579579

580580
closePanels();
581581

0 commit comments

Comments
 (0)