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