/* * LibreOffice Online toolbar */ $(function () { $('#toolbar-up-more').w2toolbar({ name: 'toolbar-up-more', items: [ ], onClick: function (e) { onClick(e.target); } }); $('#toolbar-up').w2toolbar({ name: 'toolbar-up', items: [ { type: 'button', id: 'save', img: 'save', hint: _("Save"), uno: 'Save' }, { type: 'break' }, { type: 'button', id: 'undo', img: 'undo', hint: _("Undo"), uno: 'Undo' }, { type: 'button', id: 'redo', img: 'redo', hint: _("Redo"), uno: 'Redo' }, { type: 'break' }, { type: 'html', id: 'styles', html: '' }, { type: 'html', id: 'fonts', html: '' }, { type: 'html', id: 'fontsizes', html: '' }, { type: 'break' }, { type: 'button', id: 'bold', img: 'bold', hint: _("Bold"), uno: 'Bold' }, { type: 'button', id: 'italic', img: 'italic', hint: _("Italic"), uno: 'Italic' }, { type: 'button', id: 'underline', img: 'underline', hint: _("Underline"), uno: 'Underline' }, { type: 'button', id: 'strikeout', img: 'strikeout', hint: _("Strikeout"), uno: 'Strikeout' }, { type: 'break' }, { type: 'html', id: 'fontcolor-html', html: '' }, { type: 'button', id: 'fontcolor', img: 'color', hint: _("Font Color") }, { type: 'html', id: 'backcolor-html', html: '' }, { type: 'button', id: 'backcolor', img: 'backcolor', hint: _("Highlighting") }, { type: 'break' }, { type: 'button', id: 'alignleft', img: 'alignleft', hint: _("Align left"), uno: 'LeftPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"1"}}' }, { type: 'button', id: 'alignhorizontal', img: 'alignhorizontal', hint: _("Center horizontaly"), uno: 'CenterPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"2"}}' }, { type: 'button', id: 'alignright', img: 'alignright', hint: _("Align right"), uno: 'RightPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"3"}}' }, { type: 'button', id: 'alignblock', img: 'alignblock', hint: _("Justified"), uno: 'JustifyPara', unosheet: 'HorizontalAlignment {"HorizontalAlignment":{"type":"unsigned short", "value":"4"}}' }, { type: 'break' }, { type: 'button', id: 'bullet', img: 'bullet', hint: _("Bullets on/off"), uno: 'DefaultBullet' }, { type: 'button', id: 'numbering', img: 'numbering', hint: _("Numbering on/off"), uno: 'DefaultNumbering' }, { type: 'break' }, { type: 'button', id: 'incrementindent', img: 'incrementindent', hint: _("Increase Indent"), uno: 'IncrementIndent' }, { type: 'button', id: 'decrementindent', img: 'decrementindent', hint: _("Decrease Indent"), uno: 'DecrementIndent' }, { type: 'break', id: 'incdecindent' }, { type: 'button', id: 'annotation', img: 'annotation', hint: _("Insert Comment"), uno: 'InsertAnnotation' }, { type: 'button', id: 'insertgraphic', img: 'insertgraphic', hint: _("Insert Graphic") }, { type: 'break' }, { type: 'button', id: 'help', img: 'help', hint: _("Help") }, { type: 'html', id: 'right' }, { type: 'button', id: 'more', img: 'more', hint: _("More") }, { type: 'button', id: 'close', img: 'closedoc', hint: _("Close Document"), hidden: true } ], onClick: function (e) { onClick(e.target); }, onRefresh: function(e) { if (!L.DomUtil.get('fontcolorindicator')) { var fontColorIndicator = L.DomUtil.create('div', 'font-color-indicator', L.DomUtil.get('tb_toolbar-up_item_fontcolor')); fontColorIndicator.id = 'fontcolorindicator'; } if (!L.DomUtil.get('backcolorindicator')) { var backColorIndicator = L.DomUtil.create('div', 'back-color-indicator', L.DomUtil.get('tb_toolbar-up_item_backcolor')); backColorIndicator.id = 'backcolorindicator'; } } }); $('#formulabar').w2toolbar({ name: 'formulabar', items: [ { type: 'html', id: 'left' }, { type: 'button', id: 'sum', img: 'autosum', hint: _("Sum") }, { type: 'button', id: 'function', img: 'equal', hint: _("Function") }, { type: 'button', hidden: true, id: 'cancelformula', img: 'cancel', hint: _("Cancel") }, { type: 'button', hidden: true, id: 'acceptformula', img: 'accepttrackedchanges', hint: _("Accept") }, { type: 'html', id: 'formula', html: '' } ], onClick: function (e) { onClick(e.target); } }); $('#spreadsheet-toolbar').w2toolbar({ name: 'spreadsheet-toolbar', items: [ { type: 'button', id: 'firstrecord', img: 'firstrecord', hidden: true, hint: _("First Sheet") }, { type: 'button', id: 'prevrecord', img: 'prevrecord', hidden: true, hint: _("Previous Sheet") }, { type: 'button', id: 'nextrecord', img: 'nextrecord', hidden: true, hint: _("Next Sheet") }, { type: 'button', id: 'lastrecord', img: 'lastrecord', hidden: true, hint: _("Last Sheet") } ], onClick: function (e) { onClick(e.target); } }); $('#presentation-toolbar').w2toolbar({ name: 'presentation-toolbar', items: [ { type: 'html', id: 'left' }, { type: 'button', id: 'presentation', img: 'presentation', hidden:true, hint: _("Fullscreen presentation") }, { type: 'break', id: 'presentationbreak', hidden:true }, { type: 'button', id: 'insertpage', img: 'insertpage', hidden:true, hint: _("Insert Page") }, { type: 'button', id: 'duplicatepage', img: 'duplicatepage', hidden:true, hint: _("Duplicate Page") }, { type: 'button', id: 'deletepage', img: 'deletepage', hidden:true, hint: _("Delete Page") }, { type: 'html', id: 'right' } ], onClick: function (e) { onClick(e.target); } }); $('#toolbar-down').w2toolbar({ name: 'toolbar-down', items: [ { type: 'html', id: 'search', html: '
'+ ' Search:'+ ' '+ '
' }, { type: 'button', id: 'searchprev', img: 'prev', hint: _("Search backwards"), disabled: true }, { type: 'button', id: 'searchnext', img: 'next', hint: _("Search forward"), disabled: true }, { type: 'button', id: 'cancelsearch', img: 'cancel', hint: _("Cancel the search"), hidden: true }, { type: 'html', id: 'left' }, { type: 'html', id: 'right' }, { type: 'html', id: 'modifiedstatuslabel', html: '
' }, { type: 'break' }, { type: 'button', id: 'takeedit', img: 'edit', hint: _("Take edit lock (others can only view)")}, { type: 'html', id: 'takeeditlabel', html: '
VIEWING
' }, { type: 'break' }, { type: 'button', id: 'prev', img: 'prev', hint: _("Previous page") }, { type: 'button', id: 'next', img: 'next', hint: _("Next page") }, { type: 'break', id: 'prevnextbreak' }, { type: 'button', id: 'zoomreset', img: 'zoomreset', hint: _("Reset zoom") }, { type: 'button', id: 'zoomout', img: 'zoomout', hint: _("Zoom out") }, { type: 'html', id: 'zoomlevel', html: '
100%
'}, { type: 'button', id: 'zoomin', img: 'zoomin', hint: _("Zoom in") } ], onClick: function (e) { onClick(e.target); } }); $('#fontColorPicker').colorpicker({showOn:'none', hideButton:true}); $("#fontColorPicker").on("change.color", onColorPick); $('#backColorPicker').colorpicker({showOn:'none', hideButton:true}); $("#backColorPicker").on("change.color", onColorPick); }); var formatButtons = ['undo', 'redo', 'save', 'bold', 'italic', 'underline', 'strikeout', 'annotation', 'fontcolor', 'backcolor', 'bullet', 'numbering', 'alignleft', 'alignhorizontal', 'alignright', 'alignblock', 'incrementindent', 'decrementindent', 'insertgraphic']; var takeEditPopupMessage = '
You are viewing now.
Click here to take edit
'; var takeEditPopupTimeout = null; function onSearch(e) { if (e.keyCode === 13) { var toolbar = w2ui['toolbar-down']; map.search(L.DomUtil.get('search-input').value); toolbar.enable('searchprev'); toolbar.enable('searchnext'); toolbar.show('cancelsearch'); } else { map.fire('requestloksession'); } } function onClick(id) { if (w2ui['toolbar-up'].get(id) !== null) { var toolbar = w2ui['toolbar-up']; var item = toolbar.get(id) ; } else if (w2ui['formulabar'].get(id) !== null) { toolbar = w2ui['formulabar']; item = toolbar.get(id) ; } else if (w2ui['toolbar-down'].get(id) !== null) { toolbar = w2ui['toolbar-down']; item = toolbar.get(id) ; } else if (w2ui['spreadsheet-toolbar'].get(id) !== null) { toolbar = w2ui['spreadsheet-toolbar']; item = toolbar.get(id) ; } else if (w2ui['presentation-toolbar'].get(id) != null) { toolbar = w2ui['presentation-toolbar']; item = toolbar.get(id); } else { throw new Error('unknown id: ' + id); } var docLayer = map._docLayer; map.focus(); if (item.disabled) { return; } if (item.uno) { if (item.unosheet && map.getDocType() === 'spreadsheet') { map.toggleCommandState(item.unosheet); } else { map.toggleCommandState(item.uno); } } else if (id === 'zoomin' && map.getZoom() < map.getMaxZoom()) { map.zoomIn(1); } else if (id === 'zoomout' && map.getZoom() > map.getMinZoom()) { map.zoomOut(1); } else if (id === 'zoomreset') { map.setZoom(map.options.zoom); } else if (id === 'prev' || id === 'next') { if (docLayer._docType === 'text') { map.goToPage(id); } else { map.setPart(id); } } else if (id === 'menu:file:saveas') { var dialog = '' + '' + '' + '' + '' + ''; vex.dialog.open({ message: 'Save as:', input: dialog, callback: onSaveAs }); } else if (id === 'takeedit') { if (!item.checked) { map._socket.sendMessage('takeedit'); // And advertise which page we're on. map._socket.sendMessage('setclientpart part=' + map._docLayer._selectedPart); } } else if (id === 'searchprev') { map.search(L.DomUtil.get('search-input').value, true); } else if (id === 'searchnext') { map.search(L.DomUtil.get('search-input').value); } else if (id === 'cancelsearch') { map.resetSelection(); toolbar.hide('cancelsearch'); toolbar.disable('searchprev'); toolbar.disable('searchnext'); L.DomUtil.get('search-input').value = ''; } else if (id === 'presentation' && map.getDocType() === 'presentation') { map.fire('fullscreen'); } else if (id === 'insertpage') { map.insertPage(); } else if (id === 'duplicatepage') { map.duplicatePage(); } else if (id === 'deletepage') { vex.dialog.confirm({ message: _("Are you sure you want to delete this page?"), callback: onDelete }); } else if (id === 'firstrecord') { $('#spreadsheet-tab-scroll').scrollLeft(0); } // TODO: We should get visible tab's width instead of 60px else if (id === 'nextrecord') { $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').scrollLeft()+60); } else if (id === 'prevrecord') { $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').scrollLeft()-60); } else if (id === 'lastrecord') { $('#spreadsheet-tab-scroll').scrollLeft($('#spreadsheet-tab-scroll').prop("scrollWidth")); } else if (id === 'insertgraphic') { L.DomUtil.get('insertgraphic').click(); } else if (id === 'fontcolor') { // absolutely no idea why, but without the timeout, the popup is // closed as soon as it is opend setTimeout(function () {$('#fontColorPicker').colorpicker('showPalette')}, 0); } else if (id === 'backcolor') { // absolutely no idea why, but without the timeout, the popup is // closed as soon as it is opend setTimeout(function () {$('#backColorPicker').colorpicker('showPalette')}, 0); } else if (id === 'sum') { L.DomUtil.get('formulaInput').value = '=SUM()'; L.DomUtil.get('formulaInput').focus(); map.cellEnterString(L.DomUtil.get('formulaInput').value); } else if (id === 'function') { L.DomUtil.get('formulaInput').value = '='; L.DomUtil.get('formulaInput').focus(); map.cellEnterString(L.DomUtil.get('formulaInput').value); } else if (id === 'cancelformula') { L.DomUtil.get('formulaInput').value = ''; map.cellEnterString(L.DomUtil.get('formulaInput').value); } else if (id === 'acceptformula') { map.cellEnterString(L.DomUtil.get('formulaInput').value); } else if (id === 'more') { $('#toolbar-up-more').toggle(); if ($('#toolbar-up-more').is(':visible')) { toolbar.check('more'); } else { toolbar.uncheck('more'); } resizeToolbar(); } else if (id === 'help') { var w = window.innerWidth / 2; var h = window.innerHeight / 2; $.modal('