remove-w2ui: use JSDialog for formulabar
- remove w2toolbar - use JSDialog instead - remove Leaflet class, use ES6 class Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: I94fd17983cd727eefdd5b43f5b93d4319f15f3b0pull/8575/head
parent
464358ca70
commit
bde997dfa8
|
@ -366,7 +366,6 @@ COOL_JS_LST =\
|
|||
src/control/Control.MobileTopBar.js \
|
||||
src/control/Control.MobileBottomBar.js \
|
||||
src/control/Control.UserList.ts \
|
||||
src/control/Control.FormulaBar.js \
|
||||
src/control/Control.FormulaBarJSDialog.js \
|
||||
src/control/Control.SheetsBar.js \
|
||||
src/control/Control.PresentationBar.js \
|
||||
|
@ -758,7 +757,6 @@ pot:
|
|||
src/control/Control.DocumentNameInput.js \
|
||||
src/control/Control.DocumentRepair.js \
|
||||
src/control/Control.DownloadProgress.js \
|
||||
src/control/Control.FormulaBar.js \
|
||||
src/control/Control.FormulaBarJSDialog.js \
|
||||
src/control/Control.IdleHandler.ts \
|
||||
src/control/Control.JSDialogBuilder.js \
|
||||
|
|
|
@ -182,17 +182,6 @@ div#w2ui-overlay-actionbar.w2ui-overlay{
|
|||
#document-name-input {
|
||||
display: none;
|
||||
}
|
||||
/* Related to selectionMarkers.css */
|
||||
.inputbar_multiline #tb_formulabar_item_formula > div,
|
||||
.inputbar_multiline #tb_formulabar_item_address > div {
|
||||
margin-top: 0px;
|
||||
}
|
||||
.inputbar_multiline #tb_formulabar_item_address{
|
||||
border-right: solid 1px #0000004d !important;
|
||||
}
|
||||
.inputbar_multiline #addressInput{
|
||||
border: none;
|
||||
}
|
||||
|
||||
.spreadsheet-tab-selected{
|
||||
color: #0b87e7 !important;
|
||||
|
@ -287,15 +276,16 @@ nav:not(.spreadsheet-color-indicator) ~ #toolbar-wrapper #toolbar-up.w2ui-toolba
|
|||
margin: 0 !important;
|
||||
}
|
||||
#expand.formulabar {
|
||||
margin-inline-start: -8px !important
|
||||
margin-inline-start: -8px !important;
|
||||
height: 30px !important;
|
||||
}
|
||||
.formulabar.toolbox {
|
||||
grid-column-gap: 8px;
|
||||
/* fx = inputfield expander */
|
||||
grid-template-columns: 24px auto 16px 0;
|
||||
grid-template-columns: 32px auto 16px 0;
|
||||
display: grid;
|
||||
grid-auto-flow: column;
|
||||
align-items: center;
|
||||
align-items: start;
|
||||
}
|
||||
.expanded .formulabar.toolbox {
|
||||
align-items: flex-start;
|
||||
|
@ -304,6 +294,9 @@ nav:not(.spreadsheet-color-indicator) ~ #toolbar-wrapper #toolbar-up.w2ui-toolba
|
|||
padding: 0px !important;
|
||||
border-top: 1px solid #bbbbbb !important;
|
||||
}
|
||||
#formulabar > div > div {
|
||||
grid-template-columns: 70px auto;
|
||||
}
|
||||
#toolbar-search {
|
||||
height: 39px !important;
|
||||
}
|
||||
|
@ -339,25 +332,11 @@ nav:not(.spreadsheet-color-indicator) ~ #toolbar-wrapper #toolbar-up.w2ui-toolba
|
|||
#addressInput{
|
||||
margin-inline-start: 8px;
|
||||
width: 50px;
|
||||
height: 23px;
|
||||
text-align: center;
|
||||
border-color: 1px solid #808080 !important;
|
||||
height: 26px;
|
||||
align-self: start;
|
||||
}
|
||||
.w2ui-icon.equal, .w2ui-icon.autosum{width: 38px !important;}
|
||||
|
||||
#calc-inputbar-wrapper {
|
||||
display: block;
|
||||
border: none;
|
||||
}
|
||||
|
||||
#calc-inputbar {
|
||||
display: block;
|
||||
width: 100%;
|
||||
position: relative;
|
||||
padding: 0px;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
#toolbar-wrapper.mobile td[id^='tb_actionbar_item'] .w2ui-tb-image {
|
||||
width: 36px !important;
|
||||
}
|
||||
|
|
|
@ -1805,7 +1805,7 @@ input[type='number']:hover::-webkit-outer-spin-button {
|
|||
}
|
||||
|
||||
#expand.formulabar {
|
||||
height: 28px !important;
|
||||
height: 30px !important;
|
||||
margin: 0 !important;
|
||||
border-radius: 0 var(--border-radius) var(--border-radius) 0 !important;
|
||||
border-inline-start: none !important;
|
||||
|
|
|
@ -238,3 +238,33 @@
|
|||
.spreadsheet ~ #main-document-content #sidebar-dock-wrapper .unoEditStyle.sidebar {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* formulabar */
|
||||
|
||||
#addressInput {
|
||||
height: 26px;
|
||||
width: 100px;
|
||||
color: var(--color-main-text);
|
||||
background-color: var(--color-background-lighter);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--border-radius);
|
||||
align-self: start;
|
||||
}
|
||||
|
||||
#formulabar-toolbox > div {
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
#formulabar {
|
||||
background-color: var(--color-main-background);
|
||||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
#formulabar.expanded #addressInput * {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#formulabar > div > div {
|
||||
display: grid;
|
||||
grid-template-columns: 110px auto;
|
||||
}
|
||||
|
|
|
@ -169,26 +169,6 @@ w2ui-toolbar {
|
|||
border-top: 1px solid var(--color-border);
|
||||
}
|
||||
|
||||
#formulabar {
|
||||
background-color: var(--color-main-background);
|
||||
border-top: 1px solid var(--color-border);
|
||||
height: 30px;
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
#formulabar.expanded {
|
||||
padding-block: 5px;
|
||||
}
|
||||
|
||||
#tb_formulabar_item_address {
|
||||
padding-inline-end: 5px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#formulabar.expanded #tb_formulabar_item_address * {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#presentation-toolbar {
|
||||
bottom: 0;
|
||||
background-color: var(--color-main-background);
|
||||
|
@ -245,23 +225,6 @@ w2ui-toolbar {
|
|||
width: 50%;
|
||||
}
|
||||
|
||||
#addressInput {
|
||||
height: 28px;
|
||||
width: 100px;
|
||||
color: var(--color-main-text);
|
||||
background-color: var(--color-background-lighter);
|
||||
border: 1px solid var(--color-border);
|
||||
border-radius: var(--border-radius);
|
||||
}
|
||||
|
||||
#tb_formulabar_item_formula {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#tb_formulabar_item_formula div table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@keyframes textPulse {
|
||||
0% {
|
||||
box-shadow: inset 0 0 2px 1px #f0f0f0, 0 0 0.1px 1px #bbb, 0 0 4px rgba(var(--blue1-txt-primary-color), 0.1);
|
||||
|
|
|
@ -1,196 +0,0 @@
|
|||
/* -*- js-indent-level: 8 -*- */
|
||||
/*
|
||||
* Copyright the Collabora Online contributors.
|
||||
*
|
||||
* SPDX-License-Identifier: MPL-2.0
|
||||
*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
/*
|
||||
* L.Control.FormulaBar
|
||||
*/
|
||||
|
||||
/* global $ w2ui _ */
|
||||
L.Control.FormulaBar = L.Control.extend({
|
||||
|
||||
onAdd: function (map) {
|
||||
this.map = map;
|
||||
this.create();
|
||||
|
||||
map.on('doclayerinit', this.onDocLayerInit, this);
|
||||
map.on('updatepermission', this.onUpdatePermission, this);
|
||||
|
||||
map.on('celladdress', function (e) {
|
||||
if (document.activeElement !== L.DomUtil.get('addressInput')) {
|
||||
// if the user is not editing the address field
|
||||
L.DomUtil.get('addressInput').value = e.address;
|
||||
}
|
||||
map.formulabarSetDirty();
|
||||
});
|
||||
},
|
||||
|
||||
create: function() {
|
||||
var that = this;
|
||||
var toolbar = $('#formulabar');
|
||||
toolbar.w2toolbar({
|
||||
name: 'formulabar',
|
||||
hidden: true,
|
||||
items: [
|
||||
{type: 'html', id: 'left'},
|
||||
{type: 'html', id: 'address', html: '<input id="addressInput" type="text">'},
|
||||
{type: 'html', id: 'formula', html: '<div id="calc-inputbar-wrapper"><div id="calc-inputbar"></div></div>'}
|
||||
],
|
||||
onClick: function (e) {
|
||||
that.onClick(e, e.target);
|
||||
window.hideTooltip(this, e.target);
|
||||
},
|
||||
onRefresh: function() {
|
||||
$('#addressInput').off('keyup', that.onAddressInput.bind(that)).on('keyup', that.onAddressInput.bind(that));
|
||||
}
|
||||
});
|
||||
this.map.uiManager.enableTooltip(toolbar);
|
||||
document.getElementById('addressInput').setAttribute('aria-label', _('cell address'));
|
||||
|
||||
toolbar.bind('touchstart', function(e) {
|
||||
w2ui['formulabar'].touchStarted = true;
|
||||
var touchEvent = e.originalEvent;
|
||||
if (touchEvent && touchEvent.touches.length > 1) {
|
||||
L.DomEvent.preventDefault(e);
|
||||
}
|
||||
});
|
||||
|
||||
$(w2ui.formulabar.box).find('.w2ui-scroll-left, .w2ui-scroll-right').hide();
|
||||
w2ui.formulabar.on('resize', function(target, e) {
|
||||
e.isCancelled = true;
|
||||
});
|
||||
},
|
||||
|
||||
onClick: function(e, id, item) {
|
||||
if ('formulabar' in w2ui && w2ui['formulabar'].get(id) !== null) {
|
||||
var toolbar = w2ui['formulabar'];
|
||||
item = toolbar.get(id);
|
||||
}
|
||||
|
||||
this.map.preventKeyboardPopup(id);
|
||||
|
||||
if (item.disabled)
|
||||
return;
|
||||
|
||||
if (item.uno)
|
||||
this.map.executeUnoAction(item);
|
||||
},
|
||||
|
||||
onDocLayerInit: function() {
|
||||
var docType = this.map.getDocType();
|
||||
if (docType == 'spreadsheet') {
|
||||
$('#formulabar').show();
|
||||
}
|
||||
},
|
||||
|
||||
onUpdatePermission: function(e) {
|
||||
var formulaBarButtons = ['sum', 'function'];
|
||||
var toolbar = w2ui.formulabar;
|
||||
|
||||
if (e.perm === 'edit') {
|
||||
// Enable formula bar
|
||||
$('#addressInput').prop('disabled', false);
|
||||
this.map.formulabar.enable();
|
||||
|
||||
if (toolbar) {
|
||||
formulaBarButtons.forEach(function(id) {
|
||||
toolbar.enable(id);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Disable formula bar
|
||||
$('#addressInput').prop('disabled', true);
|
||||
this.map.formulabar.disable();
|
||||
|
||||
if (toolbar) {
|
||||
formulaBarButtons.forEach(function(id) {
|
||||
toolbar.disable(id);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onAddressInput: function(e) {
|
||||
if (e.keyCode === 13) {
|
||||
// address control should not have focus anymore
|
||||
L.DomUtil.get('addressInput').blur();
|
||||
this.map.focus();
|
||||
var value = L.DomUtil.get('addressInput').value;
|
||||
var command = {
|
||||
ToPoint : {
|
||||
type: 'string',
|
||||
value: value
|
||||
}
|
||||
|
||||
};
|
||||
this.map.sendUnoCommand('.uno:GoToCell', command);
|
||||
} else if (e.keyCode === 27) { // 27 = esc key
|
||||
this.map.sendUnoCommand('.uno:Cancel');
|
||||
L.DomUtil.get('addressInput').blur();
|
||||
this.map.focus();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
L.Map.include({
|
||||
onFormulaBarFocus: function() {
|
||||
var mobileTopBar = w2ui['actionbar'];
|
||||
var jsdialogFormulabar = this.formulabar;
|
||||
var target = jsdialogFormulabar;
|
||||
|
||||
if (window.mode.isMobile() === true) {
|
||||
mobileTopBar.hide('undo');
|
||||
mobileTopBar.hide('redo');
|
||||
target = mobileTopBar;
|
||||
} else {
|
||||
jsdialogFormulabar.hide('startformula');
|
||||
jsdialogFormulabar.hide('AutoSumMenu');
|
||||
}
|
||||
target.show('cancelformula');
|
||||
target.show('acceptformula');
|
||||
},
|
||||
|
||||
onFormulaBarBlur: function() {
|
||||
// The timeout is needed because we want 'click' event on 'cancel',
|
||||
// 'accept' button to act before we hide these buttons because
|
||||
// once hidden, click event won't be processed.
|
||||
// TODO: Some better way to do it ?
|
||||
var map = this;
|
||||
|
||||
setTimeout(function() {
|
||||
if ($('.leaflet-cursor').is(':visible'))
|
||||
return;
|
||||
var mobileTopBar = w2ui['actionbar'];
|
||||
var jsdialogFormulabar = map.formulabar;
|
||||
|
||||
var target = window.mode.isMobile() ? mobileTopBar : jsdialogFormulabar;
|
||||
target.hide('cancelformula');
|
||||
target.hide('acceptformula');
|
||||
|
||||
mobileTopBar.show('undo');
|
||||
mobileTopBar.show('redo');
|
||||
|
||||
$('#AutoSumMenu-button').css('margin-inline', '0');
|
||||
$('#AutoSumMenu .unoarrow').css('margin', '0');
|
||||
|
||||
jsdialogFormulabar.show('startformula');
|
||||
jsdialogFormulabar.show('AutoSumMenu');
|
||||
|
||||
// clear reference marks
|
||||
map._docLayer._clearReferences();
|
||||
}, 250);
|
||||
|
||||
map.formulabar.blurField();
|
||||
$('#addressInput').blur();
|
||||
}
|
||||
});
|
||||
|
||||
L.control.formulaBar = function (options) {
|
||||
return new L.Control.FormulaBar(options);
|
||||
};
|
|
@ -10,21 +10,24 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* L.Control.FormulaBarJSDialog - implementation of formulabar edit field
|
||||
* JSDialog.FormulaBar - implementation of formulabar toolbar
|
||||
*/
|
||||
|
||||
/* global _ _UNO UNOKey */
|
||||
L.Control.FormulaBarJSDialog = L.Control.extend({
|
||||
container: null,
|
||||
builder: null,
|
||||
/* global JSDialog _ _UNO UNOKey */
|
||||
|
||||
onAdd: function (map) {
|
||||
class FormulaBar {
|
||||
constructor(map) {
|
||||
this.map = map;
|
||||
this.parentContainer = L.DomUtil.get('formulabar');
|
||||
|
||||
this.map.on('formulabar', this.onFormulaBar, this);
|
||||
this.map.on('jsdialogupdate', this.onJSUpdate, this);
|
||||
this.map.on('jsdialogaction', this.onJSAction, this);
|
||||
|
||||
this.map.on('doclayerinit', this.onDocLayerInit, this);
|
||||
this.map.on('updatepermission', this.onUpdatePermission, this);
|
||||
this.map.on('celladdress', this.onCellAddress, this);
|
||||
|
||||
this.builder = new L.control.jsDialogBuilder(
|
||||
{
|
||||
mobileWizard: this,
|
||||
|
@ -32,17 +35,72 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
cssClass: 'formulabar jsdialog',
|
||||
callback: this.callback.bind(this)
|
||||
});
|
||||
},
|
||||
|
||||
onRemove: function() {
|
||||
this.createFormulabar('');
|
||||
}
|
||||
|
||||
onRemove() {
|
||||
this.map.off('formulabar', this.onFormulaBar, this);
|
||||
this.map.off('jsdialogupdate', this.onJSUpdate, this);
|
||||
this.map.off('jsdialogaction', this.onJSAction, this);
|
||||
},
|
||||
|
||||
createFormulabar: function(text) {
|
||||
this.map.off('doclayerinit', this.onDocLayerInit, this);
|
||||
this.map.off('updatepermission', this.onUpdatePermission, this);
|
||||
this.map.off('celladdress', this.onCellAddress, this);
|
||||
}
|
||||
|
||||
onDocLayerInit() {
|
||||
var docType = this.map.getDocType();
|
||||
if (docType == 'spreadsheet')
|
||||
this.showFormulabar();
|
||||
}
|
||||
|
||||
onUpdatePermission(e) {
|
||||
var adressInput = L.DomUtil.get('addressInput');
|
||||
|
||||
if (e.perm === 'edit') {
|
||||
if (adressInput)
|
||||
adressInput.removeAttribute('disabled');
|
||||
this.enable();
|
||||
} else {
|
||||
if (adressInput)
|
||||
adressInput.setAttribute('disabled', '');
|
||||
this.disable();
|
||||
}
|
||||
}
|
||||
|
||||
onCellAddress (e) {
|
||||
var adressInput = L.DomUtil.get('addressInput');
|
||||
if (adressInput && document.activeElement !== adressInput) {
|
||||
// if the user is not editing the address field
|
||||
adressInput.value = e.address;
|
||||
}
|
||||
this.map.formulabarSetDirty();
|
||||
}
|
||||
|
||||
onAddressInputChange() {
|
||||
// address control should not have focus anymore
|
||||
L.DomUtil.get('addressInput').blur();
|
||||
this.map.focus();
|
||||
var value = L.DomUtil.get('addressInput').value;
|
||||
var command = {
|
||||
ToPoint : {
|
||||
type: 'string',
|
||||
value: value
|
||||
}
|
||||
|
||||
};
|
||||
this.map.sendUnoCommand('.uno:GoToCell', command);
|
||||
}
|
||||
|
||||
createFormulabar(text) {
|
||||
if (!window.mode.isMobile()) {
|
||||
var data = [
|
||||
{
|
||||
id: 'addressInput',
|
||||
type: 'edit',
|
||||
text: _('cell address')
|
||||
},
|
||||
{
|
||||
id: 'formulabar-toolbox',
|
||||
type: 'toolbox',
|
||||
|
@ -91,6 +149,11 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
}];
|
||||
} else {
|
||||
var data = [
|
||||
{
|
||||
id: 'addressInput',
|
||||
type: 'edit',
|
||||
text: _('cell address')
|
||||
},
|
||||
{
|
||||
type: 'toolbox',
|
||||
children: [
|
||||
|
@ -113,22 +176,14 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
}];
|
||||
}
|
||||
|
||||
var wrapper = document.getElementById('calc-inputbar-wrapper');
|
||||
wrapper.style.display = 'block';
|
||||
this.parentContainer.innerHTML = '';
|
||||
this.builder.build(this.parentContainer, data);
|
||||
}
|
||||
|
||||
var parent = document.getElementById('calc-inputbar');
|
||||
parent.innerHTML = '';
|
||||
this.container = L.DomUtil.create('div', 'inputbar_container', parent);
|
||||
this.container.style.width = '100%';
|
||||
|
||||
this.builder.build(this.container, data);
|
||||
},
|
||||
|
||||
toggleMultiLine: function(input) {
|
||||
toggleMultiLine(input) {
|
||||
if (L.DomUtil.hasClass(input, 'expanded')) {
|
||||
L.DomUtil.removeClass(input, 'expanded');
|
||||
L.DomUtil.removeClass(L.DomUtil.get('calc-inputbar-wrapper'), 'expanded');
|
||||
L.DomUtil.removeClass(L.DomUtil.get('formulabar'), 'expanded');
|
||||
L.DomUtil.removeClass(this.parentContainer, 'expanded');
|
||||
this.onJSUpdate({
|
||||
data: {
|
||||
jsontype: 'formulabar',
|
||||
|
@ -144,8 +199,7 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
});
|
||||
} else {
|
||||
L.DomUtil.addClass(input, 'expanded');
|
||||
L.DomUtil.addClass(L.DomUtil.get('calc-inputbar-wrapper'), 'expanded');
|
||||
L.DomUtil.addClass(L.DomUtil.get('formulabar'), 'expanded');
|
||||
L.DomUtil.addClass(this.parentContainer, 'expanded');
|
||||
this.onJSUpdate({
|
||||
data: {
|
||||
jsontype: 'formulabar',
|
||||
|
@ -160,9 +214,9 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
callback: function(objectType, eventType, object, data, builder) {
|
||||
callback(objectType, eventType, object, data, builder) {
|
||||
if (object.id === 'expand') {
|
||||
var input = this.getInputField();
|
||||
if (input)
|
||||
|
@ -170,6 +224,11 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
if (object.id === 'addressInput' && eventType === 'changed') {
|
||||
this.onAddressInputChange();
|
||||
return;
|
||||
}
|
||||
|
||||
// in the core we have DrawingArea not TextView
|
||||
if (object.id.indexOf('sc_input_window') === 0) {
|
||||
objectType = 'drawingarea';
|
||||
|
@ -182,48 +241,53 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
}
|
||||
|
||||
builder._defaultCallbackHandler(objectType, eventType, object, data, builder);
|
||||
},
|
||||
}
|
||||
|
||||
focusField: function() {
|
||||
focusField() {
|
||||
L.DomUtil.addClass(this.getInputField(), 'focused');
|
||||
},
|
||||
}
|
||||
|
||||
blurField: function() {
|
||||
blurField() {
|
||||
L.DomUtil.removeClass(this.getInputField(), 'focused');
|
||||
},
|
||||
}
|
||||
|
||||
enable: function() {
|
||||
enable() {
|
||||
var input = this.getInputField();
|
||||
if (!input)
|
||||
return;
|
||||
|
||||
input.enable();
|
||||
},
|
||||
}
|
||||
|
||||
disable: function() {
|
||||
disable() {
|
||||
var input = this.getInputField();
|
||||
if (!input)
|
||||
return;
|
||||
|
||||
input.disable();
|
||||
},
|
||||
}
|
||||
|
||||
hasFocus: function() {
|
||||
hasFocus() {
|
||||
var input = this.getInputField();
|
||||
if (!input)
|
||||
return false;
|
||||
return L.DomUtil.hasClass(input, 'focused');
|
||||
},
|
||||
}
|
||||
|
||||
show: function(action) {
|
||||
showFormulabar() {
|
||||
if (this.parentContainer)
|
||||
this.parentContainer.style.setProperty('display', 'table-cell');
|
||||
}
|
||||
|
||||
show(action) {
|
||||
this.showButton(action, true);
|
||||
},
|
||||
}
|
||||
|
||||
hide: function(action) {
|
||||
hide(action) {
|
||||
this.showButton(action, false);
|
||||
},
|
||||
}
|
||||
|
||||
showButton: function(action, show) {
|
||||
showButton(action, show) {
|
||||
this.onJSAction(
|
||||
{
|
||||
data: {
|
||||
|
@ -235,33 +299,33 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
getControl: function(controlId) {
|
||||
if (!this.container)
|
||||
getControl(controlId) {
|
||||
if (!this.parentContainer)
|
||||
return;
|
||||
|
||||
var control = this.container.querySelector('[id=\'' + controlId + '\']');
|
||||
var control = this.parentContainer.querySelector('[id=\'' + controlId + '\']');
|
||||
if (!control)
|
||||
window.app.console.warn('formulabar update: not found control with id: "' + controlId + '"');
|
||||
|
||||
return control;
|
||||
},
|
||||
}
|
||||
|
||||
getInputField: function() {
|
||||
getInputField() {
|
||||
return this.getControl('sc_input_window');
|
||||
},
|
||||
}
|
||||
|
||||
onFormulaBar: function(e) {
|
||||
onFormulaBar(e) {
|
||||
var data = e.data;
|
||||
if (data.jsontype !== 'formulabar')
|
||||
return;
|
||||
|
||||
console.warn('formulabar: old style formulabar full update - to fix in core');
|
||||
return;
|
||||
},
|
||||
}
|
||||
|
||||
onJSUpdate: function (e) {
|
||||
onJSUpdate (e) {
|
||||
var data = e.data;
|
||||
if (data.jsontype !== 'formulabar')
|
||||
return;
|
||||
|
@ -279,9 +343,9 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
this.builder.build(temporaryParent, [data.control], false);
|
||||
parent.insertBefore(temporaryParent.firstChild, control.nextSibling);
|
||||
L.DomUtil.remove(control);
|
||||
},
|
||||
}
|
||||
|
||||
onJSAction: function (e) {
|
||||
onJSAction (e) {
|
||||
var data = e.data;
|
||||
|
||||
if (data.jsontype !== 'formulabar')
|
||||
|
@ -294,7 +358,7 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
|
||||
var innerData = data ? data.data : null;
|
||||
|
||||
if (this.container) {
|
||||
if (this.parentContainer.firstChild) {
|
||||
var messageForInputField = innerData && innerData.control_id === 'sc_input_window';
|
||||
var isSetTextMessage = innerData && innerData.action_type === 'setText';
|
||||
var isGrabFocusMessage = innerData && innerData.action_type === 'grab_focus';
|
||||
|
@ -313,12 +377,12 @@ L.Control.FormulaBarJSDialog = L.Control.extend({
|
|||
return;
|
||||
}
|
||||
|
||||
this.builder.executeAction(this.container, innerData);
|
||||
this.builder.executeAction(this.parentContainer, innerData);
|
||||
} else
|
||||
this.createFormulabar(innerData.text);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
L.control.formulaBarJSDialog = function (options) {
|
||||
return new L.Control.FormulaBarJSDialog(options);
|
||||
JSDialog.FormulaBar = function (map) {
|
||||
return new FormulaBar(map);
|
||||
};
|
||||
|
|
|
@ -1642,6 +1642,10 @@ L.Control.JSDialogBuilder = L.Control.extend({
|
|||
builder.callback('edit', 'change', edit, this.value, builder);
|
||||
});
|
||||
|
||||
edit.addEventListener('change', function() {
|
||||
builder.callback('edit', 'changed', edit, this.value, builder);
|
||||
});
|
||||
|
||||
edit.addEventListener('click', function(e) {
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
|
|
@ -310,10 +310,7 @@ L.Control.UIManager = L.Control.extend({
|
|||
|
||||
if (docType === 'spreadsheet') {
|
||||
this.map.addControl(L.control.sheetsBar({shownavigation: isDesktop || window.mode.isTablet()}));
|
||||
this.map.addControl(L.control.formulaBar());
|
||||
var formulabar = L.control.formulaBarJSDialog();
|
||||
this.map.formulabar = formulabar;
|
||||
this.map.addControl(formulabar);
|
||||
this.map.formulabar = JSDialog.FormulaBar(this.map);
|
||||
$('#toolbar-wrapper').addClass('spreadsheet');
|
||||
|
||||
// remove unused elements
|
||||
|
|
|
@ -213,7 +213,7 @@ L.Map.include({
|
|||
}
|
||||
|
||||
if (window.ThisIsTheiOSApp && window.mode.isTablet() && this._docLayer._docType === 'spreadsheet')
|
||||
this.showCalcInputBar(0);
|
||||
this.showCalcInputBar();
|
||||
|
||||
if (window.ThisIsTheAndroidApp)
|
||||
window.postMobileMessage('EDITMODE on');
|
||||
|
|
|
@ -1053,13 +1053,64 @@ L.Map.include({
|
|||
map.fire('postMessage', {msgId: 'UI_SaveAs', args: {format: format}});
|
||||
},
|
||||
|
||||
onFormulaBarFocus: function() {
|
||||
var mobileTopBar = w2ui['actionbar'];
|
||||
var jsdialogFormulabar = this.formulabar;
|
||||
var target = jsdialogFormulabar;
|
||||
|
||||
if (window.mode.isMobile() === true) {
|
||||
mobileTopBar.hide('undo');
|
||||
mobileTopBar.hide('redo');
|
||||
target = mobileTopBar;
|
||||
} else {
|
||||
jsdialogFormulabar.hide('startformula');
|
||||
jsdialogFormulabar.hide('AutoSumMenu');
|
||||
}
|
||||
target.show('cancelformula');
|
||||
target.show('acceptformula');
|
||||
},
|
||||
|
||||
onFormulaBarBlur: function() {
|
||||
// The timeout is needed because we want 'click' event on 'cancel',
|
||||
// 'accept' button to act before we hide these buttons because
|
||||
// once hidden, click event won't be processed.
|
||||
// TODO: Some better way to do it ?
|
||||
var map = this;
|
||||
|
||||
setTimeout(function() {
|
||||
if ($('.leaflet-cursor').is(':visible'))
|
||||
return;
|
||||
var mobileTopBar = w2ui['actionbar'];
|
||||
var jsdialogFormulabar = map.formulabar;
|
||||
|
||||
var target = window.mode.isMobile() ? mobileTopBar : jsdialogFormulabar;
|
||||
target.hide('cancelformula');
|
||||
target.hide('acceptformula');
|
||||
|
||||
mobileTopBar.show('undo');
|
||||
mobileTopBar.show('redo');
|
||||
|
||||
$('#AutoSumMenu-button').css('margin-inline', '0');
|
||||
$('#AutoSumMenu .unoarrow').css('margin', '0');
|
||||
|
||||
jsdialogFormulabar.show('startformula');
|
||||
jsdialogFormulabar.show('AutoSumMenu');
|
||||
|
||||
// clear reference marks
|
||||
map._docLayer._clearReferences();
|
||||
}, 250);
|
||||
|
||||
map.formulabar.blurField();
|
||||
$('#addressInput').blur();
|
||||
},
|
||||
|
||||
formulabarBlur: function() {
|
||||
if (!this.uiManager.isAnyDialogOpen())
|
||||
this.focus();
|
||||
},
|
||||
|
||||
formulabarFocus: function() {
|
||||
this.formulabar.focus();
|
||||
this.formulabar.focusField();
|
||||
},
|
||||
|
||||
formulabarSetDirty: function() {
|
||||
|
|
|
@ -1356,9 +1356,8 @@ L.Map = L.Evented.extend({
|
|||
},
|
||||
|
||||
showCalcInputBar: function() {
|
||||
var wrapper = document.getElementById('calc-inputbar-wrapper');
|
||||
if (wrapper)
|
||||
wrapper.style.display = 'block';
|
||||
if (this.formulabar)
|
||||
this.formulabar.showFormulabar();
|
||||
},
|
||||
|
||||
// Change the focus to a dialog or editor.
|
||||
|
|
|
@ -245,7 +245,7 @@ function assertDataClipboardTable(expectedData) {
|
|||
function selectCellsInRange(range) {
|
||||
cy.log('>> selectCellsInRange - start');
|
||||
|
||||
cy.cGet('#tb_formulabar_item_address #addressInput')
|
||||
cy.cGet('#formulabar #addressInput')
|
||||
.clear()
|
||||
.type(range + '{enter}');
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ describe(['tagmobile', 'tagnextcloud'], 'Formula bar tests.', function() {
|
|||
|
||||
calcHelper.typeIntoFormulabar('{end}');
|
||||
|
||||
cy.cGet('#calc-inputbar .lokdialog-cursor')
|
||||
cy.cGet('#formulabar .lokdialog-cursor')
|
||||
.should(function(cursor) {
|
||||
expect(cursor.offset().left).to.be.equal(93);
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ describe(['tagmobile', 'tagnextcloud'], 'Formula bar tests.', function() {
|
|||
calcHelper.clickFormulaBar();
|
||||
helper.assertCursorAndFocus();
|
||||
|
||||
helper.moveCursor('end', undefined, true, '#calc-inputbar .lokdialog-cursor');
|
||||
helper.moveCursor('end', undefined, true, '#formulabar .lokdialog-cursor');
|
||||
|
||||
calcHelper.typeIntoFormulabar('{backspace}{backspace}{backspace}');
|
||||
|
||||
|
@ -151,7 +151,7 @@ describe(['tagmobile', 'tagnextcloud'], 'Formula bar tests.', function() {
|
|||
it.skip('Switch oneline-multiline mode of input bar', function() {
|
||||
// Get the initial height of the input field.
|
||||
var inputOriginalHeight = 0;
|
||||
cy.cGet('#calc-inputbar')
|
||||
cy.cGet('#formulabar')
|
||||
.should(function(inputbar) {
|
||||
inputOriginalHeight = inputbar.height();
|
||||
expect(inputOriginalHeight).to.not.equal(0);
|
||||
|
@ -159,24 +159,24 @@ describe(['tagmobile', 'tagnextcloud'], 'Formula bar tests.', function() {
|
|||
|
||||
// Switch to multiline mode.
|
||||
var arrowPos = [255, 10];
|
||||
cy.cGet('#calc-inputbar')
|
||||
cy.cGet('#formulabar')
|
||||
.click(arrowPos[0], arrowPos[1]);
|
||||
|
||||
cy.cGet('#calc-inputbar')
|
||||
cy.cGet('#formulabar')
|
||||
.should(function(inputbar) {
|
||||
expect(inputbar.height()).to.be.greaterThan(inputOriginalHeight);
|
||||
});
|
||||
|
||||
cy.cGet('#calc-inputbar')
|
||||
cy.cGet('#formulabar')
|
||||
.should(function(inputbar) {
|
||||
expect(inputbar.height()).to.be.equal(111);
|
||||
});
|
||||
|
||||
// Switch back to one-line mode.
|
||||
cy.cGet('#calc-inputbar')
|
||||
cy.cGet('#formulabar')
|
||||
.click(arrowPos[0], arrowPos[1]);
|
||||
|
||||
cy.cGet('#calc-inputbar')
|
||||
cy.cGet('#formulabar')
|
||||
.should(function(inputbar) {
|
||||
expect(inputbar.height()).to.be.equal(inputOriginalHeight);
|
||||
});
|
||||
|
@ -212,11 +212,11 @@ describe(['tagmobile', 'tagnextcloud'], 'Formula bar tests.', function() {
|
|||
.click();
|
||||
|
||||
cy.cGet('#mobile-wizard-content').should('not.be.visible');
|
||||
cy.cGet('#calc-inputbar .lokdialog-cursor').should('be.visible');
|
||||
cy.cGet('#formulabar .lokdialog-cursor').should('be.visible');
|
||||
|
||||
// Add a range
|
||||
calcHelper.typeIntoFormulabar('B2:B4');
|
||||
cy.cGet('#tb_actionbar_item_acceptformula').click();
|
||||
cy.cGet('#acceptformula').click();
|
||||
|
||||
// Close mobile wizard with formulas.
|
||||
cy.waitUntil(function() {
|
||||
|
|
Loading…
Reference in New Issue