1 | {include file='include/colorbox.inc.tpl'} |
---|
2 | {include file='include/add_album.inc.tpl'} |
---|
3 | {combine_script id='jquery.ajaxmanager' load='footer' path='themes/default/js/plugins/jquery.ajaxmanager.js'} |
---|
4 | {combine_script id='jquery.jgrowl' load='footer' require='jquery' path='themes/default/js/plugins/jquery.jgrowl_minimized.js'} |
---|
5 | {combine_css path="admin/themes/default/uploadify.jGrowl.css"} |
---|
6 | |
---|
7 | {footer_script require='jquery.ajaxmanager,jquery.jgrowl'} |
---|
8 | /* global vars */ |
---|
9 | var errorHead = '{'ERROR'|@translate|@escape:'javascript'}'; |
---|
10 | var errorMsg = '{'an error happened'|@translate|@escape:'javascript'}'; |
---|
11 | var successHead = '{'Success'|@translate|@escape:'javascript'}'; |
---|
12 | |
---|
13 | var import_done = 0; |
---|
14 | var import_selected = {$nb_elements}; |
---|
15 | var queuedManager = jQuery.manageAjax.create('queued', {ldelim} |
---|
16 | queue: true, |
---|
17 | maxRequests: 1 |
---|
18 | }); |
---|
19 | |
---|
20 | {literal} |
---|
21 | /* import queue */ |
---|
22 | function performImport(photo, album, fills, pwa_album) { |
---|
23 | queuedManager.add({ |
---|
24 | type: 'GET', |
---|
25 | dataType: 'json', |
---|
26 | url: 'ws.php', |
---|
27 | data: { method: 'pwg.images.addPicasa', id: photo, category: album, fills: fills, pwa_album: pwa_album, format: 'json' }, |
---|
28 | success: function(data) { |
---|
29 | if (data['stat'] == 'ok') { |
---|
30 | jQuery.jGrowl(data['result'], { theme: 'success', header: successHead, life: 4000, sticky: false }); |
---|
31 | } else { |
---|
32 | jQuery.jGrowl(data['result'], { theme: 'error', header: errorHead, sticky: true }); |
---|
33 | } |
---|
34 | |
---|
35 | import_done++; |
---|
36 | $("#progress").html(import_done +"/"+ import_selected); |
---|
37 | |
---|
38 | if (import_done == import_selected) { |
---|
39 | $("#import_form").append('<input type="hidden" name="done" value="' + import_done + '">'); |
---|
40 | $("#import_form").submit(); |
---|
41 | } |
---|
42 | }, |
---|
43 | error: function(data) { |
---|
44 | jQuery.jGrowl(errorMsg, { theme: 'error', header: errorHead, sticky: true }); |
---|
45 | } |
---|
46 | }); |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | $(document).ready(function() { |
---|
51 | var all_elements = {/literal}{$all_elements}{literal}; |
---|
52 | |
---|
53 | /* begin import */ |
---|
54 | jQuery('#beginImport').click(function() { |
---|
55 | $("#loader_import").fadeIn(); |
---|
56 | |
---|
57 | if ($("input[name='album_mode']:checked").val() == 'identical') { |
---|
58 | album = "<!-- create -->"; |
---|
59 | } else { |
---|
60 | album = $("#albumSelect option:selected").val(); |
---|
61 | } |
---|
62 | |
---|
63 | var fills = ''; |
---|
64 | $("input[name^='fill_']:checked").each(function() { |
---|
65 | fills+= $(this).attr("name") +','; |
---|
66 | }); |
---|
67 | |
---|
68 | import_selected = all_elements.length; |
---|
69 | $("#progress").html("0/"+ import_selected); |
---|
70 | |
---|
71 | for (var i in all_elements) { |
---|
72 | performImport(all_elements[i]['id'], album, fills, all_elements[i]['album']); |
---|
73 | } |
---|
74 | |
---|
75 | return false; |
---|
76 | }); |
---|
77 | |
---|
78 | /* album mode */ |
---|
79 | $("input[name='album_mode']").change(function() { |
---|
80 | if ($(this).val() == 'one_album') { |
---|
81 | $("#albumSelectWrapper").slideDown(); |
---|
82 | } else { |
---|
83 | $("#albumSelectWrapper").slideUp(); |
---|
84 | } |
---|
85 | }); |
---|
86 | }); |
---|
87 | {/literal} |
---|
88 | {/footer_script} |
---|
89 | |
---|
90 | <form action="{$F_ACTION}" method="post" id="import_form"> |
---|
91 | |
---|
92 | <fieldset> |
---|
93 | <legend>{'Selection'|@translate}</legend> |
---|
94 | |
---|
95 | {if $nb_elements} |
---|
96 | {'%d elements ready for importation'|@translate|@sprintf:$nb_elements} |
---|
97 | {else} |
---|
98 | <div>{'No photo in the current set.'|@translate}</div> |
---|
99 | {/if} |
---|
100 | </fieldset> |
---|
101 | |
---|
102 | <fieldset> |
---|
103 | <legend>{'Import options'|@translate}</legend> |
---|
104 | |
---|
105 | <p> |
---|
106 | <label><input type="radio" name="album_mode" value="identical" checked="checked"> {'Reproduce Google albums'|@translate}</label><br> |
---|
107 | <label><input type="radio" name="album_mode" value="one_album"> {'Import all photos in this album'|@translate} :</label> |
---|
108 | </p> |
---|
109 | |
---|
110 | <p id="albumSelectWrapper" style="display:none;"> |
---|
111 | <select style="width:400px" name="associate" id="albumSelect" size="1"> |
---|
112 | {html_options options=$category_parent_options} |
---|
113 | </select> |
---|
114 | {'... or '|@translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|@translate}">{'create a new album'|@translate}</a> |
---|
115 | </p> |
---|
116 | |
---|
117 | <p> |
---|
118 | <b>{'Fill these fields from Google datas'|@translate}:</b> |
---|
119 | <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|@translate}</label> |
---|
120 | <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|@translate}</label> |
---|
121 | <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|@translate}</label> |
---|
122 | <label><input type="checkbox" name="fill_date" checked="checked"> {'Creation date'|@translate}</label> |
---|
123 | <label><input type="checkbox" name="fill_description" checked="checked"> {'Description'|@translate}</label> |
---|
124 | {if $GMAPS_LOADED}<label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>{/if} |
---|
125 | </p> |
---|
126 | |
---|
127 | <p> |
---|
128 | <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|@translate}" {if not $nb_elements}style="display:none;"{/if}> |
---|
129 | <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> |
---|
130 | </p> |
---|
131 | </fieldset> |
---|
132 | </form> |
---|