source: trunk/admin/themes/default/template/photos_add_direct.tpl @ 8128

Last change on this file since 8128 was 8128, checked in by patdenice, 13 years ago

feature 2060: Remove {$TAG_INPUT_ENABLED} from tpl files.

File size: 9.8 KB
Line 
1{combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js' }
2
3{if $upload_mode eq 'multiple'}
4<script type="text/javascript" src="{$uploadify_path}/swfobject.js"></script>
5{combine_script id='jquery.uploadify' load='footer' require='jquery' path='admin/include/uploadify/jquery.uploadify.v2.1.0.min.js' }
6{/if}
7{html_head}
8<link rel="stylesheet" type="text/css" href="{$ROOT_URL}admin/themes/default/uploadify.jGrowl.css">
9{/html_head}
10
11{footer_script}{literal}
12jQuery(document).ready(function(){
13  function checkUploadStart() {
14    var nbErrors = 0;
15    $("#formErrors").hide();
16    $("#formErrors li").hide();
17
18    if ($("input[name=category_type]:checked").val() == "new" && $("input[name=category_name]").val() == "") {
19      $("#formErrors #emptyCategoryName").show();
20      nbErrors++;
21    }
22
23    var nbFiles = 0;
24    if ($("#uploadBoxes").size() == 1) {
25      $("input[name^=image_upload]").each(function() {
26        if ($(this).val() != "") {
27          nbFiles++;
28        }
29      });
30    }
31    else {
32      nbFiles = $(".uploadifyQueueItem").size();
33    }
34
35    if (nbFiles == 0) {
36      $("#formErrors #noPhoto").show();
37      nbErrors++;
38    }
39
40    if (nbErrors != 0) {
41      $("#formErrors").show();
42      return false;
43    }
44    else {
45      return true;
46    }
47
48  }
49
50  function humanReadableFileSize(bytes) {
51    var byteSize = Math.round(bytes / 1024 * 100) * .01;
52    var suffix = 'KB';
53
54    if (byteSize > 1000) {
55      byteSize = Math.round(byteSize *.001 * 100) * .01;
56      suffix = 'MB';
57    }
58
59    var sizeParts = byteSize.toString().split('.');
60    if (sizeParts.length > 1) {
61      byteSize = sizeParts[0] + '.' + sizeParts[1].substr(0,2);
62    }
63    else {
64      byteSize = sizeParts[0];
65    }
66
67    return byteSize+suffix;
68  }
69
70  if ($("select[name=category] option").length == 0) {
71    $('input[name=category_type][value=existing]').attr('disabled', true);
72    $('input[name=category_type]').attr('checked', false);
73    $('input[name=category_type][value=new]').attr('checked', true);
74  }
75
76  $("input[name=category_type]").click(function () {
77    $("[id^=category_type_]").hide();
78    $("#category_type_"+$(this).attr("value")).show();
79  });
80
81  $("#hideErrors").click(function() {
82    $("#formErrors").hide();
83    return false;
84  });
85
86{/literal}
87{if $upload_mode eq 'html'}
88{literal}
89  function addUploadBox() {
90    var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]"></p>';
91    $(uploadBox).appendTo("#uploadBoxes");
92  }
93
94  addUploadBox();
95
96  $("#addUploadBox A").click(function () {
97    addUploadBox();
98  });
99
100  $("#uploadForm").submit(function() {
101    return checkUploadStart();
102  });
103{/literal}
104{elseif $upload_mode eq 'multiple'}
105
106var uploadify_path = '{$uploadify_path}';
107var upload_id = '{$upload_id}';
108var session_id = '{$session_id}';
109var pwg_token = '{$pwg_token}';
110var buttonText = 'Browse';
111var sizeLimit = {$upload_max_filesize};
112
113{literal}
114  jQuery("#uploadify").uploadify({
115    'uploader'       : uploadify_path + '/uploadify.swf',
116    'script'         : uploadify_path + '/uploadify.php',
117    'scriptData'     : {
118      'upload_id' : upload_id,
119      'session_id' : session_id,
120      'pwg_token' : pwg_token,
121    },
122    'cancelImg'      : uploadify_path + '/cancel.png',
123    'queueID'        : 'fileQueue',
124    'auto'           : false,
125    'displayData'    : 'speed',
126    'buttonText'     : buttonText,
127    'multi'          : true,
128    'fileDesc'       : 'Photo files (*.jpg,*.jpeg,*.png)',
129    'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG',
130    'sizeLimit'      : sizeLimit,
131    'onAllComplete'  : function(event, data) {
132      if (data.errors) {
133        return false;
134      }
135      else {
136        $("input[name=submit_upload]").click();
137      }
138    },
139    onError: function (event, queueID ,fileObj, errorObj) {
140      var msg;
141
142      if (errorObj.type === "HTTP") {
143        if (errorObj.info === 404) {
144          alert('Could not find upload script.');
145          msg = 'Could not find upload script.';
146        }
147        else {
148          msg = errorObj.type+": "+errorObj.info;
149        }
150      }
151      else if (errorObj.type ==="File Size") {
152        msg = "File too big";
153        msg = msg + '<br>'+fileObj.name+': '+humanReadableFileSize(fileObj.size);
154        msg = msg + '<br>Limit: '+humanReadableFileSize(sizeLimit);
155      }
156      else {
157        msg = errorObj.type+": "+errorObj.info;
158      }
159
160      $.jGrowl(
161        '<p></p>'+msg,
162        {
163          theme:  'error',
164          header: 'ERROR',
165          sticky: true
166        }
167      );
168
169      $("#fileUploadgrowl" + queueID).fadeOut(
170        250,
171        function() {
172          $("#fileUploadgrowl" + queueID).remove()
173        }
174      );
175      return false;
176    },
177    onCancel: function (a, b, c, d) {
178      var msg = "Cancelled uploading: "+c.name;
179      $.jGrowl(
180        '<p></p>'+msg,
181        {
182          theme:  'warning',
183          header: 'Cancelled Upload',
184          life:   4000,
185          sticky: false
186        }
187      );
188    },
189    onClearQueue: function (a, b) {
190      var msg = "Cleared "+b.fileCount+" files from queue";
191      $.jGrowl(
192        '<p></p>'+msg,
193        {
194          theme:  'warning',
195          header: 'Cleared Queue',
196          life:   4000,
197          sticky: false
198        }
199      );
200    },
201    onComplete: function (a, b ,c, d, e) {
202      var size = Math.round(c.size/1024);
203      $.jGrowl(
204        '<p></p>'+c.name+' - '+size+'KB',
205        {
206          theme:  'success',
207          header: 'Upload Complete',
208          life:   4000,
209          sticky: false
210        }
211      );
212    }
213  });
214
215  $("input[type=button]").click(function() {
216    if (!checkUploadStart()) {
217      return false;
218    }
219
220    $("#uploadify").uploadifyUpload();
221  });
222
223{/literal}
224{/if}
225});
226{/footer_script}
227
228<div class="titrePage">
229  <h2>{'Upload Photos'|@translate}</h2>
230</div>
231
232<div id="photosAddContent">
233
234{if count($setup_errors) > 0}
235<div class="errors">
236  <ul>
237  {foreach from=$setup_errors item=error}
238    <li>{$error}</li>
239  {/foreach}
240  </ul>
241</div>
242{else}
243
244  {if count($setup_warnings) > 0}
245<div class="warnings">
246  <ul>
247    {foreach from=$setup_warnings item=warning}
248    <li>{$warning}</li>
249    {/foreach}
250  </ul>
251  <div class="hideButton" style="text-align:center"><a href="{$hide_warnings_link}">{'Hide'|@translate}</a></div>
252</div>
253  {/if}
254
255
256{if !empty($thumbnails)}
257<fieldset>
258  <legend>{'Uploaded Photos'|@translate}</legend>
259  <div>
260  {foreach from=$thumbnails item=thumbnail}
261    <a href="{$thumbnail.link}" class="externalLink">
262      <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail">
263    </a>
264  {/foreach}
265  </div>
266  <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p>
267</fieldset>
268<p><a href="{$another_upload_link}">{'Add another set of photos'|@translate}</a></p>
269{else}
270
271<div id="formErrors" class="errors" style="display:none">
272  <ul>
273    <li id="emptyCategoryName">{'The name of an album must not be empty'|@translate}</li>
274    <li id="noPhoto">{'Select at least one picture'|@translate}</li>
275  </ul>
276  <div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|@translate}</a></div>
277</div>
278
279<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$form_action}" class="properties">
280    <fieldset>
281      <legend>{'Drop into album'|@translate}</legend>
282      {if $upload_mode eq 'multiple'}
283      <input name="upload_id" value="{$upload_id}" type="hidden">
284      {/if}
285
286      <label><input type="radio" name="category_type" value="existing"> {'existing album'|@translate}</label>
287      <label><input type="radio" name="category_type" value="new" checked="checked"> {'create a new album'|@translate}</label>
288
289      <div id="category_type_existing" style="display:none" class="category_selection">
290        <select class="categoryDropDown" name="category">
291          {html_options options=$category_options selected=$category_options_selected}
292        </select>
293      </div>
294
295      <div id="category_type_new" class="category_selection">
296        <table>
297          <tr>
298            <td>{'Parent album'|@translate}</td>
299            <td>
300              <select class="categoryDropDown" name="category_parent">
301                <option value="0">------------</option>
302                {html_options options=$category_parent_options selected=$category_parent_options_selected}
303              </select>
304            </td>
305          </tr>
306          <tr>
307            <td>{'Album name'|@translate}</td>
308            <td>
309              <input type="text" name="category_name" value="{$F_CATEGORY_NAME}" style="width:400px">
310            </td>
311          </tr>
312        </table>
313      </div>
314    </fieldset>
315
316    <fieldset>
317      <legend>{'Who can see these photos?'|@translate}</legend>
318
319      <select name="level" size="1">
320        {html_options options=$level_options selected=$level_options_selected}
321      </select>
322    </fieldset>
323
324    <fieldset>
325      <legend>{'Select files'|@translate}</legend>
326
327{if $upload_mode eq 'html'}
328    <p><a href="{$switch_url}">{'... or switch to the multiple files form'|@translate}</a></p>
329
330      <p>{'JPEG files or ZIP archives with JPEG files inside please.'|@translate}</p>
331
332      <div id="uploadBoxes"></div>
333      <div id="addUploadBox">
334        <a href="javascript:">{'+ Add an upload box'|@translate}</a>
335      </div>
336   
337    </fieldset>
338
339    <p>
340      <input class="submit" type="submit" name="submit_upload" value="{'Upload'|@translate}">
341    </p>
342{elseif $upload_mode eq 'multiple'}
343    <p>
344      <input type="file" name="uploadify" id="uploadify">
345    </p>
346
347    <p><a href="{$switch_url}">{'... or switch to the old style form'|@translate}</a></p>
348
349    <div id="fileQueue"></div>
350
351    </fieldset>
352    <p>
353      <input class="submit" type="button" value="{'Upload'|@translate}">
354      <input type="submit" name="submit_upload" style="display:none">
355    </p>
356{/if}
357</form>
358{/if} {* empty($thumbnails) *}
359{/if} {* $setup_errors *}
360
361</div> <!-- photosAddContent -->
Note: See TracBrowser for help on using the repository browser.