From 91ac815e3b49429c8c76adbc1472049d2bfb8776 Mon Sep 17 00:00:00 2001 From: Gordon Koo Date: Wed, 1 Aug 2012 16:21:43 -0700 Subject: [PATCH] defer tour until window onload --- js/hopscotch-min.js | 2 +- js/hopscotch.js | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/js/hopscotch-min.js b/js/hopscotch-min.js index d1884044..d7b594ab 100644 --- a/js/hopscotch-min.js +++ b/js/hopscotch-min.js @@ -1 +1 @@ -(function(){var i,c,h,g,f="undefined",a=(typeof window.jQuery!==f),d=(typeof window.localStorage!==f),e=document.body.style,b=(typeof e.MozTransition!==f||typeof e.MsTransition!==f||typeof e.webkitTransition!==f||typeof e.OTransition!==f||typeof e.transition!==f);if(window.hopscotch){return}g={addClass:function(l,n){var k,m,j;if(a){$(l).addClass(n)}else{if(l.className.length===0){l.className=n}else{k=l.className.split(" ");for(m=0,j=k.length;m0);this.showNextButton(this.nextBtnEl&&s&&!u);if(u){g.removeClass(this.doneBtnEl,"hide")}else{g.addClass(this.doneBtnEl,"hide")}this.setArrow(t.orientation);w=g.getPixelValue(t.width)||q.bubbleWidth;v=g.valOrDefault(t.padding,q.bubblePadding);this.containerEl.style.width=w+"px";this.containerEl.style.padding=v+"px";if(t.orientation==="top"){setTimeout(function(){m(z,t);if(y){y()}},5)}else{m(this,t);if(y){y()}}o=t.prevCallback;p=t.nextCallback;return this};this.setTitle=function(r){if(r){this.titleEl.innerHTML=r;g.removeClass(this.titleEl,"hide")}else{g.addClass(this.titleEl,"hide")}return this};this.setContent=function(r){if(r){this.contentEl.innerHTML=r;g.removeClass(this.contentEl,"hide")}else{g.addClass(this.contentEl,"hide")}return this};this.setNum=function(r){if(h.stepNums&&rD)?E:D,G=g.getScrollTop(),v=G+g.getWindowHeight(),w=A-50,u,z,y,I,x,B;if(a){$("body, html").animate({scrollTop:w},l.scrollDuration);return}else{if(typeof YAHOO!==f&&typeof YAHOO.env!==f&&typeof YAHOO.env.ua!==f&&typeof YAHOO.util!==f&&typeof YAHOO.util.Scroll!==f){u=YAHOO.env.ua.webkit?document.body:document.documentElement;y=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:undefined;z=new YAHOO.util.Scroll(u,{scroll:{to:[0,w]}},l.scrollDuration/1000,y);z.animate();return}}if(w<0){w=0}if(A>=G&&A<=G+50){return}if(Av){if(l.smoothScroll){I=(G>A)?-1:1;x=Math.abs(G-A)/(l.scrollDuration/10);B=setInterval(function(){var M=g.getScrollTop(),L=M+(I*x);if((I>0&&L>=w)||I<0&&L<=w){L=w;clearInterval(B)}window.scrollTo(0,L);if(g.getScrollTop()===M){clearInterval(B)}},10)}else{window.scrollTo(0,w)}}};this.init=function(){var t,u;if(j){this.configure(j)}t=g.getState("hopscotch.tour.next");if(t){u=t.split(":");s=u[0];n=parseInt(u[1],10);if(u.length>2&&u[2]==="mp"){++n}}};this.loadTour=function(v){var u={},t,w;o=v;for(w in v){if(v.hasOwnProperty(w)&&w!=="id"&&w!=="steps"){u[w]=v[w]}}this.configure(u);t=m();t.showPrevButton(l.showPrevButton,true);t.showNextButton(l.showNextButton,true)};this.startTour=function(){var t;if(!o){throw"Need to load a tour before you start it!"}if(o.id===s&&typeof n!==f){k=n;if(!document.getElementById(o.steps[k].targetId)){if(k<=0||!document.getElementById(o.steps[--k].targetId)){this.endTour(false);return}}}else{k=0}this.showStep(k);t=m().show();if(l.animate){t.initAnimate()}this.isActive=true};this.showStep=function(w){var x=o.steps[w],v=o.steps.length,u=o.id+":"+w,t=m();if(!o){throw"No tour currently selected!"}k=w;t.renderStep(x,w,(w===v-1),p);if(x.multiPage){u+=":mp"}g.setState("hopscotch.tour.next",u,7)};this.prevStep=function(){if(k>0){this.showStep(--k)}};this.nextStep=function(){if(l.allNextCallback){l.allNextCallback(r(),k)}if(k0);this.showNextButton(this.nextBtnEl&&u&&!w);if(w){i.removeClass(this.doneBtnEl,"hide")}else{i.addClass(this.doneBtnEl,"hide")}this.setArrow(v.orientation);y=i.getPixelValue(v.width)||s.bubbleWidth;x=i.valOrDefault(v.padding,s.bubblePadding);this.containerEl.style.width=y+"px";this.containerEl.style.padding=x+"px";if(v.orientation==="top"){setTimeout(function(){o(B,v);if(A){A()}},5)}else{o(this,v);if(A){A()}}q=v.onPrev;r=v.onNext;return this};this.setTitle=function(t){if(t){this.titleEl.innerHTML=t;i.removeClass(this.titleEl,"hide")}else{i.addClass(this.titleEl,"hide")}return this};this.setContent=function(t){if(t){this.contentEl.innerHTML=t;i.removeClass(this.contentEl,"hide")}else{i.addClass(this.contentEl,"hide")}return this};this.setNum=function(t){if(j.stepNums&&tF)?G:F,I=i.getScrollTop(),x=I+i.getWindowHeight(),y=C-50,w,B,A,K,z,D;if(b){$("body, html").animate({scrollTop:y},n.scrollDuration);return}else{if(typeof YAHOO!==h&&typeof YAHOO.env!==h&&typeof YAHOO.env.ua!==h&&typeof YAHOO.util!==h&&typeof YAHOO.util.Scroll!==h){w=YAHOO.env.ua.webkit?document.body:document.documentElement;A=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:undefined;B=new YAHOO.util.Scroll(w,{scroll:{to:[0,y]}},n.scrollDuration/1000,A);B.animate();return}}if(y<0){y=0}if(C>=I&&C<=I+50){return}if(Cx){if(n.smoothScroll){K=(I>C)?-1:1;z=Math.abs(I-C)/(n.scrollDuration/10);D=setInterval(function(){var O=i.getScrollTop(),N=O+(K*z);if((K>0&&N>=y)||K<0&&N<=y){N=y;clearInterval(D)}window.scrollTo(0,N);if(i.getScrollTop()===O){clearInterval(D)}},10)}else{window.scrollTo(0,y)}}};this.init=function(){var v,w;if(l){this.configure(l)}};this.loadTour=function(x){var w={},v,y;q=x;for(y in x){if(x.hasOwnProperty(y)&&y!=="id"&&y!=="steps"){w[y]=x[y]}}this.configure(w);tourState=i.getState(n.cookieName);if(tourState){tourPair=tourState.split(":");u=tourPair[0];p=parseInt(tourPair[1],10);if(tourPair.length>2&&tourPair[2]==="mp"){++p}}v=o();v.showPrevButton(n.showPrevButton,true);v.showNextButton(n.showNextButton,true)};this.startTour=function(){var v;if(!q){throw"Need to load a tour before you start it!"}if(!g){a=true;return}if(q.id===u&&typeof p!==h){m=p;if(!document.getElementById(q.steps[m].targetId)){if(m<=0||!document.getElementById(q.steps[--m].targetId)){this.endTour(false);return}}}else{m=0}this.showStep(m);v=o().show();if(n.animate){v.initAnimate()}this.isActive=true};this.showStep=function(y){var z=q.steps[y],x=q.steps.length,w=q.id+":"+y,v=o();if(!q){throw"No tour currently selected!"}m=y;v.renderStep(z,y,(y===x-1),r);if(z.multiPage){w+=":mp"}i.setState(n.cookieName,w,1)};this.prevStep=function(){if(m>0){this.showStep(--m)}};this.nextStep=function(){if(n.onNext){n.onNext(t(),m)}if(m