+ }, 'json').fail(failModal('Nie udało się utworzyć katalogu'));
+ });
+
+ $('#rename-form').on('show.bs.modal', function() {
+ var $this = $(this);
+
+ var file = filex.selectedFiles()[0];
+
+ $this.find('#id_host').val(filex.host);
+ $this.find('#id_path').val(filex.path.full());
+ $this.find('#id_src').val(file.get('name'));
+ $this.find('#id_dst').val(file.get('name'));
+ }).on('submit', function(e) {
+ var $this = $(this);
+
+ e.preventDefault();
+ filex.busy();
+ $this.modal('hide');
+
+ $.post($this.attr('action'), $this.serialize(), function() {
+ status('Nazwę zmieniono pomyślnie');
+ filex.reloadFiles();
+ }, 'json').fail(failModal('Nie udało się zmienić nazwy'));
+ });
+
+ $('#compress-form').on('submit', function(e) {
+ e.preventDefault();
+
+ var $this = $(this),
+ name = $this.find('#id_name').val(),
+ type = $this.find('#id_type').val(),
+ archive = name + (name.endsWith(type) ? '' : type),
+ data = {
+ host: filex.host,
+ path: filex.path.full(),
+ files: _.map(filex.selectedFiles(), function (item) { return item.get('name') }),
+ archive: archive
+ };
+
+ // check if maybe file with given name exists
+ if (filex.files.some(function(item) { return item.get('name') == archive })) {
+ $this.find('.alert').remove();
+
+ $('<div>', {
+ 'class': 'alert alert-danger',
+ html: '<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span> Plik o podanej już nazwie istnieje!'
+ }).prependTo($this.find('.modal-body'));
+
+ return;
+ }
+
+ filex.busy();
+ $this.modal('hide');
+
+ $.post($this.attr('action'), data, function() {
+ status('Archiwum utworzono pomyślnie');
+ filex.reloadFiles();
+ }, 'json').fail(failModal('Nie udało się utworzyć archiwum'));
+ });
+
+ $('#btn-extract').on('click', function() {
+ filex.busy();
+
+ var data = {
+ host: filex.host,
+ archive: filex.path.full() + '/' + filex.selectedFiles()[0].get('name'),
+ dst: filex.path.full()
+ };
+
+ $.post('{% url 'filex:extract' %}', data, function() {
+ status('Archiwum rozpakowano pomyślnie');
+ filex.reloadFiles();
+ }, 'json').fail(failModal('Nie udało się rozpakować archiwum'));