From 6ac3a70e704aba72b02ffea56a390826009eacd8 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Thu, 23 Jun 2016 20:06:21 -0700 Subject: [PATCH 1/8] Add error callback for showStep Calling showStep without a proper step target fails, but the tour error callback is not invoked. This change fixes that, and sets the current step number to the step that failed for debugging purposes --- src/js/hopscotch.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 29ff47df..3bf39172 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1945,6 +1945,8 @@ this.showStep = function(stepNum) { var step = currTour.steps[stepNum]; if(!utils.getStepTarget(step)) { + currStepNum = stepNum; + utils.invokeEventCallbacks('error'); return; } From 191048c8599b21d0c9afee1ffafd388f8430e237 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 16:46:31 -0700 Subject: [PATCH 2/8] Revert step num after error callback Not sure if this will work --- src/js/hopscotch.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 3bf39172..88cb9814 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1945,8 +1945,10 @@ this.showStep = function(stepNum) { var step = currTour.steps[stepNum]; if(!utils.getStepTarget(step)) { + prevStepNum = currStepNum; currStepNum = stepNum; utils.invokeEventCallbacks('error'); + currStepNum = prevStepNum; return; } From ffa1a3e9aa7402f78f06c183e1ade8c752411299 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 16:55:26 -0700 Subject: [PATCH 3/8] remove all stepNum stuff, see if it still breaks just a test to see what's breaking --- src/js/hopscotch.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 88cb9814..4b075169 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1945,10 +1945,7 @@ this.showStep = function(stepNum) { var step = currTour.steps[stepNum]; if(!utils.getStepTarget(step)) { - prevStepNum = currStepNum; - currStepNum = stepNum; utils.invokeEventCallbacks('error'); - currStepNum = prevStepNum; return; } From 8dfed46adf0bd2c0f980515c3f182597ae520ab8 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 16:58:32 -0700 Subject: [PATCH 4/8] Add templates stuff --- src/js/hopscotch.js | 86 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 84 insertions(+), 2 deletions(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 4b075169..fe4c196d 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -2431,8 +2431,90 @@ // Template includes, placed inside a closure to ensure we don't // end up declaring our shim globally. (function(){ -// @@include('../../src/tl/_template_headers.js') // -// @@include('../../tmp/js/hopscotch_templates.js') // +var _ = {}; +/* + * Adapted from the Underscore.js framework. Check it out at + * https://github.com/jashkenas/underscore + */ +_.escape = function(str){ + if(customEscape){ return customEscape(str); } + + if(str == null) return ''; + return ('' + str).replace(new RegExp('[&<>"\']', 'g'), function(match){ + if(match == '&'){ return '&' } + if(match == '<'){ return '<' } + if(match == '>'){ return '>' } + if(match == '"'){ return '"' } + if(match == "'"){ return ''' } + }); +} +this["templates"] = this["templates"] || {}; + +this["templates"]["bubble_default"] = function(obj) { +obj || (obj = {}); +var __t, __p = '', __e = _.escape, __j = Array.prototype.join; +function print() { __p += __j.call(arguments, '') } +with (obj) { + + + function optEscape(str, unsafe){ + if(unsafe){ + return _.escape(str); + } + return str; + } +; +__p += '\n
\n '; + if(tour.isTour){ ; +__p += '' + +((__t = ( i18n.stepNum )) == null ? '' : __t) + +''; + } ; +__p += '\n
\n '; + if(step.title !== ''){ ; +__p += '

' + +((__t = ( optEscape(step.title, tour.unsafe) )) == null ? '' : __t) + +'

'; + } ; +__p += '\n '; + if(step.content !== ''){ ; +__p += '
' + +((__t = ( optEscape(step.content, tour.unsafe) )) == null ? '' : __t) + +'
'; + } ; +__p += '\n
\n
\n '; + if(buttons.showPrev){ ; +__p += ''; + } ; +__p += '\n '; + if(buttons.showCTA){ ; +__p += ''; + } ; +__p += '\n '; + if(buttons.showNext){ ; +__p += ''; + } ; +__p += '\n
\n '; + if(buttons.showClose){ ; +__p += ''; + } ; +__p += '\n
\n
\n
\n
\n
'; + +} +return __p +}; }.call(winHopscotch)); return winHopscotch; From 652e8774f2625f0aaeb4e7eb8e85df7f0ab49c33 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 17:15:01 -0700 Subject: [PATCH 5/8] Revert "Add templates stuff" This reverts commit 8dfed46adf0bd2c0f980515c3f182597ae520ab8. --- src/js/hopscotch.js | 86 ++------------------------------------------- 1 file changed, 2 insertions(+), 84 deletions(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index fe4c196d..4b075169 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -2431,90 +2431,8 @@ // Template includes, placed inside a closure to ensure we don't // end up declaring our shim globally. (function(){ -var _ = {}; -/* - * Adapted from the Underscore.js framework. Check it out at - * https://github.com/jashkenas/underscore - */ -_.escape = function(str){ - if(customEscape){ return customEscape(str); } - - if(str == null) return ''; - return ('' + str).replace(new RegExp('[&<>"\']', 'g'), function(match){ - if(match == '&'){ return '&' } - if(match == '<'){ return '<' } - if(match == '>'){ return '>' } - if(match == '"'){ return '"' } - if(match == "'"){ return ''' } - }); -} -this["templates"] = this["templates"] || {}; - -this["templates"]["bubble_default"] = function(obj) { -obj || (obj = {}); -var __t, __p = '', __e = _.escape, __j = Array.prototype.join; -function print() { __p += __j.call(arguments, '') } -with (obj) { - - - function optEscape(str, unsafe){ - if(unsafe){ - return _.escape(str); - } - return str; - } -; -__p += '\n
\n '; - if(tour.isTour){ ; -__p += '' + -((__t = ( i18n.stepNum )) == null ? '' : __t) + -''; - } ; -__p += '\n
\n '; - if(step.title !== ''){ ; -__p += '

' + -((__t = ( optEscape(step.title, tour.unsafe) )) == null ? '' : __t) + -'

'; - } ; -__p += '\n '; - if(step.content !== ''){ ; -__p += '
' + -((__t = ( optEscape(step.content, tour.unsafe) )) == null ? '' : __t) + -'
'; - } ; -__p += '\n
\n
\n '; - if(buttons.showPrev){ ; -__p += ''; - } ; -__p += '\n '; - if(buttons.showCTA){ ; -__p += ''; - } ; -__p += '\n '; - if(buttons.showNext){ ; -__p += ''; - } ; -__p += '\n
\n '; - if(buttons.showClose){ ; -__p += ''; - } ; -__p += '\n
\n
\n
\n
\n
'; - -} -return __p -}; +// @@include('../../src/tl/_template_headers.js') // +// @@include('../../tmp/js/hopscotch_templates.js') // }.call(winHopscotch)); return winHopscotch; From 27f6d73a967c22b65f38718e55288dfda32f339c Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 17:29:46 -0700 Subject: [PATCH 6/8] Resubmit error callback patch temporarily set currStepNum then revert --- src/js/hopscotch.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 4b075169..88cb9814 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1945,7 +1945,10 @@ this.showStep = function(stepNum) { var step = currTour.steps[stepNum]; if(!utils.getStepTarget(step)) { + prevStepNum = currStepNum; + currStepNum = stepNum; utils.invokeEventCallbacks('error'); + currStepNum = prevStepNum; return; } From 96091ea81d0f8003c940e20ace144b34c9e45185 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 17:34:52 -0700 Subject: [PATCH 7/8] deglobalizing temporary var --- src/js/hopscotch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index 88cb9814..bd368b24 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1945,7 +1945,7 @@ this.showStep = function(stepNum) { var step = currTour.steps[stepNum]; if(!utils.getStepTarget(step)) { - prevStepNum = currStepNum; + var prevStepNum = currStepNum; currStepNum = stepNum; utils.invokeEventCallbacks('error'); currStepNum = prevStepNum; From b30cc254ff0b147a2737cb2f638aaf9ca8d69010 Mon Sep 17 00:00:00 2001 From: Travis Stone Date: Fri, 24 Jun 2016 17:43:34 -0700 Subject: [PATCH 8/8] Hoist temp var to top of function --- src/js/hopscotch.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/js/hopscotch.js b/src/js/hopscotch.js index bd368b24..aa7b0ade 100644 --- a/src/js/hopscotch.js +++ b/src/js/hopscotch.js @@ -1943,9 +1943,9 @@ * @returns {Object} Hopscotch */ this.showStep = function(stepNum) { - var step = currTour.steps[stepNum]; + var step = currTour.steps[stepNum], + prevStepNum = currStepNum; if(!utils.getStepTarget(step)) { - var prevStepNum = currStepNum; currStepNum = stepNum; utils.invokeEventCallbacks('error'); currStepNum = prevStepNum;