1 | {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} |
---|
2 | (function($){ |
---|
3 | /* global vars */ |
---|
4 | var nb_thumbs_set = {$nb_thumbs_set}; |
---|
5 | var all_elements = [{if !empty($all_elements)}{','|@implode:$all_elements}{/if}]; |
---|
6 | var import_done = 0; |
---|
7 | var import_selected = 0; |
---|
8 | var queuedManager = $.manageAjax.create('queued', {ldelim} |
---|
9 | queue: true, |
---|
10 | maxRequests: 1 |
---|
11 | }); |
---|
12 | |
---|
13 | /* Shift-click: select all photos between the click and the shift+click */ |
---|
14 | var last_clicked=0; |
---|
15 | var last_clickedstatus=true; |
---|
16 | $.fn.enableShiftClick = function() { |
---|
17 | var inputs = []; |
---|
18 | var count=0; |
---|
19 | var This=$(this); |
---|
20 | this.find('input[type=checkbox]').each(function() { |
---|
21 | var pos=count; |
---|
22 | inputs[count++]=this; |
---|
23 | $(this).bind("shclick", function (dummy,event) { |
---|
24 | if (event.shiftKey) { |
---|
25 | var first = last_clicked; |
---|
26 | var last = pos; |
---|
27 | if (first > last) { |
---|
28 | first=pos; |
---|
29 | last=last_clicked; |
---|
30 | } |
---|
31 | |
---|
32 | for (var i=first; i<=last;i++) { |
---|
33 | input = $(inputs[i]); |
---|
34 | $(input).attr('checked', last_clickedstatus); |
---|
35 | if (last_clickedstatus) { |
---|
36 | $(input).siblings("span.wrap2").addClass("thumbSelected"); |
---|
37 | } |
---|
38 | else { |
---|
39 | $(input).siblings("span.wrap2").removeClass("thumbSelected"); |
---|
40 | } |
---|
41 | } |
---|
42 | } |
---|
43 | else { |
---|
44 | last_clicked = pos; |
---|
45 | last_clickedstatus = this.checked; |
---|
46 | } |
---|
47 | return true; |
---|
48 | }); |
---|
49 | $(this).click(function(event) { $(this).triggerHandler("shclick",event); }); |
---|
50 | }); |
---|
51 | } |
---|
52 | |
---|
53 | /* update displaying */ |
---|
54 | function checkPermitAction() { |
---|
55 | var nbSelected = 0; |
---|
56 | if ($("input[name=setSelected]").is(':checked')) { |
---|
57 | nbSelected = nb_thumbs_set; |
---|
58 | } |
---|
59 | else { |
---|
60 | $(".thumbnails input[type=checkbox]").each(function() { |
---|
61 | if ($(this).is(':checked')) nbSelected++; |
---|
62 | }); |
---|
63 | } |
---|
64 | |
---|
65 | if (nbSelected == 0) { |
---|
66 | $("#beginImport").hide(); |
---|
67 | } |
---|
68 | else { |
---|
69 | $("#beginImport").show(); |
---|
70 | } |
---|
71 | |
---|
72 | $("#applyOnDetails").text( |
---|
73 | sprintf( |
---|
74 | '{'on the %d selected photos'|translate|escape:javascript}', |
---|
75 | nbSelected |
---|
76 | ) |
---|
77 | ); |
---|
78 | |
---|
79 | // display the number of currently selected photos in the "Selection" fieldset |
---|
80 | if (nbSelected == 0) { |
---|
81 | $("#selectedMessage").text( |
---|
82 | sprintf( |
---|
83 | '{'No photo selected, %d photos in current set'|translate|escape:javascript}', |
---|
84 | nb_thumbs_set |
---|
85 | ) |
---|
86 | ); |
---|
87 | } |
---|
88 | else if (nbSelected == nb_thumbs_set) { |
---|
89 | $("#selectedMessage").text( |
---|
90 | sprintf( |
---|
91 | '{'All %d photos are selected'|translate|escape:javascript}', |
---|
92 | nb_thumbs_set |
---|
93 | ) |
---|
94 | ); |
---|
95 | } |
---|
96 | else { |
---|
97 | $("#selectedMessage").text( |
---|
98 | sprintf( |
---|
99 | '{'%d of %d photos selected'|translate|escape:javascript}', |
---|
100 | nbSelected, |
---|
101 | nb_thumbs_set |
---|
102 | ) |
---|
103 | ); |
---|
104 | } |
---|
105 | } |
---|
106 | |
---|
107 | /* import queue */ |
---|
108 | function performImport(photo, album, fills) { |
---|
109 | queuedManager.add({ |
---|
110 | type: 'GET', |
---|
111 | dataType: 'json', |
---|
112 | url: 'ws.php', |
---|
113 | data: { |
---|
114 | method: 'pwg.images.addFlickr', |
---|
115 | id: photo, |
---|
116 | category: album, |
---|
117 | fills: fills, |
---|
118 | format: 'json' |
---|
119 | }, |
---|
120 | success: function(data) { |
---|
121 | if (data['stat'] == 'ok') { |
---|
122 | jQuery.jGrowl(data['result'], { |
---|
123 | theme: 'success', life: 4000, sticky: false, |
---|
124 | header: '{'Success'|translate}' |
---|
125 | }); |
---|
126 | jQuery("#photo-"+photo).fadeOut(function(){ $(this).remove(); }); |
---|
127 | } |
---|
128 | else { |
---|
129 | jQuery.jGrowl(data['result'], { |
---|
130 | theme: 'error', sticky: true, |
---|
131 | header: '{'ERROR'|translate}' |
---|
132 | }); |
---|
133 | } |
---|
134 | |
---|
135 | import_done++; |
---|
136 | $("#progress").html(import_done +"/"+ import_selected); |
---|
137 | |
---|
138 | if (import_done == import_selected) { |
---|
139 | $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">'); |
---|
140 | $("#import_form").submit(); |
---|
141 | } |
---|
142 | }, |
---|
143 | error: function(data) { |
---|
144 | jQuery.jGrowl('{'an error happened'|translate|@escape:'javascript'}', { |
---|
145 | theme: 'error', sticky: true, |
---|
146 | header: '{'ERROR'|translate}' |
---|
147 | }); |
---|
148 | } |
---|
149 | }); |
---|
150 | } |
---|
151 | |
---|
152 | |
---|
153 | checkPermitAction(); |
---|
154 | $("a.preview-box").colorbox(); |
---|
155 | $('ul.thumbnails').enableShiftClick(); |
---|
156 | |
---|
157 | /* tiptip */ |
---|
158 | $('img.thumbnail').tipTip({ |
---|
159 | 'delay' : 0, |
---|
160 | 'fadeIn' : 200, |
---|
161 | 'fadeOut' : 200 |
---|
162 | }); |
---|
163 | |
---|
164 | /* thumbnail click */ |
---|
165 | $(".wrap1 label").click(function(event) { |
---|
166 | $("input[name=setSelected]").prop('checked', false); |
---|
167 | |
---|
168 | var wrap2 = $(this).children(".wrap2"); |
---|
169 | var checkbox = $(this).children("input[type=checkbox]"); |
---|
170 | |
---|
171 | checkbox.triggerHandler("shclick",event); |
---|
172 | |
---|
173 | if ($(checkbox).is(':checked')) { |
---|
174 | $(wrap2).addClass("thumbSelected"); |
---|
175 | } |
---|
176 | else { |
---|
177 | $(wrap2).removeClass('thumbSelected'); |
---|
178 | } |
---|
179 | |
---|
180 | checkPermitAction(); |
---|
181 | }); |
---|
182 | |
---|
183 | /* select all */ |
---|
184 | $("#selectAll").click(function() { |
---|
185 | $("input[name=setSelected]").prop('checked', false); |
---|
186 | |
---|
187 | $(".thumbnails label").each(function() { |
---|
188 | var wrap2 = $(this).children(".wrap2"); |
---|
189 | var checkbox = $(this).children("input[type=checkbox]"); |
---|
190 | |
---|
191 | $(checkbox).prop('checked', true); |
---|
192 | $(wrap2).addClass("thumbSelected"); |
---|
193 | }); |
---|
194 | |
---|
195 | checkPermitAction(); |
---|
196 | return false; |
---|
197 | }); |
---|
198 | |
---|
199 | /* select none */ |
---|
200 | $("#selectNone").click(function() { |
---|
201 | $("input[name=setSelected]").prop('checked', false); |
---|
202 | |
---|
203 | $(".thumbnails label").each(function() { |
---|
204 | var wrap2 = $(this).children(".wrap2"); |
---|
205 | var checkbox = $(this).children("input[type=checkbox]"); |
---|
206 | |
---|
207 | $(checkbox).prop('checked', false); |
---|
208 | $(wrap2).removeClass("thumbSelected"); |
---|
209 | }); |
---|
210 | |
---|
211 | checkPermitAction(); |
---|
212 | return false; |
---|
213 | }); |
---|
214 | |
---|
215 | /* select invert */ |
---|
216 | $("#selectInvert").click(function() { |
---|
217 | $("input[name=setSelected]").prop('checked', false); |
---|
218 | |
---|
219 | $(".thumbnails label").each(function() { |
---|
220 | var wrap2 = $(this).children(".wrap2"); |
---|
221 | var checkbox = $(this).children("input[type=checkbox]"); |
---|
222 | |
---|
223 | $(checkbox).prop('checked', !$(checkbox).is(':checked')); |
---|
224 | |
---|
225 | if ($(checkbox).is(':checked')) { |
---|
226 | $(wrap2).addClass("thumbSelected"); |
---|
227 | } |
---|
228 | else { |
---|
229 | $(wrap2).removeClass('thumbSelected'); |
---|
230 | } |
---|
231 | }); |
---|
232 | |
---|
233 | checkPermitAction(); |
---|
234 | return false; |
---|
235 | }); |
---|
236 | |
---|
237 | /* select set */ |
---|
238 | $("#selectSet").click(function() { |
---|
239 | $("input[name=setSelected]").prop('checked', true); |
---|
240 | |
---|
241 | $(".thumbnails label").each(function() { |
---|
242 | var wrap2 = $(this).children(".wrap2"); |
---|
243 | var checkbox = $(this).children("input[type=checkbox]"); |
---|
244 | |
---|
245 | $(checkbox).prop('checked', true); |
---|
246 | $(wrap2).addClass("thumbSelected"); |
---|
247 | }); |
---|
248 | |
---|
249 | checkPermitAction(); |
---|
250 | return false; |
---|
251 | }); |
---|
252 | |
---|
253 | /* begin import */ |
---|
254 | jQuery('#beginImport').click(function() { |
---|
255 | $("#loader_import").fadeIn(); |
---|
256 | var album = $("#albumSelect option:selected").val(); |
---|
257 | |
---|
258 | var fills = ''; |
---|
259 | $("input[name^='fill_']:checked").each(function() { |
---|
260 | fills+= $(this).attr("name") +','; |
---|
261 | }); |
---|
262 | |
---|
263 | if (jQuery('input[name="setSelected"]').attr('checked')) { |
---|
264 | import_selected = all_elements.length; |
---|
265 | $("#progress").html("0/"+ import_selected); |
---|
266 | |
---|
267 | for (var i in all_elements) { |
---|
268 | performImport(all_elements[i], album, fills); |
---|
269 | } |
---|
270 | } |
---|
271 | else { |
---|
272 | import_selected = $("input[name='selection[]']:checked").length; |
---|
273 | $("#progress").html("0/"+ import_selected); |
---|
274 | |
---|
275 | jQuery("input[name='selection[]']:checked").each(function() { |
---|
276 | performImport(jQuery(this).attr('value'), album, fills); |
---|
277 | }); |
---|
278 | } |
---|
279 | |
---|
280 | return false; |
---|
281 | }); |
---|
282 | |
---|
283 | /* pagination loader */ |
---|
284 | jQuery('#navigation a').click(function() { |
---|
285 | $("#loader_display").fadeIn(); |
---|
286 | }); |
---|
287 | }(jQuery)); |
---|
288 | {/footer_script} |
---|
289 | |
---|
290 | |
---|
291 | <div id="batchManagerGlobal"> |
---|
292 | <form action="{$F_ACTION}" method="post" id="import_form"> |
---|
293 | |
---|
294 | <fieldset> |
---|
295 | <legend>{'Selection'|translate}</legend> |
---|
296 | |
---|
297 | {if !empty($thumbnails)} |
---|
298 | <p id="checkActions"> |
---|
299 | {'Select:'|translate} |
---|
300 | {if $nb_thumbs_set > $nb_thumbs_page} |
---|
301 | <a href="#" id="selectAll">{'The whole page'|translate}</a>, |
---|
302 | <a href="#" id="selectSet">{'The whole set'|translate}</a>, |
---|
303 | {else} |
---|
304 | <a href="#" id="selectAll">{'All'|translate}</a>, |
---|
305 | {/if} |
---|
306 | <a href="#" id="selectNone">{'None'|translate}</a>, |
---|
307 | <a href="#" id="selectInvert">{'Invert'|translate}</a> |
---|
308 | |
---|
309 | <span id="selectedMessage"></span> |
---|
310 | <input type="checkbox" name="setSelected" style="display:none"> |
---|
311 | <span id="loader_display" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i></span> |
---|
312 | </p> |
---|
313 | |
---|
314 | <ul class="thumbnails"> |
---|
315 | {foreach from=$thumbnails item=thumbnail} |
---|
316 | <li id="photo-{$thumbnail.id}"> |
---|
317 | <span class="wrap1"> |
---|
318 | <label> |
---|
319 | <span class="wrap2"> |
---|
320 | <div class="actions"><a href="{$thumbnail.src}" class="preview-box">{'Zoom'|translate}</a> · <a href="{$thumbnail.url}" target="_blank" title="{'Open Flickr page in a new tab'|translate}">Flickr</a></div> |
---|
321 | <span> |
---|
322 | <img src="{$thumbnail.thumb}" alt="{$thumbnail.title}" title="{$thumbnail.title|escape:'html'}" class="thumbnail"> |
---|
323 | </span> |
---|
324 | </span> |
---|
325 | <input type="checkbox" name="selection[]" value="{$thumbnail.id}"> |
---|
326 | </label> |
---|
327 | </span> |
---|
328 | </li> |
---|
329 | {/foreach} |
---|
330 | </ul> |
---|
331 | |
---|
332 | |
---|
333 | <div style="clear:both;" id="navigation"> |
---|
334 | {if !empty($navbar) } |
---|
335 | <div style="float:left"> |
---|
336 | {include file='navigation_bar.tpl'|get_extent:'navbar'} |
---|
337 | </div> |
---|
338 | {/if} |
---|
339 | |
---|
340 | <div style="float:right;margin-top:10px;">{'display'|translate} |
---|
341 | <a href="{$U_DISPLAY}&display=20">20</a> |
---|
342 | · <a href="{$U_DISPLAY}&display=50">50</a> |
---|
343 | · <a href="{$U_DISPLAY}&display=100">100</a> |
---|
344 | · <a href="{$U_DISPLAY}&display=all">{'all'|translate}</a> |
---|
345 | {'photos per page'|translate} |
---|
346 | </div> |
---|
347 | </div> |
---|
348 | |
---|
349 | {else} |
---|
350 | <div>{'No photo in the current set.'|translate}</div> |
---|
351 | {/if} |
---|
352 | </fieldset> |
---|
353 | |
---|
354 | <fieldset> |
---|
355 | <legend>{'Import options'|translate}</legend> |
---|
356 | |
---|
357 | <p> |
---|
358 | <label for="albumSelect"><b>{'Album'|translate}:</b></label> |
---|
359 | <select style="width:400px" name="associate" id="albumSelect" size="1"> |
---|
360 | {html_options options=$category_parent_options} |
---|
361 | </select> |
---|
362 | {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a> |
---|
363 | </p> |
---|
364 | |
---|
365 | <p> |
---|
366 | <b>{'Fill these fields from Flickr datas'|translate}:</b> |
---|
367 | <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|translate}</label> |
---|
368 | <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|translate}</label> |
---|
369 | <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|translate}</label> |
---|
370 | <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|translate}</label> |
---|
371 | <label><input type="checkbox" name="fill_posted"> {'Post date'|translate}</label> |
---|
372 | <label><input type="checkbox" name="fill_description" checked="checked"> {'Description'|@translate}</label> |
---|
373 | <label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label> |
---|
374 | <label><input type="checkbox" name="fill_level" checked="checked"> {'Privacy level'|@translate}</label> |
---|
375 | </p> |
---|
376 | |
---|
377 | <p> |
---|
378 | <input type="hidden" name="album" value="{$album}"> |
---|
379 | <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|translate}" style="display:none;"> |
---|
380 | <span id="loader_import" style="display:none;"><img src="admin/themes/default/images/ajax-loader.gif"> <i>{'Processing...'|translate}</i> <span id="progress"></span></span> |
---|
381 | </p> |
---|
382 | </fieldset> |
---|
383 | </form> |
---|
384 | </div> |
---|