I'm working on a site that has a few site design specific widgets like tabs, alerts, messages, autocomplete etc. Unfortunately they're either global functions:
customAlert("message", "buttontext", callback);
or jquery ui widgets:
$(".tabs").customTabs();
I've started on rewriting these in the following format:
sitename.ui.alert(settings, callback);
sitename.ui.message(message);
but I'm stuck on how to do this for UI widgets. I want the API to be simple and straightforward and discover-able with Google Chromes console.
The following example works, however I don't like the idea of having function names as string literals. Also it mixes DOM related code with my API code.
$(".tabs").customTabs("hideByIndex", 3);
So the tabs API call should look something like this:
sitename.ui.tabs($selector); // init
sitename.ui.tabs($selector).hideByIndex(3); // call function
or this:
sitename.ui.tabs.create($selector); // init
sitename.ui.tabs.hideByIndex($selector, index); //call function
Or is there another way? Please leave your thoughts on what path I should take.