diff --git a/archives/hopscotch-0.2.4.tar.gz b/archives/hopscotch-0.2.4.tar.gz
new file mode 100644
index 00000000..a185594c
Binary files /dev/null and b/archives/hopscotch-0.2.4.tar.gz differ
diff --git a/archives/hopscotch-0.2.4.zip b/archives/hopscotch-0.2.4.zip
new file mode 100644
index 00000000..7bb5721f
Binary files /dev/null and b/archives/hopscotch-0.2.4.zip differ
diff --git a/bower.json b/bower.json
index 11d9d088..e8c348bd 100644
--- a/bower.json
+++ b/bower.json
@@ -1,6 +1,6 @@
{
"name": "hopscotch",
- "version": "0.2.3",
+ "version": "0.2.4",
"authors": [],
"description": "A framework to make it easy for developers to add product tours to their pages.",
"main": [
diff --git a/dist/css/hopscotch.css b/dist/css/hopscotch.css
index f84ba7ff..15e3f9e4 100644
--- a/dist/css/hopscotch.css
+++ b/dist/css/hopscotch.css
@@ -1,6 +1,6 @@
-/**! hopscotch - v0.2.3
+/**! hopscotch - v0.2.4
*
-* Copyright 2014 LinkedIn Corp. All rights reserved.
+* Copyright 2015 LinkedIn Corp. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/dist/css/hopscotch.min.css b/dist/css/hopscotch.min.css
index 44594ecb..0621ac6a 100644
--- a/dist/css/hopscotch.min.css
+++ b/dist/css/hopscotch.min.css
@@ -1,6 +1,6 @@
-/**! hopscotch - v0.2.3
+/**! hopscotch - v0.2.4
*
-* Copyright 2014 LinkedIn Corp. All rights reserved.
+* Copyright 2015 LinkedIn Corp. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
diff --git a/dist/js/hopscotch.js b/dist/js/hopscotch.js
index 8dbe8d96..045faf64 100644
--- a/dist/js/hopscotch.js
+++ b/dist/js/hopscotch.js
@@ -1,6 +1,6 @@
-/**! hopscotch - v0.2.3
+/**! hopscotch - v0.2.4
*
-* Copyright 2014 LinkedIn Corp. All rights reserved.
+* Copyright 2015 LinkedIn Corp. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,7 +14,25 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-(function(context, namespace) {
+(function(context, factory) {
+ 'use strict';
+
+ if (typeof define === 'function' && define.amd) {
+ // AMD. Register as an anonymous module.
+ define([], factory);
+ } else if (typeof exports === 'object') {
+ // Node/CommonJS
+ module.exports = factory();
+ } else {
+ var namespace = 'hopscotch';
+ // Browser globals
+ if (context[namespace]) {
+ // Hopscotch already exists.
+ return;
+ }
+ context[namespace] = factory();
+ }
+}(this, (function() {
var Hopscotch,
HopscotchBubble,
HopscotchCalloutManager,
@@ -29,14 +47,15 @@
helpers,
winLoadHandler,
defaultOpts,
- winHopscotch = context[namespace],
+ winHopscotch,
undefinedStr = 'undefined',
waitingToStart = false, // is a tour waiting for the document to finish
// loading so that it can start?
- hasJquery = (typeof window.jQuery !== undefinedStr),
+ hasJquery = (typeof jQuery !== undefinedStr),
hasSessionStorage = false,
isStorageWritable = false,
document = window.document,
+ validIdRegEx = /^[a-zA-Z]+[a-zA-Z0-9_-]*$/,
rtlMatches = {
left: 'right',
right: 'left'
@@ -69,11 +88,6 @@
cookieName: 'hopscotch.tour.state'
};
- if (winHopscotch) {
- // Hopscotch already exists.
- return;
- }
-
if (!Array.isArray) {
Array.isArray = function(obj) {
return Object.prototype.toString.call(obj) === '[object Array]';
@@ -301,25 +315,22 @@
return window.innerHeight || document.documentElement.clientHeight;
},
- /**
- * @private
- */
- getWindowWidth: function() {
- return window.innerWidth || document.documentElement.clientWidth;
- },
-
/**
* @private
*/
addEvtListener: function(el, evtName, fn) {
- return el.addEventListener ? el.addEventListener(evtName, fn, false) : el.attachEvent('on' + evtName, fn);
+ if(el) {
+ return el.addEventListener ? el.addEventListener(evtName, fn, false) : el.attachEvent('on' + evtName, fn);
+ }
},
/**
* @private
*/
removeEvtListener: function(el, evtName, fn) {
- return el.removeEventListener ? el.removeEventListener(evtName, fn, false) : el.detachEvent('on' + evtName, fn);
+ if(el) {
+ return el.removeEventListener ? el.removeEventListener(evtName, fn, false) : el.detachEvent('on' + evtName, fn);
+ }
},
documentIsReady: function() {
@@ -653,7 +664,7 @@
left = boundingRect.right + this.opt.arrowWidth;
}
else {
- throw 'Bubble placement failed because step.placement is invalid or undefined!';
+ throw new Error('Bubble placement failed because step.placement is invalid or undefined!');
}
// SET (OR RESET) ARROW OFFSETS
@@ -786,7 +797,7 @@
stepNum: this._getStepI18nNum(this._getStepNum(idx))
},
buttons:{
- showPrev: (utils.valOrDefault(step.showPrevButton, this.opt.showPrevButton) && (idx > 0)),
+ showPrev: (utils.valOrDefault(step.showPrevButton, this.opt.showPrevButton) && (this._getStepNum(idx) > 0)),
showNext: utils.valOrDefault(step.showNextButton, this.opt.showNextButton),
showCTA: utils.valOrDefault((step.showCTAButton && step.ctaLabel), false),
ctaLabel: step.ctaLabel,
@@ -817,19 +828,19 @@
el.innerHTML = tourSpecificRenderer(opts);
}
else if(typeof tourSpecificRenderer === 'string'){
- if(!hopscotch.templates || (typeof hopscotch.templates[tourSpecificRenderer] !== 'function')){
- throw 'Bubble rendering failed - template "' + tourSpecificRenderer + '" is not a function.';
+ if(!winHopscotch.templates || (typeof winHopscotch.templates[tourSpecificRenderer] !== 'function')){
+ throw new Error('Bubble rendering failed - template "' + tourSpecificRenderer + '" is not a function.');
}
- el.innerHTML = hopscotch.templates[tourSpecificRenderer](opts);
+ el.innerHTML = winHopscotch.templates[tourSpecificRenderer](opts);
}
else if(customRenderer){
el.innerHTML = customRenderer(opts);
}
else{
- if(!hopscotch.templates || (typeof hopscotch.templates[templateToUse] !== 'function')){
- throw 'Bubble rendering failed - template "' + templateToUse + '" is not a function.';
+ if(!winHopscotch.templates || (typeof winHopscotch.templates[templateToUse] !== 'function')){
+ throw new Error('Bubble rendering failed - template "' + templateToUse + '" is not a function.');
}
- el.innerHTML = hopscotch.templates[templateToUse](opts);
+ el.innerHTML = winHopscotch.templates[templateToUse](opts);
}
// Find arrow among new child elements.
@@ -900,22 +911,22 @@
*
* @private
*/
- _setArrow: function(orientation) {
+ _setArrow: function(placement) {
utils.removeClass(this.arrowEl, 'down up right left');
// Whatever the orientation is, we want to arrow to appear
// "opposite" of the orientation. E.g., a top orientation
// requires a bottom arrow.
- if (orientation === 'top') {
+ if (placement === 'top') {
utils.addClass(this.arrowEl, 'down');
}
- else if (orientation === 'bottom') {
+ else if (placement === 'bottom') {
utils.addClass(this.arrowEl, 'up');
}
- else if (orientation === 'left') {
+ else if (placement === 'left') {
utils.addClass(this.arrowEl, 'right');
}
- else if (orientation === 'right') {
+ else if (placement === 'right') {
utils.addClass(this.arrowEl, 'left');
}
},
@@ -1071,6 +1082,7 @@
numChildren,
node,
i,
+ currTour,
opt;
//Register DOM element for this bubble.
@@ -1095,6 +1107,11 @@
el.className = 'hopscotch-bubble animated';
if (!opt.isTourBubble) {
utils.addClass(el, 'hopscotch-callout no-number');
+ } else {
+ currTour = winHopscotch.getCurrTour();
+ if(currTour){
+ utils.addClass(el, 'tour-' + currTour.id);
+ }
}
/**
@@ -1186,8 +1203,11 @@
var callout;
if (opt.id) {
+ if(!validIdRegEx.test(opt.id)) {
+ throw new Error('Callout ID is using an invalid format. Use alphanumeric, underscores, and/or hyphens only. First character must be a letter.');
+ }
if (callouts[opt.id]) {
- throw 'Callout by that id already exists. Please choose a unique id.';
+ throw new Error('Callout by that id already exists. Please choose a unique id.');
}
opt.showNextButton = opt.showPrevButton = false;
opt.isTourBubble = false;
@@ -1204,7 +1224,7 @@
}
}
else {
- throw 'Must specify a callout id.';
+ throw new Error('Must specify a callout id.');
}
return callout;
};
@@ -1325,6 +1345,19 @@
return bubble;
},
+ /**
+ * Destroy the bubble currently associated with Hopscotch.
+ * This is done when we end the current tour.
+ *
+ * @private
+ */
+ destroyBubble = function() {
+ if(bubble){
+ bubble.destroy();
+ bubble = null;
+ }
+ },
+
/**
* Convenience method for getting an option. Returns custom config option
* or the default config option if no custom value exists.
@@ -1832,13 +1865,25 @@
// loadTour if we are calling startTour directly. (When we call startTour
// from window onLoad handler, we'll use currTour)
if (!currTour) {
+
+ // Sanity check! Is there a tour?
+ if(!tour){
+ throw new Error('Tour data is required for startTour.');
+ }
+
+ // Check validity of tour ID. If invalid, throw an error.
+ if(!tour.id || !validIdRegEx.test(tour.id)) {
+ throw new Error('Tour ID is using an invalid format. Use alphanumeric, underscores, and/or hyphens only. First character must be a letter.');
+ }
+
currTour = tour;
loadTour.call(this, tour);
+
}
if (typeof stepNum !== undefinedStr) {
if (stepNum >= currTour.steps.length) {
- throw 'Specified step number out of bounds.';
+ throw new Error('Specified step number out of bounds.');
}
currStepNum = stepNum;
}
@@ -1908,6 +1953,10 @@
*/
this.showStep = function(stepNum) {
var step = currTour.steps[stepNum];
+ if(!utils.getStepTarget(step)) {
+ return;
+ }
+
if (step.delay) {
setTimeout(function() {
showStepHelper(stepNum);
@@ -1986,6 +2035,7 @@
this.removeCallbacks(null, true);
this.resetDefaultOptions();
+ destroyBubble();
currTour = null;
@@ -2385,7 +2435,6 @@
};
winHopscotch = new Hopscotch();
- context[namespace] = winHopscotch;
// Template includes, placed inside a closure to ensure we don't
// end up declaring our shim globally.
@@ -2407,10 +2456,9 @@ _.escape = function(str){
if(match == "'"){ return ''' }
});
}
-this["hopscotch"] = this["hopscotch"] || {};
-this["hopscotch"]["templates"] = this["hopscotch"]["templates"] || {};
+this["templates"] = this["templates"] || {};
-this["hopscotch"]["templates"]["bubble_default"] = function(obj) {
+this["templates"]["bubble_default"] = function(obj) {
obj || (obj = {});
var __t, __p = '', __e = _.escape, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
@@ -2477,6 +2525,8 @@ __p += '\n\n
}
return __p
};
-}());
+}.call(winHopscotch));
+
+ return winHopscotch;
-}(window, 'hopscotch'));
+})));
diff --git a/dist/js/hopscotch.min.js b/dist/js/hopscotch.min.js
index 3ba661e4..0e5a41ee 100644
--- a/dist/js/hopscotch.min.js
+++ b/dist/js/hopscotch.min.js
@@ -1,6 +1,6 @@
-/**! hopscotch - v0.2.3
+/**! hopscotch - v0.2.4
*
-* Copyright 2014 LinkedIn Corp. All rights reserved.
+* Copyright 2015 LinkedIn Corp. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -14,4 +14,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-!function(context,namespace){var Hopscotch,HopscotchBubble,HopscotchCalloutManager,HopscotchI18N,customI18N,customRenderer,customEscape,utils,callbacks,helpers,winLoadHandler,defaultOpts,templateToUse="bubble_default",Sizzle=window.Sizzle||null,winHopscotch=context[namespace],undefinedStr="undefined",waitingToStart=!1,hasJquery=typeof window.jQuery!==undefinedStr,hasSessionStorage=!1,isStorageWritable=!1,document=window.document,rtlMatches={left:"right",right:"left"};try{typeof window.sessionStorage!==undefinedStr&&(hasSessionStorage=!0,sessionStorage.setItem("hopscotch.test.storage","ok"),sessionStorage.removeItem("hopscotch.test.storage"),isStorageWritable=!0)}catch(err){}defaultOpts={smoothScroll:!0,scrollDuration:1e3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,isRtl:!1,cookieName:"hopscotch.tour.state"},winHopscotch||(Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),winLoadHandler=function(){waitingToStart&&winHopscotch.startTour()},utils={addClass:function(a,b){var c,d,e,f;if(a.className){for(d=b.split(/\s+/),c=" "+a.className+" ",e=0,f=d.length;f>e;++e)c.indexOf(" "+d[e]+" ")<0&&(c+=d[e]+" ");a.className=c.replace(/^\s+|\s+$/g,"")}else a.className=b},removeClass:function(a,b){var c,d,e,f;for(d=b.split(/\s+/),c=" "+a.className+" ",e=0,f=d.length;f>e;++e)c=c.replace(" "+d[e]+" "," ");a.className=c.replace(/^\s+|\s+$/g,"")},hasClass:function(a,b){var c;return a.className?(c=" "+a.className+" ",-1!==c.indexOf(" "+b+" ")):!1},getPixelValue:function(a){var b=typeof a;return"number"===b?a:"string"===b?parseInt(a,10):0},valOrDefault:function(a,b){return typeof a!==undefinedStr?a:b},invokeCallbackArrayHelper:function(a){var b;return Array.isArray(a)&&(b=helpers[a[0]],"function"==typeof b)?b.apply(this,a.slice(1)):void 0},invokeCallbackArray:function(a){var b,c;if(Array.isArray(a)){if("string"==typeof a[0])return utils.invokeCallbackArrayHelper(a);for(b=0,c=a.length;c>b;++b)utils.invokeCallback(a[b])}},invokeCallback:function(a){return"function"==typeof a?a():"string"==typeof a&&helpers[a]?helpers[a]():utils.invokeCallbackArray(a)},invokeEventCallbacks:function(a,b){var c,d,e=callbacks[a];if(b)return this.invokeCallback(b);for(c=0,d=e.length;d>c;++c)this.invokeCallback(e[c].cb)},getScrollTop:function(){var a;return a=typeof window.pageYOffset!==undefinedStr?window.pageYOffset:document.documentElement.scrollTop},getScrollLeft:function(){var a;return a=typeof window.pageXOffset!==undefinedStr?window.pageXOffset:document.documentElement.scrollLeft},getWindowHeight:function(){return window.innerHeight||document.documentElement.clientHeight},getWindowWidth:function(){return window.innerWidth||document.documentElement.clientWidth},addEvtListener:function(a,b,c){return a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c)},removeEvtListener:function(a,b,c){return a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent("on"+b,c)},documentIsReady:function(){return"complete"===document.readyState||"interactive"===document.readyState},evtPreventDefault:function(a){a.preventDefault?a.preventDefault():event&&(event.returnValue=!1)},extend:function(a,b){var c;for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c])},getStepTargetHelper:function(a){var b=document.getElementById(a);if(b)return b;if(hasJquery)return b=jQuery(a),b.length?b[0]:null;if(Sizzle)return b=new Sizzle(a),b.length?b[0]:null;if(document.querySelector)try{return document.querySelector(a)}catch(c){}return/^#[a-zA-Z][\w-_:.]*$/.test(a)?document.getElementById(a.substring(1)):null},getStepTarget:function(a){var b;if(!a||!a.target)return null;if("string"==typeof a.target)return utils.getStepTargetHelper(a.target);if(Array.isArray(a.target)){var c,d;for(c=0,d=a.target.length;d>c;c++)if("string"==typeof a.target[c]&&(b=utils.getStepTargetHelper(a.target[c])))return b;return null}return a.target},getI18NString:function(a){return customI18N[a]||HopscotchI18N[a]},setState:function(a,b,c){var d,e="";if(hasSessionStorage&&isStorageWritable)try{sessionStorage.setItem(a,b)}catch(f){isStorageWritable=!1,this.setState(a,b,c)}else hasSessionStorage&&sessionStorage.removeItem(a),c&&(d=new Date,d.setTime(d.getTime()+24*c*60*60*1e3),e="; expires="+d.toGMTString()),document.cookie=a+"="+b+e+"; path=/"},getState:function(a){var b,c,d,e=a+"=",f=document.cookie.split(";");if(hasSessionStorage&&(d=sessionStorage.getItem(a)))return d;for(b=0;b
0,showNext:utils.valOrDefault(a.showNextButton,this.opt.showNextButton),showCTA:utils.valOrDefault(a.showCTAButton&&a.ctaLabel,!1),ctaLabel:a.ctaLabel,showClose:utils.valOrDefault(this.opt.showCloseButton,!0)},step:{num:b,isLast:utils.valOrDefault(k,!1),title:a.title||"",content:a.content||"",isRtl:a.isRtl,placement:a.placement,padding:utils.valOrDefault(a.padding,this.opt.bubblePadding),width:utils.getPixelValue(a.width)||this.opt.bubbleWidth,customData:a.customData||{}},tour:{isTour:this.opt.isTourBubble,numSteps:h,unsafe:utils.valOrDefault(f,!1),customData:e||{}}},"function"==typeof d)m.innerHTML=d(l);else if("string"==typeof d){if(!hopscotch.templates||"function"!=typeof hopscotch.templates[d])throw'Bubble rendering failed - template "'+d+'" is not a function.';m.innerHTML=hopscotch.templates[d](l)}else if(customRenderer)m.innerHTML=customRenderer(l);else{if(!hopscotch.templates||"function"!=typeof hopscotch.templates[templateToUse])throw'Bubble rendering failed - template "'+templateToUse+'" is not a function.';m.innerHTML=hopscotch.templates[templateToUse](l)}for(children=m.children,numChildren=children.length,i=0;ic;c++)b=e[c],a>b&&d++;return a-d},_getStepI18nNum:function(a){var b=utils.getI18NString("stepNums");return b&&af||f>=e.steps.length?null:e.steps[f]},p=function(){j.nextStep()},q=function(a){var b,c,d,e,f,g,h=m(),i=h.element,j=utils.getPixelValue(i.style.top),k=j+utils.getPixelValue(i.offsetHeight),l=utils.getStepTarget(o()),p=l.getBoundingClientRect(),q=p.top+utils.getScrollTop(),r=p.bottom+utils.getScrollTop(),s=q>j?j:q,t=k>r?k:r,u=utils.getScrollTop(),v=u+utils.getWindowHeight(),w=s-n("scrollTopMargin");s>=u&&(s<=u+n("scrollTopMargin")||v>=t)?a&&a():n("smoothScroll")?typeof YAHOO!==undefinedStr&&typeof YAHOO.env!==undefinedStr&&typeof YAHOO.env.ua!==undefinedStr&&typeof YAHOO.util!==undefinedStr&&typeof YAHOO.util.Scroll!==undefinedStr?(b=YAHOO.env.ua.webkit?document.body:document.documentElement,d=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:void 0,c=new YAHOO.util.Scroll(b,{scroll:{to:[0,w]}},n("scrollDuration")/1e3,d),c.onComplete.subscribe(a),c.animate()):hasJquery?jQuery("body, html").animate({scrollTop:w},n("scrollDuration"),a):(0>w&&(w=0),e=u>s?-1:1,f=Math.abs(u-w)/(n("scrollDuration")/10),(g=function(){var b=utils.getScrollTop(),c=b+e*f;return e>0&&c>=w||0>e&&w>=c?(c=w,a&&a(),void window.scrollTo(0,c)):(window.scrollTo(0,c),utils.getScrollTop()===b?void(a&&a()):void setTimeout(g,10))})()):(window.scrollTo(0,w),a&&a())},r=function(a,b){var c,d,g;f+a>=0&&f+a0?d.multipage:f>0&&e.steps[f-1].multipage,h=function(c){var e;if(-1===c)return this.endTour(!0);if(a&&(e=b>0?utils.invokeEventCallbacks("next",d.onNext):utils.invokeEventCallbacks("prev",d.onPrev)),c===f){if(g)return void w();e=utils.valOrDefault(e,!0),e?this.showStep(c):this.endTour(!1)}},!g&&n("skipIfNoElement"))r(b,function(a){h.call(j,a)});else if(f+b>=0&&f+b2&&(l=d[2].split(",")),h=parseInt(h,10)),this},u=function(a,b,c){var d,e;if(f=a||0,k=b||{},d=o(),e=utils.getStepTarget(d))return void c(f);if(!e){if(utils.invokeEventCallbacks("error"),k[f]=!0,n("skipIfNoElement"))return void r(1,c);f=-1,c(f)}},v=function(a){function b(){d.show(),utils.invokeEventCallbacks("show",c.onShow)}var c=e.steps[a],d=m(),g=utils.getStepTarget(c);f!==a&&o().nextOnTargetClick&&utils.removeEvtListener(utils.getStepTarget(o()),"click",p),f=a,d.hide(!1),d.render(c,a,function(a){a?q(b):b(),c.nextOnTargetClick&&utils.addEvtListener(g,"click",p)}),w()},w=function(){var a=e.id+":"+f,b=winHopscotch.getSkippedStepsIndexes();b&&b.length>0&&(a+=":"+b.join(",")),utils.setState(n("cookieName"),a,1)},x=function(a){a&&this.configure(a)};this.getCalloutManager=function(){return typeof c===undefinedStr&&(c=new HopscotchCalloutManager),c},this.startTour=function(a,b){var c,d,f={},i=this;if(e||(e=a,t.call(this,a)),typeof b!==undefinedStr){if(b>=e.steps.length)throw"Specified step number out of bounds.";d=b}if(!utils.documentIsReady())return waitingToStart=!0,this;if("undefined"==typeof d&&e.id===g&&typeof h!==undefinedStr){if(d=h,l.length>0)for(var j=0,k=l.length;k>j;j++)f[l[j]]=!0}else d||(d=0);return u(d,f,function(a){var b=-1!==a&&utils.getStepTarget(e.steps[a]);return b?(utils.invokeEventCallbacks("start"),c=m(),c.hide(!1),i.isActive=!0,void(utils.getStepTarget(o())?i.showStep(a):(utils.invokeEventCallbacks("error"),n("skipIfNoElement")&&i.nextStep(!1)))):void i.endTour(!1,!1)}),this},this.showStep=function(a){var b=e.steps[a];return b.delay?setTimeout(function(){v(a)},b.delay):v(a),this},this.prevStep=function(a){return s.call(this,a,-1),this},this.nextStep=function(a){return s.call(this,a,1),this},this.endTour=function(a,b){var c,d=m();return a=utils.valOrDefault(a,!0),b=utils.valOrDefault(b,!0),e&&(c=o(),c&&c.nextOnTargetClick&&utils.removeEvtListener(utils.getStepTarget(c),"click",p)),f=0,h=void 0,d.hide(),a&&utils.clearState(n("cookieName")),this.isActive&&(this.isActive=!1,e&&b&&utils.invokeEventCallbacks("end")),this.removeCallbacks(null,!0),this.resetDefaultOptions(),e=null,this},this.getCurrTour=function(){return e},this.getCurrTarget=function(){return utils.getStepTarget(o())},this.getCurrStepNum=function(){return f},this.getSkippedStepsIndexes=function(){var a,b=[];for(a in k)b.push(a);return b},this.refreshBubblePosition=function(){var a=o();return a&&m().setPosition(a),this.getCalloutManager().refreshCalloutPositions(),this},this.listen=function(a,b,c){return a&&callbacks[a].push({cb:b,fromTour:c}),this},this.unlisten=function(a,b){var c,d,e=callbacks[a];for(c=0,d=e.length;d>c;++c)e[c]===b&&e.splice(c,1);return this},this.removeCallbacks=function(a,b){var c,d,e,f;for(f in callbacks)if(!a||a===f)if(b)for(c=callbacks[f],d=0,e=c.length;e>d;++d)c[d].fromTour&&(c.splice(d--,1),--e);else callbacks[f]=[];return this},this.registerHelper=function(a,b){"string"==typeof a&&"function"==typeof b&&(helpers[a]=b)},this.unregisterHelper=function(a){helpers[a]=null},this.invokeHelper=function(a){var b,c,d=[];for(b=1,c=arguments.length;c>b;++b)d.push(arguments[b]);helpers[a]&&helpers[a].call(null,d)},this.setCookieName=function(a){return d.cookieName=a,this},this.resetDefaultOptions=function(){return d={},this},this.resetDefaultI18N=function(){return customI18N={},this},this.getState=function(){return utils.getState(n("cookieName"))},i=function(a,b){var c,e,f,g,h=["next","prev","start","end","show","error","close"];for(d||this.resetDefaultOptions(),utils.extend(d,a),a&&utils.extend(customI18N,a.i18n),f=0,g=h.length;g>f;++f)e="on"+h[f].charAt(0).toUpperCase()+h[f].substring(1),a[e]&&this.listen(h[f],a[e],b);return c=m(!0),this},this.configure=function(a){return i.call(this,a,!1)},this.setRenderer=function(a){var b=typeof a;return"string"===b?(templateToUse=a,customRenderer=void 0):"function"===b&&(customRenderer=a),this},this.setEscaper=function(a){return"function"==typeof a&&(customEscape=a),this},x.call(this,a)},winHopscotch=new Hopscotch,context[namespace]=winHopscotch,function(){var _={};_.escape=function(a){return customEscape?customEscape(a):null==a?"":(""+a).replace(new RegExp("[&<>\"']","g"),function(a){return"&"==a?"&":"<"==a?"<":">"==a?">":'"'==a?""":"'"==a?"'":void 0})},this.hopscotch=this.hopscotch||{},this.hopscotch.templates=this.hopscotch.templates||{},this.hopscotch.templates.bubble_default=function(obj){function optEscape(a,b){return b?_.escape(a):a}obj||(obj={});{var __t,__p="";_.escape,Array.prototype.join}with(obj)__p+='\n\n ',tour.isTour&&(__p+='
'+(null==(__t=i18n.stepNum)?"":__t)+" "),__p+='\n
\n ',""!==step.title&&(__p+='
'+(null==(__t=optEscape(step.title,tour.unsafe))?"":__t)+" "),__p+="\n ",""!==step.content&&(__p+='
'+(null==(__t=optEscape(step.content,tour.unsafe))?"":__t)+"
"),__p+='\n
\n
\n ',buttons.showPrev&&(__p+=''+(null==(__t=i18n.prevBtn)?"":__t)+" "),__p+="\n ",buttons.showCTA&&(__p+=''+(null==(__t=buttons.ctaLabel)?"":__t)+" "),__p+="\n ",buttons.showNext&&(__p+=''+(null==(__t=i18n.nextBtn)?"":__t)+" "),__p+="\n
\n ",buttons.showClose&&(__p+='
'+(null==(__t=i18n.closeTooltip)?"":__t)+" "),__p+='\n
\n';return __p}}())}(window,"hopscotch");
\ No newline at end of file
+!function(a,b){"use strict";if("function"==typeof define&&define.amd)define([],b);else if("object"==typeof exports)module.exports=b();else{var c="hopscotch";if(a[c])return;a[c]=b()}}(this,function(){var Hopscotch,HopscotchBubble,HopscotchCalloutManager,HopscotchI18N,customI18N,customRenderer,customEscape,utils,callbacks,helpers,winLoadHandler,defaultOpts,winHopscotch,templateToUse="bubble_default",Sizzle=window.Sizzle||null,undefinedStr="undefined",waitingToStart=!1,hasJquery=typeof jQuery!==undefinedStr,hasSessionStorage=!1,isStorageWritable=!1,document=window.document,validIdRegEx=/^[a-zA-Z]+[a-zA-Z0-9_-]*$/,rtlMatches={left:"right",right:"left"};try{typeof window.sessionStorage!==undefinedStr&&(hasSessionStorage=!0,sessionStorage.setItem("hopscotch.test.storage","ok"),sessionStorage.removeItem("hopscotch.test.storage"),isStorageWritable=!0)}catch(err){}return defaultOpts={smoothScroll:!0,scrollDuration:1e3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,isRtl:!1,cookieName:"hopscotch.tour.state"},Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),winLoadHandler=function(){waitingToStart&&winHopscotch.startTour()},utils={addClass:function(a,b){var c,d,e,f;if(a.className){for(d=b.split(/\s+/),c=" "+a.className+" ",e=0,f=d.length;f>e;++e)c.indexOf(" "+d[e]+" ")<0&&(c+=d[e]+" ");a.className=c.replace(/^\s+|\s+$/g,"")}else a.className=b},removeClass:function(a,b){var c,d,e,f;for(d=b.split(/\s+/),c=" "+a.className+" ",e=0,f=d.length;f>e;++e)c=c.replace(" "+d[e]+" "," ");a.className=c.replace(/^\s+|\s+$/g,"")},hasClass:function(a,b){var c;return a.className?(c=" "+a.className+" ",-1!==c.indexOf(" "+b+" ")):!1},getPixelValue:function(a){var b=typeof a;return"number"===b?a:"string"===b?parseInt(a,10):0},valOrDefault:function(a,b){return typeof a!==undefinedStr?a:b},invokeCallbackArrayHelper:function(a){var b;return Array.isArray(a)&&(b=helpers[a[0]],"function"==typeof b)?b.apply(this,a.slice(1)):void 0},invokeCallbackArray:function(a){var b,c;if(Array.isArray(a)){if("string"==typeof a[0])return utils.invokeCallbackArrayHelper(a);for(b=0,c=a.length;c>b;++b)utils.invokeCallback(a[b])}},invokeCallback:function(a){return"function"==typeof a?a():"string"==typeof a&&helpers[a]?helpers[a]():utils.invokeCallbackArray(a)},invokeEventCallbacks:function(a,b){var c,d,e=callbacks[a];if(b)return this.invokeCallback(b);for(c=0,d=e.length;d>c;++c)this.invokeCallback(e[c].cb)},getScrollTop:function(){var a;return a=typeof window.pageYOffset!==undefinedStr?window.pageYOffset:document.documentElement.scrollTop},getScrollLeft:function(){var a;return a=typeof window.pageXOffset!==undefinedStr?window.pageXOffset:document.documentElement.scrollLeft},getWindowHeight:function(){return window.innerHeight||document.documentElement.clientHeight},addEvtListener:function(a,b,c){return a?a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c):void 0},removeEvtListener:function(a,b,c){return a?a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent("on"+b,c):void 0},documentIsReady:function(){return"complete"===document.readyState||"interactive"===document.readyState},evtPreventDefault:function(a){a.preventDefault?a.preventDefault():event&&(event.returnValue=!1)},extend:function(a,b){var c;for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c])},getStepTargetHelper:function(a){var b=document.getElementById(a);if(b)return b;if(hasJquery)return b=jQuery(a),b.length?b[0]:null;if(Sizzle)return b=new Sizzle(a),b.length?b[0]:null;if(document.querySelector)try{return document.querySelector(a)}catch(c){}return/^#[a-zA-Z][\w-_:.]*$/.test(a)?document.getElementById(a.substring(1)):null},getStepTarget:function(a){var b;if(!a||!a.target)return null;if("string"==typeof a.target)return utils.getStepTargetHelper(a.target);if(Array.isArray(a.target)){var c,d;for(c=0,d=a.target.length;d>c;c++)if("string"==typeof a.target[c]&&(b=utils.getStepTargetHelper(a.target[c])))return b;return null}return a.target},getI18NString:function(a){return customI18N[a]||HopscotchI18N[a]},setState:function(a,b,c){var d,e="";if(hasSessionStorage&&isStorageWritable)try{sessionStorage.setItem(a,b)}catch(f){isStorageWritable=!1,this.setState(a,b,c)}else hasSessionStorage&&sessionStorage.removeItem(a),c&&(d=new Date,d.setTime(d.getTime()+24*c*60*60*1e3),e="; expires="+d.toGMTString()),document.cookie=a+"="+b+e+"; path=/"},getState:function(a){var b,c,d,e=a+"=",f=document.cookie.split(";");if(hasSessionStorage&&(d=sessionStorage.getItem(a)))return d;for(b=0;b0,showNext:utils.valOrDefault(a.showNextButton,this.opt.showNextButton),showCTA:utils.valOrDefault(a.showCTAButton&&a.ctaLabel,!1),ctaLabel:a.ctaLabel,showClose:utils.valOrDefault(this.opt.showCloseButton,!0)},step:{num:b,isLast:utils.valOrDefault(k,!1),title:a.title||"",content:a.content||"",isRtl:a.isRtl,placement:a.placement,padding:utils.valOrDefault(a.padding,this.opt.bubblePadding),width:utils.getPixelValue(a.width)||this.opt.bubbleWidth,customData:a.customData||{}},tour:{isTour:this.opt.isTourBubble,numSteps:h,unsafe:utils.valOrDefault(f,!1),customData:e||{}}},"function"==typeof d)m.innerHTML=d(l);else if("string"==typeof d){if(!winHopscotch.templates||"function"!=typeof winHopscotch.templates[d])throw new Error('Bubble rendering failed - template "'+d+'" is not a function.');m.innerHTML=winHopscotch.templates[d](l)}else if(customRenderer)m.innerHTML=customRenderer(l);else{if(!winHopscotch.templates||"function"!=typeof winHopscotch.templates[templateToUse])throw new Error('Bubble rendering failed - template "'+templateToUse+'" is not a function.');m.innerHTML=winHopscotch.templates[templateToUse](l)}for(children=m.children,numChildren=children.length,i=0;ic;c++)b=e[c],a>b&&d++;return a-d},_getStepI18nNum:function(a){var b=utils.getI18NString("stepNums");return b&&af||f>=e.steps.length?null:e.steps[f]},q=function(){j.nextStep()},r=function(a){var b,c,d,e,f,g,h=m(),i=h.element,j=utils.getPixelValue(i.style.top),k=j+utils.getPixelValue(i.offsetHeight),l=utils.getStepTarget(p()),n=l.getBoundingClientRect(),q=n.top+utils.getScrollTop(),r=n.bottom+utils.getScrollTop(),s=q>j?j:q,t=k>r?k:r,u=utils.getScrollTop(),v=u+utils.getWindowHeight(),w=s-o("scrollTopMargin");s>=u&&(s<=u+o("scrollTopMargin")||v>=t)?a&&a():o("smoothScroll")?typeof YAHOO!==undefinedStr&&typeof YAHOO.env!==undefinedStr&&typeof YAHOO.env.ua!==undefinedStr&&typeof YAHOO.util!==undefinedStr&&typeof YAHOO.util.Scroll!==undefinedStr?(b=YAHOO.env.ua.webkit?document.body:document.documentElement,d=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:void 0,c=new YAHOO.util.Scroll(b,{scroll:{to:[0,w]}},o("scrollDuration")/1e3,d),c.onComplete.subscribe(a),c.animate()):hasJquery?jQuery("body, html").animate({scrollTop:w},o("scrollDuration"),a):(0>w&&(w=0),e=u>s?-1:1,f=Math.abs(u-w)/(o("scrollDuration")/10),(g=function(){var b=utils.getScrollTop(),c=b+e*f;return e>0&&c>=w||0>e&&w>=c?(c=w,a&&a(),void window.scrollTo(0,c)):(window.scrollTo(0,c),utils.getScrollTop()===b?void(a&&a()):void setTimeout(g,10))})()):(window.scrollTo(0,w),a&&a())},s=function(a,b){var c,d,g;f+a>=0&&f+a0?d.multipage:f>0&&e.steps[f-1].multipage,h=function(c){var e;if(-1===c)return this.endTour(!0);if(a&&(e=b>0?utils.invokeEventCallbacks("next",d.onNext):utils.invokeEventCallbacks("prev",d.onPrev)),c===f){if(g)return void x();e=utils.valOrDefault(e,!0),e?this.showStep(c):this.endTour(!1)}},!g&&o("skipIfNoElement"))s(b,function(a){h.call(j,a)});else if(f+b>=0&&f+b2&&(l=d[2].split(",")),h=parseInt(h,10)),this},v=function(a,b,c){var d,e;if(f=a||0,k=b||{},d=p(),e=utils.getStepTarget(d))return void c(f);if(!e){if(utils.invokeEventCallbacks("error"),k[f]=!0,o("skipIfNoElement"))return void s(1,c);f=-1,c(f)}},w=function(a){function b(){d.show(),utils.invokeEventCallbacks("show",c.onShow)}var c=e.steps[a],d=m(),g=utils.getStepTarget(c);f!==a&&p().nextOnTargetClick&&utils.removeEvtListener(utils.getStepTarget(p()),"click",q),f=a,d.hide(!1),d.render(c,a,function(a){a?r(b):b(),c.nextOnTargetClick&&utils.addEvtListener(g,"click",q)}),x()},x=function(){var a=e.id+":"+f,b=winHopscotch.getSkippedStepsIndexes();b&&b.length>0&&(a+=":"+b.join(",")),utils.setState(o("cookieName"),a,1)},y=function(a){a&&this.configure(a)};this.getCalloutManager=function(){return typeof c===undefinedStr&&(c=new HopscotchCalloutManager),c},this.startTour=function(a,b){var c,d,f={},i=this;if(!e){if(!a)throw new Error("Tour data is required for startTour.");if(!a.id||!validIdRegEx.test(a.id))throw new Error("Tour ID is using an invalid format. Use alphanumeric, underscores, and/or hyphens only. First character must be a letter.");e=a,u.call(this,a)}if(typeof b!==undefinedStr){if(b>=e.steps.length)throw new Error("Specified step number out of bounds.");d=b}if(!utils.documentIsReady())return waitingToStart=!0,this;if("undefined"==typeof d&&e.id===g&&typeof h!==undefinedStr){if(d=h,l.length>0)for(var j=0,k=l.length;k>j;j++)f[l[j]]=!0}else d||(d=0);return v(d,f,function(a){var b=-1!==a&&utils.getStepTarget(e.steps[a]);return b?(utils.invokeEventCallbacks("start"),c=m(),c.hide(!1),i.isActive=!0,void(utils.getStepTarget(p())?i.showStep(a):(utils.invokeEventCallbacks("error"),o("skipIfNoElement")&&i.nextStep(!1)))):void i.endTour(!1,!1)}),this},this.showStep=function(a){var b=e.steps[a];if(utils.getStepTarget(b))return b.delay?setTimeout(function(){w(a)},b.delay):w(a),this},this.prevStep=function(a){return t.call(this,a,-1),this},this.nextStep=function(a){return t.call(this,a,1),this},this.endTour=function(a,b){var c,d=m();return a=utils.valOrDefault(a,!0),b=utils.valOrDefault(b,!0),e&&(c=p(),c&&c.nextOnTargetClick&&utils.removeEvtListener(utils.getStepTarget(c),"click",q)),f=0,h=void 0,d.hide(),a&&utils.clearState(o("cookieName")),this.isActive&&(this.isActive=!1,e&&b&&utils.invokeEventCallbacks("end")),this.removeCallbacks(null,!0),this.resetDefaultOptions(),n(),e=null,this},this.getCurrTour=function(){return e},this.getCurrTarget=function(){return utils.getStepTarget(p())},this.getCurrStepNum=function(){return f},this.getSkippedStepsIndexes=function(){var a,b=[];for(a in k)b.push(a);return b},this.refreshBubblePosition=function(){var a=p();return a&&m().setPosition(a),this.getCalloutManager().refreshCalloutPositions(),this},this.listen=function(a,b,c){return a&&callbacks[a].push({cb:b,fromTour:c}),this},this.unlisten=function(a,b){var c,d,e=callbacks[a];for(c=0,d=e.length;d>c;++c)e[c]===b&&e.splice(c,1);return this},this.removeCallbacks=function(a,b){var c,d,e,f;for(f in callbacks)if(!a||a===f)if(b)for(c=callbacks[f],d=0,e=c.length;e>d;++d)c[d].fromTour&&(c.splice(d--,1),--e);else callbacks[f]=[];return this},this.registerHelper=function(a,b){"string"==typeof a&&"function"==typeof b&&(helpers[a]=b)},this.unregisterHelper=function(a){helpers[a]=null},this.invokeHelper=function(a){var b,c,d=[];for(b=1,c=arguments.length;c>b;++b)d.push(arguments[b]);helpers[a]&&helpers[a].call(null,d)},this.setCookieName=function(a){return d.cookieName=a,this},this.resetDefaultOptions=function(){return d={},this},this.resetDefaultI18N=function(){return customI18N={},this},this.getState=function(){return utils.getState(o("cookieName"))},i=function(a,b){var c,e,f,g,h=["next","prev","start","end","show","error","close"];for(d||this.resetDefaultOptions(),utils.extend(d,a),a&&utils.extend(customI18N,a.i18n),f=0,g=h.length;g>f;++f)e="on"+h[f].charAt(0).toUpperCase()+h[f].substring(1),a[e]&&this.listen(h[f],a[e],b);return c=m(!0),this},this.configure=function(a){return i.call(this,a,!1)},this.setRenderer=function(a){var b=typeof a;return"string"===b?(templateToUse=a,customRenderer=void 0):"function"===b&&(customRenderer=a),this},this.setEscaper=function(a){return"function"==typeof a&&(customEscape=a),this},y.call(this,a)},winHopscotch=new Hopscotch,function(){var _={};_.escape=function(a){return customEscape?customEscape(a):null==a?"":(""+a).replace(new RegExp("[&<>\"']","g"),function(a){return"&"==a?"&":"<"==a?"<":">"==a?">":'"'==a?""":"'"==a?"'":void 0})},this.templates=this.templates||{},this.templates.bubble_default=function(obj){function optEscape(a,b){return b?_.escape(a):a}obj||(obj={});{var __t,__p="";_.escape,Array.prototype.join}with(obj)__p+='\n\n ',tour.isTour&&(__p+='
'+(null==(__t=i18n.stepNum)?"":__t)+" "),__p+='\n
\n ',""!==step.title&&(__p+='
'+(null==(__t=optEscape(step.title,tour.unsafe))?"":__t)+" "),__p+="\n ",""!==step.content&&(__p+='
'+(null==(__t=optEscape(step.content,tour.unsafe))?"":__t)+"
"),__p+='\n
\n
\n ',buttons.showPrev&&(__p+=''+(null==(__t=i18n.prevBtn)?"":__t)+" "),__p+="\n ",buttons.showCTA&&(__p+=''+(null==(__t=buttons.ctaLabel)?"":__t)+" "),__p+="\n ",buttons.showNext&&(__p+=''+(null==(__t=i18n.nextBtn)?"":__t)+" "),__p+="\n
\n ",buttons.showClose&&(__p+='
'+(null==(__t=i18n.closeTooltip)?"":__t)+" "),__p+='\n
\n';return __p}}.call(winHopscotch),winHopscotch});
\ No newline at end of file
diff --git a/package.json b/package.json
index adfc4e24..4d5a1314 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "hopscotch",
- "version": "0.2.3",
+ "version": "0.2.4",
"description": "A framework to make it easy for developers to add product tours to their pages.",
"main": "dist/js/hopscotch.min.js",
"directories": {