zurb / joyride

jQuery feature tour plugin.
http://www.zurb.com/playground/jquery-joyride-feature-tour-plugin
1.42k stars 238 forks source link

Make the callbacks options to accept function name #167

Open intellisense opened 10 years ago

intellisense commented 10 years ago

I have created a Django application django-joyride on top of this library where joyrides are configurable through admin panel. As now all the configuration is managed through admin, It is necessary that postExposeCallback etc callbacks should accept function name as string:

postExposeCallback: "my_callback_name"

You just need to add below lines in non configurable settings in order to achieve that:

// check if callbacks are passed as string
if (typeof settings.postExposeCallback !== "function"){
    settings.postExposeCallback = window[settings.postExposeCallback];
}
if (typeof settings.preRideCallback !== "function"){
    settings.preRideCallback = window[settings.preRideCallback];
}
if (typeof settings.postRideCallback !== "function"){
    settings.postRideCallback = window[settings.postRideCallback];
}
if (typeof settings.preStepCallback !== "function"){
    settings.preStepCallback = window[settings.preStepCallback];
}
if (typeof settings.postStepCallback !== "function"){
    settings.postStepCallback = window[settings.postStepCallback];
}