source: extensions/flickr2piwigo/admin/template/import.list_all.tpl @ 27265

Last change on this file since 27265 was 27265, checked in by mistic100, 10 years ago

fix bugs in "import all" and level sync

File size: 4.7 KB
Line 
1{footer_script require='jquery.ajaxmanager,jquery.jgrowl'}
2(function($){
3  /* global vars */
4  var all_elements = {$all_elements};
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) {
14    queuedManager.add({
15      type: 'GET',
16      dataType: 'json',
17      url: 'ws.php',
18      data: {
19        method: 'pwg.images.addFlickr',
20        id: photo,
21        category: album,
22        fills: fills,
23        format: 'json'
24      },
25      success: function(data) {
26        if (data['stat'] == 'ok') {
27          $.jGrowl(data['result'], {
28            theme: 'success', life: 4000, sticky: false,
29            header: '{'Success'|translate}',
30          });
31          $("#photo-"+photo.id).fadeOut(function(){ $(this).remove(); });
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  /* begin import */
58  $('#beginImport').click(function() {
59    $("#loader_import").fadeIn();
60
61    if ($("input[name='album_mode']:checked").val() == 'identical') {
62      var album = 0;
63    }
64    else {
65      var album = $("#albumSelect option:selected").val();
66    }
67
68    var fills = '';
69    $("input[name^='fill_']:checked").each(function() {
70      fills+= $(this).attr("name") +',';
71    });
72
73    import_selected = all_elements.length;
74    $("#progress").html("0/"+ import_selected);
75
76    for (var i in all_elements) {
77      if (album == 0) this_album = all_elements[i]['albums'];
78      else            this_album = album;
79
80      performImport(all_elements[i]['id'], this_album, fills);
81    }
82
83    return false;
84  });
85
86  /* album mode */
87  $("input[name='album_mode']").change(function() {
88    if ($(this).val() == 'one_album') {
89      $("#albumSelectWrapper").slideDown();
90    }
91    else {
92      $("#albumSelectWrapper").slideUp();
93    }
94  });
95}(jQuery));
96{/footer_script}
97
98
99<form action="{$F_ACTION}" method="post" id="import_form">
100
101  <fieldset>
102    <legend>{'Selection'|translate}</legend>
103
104  {if $nb_elements}
105    {'%d elements ready for importation'|translate:$nb_elements}
106  {else}
107    <div>{'No photo in the current set.'|translate}</div>
108  {/if}
109  </fieldset>
110
111  <fieldset>
112    <legend>{'Import options'|translate}</legend>
113
114    <p>
115      <label><input type="radio" name="album_mode" value="identical" checked="checked"> {'Reproduce flickr albums'|translate}</label><br>
116      <label><input type="radio" name="album_mode" value="one_album"> {'Import all photos in this album'|translate} :</label>
117    </p>
118
119    <p id="albumSelectWrapper" style="display:none;">
120      <select style="width:400px" name="associate" id="albumSelect" size="1">
121        {html_options options=$category_parent_options}
122      </select>
123      {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a>
124    </p>
125
126    <p>
127      <b>{'Fill these fields from Flickr datas'|translate}:</b>
128      <label><input type="checkbox" name="fill_name" checked="checked"> {'Photo name'|translate}</label>
129      <label><input type="checkbox" name="fill_author" checked="checked"> {'Author'|translate}</label>
130      <label><input type="checkbox" name="fill_tags" checked="checked"> {'Tags'|translate}</label>
131      <label><input type="checkbox" name="fill_taken" checked="checked"> {'Creation date'|translate}</label>
132      <label><input type="checkbox" name="fill_posted"> {'Post date'|translate}</label>
133      <label><input type="checkbox" name="fill_description" checked="checked"> {'Description'|@translate}</label>
134      <label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>
135      <label><input type="checkbox" name="fill_level" checked="checked"> {'Privacy level'|@translate}</label>
136    </p>
137
138    <p>
139      <input type="submit" name="import_set" id="beginImport" value="{'Begin transfer'|translate}" {if not $nb_elements}style="display:none;"{/if}>
140      <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>
141    </p>
142  </fieldset>
143</form>
Note: See TracBrowser for help on using the repository browser.