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