Commit be009662c44d661d41e2addf7bbc8286951daed9
1 parent
63e69586
Modification: support actioner on jquery_button => JQuery_Actioner
Showing
2 changed files
with
135 additions
and
24 deletions
Show diff stats
web/CXM_jquery.anubis
| @@ -11,6 +11,18 @@ read calexium_lib/web/CXM_making_a_web_site.anubis | @@ -11,6 +11,18 @@ read calexium_lib/web/CXM_making_a_web_site.anubis | ||
| 11 | read tools/printable_tree.anubis | 11 | read tools/printable_tree.anubis |
| 12 | read tools/basis.anubis | 12 | read tools/basis.anubis |
| 13 | 13 | ||
| 14 | +/* jQuery Actioner type */ | ||
| 15 | +public type JQuery_Actioner_type: | ||
| 16 | + jqform, | ||
| 17 | + jqlink | ||
| 18 | +. | ||
| 19 | + | ||
| 20 | +/* jQuery Actioner */ | ||
| 21 | +public type JQuery_Actioner: | ||
| 22 | + jQuery_actioner(Actioner_Target target, JQuery_Actioner_type type, String url_or_form_id) | ||
| 23 | +. | ||
| 24 | + | ||
| 25 | + | ||
| 14 | /* jQuery default js files */ | 26 | /* jQuery default js files */ |
| 15 | define List(HTML_Head_Tag) | 27 | define List(HTML_Head_Tag) |
| 16 | jquery_defaults | 28 | jquery_defaults |
web/CXM_jquery_button.anubis
| @@ -8,6 +8,7 @@ | @@ -8,6 +8,7 @@ | ||
| 8 | */ | 8 | */ |
| 9 | 9 | ||
| 10 | read calexium_lib/web/CXM_making_a_web_site.anubis | 10 | read calexium_lib/web/CXM_making_a_web_site.anubis |
| 11 | +read calexium_lib/web/CXM_jquery.anubis | ||
| 11 | read calexium_lib/web/CXM_jquery_icons.anubis | 12 | read calexium_lib/web/CXM_jquery_icons.anubis |
| 12 | read tools/basis.anubis | 13 | read tools/basis.anubis |
| 13 | read system/string.anubis | 14 | read system/string.anubis |
| @@ -15,10 +16,102 @@ read system/string.anubis | @@ -15,10 +16,102 @@ read system/string.anubis | ||
| 15 | 16 | ||
| 16 | public type JQuery_button: | 17 | public type JQuery_button: |
| 17 | jQuery_button( | 18 | jQuery_button( |
| 18 | - String button_id, String button_name, String button_label, 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 | 19 | + 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 |
| 19 | ) | 20 | ) |
| 20 | . | 21 | . |
| 21 | 22 | ||
| 23 | +define String | ||
| 24 | + jquery_button_get_onclick_action_window_options | ||
| 25 | + ( | ||
| 26 | + List(Other_Window_Option) options, | ||
| 27 | + String formated_options | ||
| 28 | + ) | ||
| 29 | + = | ||
| 30 | + if options is | ||
| 31 | + { | ||
| 32 | + [ ] then formated_options, | ||
| 33 | + [ h . t ] then | ||
| 34 | + if h is | ||
| 35 | + { | ||
| 36 | + resizable then | ||
| 37 | + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule | ||
| 38 | + jquery_button_get_onclick_action_window_options( | ||
| 39 | + t, | ||
| 40 | + formated_options+"resizable='yes'" | ||
| 41 | + ) | ||
| 42 | + else | ||
| 43 | + jquery_button_get_onclick_action_window_options( | ||
| 44 | + t, | ||
| 45 | + formated_options+", resizable='yes'" | ||
| 46 | + ), | ||
| 47 | + scrollbars then | ||
| 48 | + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule | ||
| 49 | + jquery_button_get_onclick_action_window_options( | ||
| 50 | + t, | ||
| 51 | + formated_options+"scrollbars='yes'" | ||
| 52 | + ) | ||
| 53 | + else | ||
| 54 | + jquery_button_get_onclick_action_window_options( | ||
| 55 | + t, | ||
| 56 | + formated_options+", scrollbars='yes'" | ||
| 57 | + ), | ||
| 58 | + width(w) then | ||
| 59 | + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule | ||
| 60 | + jquery_button_get_onclick_action_window_options( | ||
| 61 | + t, | ||
| 62 | + formated_options+"width="+w | ||
| 63 | + ) | ||
| 64 | + else | ||
| 65 | + jquery_button_get_onclick_action_window_options( | ||
| 66 | + t, | ||
| 67 | + formated_options+", width="+w | ||
| 68 | + ), | ||
| 69 | + height(h) then | ||
| 70 | + if formated_options="" then // si c'est vide on ne prefixe pas avec une virgule | ||
| 71 | + jquery_button_get_onclick_action_window_options( | ||
| 72 | + t, | ||
| 73 | + formated_options+"height="+h | ||
| 74 | + ) | ||
| 75 | + else | ||
| 76 | + jquery_button_get_onclick_action_window_options( | ||
| 77 | + t, | ||
| 78 | + formated_options+", height="+h | ||
| 79 | + ) | ||
| 80 | + } | ||
| 81 | + } | ||
| 82 | + . | ||
| 83 | + | ||
| 84 | +define HTML_Head_Tag | ||
| 85 | + jquery_button_get_onclick_action | ||
| 86 | + ( | ||
| 87 | + String button_id, | ||
| 88 | + JQuery_Actioner actioner | ||
| 89 | + ) | ||
| 90 | + = | ||
| 91 | + if actioner is jQuery_actioner(target, act_type, str) then | ||
| 92 | + if target is | ||
| 93 | + { | ||
| 94 | + same then | ||
| 95 | + if act_type is | ||
| 96 | + { | ||
| 97 | + jqform then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){$('#"+str+"').submit();});});")), | ||
| 98 | + jqlink then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){document.location='"+str+"';});});")), | ||
| 99 | + }, | ||
| 100 | + same(label) then | ||
| 101 | + if act_type is | ||
| 102 | + { | ||
| 103 | + jqform then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){$('#"+str+"').submit();});});")), | ||
| 104 | + jqlink then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){document.location='"+str+"';});});")), | ||
| 105 | + }, | ||
| 106 | + other(window_name, window_options) then | ||
| 107 | + if act_type is | ||
| 108 | + { | ||
| 109 | + jqform then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){$('#"+str+"').submit();});});")), //il s'agit d'une soumision d'un formulaire => cela se fait uniquement dans la mรชme fenรชtre ! | ||
| 110 | + jqlink then js_inline(script("", "$(document).ready(function(){$('#"+button_id+"').click(function(){window.open('"+str+"', '"+window_name+"', '"+jquery_button_get_onclick_action_window_options(window_options, "")+"');});});")), | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + . | ||
| 114 | + | ||
| 22 | define HTML_Partial_Content | 115 | define HTML_Partial_Content |
| 23 | _jquery_buttons | 116 | _jquery_buttons |
| 24 | ( | 117 | ( |
| @@ -35,11 +128,12 @@ define HTML_Partial_Content | @@ -35,11 +128,12 @@ define HTML_Partial_Content | ||
| 35 | sequence(reverse(html_buttons)) | 128 | sequence(reverse(html_buttons)) |
| 36 | ), | 129 | ), |
| 37 | [ h . t ] then | 130 | [ h . t ] then |
| 38 | - if h is jQuery_button(id, name, label, primary, secondary) then | 131 | + if h is jQuery_button(id, name, label, actioner, primary, secondary) then |
| 132 | + with onclick_action=jquery_button_get_onclick_action(id, actioner), | ||
| 39 | if id = "" then // if the ID is not set => we can't use icons in the buttonset. | 133 | if id = "" then // if the ID is not set => we can't use icons in the buttonset. |
| 40 | _jquery_buttons( | 134 | _jquery_buttons( |
| 41 | t, | 135 | t, |
| 42 | - html_tags, | 136 | + [ onclick_action . html_tags ], |
| 43 | [ | 137 | [ |
| 44 | literal("<input type=\"submit\" name=\""+name+"\" value=\""+label+"\">") | 138 | literal("<input type=\"submit\" name=\""+name+"\" value=\""+label+"\">") |
| 45 | . | 139 | . |
| @@ -52,10 +146,10 @@ define HTML_Partial_Content | @@ -52,10 +146,10 @@ define HTML_Partial_Content | ||
| 52 | _jquery_buttons( | 146 | _jquery_buttons( |
| 53 | t, | 147 | t, |
| 54 | [ | 148 | [ |
| 55 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")) | ||
| 56 | - . | ||
| 57 | - html_tags | ||
| 58 | - ], | 149 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")), |
| 150 | + onclick_action | ||
| 151 | + ] | ||
| 152 | + +html_tags, | ||
| 59 | [ | 153 | [ |
| 60 | literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">") | 154 | literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">") |
| 61 | . | 155 | . |
| @@ -66,10 +160,10 @@ define HTML_Partial_Content | @@ -66,10 +160,10 @@ define HTML_Partial_Content | ||
| 66 | _jquery_buttons( | 160 | _jquery_buttons( |
| 67 | t, | 161 | t, |
| 68 | [ | 162 | [ |
| 69 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) | ||
| 70 | - . | ||
| 71 | - html_tags | ||
| 72 | - ], | 163 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), |
| 164 | + onclick_action | ||
| 165 | + ] | ||
| 166 | + +html_tags, | ||
| 73 | [ | 167 | [ |
| 74 | literal("<button id=\""+id+"\">"+label+"</button>") | 168 | literal("<button id=\""+id+"\">"+label+"</button>") |
| 75 | . | 169 | . |
| @@ -81,10 +175,10 @@ define HTML_Partial_Content | @@ -81,10 +175,10 @@ define HTML_Partial_Content | ||
| 81 | _jquery_buttons( | 175 | _jquery_buttons( |
| 82 | t, | 176 | t, |
| 83 | [ | 177 | [ |
| 84 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")) | ||
| 85 | - . | ||
| 86 | - html_tags | ||
| 87 | - ], | 178 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")), |
| 179 | + onclick_action | ||
| 180 | + ] | ||
| 181 | + +html_tags, | ||
| 88 | [ | 182 | [ |
| 89 | literal("<button id=\""+id+"\">"+label+"</button>") | 183 | literal("<button id=\""+id+"\">"+label+"</button>") |
| 90 | . | 184 | . |
| @@ -95,10 +189,10 @@ define HTML_Partial_Content | @@ -95,10 +189,10 @@ define HTML_Partial_Content | ||
| 95 | _jquery_buttons( | 189 | _jquery_buttons( |
| 96 | t, | 190 | t, |
| 97 | [ | 191 | [ |
| 98 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) | ||
| 99 | - . | ||
| 100 | - html_tags | ||
| 101 | - ], | 192 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), |
| 193 | + onclick_action | ||
| 194 | + ] | ||
| 195 | + +html_tags, | ||
| 102 | [ | 196 | [ |
| 103 | literal("<button id=\""+id+"\">"+label+"</button>") | 197 | literal("<button id=\""+id+"\">"+label+"</button>") |
| 104 | . | 198 | . |
| @@ -132,19 +226,22 @@ public define HTML_Partial_Content | @@ -132,19 +226,22 @@ public define HTML_Partial_Content | ||
| 132 | JQuery_button button | 226 | JQuery_button button |
| 133 | ) | 227 | ) |
| 134 | = | 228 | = |
| 135 | - if button is jQuery_button(id, name, label, primary, secondary) then | 229 | + if button is jQuery_button(id, name, label, actioner, primary, secondary) then |
| 230 | + with onclick_action=jquery_button_get_onclick_action(id, actioner), | ||
| 136 | if jquery_icon_to_string(primary) = "" then | 231 | if jquery_icon_to_string(primary) = "" then |
| 137 | if jquery_icon_to_string(secondary) = "" then | 232 | if jquery_icon_to_string(secondary) = "" then |
| 138 | partial_content( | 233 | partial_content( |
| 139 | [ | 234 | [ |
| 140 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")) | 235 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button();});")), |
| 236 | + onclick_action | ||
| 141 | ], | 237 | ], |
| 142 | literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">") | 238 | literal("<input type=\"submit\" id=\""+id+"\" name=\""+name+"\" value=\""+label+"\">") |
| 143 | ) | 239 | ) |
| 144 | else | 240 | else |
| 145 | partial_content( | 241 | partial_content( |
| 146 | [ | 242 | [ |
| 147 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) | 243 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), |
| 244 | + onclick_action | ||
| 148 | ], | 245 | ], |
| 149 | literal("<button id=\""+id+"\">"+label+"</button>") | 246 | literal("<button id=\""+id+"\">"+label+"</button>") |
| 150 | ) | 247 | ) |
| @@ -152,14 +249,16 @@ public define HTML_Partial_Content | @@ -152,14 +249,16 @@ public define HTML_Partial_Content | ||
| 152 | if jquery_icon_to_string(secondary) = "" then | 249 | if jquery_icon_to_string(secondary) = "" then |
| 153 | partial_content( | 250 | partial_content( |
| 154 | [ | 251 | [ |
| 155 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")) | 252 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"'}});});")), |
| 253 | + onclick_action | ||
| 156 | ], | 254 | ], |
| 157 | literal("<button id=\""+id+"\">"+label+"</button>") | 255 | literal("<button id=\""+id+"\">"+label+"</button>") |
| 158 | ) | 256 | ) |
| 159 | else | 257 | else |
| 160 | partial_content( | 258 | partial_content( |
| 161 | [ | 259 | [ |
| 162 | - js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")) | 260 | + js_inline(script("", "$(document).ready(function(){$('#"+id+"').button({icons:{primary:'"+jquery_icon_to_string(primary)+"',secondary:'"+jquery_icon_to_string(secondary)+"'}});});")), |
| 261 | + onclick_action | ||
| 163 | ], | 262 | ], |
| 164 | literal("<button id=\""+id+"\">"+label+"</button>") | 263 | literal("<button id=\""+id+"\">"+label+"</button>") |
| 165 | ) | 264 | ) |