Your widget is an XML file :
The ModulePrefs tag is used to define the properties of the widget :
Some tags can inform API that a widget contains some required features.
With POSH, you can add a require which inform API the l10n files of your widget are relative to your portal. So your url might be relative.
If you download a Portaneo widget, this widget contains the following require feature.
Some Portaneo widgets can be integrated to your portal by your administrator. In this case, the urls will be relative to your portal. These widgets contain the following require feature.
The UserPref tags are used to define the widget's options, that will give personalization to users. These are the options that show up when you click on "configure" button in the widget's header.
The Content tag regroups the widget's HTML and javaScript code.
With new version (Posh 2.1), you may define several content
for each view of your widget, home view for original widget, canvas view for full screen state.
view attribute, several options :
Code functions | |
_IG_RegisterOnloadHandler(FUNCTION) | Call the FUNCTION function on the widget loading. example : function init(){ alert('hello world'); } _IG_RegisterOnloadHandler(init); |
_IG_AdjustIFrameHeight() | Adjust the widget height to the widget content. Use it if the widget's height change. |
_IG_FetchContent(URL, FUNCTION) | Load the content of a file defined by its URL and send the results to the FUNCTION function. Using of asynchronous Ajax. Example : function treatFile(responsetxt){ var obj=_gel("mydiv"); obj.innerHTML=responsetxt; } _IG_FetchContent('http://www.mysite.com/mydoc.csv',treatFile); |
_IG_FetchXmlContent(URL, FUNCTION) | Load the content of an XML file defined by its URL and send the results to the FUNCTION function. Using of asynchronous Ajax. Example : function treatXml(responsexml){ var str="name : "+responsexml.getElementsByTagName("name")[0].firstChild.nodeValue+" age : "+responsexml.getElementsByTagName("age")[0].firstChild.nodeValue; var obj=_gel("mydiv"); obj.innerHTML=str; } _IG_FetchXmlContent('http://www.mysite.com/myxmlfile.xml',treatXml); |
Function that use options | |
_IG_Prefs(__MODULE_ID__) | Send the options to an object. Example : var pref = new _IG_Prefs(__MODULE_ID__); |
.getString("variable") | Retrieve the value of a "string" option. Example : var name = pref.getString("yourname"); |
.getInt("variable") | Retrieve the integer value of a "string" option. |
.getBool("variable") | Retrieve the value of a "bool" option. |
.set("variable","value") | Modify the value of a specified option. Exemple : pref.set("yourname","John Wayne"); |
.open() | Open the options configuration box. Example : <A href=# onclick="return pref.open()">Modify the options</A> |
Tabs management | |
_IG_Tabs(__MODULE_ID__,"default selection") | Initialize tab management. Return tabs object, used to execute functions below. "default selection" is the name of the selected tab (optional). Example : var tabs = new _IG_Tabs(__MODULE_ID__); |
.tabsContainer | Optional. Define the object that will contain the tabs. Example : tabs.tabsContainer=_gel("tabsdiv"); (if you have created an object <div id="tabsdiv"></div>) |
.addTab("tabname","divid","function") | Create a new tab, with "tabname" name, inside "divid" div object, calling "function" function when clicked. Example : tabs.addTabs("tab 1","tabdiv","displayTab1Content"); |
.setSelectedTab("tabIndex") | Define the selected tab."tabIndex" is the index of the tab (start with 0). |
Other functions | |
_bringToFront(__MODULE_ID__) | Bring a widget to front, above the others. |
_gel("object") | Get the object which ID is "object". Example : var obj=_get("mydiv");obj.innerHTML='Hello world !'; |
_gelstn("object") | A wrapper around the javaScript .getElementsByTagName() method. |
_esc("string") | A wrapper around the javaScript .escape() method. |
_unesc("string") | A wrapper around the javaScript .unescape() method. |
_uc("string") | Return uppercase value of "string" string. |
_lc("string") | Return lowercase value of "string" string. |
_min(value1,value2) | Return the lesser value of value1 and value2. |
_max(value1,value2) | Return the greater value of value1 and value2. |
_args("string") | Transforms the string "name=john&age=12&sex=m" to the array {"name":"john","age":"12","sex":"m"} |
_trim("string") | Remove the useless whitespaces. |
canvas mode functions | |
gadgets.views.getCurrentView | return current view |
gadgets.views.getName | return name of the current view |
gadgets.views.getSupportedViews() | Return a hash of the widget supported views |
gadgets.views.requestNavigateTo(function) | Open the widget in the requested view ('home' or 'canvas') Example that open the CANVAS view: gadgets.views.requestNavigateTo(gadgets.views.getSupportedViews()['canvas']); |
gadgets.views.changeUrl(url) | Update Url of a widget to open a any page from the widget in full screen |
After each widget modification, test it with the tester before asking for publication (tool available on the Advanced widget page). Ready? GO!