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

Last change on this file since 5931 was 5931, checked in by nikrou, 14 years ago

Fix some errors in generated html

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