Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/2058
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel kerr committed Oct 26, 2014
1 parent 761ff11 commit 36effb1
Show file tree
Hide file tree
Showing 18 changed files with 560 additions and 553 deletions.
2 changes: 1 addition & 1 deletion upload/admin/controller/extension/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function upload() {
}

// Compare catalog files
$file = DIR_CATALOG . substr($zip_name, 7);
$file = DIR_CATALOG . substr($zip_name, 15);

if (is_file($file) && substr($zip_name, 0, 15) == 'upload/catalog/') {
$json['overwrite'][] = substr($zip_name, 7);
Expand Down
48 changes: 0 additions & 48 deletions upload/admin/view/javascript/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,56 +184,8 @@ $(document).ready(function() {
$(document).ajaxStop(function() {
$('[data-toggle=\'tooltip\']').tooltip({container: 'body'});
});

/*
// Upload
$(document).delegate('button[data-toggle=\'upload\']', 'click', function(e) {
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload"><input type="file" name="file" onchange="upload();" /></form>');
// onsubmit="return false;"
$('#form-upload input[name=\'file\']').trigger('click');
$('#form-upload').on('submit', function(e) {
alert('hi');
});
$.ajax({
url: $(this).attr('data-url'),
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').prop('disabled', true);
},
complete: function() {
$('#button-upload').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
*/
});



// Autocomplete */
(function($) {
function Autocomplete(element, options) {
Expand Down
66 changes: 35 additions & 31 deletions upload/admin/view/template/catalog/download_form.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,42 @@ $('#button-upload').on('click', function() {
$('#form-upload input[name=\'file\']').trigger('click');
$('#form-upload input[name=\'file\']').on('change', function() {
$.ajax({
url: 'index.php?route=catalog/download/upload&token=<?php echo $token; ?>',
type: 'post',
dataType: 'json',
data: new FormData($(this).parent()[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').button('loading');
},
complete: function() {
$('#button-upload').button('reset');
},
success: function(json) {
if (json['error']) {
alert(json['error']);
timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);
$.ajax({
url: 'index.php?route=catalog/download/upload&token=<?php echo $token; ?>',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').button('loading');
},
complete: function() {
$('#button-upload').button('reset');
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
$('input[name=\'filename\']').attr('value', json['filename']);
$('input[name=\'mask\']').attr('value', json['mask']);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
if (json['success']) {
alert(json['success']);
$('input[name=\'filename\']').attr('value', json['filename']);
$('input[name=\'mask\']').attr('value', json['mask']);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
});
}
}, 500);
});
//--></script></div>
<?php echo $footer; ?>
78 changes: 38 additions & 40 deletions upload/admin/view/template/common/filemanager.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -118,51 +118,49 @@ $('#button-search').on('click', function() {
$('#button-upload').on('click', function() {
$('#form-upload').remove();
$('body').prepend('<form enctype="multipart/form-data" id="form-upload"><input type="file" name="file" value="" onchange="$(\'#test\').click();" /><input type="submit" id="test" /></form>');
$('body').prepend('<form enctype="multipart/form-data" id="form-upload" style="display: none;"><input type="file" name="file" value="" /></form>');
$('#form-upload input[name=\'file\']').trigger('click');
$('#form-upload input[name=\'file\']').trigger('click');
$('#test').on('click', function(e) {
e.preventDefault();
return false;
alert('hi');
/*
$.ajax({
url: 'index.php?route=common/filemanager/upload&token=<?php echo $token; ?>&directory=<?php echo $directory; ?>',
type: 'post',
dataType: 'json',
data: new FormData($(this)[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').prop('disabled', true);
},
complete: function() {
$('#button-upload').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
if (json['success']) {
alert(json['success']);
timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);
$.ajax({
url: 'index.php?route=common/filemanager/upload&token=<?php echo $token; ?>&directory=<?php echo $directory; ?>',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload i').replaceWith('<i class="fa fa-circle-o-notch fa-spin"></i>');
$('#button-upload').prop('disabled', true);
},
complete: function() {
$('#button-upload i').replaceWith('<i class="fa fa-upload"></i>');
$('#button-upload').prop('disabled', false);
},
success: function(json) {
if (json['error']) {
alert(json['error']);
}
$('#button-refresh').trigger('click');
if (json['success']) {
alert(json['success']);
$('#button-refresh').trigger('click');
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
*/
});
});
}
}, 500);
});
function upload() {
alert('hi');
}
$('#button-folder').popover({
html: true,
placement: 'bottom',
Expand Down
100 changes: 52 additions & 48 deletions upload/admin/view/template/extension/installer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,57 +65,61 @@ $('#button-upload').on('click', function() {
$('#form-upload input[name=\'file\']').trigger('click');
$('#form-upload input[name=\'file\']').on('change', function() {
// Reset everything
$('.alert').remove();
$('#progress-bar').css('width', '0%');
$('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
$('#progress-text').html('');
$.ajax({
url: 'index.php?route=extension/installer/upload&token=<?php echo $token; ?>',
type: 'post',
dataType: 'json',
data: new FormData($(this).parent()[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').button('loading');
},
complete: function() {
$('#button-upload').button('reset');
},
success: function(json) {
if (json['error']) {
$('#progress-bar').addClass('progress-bar-danger');
$('#progress-text').html('<div class="text-danger">' + json['error'] + '</div>');
}
if (json['step']) {
step = json['step'];
total = step.length;
timer = setInterval(function() {
if ($('#form-upload input[name=\'file\']').val() != '') {
clearInterval(timer);
// Reset everything
$('.alert').remove();
$('#progress-bar').css('width', '0%');
$('#progress-bar').removeClass('progress-bar-danger progress-bar-success');
$('#progress-text').html('');
$.ajax({
url: 'index.php?route=extension/installer/upload&token=<?php echo $token; ?>',
type: 'post',
dataType: 'json',
data: new FormData($('#form-upload')[0]),
cache: false,
contentType: false,
processData: false,
beforeSend: function() {
$('#button-upload').button('loading');
},
complete: function() {
$('#button-upload').button('reset');
},
success: function(json) {
if (json['error']) {
$('#progress-bar').addClass('progress-bar-danger');
$('#progress-text').html('<div class="text-danger">' + json['error'] + '</div>');
}
if (json['overwrite'].length) {
html = '';
for (i = 0; i < json['overwrite'].length; i++) {
html += json['overwrite'][i] + "\n";
}
if (json['step']) {
step = json['step'];
total = step.length;
$('#overwrite').html(html);
$('#button-continue').prop('disabled', false);
} else {
next();
}
if (json['overwrite'].length) {
html = '';
for (i = 0; i < json['overwrite'].length; i++) {
html += json['overwrite'][i] + "\n";
}
$('#overwrite').html(html);
$('#button-continue').prop('disabled', false);
} else {
next();
}
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
});
}
}, 500);
});
$('#button-continue').on('click', function() {
Expand Down
Loading

0 comments on commit 36effb1

Please sign in to comment.