Save As: UI for changing the document name.
Change-Id: I23aba95ff0f8d867b021ba3cf0a6bc5eb4754f9d Reviewed-on: https://gerrit.libreoffice.org/44282 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
This commit is contained in:
parent
8568f47667
commit
513ffe36c1
5 changed files with 67 additions and 0 deletions
2
loleaflet/dist/loleaflet.html
vendored
2
loleaflet/dist/loleaflet.html
vendored
|
@ -53,6 +53,8 @@
|
|||
<input id="insertgraphic" type="file" style="position: fixed; top: -100em">
|
||||
</div>
|
||||
|
||||
<input id="document-name-input" type="text" disabled="true"/>
|
||||
|
||||
<div id="closebuttonwrapper">
|
||||
<div class="closebuttonimage" id="closebutton"></div>
|
||||
</div>
|
||||
|
|
25
loleaflet/dist/toolbar.css
vendored
25
loleaflet/dist/toolbar.css
vendored
|
@ -72,6 +72,31 @@
|
|||
width: 700px;
|
||||
}
|
||||
|
||||
#document-name-input {
|
||||
position: fixed;
|
||||
z-index: 1050;
|
||||
right: 35px;
|
||||
top: 2px;
|
||||
width: 200px;
|
||||
font-size: 16px;
|
||||
//font-weight: bold;
|
||||
border: 1px solid transparent;
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
#document-name-input.editable:focus {
|
||||
border: 1px solid #bbbbbb;
|
||||
background-color: white;
|
||||
}
|
||||
|
||||
#document-name-input.editable:hover {
|
||||
border: 1px solid #bbbbbb;
|
||||
background-color: white;
|
||||
background-image: url('../images/lc_editdoc.svg');
|
||||
background-position: right;
|
||||
background-repeat: no-repeat;
|
||||
}
|
||||
|
||||
#closebuttonwrapper {
|
||||
position: fixed;
|
||||
z-index: 1050;
|
||||
|
|
37
loleaflet/dist/toolbar/toolbar.js
vendored
37
loleaflet/dist/toolbar/toolbar.js
vendored
|
@ -812,6 +812,27 @@ function onSearchKeyPress(e) {
|
|||
}
|
||||
}
|
||||
|
||||
function documentNameConfirm() {
|
||||
var value = $('#document-name-input').val();
|
||||
if (value !== null && value != '') {
|
||||
map.saveAs(value);
|
||||
}
|
||||
map._onGotFocus();
|
||||
}
|
||||
|
||||
function documentNameCancel() {
|
||||
$('#document-name-input').val(map['wopi'].BaseFileName);
|
||||
map._onGotFocus();
|
||||
}
|
||||
|
||||
function onDocumentNameKeyPress(e) {
|
||||
if (e.keyCode === 13) { // Enter key
|
||||
documentNameConfirm();
|
||||
} else if (e.keyCode === 27) { // Escape key
|
||||
documentNameCancel();
|
||||
}
|
||||
}
|
||||
|
||||
function sortFontSizes() {
|
||||
var oldVal = $('.fontsizes-select').val();
|
||||
var selectList = $('.fontsizes-select option');
|
||||
|
@ -1000,6 +1021,22 @@ map.on('wopiprops', function(e) {
|
|||
evt.preventDefault();
|
||||
});
|
||||
}
|
||||
if (e.BaseFileName !== null) {
|
||||
// set the document name into the name field
|
||||
$('#document-name-input').val(e.BaseFileName);
|
||||
}
|
||||
if (e.UserCanNotWriteRelative === false) {
|
||||
// Save As allowed
|
||||
$('#document-name-input').prop('disabled', false);
|
||||
$('#document-name-input').addClass('editable');
|
||||
$('#document-name-input').on('keypress', onDocumentNameKeyPress);
|
||||
$('#document-name-input').on('focus', function() { map._onLostFocus(); /* hide the caret in the main document */ });
|
||||
$('#document-name-input').on('blur', documentNameCancel);
|
||||
} else {
|
||||
$('#document-name-input').prop('disabled', true);
|
||||
$('#document-name-input').removeClass('editable');
|
||||
$('#document-name-input').off('keypress', onDocumentNameKeyPress);
|
||||
}
|
||||
});
|
||||
|
||||
map.on('doclayerinit', function () {
|
||||
|
|
|
@ -8,6 +8,7 @@ L.Map.WOPI = L.Handler.extend({
|
|||
// So use '*' because we still needs to send 'close' message to the parent frame which
|
||||
// wouldn't be possible otherwise.
|
||||
PostMessageOrigin: '*',
|
||||
BaseFileName: '',
|
||||
DocumentLoadedTime: false,
|
||||
HidePrintOption: false,
|
||||
HideSaveOption: false,
|
||||
|
@ -61,6 +62,7 @@ L.Map.WOPI = L.Handler.extend({
|
|||
this.PostMessageOrigin = wopiInfo['PostMessageOrigin'];
|
||||
}
|
||||
|
||||
this.BaseFileName = wopiInfo['BaseFileName'];
|
||||
this.HidePrintOption = !!wopiInfo['HidePrintOption'];
|
||||
this.HideSaveOption = !!wopiInfo['HideSaveOption'];
|
||||
this.HideExportOption = !!wopiInfo['HideExportOption'];
|
||||
|
|
|
@ -463,6 +463,7 @@ bool DocumentBroker::load(const std::shared_ptr<ClientSession>& session, const s
|
|||
if (wopifileinfo->_disableExport)
|
||||
wopifileinfo->_hideExportOption = true;
|
||||
|
||||
wopiInfo->set("BaseFileName", wopiStorage->getFileInfo()._filename);
|
||||
wopiInfo->set("HidePrintOption", wopifileinfo->_hidePrintOption);
|
||||
wopiInfo->set("HideSaveOption", wopifileinfo->_hideSaveOption);
|
||||
wopiInfo->set("HideExportOption", wopifileinfo->_hideExportOption);
|
||||
|
|
Loading…
Reference in a new issue