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

Last change on this file since 5742 was 5742, checked in by plg, 14 years ago

feature 1590: hide the upload form when displaying upload results.

File size: 6.6 KB
Line 
1{known_script id="jquery" src=$ROOT_URL|@cat:"themes/default/js/jquery.packed.js"}
2
3{if $upload_mode eq 'multiple'}
4<script type="text/javascript" src="{$uploadify_path}/swfobject.js"></script>
5<script type="text/javascript" src="{$uploadify_path}/jquery.uploadify.v2.1.0.min.js"></script>
6{/if}
7
8{literal}
9<script type="text/javascript">
10jQuery(document).ready(function(){
11  function checkUploadStart() {
12    var nbErrors = 0;
13    $("#formErrors li").hide();
14
15    if ($("input[name=category_type]:checked").val() == "new" && $("input[name=category_name]").val() == "") {
16      $("#formErrors #emptyCategoryName").show();
17      nbErrors++;
18    }
19
20    var nbFiles = 0;
21    if ($("#uploadBoxes").size() == 1) {
22      $("input[name^=image_upload]").each(function() {
23        if ($(this).val() != "") {
24          nbFiles++;
25        }
26      });
27    }
28    else {
29      nbFiles = $(".uploadifyQueueItem").size();
30    }
31
32    if (nbFiles == 0) {
33      $("#formErrors #noPhoto").show();
34      nbErrors++;
35    }
36
37    if (nbErrors != 0) {
38      $("#formErrors").show();
39      return false;
40    }
41    else {
42      return true;
43    }
44
45  }
46
47  $("input[name=category_type]").click(function () {
48    $("[id^=category_type_]").hide();
49    $("#category_type_"+$(this).attr("value")).show();
50  });
51
52  $("#hideErrors").click(function() {
53    $("#formErrors").hide();
54    return false;
55  });
56
57{/literal}
58{if $upload_mode eq 'html'}
59{literal}
60  function addUploadBox() {
61    var uploadBox = '<p class="file"><input type="file" size="60" name="image_upload[]" /></p>';
62    $(uploadBox).appendTo("#uploadBoxes");
63  }
64
65  addUploadBox();
66
67  $("#addUploadBox A").click(function () {
68    addUploadBox();
69  });
70
71  $("#uploadForm").submit(function() {
72    return checkUploadStart();
73  });
74{/literal}
75{elseif $upload_mode eq 'multiple'}
76
77var uploadify_path = '{$uploadify_path}';
78var upload_id = '{$upload_id}';
79var session_id = '{$session_id}';
80var pwg_token = '{$pwg_token}';
81var buttonText = 'Browse';
82
83{literal}
84  jQuery("#uploadify").uploadify({
85    'uploader'       : uploadify_path + '/uploadify.swf',
86    'script'         : uploadify_path + '/uploadify.php',
87    'scriptData'     : {
88      'upload_id' : upload_id,
89      'session_id' : session_id,
90      'pwg_token' : pwg_token,
91    },
92    'cancelImg'      : uploadify_path + '/cancel.png',
93    'queueID'        : 'fileQueue',
94    'auto'           : false,
95    'displayData'    : 'speed',
96    'buttonText'     : buttonText,
97    'multi'          : true,
98    'fileDesc'       : 'Photo files (*.jpg,*.jpeg)',
99    'fileExt'        : '*.jpg;*.JPG;*.jpeg;*.JPEG',
100    'onAllComplete'  : function(event, data) {
101      if (data.errors) {
102        return false;
103      }
104      else {
105        $("input[name=submit_upload]").click();
106      }
107    }
108  });
109
110  $("input[type=button]").click(function() {
111    if (!checkUploadStart()) {
112      return false;
113    }
114
115    $("#uploadify").uploadifyUpload();
116  });
117
118{/literal}
119{/if}
120});
121</script>
122
123<div class="titrePage">
124  <h2>{'Upload Photos'|@translate}</h2>
125</div>
126
127<div id="photosAddContent">
128
129{if count($setup_errors) > 0}
130<div class="errors">
131  <ul>
132  {foreach from=$setup_errors item=error}
133    <li>{$error}</li>
134  {/foreach}
135  </ul>
136</div>
137{else}
138
139{if !empty($thumbnails)}
140<fieldset>
141  <legend>{'Uploaded Photos'|@translate}</legend>
142  <div>
143  {foreach from=$thumbnails item=thumbnail}
144    <a href="{$thumbnail.link}" class="externalLink">
145      <img src="{$thumbnail.src}" alt="{$thumbnail.file}" title="{$thumbnail.title}" class="thumbnail">
146    </a>
147  {/foreach}
148  </div>
149  <p id="batchLink"><a href="{$batch_link}">{$batch_label}</a></p>
150</fieldset>
151<p><a href="">{'Add another set of photos'|@translate}</a></p>
152{else}
153
154<div id="formErrors" class="errors" style="display:none">
155  <ul>
156    <li id="emptyCategoryName">{'The name of a category should not be empty'|@translate}</li>
157    <li id="noPhoto">{'Select at least one picture'|@translate}</li>
158  </ul>
159  <div class="hideButton" style="text-align:center"><a href="#" id="hideErrors">{'Hide'|@translate}</a></div>
160</div>
161
162<form id="uploadForm" enctype="multipart/form-data" method="post" action="{$F_ACTION}" class="properties">
163{if $upload_mode eq 'multiple'}
164<input name="upload_id" value="{$upload_id}" type="hidden">
165{/if}
166
167    <fieldset>
168      <legend>{'Drop into category'|@translate}</legend>
169     
170      <label><input type="radio" name="category_type" value="existing"> {'existing category'|@translate}</label>
171      <label><input type="radio" name="category_type" value="new" checked="checked"> {'create a new category'|@translate}</label>
172
173      <div id="category_type_existing" style="display:none" class="category_selection">
174        <select class="categoryDropDown" name="category">
175          {html_options options=$category_options}
176        </select>
177      </div>
178
179      <div id="category_type_new" class="category_selection">
180        <table>
181          <tr>
182            <td>{'Parent category'|@translate}</td>
183            <td>
184              <select class="categoryDropDown" name="category_parent">
185                <option value="0">------------</option>
186                {html_options options=$category_options}
187              </select>
188            </td>
189          </tr>
190          <tr>
191            <td>{'Category name'|@translate}</td>
192            <td>
193              <input type="text" name="category_name" value="{$F_CATEGORY_NAME}" style="width:400px">
194            </td>
195          </tr>
196        </table>
197      </div>
198    </fieldset>
199
200    <fieldset>
201      <legend>{'Who can see these photos?'|@translate}</legend>
202
203      <select name="level" size="1">
204        {html_options options=$level_options selected=$level_options_selected}
205      </select>
206    </fieldset>
207
208    <fieldset>
209      <legend>{'Select files'|@translate}</legend>
210
211{if $upload_mode eq 'html'}
212    <p><a href="{$switch_url}">{'... or switch to the multiple files form'|@translate}</a></p>
213
214      <p>{'JPEG files or ZIP archives with JPEG files inside please.'|@translate}</p>
215
216      <div id="uploadBoxes"></div>
217      <div id="addUploadBox">
218        <a href="javascript:">{'+ Add an upload box'|@translate}</a>
219      </div>
220   
221    </fieldset>
222
223    <p>
224      <input class="submit" type="submit" name="submit_upload" value="{'Upload'|@translate}" {$TAG_INPUT_ENABLED}/>
225    </p>
226{elseif $upload_mode eq 'multiple'}
227    </table>
228
229    <p>
230      <input type="file" name="uploadify" id="uploadify" />
231    </p>
232
233    <p><a href="{$switch_url}">{'... or switch to the old style form'|@translate}</a></p>
234
235    <div id="fileQueue"></div>
236
237    </fieldset>
238    <p>
239      <input class="submit" type="button" value="{'Upload'|@translate}"/>
240      <input type="submit" name="submit_upload" style="display:none"/>
241    </p>
242{/if}
243</form>
244{/if} {* empty($thumbnails) *}
245{/if} {* $setup_errors *}
246
247</div> <!-- photosAddContent -->
Note: See TracBrowser for help on using the repository browser.