Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made a handful of changes and a couple of bug fixes #116

Open
wants to merge 14 commits into
base: dev
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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().
  • Loading branch information
majorcode committed Feb 19, 2014
commit db7545c38ccc44919f6504b4708de001c583eb3e
22 changes: 8 additions & 14 deletions guiders.js
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,19 @@ var guiders = (function($) {
return myGuider;
};

guiders._dehighlightElement = function(selector) {
$(selector).removeClass('guiders_highlight');
};

guiders._hideOverlay = function() {
$("#guiders_overlay").fadeOut("fast");
};

guiders._highlightElement = function(selector) {
guiders._removeHighlight();
$(selector).addClass('guiders_highlight');
};

guiders._removeHighlight = function () {
$(".guiders_highlight").removeClass('guiders_highlight');
};

guiders._initializeOverlay = function() {
if ($("#guiders_overlay").length === 0) {
$("<div id='guiders_overlay'></div>").hide().appendTo("body");
Expand Down Expand Up @@ -482,6 +483,7 @@ var guiders = (function($) {

guiders.hideAll = function(omitHidingOverlay, next) {
next = next || false;
guiders._removeHighlight();

$(".guider:visible").each(function(index, elem){
var myGuider = guiders.get($(elem).attr('id'));
Expand All @@ -490,10 +492,6 @@ var guiders = (function($) {
}
});
$(".guider").fadeOut("fast");
var currentGuider = guiders.getCurrentGuider();
if (currentGuider && currentGuider.highlight) {
guiders._dehighlightElement(currentGuider.highlight);
}
if (typeof omitHidingOverlay !== "undefined" && omitHidingOverlay === true) {
// do nothing for now
} else {
Expand All @@ -516,9 +514,6 @@ var guiders = (function($) {
var nextGuider = guiders.get(nextGuiderId);
var omitHidingOverlay = nextGuider.overlay ? true : false;
guiders.hideAll(omitHidingOverlay, true);
if (currentGuider && currentGuider.highlight) {
guiders._dehighlightElement(currentGuider.highlight);
}

if (nextGuider.shouldSkip && nextGuider.shouldSkip()) {
guiders._currentGuiderID = nextGuider.id;
Expand Down Expand Up @@ -554,9 +549,6 @@ var guiders = (function($) {
var myGuider = guiders.get(prevGuiderId);
var omitHidingOverlay = myGuider.overlay ? true : false;
guiders.hideAll(omitHidingOverlay, true);
if (prevGuider && prevGuider.highlight) {
guiders._dehighlightElement(prevGuider.highlight);
}

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

var myGuider = guiders.get(id);
guiders._removeHighlight();

if (myGuider.overlay) {
guiders._showOverlay(myGuider);
// if guider is attached to an element, make sure it's visible
Expand Down