diff --git a/js/hopscotch-0.1.js b/js/hopscotch-0.1.js index 09a6d45e..7c188c94 100644 --- a/js/hopscotch-0.1.js +++ b/js/hopscotch-0.1.js @@ -568,11 +568,11 @@ boundingRect, top, left, + arrowOffset, bubbleBorder = 6, targetEl = utils.getStepTarget(step), el = this.element, - arrowEl = this.arrowEl, - arrowOffset = utils.getPixelValue(step.arrowOffset); + arrowEl = this.arrowEl; bubbleWidth = utils.getPixelValue(step.width) || this.opt.bubbleWidth; bubblePadding = utils.valOrDefault(step.padding, this.opt.bubblePadding); @@ -605,17 +605,36 @@ } // SET (OR RESET) ARROW OFFSETS + if (step.arrowOffset !== 'center') { + arrowOffset = utils.getPixelValue(step.arrowOffset); + } + else { + arrowOffset = step.arrowOffset; + } if (!arrowOffset) { arrowEl.style.top = ''; arrowEl.style.left = ''; } else if (step.placement === 'top' || step.placement === 'bottom') { arrowEl.style.top = ''; - arrowEl.style.left = arrowOffset + 'px'; + if (arrowOffset === 'center') { + arrowEl.style.left = bubbleWidth/2 - this.opt.arrowWidth/2 + 'px'; + } + else { + // Numeric pixel value + arrowEl.style.left = arrowOffset + 'px'; + } } else if (step.placement === 'left' || step.placement === 'right') { arrowEl.style.left = ''; - arrowEl.style.top = arrowOffset + 'px'; + if (arrowOffset === 'center') { + bubbleHeight = bubbleHeight || el.offsetHeight; + arrowEl.style.top = bubbleHeight/2 - this.opt.arrowWidth/2 + 'px'; + } + else { + // Numeric pixel value + arrowEl.style.top = arrowOffset + 'px'; + } } // HORIZONTAL OFFSET diff --git a/js/hopscotch-0.1.min.js b/js/hopscotch-0.1.min.js index 6ab09b8a..6ae1ce10 100644 --- a/js/hopscotch-0.1.min.js +++ b/js/hopscotch-0.1.min.js @@ -1,37 +1,37 @@ -(function(u,v){var w,x,C,D,y,E=window.Sizzle||null,b,r,n,p,j=u[v],F=!1,G="undefined"!==typeof window.jQuery,s="undefined"!==typeof window.sessionStorage,h=window.document;p={smoothScroll:!0,scrollDuration:1E3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,cookieName:"hopscotch.tour.state"};j||(Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),b={addClass:function(a, +(function(u,v){var w,x,C,D,y,E=window.Sizzle||null,b,r,n,p,k=u[v],F=!1,G="undefined"!==typeof window.jQuery,s="undefined"!==typeof window.sessionStorage,h=window.document;p={smoothScroll:!0,scrollDuration:1E3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,cookieName:"hopscotch.tour.state"};k||(Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),b={addClass:function(a, b){var c,e,d,i;if(a.className){e=b.split(/\s+/);c=" "+a.className+" ";d=0;for(i=e.length;dc.indexOf(" "+e[d]+" ")&&(c+=e[d]+" ");a.className=c.replace(/^\s+|\s+$/g,"")}else a.className=b},removeClass:function(a,b){var c,e,d,i;e=b.split(/\s+/);c=" "+a.className+" ";d=0;for(i=e.length;dg||g>=i.steps.length?null:i.steps[g]},u=function(){f.nextStep(!1)},B=function(a,c){var e,f,d;0<=g+a&&g+af?e:f,d=b.getScrollTop(),f=d+b.getWindowHeight(),g=a-l("scrollTopMargin"),z,i,A;a>=d&&(a<=d+l("scrollTopMargin")||e<= -f)?k&&k():l("smoothScroll")?"undefined"!==typeof YAHOO&&"undefined"!==typeof YAHOO.env&&"undefined"!==typeof YAHOO.env.ua&&"undefined"!==typeof YAHOO.util&&"undefined"!==typeof YAHOO.util.Scroll?(a=YAHOO.env.ua.webkit?h.body:h.documentElement,e=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:void 0,a=new YAHOO.util.Scroll(a,{scroll:{to:[0,g]}},l("scrollDuration")/1E3,e),a.onComplete.subscribe(k),a.animate()):G?$("body, html").animate({scrollTop:g},l("scrollDuration"),k):(0>g&&(g=0),z=d>a?-1:1,i=Math.abs(d- -g)/(l("scrollDuration")/10),A=function(){var a=b.getScrollTop(),c=a+z*i;0=g||0>z&&c<=g?(c=g,k&&k(),window.scrollTo(0,c)):(window.scrollTo(0,c),b.getScrollTop()===a?k&&k():setTimeout(A,10))},A()):(window.scrollTo(0,g),k&&k())}else k();c.nextOnTargetClick&&b.addEvtListener(j,"click",u)});c.multipage&&(f+=":mp");b.setState(l("cookieName"),f,1)};this.getCalloutManager=function(){"undefined"===typeof e&&(e=new C);return e};this.startTour=function(a,c){var e,f=this;if(!i){i=a;var d={},h;for(h in a)a.hasOwnProperty(h)&& -("id"!==h&&"steps"!==h)&&(d[h]=a[h]);s.call(this,d,!0);if(d=b.getState(l("cookieName")))d=d.split(":"),j=d[0],m=d[1],m=parseInt(m,10),2=i.steps.length)throw"Specified step number out of bounds.";g=c}if(!b.documentIsReady())return F=!0,this;!g&&i.id===j&&"undefined"!==typeof m?g=m:g||(g=0);a:{var d=function(a){-1!==a&&b.getStepTarget(i.steps[a])?(b.invokeEventCallbacks("start"),e=t(),e.hide(!1),f.isActive=!0,b.getStepTarget(q())? -f.showStep(a):(b.invokeEventCallbacks("error"),l("skipIfNoElement")&&f.nextStep(!1))):f.endTour(!1,!1)},k;h=!1;g=g||0;k=q();if(k=b.getStepTarget(k))d(g);else{if(0g||g>=i.steps.length?null:i.steps[g]},u=function(){f.nextStep(!1)},B=function(a,c){var e,f,d;0<=g+a&&g+af?e:f,d=b.getScrollTop(),f=d+b.getWindowHeight(),g=a-l("scrollTopMargin"),z,i,A;a>=d&&(a<=d+l("scrollTopMargin")||e<=f)?j&&j():l("smoothScroll")?"undefined"!==typeof YAHOO&&"undefined"!==typeof YAHOO.env&&"undefined"!==typeof YAHOO.env.ua&&"undefined"!==typeof YAHOO.util&&"undefined"!==typeof YAHOO.util.Scroll?(a=YAHOO.env.ua.webkit?h.body:h.documentElement,e=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:void 0,a=new YAHOO.util.Scroll(a,{scroll:{to:[0,g]}}, +l("scrollDuration")/1E3,e),a.onComplete.subscribe(j),a.animate()):G?$("body, html").animate({scrollTop:g},l("scrollDuration"),j):(0>g&&(g=0),z=d>a?-1:1,i=Math.abs(d-g)/(l("scrollDuration")/10),A=function(){var a=b.getScrollTop(),c=a+z*i;0=g||0>z&&c<=g?(c=g,j&&j(),window.scrollTo(0,c)):(window.scrollTo(0,c),b.getScrollTop()===a?j&&j():setTimeout(A,10))},A()):(window.scrollTo(0,g),j&&j())}else j();c.nextOnTargetClick&&b.addEvtListener(k,"click",u)});c.multipage&&(f+=":mp");b.setState(l("cookieName"), +f,1)};this.getCalloutManager=function(){"undefined"===typeof e&&(e=new C);return e};this.startTour=function(a,c){var e,f=this;if(!i){i=a;var d={},h;for(h in a)a.hasOwnProperty(h)&&("id"!==h&&"steps"!==h)&&(d[h]=a[h]);s.call(this,d,!0);if(d=b.getState(l("cookieName")))d=d.split(":"),k=d[0],m=d[1],m=parseInt(m,10),2=i.steps.length)throw"Specified step number out of bounds.";g=c}if(!b.documentIsReady())return F=!0,this;!g&& +i.id===k&&"undefined"!==typeof m?g=m:g||(g=0);a:{var d=function(a){-1!==a&&b.getStepTarget(i.steps[a])?(b.invokeEventCallbacks("start"),e=t(),e.hide(!1),f.isActive=!0,b.getStepTarget(q())?f.showStep(a):(b.invokeEventCallbacks("error"),l("skipIfNoElement")&&f.nextStep(!1))):f.endTour(!1,!1)},j;h=!1;g=g||0;j=q();if(j=b.getStepTarget(j))d(g);else{if(0