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

Commit c0e8a42

Browse files
committed
showing the pattern state for the selected pattern
1 parent d3d3249 commit c0e8a42

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

public/styleguide/js/code-pattern.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var codePattern = {
5252
// if comments overlay is turned on add the has-comment class and pointer
5353
if (codePattern.codeOverlayActive) {
5454

55-
var obj = JSON.stringify({ "codeOverlay": "on", "lineage": lineage, "lineageR": lineageR, "codePatternPartial": patternPartial, "cssEnabled": cssEnabled });
55+
var obj = JSON.stringify({ "codeOverlay": "on", "lineage": lineage, "lineageR": lineageR, "patternPartial": patternPartial, "patternState": patternState, "cssEnabled": cssEnabled });
5656
parent.postMessage(obj,codePattern.targetOrigin);
5757

5858
} else if (codePattern.codeEmbeddedActive) {

public/styleguide/js/code-viewer.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ var codeViewer = {
253253
* when turning on or switching between patterns with code view on make sure we get
254254
* the code from from the pattern via post message
255255
*/
256-
updateCode: function(lineage,lineageR,patternPartial,cssEnabled) {
256+
updateCode: function(lineage,lineageR,patternPartial,patternState,cssEnabled) {
257257

258258
// clear any selections that might have been made
259259
codeViewer.clearSelection();
@@ -294,7 +294,17 @@ var codeViewer = {
294294
document.getElementById("sg-viewport").contentWindow.postMessage(obj,codeViewer.targetOrigin);
295295
});
296296

297-
$('#sg-code-lineage-patternname, #sg-code-lineager-patternname').html(patternPartial);
297+
// show pattern state
298+
if (patternState != "") {
299+
$("#sg-code-patternstate").css("display","block");
300+
var patternStateItem = "<span class=\"sg-pattern-state "+patternState+"\">"+patternState+"</span>";
301+
$("#sg-code-patternstate-fill").html(patternStateItem);
302+
} else {
303+
$("#sg-code-patternstate").css("display","none");
304+
}
305+
306+
// fill in the name of the pattern
307+
$('#sg-code-lineage-patternname, #sg-code-lineager-patternname, #sg-code-patternstate-patternname').html(patternPartial);
298308

299309
// get the file name of the pattern so we can get the various editions of the code that can show in code view
300310
var fileName = urlHandler.getFileName(patternPartial);
@@ -343,7 +353,7 @@ var codeViewer = {
343353
// switch based on stuff related to the postmessage
344354
if (data.codeOverlay !== undefined) {
345355
if (data.codeOverlay === "on") {
346-
codeViewer.updateCode(data.lineage,data.lineageR,data.codePatternPartial,data.cssEnabled);
356+
codeViewer.updateCode(data.lineage,data.lineageR,data.patternPartial,data.patternState,data.cssEnabled);
347357
} else {
348358
codeViewer.slideCode($('#sg-code-container').outerHeight());
349359
}

0 commit comments

Comments
 (0)