Skip to content

Commit

Permalink
test template (file > open)
Browse files Browse the repository at this point in the history
  • Loading branch information
viliusle committed Jul 27, 2018
1 parent bae1ef1 commit 92f1586
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 64 deletions.
Binary file removed images/_sprites.png
Binary file not shown.
141 changes: 79 additions & 62 deletions images/json-test.json → images/test-collection.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion src/js/config-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ var menu_template = `
<li class="more">
<a class="trn" href="#">Open</a>
<ul>
<li><a class="trn dots" data-target="file/open.open_file" href="#">Open File</a></li>
<li><a class="trn dots" data-target="file/open.open_file" data-key="Drag&Drop" href="#">Open File</a></li>
<li><a class="trn dots" data-target="file/open.open_dir" href="#">Open Directory</a></li>
<li><a class="trn dots" data-target="file/open.open_url" href="#">Open URL</a></li>
<li><a class="trn dots" data-target="file/open.open_data_url" href="#">Open Data URL</a></li>
<li><a class="trn dots" data-target="file/open.open_template_test" href="#">Open test template</a></li>
</ul>
</li>
<li><a class="trn dots" data-target="file/search.search" href="#">Search images</a></li>
Expand Down
18 changes: 17 additions & 1 deletion src/js/modules/file/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,18 @@ class File_open_class {
FR.readAsDataURL(f);
}
}

open_template_test(){
var _this = this;

window.fetch("./../../../../images/test-collection.json").then(function(response) {
return response.json();
}).then(function(json) {
_this.load_json(json, false);
}).catch(function(ex) {
alertify.error('Sorry, image could not be loaded.');
});
}

/**
* check if url has url params, for example: http:https://viliusle.github.io/miniPaint/?image=http:https://i.imgur.com/ATda8Ae.jpg
Expand Down Expand Up @@ -276,7 +288,11 @@ class File_open_class {
}

load_json(data) {
var json = JSON.parse(data);
var json;
if(typeof data == 'string')
json = JSON.parse(data);
else
json = data;
if (json.info.version == undefined) {
json.info.version = "3";
}
Expand Down

0 comments on commit 92f1586

Please sign in to comment.