Commit 733057ccc5e409f0a6ab08249f672620c44f196e
1 parent
98b5afb8
-Gallery frontend ready
Showing
1 changed file
with
52 additions
and
0 deletions
Show diff stats
1 | +$( | |
2 | + function() { | |
3 | + $(document) | |
4 | + .on( | |
5 | + 'change', '.gw-image-input', function(e) { | |
6 | + var input = this; | |
7 | + $.ajax( | |
8 | + { | |
9 | + url: '/admin/imagemanager/manager/view', | |
10 | + type: "POST", | |
11 | + data: { | |
12 | + 'ImageManager_id': input.value | |
13 | + }, | |
14 | + success: function(data) { | |
15 | + $( | |
16 | + '#' + $(input) | |
17 | + .data('img') | |
18 | + ) | |
19 | + .attr('src', data.image); | |
20 | + $( | |
21 | + '#' + $(input) | |
22 | + .data('name') | |
23 | + ) | |
24 | + .html(data.fileName); | |
25 | + } | |
26 | + } | |
27 | + ); | |
28 | + } | |
29 | + ); | |
30 | + | |
31 | + $(document) | |
32 | + .on( | |
33 | + 'click', '#add-image', function(e) { | |
34 | + var hash = Math.floor(Math.random() * 89999) + 10000; | |
35 | + var content = '<div class="col-md-4 gw-item"><input id="' + hash + '" class="gw-image-input" name ="images" ' + 'data-img="' + hash + '_img" data-name="' + hash + '_name" type ="hidden"> ' + '<img id="' + hash + '_img" class="img-rounded" src="/admin/product/create" alt="">' + '<p id="' + hash + '_name" class="text-info"></p>' + '<button type="button" class="open-modal-imagemanager" data-aspect-ratio="" data-crop-view-mode="1" ' + 'data-input-id="' + hash + '"><i class="fa fa-folder-open"></i></button><button type="button" class="remove-img">' + '<i class="fa fa-trash"></i></button></div>'; | |
36 | + $('.gw-container') | |
37 | + .append(content); | |
38 | + // if (document.querySelectorAll(".gw-container > .gw-item").length % 3 === 0) { | |
39 | + // $('.gw-container').append('<div class="clearfix"></div>'); | |
40 | + // } | |
41 | + } | |
42 | + ); | |
43 | + $(document) | |
44 | + .on( | |
45 | + 'click', '.remove-img', function(e) { | |
46 | + $(this) | |
47 | + .parent() | |
48 | + .remove(); | |
49 | + } | |
50 | + ) | |
51 | + } | |
52 | +); | |
0 | 53 | \ No newline at end of file | ... | ... |