Empower your power users
Switcheroo is designed to be easily to implement. Giving your users a much better navigation experience should not be a big deal! Simple include the Switcheroo javascript file, and when you have your data in the switcheroo object format create a Switcheroo instance.
The Switcheroo constructor expects a parameter object, any parameters left unset will be set by default. The format is as follows:
{
// Holds the data that will be searched
data: [],
// Key bindings for quick open and closing of Switcheroo
keyBindings: {
open: ['Control','Shift','F'],
close: ['Escape']
},
// The text labes used within Switcheroo
text: {
closeButton: 'Close',
searchField: 'Start Typing...'
},
// Show Switcheroo categories on result
showCategories: true,
// Put sorted objects into categorical groups based on category
prioritizeCategoricalSort: true,
// Automatically close Switcheroo when a result is selected by the user
closeOnSelect: true,
// Specifies whether search results should be case sensitive or not
caseSensitive: false
}
Like the constructor parameters, there is an expected data format, this will not be desigend by default. The format is as follow:
{
// Group which the object belongs too
category: 'friend',
// Name is the content that will be search against
name: 'fran',
// Actions are functions that are called and passed the object that are they contained in.
action: genericAction
// Note: adding custom data fields is encouraged
myCustomProperty: "Fran is the best!"
}
Once a user has selected a search result that result object is passed to the action function that was included when the Switcheroo instance was created. Having custom functions for different categories or results allows for maximum customization when a result is selected.