Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Wrapping onClose callbacks or having global events #75

Closed
maraujop opened this Issue · 2 comments

2 participants

@maraujop

It would be nice to have a way to write some general code that executed on every onClose callback, a function that wraps the callback or having an event that flags that the tour was closed.

For example, I want to do a certain action on all steps closing and I don't want to write a onClose function for every single step repeating code or calling the same function.

I believe this is not possible currently. Meanwhile I've added an event to handle this case.

thanks, cheers,
Miguel

@maraujop

Here is the event I've added that is triggered on body, its name is guiders-close.

diff --git a/static/js/libraries/guiders-1.2.8.js b/static/js/libraries/guiders-1.2.8.js
index a5f970b..90ec37a 100644
--- a/static/js/libraries/guiders-1.2.8.js
+++ b/static/js/libraries/guiders-1.2.8.js
@@ -116,6 +116,7 @@ var guiders = (function($) {
               guiders.hideAll();
               if (myGuider.onClose) {
                 myGuider.onClose(myGuider, false /* close by button */);
+                $('body').trigger("guiders-close");
               }
             });
             break;
@@ -153,7 +154,8 @@ var guiders = (function($) {
       guiders.hideAll();
       if (myGuider.onClose) {
         myGuider.onClose(myGuider, true);
-       }
+        $('body').trigger("guiders-close");
+      }
     });
   };

@@ -163,6 +165,7 @@ var guiders = (function($) {
         guiders.hideAll();
         if (myGuider.onClose) {
           myGuider.onClose(myGuider, true /*close by X/Escape*/);
+          $('body').trigger("guiders-close");
         }
         return false;
       }

Cheers,
Miguel

@pickhardt
Collaborator

Thanks Miguel. I am going to use this, but with camelCase instead of hyphens. Also, I'm not going to merge directly into master anymore. I just created a dev branch. This way I'll be able to merge pull requests to dev without screwing up master, while working on a new version.

@pickhardt pickhardt closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.