loleaflet: add a menu drop down toolbar item

This commit is contained in:
Henry Castro 2016-07-14 22:12:28 -04:00
parent ddfd0a3341
commit d57c5758fd
3 changed files with 66 additions and 17 deletions

BIN
loleaflet/dist/images/lc_ok.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 195 B

View file

@ -266,6 +266,7 @@ button.leaflet-control-search-next
.w2ui-icon.numberformatdecdecimals{ background: url('/loleaflet/dist/images/lc_numberformatdecdecimals.png') no-repeat center !important; }
.w2ui-icon.sortascending{ background: url('/loleaflet/dist/images/sc_sortascending.png') no-repeat center !important; }
.w2ui-icon.sortdescending{ background: url('/loleaflet/dist/images/sc_sortdescending.png') no-repeat center !important; }
.w2ui-icon.selected{ background: url('/loleaflet/dist/images/lc_ok.png') no-repeat center !important; }
.inserttable-pop {
z-index: 100000;

View file

@ -52,7 +52,7 @@ function resizeToolbar() {
}
}
function onClick(id) {
function onClick(id, item, subItem) {
if (w2ui['toolbar-up'].get(id) !== null) {
var toolbar = w2ui['toolbar-up'];
var item = toolbar.get(id);
@ -77,6 +77,16 @@ function onClick(id) {
toolbar = w2ui['toolbar-up-more'];
item = toolbar.get(id);
}
else if (item && subItem)
{
var command = {
'StatusBarFunc': {
type: 'unsigned short',
value: subItem.func
}
};
map.sendUnoCommand('.uno:StatusBarFunc', command);
}
else {
throw new Error('unknown id: ' + id);
}
@ -448,7 +458,7 @@ $(function () {
{type: 'button', id: 'zoomin', img: 'zoomin', hint: _('Zoom in')}
],
onClick: function (e) {
onClick(e.target);
onClick(e.target, e.item, e.subItem);
}
});
});
@ -516,6 +526,23 @@ function toLocalePattern (pattern, regex, text, sub1, sub2) {
return text;
}
function selectItem(item, func)
{
var index = -1;
for (var it = 0; it < item.items.length; it++) {
if (item.items[it].func === func) {
index = it;
break;
}
}
if (index !== -1) {
item.items[item.current].icon = '';
item.items[index].icon = 'selected';
item.current = index;
}
}
function onSearch(e) {
if (e.keyCode === 13) {
var toolbar = w2ui['toolbar-down'];
@ -708,15 +735,30 @@ map.on('doclayerinit', function () {
case 'spreadsheet':
statusbar.insert('left', [
{type: 'break', id:'break1'},
{type: 'html', id: 'StatusDocPos', html: '<div id="StatusDocPos" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'StatusDocPos',
html: '<div id="StatusDocPos" class="loleaflet-font" title="'+_('Number of Sheets')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break2'},
{type: 'html', id: 'RowColSelCount', html: '<div id="RowColSelCount" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'RowColSelCount',
html: '<div id="RowColSelCount" class="loleaflet-font" title="'+_('Selected range of cells')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break3'},
{type: 'html', id: 'InsertMode', html: '<div id="InsertMode" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'InsertMode',
html: '<div id="InsertMode" class="loleaflet-font" title="'+_('Entering text mode')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break5'},
{type: 'html', id: 'StatusSelectionMode', html: '<div id="StatusSelectionMode" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'StatusSelectionMode',
html: '<div id="StatusSelectionMode" class="loleaflet-font" title="'+_('Selection Mode')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break8'},
{type: 'html', id: 'StateTableCell', html: '<div id="StateTableCell" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'StateTableCell',
html: '<div id="StateTableCell" class="loleaflet-font" title="'+_('Choice of functions')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'menu', id: 'StateTableCellMenu', caption: '', current: 7, items: [
{ func: '1', text: _('Average'), icon: ''},
{ func: '3', text: _('CountA'), icon: ''},
{ func: '2', text: _('Count'), icon: ''},
{ func: '4', text: _('Maximum'), icon: ''},
{ func: '5', text: _('Minimum'), icon: ''},
{ func: '9', text: _('Sum'), icon: ''},
{ func: '12', text: _('Selection count'), icon: ''},
{ func: '16', text: _('None'), icon: 'selected'},
]},
]);
toolbar.remove('alignblock', 'bullet', 'numbering', 'break-numbering');
toolbar.insert('break-align', [
@ -739,20 +781,25 @@ map.on('doclayerinit', function () {
case 'text':
statusbar.insert('left', [
{type: 'break', id:'break1'},
{type: 'html', id: 'StatePageNumber', html: '<div id="StatePageNumber" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'StatePageNumber',
html: '<div id="StatePageNumber" class="loleaflet-font" title="'+_('Number of Pages')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break2'},
{type: 'html', id: 'StateWordCount', html: '<div id="StateWordCount" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'StateWordCount',
html: '<div id="StateWordCount" class="loleaflet-font" title="'+_('Word Counter')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break5'},
{type: 'html', id: 'InsertMode', html: '<div id="InsertMode" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'InsertMode',
html: '<div id="InsertMode" class="loleaflet-font" title="'+_('Entering text mode')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'break', id:'break6'},
{type: 'html', id: 'SelectionMode', html: '<div id="StatusSelectionMode" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'SelectionMode',
html: '<div id="StatusSelectionMode" class="loleaflet-font" title="'+_('Selection Mode')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
]);
statusbar.refresh();
break;
case 'presentation':
statusbar.insert('left', [
{type: 'break', id:'break1'},
{type: 'html', id: 'PageStatus', html: '<div id="PageStatus" class="loleaflet-font" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
{type: 'html', id: 'PageStatus',
html: '<div id="PageStatus" class="loleaflet-font" title="'+_('Number of Slides')+ '" style="padding: 5px 5px;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp</div>' },
]);
statusbar.refresh();
break;
@ -761,6 +808,7 @@ map.on('doclayerinit', function () {
map.on('commandstatechanged', function (e) {
var toolbar = w2ui['toolbar-up'];
var statusbar = w2ui['toolbar-down'];
var commandName = e.commandName;
var state = e.state;
var found = false;
@ -886,12 +934,12 @@ map.on('commandstatechanged', function (e) {
commandName === '.uno:SelectionMode') {
$('#StatusSelectionMode').html(state ? L.Styles.selectionMode[state].toLocaleString() : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp');
}
else if (commandName === '.uno:Position' ||
commandName === '.uno:StateTableCell' ||
commandName === '.uno:StatusBarFunc' ||
commandName === '.uno:Size') {
else if (commandName == '.uno:StateTableCell') {
$('#StateTableCell').html(state ? state : '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp');
}
else if (commandName === '.uno:StatusBarFunc') {
if (state) {
$('#StateTableCell').html(state);
selectItem(statusbar.get('StateTableCellMenu'), state);
}
}
else if (commandName === '.uno:StatePageNumber') {