showing results for - "exporting images from the settings shopify"
Noah
11 May 2016
1function fetchPageAssets(){
2  var downloader = $("<a id='download-file' href='' download='' target='_blank'></a>")
3  $(".ui-title-bar").append(downloader)
4  var assets = $("#assets-table .next-input--readonly")
5  assets.each(function(index, input) {
6    $('#download-file').attr('href', input.value);
7    $('#download-file')[0].click();
8    if (index + 1 == assets.length) {
9      var lastItem = $(input).parents("tr[bind-class]").attr('bind-class').substring(25,36)
10      $.ajax({
11        url: "/admin/settings/files?direction=next&last_id="+lastItem+"&last_value="+ lastItem+"&limit=100&order=id+desc",
12      }).done(function(data) {
13        var mutationObserver = new MutationObserver(function(mutations, observer) {
14          mutations.forEach(function(mutation) {
15            if (mutation.target.id && mutation.target.id == "assets-table") {
16              fetchPageAssets()
17              observer.disconnect()
18            }
19          })
20        });
21        mutationObserver.observe(document, {
22          childList: true,
23          subtree: true
24        });
25        var newDoc = document.open("text/html", "replace");
26        newDoc.write(data);
27        newDoc.close();
28      })
29    }
30  })
31}
32fetchPageAssets()