From fd844895eef178cb892511089af74e23b385836b Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 4 Aug 2017 10:51:00 +0100 Subject: [PATCH 1/4] Prevent AnnoButton clicks from bubbling up to surrounding elements on the page --- anno.js | 1 + src/anno.litcoffee | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/anno.js b/anno.js index 4a20e85..381d8d1 100644 --- a/anno.js +++ b/anno.js @@ -531,6 +531,7 @@ AnnoButton = (function() { AnnoButton.prototype.buttonElem = function(anno) { return $("").html(this.textFn(anno)).addClass(this.className).click((function(_this) { return function(evt) { + evt.preventDefault(); return _this.click.call(anno, anno, evt); }; })(this)); diff --git a/src/anno.litcoffee b/src/anno.litcoffee index e5dfe7f..a68a8a4 100644 --- a/src/anno.litcoffee +++ b/src/anno.litcoffee @@ -558,7 +558,10 @@ Buttons return $(""). html( @textFn(anno) ). addClass( @className ). - click( (evt) => @click.call(anno, anno, evt) ) + click( (evt) => { + evt.preventDefault(); + @click.call(anno, anno, evt) + }) textFn: (anno) -> if @text? then @text From f4b6d08735b8a6e128d76a11bdbba3a7eb208b79 Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 4 Aug 2017 11:00:15 +0100 Subject: [PATCH 2/4] Turns out you need evt.stopPropagation to prevent click events being bubbled up as well as for submit events --- anno.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/anno.js b/anno.js index 381d8d1..07f7608 100644 --- a/anno.js +++ b/anno.js @@ -531,7 +531,8 @@ AnnoButton = (function() { AnnoButton.prototype.buttonElem = function(anno) { return $("").html(this.textFn(anno)).addClass(this.className).click((function(_this) { return function(evt) { - evt.preventDefault(); + evt.stopPropagation(); + evt.preventDefault(); return _this.click.call(anno, anno, evt); }; })(this)); From 6796eb20ae9e7b44d7bb4b922ad111edb2fb4476 Mon Sep 17 00:00:00 2001 From: Nathan Date: Fri, 4 Aug 2017 12:37:41 +0100 Subject: [PATCH 3/4] Added onComplete and onDismissed event handlers so that devs know when a user ended/finished a tour. --- .DS_Store | Bin 0 -> 6148 bytes anno.js | 22 +++++++++++++++++++--- src/anno.litcoffee | 25 ++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 + +Complete is called when an anno chain reaches the end. + + complete: () -> + @hide() + @onComplete(this) + return this + +Dismissed is called when a user effectively ends a tour by clicking on the overlay background. + + onDismissed: (anno) -> + + dismissed: () -> + @hide() + @onDismissed(this) + return this + Hiding is done in two stages so that you can re-use one overlay element for a long chain of Anno's. hide: () -> @@ -345,7 +363,8 @@ Semi-transparent overlay and other effects click( (evt) => @overlayClick.call(this, this, evt) ) overlayClassName: '' # TODO talk about .anno-hidden - overlayClick: (anno, evt) -> anno.hide() + + overlayClick: (anno, evt) -> anno.dismissed() hideOverlay: () -> $('.anno-overlay').addClass 'anno-hidden' @@ -579,14 +598,14 @@ fat arrow. if anno._chainNext? anno.switchToChainNext() else - anno.hide() + anno.complete() These are some handy presets that you can use by adding `AnnoButton.NextButton` to your Anno object's `buttons` list. @NextButton: new AnnoButton({ text: 'Next' , click: () -> @switchToChainNext() }) - @DoneButton: new AnnoButton({ text: 'Done' , click: () -> @hide() }) + @DoneButton: new AnnoButton({ text: 'Done' , click: () -> @complete() }) @BackButton: new AnnoButton( text: 'Back' From 7cf34f809ad128793c932ead2eef0678f60caa2b Mon Sep 17 00:00:00 2001 From: Nathan Date: Wed, 27 Feb 2019 16:33:35 +0000 Subject: [PATCH 4/4] Remove osx file --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 5008ddfcf53c02e82d7eee2e57c38e5672ef89f6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0