From bc45ab1a9716820e794749559de6c6e928f8a2ea Mon Sep 17 00:00:00 2001 From: Gordon Koo Date: Tue, 5 Feb 2013 15:48:51 -0800 Subject: [PATCH] prevent nextStep() from progressing tour after multistep is detected --- js/hopscotch-0.0.4.js | 14 +++++++++++--- js/hopscotch-0.0.4.min.js | 8 ++++---- minify.sh | 9 +++++---- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/js/hopscotch-0.0.4.js b/js/hopscotch-0.0.4.js index 191025ba..b3a3563c 100644 --- a/js/hopscotch-0.0.4.js +++ b/js/hopscotch-0.0.4.js @@ -1298,12 +1298,14 @@ self = this, step, origStepNum, + wasMultiPage, changeStepCb; bubble.hide(); doCallbacks = utils.valOrDefault(doCallbacks, true); step = getCurrStep(); + wasMultiPage = step.multipage; origStepNum = currStepNum; /** @@ -1318,20 +1320,26 @@ } if (doCallbacks) { - // invoke callbacks + // Step-specific callbacks if (direction > 0 && step.onNext) { step.onNext(); } else if (direction < 0 && step.onPrev) { step.onPrev(); } + + // Tour-wide next/prev callbacks utils.invokeCallbacks(direction > 0 ? 'next' : 'prev', [currTour.id, origStepNum]); + + if (direction > 0 && wasMultiPage) { + return; + } } this.showStep(stepNum); }; - if (opt.skipIfNoElement) { + if (!wasMultiPage && opt.skipIfNoElement) { goToStepWithTarget(direction, function(stepNum) { changeStepCb.call(self, stepNum); }); @@ -1340,7 +1348,7 @@ // only try incrementing once, and invoke error callback if no target is found currStepNum += direction; step = getCurrStep(); - if (!utils.getStepTarget(step)) { + if (!utils.getStepTarget(step) && !wasMultiPage) { utils.invokeCallbacks('error', [currTour.id, currStepNum]); return this.endTour(true, false); } diff --git a/js/hopscotch-0.0.4.min.js b/js/hopscotch-0.0.4.min.js index f78fd3da..9d15a892 100644 --- a/js/hopscotch-0.0.4.min.js +++ b/js/hopscotch-0.0.4.min.js @@ -21,10 +21,10 @@ e;this.containerEl=c;this.titleEl=document.createElement("h3");this.contentEl=do this.numberEl.className="hopscotch-bubble-number",c.appendChild(this.numberEl)):b.addClass(e,"no-number");d.appendChild(this.titleEl);d.appendChild(this.contentEl);d.className="hopscotch-bubble-content";c.appendChild(d);e.appendChild(c);opt.showNavButtons&&this._initNavButtons();this.initCloseButton();this._initArrow();a=function(){!h&&f.isShowing&&(h=!0,setTimeout(function(){f.setPosition(f.currStep);h=!1},100))};window.addEventListener?window.addEventListener("resize",a,!1):window.attachEvent&& window.attachEvent("onresize",a,!1);this.hide();document.body.appendChild(e)}},z=function(){var a={};this.createCallout=function(b){var c;if(b.id){if(a[b.id])throw"Callout by that id already exists. Please choose a unique id.";b.isTourBubble=!1;c=new v(b);a[b.id]=c;b.target&&c.render(b)}else throw"Must specify a callout id.";};this.getCallout=function(b){return a[b]};this.removeAllCallouts=function(){for(var b in a)this.removeCallout(b)};this.removeCallout=function(b){var c=a[b];a[b]=null;c&&c.destroy()}}, k=function(a){var e=this,c,d,f,h,g,k,j,r,s=function(){c||(c=new v({animate:f.animate,bubblePadding:f.bubblePadding,bubbleWidth:f.bubbleWidth,showNextButton:f.showNextButton,showPrevButton:f.showPrevButton,arrowWidth:f.arrowWidth}));return c},n=function(){return 0>g||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&& +0))):d(-1)},u=function(a,d){var c=this,e,i,j,k;s().hide();a=b.valOrDefault(a,!0);e=n();j=e.multipage;i=g;k=function(c){if(-1===c)return this.endTour(!0);if(a){if(0d&&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?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 /Users/gkoo/Sites/hopscotch/js/hopscotch-0.0.3.min.js +java -jar /Users/gkoo/workspace/compiler-latest-1/compiler.jar --js=/Users/gkoo/Sites/hopscotch/js/hopscotch-0.0.4.js --js_output_file=/Users/gkoo/Sites/hopscotch/js/hopscotch-0.0.4.min.js +#java -jar /Users/gkoo/workspace/yuicompressor-2.4.7/build/yuicompressor-2.4.7.jar --type js /Users/gkoo/Sites/hopscotch/js/hopscotch-0.0.3.js > /Users/gkoo/Sites/hopscotch/js/hopscotch-0.0.3.min.js echo "Done minifying..."