Commit aba83952bb1e3c0d58692aa460c06656ecfd3c9e
1 parent
8690ee5e
add button_type type and move css to css/cxm/
Showing
1 changed file
with
41 additions
and
13 deletions
Show diff stats
web/jQuery/CXM_jquery_button.anubis
| ... | ... | @@ -15,12 +15,40 @@ read system/string.anubis |
| 15 | 15 | read tools/random.anubis |
| 16 | 16 | |
| 17 | 17 | |
| 18 | +public type JQuery_button_type: | |
| 19 | + button, | |
| 20 | + reset, | |
| 21 | + submit. | |
| 22 | + | |
| 23 | +public define String | |
| 24 | + to_String | |
| 25 | + ( | |
| 26 | + JQuery_button_type bt_type | |
| 27 | + )= | |
| 28 | + if bt_type is | |
| 29 | + { | |
| 30 | + button then "button", | |
| 31 | + reset then "reset", | |
| 32 | + submit then "submit" | |
| 33 | + }. | |
| 34 | + | |
| 18 | 35 | public type JQuery_button: |
| 19 | - jQuery_button( | |
| 36 | + jQuery_button( JQuery_button_type bt_type, | |
| 20 | 37 | String button_id, String button_name, String button_label, JQuery_Actioner actioner, JQuery_icon primary, JQuery_icon secondary // primary icon is for left icon, secondary icon is for right icon and button_id must set with an unique ID in order to have icons working |
| 21 | 38 | ) |
| 22 | 39 | . |
| 23 | 40 | |
| 41 | +public define JQuery_button | |
| 42 | + jQuery_button | |
| 43 | + ( | |
| 44 | + JQuery_button_type bt_type, | |
| 45 | + String button_id, | |
| 46 | + String button_name, | |
| 47 | + String button_label, | |
| 48 | + JQuery_Actioner actioner | |
| 49 | + ) = | |
| 50 | + jQuery_button(bt_type, button_id, button_name, button_label, actioner, jq_icon_none, jq_icon_none). | |
| 51 | + | |
| 24 | 52 | define String |
| 25 | 53 | jquery_button_get_onclick_action_window_options |
| 26 | 54 | ( |
| ... | ... | @@ -132,14 +160,15 @@ define HTML_Partial_Content |
| 132 | 160 | sequence(reverse(html_buttons)) |
| 133 | 161 | ), |
| 134 | 162 | [ h . t ] then |
| 135 | - if h is jQuery_button(id, name, label, actioner, primary, secondary) then | |
| 163 | + if h is jQuery_button(bt_type, id, name, label, actioner, primary, secondary) then | |
| 136 | 164 | with onclick_action=jquery_button_get_onclick_action(id, actioner), |
| 137 | 165 | if id = "" then // if the ID is not set => we can't use icons in the buttonset. |
| 138 | 166 | _jquery_buttons( |
| 139 | 167 | t, |
| 140 | 168 | [ onclick_action . html_tags ], |
| 141 | 169 | [ |
| 142 | - literal("<input type=\"submit\" name=\""+name+"\" value=\""+label+"\">") | |
| 170 | + literal("<button type=\""+to_String(bt_type)+"\" name=\""+name+"\">"+label+"</button>") | |
| 171 | + | |
| 143 | 172 | . |
| 144 | 173 | html_buttons |
| 145 | 174 | ] |
| ... | ... | @@ -155,7 +184,7 @@ define HTML_Partial_Content |
| 155 | 184 | ] |
| 156 | 185 | +html_tags, |
| 157 | 186 | [ |
| 158 | - literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">") | |
| 187 | + literal("<button type=\""+to_String(bt_type)+"\" id=\""+id+"\" name=\""+name+"\">"+label+"</button>") | |
| 159 | 188 | . |
| 160 | 189 | html_buttons |
| 161 | 190 | ] |
| ... | ... | @@ -213,12 +242,11 @@ public define HTML_Partial_Content |
| 213 | 242 | List(JQuery_button) buttons |
| 214 | 243 | ) |
| 215 | 244 | = |
| 216 | - if _jquery_buttons(buttons, [], []) is partial_content(tags, html) then | |
| 217 | 245 | partial_content( |
| 218 | - [ js_inline(jquery_ready("$('#"+buttons_container_id+"').buttonset();")) ] + tags, | |
| 246 | + [ js_inline(jquery_ready("$('#"+buttons_container_id+"').buttonset();")) ], | |
| 219 | 247 | sequence([ |
| 220 | 248 | literal("<div id=\""+buttons_container_id+"\">"), |
| 221 | - html, | |
| 249 | + partial(_jquery_buttons(buttons, [], [])), | |
| 222 | 250 | literal("</div>") |
| 223 | 251 | ]) |
| 224 | 252 | ) |
| ... | ... | @@ -230,7 +258,7 @@ public define HTML_Partial_Content |
| 230 | 258 | JQuery_button button |
| 231 | 259 | ) |
| 232 | 260 | = |
| 233 | - if button is jQuery_button(id, name, label, actioner, primary, secondary) then | |
| 261 | + if button is jQuery_button(bt_type, id, name, label, actioner, primary, secondary) then | |
| 234 | 262 | with onclick_action=jquery_button_get_onclick_action(id, actioner), |
| 235 | 263 | if jquery_icon_to_string(primary) = "" then |
| 236 | 264 | if jquery_icon_to_string(secondary) = "" then |
| ... | ... | @@ -239,7 +267,7 @@ public define HTML_Partial_Content |
| 239 | 267 | js_inline(jquery_ready("$('#"+id+"').button();")), |
| 240 | 268 | onclick_action |
| 241 | 269 | ], |
| 242 | - literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">") | |
| 270 | + literal("<button type=\""+to_String(bt_type)+"\" id=\""+id+"\" name=\""+name+"\">"+label+"</button>") | |
| 243 | 271 | ) |
| 244 | 272 | else |
| 245 | 273 | partial_content( |
| ... | ... | @@ -247,7 +275,7 @@ public define HTML_Partial_Content |
| 247 | 275 | js_inline(jquery_ready("$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});")), |
| 248 | 276 | onclick_action |
| 249 | 277 | ], |
| 250 | - literal("<button id=\""+id+"\">"+label+"</button>") | |
| 278 | + literal("<button type=\""+to_String(bt_type)+"\" id=\""+id+"\">"+label+"</button>") | |
| 251 | 279 | ) |
| 252 | 280 | else |
| 253 | 281 | if jquery_icon_to_string(secondary) = "" then |
| ... | ... | @@ -256,7 +284,7 @@ public define HTML_Partial_Content |
| 256 | 284 | js_inline(jquery_ready("$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});")), |
| 257 | 285 | onclick_action |
| 258 | 286 | ], |
| 259 | - literal("<button id=\""+id+"\">"+label+"</button>") | |
| 287 | + literal("<button type=\""+to_String(bt_type)+"\" id=\""+id+"\">"+label+"</button>") | |
| 260 | 288 | ) |
| 261 | 289 | else |
| 262 | 290 | partial_content( |
| ... | ... | @@ -264,7 +292,7 @@ public define HTML_Partial_Content |
| 264 | 292 | js_inline(jquery_ready("$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});")), |
| 265 | 293 | onclick_action |
| 266 | 294 | ], |
| 267 | - literal("<button id=\""+id+"\">"+label+"</button>") | |
| 295 | + literal("<button type=\""+to_String(bt_type)+"\" id=\""+id+"\">"+label+"</button>") | |
| 268 | 296 | ) |
| 269 | 297 | . |
| 270 | 298 | |
| ... | ... | @@ -308,7 +336,7 @@ public define HTML_Partial_Content |
| 308 | 336 | partial_content( |
| 309 | 337 | [ |
| 310 | 338 | jquery_button_get_onclick_action(button_id_str, actioner), |
| 311 | - css(css_file("css/cxm_button.css")), | |
| 339 | + css(css_file("css/cxm/cxm_button.css")), | |
| 312 | 340 | js_inline(jquery_ready("$('.jq_img_btn').button();")) |
| 313 | 341 | ], |
| 314 | 342 | jquery_button_html(button, button_id_str)) | ... | ... |