diff --git a/js/hopscotch-0.1.min.js b/js/hopscotch-0.1.min.js index 7e1aae2f..94f91e16 100644 --- a/js/hopscotch-0.1.min.js +++ b/js/hopscotch-0.1.min.js @@ -13,4 +13,4 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. - */(function(e,t){var n,r,i,s,o,u=window.Sizzle||null,a,f,l,c,h,p=e[t],d="undefined",v=!1,m=typeof window.jQuery!==d,g=typeof window.sessionStorage!==d,y=window.document;h={smoothScroll:!0,scrollDuration:1e3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,cookieName:"hopscotch.tour.state"};if(p)return;Array.isArray||(Array.isArray=function(e){return Object.prototype.toString.call(e)==="[object Array]"}),c=function(){v&&p.startTour()},a={addClass:function(e,t){var n,r,i,s,o;if(!e.className)e.className=t;else{r=t.split(/\s+/),n=" "+e.className+" ";for(s=0,o=r.length;s=0?r+=" prev":r+=" next",a.addClass(n,r),n},setPosition:function(e){var t,n,r,i,s,o,u,f=6,l=a.getStepTarget(e),c=this.element,h=this.arrowEl;t=a.getPixelValue(e.width)||this.opt.bubbleWidth,r=a.valOrDefault(e.padding,this.opt.bubblePadding),a.removeClass(c,"fade-in-down fade-in-up fade-in-left fade-in-right"),!e.placement&&e.orientation&&(e.placement=e.orientation),i=l.getBoundingClientRect(),e.placement==="top"?(n=c.offsetHeight,s=i.top-n-this.opt.arrowWidth,o=i.left):e.placement==="bottom"?(s=i.bottom+this.opt.arrowWidth,o=i.left):e.placement==="left"?(s=i.top,o=i.left-t-2*r-2*f-this.opt.arrowWidth):e.placement==="right"&&(s=i.top,o=i.right+this.opt.arrowWidth),e.arrowOffset!=="center"?u=a.getPixelValue(e.arrowOffset):u=e.arrowOffset;if(!u)h.style.top="",h.style.left="";else if(e.placement==="top"||e.placement==="bottom")h.style.top="",u==="center"?h.style.left=t/2+r-h.getBoundingClientRect().width/2+"px":h.style.left=u+"px";else if(e.placement==="left"||e.placement==="right")h.style.left="",u==="center"?(n=n||c.offsetHeight,h.style.top=n/2+r-h.getBoundingClientRect().height/2+"px"):h.style.top=u+"px";e.xOffset==="center"?o=i.left+i.width/2-t/2-r:o+=a.getPixelValue(e.xOffset),e.yOffset==="center"?(n=n||c.offsetHeight,s=i.top+i.height/2-n/2-r):s+=a.getPixelValue(e.yOffset),e.fixedElement||(s+=a.getScrollTop(),o+=a.getScrollLeft()),c.style.position=e.fixedElement?"fixed":"absolute",c.style.top=s+"px",c.style.left=o+"px"},_initNavButtons:function(){var e=y.createElement("div");return this.prevBtnEl=this._createButton("hopscotch-prev",a.getI18NString("prevBtn")),this.nextBtnEl=this._createButton("hopscotch-next",a.getI18NString("nextBtn")),this.doneBtnEl=this._createButton("hopscotch-done",a.getI18NString("doneBtn")),this.ctaBtnEl=this._createButton("hopscotch-cta"),a.addClass(this.doneBtnEl,"hide"),e.appendChild(this.prevBtnEl),e.appendChild(this.ctaBtnEl),e.appendChild(this.nextBtnEl),e.appendChild(this.doneBtnEl),a.addEvtListener(this.prevBtnEl,"click",function(e){p.prevStep(!0)}),a.addEvtListener(this.nextBtnEl,"click",function(e){p.nextStep(!0)}),a.addEvtListener(this.doneBtnEl,"click",function(e){p.endTour()}),e.className="hopscotch-actions",this.buttonsEl=e,this.containerEl.appendChild(e),this},_getCloseFn:function(){var e=this;return this.closeFn||(this.closeFn=function(t){e.opt.onClose&&a.invokeCallback(e.opt.onClose),e.opt.id&&!e.opt.isTourBubble?p.getCalloutManager().removeCallout(e.opt.id):e.destroy(),a.evtPreventDefault(t)}),this.closeFn},initCloseButton:function(){var e=y.createElement("a");return e.className="hopscotch-bubble-close",e.href="#",e.title=a.getI18NString("closeTooltip"),e.innerHTML=a.getI18NString("closeTooltip"),this.opt.isTourBubble?a.addEvtListener(e,"click",function(e){var t=p.getCurrStepNum(),n=p.getCurrTour(),r=t===n.steps.length-1;a.invokeEventCallbacks("close"),p.endTour(!0,r),e.preventDefault?e.preventDefault():event&&(event.returnValue=!1)}):a.addEvtListener(e,"click",this._getCloseFn()),a.valOrDefault(this.opt.showCloseButton,!0)||a.addClass(e,"hide"),this.closeBtnEl=e,this.containerEl.appendChild(e),this},_initArrow:function(){var e,t;return this.arrowEl=y.createElement("div"),this.arrowEl.className="hopscotch-bubble-arrow-container",t=y.createElement("div"),t.className="hopscotch-bubble-arrow-border",e=y.createElement("div"),e.className="hopscotch-bubble-arrow",this.arrowEl.appendChild(t),this.arrowEl.appendChild(e),this.element.appendChild(this.arrowEl),this},_setupCTAButton:function(e){var t,n=this;this._showButton(this.ctaBtnEl,!!e.showCTAButton),e.showCTAButton&&e.ctaLabel&&(this.ctaBtnEl.innerHTML=e.ctaLabel,t=function(){a.removeEvtListener(n.ctaBtnEl,"click",t),n.opt.isTourBubble||p.getCalloutManager().removeCallout(e.id),e.onCTA&&typeof e.onCTA=="function"&&e.onCTA()},a.addEvtListener(this.ctaBtnEl,"click",t))},render:function(e,t,n,r){var i=this.element,s,o,u,f;return e?this.currStep=e:this.currStep&&(e=this.currStep),!e.placement&&e.orientation&&(e.placement=e.orientation),s=a.valOrDefault(e.showNextButton,this.opt.showNextButton),o=a.valOrDefault(e.showPrevButton,this.opt.showPrevButton),this.setTitle(e.title||""),this.setContent(e.content||""),this.opt.isTourBubble&&this.setNum(t),this.placement=e.placement,this.showPrevButton(this.prevBtnEl&&o&&t>0),this.showNextButton(this.nextBtnEl&&s&&!n),this.nextBtnEl.innerHTML=e.showSkip?a.getI18NString("skipBtn"):a.getI18NString("nextBtn"),n?a.removeClass(this.doneBtnEl,"hide"):a.addClass(this.doneBtnEl,"hide"),this._setupCTAButton(e),this._setArrow(e.placement),u=a.getPixelValue(e.width)||this.opt.bubbleWidth,f=a.valOrDefault(e.padding,this.opt.bubblePadding),this.containerEl.style.width=u+"px",this.containerEl.style.padding=f+"px",i.style.zIndex=e.zindex||"",e.placement==="top"?(i.style.top="-9999px",i.style.left="-9999px",a.removeClass(i,"hide"),this.setPosition(e),a.addClass(i,"hide")):this.setPosition(e),r&&r(!e.fixedElement),this},setTitle:function(e){return e?(this.titleEl.innerHTML=e,a.removeClass(this.titleEl,"hide")):a.addClass(this.titleEl,"hide"),this},setContent:function(e){return e?(this.contentEl.innerHTML=e,a.removeClass(this.contentEl,"hide")):a.addClass(this.contentEl,"hide"),this},setNum:function(e){var t=a.getI18NString("stepNums");t&&e=c.steps.length?e=null:e=c.steps[p],e},T=function(){t.nextStep()},N=function(e){var t=E(),n=t.element,r=a.getPixelValue(n.style.top),i=r+a.getPixelValue(n.offsetHeight),s=a.getStepTarget(x()),o=s.getBoundingClientRect(),u=o.top+a.getScrollTop(),f=o.bottom+a.getScrollTop(),l=rf?i:f,h=a.getScrollTop(),p=h+a.getWindowHeight(),v=l-S("scrollTopMargin"),g,b,w,T,N,C,k;l>=h&&(l<=h+S("scrollTopMargin")||c<=p)?e&&e():S("smoothScroll")?typeof YAHOO!==d&&typeof YAHOO.env!==d&&typeof YAHOO.env.ua!==d&&typeof YAHOO.util!==d&&typeof YAHOO.util.Scroll!==d?(g=YAHOO.env.ua.webkit?y.body:y.documentElement,w=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:undefined,b=new YAHOO.util.Scroll(g,{scroll:{to:[0,v]}},S("scrollDuration")/1e3,w),b.onComplete.subscribe(e),b.animate()):m?$("body, html").animate({scrollTop:v},S("scrollDuration"),e):(v<0&&(v=0),T=h>l?-1:1,N=Math.abs(h-v)/(S("scrollDuration")/10),k=function(){var t=a.getScrollTop(),n=t+T*N;if(T>0&&n>=v||T<0&&n<=v){n=v,e&&e(),window.scrollTo(0,n);return}window.scrollTo(0,n);if(a.getScrollTop()===t){e&&e();return}setTimeout(k,10)},k()):(window.scrollTo(0,v),e&&e())},C=function(e,t){var n,r,i;p+e>=0&&p+e0?o=s.multipage:o=p>0&&c.steps[p-1].multipage,u=function(n){if(n===-1)return this.endTour(!0);e&&(t>0?a.invokeEventCallbacks("next",s.onNext):a.invokeEventCallbacks("prev",s.onPrev));if(o){a.setState(S("cookieName"),c.id+":"+p,1);return}this.showStep(n)};if(!o&&S("skipIfNoElement"))C(t,function(e){u.call(r,e)});else if(p+t>=0&&p+t=c.steps.length)throw"Specified step number out of bounds.";p=t}return a.documentIsReady()?(!p&&c.id===g&&typeof b!==d?p=b:p||(p=0),A(p,function(e){var t=e!==-1&&a.getStepTarget(c.steps[e]);if(!t){r.endTour(!1,!1);return}a.invokeEventCallbacks("start"),n=E(),n.hide(!1),r.isActive=!0,a.getStepTarget(x())?r.showStep(e):(a.invokeEventCallbacks("error"),S("skipIfNoElement")&&r.nextStep(!1))}),this):(v=!0,this)},this.showStep=function(e){var t=c.steps[e];return t.delay?setTimeout(function(){O(e)},t.delay):O(e),this},this.prevStep=function(e){return k.call(this,e,-1),this},this.nextStep=function(e){var t=x(),n=a.getStepTarget(t);return t.nextOnTargetClick&&a.removeEvtListener(n,"click",T),k.call(this,e,1),this},this.endTour=function(e,t){var n=E();return e=a.valOrDefault(e,!0),t=a.valOrDefault(t,!0),p=0,b=undefined,n.hide(),e&&a.clearState(S("cookieName")),this.isActive&&(this.isActive=!1,c&&t&&a.invokeEventCallbacks("end")),this.removeCallbacks(null,!0),this.resetDefaultOptions(),c=null,this},this.getCurrTour=function(){return c},this.getCurrStepNum=function(){return p},this.listen=function(e,t,n){return e&&f[e].push({cb:t,fromTour:n}),this},this.unlisten=function(e,t){var n=f[e],r,i;for(r=0,i=n.length;r=0?r+=" prev":r+=" next",a.addClass(n,r),n},setPosition:function(e){var t,n,r,i,s,o,u,f=6,l=a.getStepTarget(e),c=this.element,h=this.arrowEl;t=a.getPixelValue(e.width)||this.opt.bubbleWidth,r=a.valOrDefault(e.padding,this.opt.bubblePadding),a.removeClass(c,"fade-in-down fade-in-up fade-in-left fade-in-right"),!e.placement&&e.orientation&&(e.placement=e.orientation),i=l.getBoundingClientRect(),e.placement==="top"?(n=c.offsetHeight,s=i.top-n-this.opt.arrowWidth,o=i.left):e.placement==="bottom"?(s=i.bottom+this.opt.arrowWidth,o=i.left):e.placement==="left"?(s=i.top,o=i.left-t-2*r-2*f-this.opt.arrowWidth):e.placement==="right"&&(s=i.top,o=i.right+this.opt.arrowWidth),e.arrowOffset!=="center"?u=a.getPixelValue(e.arrowOffset):u=e.arrowOffset;if(!u)h.style.top="",h.style.left="";else if(e.placement==="top"||e.placement==="bottom")h.style.top="",u==="center"?h.style.left=t/2+r-h.getBoundingClientRect().width/2+"px":h.style.left=u+"px";else if(e.placement==="left"||e.placement==="right")h.style.left="",u==="center"?(n=n||c.offsetHeight,h.style.top=n/2+r-h.getBoundingClientRect().height/2+"px"):h.style.top=u+"px";e.xOffset==="center"?o=i.left+i.width/2-t/2-r:o+=a.getPixelValue(e.xOffset),e.yOffset==="center"?(n=n||c.offsetHeight,s=i.top+i.height/2-n/2-r):s+=a.getPixelValue(e.yOffset),e.fixedElement||(s+=a.getScrollTop(),o+=a.getScrollLeft()),c.style.position=e.fixedElement?"fixed":"absolute",c.style.top=s+"px",c.style.left=o+"px"},_initNavButtons:function(){var e=y.createElement("div");return this.prevBtnEl=this._createButton("hopscotch-prev",a.getI18NString("prevBtn")),this.nextBtnEl=this._createButton("hopscotch-next",a.getI18NString("nextBtn")),this.doneBtnEl=this._createButton("hopscotch-done",a.getI18NString("doneBtn")),this.ctaBtnEl=this._createButton("hopscotch-cta"),a.addClass(this.doneBtnEl,"hide"),e.appendChild(this.prevBtnEl),e.appendChild(this.ctaBtnEl),e.appendChild(this.nextBtnEl),e.appendChild(this.doneBtnEl),a.addEvtListener(this.prevBtnEl,"click",function(e){p.prevStep(!0)}),a.addEvtListener(this.nextBtnEl,"click",function(e){p.nextStep(!0)}),a.addEvtListener(this.doneBtnEl,"click",function(e){p.endTour()}),e.className="hopscotch-actions",this.buttonsEl=e,this.containerEl.appendChild(e),this},_getCloseFn:function(){var e=this;return this.closeFn||(this.closeFn=function(t){e.opt.onClose&&a.invokeCallback(e.opt.onClose),e.opt.id&&!e.opt.isTourBubble?p.getCalloutManager().removeCallout(e.opt.id):e.destroy(),a.evtPreventDefault(t)}),this.closeFn},initCloseButton:function(){var e=y.createElement("a");return e.className="hopscotch-bubble-close",e.href="#",e.title=a.getI18NString("closeTooltip"),e.innerHTML=a.getI18NString("closeTooltip"),this.opt.isTourBubble?a.addEvtListener(e,"click",function(e){var t=p.getCurrStepNum(),n=p.getCurrTour(),r=t===n.steps.length-1;a.invokeEventCallbacks("close"),p.endTour(!0,r),e.preventDefault?e.preventDefault():event&&(event.returnValue=!1)}):a.addEvtListener(e,"click",this._getCloseFn()),a.valOrDefault(this.opt.showCloseButton,!0)||a.addClass(e,"hide"),this.closeBtnEl=e,this.containerEl.appendChild(e),this},_initArrow:function(){var e,t;return this.arrowEl=y.createElement("div"),this.arrowEl.className="hopscotch-bubble-arrow-container",t=y.createElement("div"),t.className="hopscotch-bubble-arrow-border",e=y.createElement("div"),e.className="hopscotch-bubble-arrow",this.arrowEl.appendChild(t),this.arrowEl.appendChild(e),this.element.appendChild(this.arrowEl),this},_setupCTAButton:function(e){var t,n=this;this._showButton(this.ctaBtnEl,!!e.showCTAButton),e.showCTAButton&&e.ctaLabel&&(this.ctaBtnEl.innerHTML=e.ctaLabel,t=function(){a.removeEvtListener(n.ctaBtnEl,"click",t),n.opt.isTourBubble||p.getCalloutManager().removeCallout(e.id),e.onCTA&&typeof e.onCTA=="function"&&e.onCTA()},a.addEvtListener(this.ctaBtnEl,"click",t))},render:function(e,t,n,r){var i=this.element,s,o,u,f;return e?this.currStep=e:this.currStep&&(e=this.currStep),!e.placement&&e.orientation&&(e.placement=e.orientation),s=a.valOrDefault(e.showNextButton,this.opt.showNextButton),o=a.valOrDefault(e.showPrevButton,this.opt.showPrevButton),this.setTitle(e.title||""),this.setContent(e.content||""),this.opt.isTourBubble&&this.setNum(t),this.placement=e.placement,this.showPrevButton(this.prevBtnEl&&o&&t>0),this.showNextButton(this.nextBtnEl&&s&&!n),this.nextBtnEl.innerHTML=e.showSkip?a.getI18NString("skipBtn"):a.getI18NString("nextBtn"),n?a.removeClass(this.doneBtnEl,"hide"):a.addClass(this.doneBtnEl,"hide"),this._setupCTAButton(e),this._setArrow(e.placement),u=a.getPixelValue(e.width)||this.opt.bubbleWidth,f=a.valOrDefault(e.padding,this.opt.bubblePadding),this.containerEl.style.width=u+"px",this.containerEl.style.padding=f+"px",i.style.zIndex=e.zindex||"",e.placement==="top"?(i.style.top="-9999px",i.style.left="-9999px",a.removeClass(i,"hide"),this.setPosition(e),a.addClass(i,"hide")):this.setPosition(e),r&&r(!e.fixedElement),this},setTitle:function(e){return e?(this.titleEl.innerHTML=e,a.removeClass(this.titleEl,"hide")):a.addClass(this.titleEl,"hide"),this},setContent:function(e){return e?(this.contentEl.innerHTML=e,a.removeClass(this.contentEl,"hide")):a.addClass(this.contentEl,"hide"),this},setNum:function(e){var t=a.getI18NString("stepNums");t&&e=c.steps.length?e=null:e=c.steps[p],e},T=function(){t.nextStep()},N=function(e){var t=E(),n=t.element,r=a.getPixelValue(n.style.top),i=r+a.getPixelValue(n.offsetHeight),s=a.getStepTarget(x()),o=s.getBoundingClientRect(),u=o.top+a.getScrollTop(),f=o.bottom+a.getScrollTop(),l=rf?i:f,h=a.getScrollTop(),p=h+a.getWindowHeight(),v=l-S("scrollTopMargin"),g,b,w,T,N,C,k;l>=h&&(l<=h+S("scrollTopMargin")||c<=p)?e&&e():S("smoothScroll")?typeof YAHOO!==d&&typeof YAHOO.env!==d&&typeof YAHOO.env.ua!==d&&typeof YAHOO.util!==d&&typeof YAHOO.util.Scroll!==d?(g=YAHOO.env.ua.webkit?y.body:y.documentElement,w=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:undefined,b=new YAHOO.util.Scroll(g,{scroll:{to:[0,v]}},S("scrollDuration")/1e3,w),b.onComplete.subscribe(e),b.animate()):m?jQuery("body, html").animate({scrollTop:v},S("scrollDuration"),e):(v<0&&(v=0),T=h>l?-1:1,N=Math.abs(h-v)/(S("scrollDuration")/10),k=function(){var t=a.getScrollTop(),n=t+T*N;if(T>0&&n>=v||T<0&&n<=v){n=v,e&&e(),window.scrollTo(0,n);return}window.scrollTo(0,n);if(a.getScrollTop()===t){e&&e();return}setTimeout(k,10)},k()):(window.scrollTo(0,v),e&&e())},C=function(e,t){var n,r,i;p+e>=0&&p+e0?o=s.multipage:o=p>0&&c.steps[p-1].multipage,u=function(n){if(n===-1)return this.endTour(!0);e&&(t>0?a.invokeEventCallbacks("next",s.onNext):a.invokeEventCallbacks("prev",s.onPrev));if(o){a.setState(S("cookieName"),c.id+":"+p,1);return}this.showStep(n)};if(!o&&S("skipIfNoElement"))C(t,function(e){u.call(r,e)});else if(p+t>=0&&p+t=c.steps.length)throw"Specified step number out of bounds.";p=t}return a.documentIsReady()?(!p&&c.id===g&&typeof b!==d?p=b:p||(p=0),A(p,function(e){var t=e!==-1&&a.getStepTarget(c.steps[e]);if(!t){r.endTour(!1,!1);return}a.invokeEventCallbacks("start"),n=E(),n.hide(!1),r.isActive=!0,a.getStepTarget(x())?r.showStep(e):(a.invokeEventCallbacks("error"),S("skipIfNoElement")&&r.nextStep(!1))}),this):(v=!0,this)},this.showStep=function(e){var t=c.steps[e];return t.delay?setTimeout(function(){O(e)},t.delay):O(e),this},this.prevStep=function(e){return k.call(this,e,-1),this},this.nextStep=function(e){var t=x(),n=a.getStepTarget(t);return t.nextOnTargetClick&&a.removeEvtListener(n,"click",T),k.call(this,e,1),this},this.endTour=function(e,t){var n=E();return e=a.valOrDefault(e,!0),t=a.valOrDefault(t,!0),p=0,b=undefined,n.hide(),e&&a.clearState(S("cookieName")),this.isActive&&(this.isActive=!1,c&&t&&a.invokeEventCallbacks("end")),this.removeCallbacks(null,!0),this.resetDefaultOptions(),c=null,this},this.getCurrTour=function(){return c},this.getCurrStepNum=function(){return p},this.listen=function(e,t,n){return e&&f[e].push({cb:t,fromTour:n}),this},this.unlisten=function(e,t){var n=f[e],r,i;for(r=0,i=n.length;r