Commit 0555931cf45f083fa29cd976aadf081a4f3c1d78
1 parent
1167a13b
add the managment of the overlay in load_content and change the code accordingly.
in same time add a new alternative into left_menu type with "left_menu_entry_load_content". This is better to understand when constructing a menu
Showing
5 changed files
with
72 additions
and
47 deletions
Show diff stats
web/jquery.anubis
| ... | ... | @@ -103,7 +103,7 @@ public define String |
| 103 | 103 | } |
| 104 | 104 | jqflink(link) then "document.location='"+link+"';", |
| 105 | 105 | jqscript(script) then script |
| 106 | - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) | |
| 106 | + jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false, true) | |
| 107 | 107 | }, |
| 108 | 108 | same(label) then |
| 109 | 109 | if act_type is |
| ... | ... | @@ -132,7 +132,7 @@ public define String |
| 132 | 132 | } |
| 133 | 133 | jqflink(link) then "document.location='"+link+"';", |
| 134 | 134 | jqscript(script) then script |
| 135 | - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) | |
| 135 | + jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false, true) | |
| 136 | 136 | }, |
| 137 | 137 | other(window_name, window_options) then |
| 138 | 138 | if act_type is |
| ... | ... | @@ -164,7 +164,7 @@ public define String |
| 164 | 164 | } |
| 165 | 165 | jqflink(link) then "document.location='"+link+"';", |
| 166 | 166 | jqscript(script) then script |
| 167 | - jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false) | |
| 167 | + jqload(target_id, web_action, extra_args) then load_content(target_id, web_action, extra_args, false, true) | |
| 168 | 168 | } |
| 169 | 169 | }. |
| 170 | 170 | ... | ... |
web/load_content.anubis
| ... | ... | @@ -45,10 +45,11 @@ public define String |
| 45 | 45 | String target, |
| 46 | 46 | WEB_Action_Name web_action, |
| 47 | 47 | List((String,String)) extra_args, |
| 48 | - Bool replace | |
| 48 | + Bool replace, | |
| 49 | + Bool overlay | |
| 49 | 50 | )= |
| 50 | 51 | |
| 51 | - "Xlib.load_content('"+target+"', '"+format_web_action_name(web_action, extra_args)+"', "+to_String(replace)+");" | |
| 52 | + "Xlib.load_content('"+target+"', '"+format_web_action_name(web_action, extra_args)+"', "+to_String(replace)+", "+to_String(replace)+");" | |
| 52 | 53 | . |
| 53 | 54 | |
| 54 | 55 | public define String |
| ... | ... | @@ -57,9 +58,10 @@ public define String |
| 57 | 58 | String target, |
| 58 | 59 | WEB_Action_Name web_action, |
| 59 | 60 | List((String,String)) extra_args, |
| 60 | - Bool replace | |
| 61 | + Bool replace, | |
| 62 | + Bool overlay | |
| 61 | 63 | )= |
| 62 | - to_JS_String("Xlib.load_content('"+target+"', "+format_web_action_name_to_js(web_action, extra_args)+", "+to_String(replace)+")") | |
| 64 | + to_JS_String("Xlib.load_content('"+target+"', "+format_web_action_name_to_js(web_action, extra_args)+", "+to_String(replace)+", "+to_String(replace)+")") | |
| 63 | 65 | . |
| 64 | 66 | |
| 65 | 67 | public define String |
| ... | ... | @@ -69,7 +71,7 @@ public define String |
| 69 | 71 | WEB_Action_Name web_action, |
| 70 | 72 | List((String,String)) extra_args |
| 71 | 73 | )= |
| 72 | - load_content(target, web_action, extra_args, true) | |
| 74 | + load_content(target, web_action, extra_args, true, true) | |
| 73 | 75 | . |
| 74 | 76 | |
| 75 | 77 | public define String |
| ... | ... | @@ -79,7 +81,7 @@ public define String |
| 79 | 81 | WEB_Action_Name web_action, |
| 80 | 82 | (String, String) extra_arg |
| 81 | 83 | )= |
| 82 | - load_content(target, web_action, [extra_arg], true) | |
| 84 | + load_content(target, web_action, [extra_arg], true, true) | |
| 83 | 85 | . |
| 84 | 86 | |
| 85 | 87 | public define String |
| ... | ... | @@ -88,7 +90,7 @@ public define String |
| 88 | 90 | String target, |
| 89 | 91 | WEB_Action_Name web_action |
| 90 | 92 | )= |
| 91 | - load_content(target, web_action, [], true) | |
| 93 | + load_content(target, web_action, [], true, true) | |
| 92 | 94 | . |
| 93 | 95 | |
| 94 | 96 | |
| ... | ... | @@ -99,7 +101,7 @@ public define String |
| 99 | 101 | WEB_Action_Name web_action, |
| 100 | 102 | Bool replace |
| 101 | 103 | )= |
| 102 | - load_content(target, web_action, [], replace) | |
| 104 | + load_content(target, web_action, [], replace, true) | |
| 103 | 105 | . |
| 104 | 106 | |
| 105 | 107 | public define HTML_Partial_Content |
| ... | ... | @@ -108,11 +110,12 @@ public define HTML_Partial_Content |
| 108 | 110 | String target, |
| 109 | 111 | WEB_Action_Name web_action, |
| 110 | 112 | List((String,String)) extra_args, |
| 111 | - Bool replace | |
| 113 | + Bool replace, | |
| 114 | + Bool overlay | |
| 112 | 115 | )= |
| 113 | 116 | partial_content([ |
| 114 | 117 | js(js_file("xlib/js/xlib.js")), |
| 115 | - js_inline(script("text/javascript","$(document).ready(function(){"+load_content(target, web_action, extra_args, replace)+"});")) | |
| 118 | + js_inline(script("text/javascript","$(document).ready(function(){"+load_content(target, web_action, extra_args, replace, overlay)+"});")) | |
| 116 | 119 | ], |
| 117 | 120 | empty) |
| 118 | 121 | . |
| ... | ... | @@ -122,9 +125,20 @@ public define HTML_Partial_Content |
| 122 | 125 | ( |
| 123 | 126 | String target, |
| 124 | 127 | WEB_Action_Name web_action, |
| 128 | + List((String,String)) extra_args, | |
| 129 | + Bool replace | |
| 130 | + )= | |
| 131 | + load_content_init(target, web_action, extra_args, replace, true) | |
| 132 | +. | |
| 133 | + | |
| 134 | +public define HTML_Partial_Content | |
| 135 | + load_content_init | |
| 136 | + ( | |
| 137 | + String target, | |
| 138 | + WEB_Action_Name web_action, | |
| 125 | 139 | List((String,String)) extra_args |
| 126 | 140 | )= |
| 127 | - load_content_init(target, web_action, extra_args, false) | |
| 141 | + load_content_init(target, web_action, extra_args, false, true) | |
| 128 | 142 | . |
| 129 | 143 | |
| 130 | 144 | public define HTML_Partial_Content |
| ... | ... | @@ -133,7 +147,7 @@ public define HTML_Partial_Content |
| 133 | 147 | String target, |
| 134 | 148 | WEB_Action_Name web_action |
| 135 | 149 | )= |
| 136 | - load_content_init(target, web_action, [], false) | |
| 150 | + load_content_init(target, web_action, [], false, true) | |
| 137 | 151 | . |
| 138 | 152 | |
| 139 | 153 | public define HTML_Partial_Content |
| ... | ... | @@ -143,5 +157,5 @@ public define HTML_Partial_Content |
| 143 | 157 | WEB_Action_Name web_action, |
| 144 | 158 | Bool replace |
| 145 | 159 | )= |
| 146 | - load_content_init(target, web_action, [], replace) | |
| 160 | + load_content_init(target, web_action, [], replace, true) | |
| 147 | 161 | . | ... | ... |
web/widgets/button.anubis
| ... | ... | @@ -140,10 +140,11 @@ public define HTML_Partial_Content |
| 140 | 140 | WEB_Action_Name web_action, |
| 141 | 141 | List((String, String)) extra_args, |
| 142 | 142 | String target, |
| 143 | - Bool replace | |
| 143 | + Bool replace, | |
| 144 | + Bool overlay | |
| 144 | 145 | )= |
| 145 | 146 | partial_content( |
| 146 | - img([ event(onclick, load_content(target, web_action, extra_args, replace)), | |
| 147 | + img([ event(onclick, load_content(target, web_action, extra_args, replace, overlay)), | |
| 147 | 148 | style("cursor: pointer") . core_attrs |
| 148 | 149 | ], img_path)) |
| 149 | 150 | . |
| ... | ... | @@ -157,7 +158,7 @@ public define HTML_Partial_Content |
| 157 | 158 | String target, |
| 158 | 159 | Bool replace |
| 159 | 160 | )= |
| 160 | - img_button(img_path, [], web_action, extra_args, target, replace) | |
| 161 | + img_button(img_path, [], web_action, extra_args, target, replace, true) | |
| 161 | 162 | . |
| 162 | 163 | |
| 163 | 164 | public define HTML_Partial_Content |
| ... | ... | @@ -168,7 +169,7 @@ public define HTML_Partial_Content |
| 168 | 169 | List((String, String)) extra_args, |
| 169 | 170 | String target |
| 170 | 171 | )= |
| 171 | - img_button(img_path, [], web_action, extra_args, target, false) | |
| 172 | + img_button(img_path, [], web_action, extra_args, target, false, true) | |
| 172 | 173 | . |
| 173 | 174 | |
| 174 | 175 | public define HTML_Partial_Content |
| ... | ... | @@ -255,7 +256,7 @@ define List(CoreAttrs) |
| 255 | 256 | with ok_action = if load_content_target = "" then |
| 256 | 257 | to_JS_String("Xlib.jq_query("+format_web_action_name_to_js(web_action, extra_ops)+")") |
| 257 | 258 | else |
| 258 | - load_content_JS_String(load_content_target, web_action, extra_ops, true), | |
| 259 | + load_content_JS_String(load_content_target, web_action, extra_ops, true, true), | |
| 259 | 260 | //to_JS_String("Xlib.load_content('"++"', "+format_web_action_name_to_js(web_action, extra_ops)+", true)"), |
| 260 | 261 | |
| 261 | 262 | core_attrs + [id(uid), style("cursor: pointer"), event(onclick, "Xlib.make_confirm_dialog(this, "+ ok_action +");")]. | ... | ... |
web/widgets/left_menu.anubis
| ... | ... | @@ -17,8 +17,7 @@ public type Left_Menu_Entry: |
| 17 | 17 | List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) |
| 18 | 18 | WEB_Action_Name action, //action (url to apply when click |
| 19 | 19 | String text, //text to show |
| 20 | - List((String, String)) extra, //extra web arguments to send when click | |
| 21 | - Maybe(String) target_id //target_id use during load_content | |
| 20 | + List((String, String)) extra //extra web arguments to send when click | |
| 22 | 21 | ), |
| 23 | 22 | left_menu_entry_js( //MENU entry with call to js |
| 24 | 23 | String entry_id, //it's also use as icon prefix |
| ... | ... | @@ -27,6 +26,17 @@ public type Left_Menu_Entry: |
| 27 | 26 | String js_call, //javascript to call on click event |
| 28 | 27 | String text //text to show |
| 29 | 28 | ), |
| 29 | + left_menu_entry_load_content( //MENU entry hence no selectable | |
| 30 | + String entry_id, //it's also use as icon prefix | |
| 31 | + Bool sub_entry, | |
| 32 | + List(String) classes, //additional classes if need (for disabling entry, change background color, etc.) | |
| 33 | + WEB_Action_Name action, //action (url to apply when click | |
| 34 | + String text, //text to show | |
| 35 | + List((String, String)) extra, //extra web arguments to send when click | |
| 36 | + String target_id //target_id use during load_content | |
| 37 | + Bool replace, | |
| 38 | + Bool overlay | |
| 39 | + ), | |
| 30 | 40 | |
| 31 | 41 | title( //TITLE entry hence no selectable |
| 32 | 42 | String title_id, //it's also use as icon prefix |
| ... | ... | @@ -150,7 +160,7 @@ public define Left_Menu_Entry |
| 150 | 160 | WEB_Action_Name action, |
| 151 | 161 | String text |
| 152 | 162 | )= |
| 153 | - left_menu_entry(entry_id, false, [], action, text, [], failure) | |
| 163 | + left_menu_entry(entry_id, false, [], action, text, []) | |
| 154 | 164 | . |
| 155 | 165 | |
| 156 | 166 | public define Left_Menu_Entry |
| ... | ... | @@ -160,7 +170,7 @@ public define Left_Menu_Entry |
| 160 | 170 | WEB_Action_Name action, |
| 161 | 171 | String text |
| 162 | 172 | )= |
| 163 | - left_menu_entry(entry_id, true, [], action, text, [], failure) | |
| 173 | + left_menu_entry(entry_id, true, [], action, text, []) | |
| 164 | 174 | . |
| 165 | 175 | |
| 166 | 176 | public define Left_Menu_Entry |
| ... | ... | @@ -170,7 +180,7 @@ public define Left_Menu_Entry |
| 170 | 180 | String action, |
| 171 | 181 | String text |
| 172 | 182 | )= |
| 173 | - left_menu_entry(entry_id, false, [], action_name(action), text, [], failure) | |
| 183 | + left_menu_entry(entry_id, false, [], action_name(action), text, []) | |
| 174 | 184 | . |
| 175 | 185 | |
| 176 | 186 | public define Left_Menu_Entry |
| ... | ... | @@ -180,7 +190,7 @@ public define Left_Menu_Entry |
| 180 | 190 | String action, |
| 181 | 191 | String text |
| 182 | 192 | )= |
| 183 | - left_menu_entry(entry_id, true, [], action_name(action), text, [], failure) | |
| 193 | + left_menu_entry(entry_id, true, [], action_name(action), text, []) | |
| 184 | 194 | . |
| 185 | 195 | |
| 186 | 196 | public define Left_Menu_Entry |
| ... | ... | @@ -191,7 +201,7 @@ public define Left_Menu_Entry |
| 191 | 201 | String text, //text to show |
| 192 | 202 | List((String, String)) extra //extra web arguments to send when click |
| 193 | 203 | )= |
| 194 | - left_menu_entry(entry_id, false, [], action, text, extra, failure) | |
| 204 | + left_menu_entry(entry_id, false, [], action, text, extra) | |
| 195 | 205 | . |
| 196 | 206 | |
| 197 | 207 | public define Left_Menu_Entry |
| ... | ... | @@ -202,11 +212,11 @@ public define Left_Menu_Entry |
| 202 | 212 | String text, //text to show |
| 203 | 213 | List((String, String)) extra //extra web arguments to send when click |
| 204 | 214 | )= |
| 205 | - left_menu_entry(entry_id, true, [], action, text, extra, failure) | |
| 215 | + left_menu_entry(entry_id, true, [], action, text, extra) | |
| 206 | 216 | . |
| 207 | 217 | |
| 208 | 218 | public define Left_Menu_Entry |
| 209 | - left_menu_entry | |
| 219 | + left_menu_entry_load_content | |
| 210 | 220 | ( |
| 211 | 221 | String entry_id, //it's also use as icon prefix |
| 212 | 222 | WEB_Action_Name action, //action (url to apply when click |
| ... | ... | @@ -214,11 +224,11 @@ public define Left_Menu_Entry |
| 214 | 224 | List((String, String)) extra, //extra web arguments to send when click |
| 215 | 225 | String target_id |
| 216 | 226 | )= |
| 217 | - left_menu_entry(entry_id, false, [], action, text, extra, success(target_id)) | |
| 227 | + left_menu_entry_load_content(entry_id, false, [], action, text, extra, target_id, false, true) | |
| 218 | 228 | . |
| 219 | 229 | |
| 220 | 230 | public define Left_Menu_Entry |
| 221 | - left_menu_sub_entry | |
| 231 | + left_menu_sub_entry_load_content | |
| 222 | 232 | ( |
| 223 | 233 | String entry_id, //it's also use as icon prefix |
| 224 | 234 | WEB_Action_Name action, //action (url to apply when click |
| ... | ... | @@ -226,7 +236,7 @@ public define Left_Menu_Entry |
| 226 | 236 | List((String, String)) extra, //extra web arguments to send when click |
| 227 | 237 | String target_id |
| 228 | 238 | )= |
| 229 | - left_menu_entry(entry_id, true, [], action, text, extra, success(target_id)) | |
| 239 | + left_menu_entry_load_content(entry_id, true, [], action, text, extra, target_id, false, true) | |
| 230 | 240 | . |
| 231 | 241 | |
| 232 | 242 | public define Left_Menu_Entry |
| ... | ... | @@ -237,7 +247,7 @@ public define Left_Menu_Entry |
| 237 | 247 | String text, //text to show |
| 238 | 248 | List((String, String)) extra //extra web arguments to send when click |
| 239 | 249 | )= |
| 240 | - left_menu_entry(entry_id, false, [], action_name(action), text, extra, failure) | |
| 250 | + left_menu_entry(entry_id, false, [], action_name(action), text, extra) | |
| 241 | 251 | . |
| 242 | 252 | |
| 243 | 253 | public define Left_Menu_Entry |
| ... | ... | @@ -248,11 +258,11 @@ public define Left_Menu_Entry |
| 248 | 258 | String text, //text to show |
| 249 | 259 | List((String, String)) extra //extra web arguments to send when click |
| 250 | 260 | )= |
| 251 | - left_menu_entry(entry_id, true, [], action_name(action), text, extra, failure) | |
| 261 | + left_menu_entry(entry_id, true, [], action_name(action), text, extra) | |
| 252 | 262 | . |
| 253 | 263 | |
| 254 | 264 | public define Left_Menu_Entry |
| 255 | - left_menu_entry | |
| 265 | + left_menu_entry_load_content | |
| 256 | 266 | ( |
| 257 | 267 | String entry_id, //it's also use as icon prefix |
| 258 | 268 | String action, //action (url to apply when click |
| ... | ... | @@ -260,11 +270,11 @@ public define Left_Menu_Entry |
| 260 | 270 | List((String, String)) extra, //extra web arguments to send when click |
| 261 | 271 | String target_id |
| 262 | 272 | )= |
| 263 | - left_menu_entry(entry_id, false, [], action_name(action), text, extra, success(target_id)) | |
| 273 | + left_menu_entry_load_content(entry_id, false, [], action_name(action), text, extra, target_id, false, true) | |
| 264 | 274 | . |
| 265 | 275 | |
| 266 | 276 | public define Left_Menu_Entry |
| 267 | - left_menu_sub_entry | |
| 277 | + left_menu_sub_entry_load_content | |
| 268 | 278 | ( |
| 269 | 279 | String entry_id, //it's also use as icon prefix |
| 270 | 280 | String action, //action (url to apply when click |
| ... | ... | @@ -272,7 +282,7 @@ public define Left_Menu_Entry |
| 272 | 282 | List((String, String)) extra, //extra web arguments to send when click |
| 273 | 283 | String target_id |
| 274 | 284 | )= |
| 275 | - left_menu_entry(entry_id, true, [], action_name(action), text, extra, success(target_id)) | |
| 285 | + left_menu_entry_load_content(entry_id, true, [], action_name(action), text, extra, target_id, false, true) | |
| 276 | 286 | . |
| 277 | 287 | |
| 278 | 288 | public define Left_Menu_Entry | ... | ... |
web/widgets/left_menu_html.anubis
| ... | ... | @@ -26,21 +26,21 @@ define List(HTML_Off_Form) |
| 26 | 26 | with entry = |
| 27 | 27 | if h is |
| 28 | 28 | { |
| 29 | - left_menu_entry(_menu_id, subentry, _classes, _action, _text, _extra, _target_id) then | |
| 29 | + left_menu_entry(_menu_id, subentry, _classes, _action, _text, _extra) then | |
| 30 | 30 | with item_class = if subentry then "subitem " else "item ", |
| 31 | - if _target_id is | |
| 32 | - { | |
| 33 | - failure then p([class(item_class+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), | |
| 34 | - success(target_id) then | |
| 35 | - p([class(item_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), | |
| 36 | - event(onclick, load_content(target_id, _action, _extra))],text(_T(_text))), | |
| 37 | - } | |
| 31 | + | |
| 32 | + p([class(item_class+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes))],actioner(same,same, link(_T(_text)),_action,_extra)), | |
| 38 | 33 | |
| 39 | 34 | left_menu_entry_js(_menu_id, subentry, _classes, _js_to_call, _text) then |
| 40 | 35 | with item_class = if subentry then "subitem " else "item ", |
| 41 | 36 | p([class(item_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), |
| 42 | 37 | event(onclick, _js_to_call)],text(_T(_text))), |
| 43 | 38 | |
| 39 | + left_menu_entry_load_content(_menu_id, subentry, _classes, _action, _text, _extra, _target_id, _replace, _overlay) then | |
| 40 | + with item_class = if subentry then "subitem " else "item ", | |
| 41 | + p([class(item_class+"clickable "+_menu_id+"_icon"+(if _menu_id=selected then " selected" else "")+ " "+join(" ", _classes)), | |
| 42 | + event(onclick, load_content(_target_id, _action, _extra, _replace, _overlay))],text(_T(_text))), | |
| 43 | + | |
| 44 | 44 | title(_title_id, subtitle, _classes, _text) then |
| 45 | 45 | p([class(if subtitle then "menu_subtitle" else "menu_title"), class((if _title_id=selected then " selected" else "")+ " "+join(" ", _classes))], text([],_T(_text))) |
| 46 | 46 | // p([class("menu_title"), class("item "+_title_id+"_icon"+if _title_id=selected then " selected" else ""+ " "+join(" ", _classes))], text([],_T(_text))) | ... | ... |