Wrapping onClose callbacks or having global events #75

Closed
maraujop opened this Issue Jul 27, 2012 · 2 comments

Comments

Projects
None yet
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

This comment has been minimized.

Show comment Hide comment
@maraujop

maraujop Jul 30, 2012

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

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

This comment has been minimized.

Show comment Hide comment
@pickhardt

pickhardt Jan 27, 2013

Owner

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.

Owner

pickhardt commented Jan 27, 2013

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 Jan 27, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment