diff --git a/js/hopscotch-0.0.4.js b/js/hopscotch-0.0.4.js index a3323773..6dc0fd9d 100644 --- a/js/hopscotch-0.0.4.js +++ b/js/hopscotch-0.0.4.js @@ -1297,6 +1297,7 @@ var bubble = getBubble(), self = this, step, + origStep, origStepNum, wasMultiPage, changeStepCb; @@ -1305,8 +1306,9 @@ doCallbacks = utils.valOrDefault(doCallbacks, true); step = getCurrStep(); - wasMultiPage = step.multipage; + origStep = step; origStepNum = currStepNum; + wasMultiPage = step.multipage; /** * Callback for goToStepWithTarget @@ -1321,11 +1323,11 @@ if (doCallbacks) { // Step-specific callbacks - if (direction > 0 && step.onNext) { - step.onNext(); + if (direction > 0 && origStep.onNext) { + origStep.onNext(); } - else if (direction < 0 && step.onPrev) { - step.onPrev(); + else if (direction < 0 && origStep.onPrev) { + origStep.onPrev(); } // Tour-wide next/prev callbacks @@ -1352,7 +1354,7 @@ utils.invokeCallbacks('error', [currTour.id, currStepNum]); return this.endTour(true, false); } - this.changeStepCb(currStepNum); + changeStepCb(currStepNum); } return this; diff --git a/js/hopscotch-0.0.4.min.js b/js/hopscotch-0.0.4.min.js index 06c8ad8f..5df9c7df 100644 --- a/js/hopscotch-0.0.4.min.js +++ b/js/hopscotch-0.0.4.min.js @@ -1,32 +1 @@ -(function(t,u){var k,v,z,l,b,p,i=t[u],A=!1,q={animate:!1,smoothScroll:!0,scrollDuration:1E3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,cookieName:"hopscotch.tour.state"},x="undefined"!==typeof window.jQuery,r="undefined"!==typeof window.sessionStorage;k=document.body.style;var B="undefined"!==typeof k.MozTransition||"undefined"!==typeof k.MsTransition||"undefined"!==typeof k.webkitTransition||"undefined"!== -typeof k.OTransition||"undefined"!==typeof k.transition;i||(k=function(){A&&i.startTour()},window.addEventListener?window.addEventListener("load",k,!1):window.attachEvent&&window.attachEvent("onload",k),b={addClass:function(a,e){var b,d,f;if(0===a.className.length)a.className=e;else{b=a.className.split(/\s+/);d=0;for(f=b.length;dg||g>=h.steps.length?null:h.steps[g]},t=function(){e.nextStep(!1)},y=function(a,d){var f,c;0<=g+a&&g+ad&&e.onPrev)e.onPrev();b.invokeCallbacks(0g?d:g,h=b.getScrollTop(),g=h+b.getWindowHeight(),m=e-f.scrollTopMargin,w,k,l;e>=h&&(e<=h+f.scrollTopMargin||d<=g)?a&&a():f.smoothScroll?"undefined"!==typeof YAHOO&&"undefined"!==typeof YAHOO.env&& -"undefined"!==typeof YAHOO.env.ua&&"undefined"!==typeof YAHOO.util&&"undefined"!==typeof YAHOO.util.Scroll?(e=YAHOO.env.ua.webkit?document.body:document.documentElement,d=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:void 0,e=new YAHOO.util.Scroll(e,{scroll:{to:[0,m]}},f.scrollDuration/1E3,d),e.onComplete.subscribe(a),e.animate()):x?$("body, html").animate({scrollTop:m},f.scrollDuration,a):(0>m&&(m=0),w=h>e?-1:1,k=Math.abs(h-m)/(f.scrollDuration/10),l=function(){var c=b.getScrollTop(),d=c+w*k;0=m||0>w&&d<=m?(d=m,a&&a(),window.scrollTo(0,d)):(window.scrollTo(0,d),b.getScrollTop()===c?a&&a():setTimeout(l,10))},l()):(window.scrollTo(0,m),a&&a());if(c.onShow)c.onShow();c.nextOnTargetClick&&b.addClickListener(j,t)});b.invokeCallbacks("show",[h.id,g]);c.multipage&&(e+=":mp");b.setState(f.cookieName,e,1)},c.delay||0);return this};this.prevStep=function(a){u.call(this,a,-1);return this};this.nextStep=function(a){var c=n(),d=b.getStepTarget(c);c.nextOnTargetClick&&b.removeClickListener(d,t);u.call(this, -a,1);return this};this.endTour=function(a,c){var d=s(),a=b.valOrDefault(a,!0),c=b.valOrDefault(c,!0);g=0;j=void 0;d.hide();a&&b.clearState(f.cookieName);i.isActive=!1;h&&c&&b.invokeCallbacks("end",[h.id]);i.removeCallbacks(!0);h=null;return this};this.getCurrTour=function(){return h};this.getCurrStepNum=function(){return g};this.listen=function(a,b,c){a&&b&&p[a].push({cb:b,fromTour:c});return this};this.removeCallback=function(a,b){var c=p[a],d,e;d=0;for(e=c.length;d=0){l.addClass(r,"prev")}else{l.addClass(r,"next")}return r},setPosition:function(u){var z,r,x,t,y,v,w=6,C=l.getStepTarget(u),s=this.element,B=this.arrowEl,A=l.getPixelValue(u.arrowOffset);z=l.getPixelValue(u.width)||this.opt.bubbleWidth;x=l.valOrDefault(u.padding,this.opt.bubblePadding);l.removeClass(s,"fade-in-down fade-in-up fade-in-left fade-in-right");t=C.getBoundingClientRect();if(u.orientation==="top"){r=s.offsetHeight;y=(t.top-r)-this.opt.arrowWidth;v=t.left}else{if(u.orientation==="bottom"){y=t.bottom+this.opt.arrowWidth;v=t.left}else{if(u.orientation==="left"){y=t.top;v=t.left-z-2*x-2*w-this.opt.arrowWidth}else{if(u.orientation==="right"){y=t.top;v=t.right+this.opt.arrowWidth}}}}if(!A){B.style.top="";B.style.left=""}else{if(u.orientation==="top"||u.orientation==="bottom"){B.style.top="";B.style.left=A+"px"}else{if(u.orientation==="left"||u.orientation==="right"){B.style.left="";B.style.top=A+"px"}}}v+=l.getPixelValue(u.xOffset);y+=l.getPixelValue(u.yOffset);if(!u.fixedElement){y+=l.getScrollTop();v+=l.getScrollLeft()}s.style.position=(u.fixedElement?"fixed":"absolute");if(this.opt.animate&&d&&!f){$(s).animate({top:y+"px",left:v+"px"})}else{s.style.top=y+"px";s.style.left=v+"px"}},_initNavButtons:function(){var r=document.createElement("div");this.prevBtnEl=this._createButton("hopscotch-prev",n.prevBtn);this.nextBtnEl=this._createButton("hopscotch-next",n.nextBtn);this.doneBtnEl=this._createButton("hopscotch-done",n.doneBtn);l.addClass(this.doneBtnEl,"hide");r.appendChild(this.prevBtnEl);r.appendChild(this.nextBtnEl);r.appendChild(this.doneBtnEl);l.addClickListener(this.prevBtnEl,function(s){p.prevStep(true)});l.addClickListener(this.nextBtnEl,function(s){p.nextStep(true)});l.addClickListener(this.doneBtnEl,p.endTour);r.className="hopscotch-actions";this.buttonsEl=r;this.containerEl.appendChild(r);return this},_getCloseFn:function(){var r=this;if(!this.closeFn){this.closeFn=function(s){if(r.opt.onClose){r.opt.onClose()}if(r.opt.id&&!r.opt.isTourBubble){p.getCalloutManager().removeCallout(r.opt.id)}else{r.destroy()}l.evtPreventDefault(s)}}return this.closeFn},initCloseButton:function(){var r=document.createElement("a");r.className="hopscotch-bubble-close";r.href="#";r.title=n.closeTooltip;r.innerHTML=n.closeTooltip;if(this.opt.isTourBubble){l.addClickListener(r,function(t){var s=p.getCurrStepNum(),u=p.getCurrTour(),v=(s===u.steps.length-1);l.invokeCallbacks("close",[u.id,s]);p.endTour(true,v);if(t.preventDefault){t.preventDefault()}else{if(event){event.returnValue=false}}})}else{l.addClickListener(r,this._getCloseFn())}this.closeBtnEl=r;this.containerEl.appendChild(r);return this},_initArrow:function(){var r,s;this.arrowEl=document.createElement("div");this.arrowEl.className="hopscotch-bubble-arrow-container";s=document.createElement("div");s.className="hopscotch-bubble-arrow-border";r=document.createElement("div");r.className="hopscotch-bubble-arrow";this.arrowEl.appendChild(s);this.arrowEl.appendChild(r);this.element.appendChild(this.arrowEl);return this},render:function(u,y,v,z){var s=this.element,t,r,x,w;if(u){this.currStep=u}else{if(this.currStep){u=this.currStep}}t=l.valOrDefault(u.showNextButton,this.opt.showNextButton);r=l.valOrDefault(u.showPrevButton,this.opt.showPrevButton);this.setTitle(u.title||"");this.setContent(u.content||"");if(this.opt.showNumber){this.setNum(y)}this.orientation=u.orientation;if(this.opt.showNavButtons){this.showPrevButton(this.prevBtnEl&&r&&y>0);this.showNextButton(this.nextBtnEl&&t&&!v);this.nextBtnEl.value=u.showSkip?n.skipBtn:n.nextBtn;if(v){l.removeClass(this.doneBtnEl,"hide")}else{l.addClass(this.doneBtnEl,"hide")}}this._setArrow(u.orientation);x=l.getPixelValue(u.width)||this.opt.bubbleWidth;w=l.valOrDefault(u.padding,this.opt.bubblePadding);this.containerEl.style.width=x+"px";this.containerEl.style.padding=w+"px";s.style.zIndex=u.zindex||"";if(u.orientation==="top"){s.style.top="-9999px";s.style.left="-9999px";l.removeClass(s,"hide");this.setPosition(u);l.addClass(s,"hide");if(z&&!u.fixedElement){z()}else{this.show()}}else{this.setPosition(u);if(z&&!u.fixedElement){z()}else{this.show()}}return this},setTitle:function(r){if(r){this.titleEl.innerHTML=r;l.removeClass(this.titleEl,"hide")}else{l.addClass(this.titleEl,"hide")}return this},setContent:function(r){if(r){this.contentEl.innerHTML=r;l.removeClass(this.contentEl,"hide")}else{l.addClass(this.contentEl,"hide")}return this},setNum:function(r){if(n.stepNums&&r=C.steps.length){J=null}else{J=C.steps[w]}return J},t=function(){E.nextStep(false)},v=function(T){var S=A(),ac=S.element,X=l.getPixelValue(ac.style.top),W=X+l.getPixelValue(ac.offsetHeight),U=l.getStepTarget(F()),ad=U.getBoundingClientRect(),aa=ad.top+l.getScrollTop(),V=ad.bottom+l.getScrollTop(),Q=(XV)?W:V,Z=l.getScrollTop(),L=Z+l.getWindowHeight(),M=Q-s.scrollTopMargin,K,P,O,ab,N,R,Y;if(Q>=Z&&(Q<=Z+s.scrollTopMargin||J<=L)){if(T){T()}return}else{if(!s.smoothScroll){window.scrollTo(0,M);if(T){T()}return}else{if(typeof YAHOO!==k&&typeof YAHOO.env!==k&&typeof YAHOO.env.ua!==k&&typeof YAHOO.util!==k&&typeof YAHOO.util.Scroll!==k){K=YAHOO.env.ua.webkit?document.body:document.documentElement;O=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:undefined;P=new YAHOO.util.Scroll(K,{scroll:{to:[0,M]}},s.scrollDuration/1000,O);P.onComplete.subscribe(T);P.animate()}else{if(d){$("body, html").animate({scrollTop:M},s.scrollDuration,T)}else{if(M<0){M=0}ab=(Z>Q)?-1:1;N=Math.abs(Z-M)/(s.scrollDuration/10);Y=function(){var af=l.getScrollTop(),ae=af+(ab*N);if((ab>0&&ae>=M)||(ab<0&&ae<=M)){ae=M;if(T){T()}window.scrollTo(0,ae);return}window.scrollTo(0,ae);if(l.getScrollTop()===af){if(T){T()}return}setTimeout(Y,10)};Y()}}}}},z=function(M,J){var L,K;if(w+M>=0&&w+M0&&M.onNext){M.onNext()}else{if(O<0&&M.onPrev){M.onPrev()}}l.invokeCallbacks(O>0?"next":"prev",[C.id,P]);if(O>0&&L){return}}this.showStep(S)};if(!L&&s.skipIfNoElement){z(O,function(S){Q.call(R,S)})}else{if(w+O>=0&&w+O2&&L[2]==="mp"){if(r