From 3955216fd900f8e0ccc0f0d35e626c7364e65851 Mon Sep 17 00:00:00 2001 From: Gordon Koo Date: Mon, 19 Nov 2012 15:18:31 -0800 Subject: [PATCH] add check for duplicate callout id --- js/hopscotch-0.0.4.js | 3 +++ js/hopscotch-0.0.4.min.js | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/js/hopscotch-0.0.4.js b/js/hopscotch-0.0.4.js index 147a7ea6..0e1c70d2 100644 --- a/js/hopscotch-0.0.4.js +++ b/js/hopscotch-0.0.4.js @@ -986,6 +986,9 @@ var callout; if (opt.id) { + if (callouts[opt.id]) { + throw "Callout by that id already exists. Please choose a unique id."; + } opt.isTourBubble = false; callout = new HopscotchBubble(opt); callouts[opt.id] = callout; diff --git a/js/hopscotch-0.0.4.min.js b/js/hopscotch-0.0.4.min.js index fc90501e..54935e6d 100644 --- a/js/hopscotch-0.0.4.min.js +++ b/js/hopscotch-0.0.4.min.js @@ -19,14 +19,14 @@ if("right"===this.orientation)return"left"},show:function(){var a=this,e="fade-i b){this._showButton(this.closeBtnEl,a,b)},_initAnimate:function(){var a=this;setTimeout(function(){b.addClass(a.element,"animate")},50)},_removeAnimate:function(){b.removeClass(this.element,"animate")},destroy:function(){var a=this.element;a.parentNode.removeChild(a);b.removeClickListener(this.closeBtnEl,this._getCloseFn())},init:function(a){var e=document.createElement("div"),c=document.createElement("div"),d=document.createElement("div"),f=this,h=!1;this.element=e;this.containerEl=c;this.titleEl= document.createElement("h3");this.contentEl=document.createElement("p");opt={animate:q.animate,showPrevButton:q.showPrevButton,showNextButton:q.showNextButton,bubbleWidth:q.bubbleWidth,bubblePadding:q.bubblePadding,arrowWidth:q.arrowWidth,showNumber:!0,showNavButtons:!0,isTourBubble:!0};a="undefined"===typeof a?{}:a;b.extend(opt,a);this.opt=opt;e.className="hopscotch-bubble animated";c.className="hopscotch-bubble-container";opt.showNumber?(this.numberEl=document.createElement("span"),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)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 c,f;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?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;dg||g>=h.steps.length?null:h.steps[g]},t=function(){e.nextStep(!1)},y=function(a,d){var c,f;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?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