Skip to content

Commit

Permalink
Merge pull request pickhardt#51 from mikz/attach_to
Browse files Browse the repository at this point in the history
handle guiders without existing attachTo element exactly as without attachTo
  • Loading branch information
Jeff Pickhardt committed May 24, 2012
2 parents 4709299 + ec5a961 commit 8a3c78e
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions guiders-1.2.3.js
Expand Up @@ -120,17 +120,15 @@ var guiders = (function($) {
var myHeight = myGuider.elem.innerHeight();
var myWidth = myGuider.elem.innerWidth();

if (myGuider.position === 0 || myGuider.attachTo === null) {
var attachTo = $(myGuider.attachTo);

if (myGuider.position === 0 || attachTo.length === 0) {
myGuider.elem.css("position", "absolute");
myGuider.elem.css("top", ($(window).height() - myHeight) / 3 + $(window).scrollTop() + "px");
myGuider.elem.css("left", ($(window).width() - myWidth) / 2 + $(window).scrollLeft() + "px");
return;
}

var attachTo = $(myGuider.attachTo);
if (attachTo.length === 0) {
return;
}

var base = attachTo.offset();
var attachToHeight = attachTo.innerHeight();
var attachToWidth = attachTo.innerWidth();
Expand Down Expand Up @@ -167,7 +165,7 @@ var guiders = (function($) {
left += myGuider.offset.left;
}

myGuider.elem.css({
return myGuider.elem.css({
"position": "absolute",
"top": top,
"left": left
Expand Down Expand Up @@ -325,8 +323,7 @@ var guiders = (function($) {

// Ensure myGuider.attachTo is a jQuery element.
if (typeof myGuider.attachTo !== "undefined" && myGuider !== null) {
guiders._attach(myGuider);
guiders._styleArrow(myGuider);
guiders._attach(myGuider) && guiders._styleArrow(myGuider);
}

guiders._initializeOverlay();
Expand Down

0 comments on commit 8a3c78e

Please sign in to comment.