diff options
author | Vincent Petry <pvince81@owncloud.com> | 2015-08-27 13:22:58 +0200 |
---|---|---|
committer | Vincent Petry <pvince81@owncloud.com> | 2015-08-28 17:27:48 +0200 |
commit | 59273a8863ecc0aa570f56e024cb1a22d424111a (patch) | |
tree | de68a1c0978ec00e3dd81a9862a7cc51e9408b5c /apps/files/js/file-upload.js | |
parent | efeef958a3e707c06f25dc6e473d1b49edf88b07 (diff) | |
download | nextcloud-server-59273a8863ecc0aa570f56e024cb1a22d424111a.tar.gz nextcloud-server-59273a8863ecc0aa570f56e024cb1a22d424111a.zip |
Combine upload action into the "New" menu
Refactored the new menu to be encapsulated in the NewFileMenu JS class
Diffstat (limited to 'apps/files/js/file-upload.js')
-rw-r--r-- | apps/files/js/file-upload.js | 149 |
1 files changed, 0 insertions, 149 deletions
diff --git a/apps/files/js/file-upload.js b/apps/files/js/file-upload.js index 6b6acdb5e01..17f0f777169 100644 --- a/apps/files/js/file-upload.js +++ b/apps/files/js/file-upload.js @@ -551,155 +551,6 @@ OC.Upload = { $('#file_upload_start').attr('multiple', 'multiple'); } - $(document).click(function(ev) { - // do not close when clicking in the dropdown - if ($(ev.target).closest('#new').length){ - return; - } - $('#new>ul').hide(); - $('#new').removeClass('active'); - if ($('#new .error').length > 0) { - $('#new .error').tipsy('hide'); - } - $('#new li').each(function(i,element) { - if ($(element).children('p').length === 0) { - $(element).children('form').remove(); - $(element).append('<p>' + $(element).data('text') + '</p>'); - } - }); - }); - $('#new').click(function(event) { - event.stopPropagation(); - }); - $('#new>a').click(function() { - $('#new>ul').toggle(); - $('#new').toggleClass('active'); - }); - $('#new li').click(function() { - if ($(this).children('p').length === 0) { - return; - } - - $('#new .error').tipsy('hide'); - - $('#new li').each(function(i, element) { - if ($(element).children('p').length === 0) { - $(element).children('form').remove(); - $(element).append('<p>' + $(element).data('text') + '</p>'); - } - }); - - var type = $(this).data('type'); - var text = $(this).children('p').text(); - $(this).data('text', text); - $(this).children('p').remove(); - - // add input field - var form = $('<form></form>'); - var input = $('<input type="text">'); - var newName = $(this).attr('data-newname') || ''; - var fileType = 'input-' + $(this).attr('data-type'); - if (newName) { - input.val(newName); - input.attr('id', fileType); - } - var label = $('<label class="hidden-visually" for="">' + escapeHTML(newName) + '</label>'); - label.attr('for', fileType); - - form.append(label).append(input); - $(this).append(form); - var lastPos; - var checkInput = function () { - var filename = input.val(); - if (!Files.isFileNameValid(filename)) { - // Files.isFileNameValid(filename) throws an exception itself - } else if (FileList.inList(filename)) { - throw t('files', '{new_name} already exists', {new_name: filename}); - } else { - return true; - } - }; - - // verify filename on typing - input.keyup(function(event) { - try { - checkInput(); - input.tipsy('hide'); - input.removeClass('error'); - } catch (error) { - input.attr('title', error); - input.tipsy({gravity: 'w', trigger: 'manual'}); - input.tipsy('show'); - input.addClass('error'); - } - }); - - input.focus(); - // pre select name up to the extension - lastPos = newName.lastIndexOf('.'); - if (lastPos === -1) { - lastPos = newName.length; - } - input.selectRange(0, lastPos); - form.submit(function(event) { - event.stopPropagation(); - event.preventDefault(); - try { - checkInput(); - var newname = input.val(); - if (FileList.lastAction) { - FileList.lastAction(); - } - var name = FileList.getUniqueName(newname); - switch(type) { - case 'file': - $.post( - OC.filePath('files', 'ajax', 'newfile.php'), - { - dir: FileList.getCurrentDirectory(), - filename: name - }, - function(result) { - if (result.status === 'success') { - FileList.add(result.data, {animate: true, scrollTo: true}); - } else { - OC.dialogs.alert(result.data.message, t('core', 'Could not create file')); - } - } - ); - break; - case 'folder': - $.post( - OC.filePath('files','ajax','newfolder.php'), - { - dir: FileList.getCurrentDirectory(), - foldername: name - }, - function(result) { - if (result.status === 'success') { - FileList.add(result.data, {animate: true, scrollTo: true}); - } else { - OC.dialogs.alert(result.data.message, t('core', 'Could not create folder')); - } - } - ); - break; - } - var li = form.parent(); - form.remove(); - /* workaround for IE 9&10 click event trap, 2 lines: */ - $('input').first().focus(); - $('#content').focus(); - li.append('<p>' + li.data('text') + '</p>'); - $('#new>a').click(); - } catch (error) { - input.attr('title', error); - input.tipsy({gravity: 'w', trigger: 'manual'}); - input.tipsy('show'); - input.addClass('error'); - } - }); - }); window.file_upload_param = file_upload_param; return file_upload_param; } |