Changeset 23037 for extensions/community/admin_permissions.tpl
- Timestamp:
- Jun 4, 2013, 12:55:59 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/community/admin_permissions.tpl
r9807 r23037 1 {combine_script id='jquery.ui.slider' require='jquery.ui' load='footer' path='themes/default/js/ui/minified/jquery.ui.slider.min.js'} 2 {combine_css path="themes/default/js/ui/theme/jquery.ui.slider.css"} 3 1 4 {literal} 2 5 <style> … … 6 9 .permissionActions img {margin-bottom:-2px} 7 10 .rowSelected {background-color:#C2F5C2 !important} 11 #community_nb_photos, #community_storage {width:400px; display:inline-block; margin-right:10px;} 8 12 </style> 9 13 {/literal} 10 14 11 15 {footer_script}{literal} 16 function sprintf() { 17 var i = 0, a, f = arguments[i++], o = [], m, p, c, x, s = ''; 18 while (f) { 19 if (m = /^[^\x25]+/.exec(f)) { 20 o.push(m[0]); 21 } 22 else if (m = /^\x25{2}/.exec(f)) { 23 o.push('%'); 24 } 25 else if (m = /^\x25(?:(\d+)\$)?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(f)) { 26 if (((a = arguments[m[1] || i++]) == null) || (a == undefined)) { 27 throw('Too few arguments.'); 28 } 29 if (/[^s]/.test(m[7]) && (typeof(a) != 'number')) { 30 throw('Expecting number but found ' + typeof(a)); 31 } 32 switch (m[7]) { 33 case 'b': a = a.toString(2); break; 34 case 'c': a = String.fromCharCode(a); break; 35 case 'd': a = parseInt(a); break; 36 case 'e': a = m[6] ? a.toExponential(m[6]) : a.toExponential(); break; 37 case 'f': a = m[6] ? parseFloat(a).toFixed(m[6]) : parseFloat(a); break; 38 case 'o': a = a.toString(8); break; 39 case 's': a = ((a = String(a)) && m[6] ? a.substring(0, m[6]) : a); break; 40 case 'u': a = Math.abs(a); break; 41 case 'x': a = a.toString(16); break; 42 case 'X': a = a.toString(16).toUpperCase(); break; 43 } 44 a = (/[def]/.test(m[7]) && m[2] && a >= 0 ? '+'+ a : a); 45 c = m[3] ? m[3] == '0' ? '0' : m[3].charAt(1) : ' '; 46 x = m[5] - String(a).length - s.length; 47 p = m[5] ? str_repeat(c, x) : ''; 48 o.push(s + (m[4] ? a + p : p + a)); 49 } 50 else { 51 throw('Huh ?!'); 52 } 53 f = f.substring(m[0].length); 54 } 55 return o.join(''); 56 } 57 12 58 $(document).ready(function() { 13 59 $("select[name=who]").change(function () { … … 52 98 return false; 53 99 }); 100 101 /* ∞ */ 102 /** 103 * find the key from a value in the startStopValues array 104 */ 105 function getSliderKeyFromValue(value, values) { 106 for (var key in values) { 107 if (values[key] == value) { 108 return key; 109 } 110 } 111 return 0; 112 } 113 114 var nbPhotosValues = [5,10,20,50,100,500,1000,5000,-1]; 115 116 function getNbPhotosInfoFromIdx(idx) { 117 if (idx == nbPhotosValues.length - 1) { 118 return "{/literal}{'no limit'|@translate}{literal}"; 119 } 120 121 return sprintf( 122 "{/literal}{'up to %d photos (for each user)'|@translate}{literal}", 123 nbPhotosValues[idx] 124 ); 125 } 126 127 /* init nb_photos info span */ 128 var nbPhotos_init = getSliderKeyFromValue(jQuery('input[name=nb_photos]').val(), nbPhotosValues); 129 130 jQuery("#community_nb_photos_info").html(getNbPhotosInfoFromIdx(nbPhotos_init)); 131 132 jQuery("#community_nb_photos").slider({ 133 range: "min", 134 min: 0, 135 max: nbPhotosValues.length - 1, 136 value: nbPhotos_init, 137 slide: function( event, ui ) { 138 jQuery("#community_nb_photos_info").html(getNbPhotosInfoFromIdx(ui.value)); 139 }, 140 stop: function( event, ui ) { 141 jQuery("input[name=nb_photos]").val(nbPhotosValues[ui.value]); 142 } 143 }); 144 145 var storageValues = [10,50,100,200,500,1000,5000,-1]; 146 147 function getStorageInfoFromIdx(idx) { 148 if (idx == storageValues.length - 1) { 149 return "{/literal}{'no limit'|@translate}{literal}"; 150 } 151 152 return sprintf( 153 "{/literal}{'up to %dMB (for each user)'|@translate}{literal}", 154 storageValues[idx] 155 ); 156 } 157 158 /* init storage info span */ 159 var storage_init = getSliderKeyFromValue(jQuery('input[name=storage]').val(), storageValues); 160 161 jQuery("#community_storage_info").html(getStorageInfoFromIdx(storage_init)); 162 163 jQuery("#community_storage").slider({ 164 range: "min", 165 min: 0, 166 max: storageValues.length - 1, 167 value: storage_init, 168 slide: function( event, ui ) { 169 jQuery("#community_storage_info").html(getStorageInfoFromIdx(ui.value)); 170 }, 171 stop: function( event, ui ) { 172 jQuery("input[name=storage]").val(storageValues[ui.value]); 173 } 174 }); 175 54 176 }); 55 177 {/literal}{/footer_script} … … 104 226 </p> 105 227 228 <p style="margin-bottom:0"> 229 <strong>{'How many photos?'|@translate}</strong> 230 </p> 231 <div id="community_nb_photos"></div> 232 <span id="community_nb_photos_info">{'no limit'|@translate}</span> 233 <input type="hidden" name="nb_photos" value="{$nb_photos}"> 234 235 <p style="margin-top:1.5em;margin-bottom:0;"> 236 <strong>{'How much disk space?'|@translate}</strong> 237 </p> 238 <div id="community_storage"></div> 239 <span id="community_storage_info">{'no limit'|@translate}</span> 240 <input type="hidden" name="storage" value="{$storage}"> 241 106 242 {if isset($edit)} 107 243 <input type="hidden" name="edit" value="{$edit}"> 108 244 {/if} 109 245 110 <p style="margin :0;">246 <p style="margin-top:1.5em;"> 111 247 <input class="submit" type="submit" name="submit_add" value="{if isset($edit)}{'Submit'|@translate}{else}{'Add'|@translate}{/if}"/> 112 248 <a href="{$F_ADD_ACTION}">{'Cancel'|@translate}</a> … … 128 264 <td>{$permission.WHERE}</td> 129 265 <td> 130 <span title="{$permission.TRUST_TOOLTIP}">{$permission.TRUST}</span> 131 {if $permission.RECURSIVE} 132 , <span title="{$permission.RECURSIVE_TOOLTIP}">{'sub-albums'|@translate}</span> 133 266 <span title="{$permission.TRUST_TOOLTIP}">{$permission.TRUST}</span>{if $permission.RECURSIVE}, 267 <span title="{$permission.RECURSIVE_TOOLTIP}">{'sub-albums'|@translate}</span>{/if}{if $permission.NB_PHOTOS}, 268 <span title="{$permission.NB_PHOTOS_TOOLTIP}">{'%d photos'|@translate|sprintf:$permission.NB_PHOTOS}</span>{/if}{if $permission.STORAGE}, 269 <span title="{$permission.STORAGE_TOOLTIP}">{$permission.STORAGE}MB</span>{/if} 134 270 {if $permission.CREATE_SUBCATEGORIES} 135 271 , {'sub-albums creation'|@translate}
Note: See TracChangeset
for help on using the changeset viewer.