Skip to content

Commit db7545c

Browse files
committed
Replace _dehighlightElement() with _removeHighlight() and call it in key places.
Note that hideAll() was often called before _dehighlightElement(). So it makes sense to ensure that the highlight is cleared in hideAll(). I also remove the highlight before setting the next one, and in the top of show().
1 parent 349bbd5 commit db7545c

1 file changed

Lines changed: 8 additions & 14 deletions

File tree

guiders.js

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -258,18 +258,19 @@ var guiders = (function($) {
258258
return myGuider;
259259
};
260260

261-
guiders._dehighlightElement = function(selector) {
262-
$(selector).removeClass('guiders_highlight');
263-
};
264-
265261
guiders._hideOverlay = function() {
266262
$("#guiders_overlay").fadeOut("fast");
267263
};
268264

269265
guiders._highlightElement = function(selector) {
266+
guiders._removeHighlight();
270267
$(selector).addClass('guiders_highlight');
271268
};
272269

270+
guiders._removeHighlight = function () {
271+
$(".guiders_highlight").removeClass('guiders_highlight');
272+
};
273+
273274
guiders._initializeOverlay = function() {
274275
if ($("#guiders_overlay").length === 0) {
275276
$("<div id='guiders_overlay'></div>").hide().appendTo("body");
@@ -482,6 +483,7 @@ var guiders = (function($) {
482483

483484
guiders.hideAll = function(omitHidingOverlay, next) {
484485
next = next || false;
486+
guiders._removeHighlight();
485487

486488
$(".guider:visible").each(function(index, elem){
487489
var myGuider = guiders.get($(elem).attr('id'));
@@ -490,10 +492,6 @@ var guiders = (function($) {
490492
}
491493
});
492494
$(".guider").fadeOut("fast");
493-
var currentGuider = guiders.getCurrentGuider();
494-
if (currentGuider && currentGuider.highlight) {
495-
guiders._dehighlightElement(currentGuider.highlight);
496-
}
497495
if (typeof omitHidingOverlay !== "undefined" && omitHidingOverlay === true) {
498496
// do nothing for now
499497
} else {
@@ -516,9 +514,6 @@ var guiders = (function($) {
516514
var nextGuider = guiders.get(nextGuiderId);
517515
var omitHidingOverlay = nextGuider.overlay ? true : false;
518516
guiders.hideAll(omitHidingOverlay, true);
519-
if (currentGuider && currentGuider.highlight) {
520-
guiders._dehighlightElement(currentGuider.highlight);
521-
}
522517

523518
if (nextGuider.shouldSkip && nextGuider.shouldSkip()) {
524519
guiders._currentGuiderID = nextGuider.id;
@@ -554,9 +549,6 @@ var guiders = (function($) {
554549
var myGuider = guiders.get(prevGuiderId);
555550
var omitHidingOverlay = myGuider.overlay ? true : false;
556551
guiders.hideAll(omitHidingOverlay, true);
557-
if (prevGuider && prevGuider.highlight) {
558-
guiders._dehighlightElement(prevGuider.highlight);
559-
}
560552

561553
// Trigger before show to allow observers to change the
562554
// DOM before the new guider calculates its position
@@ -594,6 +586,8 @@ var guiders = (function($) {
594586
}
595587

596588
var myGuider = guiders.get(id);
589+
guiders._removeHighlight();
590+
597591
if (myGuider.overlay) {
598592
guiders._showOverlay(myGuider);
599593
// if guider is attached to an element, make sure it's visible

0 commit comments

Comments
 (0)