Changeset 23037 for extensions/community/add_photos.tpl
- Timestamp:
- Jun 4, 2013, 12:55:59 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/community/add_photos.tpl
r22820 r23037 12 12 {footer_script}{literal} 13 13 jQuery(document).ready(function(){ 14 function sprintf() { 15 var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = ''; 16 while (f) { 17 if (m = /^[^\x25]+/.exec(f)) { 18 o.push(m[0]); 19 } 20 else if (m = /^\x25{2}/.exec(f)) { 21 o.push('%'); 22 } 23 else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) { 24 if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) { 25 throw('Too few arguments.'); 26 } 27 if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) { 28 throw('Expecting number but found ' + typeof(a)); 29 } 30 switch (m[7]) { 31 case 'b': a = a.toString(2); break; 32 case 'c': a = String.fromCharCode(a); break; 33 case 'd': a = parseInt(a); break; 34 case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break; 35 case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break; 36 case 'o': a = a.toString(8); break; 37 case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break; 38 case 'u': a = Math.abs(a); break; 39 case 'x': a = a.toString(16); break; 40 case 'X': a = a.toString(16).toUpperCase(); break; 41 } 42 a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a); 43 c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; 44 x = m[5] - String(a).length - s.length; 45 p = m[5] ? str_repeat(c, x) : ''; 46 o.push(s + (m[4] ? a + p : p + a)); 47 } 48 else { 49 throw('Huh ?!'); 50 } 51 f = f.substring(m[0].length); 52 } 53 return o.join(''); 54 } 55 14 56 function checkUploadStart() { 15 57 var nbErrors = 0; … … 167 209 {/literal} 168 210 {if $upload_mode eq 'html'} 211 {if isset($limit_nb_photos)} 212 var limit_nb_photos = {$limit_nb_photos}; 213 {/if} 169 214 {literal} 215 170 216 function addUploadBox() { 171 217 var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]"></p>'; 172 218 jQuery(uploadBox).appendTo("#uploadBoxes"); 219 220 if (typeof limit_nb_photos != 'undefined') { 221 if (jQuery("input[name^=image_upload]").size() >= limit_nb_photos) { 222 jQuery("#addUploadBox").hide(); 223 } 224 } 173 225 } 174 226 … … 176 228 177 229 jQuery("#addUploadBox A").click(function () { 230 if (typeof limit_nb_photos != 'undefined') { 231 if (jQuery("input[name^=image_upload]").size() >= limit_nb_photos) { 232 alert('tu rigoles mon gaillard !'); 233 return false; 234 } 235 } 236 178 237 addUploadBox(); 179 238 }); … … 191 250 var buttonText = "{'Select files'|@translate}"; 192 251 var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */ 252 var sumQueueFilesize = 0; 253 {if isset($limit_storage)} 254 var limit_storage = {$limit_storage}; 255 {/if} 193 256 194 257 {literal} … … 209 272 'fileSizeLimit' : sizeLimit, 210 273 'progressData' : 'percentage', 274 {/literal} 275 {if isset($limit_nb_photos)} 276 'queueSizeLimit' : {$limit_nb_photos}, 277 {/if} 278 {literal} 211 279 requeueErrors : false, 212 'onSelect' : function(event,ID,fileObj) { 280 'onSelect' : function(file) { 281 console.log('filesize = '+file.size+'bytes'); 282 283 if (typeof limit_storage != 'undefined') { 284 if (sumQueueFilesize + file.size > limit_storage) { 285 jQuery.jGrowl( 286 '<p></p>'+sprintf( 287 '{/literal}{'File %s too big (%uMB), quota of %uMB exceeded'|@translate}{literal}', 288 file.name, 289 Math.round(file.size/(1024*1024)), 290 limit_storage/(1024*1024) 291 ), 292 { 293 theme: 'error', 294 header: 'ERROR', 295 life: 4000, 296 sticky: false 297 } 298 ); 299 300 jQuery('#uploadify').uploadifyCancel(file.id); 301 return false; 302 } 303 else { 304 sumQueueFilesize += file.size; 305 } 306 } 307 213 308 jQuery("#fileQueue").show(); 309 }, 310 'onCancel' : function(file) { 311 console.log('The file ' + file.name + ' was cancelled ('+file.size+')'); 214 312 }, 215 313 'onQueueComplete' : function(stats) { … … 432 530 <legend>{'Select files'|@translate}</legend> 433 531 434 <p id="uploadWarningsSummary">{$upload_max_filesize_shorthand}B. {$upload_file_types}. {if isset($max_upload_resolution)}{$max_upload_resolution}Mpx{/if} <a class="showInfo" title="{'Learn more'|@translate}">i</a></p> 532 <p id="uploadWarningsSummary">{$upload_max_filesize_shorthand}B. {$upload_file_types}. {if isset($max_upload_resolution)}{$max_upload_resolution}Mpx.{/if} {$quota_summary} 533 <a class="showInfo" title="{'Learn more'|@translate}">i</a></p> 435 534 436 535 <p id="uploadWarnings"> … … 440 539 {'Approximate maximum resolution: %dM pixels (that\'s %dx%d pixels).'|@translate|@sprintf:$max_upload_resolution:$max_upload_width:$max_upload_height} 441 540 {/if} 541 {$quota_details} 442 542 </p> 443 543
Note: See TracChangeset
for help on using the changeset viewer.