+ }, 'json').fail(failModal('Nie udało się utworzyć katalogu'));
+ });
+
+ $('#rename-form').on('show.bs.modal', function() {
+ $(this).find('#id_dst').val(filex.selectedFiles()[0].get('name'));
+ }).on('submit', function(e) {
+ e.preventDefault();
+
+ var $this = $(this),
+ path = filex.path.full() + '/',
+ newName = $this.find('#id_dst').val(),
+ data = {
+ host: filex.host,
+ src: path + filex.selectedFiles()[0].get('name'),
+ dst: path + newName
+ };
+
+ if (conflictingName(newName, $this))
+ return;
+
+ filex.busy();
+ $this.modal('hide');
+
+ $.post($this.attr('action'), data, 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_archive').val(),
+ type = $this.find('#id_type').val(),
+ path = filex.path.full(),
+ archive = name + (name.endsWith(type) ? '' : type),
+ data = {
+ host: filex.host,
+ path: path,
+ files: _.map(filex.selectedFiles(), function (item) { return item.get('name') }),
+ archive: path + '/' + archive
+ };
+
+ if (conflictingName(archive, $this))
+ 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,
+ path: 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'));