Changeset 13575 for trunk/admin
- Timestamp:
- Mar 15, 2012, 10:04:39 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/themes/default/template/batch_manager_global.tpl
r13544 r13575 95 95 var nb_thumbs_set = {$nb_thumbs_set}; 96 96 var applyOnDetails_pattern = "{'on the %d selected photos'|@translate}"; 97 var elements = [];98 97 var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; 99 var generate_derivatives_done=false; 98 var derivatives = {ldelim} 99 elements: null, 100 done: 0, 101 total: 0, 102 103 finished: function() {ldelim} 104 return derivatives.done == derivatives.total && derivatives.elements && derivatives.elements.length==0; 105 } 106 }; 100 107 101 108 var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}"; … … 155 162 } 156 163 157 function progress( val, max,success) {158 jQuery('#progressBar').progressBar( val, {159 max: max,164 function progress(success) { 165 jQuery('#progressBar').progressBar(derivatives.done, { 166 max: derivatives.total, 160 167 textFormat: 'fraction', 161 168 boxImage: 'themes/default/images/progressbar.gif', … … 168 175 } 169 176 170 if (val == max) { 171 generate_derivatives_done = true; 177 if (derivatives.finished()) { 172 178 jQuery('#applyAction').click(); 173 179 } … … 406 412 407 413 jQuery('#applyAction').click(function() { 408 if (jQuery('[name="selectAction"]').val() != 'generate_derivatives') 409 { 410 return true; 411 } 412 if (generate_derivatives_done) 414 if (jQuery('[name="selectAction"]').val() != 'generate_derivatives' 415 || derivatives.finished() ) 413 416 { 414 417 return true; … … 423 426 }); 424 427 428 derivatives.elements = []; 425 429 if (jQuery('input[name="setSelected"]').attr('checked')) 426 elements = all_elements;430 derivatives.elements = all_elements; 427 431 else 428 432 jQuery('input[name="selection[]"]').each(function() { 429 433 if (jQuery(this).attr('checked')) { 430 elements.push(jQuery(this).val());434 derivatives.elements.push(jQuery(this).val()); 431 435 } 432 436 }); 433 434 progressBar_max = 0;435 todo = 0;436 437 437 438 jQuery('#applyActionBlock').hide(); … … 439 440 jQuery('#regenerationMsg').show(); 440 441 441 jQuery('#progressBar').progressBar(0, { 442 max: progressBar_max, 443 textFormat: 'fraction', 444 boxImage: 'themes/default/images/progressbar.gif', 445 barImage: 'themes/default/images/progressbg_orange.gif' 446 }); 447 442 progress(); 448 443 getDerivativeUrls(); 449 444 return false; … … 451 446 452 447 function getDerivativeUrls() { 453 if (elements.length==0) 454 return; 455 var ids = elements.splice(0, 500); 448 var ids = derivatives.elements.splice(0, 500); 456 449 var params = {max_urls: 100000, ids: ids, types: []}; 457 450 jQuery("#action_generate_derivatives input").each( function(i, t) { … … 469 462 return; 470 463 } 471 progressBar_max+= data.result.urls.length;472 progress( todo, progressBar_max);464 derivatives.total += data.result.urls.length; 465 progress(); 473 466 for (var i=0; i < data.result.urls.length; i++) { 474 467 jQuery.manageAjax.add("queued", { … … 476 469 url: data.result.urls[i] + "&ajaxload=true", 477 470 dataType: 'json', 478 success: ( function(data) { progress(++todo, progressBar_max,true) }),479 error: ( function(data) { progress(++todo, progressBar_max,false) })471 success: ( function(data) { derivatives.done++; progress(true) }), 472 error: ( function(data) { derivatives.done++; progress(false) }) 480 473 }); 481 474 } 475 if (derivatives.elements.length) 476 setTimeout( getDerivativeUrls, 25 * (derivatives.total-derivatives.done)); 482 477 } 483 478 } ); … … 643 638 644 639 <legend>{'Action'|@translate}</legend> 645 <div id="forbidAction"{if count($selection) != 0} style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div>646 <div id="permitAction"{if count($selection) == 0} style="display:none"{/if}>640 <div id="forbidAction"{if count($selection) != 0} style="display:none"{/if}>{'No photo selected, no action possible.'|@translate}</div> 641 <div id="permitAction"{if count($selection) == 0} style="display:none"{/if}> 647 642 648 643 <select name="selectAction">
Note: See TracChangeset
for help on using the changeset viewer.