|
40 | 40 | jQuery(document).on('focus', ':input', function() { ActiveScaffold.last_focus = this; }); |
41 | 41 | jQuery(document).on('blur', ':input', function(e) { ActiveScaffold.last_focus = e.relatedTarget; }); |
42 | 42 | jQuery(document).click(function(event) { |
43 | | - jQuery('.action_group.dyn > ul').hide(); // only hide so action links loading still work |
| 43 | + if (!jQuery(event.target).closest('.action_group.dyn').length) { |
| 44 | + jQuery('.action_group.dyn > ul').remove(); |
| 45 | + } |
44 | 46 | }); |
45 | 47 | jQuery(document).on('ajax:beforeSend', 'form.as_form', function(event) { |
46 | 48 | var as_form = jQuery(this).closest("form"); |
|
257 | 259 | if (span.data('editInPlace')) span.trigger('click.editInPlace'); |
258 | 260 | else ActiveScaffold.in_place_editor_field_clicked(span); |
259 | 261 | }); |
| 262 | + jQuery(document).on('click', '.file-input-controls .remove-file-btn', function(event) { |
| 263 | + event.preventDefault(); |
| 264 | + var btn = jQuery(this), file_line = btn.closest('.file-input-controls'); |
| 265 | + if (file_line.find('.remove_file').val('true').length) { |
| 266 | + btn.parent().hide(); |
| 267 | + file_line.find('input').show(); |
| 268 | + if (file_line.attr('required')) file_line.find('input').attr('required', 'required'); |
| 269 | + } else { |
| 270 | + file_line.remove(); |
| 271 | + } |
| 272 | + return false; |
| 273 | + }); |
| 274 | + jQuery(document).on('change', '.file-input-controls input[type=file]', function(event) { |
| 275 | + var file_line = jQuery(this).closest('.file-input-controls'); |
| 276 | + file_line.find('.remove_file').val('false'); |
| 277 | + }); |
260 | 278 | jQuery(document).on('ajax:before', 'a.as_paginate',function(event) { |
261 | 279 | var as_paginate = jQuery(this); |
262 | 280 | as_paginate.prevAll('img.loading-indicator').css('visibility','visible'); |
|
287 | 305 | } else return false; |
288 | 306 | }); |
289 | 307 | jQuery(document).on('ajax:complete', '.action_group.dyn > ul a', function(event) { |
290 | | - var action_link = ActiveScaffold.find_action_link(event.target); |
291 | | - if (action_link && action_link.loading_indicator) action_link.loading_indicator.css('visibility','hidden'); |
292 | | - jQuery(event.target).closest('.action_group.dyn > ul').remove(); |
| 308 | + var action_link = ActiveScaffold.find_action_link(event.target), link = jQuery(event.target); |
| 309 | + if (action_link && action_link.loading_indicator) action_link.loading_indicator.css('visibility', 'hidden'); |
| 310 | + setTimeout(function() { |
| 311 | + if (!link.parent().is('.action_group.dyn')) { |
| 312 | + link.closest('.action_group.dyn > ul').remove(); |
| 313 | + } |
| 314 | + }, 100); |
293 | 315 | }); |
294 | 316 |
|
295 | 317 | jQuery(document).on('change', 'input.update_form:not(.recordselect), textarea.update_form, select.update_form, .checkbox-list.update_form input:checkbox', function(event, additional_params) { |
|
0 commit comments