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