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
RevLine 
[16063]1{footer_script require='jquery.ajaxmanager,jquery.jgrowl'}
[26180]2(function($){
3  /* global vars */
[27265]4  var all_elements = {$all_elements};
[26180]5  var import_done = 0;
6  var import_selected = {$nb_elements};
7  var queuedManager = $.manageAjax.create('queued', {
8    queue: true,
9    maxRequests: 1
10  });
[16063]11
[26180]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        }
[16063]39
[26180]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        });
[16063]53      }
[26180]54    });
55  }
[16063]56
57  /* begin import */
[26180]58  $('#beginImport').click(function() {
[16063]59    $("#loader_import").fadeIn();
[26180]60
[17476]61    if ($("input[name='album_mode']:checked").val() == 'identical') {
[16063]62      var album = 0;
[26180]63    }
64    else {
[16063]65      var album = $("#albumSelect option:selected").val();
66    }
[26180]67
[16063]68    var fills = '';
69    $("input[name^='fill_']:checked").each(function() {
70      fills+= $(this).attr("name") +',';
[26180]71    });
72
[16063]73    import_selected = all_elements.length;
74    $("#progress").html("0/"+ import_selected);
[26180]75
[16063]76    for (var i in all_elements) {
77      if (album == 0) this_album = all_elements[i]['albums'];
78      else            this_album = album;
[26180]79
[16063]80      performImport(all_elements[i]['id'], this_album, fills);
81    }
[26180]82
[16063]83    return false;
84  });
[26180]85
[16063]86  /* album mode */
87  $("input[name='album_mode']").change(function() {
88    if ($(this).val() == 'one_album') {
89      $("#albumSelectWrapper").slideDown();
[26180]90    }
91    else {
[16063]92      $("#albumSelectWrapper").slideUp();
93    }
94  });
[26180]95}(jQuery));
[16063]96{/footer_script}
97
[26180]98
[16063]99<form action="{$F_ACTION}" method="post" id="import_form">
100
101  <fieldset>
[26180]102    <legend>{'Selection'|translate}</legend>
[16063]103
104  {if $nb_elements}
[26180]105    {'%d elements ready for importation'|translate:$nb_elements}
[16063]106  {else}
[26180]107    <div>{'No photo in the current set.'|translate}</div>
[16063]108  {/if}
109  </fieldset>
[26180]110
[16063]111  <fieldset>
[26180]112    <legend>{'Import options'|translate}</legend>
113
[16063]114    <p>
[26180]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>
[16063]117    </p>
118
119    <p id="albumSelectWrapper" style="display:none;">
120      <select style="width:400px" name="associate" id="albumSelect" size="1">
[17476]121        {html_options options=$category_parent_options}
[16063]122      </select>
[26180]123      {'... or '|translate}<a href="#" class="addAlbumOpen" title="{'create a new album'|translate}">{'create a new album'|translate}</a>
[16063]124    </p>
[26180]125
[16063]126    <p>
[26180]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>
[25789]133      <label><input type="checkbox" name="fill_description" checked="checked"> {'Description'|@translate}</label>
[26180]134      <label><input type="checkbox" name="fill_geotag" checked="checked"> {'Geolocalization'|@translate}</label>
[27242]135      <label><input type="checkbox" name="fill_level" checked="checked"> {'Privacy level'|@translate}</label>
[16063]136    </p>
[26180]137
[16063]138    <p>
[26180]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>
[16063]141    </p>
142  </fieldset>
143</form>
Note: See TracBrowser for help on using the repository browser.