type Script= String
type OnLoadScript= String
type File= String
data WebRequirement= CSSFile String
| CSS Script
| JScriptFile File [OnLoadScript]
| JScript Script
| ServerProc (String, Token -> Workflow IO ())
[OnLoadScript] are scripts called when the script file is loaded.
The syntax is as such:
ask $ requires[WebRequirement]
>> rest of the page
here >> is the monadic operator
For example this widget show set of options in from data from the serves via AJAX, is defined in MFlow.Forms.Widgets, insert two javascript files, a CSS file and a script. It can be combined with other widgets that require also these scripts, but the page creation process will just insert a single script tag or css link. The programmer no longer has to care about the requirements of each widget
selectAutocomplete serverproc = do
requires [JScript ajaxScript
,JScriptFile jqueryScript [events]
,CSSFile jqueryCSS
,JScriptFile jqueryUi []]
ajaxc <- ajaxcommand="ajaxcommand" attr="attr" font="font" text1="text1" value="value">->
$ \u -> do
r <- font="font" serverproc="serverproc" u="u">->
return $ jaddtoautocomp r
getCheckBoxes
(thediv ! [strAttr "id" "users"] <<< noWidget )
<++ input ![thetype "text"
,value "select users"
,strAttr "id" "text1"
,strAttr "oninput" ajaxc
,strAttr "autocomplete" "off"]
This example uses the last version of MFlow at https://github.com/agocorona/MFlow.
It uses the last version of Workflow https://github.com/agocorona/Workflow
TCache : https://github.com/agocorona/TCache
RefSerialize: https://github.com/agocorona/RefSerialize
No comments:
Post a Comment