Module: ThinMan::AjaxHelper
- Defined in:
- lib/thin_man/ajax_helper.rb
Instance Method Summary collapse
- #ajax_delete(name, options, html_options, target, sub_class: nil, replace_response: false, no_confirm: false, custom_progress: nil, no_mouse_click: nil) ⇒ Object
- #ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, remove_on_success: nil, empty_on_success: nil, reset_on_success: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, scroll_to: nil, scroll_center: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil) ⇒ Object
- #ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, container: nil, custom_progress: nil, no_mouse_click: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil, replacement_path: nil, push_path: nil, progress_target: nil, progress_color: nil) ⇒ Object
- #ajax_form_now(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, container: nil, custom_progress: nil, mask_target: nil, mask_message: nil, replacement_path: nil, push_path: nil, progress_target: nil, progress_color: nil) ⇒ Object
- #ajax_form_now_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil) ⇒ Object
- #ajax_link(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, mask_target: nil, mask_message: nil, replacement_path: nil, push_path: nil, progress_color: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
- #ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
- #ajax_link_hash(target, insert_method: nil, sub_type: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
- #ajax_link_now(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, mask_target: nil, mask_message: nil, sequence_group: nil, sequence_number: nil, replacement_path: nil, push_path: nil, search_path: nil, search_params: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
- #dom_target(resource, label = nil) ⇒ Object
Instance Method Details
#ajax_delete(name, options, html_options, target, sub_class: nil, replace_response: false, no_confirm: false, custom_progress: nil, no_mouse_click: nil) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/thin_man/ajax_helper.rb', line 71 def ajax_delete(name, , , target, sub_class: nil, replace_response: false, no_confirm: false, custom_progress: nil, no_mouse_click: nil) = { 'data-ajax-delete' => true, 'data-ajax-target' => target } .merge!('data-sub-type' => sub_class) if sub_class.present? .merge!('data-replace-response' => true) if replace_response .merge!('data-no-confirm' => true) if no_confirm .merge!('data-custom-progress' => custom_progress) if custom_progress.present? .merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present? link_to(name, , .merge()) end |
#ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, remove_on_success: nil, empty_on_success: nil, reset_on_success: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, scroll_to: nil, scroll_center: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil) ⇒ Object
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 |
# File 'lib/thin_man/ajax_helper.rb', line 142 def ajax_form_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, remove_on_success: nil, empty_on_success: nil, reset_on_success: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, scroll_to: nil, scroll_center: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil ) data_attrs = "data-ajax-form=true data-ajax-target=#{target}" data_attrs += " data-insert-method=#{insert_method}" if insert_method data_attrs += " data-sub-type=#{sub_class}" if sub_class data_attrs += " data-empty-on-success=#{empty_on_success}" if empty_on_success data_attrs += " data-remove-on-success=#{remove_on_success}" if remove_on_success data_attrs += " data-reset-on-success=#{reset_on_success}" if reset_on_success data_attrs += " data-error-target=#{error_target}" if error_target data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click data_attrs += " data-progress-target=#{progress_target}" if progress_target data_attrs += " data-progress-color=#{progress_color}" if progress_color data_attrs += " data-mask-target=#{mask_target}" if mask_target data_attrs += " data-mask-message=#{}" if data_attrs += " data-scroll-to=#{scroll_to}" if scroll_to data_attrs += " data-scroll-center=true" if scroll_center data_attrs += " data-replacement-path=#{replacement_path}" if replacement_path data_attrs += " data-push-path=#{push_path}" if push_path data_attrs end |
#ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, container: nil, custom_progress: nil, no_mouse_click: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil, replacement_path: nil, push_path: nil, progress_target: nil, progress_color: nil) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/thin_man/ajax_helper.rb', line 86 def ajax_form_hash(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, container: nil, custom_progress: nil, no_mouse_click: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil, replacement_path: nil, push_path: nil, progress_target: nil, progress_color: nil) = { 'data-ajax-form' => true, 'data-ajax-target' => target } .merge!('data-insert-method' => insert_method) if insert_method.present? .merge!('data-sub-type' => sub_class) if sub_class.present? .merge!('data-container' => container) if container.present? .merge!('data-error-target' => error_target) if error_target.present? .merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present? .merge!('data-remove-on-success' => remove_on_success) if remove_on_success.present? .merge!('data-reset-on-success' => reset_on_success) if reset_on_success.present? .merge!('data-custom-progress' => custom_progress) if custom_progress.present? .merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present? .merge!('data-progress-target' => progress_target) if progress_target.present? .merge!('data-progress-color' => progress_color) if progress_color.present? .merge!('data-mask-target' => mask_target) if mask_target.present? .merge!('data-mask-message' => ) if .present? .merge!('data-scroll-to' => scroll_to) if scroll_to.present? .merge!('data-scroll-center' => true) if scroll_center.present? .merge!('data-replacement-path' => replacement_path) if replacement_path.present? .merge!('data-push-path' => push_path) if push_path.present? end |
#ajax_form_now(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, container: nil, custom_progress: nil, mask_target: nil, mask_message: nil, replacement_path: nil, push_path: nil, progress_target: nil, progress_color: nil) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/thin_man/ajax_helper.rb', line 115 def ajax_form_now(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, container: nil, custom_progress: nil, mask_target: nil, mask_message: nil, replacement_path: nil, push_path: nil, progress_target: nil, progress_color: nil) = { 'data-ajax-form-now' => true, 'data-ajax-target' => target } .merge!('data-insert-method' => insert_method) if insert_method.present? .merge!('data-sub-type' => sub_class) if sub_class.present? .merge!('data-container' => container) if container.present? .merge!('data-error-target' => error_target) if error_target.present? .merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present? .merge!('data-remove-on-success' => remove_on_success) if remove_on_success.present? .merge!('data-reset-on-success' => reset_on_success) if reset_on_success.present? .merge!('data-custom-progress' => custom_progress) if custom_progress.present? .merge!('data-progress-target' => progress_target) if progress_target.present? .merge!('data-progress-color' => progress_color) if progress_color.present? .merge!('data-mask-target' => mask_target) if mask_target.present? .merge!('data-mask-message' => ) if .present? .merge!('data-replacement-path' => replacement_path) if replacement_path.present? .merge!('data-push-path' => push_path) if push_path.present? end |
#ajax_form_now_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil) ⇒ Object
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/thin_man/ajax_helper.rb', line 166 def ajax_form_now_attrs(target, sub_class: nil, insert_method: nil, error_target: nil, empty_on_success: nil, reset_on_success: nil, remove_on_success: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil ) data_attrs = "data-ajax-form-now=true data-ajax-target=#{target}" data_attrs += " data-insert-method=#{insert_method}" if insert_method data_attrs += " data-sub-type=#{sub_class}" if sub_class data_attrs += " data-empty-on-success=#{empty_on_success}" if empty_on_success data_attrs += " data-remove-on-success=#{remove_on_success}" if remove_on_success data_attrs += " data-reset-on-success=#{reset_on_success}" if reset_on_success data_attrs += " data-error-target=#{error_target}" if error_target data_attrs += " data-progress-target=#{progress_target}" if progress_target data_attrs += " data-progress-color=#{progress_color}" if progress_color data_attrs += " data-mask-target=#{mask_target}" if mask_target data_attrs += " data-mask-message=#{}" if data_attrs += " data-replacement-path=#{replacement_path}" if replacement_path data_attrs += " data-push-path=#{push_path}" if push_path data_attrs end |
#ajax_link(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, mask_target: nil, mask_message: nil, replacement_path: nil, push_path: nil, progress_color: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/thin_man/ajax_helper.rb', line 3 def ajax_link(name, , , target, sub_class: nil, insert_method: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, mask_target: nil, mask_message: nil, replacement_path: nil, push_path: nil, progress_color: nil, scroll_to: nil, scroll_center: nil) = { 'data-ajax-link' => true, 'data-ajax-target' => target } .merge!('data-sub-type' => sub_class) if sub_class.present? .merge!('data-insert-method' => insert_method) if insert_method.present? .merge!('data-ajax-method' => http_method) if http_method.present? .merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present? .merge!('data-remove-on-success' => remove_on_success) if remove_on_success.present? .merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present? .merge!('data-progress-target' => progress_target) if progress_target.present? .merge!('data-progress-color' => progress_color) if progress_color.present? .merge!('data-mask-target' => mask_target) if mask_target.present? .merge!('data-mask-message' => ) if .present? .merge!('data-scroll-to' => scroll_to) if scroll_to.present? .merge!('data-scroll-center' => true) if scroll_center.present? .merge!('data-replacement-path' => replacement_path) if replacement_path.present? .merge!('data-push-path' => push_path) if push_path.present? link_to(name, , .merge()) end |
#ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
# File 'lib/thin_man/ajax_helper.rb', line 187 def ajax_link_attrs(target, insert_method: nil, sub_type: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil) data_attrs = "data-ajax-link=true data-ajax-target=#{target}" data_attrs += " data-insert-method=#{insert_method}" if insert_method data_attrs += " data-ajax-method=#{http_method}" if http_method data_attrs += " data-sub-type=#{sub_type}" if sub_type data_attrs += " data-empty-on-success=#{empty_on_success}" if empty_on_success data_attrs += " data-remove-on-success=#{remove_on_success}" if remove_on_success data_attrs += " data-no-mouse-click=#{no_mouse_click}" if no_mouse_click data_attrs += " data-progress-target=#{progress_target}" if progress_target data_attrs += " data-progress-color=#{progress_color}" if progress_color data_attrs += " data-scroll-to=#{scroll_to}" if scroll_to data_attrs += " data-scroll-center=true" if scroll_center data_attrs += " data-mask-target=#{mask_target}" if mask_target data_attrs += " data-mask-message=#{}" if data_attrs += " data-replacement-path=#{replacement_path}" if replacement_path data_attrs += " data-push-path=#{push_path}" if push_path data_attrs end |
#ajax_link_hash(target, insert_method: nil, sub_type: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File 'lib/thin_man/ajax_helper.rb', line 211 def ajax_link_hash(target, insert_method: nil, sub_type: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, replacement_path: nil, push_path: nil, mask_target: nil, mask_message: nil, scroll_to: nil, scroll_center: nil) = { 'data-ajax-link' => true, 'data-ajax-target' => target } .merge!('data-insert-method' => insert_method) if insert_method.present? .merge!('data-ajax-method' => http_method) if http_method.present? .merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present? .merge!('data-remove-on-success' => remove_on_success) if remove_on_success.present? .merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present? .merge!('data-progress-target' => progress_target) if progress_target.present? .merge!('data-progress-color' => progress_color) if progress_color.present? .merge!('data-mask-target' => mask_target) if mask_target.present? .merge!('data-mask-message' => ) if .present? .merge!('data-scroll-to' => scroll_to) if scroll_to.present? .merge!('data-scroll-center' => true) if scroll_center.present? .merge!('data-replacement-path' => replacement_path) if replacement_path.present? .merge!('data-push-path' => push_path) if push_path.present? end |
#ajax_link_now(name, options, html_options, target, sub_class: nil, insert_method: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, mask_target: nil, mask_message: nil, sequence_group: nil, sequence_number: nil, replacement_path: nil, push_path: nil, search_path: nil, search_params: nil, scroll_to: nil, scroll_center: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/thin_man/ajax_helper.rb', line 31 def ajax_link_now(name, , , target, sub_class: nil, insert_method: nil, empty_on_success: nil, remove_on_success: nil, http_method: nil, no_mouse_click: nil, progress_target: nil, progress_color: nil, mask_target: nil, mask_message: nil, sequence_group: nil, sequence_number: nil, replacement_path: nil, push_path: nil, search_path: nil, search_params: nil, scroll_to: nil, scroll_center: nil) = { 'data-ajax-link-now' => true, 'data-ajax-target' => target } .merge!('data-sub-type' => sub_class) if sub_class.present? .merge!('data-insert-method' => insert_method) if insert_method.present? .merge!('data-ajax-method' => http_method) if http_method.present? .merge!('data-empty-on-success' => empty_on_success) if empty_on_success.present? .merge!('data-remove-on-success' => remove_on_success) if remove_on_success.present? .merge!('data-no-mouse-click' => no_mouse_click) if no_mouse_click.present? .merge!('data-progress-target' => progress_target) if progress_target.present? .merge!('data-progress-color' => progress_color) if progress_color.present? .merge!('data-mask-target' => mask_target) if mask_target.present? .merge!('data-mask-message' => ) if .present? .merge!('data-sequence-group' => sequence_group) if sequence_group.present? .merge!('data-sequence-number' => sequence_number) if sequence_number.present? .merge!('data-search-path' => search_path) if search_path.present? .merge!('data-search-params' => search_params) if search_params.present? .merge!('data-scroll-to' => scroll_to) if scroll_to.present? .merge!('data-scroll-center' => true) if scroll_center.present? .merge!('data-replacement-path' => replacement_path) if replacement_path.present? .merge!('data-push-path' => push_path) if push_path.present? a_tag = link_to(name, , .merge()) if(search_path.present?) href_attr = a_tag.scan(/href="[^"]*/).first href_end_index = a_tag.index(href_attr) + href_attr.length a_tag.insert(href_end_index,"#!#{target}") end a_tag end |
#dom_target(resource, label = nil) ⇒ Object
237 238 239 |
# File 'lib/thin_man/ajax_helper.rb', line 237 def dom_target(resource, label = nil) '#' + dom_id(resource, label) end |