Commit e973169f822a3f58f460289b896e68341e1b80c3
1 parent
d714775d
add img_button_confirm function which return the raw html of the button with ass…
…ociated inline script as a string
Showing
1 changed file
with
84 additions
and
10 deletions
Show diff stats
web/widgets/button.anubis
| ... | ... | @@ -60,7 +60,33 @@ public define HTML_Partial_Content |
| 60 | 60 | List((String, String)) extra_ops |
| 61 | 61 | )= |
| 62 | 62 | img_button(img_path, same, url, extra_ops). |
| 63 | - | |
| 63 | + | |
| 64 | +define inline String | |
| 65 | + img_button_confirm_js | |
| 66 | + ( | |
| 67 | + String uid, | |
| 68 | + String dlg_title, | |
| 69 | + String dlg_text, | |
| 70 | + String dlg_ok, | |
| 71 | + String dlg_cancel | |
| 72 | + ) = | |
| 73 | + "CalexiumToolBox.data.confirm_dialog[" + to_js_string(uid) + "] = " + | |
| 74 | + "{ title: " + to_js_string(dlg_title) + | |
| 75 | + ", text: " + to_js_string(dlg_text) + | |
| 76 | + ", ok : " + to_js_string(dlg_ok) + | |
| 77 | + ", cancel: " + to_js_string(dlg_cancel) + | |
| 78 | + "};". | |
| 79 | + | |
| 80 | +define List(CoreAttrs) | |
| 81 | + img_button_confirm_image_attrs | |
| 82 | + ( | |
| 83 | + List(CoreAttrs) core_attrs, | |
| 84 | + String uid, | |
| 85 | + String url, | |
| 86 | + List((String, String)) extra_ops | |
| 87 | + ) = | |
| 88 | + core_attrs + [id(uid), style("cursor: pointer"), event(onclick, "CalexiumToolBox.make_confirm_dialog(this, " + to_js_string("/?a=" + url + format_extra_operands(extra_ops))+");")]. | |
| 89 | + | |
| 64 | 90 | public define HTML_Partial_Content |
| 65 | 91 | img_button_confirm |
| 66 | 92 | ( |
| ... | ... | @@ -75,15 +101,8 @@ public define HTML_Partial_Content |
| 75 | 101 | )= |
| 76 | 102 | with uid = generate_random_string(20), |
| 77 | 103 | |
| 78 | - js_confirm_dialog_data_obj = "CalexiumToolBox.data.confirm_dialog[" + to_js_string(uid) + "]", | |
| 79 | - js_data = js_confirm_dialog_data_obj + " = { | |
| 80 | - title: " + to_js_string(dlg_title) + ", | |
| 81 | - text: " + to_js_string(dlg_text) + ", | |
| 82 | - ok : " + to_js_string(dlg_ok) + ", | |
| 83 | - cancel: " + to_js_string(dlg_cancel) + "};", | |
| 84 | - | |
| 85 | - partial_content([js(js_file("js/cxm/cxm.js")), js_inline(jquery_ready(js_data))], | |
| 86 | - image(core_attrs + [id(uid), style("cursor: pointer"), event(onclick, "CalexiumToolBox.make_confirm_dialog(this, " + to_js_string("/?a=" + url + format_extra_operands(extra_ops))+");")], img_path, "")). | |
| 104 | + partial_content([js(js_file("js/cxm/cxm.js")), js_inline(jquery_ready(img_button_confirm_js(uid, dlg_title, dlg_text, dlg_ok, dlg_cancel)))], | |
| 105 | + image(img_button_confirm_image_attrs(core_attrs, uid, url, extra_ops), img_path, "")). | |
| 87 | 106 | |
| 88 | 107 | public define HTML_Partial_Content |
| 89 | 108 | img_button_confirm |
| ... | ... | @@ -122,4 +141,59 @@ public define HTML_Partial_Content |
| 122 | 141 | List((String, String)) extra_ops |
| 123 | 142 | )= |
| 124 | 143 | img_button_confirm(img_path, [], dlg_title, dlg_text, dlg_ok, dlg_cancel, url, extra_ops). |
| 144 | + | |
| 145 | +public define String | |
| 146 | + img_button_confirm | |
| 147 | + ( | |
| 148 | + String img_path, | |
| 149 | + List(CoreAttrs) core_attrs, | |
| 150 | + String dlg_title, | |
| 151 | + String dlg_text, | |
| 152 | + String dlg_ok, | |
| 153 | + String dlg_cancel, | |
| 154 | + String url, | |
| 155 | + List((String, String)) extra_ops | |
| 156 | + ) = | |
| 157 | + with uid = generate_random_string(20), | |
| 158 | + | |
| 159 | + "<script type=\"text/javascript\">" + jquery_ready(img_button_confirm_js(uid, dlg_title, dlg_text, dlg_ok, dlg_cancel)) + "</script>" + | |
| 160 | + "<img " + format_attrs(img_button_confirm_image_attrs(core_attrs, uid, url, extra_ops)) + " src=\"" + img_path + "\"></img>". | |
| 161 | + | |
| 162 | +public define String | |
| 163 | + img_button_confirm | |
| 164 | + ( | |
| 165 | + String img_path, | |
| 166 | + String dlg_title, | |
| 167 | + String dlg_text, | |
| 168 | + String dlg_ok, | |
| 169 | + String dlg_cancel, | |
| 170 | + String url | |
| 171 | + )= | |
| 172 | + img_button_confirm(img_path, [], dlg_title, dlg_text, dlg_ok, dlg_cancel, url, []). | |
| 125 | 173 | |
| 174 | +public define String | |
| 175 | + img_button_confirm | |
| 176 | + ( | |
| 177 | + String img_path, | |
| 178 | + List(CoreAttrs) core_attrs, | |
| 179 | + String dlg_title, | |
| 180 | + String dlg_text, | |
| 181 | + String dlg_ok, | |
| 182 | + String dlg_cancel, | |
| 183 | + String url | |
| 184 | + )= | |
| 185 | + img_button_confirm(img_path, core_attrs, dlg_title, dlg_text, dlg_ok, dlg_cancel, url, []). | |
| 186 | + | |
| 187 | +public define String | |
| 188 | + img_button_confirm | |
| 189 | + ( | |
| 190 | + String img_path, | |
| 191 | + String dlg_title, | |
| 192 | + String dlg_text, | |
| 193 | + String dlg_ok, | |
| 194 | + String dlg_cancel, | |
| 195 | + String url, | |
| 196 | + List((String, String)) extra_ops | |
| 197 | + )= | |
| 198 | + img_button_confirm(img_path, [], dlg_title, dlg_text, dlg_ok, dlg_cancel, url, extra_ops). | |
| 199 | + | ... | ... |