+ submit: function (e, data) {
+ var file = data.files[0],
+ $this = $(this);
+
+ data.context.find('.progress-info').text('Przetwarzanie');
+
+ function finish(action) {
+ if (action == 'replace')
+ data.jqXHR = $this.fileupload('send', data);
+ else
+ data.context.find('.progress-info').text('Pominięto');
+ }
+
+ $.getJSON('{% url 'filex:info' %}', {host: host, path: path + '/' + file.name}, function(response) {
+ if (applyToAll != undefined) {
+ finish(applyToAll);
+ return;
+ }
+
+ $conflictStack = $conflictStack.then(function() {
+ if (applyToAll != undefined) {
+ finish(applyToAll);
+ return;
+ }
+
+ var deferred = $.Deferred();
+
+ $conflict.one('hidden.bs.modal', function() {
+ deferred.resolve();
+ });
+
+ $('#btn-skip').off().on('click', function() {
+ if ($('#apply-to-all').prop('checked')) {
+ applyToAll = 'skip';
+ }
+
+ $conflict.modal('hide');
+ finish('skip');
+ });
+ $('#btn-replace').off().on('click', function() {
+ if ($('#apply-to-all').prop('checked')) {
+ applyToAll = 'replace';
+ }
+
+ $conflict.modal('hide');
+ finish('replace');
+ });
+
+ $conflict.find('.modal-body').html(conflictTemplate({
+ name: file.name,
+ srcDate: moment(file.lastModified),
+ srcSize: humanBytes(file.size),
+ dstDate: moment(response.date),
+ dstSize: humanBytes(response.size)
+ }));
+ $conflict.modal('show');
+
+ return deferred.promise();
+ });
+
+ }).fail(function(xhr, textStatus) {
+ // if file does not exist we are good to go
+ if (xhr.status == 404)
+ finish('replace');
+ else {
+ data.context.find('.progress-info').text('Błąd');
+ console.error("Info query failed: " + textStatus);
+ }
+ });
+
+ return false;
+ },