[28872] | 1 | {footer_script} |
---|
| 2 | var writeMetadataProgressMessage = "{'Write metadata in progress...'|translate}"; |
---|
| 3 | var wm_pwg_token = '{$WM_PWG_TOKEN}'; |
---|
| 4 | {literal} |
---|
| 5 | jQuery(document).ready(function() { |
---|
| 6 | jQuery('#applyAction').click(function(e) { |
---|
| 7 | if (typeof(elements) != "undefined") { |
---|
| 8 | return true; |
---|
| 9 | } |
---|
| 10 | |
---|
| 11 | if (jQuery('[name="selectAction"]').val() == 'writeMetadata') |
---|
| 12 | { |
---|
| 13 | e.stopPropagation(); |
---|
| 14 | } |
---|
| 15 | else |
---|
| 16 | { |
---|
| 17 | return true; |
---|
| 18 | } |
---|
| 19 | |
---|
| 20 | jQuery('.bulkAction').hide(); |
---|
| 21 | jQuery('#regenerationText').html(writeMetadataProgressMessage); |
---|
| 22 | var maxRequests=1; |
---|
| 23 | |
---|
| 24 | var queuedManager = jQuery.manageAjax.create('queued', { |
---|
| 25 | queue: true, |
---|
| 26 | cacheResponse: false, |
---|
| 27 | maxRequests: maxRequests |
---|
| 28 | }); |
---|
| 29 | |
---|
| 30 | elements = Array(); |
---|
| 31 | |
---|
| 32 | if (jQuery('input[name=setSelected]').is(':checked')) { |
---|
| 33 | elements = all_elements; |
---|
| 34 | } |
---|
| 35 | else { |
---|
| 36 | jQuery('input[name="selection[]"]').filter(':checked').each(function() { |
---|
| 37 | elements.push(jQuery(this).val()); |
---|
| 38 | }); |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | progressBar_max = elements.length; |
---|
| 42 | todo = 0; |
---|
| 43 | |
---|
| 44 | jQuery('#applyActionBlock').hide(); |
---|
| 45 | jQuery('select[name="selectAction"]').hide(); |
---|
| 46 | jQuery('#regenerationMsg').show(); |
---|
| 47 | jQuery('#progressBar').progressBar(0, { |
---|
| 48 | max: progressBar_max, |
---|
| 49 | textFormat: 'fraction', |
---|
| 50 | boxImage: 'themes/default/images/progressbar.gif', |
---|
| 51 | barImage: 'themes/default/images/progressbg_orange.gif' |
---|
| 52 | }); |
---|
| 53 | |
---|
| 54 | for (i=0;i<elements.length;i++) { |
---|
| 55 | queuedManager.add({ |
---|
| 56 | type: 'POST', |
---|
| 57 | url: 'ws.php?format=json', |
---|
| 58 | data: { |
---|
| 59 | method: "pwg.images.writeMetadata", |
---|
| 60 | pwg_token: wm_pwg_token, |
---|
| 61 | image_id: elements[i] |
---|
| 62 | }, |
---|
| 63 | dataType: 'json', |
---|
| 64 | success: ( function(data) { progressWriteMetadata(++todo, progressBar_max, data['result']) }), |
---|
| 65 | error: ( function(data) { progressWriteMetadata(++todo, progressBar_max, false) }) |
---|
| 66 | }); |
---|
| 67 | } |
---|
| 68 | return false; |
---|
| 69 | }); |
---|
| 70 | |
---|
| 71 | function progressWriteMetadata(val, max, success) { |
---|
| 72 | jQuery('#progressBar').progressBar(val, { |
---|
| 73 | max: max, |
---|
| 74 | textFormat: 'fraction', |
---|
| 75 | boxImage: 'themes/default/images/progressbar.gif', |
---|
| 76 | barImage: 'themes/default/images/progressbg_orange.gif' |
---|
| 77 | }); |
---|
| 78 | type = success ? 'regenerateSuccess': 'regenerateError' |
---|
| 79 | s = jQuery('[name="'+type+'"]').val(); |
---|
| 80 | jQuery('[name="'+type+'"]').val(++s); |
---|
| 81 | |
---|
| 82 | if (val == max) |
---|
| 83 | jQuery('#applyAction').click(); |
---|
| 84 | } |
---|
| 85 | |
---|
| 86 | }); |
---|
| 87 | {/literal}{/footer_script} |
---|
| 88 | |
---|
| 89 | <div id="write_metadata" class="bulkAction"> |
---|
| 90 | </div> |
---|