Skip to content

Commit 8b9a031

Browse files
committed
better handling of when/how to hide highlights
1 parent f412a2e commit 8b9a031

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

dist/styleguide/js/patternlab-pattern.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ var modalStyleguide = {
403403
var el = document.getElementById('sg-pattern-data-'+patternPartial);
404404
modalStyleguide.collectAndSend(el, true, false);
405405
} else {
406+
modalStyleguide.highlightsHide();
406407
modalStyleguide.close(patternPartial);
407408
}
408409

@@ -474,6 +475,21 @@ var modalStyleguide = {
474475
}
475476
},
476477

478+
/**
479+
* hide the highlights
480+
*/
481+
highlightsHide: function(patternPartial) {
482+
var patternPartialSelector = (patternPartial !== undefined) ? '#'+patternPartial+" > " : "";
483+
elsToHide = document.querySelectorAll(patternPartialSelector+'.has-annotation');
484+
for (i = 0; i < elsToHide.length; i++) {
485+
elsToHide[i].classList.remove('has-annotation');
486+
}
487+
elsToHide = document.querySelectorAll(patternPartialSelector+'.annotation-tip');
488+
for (i = 0; i < elsToHide.length; i++) {
489+
elsToHide[i].style.display = 'none';
490+
}
491+
},
492+
477493
/**
478494
* return the pattern info to the top level
479495
* @param {Object} the content that will be sent to the viewer for rendering
@@ -576,14 +592,7 @@ var modalStyleguide = {
576592

577593
} else if ((data.event !== undefined) && (data.event == 'patternLab.annotationsHighlightHide')) {
578594

579-
elsToHide = document.querySelectorAll('.has-annotation');
580-
for (i = 0; i < elsToHide.length; i++) {
581-
elsToHide[i].classList.remove('has-annotation');
582-
}
583-
elsToHide = document.querySelectorAll('.annotation-tip');
584-
for (i = 0; i < elsToHide.length; i++) {
585-
elsToHide[i].style.display = 'none';
586-
}
595+
modalStyleguide.highlightsHide();
587596

588597
} else if ((data.event !== undefined) && (data.event == 'patternLab.patternModalClose')) {
589598

dist/styleguide/js/patternlab-pattern.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)