diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2018-03-08 21:09:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-08 21:09:44 +0100 |
commit | 7e374200c4eef0e2b61076857acaed5fcdee286a (patch) | |
tree | 50c18ee31a5a92765f3c943731c3187e3711f070 /apps | |
parent | 633d0581a333e86fd55006e8803152ecc2ea50ec (diff) | |
parent | cee5be6ff262cf28af81a10c18e8cfd415b129aa (diff) | |
download | nextcloud-server-7e374200c4eef0e2b61076857acaed5fcdee286a.tar.gz nextcloud-server-7e374200c4eef0e2b61076857acaed5fcdee286a.zip |
Merge pull request #8575 from nextcloud/new-folder-button
Updated popover rules to allow form inputs and added input submit for…
Diffstat (limited to 'apps')
-rw-r--r-- | apps/files/css/files.scss | 13 | ||||
-rw-r--r-- | apps/files/js/newfilemenu.js | 15 | ||||
-rw-r--r-- | apps/files/tests/js/newfilemenuSpec.js | 3 | ||||
-rw-r--r-- | apps/files_sharing/css/public.scss | 19 | ||||
-rw-r--r-- | apps/files_sharing/js/public.js | 46 | ||||
-rw-r--r-- | apps/files_sharing/lib/Template/ExternalShareMenuAction.php | 14 |
6 files changed, 47 insertions, 63 deletions
diff --git a/apps/files/css/files.scss b/apps/files/css/files.scss index 1be58cff5a1..f2d2e7d54f3 100644 --- a/apps/files/css/files.scss +++ b/apps/files/css/files.scss @@ -38,10 +38,11 @@ font-weight: normal; } -.newFileMenu .error, #fileList .error { +.newFileMenu .error, +.newFileMenu .error + .icon-confirm, +#fileList .error { color: $color-error; border-color: $color-error; - box-shadow: 0 0 6px #f8b9b7; } /* FILE TABLE */ @@ -696,14 +697,6 @@ table.dragshadow td.size { z-index: 1001; } -.newFileMenu .filenameform { - display: inline-block; -} - -.newFileMenu .filenameform input { - margin: 2px 0; -} - #filestable .filename .action .icon, #filestable .selectedActions a .icon, #filestable .filename .favorite-mark .icon, diff --git a/apps/files/js/newfilemenu.js b/apps/files/js/newfilemenu.js index 18d9104dc40..a340b8b6218 100644 --- a/apps/files/js/newfilemenu.js +++ b/apps/files/js/newfilemenu.js @@ -26,8 +26,8 @@ var TEMPLATE_FILENAME_FORM = '<form class="filenameform">' + - '<label class="hidden-visually" for="{{cid}}-input-{{fileType}}">{{fileName}}</label>' + '<input id="{{cid}}-input-{{fileType}}" type="text" value="{{fileName}}" autocomplete="off" autocapitalize="off">' + + '<input type="submit" value=" " class="icon-confirm" />' '</form>'; /** @@ -116,7 +116,7 @@ } if ($target.find('form').length) { - $target.find('input').focus(); + $target.find('input[type=\'text\']').focus(); return; } @@ -138,7 +138,8 @@ $target.append($form); // here comes the OLD code - var $input = $form.find('input'); + var $input = $form.find('input[type=\'text\']'); + var $submit = $form.find('input[type=\'submit\']'); var lastPos; var checkInput = function () { @@ -155,7 +156,7 @@ } } catch (error) { $input.attr('title', error); - $input.tooltip({placement: 'right', trigger: 'manual'}); + $input.tooltip({placement: 'right', trigger: 'manual', 'container': '.newFileMenu'}); $input.tooltip('fixTitle'); $input.tooltip('show'); $input.addClass('error'); @@ -171,6 +172,12 @@ } }); + $submit.click(function(event) { + event.stopPropagation(); + event.preventDefault(); + $form.submit(); + }); + $input.focus(); // pre select name up to the extension lastPos = newName.lastIndexOf('.'); diff --git a/apps/files/tests/js/newfilemenuSpec.js b/apps/files/tests/js/newfilemenuSpec.js index 20f617d24d6..af998c14916 100644 --- a/apps/files/tests/js/newfilemenuSpec.js +++ b/apps/files/tests/js/newfilemenuSpec.js @@ -67,7 +67,8 @@ describe('OCA.Files.NewFileMenu', function() { }); it('sets default text in field', function() { - expect($input.length).toEqual(1); + // text + submit + expect($input.length).toEqual(2); expect($input.val()).toEqual('New folder'); }); it('prevents entering invalid file names', function() { diff --git a/apps/files_sharing/css/public.scss b/apps/files_sharing/css/public.scss index e040d449129..cc3788884e7 100644 --- a/apps/files_sharing/css/public.scss +++ b/apps/files_sharing/css/public.scss @@ -105,25 +105,8 @@ thead { border-color: rgba(0,0,0,0.3) !important; } -/* within #save */ -#save .save-form { - position: relative; - margin-right: -10px; -} - -#remote_address { +#share-menu input[type='text'] { width: 200px; - margin-right: 4px; - height: 31px; -} - -#save-button-confirm { - position: absolute; - background-color: transparent; - border: none; - margin: 0; - right: 0px; - height: 40px; } #public-upload .avatardiv { diff --git a/apps/files_sharing/js/public.js b/apps/files_sharing/js/public.js index ae19500080b..4b3ede24389 100644 --- a/apps/files_sharing/js/public.js +++ b/apps/files_sharing/js/public.js @@ -271,19 +271,13 @@ OCA.Sharing.PublicApp = { }); $('#remote_address').on("keyup paste", function() { - if ($(this).val() === '') { + if ($(this).val() === '' || $('#save > .icon.icon-loading-small').length > 0) { $('#save-button-confirm').prop('disabled', true); } else { $('#save-button-confirm').prop('disabled', false); } }); - $('#save #save-button').click(function () { - $(this).hide(); - $('.save-form').css('display', 'inline'); - $('#remote_address').focus(); - }); - // legacy window.FileList = this.fileList; }, @@ -329,6 +323,7 @@ OCA.Sharing.PublicApp = { */ _legacyCreateFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { + var self = this; var location = window.location.protocol + '//' + window.location.host + OC.webroot; if(remote.substr(-1) !== '/') { @@ -346,6 +341,7 @@ OCA.Sharing.PublicApp = { // this check needs to happen on the server due to the Content Security Policy directive $.get(OC.generateUrl('apps/files_sharing/testremote'), {remote: remote}).then(function (protocol) { if (protocol !== 'http' && protocol !== 'https') { + self._toggleLoading(); OC.dialogs.alert(t('files_sharing', 'No compatible server found at {remote}', {remote: remote}), t('files_sharing', 'Invalid server URL')); } else { @@ -355,30 +351,30 @@ OCA.Sharing.PublicApp = { } }, - _createFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { + _toggleLoading: function() { + var loading = $('#save > .icon.icon-loading-small').length === 0; + if (loading) { + $('#save > .icon-external') + .removeClass("icon-external") + .addClass("icon-loading-small"); + $('#save #save-button-confirm').prop("disabled", true); - var toggleLoading = function() { - var iconClass = $('#save-button-confirm').attr('class'); - var loading = iconClass.indexOf('icon-loading-small') !== -1; - if(loading) { - $('#save-button-confirm') - .removeClass("icon-loading-small") - .addClass("icon-confirm"); + } else { + $('#save > .icon-loading-small') + .addClass("icon-external") + .removeClass("icon-loading-small"); + $('#save #save-button-confirm').prop("disabled", false); - } - else { - $('#save-button-confirm') - .removeClass("icon-confirm") - .addClass("icon-loading-small"); + } + }, - } - }; + _createFederatedShare: function (remote, token, owner, ownerDisplayName, name, isProtected) { + var self = this; - toggleLoading(); + this._toggleLoading(); if (remote.indexOf('@') === -1) { this._legacyCreateFederatedShare(remote, token, owner, ownerDisplayName, name, isProtected); - toggleLoading(); return; } @@ -402,7 +398,7 @@ OCA.Sharing.PublicApp = { function (jqXHR) { OC.dialogs.alert(JSON.parse(jqXHR.responseText).message, t('files_sharing', 'Failed to add the public link to your Nextcloud')); - toggleLoading(); + self._toggleLoading(); } ); } diff --git a/apps/files_sharing/lib/Template/ExternalShareMenuAction.php b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php index f548a3bc6f1..e30a77cb2e6 100644 --- a/apps/files_sharing/lib/Template/ExternalShareMenuAction.php +++ b/apps/files_sharing/lib/Template/ExternalShareMenuAction.php @@ -57,12 +57,16 @@ class ExternalShareMenuAction extends SimpleMenuAction { return '<li>' . '<a id="save" data-protected="false" data-owner-display-name="' . Util::sanitizeHTML($this->displayname) . '" data-owner="' . Util::sanitizeHTML($this->owner) . '" data-name="' . Util::sanitizeHTML($this->shareName) . '">' . '<span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . - '<span id="save-button">' . Util::sanitizeHTML($this->getLabel()) . '</span>' . - '<form class="save-form hidden" action="#">' . + '<label for="remote_address">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . + '</a>' . + '</li>' . + '<li>' . + '<span class="menuitem">' . + '<form class="save-form" action="#">' . '<input type="text" id="remote_address" placeholder="user@yourNextcloud.org">' . - '<button id="save-button-confirm" class="icon-confirm svg" disabled=""></button>' . + '<input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . '</form>' . - '</a>' . + '</span>' . '</li>'; } -}
\ No newline at end of file +} |