source: branches/2.5/admin/themes/default/template/photos_add_direct.tpl @ 24975

Last change on this file since 24975 was 24975, checked in by plg, 11 years ago

bug 2975 fixed: remove useless "," at the end of arrays, because it breaks Internet Explorer 7 :-/

File size: 10.9 KB
RevLine 
[9586]1{if $upload_mode eq 'multiple'}
[7995]2{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' }
[11975]3{combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v3.0.0.min.js' }
[12005]4{combine_script id='jquery.ui.progressbar' load='footer'}
[9586]5{combine_css path="admin/themes/default/uploadify.jGrowl.css"}
6{combine_css path="admin/include/uploadify/uploadify.css"}
[5736]7{/if}
[5848]8
[11962]9{include file='include/colorbox.inc.tpl'}
[13063]10{include file='include/add_album.inc.tpl'}
[11962]11
[7995]12{footer_script}{literal}
[5736]13jQuery(document).ready(function(){
14  function checkUploadStart() {
15    var nbErrors = 0;
[9586]16    jQuery("#formErrors").hide();
17    jQuery("#formErrors li").hide();
[5089]18
[12106]19    if (jQuery("#albumSelect option:selected").length == 0) {
20      jQuery("#formErrors #noAlbum").show();
21      nbErrors++;
22    }
23
[5736]24    var nbFiles = 0;
[9586]25    if (jQuery("#uploadBoxes").size() == 1) {
26      jQuery("input[name^=image_upload]").each(function() {
27        if (jQuery(this).val() != "") {
[5736]28          nbFiles++;
29        }
30      });
31    }
32    else {
[9586]33      nbFiles = jQuery(".uploadifyQueueItem").size();
[5736]34    }
35
36    if (nbFiles == 0) {
[9586]37      jQuery("#formErrors #noPhoto").show();
[5736]38      nbErrors++;
39    }
40
41    if (nbErrors != 0) {
[9586]42      jQuery("#formErrors").show();
[5736]43      return false;
44    }
45    else {
46      return true;
47    }
48
49  }
50
[6625]51  function humanReadableFileSize(bytes) {
52    var byteSize = Math.round(bytes / 1024 * 100) * .01;
53    var suffix = 'KB';
54
55    if (byteSize > 1000) {
56      byteSize = Math.round(byteSize *.001 * 100) * .01;
57      suffix = 'MB';
58    }
59
60    var sizeParts = byteSize.toString().split('.');
61    if (sizeParts.length > 1) {
62      byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2);
63    }
64    else {
65      byteSize = sizeParts[0];
66    }
67
68    return byteSize+suffix;
69  }
70
[9586]71  jQuery("#hideErrors").click(function() {
72    jQuery("#formErrors").hide();
[5736]73    return false;
74  });
75
[11966]76  jQuery("#uploadWarningsSummary a.showInfo").click(function() {
77    jQuery("#uploadWarningsSummary").hide();
78    jQuery("#uploadWarnings").show();
[19828]79    return false;
[11966]80  });
81
[11967]82  jQuery("#showPermissions").click(function() {
83    jQuery(this).parent(".showFieldset").hide();
84    jQuery("#permissions").show();
[19828]85    return false;
[11967]86  });
87
[5089]88{/literal}
89{if $upload_mode eq 'html'}
90{literal}
91  function addUploadBox() {
[5931]92    var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]"></p>';
[9586]93    jQuery(uploadBox).appendTo("#uploadBoxes");
[5089]94  }
95
96  addUploadBox();
97
[9586]98  jQuery("#addUploadBox A").click(function () {
[5089]99    addUploadBox();
100  });
[5736]101
[9586]102  jQuery("#uploadForm").submit(function() {
[5736]103    return checkUploadStart();
104  });
[5089]105{/literal}
106{elseif $upload_mode eq 'multiple'}
107
108var uploadify_path = '{$uploadify_path}';
109var upload_id = '{$upload_id}';
110var session_id = '{$session_id}';
111var pwg_token = '{$pwg_token}';
[11975]112var buttonText = "{'Select files'|@translate}";
113var sizeLimit = Math.round({$upload_max_filesize} / 1024); /* in KBytes */
[5089]114
115{literal}
116  jQuery("#uploadify").uploadify({
[11975]117    'uploader'       : uploadify_path + '/uploadify.php',
118    'langFile'       : uploadify_path + '/uploadifyLang_en.js',
119    'swf'            : uploadify_path + '/uploadify.swf',
[13018]120    'checkExisting'  : false,
[11975]121
122    buttonCursor     : 'pointer',
123    'buttonText'     : buttonText,
124    'width'          : 300,
125    'cancelImage'    : uploadify_path + '/cancel.png',
[5089]126    'queueID'        : 'fileQueue',
127    'auto'           : false,
128    'multi'          : true,
[11975]129    'fileTypeDesc'   : 'Photo files',
130    'fileTypeExts'   : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF',
131    'fileSizeLimit'  : sizeLimit,
132    'progressData'   : 'percentage',
133    requeueErrors   : false,
[11966]134    'onSelect'       : function(event,ID,fileObj) {
135      jQuery("#fileQueue").show();
136    },
[11975]137    'onQueueComplete'  : function(stats) {
138      jQuery("input[name=submit_upload]").click();
139    },
140    onUploadError: function (file,errorCode,errorMsg,errorString,swfuploadifyQueue) {
141      /* uploadify calls the onUploadError trigger when the user cancels a file! */
142      /* There no error so we skip it to avoid panic.                            */
143      if ("Cancelled" == errorString) {
[5089]144        return false;
145      }
[6625]146
[11975]147      var msg = file.name+', '+errorString;
[5848]148
[11975]149      /* Let's put the error message in the form to display once the form is     */
150      /* performed, it makes support easier when user can copy/paste the error   */
151      /* thrown.                                                                 */
152      jQuery("#uploadForm").append('<input type="hidden" name="onUploadError[]" value="'+msg+'">');
153
[9586]154      jQuery.jGrowl(
[11975]155        '<p></p>onUploadError '+msg,
[5848]156        {
157          theme:  'error',
158          header: 'ERROR',
[11975]159          life:   4000,
160          sticky: false
[5848]161        }
162      );
163
164      return false;
165    },
[11975]166    onUploadSuccess: function (file,data,response) {
167      var data = jQuery.parseJSON(data);
[11962]168      jQuery("#uploadedPhotos").parent("fieldset").show();
169
[11975]170      /* Let's display the thumbnail of the uploaded photo, no need to wait the  */
171      /* end of the queue                                                        */
172      jQuery("#uploadedPhotos").prepend('<img src="'+data.thumbnail_url+'" class="thumbnail"> ');
[12005]173    },
174    onUploadComplete: function(file,swfuploadifyQueue) {
175      var max = parseInt(jQuery("#progressMax").text());
176      var next = parseInt(jQuery("#progressCurrent").text())+1;
177      var addToProgressBar = 2;
178      if (next <= max) {
179        jQuery("#progressCurrent").text(next);
180      }
181      else {
182        addToProgressBar = 1;
183      }
184
185      jQuery("#progressbar").progressbar({
186        value: jQuery("#progressbar").progressbar("option", "value") + addToProgressBar
187      });
[5089]188    }
189  });
[5736]190
[9586]191  jQuery("input[type=button]").click(function() {
[5736]192    if (!checkUploadStart()) {
193      return false;
194    }
195
[11962]196    jQuery("#uploadify").uploadifySettings(
[11975]197      'postData',
[11962]198      {
199        'category_id' : jQuery("select[name=category] option:selected").val(),
200        'level' : jQuery("select[name=level] option:selected").val(),
[11975]201        'upload_id' : upload_id,
202        'session_id' : session_id,
[24975]203        'pwg_token' : pwg_token
[11962]204      }
205    );
206
[12005]207    nb_files = jQuery(".uploadifyQueueItem").size();
208    jQuery("#progressMax").text(nb_files);
209    jQuery("#progressbar").progressbar({max: nb_files*2, value:1});
210    jQuery("#progressCurrent").text(1);
211
212    jQuery("#uploadProgress").show();
213
[9586]214    jQuery("#uploadify").uploadifyUpload();
[5736]215  });
216
217{/literal}
218{/if}
[5089]219});
[7995]220{/footer_script}
[5089]221
[5098]222<div class="titrePage">
[13451]223  <h2>{'Upload Photos'|@translate} {$TABSHEET_TITLE}</h2>
[5089]224</div>
225
[5174]226<div id="photosAddContent">
227
[5089]228{if count($setup_errors) > 0}
229<div class="errors">
230  <ul>
231  {foreach from=$setup_errors item=error}
232    <li>{$error}</li>
233  {/foreach}
234  </ul>
235</div>
236{else}
237
[6622]238  {if count($setup_warnings) > 0}
239<div class="warnings">
240  <ul>
241    {foreach from=$setup_warnings item=warning}
242    <li>{$warning}</li>
243    {/foreach}
244  </ul>
[6629]245  <div class="hideButton" style="text-align:center"><a href="{$hide_warnings_link}">{'Hide'|@translate}</a></div>
[6622]246</div>
247  {/if}
248
249
[5089]250{if !empty($thumbnails)}
251<fieldset>
252  <legend>{'Uploaded Photos'|@translate}</legend>
253  <div>
254  {foreach from=$thumbnails item=thumbnail}
[5493]255    <a href="{$thumbnail.link}" class="externalLink">
[5089]256      <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail">
257    </a>
258  {/foreach}
259  </div>
260  <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p>
261</fieldset>
[11966]262<p style="margin:10px"><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p>
[5742]263{else}
[5089]264
[5736]265<div id="formErrors" class="errors" style="display:none">
266  <ul>
[12106]267    <li id="noAlbum">{'Select an album'|@translate}</li>
[8682]268    <li id="noPhoto">{'Select at least one photo'|@translate}</li>
[5736]269  </ul>
270  <div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|@translate}</a></div>
271</div>
[5089]272
[11962]273
[6625]274<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties">
[11962]275{if $upload_mode eq 'multiple'}
276    <input name="upload_id" value="{$upload_id}" type="hidden">
277{/if}
278
[5174]279    <fieldset>
[6993]280      <legend>{'Drop into album'|@translate}</legend>
[5931]281
[12106]282      <span id="albumSelection"{if count($category_options) == 0} style="display:none"{/if}>
[11962]283      <select id="albumSelect" name="category">
284        {html_options options=$category_options selected=$category_options_selected}
285      </select>
[12106]286      <br>{'... or '|@translate}</span><a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a>
[11962]287     
[5174]288    </fieldset>
[5089]289
[5174]290    <fieldset>
291      <legend>{'Select files'|@translate}</legend>
[5089]292
[11966]293    <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>
[5089]294
[11966]295    <p id="uploadWarnings">
296{'Maximum file size: %sB.'|@translate|@sprintf:$upload_max_filesize_shorthand}
297{'Allowed file types: %s.'|@translate|@sprintf:$upload_file_types}
298  {if isset($max_upload_resolution)}
299{'Approximate maximum resolution: %dM pixels (that\'s %dx%d pixels).'|@translate|@sprintf:$max_upload_resolution:$max_upload_width:$max_upload_height}
300  {/if}
301    </p>
[5089]302
[11966]303{if $upload_mode eq 'html'}
[5089]304      <div id="uploadBoxes"></div>
305      <div id="addUploadBox">
306        <a href="javascript:">{'+ Add an upload box'|@translate}</a>
307      </div>
[11966]308
309    <p id="uploadModeInfos">{'You are using the Browser uploader. Try the <a href="%s">Flash uploader</a> instead.'|@translate|@sprintf:$switch_url}</p>
[5089]310
311{elseif $upload_mode eq 'multiple'}
[11975]312    <div id="uploadify">You've got a problem with your JavaScript</div>
[5089]313
[11966]314    <div id="fileQueue" style="display:none"></div>
[5089]315
[11966]316    <p id="uploadModeInfos">{'You are using the Flash uploader. Problems? Try the <a href="%s">Browser uploader</a> instead.'|@translate|@sprintf:$switch_url}</p>
[5089]317
[11967]318{/if}
[5174]319    </fieldset>
[11967]320
321    <p class="showFieldset"><a id="showPermissions" href="#">{'Manage Permissions'|@translate}</a></p>
322
323    <fieldset id="permissions" style="display:none">
324      <legend>{'Who can see these photos?'|@translate}</legend>
325
326      <select name="level" size="1">
327        {html_options options=$level_options selected=$level_options_selected}
328      </select>
329    </fieldset>
330
331{if $upload_mode eq 'html'}
[5089]332    <p>
[11967]333      <input class="submit" type="submit" name="submit_upload" value="{'Start Upload'|@translate}">
334    </p>
335{elseif $upload_mode eq 'multiple'}
[12005]336    <p style="margin-bottom:1em">
[11962]337      <input class="submit" type="button" value="{'Start Upload'|@translate}">
[5931]338      <input type="submit" name="submit_upload" style="display:none">
[5089]339    </p>
340{/if}
341</form>
[11962]342
[12005]343<div id="uploadProgress" style="display:none">
344{'Photo %s of %s'|@translate|@sprintf:'<span id="progressCurrent">1</span>':'<span id="progressMax">10</span>'}
345<br>
346<div id="progressbar"></div>
347</div>
348
[11962]349<fieldset style="display:none">
350  <legend>{'Uploaded Photos'|@translate}</legend>
351  <div id="uploadedPhotos"></div>
352</fieldset>
353
[5742]354{/if} {* empty($thumbnails) *}
355{/if} {* $setup_errors *}
[5174]356
[5931]357</div> <!-- photosAddContent -->
Note: See TracBrowser for help on using the repository browser.