Changeset 13652 for extensions/GThumb/template/admin.tpl
- Timestamp:
- Mar 20, 2012, 11:32:30 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/GThumb/template/admin.tpl
r12857 r13652 47 47 </fieldset> 48 48 49 <p><input type="submit" name="submit" value="{'Submit'|@translate}"></p> 49 <p> 50 <input type="hidden" name="pwg_token" value="{$PWG_TOKEN}"> 51 <input type="submit" name="submit" value="{'Submit'|@translate}"> 52 <input type="submit" name="cachedelete" value="{'Purge thumbnails cache'|@translate}" title="{'Delete images in GThumb+ cache.'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"> 53 <input type="button" name="cachebuild" value="{'Pre-cache thumbnails'|@translate}" title="{'Finds images that have not been cached and creates the cached version.'|@translate}" onclick="start()"> 54 </p> 50 55 </form> 51 56 52 <fieldset id="cacheinfo"> 53 <legend>{'Cache Informations'|@translate}</legend> 54 <p id="cache_data"> </p> 55 <p id="GThumbAction"> 56 <button onclick="GThumb.deletecache();" title="{'Delete images in GThumb+ cache.'|@translate}">{'Purge thumbnails cache'|@translate}</button> 57 <button onclick="GThumb.generatecache();" title="{'Finds images that have not been cached and creates the cached version.'|@translate}">{'Pre-cache thumbnails'|@translate}</button> 57 <fieldset id="generate_cache"> 58 <legend>{'Pre-cache thumbnails'|@translate}</legend> 59 <p> 60 <table> 61 <tr> 62 <td>Errors</td> 63 <td id="errors">0</td> 64 </tr> 65 <tr> 66 <td>Loaded</td> 67 <td id="loaded">0</td> 68 </tr> 69 <tr> 70 <td>Remaining</td> 71 <td id="remaining">0</td> 72 </tr> 73 </table> 58 74 </p> 59 <div id="GThumbProgressbar" style="display:none;"> 60 {'Generating cache, please wait...'|@translate}<br> 61 <div id="progressbar"></div> 62 <p><button onclick="GThumb.abort();">{'Cancel'|@translate}</button></p> 75 <p> 76 <input id="startLink" value="{'Start'|@translate}" onclick="start()" type="button"> 77 <input id="pauseLink" value="{'Pause'|@translate}" onclick="pause()" type="button" disabled="disbled"> 78 <input id="stopLink" value="{'Stop'|@translate}" onclick="stop()" type="button" disabled="disbled"> 79 </p> 80 <div id="feedbackWrap" style="height:320px; min-height:320px;"> 81 <img id="feedbackImg"> 82 </div> 83 84 <div id="errorList"> 63 85 </div> 64 86 </fieldset> … … 69 91 #cacheinfo p, #GThumbProgressbar { text-align:left; line-height:20px; margin:20px } 70 92 .ui-progressbar-value { background-image: url(plugins/GThumb/template/pbar-ani.gif); } 93 #generate_cache { display: none; } 71 94 </style> 72 95 {/literal}{/html_head} 73 96 74 {combine_script id='jquery.ui.progressbar' load='footer'} 75 {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} 76 77 {footer_script} 78 var pwg_token = '{$PWG_TOKEN}'; 79 var confirm_message = '{'Are you sure?'|@translate}'; 80 var nb_files_str = '{'%d file'|@translate}'; 81 var nb_files_str_plur = '{'%d files'|@translate}'; 82 var lang_info_zero_plural = {if $lang_info.zero_plural}true{else}false{/if}; 83 var cache_size = {$CACHE_SIZE}; 84 var nb_files = {$NB_FILES}; 85 86 {literal} 87 var GThumb = { 88 89 total: 0, 90 done: 0, 91 92 queue: jQuery.manageAjax.create('queued', { 93 queue: true, 94 cacheResponse: false, 95 maxRequests: 3 96 }), 97 98 deletecache: function() { 99 if (confirm(confirm_message)) { 100 window.location = 'admin.php?page=plugin-GThumb&deletecache=true&pwg_token='+pwg_token; 101 } 102 }, 103 104 generatecache: function() { 105 GThumb.total = nb_files; 106 GThumb.done = nb_files; 107 jQuery("#progressbar").progressbar({value: 1}); 108 jQuery.ajax({ 109 url: 'admin.php?page=plugin-GThumb&generatecache=request', 110 dataType: 'json', 111 success: function(data) { 112 if (data.length > 0) { 113 jQuery("#GThumbProgressbar, #GThumbAction").toggle(); 114 GThumb.total = data.length + GThumb.done; 115 jQuery("#progressbar").progressbar({value: Math.ceil(GThumb.done * 100 / GThumb.total)}); 116 for (i=0;i<data.length;i++) { 117 GThumb.queue.add({ 118 type: 'GET', 119 url: 'ws.php', 120 data: { 121 method: 'pwg.images.getGThumbPlusThumbnail', 122 image_id: data[i], 123 format: 'json' 124 }, 125 dataType: 'json', 126 success: function(data) { 127 nb_files++; 128 cache_size += data.result.filesize; 129 updateCacheSizeAndFiles(); 130 GThumb.progressbar(); 131 }, 132 error: GThumb.progressbar 133 }); 134 } 135 } else { 136 window.location = 'admin.php?page=plugin-GThumb&generatecache=complete'; 137 } 138 }, 139 error: function() { 140 alert('An error occured'); 141 } 142 }); 143 return false; 144 }, 145 146 progressbar: function() { 147 jQuery( "#progressbar" ).progressbar({ 148 value: Math.ceil(++GThumb.done * 100 / GThumb.total) 149 }); 150 if (GThumb.done == GThumb.total) { 151 window.location = 'admin.php?page=plugin-GThumb&generatecache=complete'; 152 } 153 }, 154 155 abort: function() { 156 GThumb.queue.clear(); 157 GThumb.queue.abort(); 158 jQuery("#GThumbProgressbar, #GThumbAction").toggle(); 97 {combine_script id='iloader' load='footer' path='themes/default/js/image.loader.js'} 98 99 {footer_script require='jquery.effects.slide'}{literal} 100 jQuery('input[name^="cache"]').tipTip({'delay' : 0, 'fadeIn' : 200, 'fadeOut' : 200}); 101 102 var loader = new ImageLoader( {onChanged: loaderChanged, maxRequests:1 } ) 103 , pending_next_page = null 104 , last_image_show_time = 0 105 , allDoneDfd, urlDfd; 106 107 function start() { 108 allDoneDfd = jQuery.Deferred(); 109 urlDfd = jQuery.Deferred(); 110 111 allDoneDfd.always( function() { 112 jQuery("#startLink").attr('disabled', false).css("opacity", 1); 113 jQuery("#pauseLink,#stopLink").attr('disabled', true).css("opacity", 0.5); 114 } ); 115 116 urlDfd.always( function() { 117 if (loader.remaining()==0) 118 allDoneDfd.resolve(); 119 } ); 120 121 jQuery('#generate_cache').show(); 122 jQuery("#startLink").attr('disabled', true).css("opacity", 0.5); 123 jQuery("#pauseLink,#stopLink").attr('disabled', false).css("opacity", 1); 124 125 loader.pause(false); 126 updateStats(); 127 getUrls('0'); 128 } 129 130 function pause() { 131 loader.pause( !loader.pause() ); 132 } 133 134 function stop() { 135 loader.clear(); 136 urlDfd.resolve(); 137 } 138 139 function getUrls(page_token) { 140 data = {prev_page: page_token, max_urls: 195, types: []}; 141 jQuery.post( '{/literal}{$ROOT_URL}{literal}admin.php?page=plugin-GThumb&getMissingDerivative=', 142 data, wsData, "json").fail( wsError ); 143 } 144 145 function wsData(data) { 146 if (data.urls.length == 0) { 147 jQuery('#generate_cache, input[name="cachebuild"]').hide(); 159 148 } 160 }; 161 162 function updateCacheSizeAndFiles() { 163 164 if ( nb_files > 1 || (nb_files == 0 && lang_info_zero_plural)) { 165 nbstr = nb_files_str_plur; 166 } else { 167 nbstr = nb_files_str; 168 } 169 170 ret = nbstr.replace('%d', nb_files) + ', '; 171 172 if (cache_size > 1024 * 1024) 173 ret += Math.round((cache_size / (1024 * 1024))*100)/100 + ' MB'; 174 else 175 ret += Math.round((cache_size / 1024)*100)/100 + ' KB'; 176 177 jQuery("#cache_data").html(ret); 178 } 179 180 updateCacheSizeAndFiles(); 181 182 jQuery('#GThumbAction button').tipTip({'delay' : 0, 'fadeIn' : 200, 'fadeOut' : 200}); 149 loader.add( data.urls ); 150 if (data.next_page) { 151 if (loader.pause() || loader.remaining() > 100) { 152 pending_next_page = data.next_page; 153 } 154 else { 155 getUrls(data.next_page); 156 } 157 } 158 } 159 160 function wsError() { 161 urlDfd.reject(); 162 } 163 164 function updateStats() { 165 jQuery("#loaded").text( loader.loaded ); 166 jQuery("#errors").text( loader.errors ); 167 jQuery("#remaining").text( loader.remaining() ); 168 } 169 170 function loaderChanged(type, img) { 171 updateStats(); 172 if (img) { 173 if (type==="load") { 174 var now = jQuery.now(); 175 if (now - last_image_show_time > 3000) { 176 last_image_show_time = now; 177 var h=img.height, url=img.src; 178 jQuery("#feedbackWrap").hide("slide", {direction:'down'}, function() { 179 last_image_show_time = jQuery.now(); 180 if (h > 300 ) 181 jQuery("#feedbackImg").attr("height", 300); 182 else 183 jQuery("#feedbackImg").removeAttr("height"); 184 jQuery("#feedbackImg").attr("src", url); 185 jQuery("#feedbackWrap").show("slide", {direction:'up'} ); 186 } ); 187 } 188 } 189 else { 190 jQuery("#errorList").prepend( '<a href="'+img.src+'">'+img.src+'</a>' + "<br>"); 191 } 192 } 193 if (pending_next_page && 100 > loader.remaining() ) { 194 getUrls(pending_next_page); 195 pending_next_page = null; 196 } 197 else if (loader.remaining() == 0 && (urlDfd.isResolved() || urlDfd.isRejected())) { 198 allDoneDfd.resolve(); 199 } 200 } 183 201 {/literal}{/footer_script}
Note: See TracChangeset
for help on using the changeset viewer.