UI Customisation
From Ajax Patterns
Contents |
Ajax/Javascript Programming and Usability in "Ajax Design Patterns" Book |
[edit]
Code Example
A standard initialisation library function sets up gadget title and colour scheme for the main element, which is passed in.
var prefs = new _IG_Prefs();
function pref(id) { return prefs.getString(id); }
function adjustHeight() { if (_IG_AdjustIFrameHeight) _IG_AdjustIFrameHeight(); }
function setTitle(title) { if (_IG_SetTitle) _IG_SetTitle(title); }
function initialiseStandardPrefs(mainEl) {
mainEl.style.background = pref("backgroundColour");
mainEl.style.color = pref("textColour");
adjustHeight();
setTitle(pref("title"));
}
Gadgets must declare these preferences. A Gadget Factory can be used to keep it DRY. e.g. http://ajaxify.com/run/widgets/opensuite/message/message.xml
<UserPref name="title" display_name="Title" default_value="Message" />
...
<UserPref name="backgroundColour" display_name="Background Colour"
default_value= "white" />
<UserPref name="textColour" display_name="Text Colour"
default_value= "black" />
We invoke the library function on gadget startup.
initialiseStandardPrefs($("message"));
Time your website with
WebWait - from the creator of AjaxPatterns.org
