Commit 2ed7c9bb authored by Bas Lijnse's avatar Bas Lijnse

Fixed focus handling to work for checkboxes and selectboxes as well


git-svn-id: https://svn.cs.ru.nl/repos/iTask-system/trunk@123 63da3aa8-80fd-4f01-9db8-e6ea747a3da2
parent 4fd3129b
......@@ -32,7 +32,7 @@ urlDecode :: !String -> *String
// Form submission handling
callClean :: !Bool !Mode !String !Lifespan -> [ElementEvents]
callClean :: !(Script -> ElementEvents) !Mode !String !Lifespan !Bool -> [ElementEvents]
submitscript :: BodyTag
initscript :: BodyTag
globalstateform :: !Value !Value -> BodyTag
......
......@@ -18,10 +18,10 @@ derive gPrint UpdValue, (,,), (,)
// script for transmitting name and value of changed input
callClean :: !Bool !Mode !String !Lifespan -> [ElementEvents]
callClean onClick Edit _ lsp = [(onSomething onClick) (SScript ("toclean(this," <+++ isOnClient lsp <+++ "," <+++ (doSubmit onClick) <+++ ")"))]
callClean onClick Submit myid lsp = [(onSomething onClick) (SScript ("toclean2(" <+++ myid <+++ "," <+++ isOnClient lsp <+++ ",true)"))]
callClean onClick _ _ _ = []
callClean :: !(Script -> ElementEvents) !Mode !String !Lifespan !Bool -> [ElementEvents]
callClean onSomething Edit _ lsp submit = [onSomething (SScript ("toclean(this," <+++ isOnClient lsp <+++ "," <+++ (doSubmit submit) <+++ ")"))]
callClean onSomething Submit myid lsp submit = [onSomething (SScript ("toclean2(" <+++ myid <+++ "," <+++ isOnClient lsp <+++ ",true)"))]
callClean onSomething _ _ _ _ = []
onSomething True = OnClick
onSomething False = OnChange
......@@ -75,11 +75,12 @@ submitscript
[ Script [] (SScript
( " function toclean(inp,onclient,submit) {" +++
" document." +++ globalFormName +++ "." +++ updateInpName +++ ".value=inp.name+\"=\"+inp.value; " +++
" document." +++ globalFormName +++ "." +++ focusInpName +++ ".value=this.name;\n;" +++
" document." +++ globalFormName +++ "." +++ focusInpName +++ ".value=inp.name;\n;" +++
" if(submit) {" +++
" document." +++ globalFormName +++ ".submit();" +++
" } else {" +++
" cleanUpdated = true;" +++
" }" +++
" cleanUpdated = true;" +++
" }"
))
, Script [] (SScript
......
......@@ -142,7 +142,7 @@ gForm{|Button|} (init,formid) hst
, Inp_Value (SV (cleanString bname))
, Inp_Name (encodeTriplet (formid.id,cntr,UpdS bname))
, `Inp_Std [Std_Style ("width:" <+++ size), Std_Id (encodeTriplet (formid.id,cntr,UpdS bname))]
, `Inp_Events (callClean True Edit "" formid.lifespan)
, `Inp_Events (callClean OnClick Edit "" formid.lifespan True)
]) ""]
},(incrHSt 1 hst))
v=:(PButton (height,width) ref)
......@@ -153,7 +153,7 @@ gForm{|Button|} (init,formid) hst
, Inp_Value (SV (cleanString ref))
, Inp_Name (encodeTriplet (formid.id,cntr,UpdS ref))
, `Inp_Std [Std_Style ("width:" <+++ width <+++ " height:" <+++ height), Std_Id (encodeTriplet (formid.id,cntr,UpdS ref))]
, `Inp_Events (callClean True Edit "" formid.lifespan)
, `Inp_Events (callClean OnClick Edit "" formid.lifespan True)
, Inp_Src ref
]) ""]
},incrHSt 1 hst)
......@@ -172,7 +172,7 @@ gForm{|CheckBox|} (init,formid) hst
, Inp_Name (encodeTriplet (formid.id,cntr,UpdS name))
, Inp_Checked Checked
, `Inp_Std [Std_Id (encodeTriplet (formid.id,cntr,UpdS name))]
, `Inp_Events (callClean True formid.mode "" formid.lifespan)
, `Inp_Events (callClean OnClick formid.mode "" formid.lifespan True)
]) ""]
},incrHSt 1 hst)
v=:(CBNotChecked name)
......@@ -183,7 +183,7 @@ gForm{|CheckBox|} (init,formid) hst
, Inp_Value (SV (cleanString name))
, Inp_Name (encodeTriplet (formid.id,cntr,UpdS name))
, `Inp_Std [Std_Id (encodeTriplet (formid.id,cntr,UpdS name))]
, `Inp_Events (callClean True formid.mode "" formid.lifespan)
, `Inp_Events (callClean OnClick formid.mode "" formid.lifespan True)
]) ""]
},incrHSt 1 hst)
......@@ -199,7 +199,7 @@ gForm{|RadioButton|} (init,formid) hst
, Inp_Name (encodeTriplet (formid.id,cntr,UpdS name))
, Inp_Checked Checked
, `Inp_Std [Std_Id (encodeTriplet (formid.id,cntr,UpdS name))]
, `Inp_Events (callClean True formid.mode "" formid.lifespan)
, `Inp_Events (callClean OnClick formid.mode "" formid.lifespan True)
]) ""]
},incrHSt 1 hst)
v=:(RBNotChecked name)
......@@ -210,7 +210,7 @@ gForm{|RadioButton|} (init,formid) hst
, Inp_Value (SV (cleanString name))
, Inp_Name (encodeTriplet (formid.id,cntr,UpdS name))
, `Inp_Std [Std_Id (encodeTriplet (formid.id,cntr,UpdS name))]
, `Inp_Events (callClean True formid.mode "" formid.lifespan)
, `Inp_Events (callClean OnClick formid.mode "" formid.lifespan True)
]) ""]
},incrHSt 1 hst)
......@@ -225,7 +225,7 @@ gForm{|PullDownMenu|} (init,formid) hst=:{submits}
(if (menuindex >= 0 && menuindex < length itemlist) (itemlist!!menuindex) ""))
, Sel_Size size
, `Sel_Std [Std_Style ("width:" <+++ width <+++ "px"), Std_Id (selectorInpName +++ encodeString (if (menuindex >= 0 && menuindex < length itemlist) (itemlist!!menuindex) ""))]
, `Sel_Events (if submits [] (callClean False formid.mode formid.id formid.lifespan))
, `Sel_Events (if submits [] (callClean OnChange formid.mode formid.id formid.lifespan True))
])
[ Option
[ Opt_Value (encodeTriplet (formid.id,cntr,UpdC (itemlist!!j)))
......@@ -289,7 +289,7 @@ where
, Inp_Name (encodeTriplet (formid.id,cntr,updval))
, Inp_Size size
, `Inp_Std [EditBoxStyle, Std_Title "::Password", Std_Id (encodeTriplet (formid.id,cntr,updval))]
, `Inp_Events if (mode == Edit && not submits) (callClean False Edit "" formid.lifespan) []
, `Inp_Events if (mode == Edit && not submits) (callClean OnChange Edit "" formid.lifespan False) []
] ""
,incrHSt 1 hst)
| mode == Display
......
......@@ -382,7 +382,7 @@ mkForm (init,formid=:{mode = Submit}) hst=:{submits = False}
] ""
# submit = Input [ Inp_Type Inp_Button
, Inp_Value (SV "Submit")
,`Inp_Events (callClean True Submit formname formid.lifespan)
,`Inp_Events (callClean OnClick Submit formname formid.lifespan True)
] ""
# clear = Input [ Inp_Type Inp_Reset, Inp_Value (SV "Clear")] ""
# sform = [Form [ Frm_Method Post
......@@ -492,10 +492,10 @@ where
]
where
styles = case formid.mode of
Edit -> [ `Sel_Std [Std_Style width, EditBoxStyle]
, `Sel_Events (if submits [] (callClean False Edit formid.id formid.lifespan))
Edit -> [ `Sel_Std [Std_Style width, EditBoxStyle, Std_Id (selectorInpName +++ encodeString myname)]
, `Sel_Events (if submits [] (callClean OnChange Edit formid.id formid.lifespan True))
]
Submit -> [ `Sel_Std [Std_Style width, EditBoxStyle]
Submit -> [ `Sel_Std [Std_Style width, EditBoxStyle, Std_Id (selectorInpName +++ encodeString myname)]
]
_ -> [ `Sel_Std [Std_Style width, DisplayBoxStyle]
, Sel_Disabled Disabled
......@@ -644,7 +644,7 @@ mkInput size (init,formid=:{mode}) val updval hst=:{cntr,submits}
, Inp_Name (encodeTriplet (formid.id,cntr,updval))
, Inp_Size size
, `Inp_Std [EditBoxStyle, Std_Title (showType val), Std_Id (encodeTriplet (formid.id,cntr,updval))]
, `Inp_Events if (mode == Edit && not submits) (callClean False formid.mode "" formid.lifespan) []
, `Inp_Events if (mode == Edit && not submits) (callClean OnChange formid.mode "" formid.lifespan False) []
] ""
, setCntr (cntr+1) hst)
| mode == Display
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment