Split the menu entry for external shares in two

The external shares entry showed a "button" that, when pressed, replaced
the button with the input to set the remote share address. The "button"
was actually a label for the input, so when the label was focused it
transferred the focus to the input and thus pressing enter or space did
not show the input. Moreover, inputs inside links are not valid HTML,
and once shown there was no way to hide the input again.

Due to all this, and for consistency with the direct link input, the
external share input was moved to a different menu item that is shown
and hidden when the button, which nows is also a real button, is
clicked.

Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
Daniel Calviño Sánchez 2019-11-07 21:30:56 +01:00
parent 33b2f4e295
commit 883a71ce8e
3 changed files with 9 additions and 10 deletions

View File

@ -21,10 +21,9 @@ $footer-height: 65px;
opacity: 1; opacity: 1;
} }
} }
#save-external-share { #external-share-menu-item {
form { form {
display: flex; display: flex;
margin: 0;
} }
.hidden { .hidden {
display: none; display: none;

View File

@ -26,9 +26,8 @@ $(document).ready(function () {
$(this).next('.popovermenu').toggleClass('open'); $(this).next('.popovermenu').toggleClass('open');
}); });
$('#save-external-share').find('label').click(function () { $('#save-external-share').click(function () {
$(this).toggleClass('hidden'); $('#external-share-menu-item').toggleClass('hidden')
$('.save-form').toggleClass('hidden')
$('#remote_address').focus(); $('#remote_address').focus();
}); });

View File

@ -67,14 +67,15 @@ class ExternalShareMenuAction extends SimpleMenuAction {
*/ */
public function render(): string { public function render(): string {
return '<li>' . return '<li>' .
' <a id="save-external-share" data-protected="false" data-owner-display-name="' . Util::sanitizeHTML($this->displayname) . '" data-owner="' . Util::sanitizeHTML($this->owner) . '" data-name="' . Util::sanitizeHTML($this->shareName) . '">' . ' <button id="save-external-share" class="icon ' . Util::sanitizeHTML($this->getIcon()) . '" data-protected="false" data-owner-display-name="' . Util::sanitizeHTML($this->displayname) . '" data-owner="' . Util::sanitizeHTML($this->owner) . '" data-name="' . Util::sanitizeHTML($this->shareName) . '">' . Util::sanitizeHTML($this->getLabel()) . '</button>' .
' <span class="icon ' . Util::sanitizeHTML($this->getIcon()) . '"></span>' . '</li>' .
' <label for="remote_address">' . Util::sanitizeHTML($this->getLabel()) . '</label>' . '<li id="external-share-menu-item" class="hidden">' .
' <form class="save-form hidden" action="#">' . ' <span class="menuitem">' .
' <form class="save-form" action="#">' .
' <input type="text" id="remote_address" placeholder="user@yourNextcloud.org">' . ' <input type="text" id="remote_address" placeholder="user@yourNextcloud.org">' .
' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' . ' <input type="submit" value=" " id="save-button-confirm" class="icon-confirm" disabled="disabled"></button>' .
' </form>' . ' </form>' .
' </a>' . ' </span>' .
'</li>'; '</li>';
} }
} }