Skip to content

Commit

Permalink
Fix sprite image uploading
Browse files Browse the repository at this point in the history
  • Loading branch information
SeinopSys committed May 7, 2019
1 parent 4cb9c00 commit eb59799
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 1 addition & 2 deletions assets/js/jquery.uploadzone.js
Expand Up @@ -32,7 +32,7 @@
$input.prev().attr('href', response.path).children('img').fadeTo(200,0,function(){
let $image = $(this);
$this.addClass('loading');
$image.attr('src',response.path).on('load',function(){
$image.attr({ src: response.path, alt: '' }).on('load',function(){
$this.removeClass('loading');
$image.fadeTo(200,1);
});
Expand Down Expand Up @@ -63,7 +63,6 @@

let fd = new FormData();
fd.append(opt.requestKey, files[0]);
fd.append('CSRF_TOKEN', $.getCSRFToken());

let ajaxOpts = {
url: opt.target,
Expand Down
3 changes: 2 additions & 1 deletion assets/js/pages/colorguide/manage.jsx
Expand Up @@ -1875,11 +1875,12 @@
let title = 'Upload sprite image',
$uploadInput = $this.find('input[type="file"]');
$.Dialog.request(title,$SpriteUploadFormTemplate.clone(),'Download image', function($form){
let $image_url = $form.find('input[name=image_url]');
const $image_url = $form.find('input[name=image_url]');
$form.find('.upload-link').on('click', function(e){
e.preventDefault();
e.stopPropagation();

$.Dialog.close();
$uploadInput.trigger('click', [true]);
});
if (PersonalGuide)
Expand Down
3 changes: 3 additions & 0 deletions assets/js/shared-utils.js
Expand Up @@ -391,6 +391,9 @@
r.push(`CSRF_TOKEN=${t}`);
event.data = r.join("&");
}
else if (event.data instanceof FormData) {
event.data.append('CSRF_TOKEN', t);
}
else event.data = { ...event.data, CSRF_TOKEN: t };
});
const simpleStatusHandler = xhr => {
Expand Down
7 changes: 6 additions & 1 deletion assets/scss/components/optional/_jquery.uploadzone.scss
@@ -1,4 +1,3 @@

.upload-wrap {
position: relative;
overflow: hidden;
Expand All @@ -11,6 +10,12 @@
&:before, &:after { opacity: 1 }
}

> a {
&, & > img {
display: block;
}
}

> input[type=file] {
position: absolute !important;
top: 0;
Expand Down

0 comments on commit eb59799

Please sign in to comment.