/*
*
* (c) Copyright Ascensio System Limited 2010-2016
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
/**
* Toolbar.js
*
* Toolbar view
*
* Created by Alexander Yuzhin on 1/9/14
* Copyright (c) 2014 Ascensio System SIA. All rights reserved.
*
*/
define([
'jquery',
'underscore',
'backbone',
'text!documenteditor/main/app/template/Toolbar.template',
'common/main/lib/collection/Fonts',
'common/main/lib/component/Button',
'common/main/lib/component/ComboBox',
'common/main/lib/component/DataView',
'common/main/lib/component/ColorPalette',
'common/main/lib/component/ThemeColorPalette',
'common/main/lib/component/Menu',
'common/main/lib/component/DimensionPicker',
'common/main/lib/component/Window',
'common/main/lib/component/ComboBoxFonts',
'common/main/lib/component/ComboDataView'
/** coauthoring begin **/
,'common/main/lib/component/SynchronizeTip'
/** coauthoring end **/
], function ($, _, Backbone, toolbarTemplate) {
'use strict';
DE.Views.Toolbar = Backbone.View.extend(_.extend({
el: '#toolbar',
// Compile our stats template
template: _.template(toolbarTemplate),
// Delegated events for creating new items, and clearing completed ones.
events: {
//
},
initialize: function () {
/**
* UI Components
*/
var me = this;
this.SchemeNames = [
this.txtScheme1, this.txtScheme2, this.txtScheme3, this.txtScheme4, this.txtScheme5,
this.txtScheme6, this.txtScheme7, this.txtScheme8, this.txtScheme9, this.txtScheme10,
this.txtScheme11, this.txtScheme12, this.txtScheme13, this.txtScheme14, this.txtScheme15,
this.txtScheme16, this.txtScheme17, this.txtScheme18, this.txtScheme19, this.txtScheme20,
this.txtScheme21
];
this.paragraphControls = [];
this.toolbarControls = [];
this.textOnlyControls = [];
this._state = {
hasCollaborativeChanges: undefined
};
this.btnSaveCls = 'btn-save';
this.btnSaveTip = this.tipSave + Common.Utils.String.platformKey('Ctrl+S');
this.btnNewDocument = new Common.UI.Button({
id : 'id-toolbar-btn-newdocument',
cls : 'btn-toolbar',
iconCls : 'btn-newdocument',
hint : this.tipNewDocument
});
this.toolbarControls.push(this.btnNewDocument);
this.btnOpenDocument = new Common.UI.Button({
id : 'id-toolbar-btn-opendocument',
cls : 'btn-toolbar',
iconCls : 'btn-opendocument',
hint : this.tipOpenDocument
});
this.toolbarControls.push(this.btnOpenDocument);
this.btnPrint = new Common.UI.Button({
id : 'id-toolbar-btn-print',
cls : 'btn-toolbar',
iconCls : 'btn-print no-mask',
hint : this.tipPrint + Common.Utils.String.platformKey('Ctrl+P')
});
this.toolbarControls.push(this.btnPrint);
this.btnSave = new Common.UI.Button({
id : 'id-toolbar-btn-save',
cls : 'btn-toolbar',
iconCls : 'no-mask ' + this.btnSaveCls,
hint : this.btnSaveTip
});
this.toolbarControls.push(this.btnSave);
this.btnUndo = new Common.UI.Button({
id : 'id-toolbar-btn-undo',
cls : 'btn-toolbar',
iconCls : 'btn-undo',
hint : this.tipUndo + Common.Utils.String.platformKey('Ctrl+Z')
});
this.toolbarControls.push(this.btnUndo);
this.btnRedo = new Common.UI.Button({
id : 'id-toolbar-btn-redo',
cls : 'btn-toolbar',
iconCls : 'btn-redo',
hint : this.tipRedo + Common.Utils.String.platformKey('Ctrl+Y')
});
this.toolbarControls.push(this.btnRedo);
this.btnCopy = new Common.UI.Button({
id : 'id-toolbar-btn-copy',
cls : 'btn-toolbar',
iconCls : 'btn-copy',
hint : this.tipCopy + Common.Utils.String.platformKey('Ctrl+C')
});
this.toolbarControls.push(this.btnCopy);
this.btnPaste = new Common.UI.Button({
id : 'id-toolbar-btn-paste',
cls : 'btn-toolbar',
iconCls : 'btn-paste',
hint : this.tipPaste + Common.Utils.String.platformKey('Ctrl+V')
});
this.paragraphControls.push(this.btnPaste);
this.btnIncFontSize = new Common.UI.Button({
id : 'id-toolbar-btn-incfont',
cls : 'btn-toolbar',
iconCls : 'btn-incfont',
hint : this.tipIncFont + Common.Utils.String.platformKey('Ctrl+]')
});
this.paragraphControls.push(this.btnIncFontSize);
this.btnDecFontSize = new Common.UI.Button({
id : 'id-toolbar-btn-decfont',
cls : 'btn-toolbar',
iconCls : 'btn-decfont',
hint : this.tipDecFont + Common.Utils.String.platformKey('Ctrl+[')
});
this.paragraphControls.push(this.btnDecFontSize);
this.btnBold = new Common.UI.Button({
id : 'id-toolbar-btn-bold',
cls : 'btn-toolbar',
iconCls : 'btn-bold',
hint : this.textBold + Common.Utils.String.platformKey('Ctrl+B'),
enableToggle: true
});
this.paragraphControls.push(this.btnBold);
this.btnItalic = new Common.UI.Button({
id : 'id-toolbar-btn-italic',
cls : 'btn-toolbar',
iconCls : 'btn-italic',
hint : this.textItalic + Common.Utils.String.platformKey('Ctrl+I'),
enableToggle: true
});
this.paragraphControls.push(this.btnItalic);
this.btnUnderline = new Common.UI.Button({
id : 'id-toolbar-btn-underline',
cls : 'btn-toolbar',
iconCls : 'btn-underline',
hint : this.textUnderline + Common.Utils.String.platformKey('Ctrl+U'),
enableToggle: true
});
this.paragraphControls.push(this.btnUnderline);
this.btnStrikeout = new Common.UI.Button({
id : 'id-toolbar-btn-strikeout',
cls : 'btn-toolbar',
iconCls : 'btn-strikeout',
hint : this.textStrikeout,
enableToggle: true
});
this.paragraphControls.push(this.btnStrikeout);
this.btnSuperscript = new Common.UI.Button({
id : 'id-toolbar-btn-superscript',
cls : 'btn-toolbar',
iconCls : 'btn-superscript',
hint : this.textSuperscript,
enableToggle: true,
toggleGroup : 'superscriptGroup'
});
this.paragraphControls.push(this.btnSuperscript);
this.btnSubscript = new Common.UI.Button({
id : 'id-toolbar-btn-subscript',
cls : 'btn-toolbar',
iconCls : 'btn-subscript',
hint : this.textSubscript,
enableToggle: true,
toggleGroup : 'superscriptGroup'
});
this.paragraphControls.push(this.btnSubscript);
this.btnHighlightColor = new Common.UI.Button({
id : 'id-toolbar-btn-highlight',
cls : 'btn-toolbar',
iconCls : 'btn-highlight',
hint : this.tipHighlightColor,
enableToggle: true,
allowDepress: true,
split : true,
menu : new Common.UI.Menu({
style: 'min-width: 100px;',
items: [
{ template: _.template('
') },
{ caption: '--' },
this.mnuHighlightTransparent = new Common.UI.MenuItem({
caption: this.strMenuNoFill,
checkable: true
})
]
})
});
this.paragraphControls.push(this.btnHighlightColor);
this.textOnlyControls.push(this.btnHighlightColor);
this.btnFontColor = new Common.UI.Button({
id : 'id-toolbar-btn-fontcolor',
cls : 'btn-toolbar',
iconCls : 'btn-fontcolor',
hint : this.tipFontColor,
split : true,
menu : new Common.UI.Menu({
items: [
{
id : 'id-toolbar-menu-auto-fontcolor',
caption : this.textAutoColor,
template : _.template('<%= caption %>')
},
{caption:'--'},
{ template: _.template('') },
{ template: _.template('' + this.textNewColor + '') }
]
})
});
this.paragraphControls.push(this.btnFontColor);
this.btnParagraphColor = new Common.UI.Button({
id : 'id-toolbar-btn-paracolor',
cls : 'btn-toolbar',
iconCls : 'btn-paracolor',
hint : this.tipPrColor,
split : true,
menu : new Common.UI.Menu({
items: [
{ template: _.template('') },
{ template: _.template('' + this.textNewColor + '') }
]
})
});
this.paragraphControls.push(this.btnParagraphColor);
this.textOnlyControls.push(this.btnParagraphColor);
this.btnAlignLeft = new Common.UI.Button({
id : 'id-toolbar-btn-align-left',
cls : 'btn-toolbar',
iconCls : 'btn-align-left',
hint : this.tipAlignLeft + Common.Utils.String.platformKey('Ctrl+L'),
enableToggle: true,
allowDepress: false,
toggleGroup : 'alignGroup'
});
this.paragraphControls.push(this.btnAlignLeft);
this.btnAlignCenter = new Common.UI.Button({
id : 'id-toolbar-btn-align-center',
cls : 'btn-toolbar',
iconCls : 'btn-align-center',
hint : this.tipAlignCenter + Common.Utils.String.platformKey('Ctrl+E'),
enableToggle: true,
allowDepress: false,
toggleGroup : 'alignGroup'
});
this.paragraphControls.push(this.btnAlignCenter);
this.btnAlignRight = new Common.UI.Button({
id : 'id-toolbar-btn-align-right',
cls : 'btn-toolbar',
iconCls : 'btn-align-right',
hint : this.tipAlignRight + Common.Utils.String.platformKey('Ctrl+R'),
enableToggle: true,
allowDepress: false,
toggleGroup : 'alignGroup'
});
this.paragraphControls.push(this.btnAlignRight);
this.btnAlignJust = new Common.UI.Button({
id : 'id-toolbar-btn-align-just',
cls : 'btn-toolbar',
iconCls : 'btn-align-just',
hint : this.tipAlignJust + Common.Utils.String.platformKey('Ctrl+J'),
enableToggle: true,
allowDepress: false,
toggleGroup: 'alignGroup'
});
this.paragraphControls.push(this.btnAlignJust);
this.btnHorizontalAlign = new Common.UI.Button({
id : 'id-toolbar-btn-halign',
cls : 'btn-toolbar',
iconCls : 'btn-align-left',
hint : this.tipHAligh,
icls : 'btn-align-left',
menu : new Common.UI.Menu({
cls: 'ppm-toolbar',
items: [
{
caption: this.tipAlignLeft + Common.Utils.String.platformKey('Ctrl+L'),
iconCls: 'mnu-align-left',
icls: 'btn-align-left',
checkable: true,
toggleGroup: 'halignGroup',
checked: true,
value: 1
},
{
caption: this.tipAlignCenter + Common.Utils.String.platformKey('Ctrl+E'),
iconCls: 'mnu-align-center',
icls: 'btn-align-center',
checkable: true,
toggleGroup: 'halignGroup',
value: 2
},
{
caption: this.tipAlignRight + Common.Utils.String.platformKey('Ctrl+R'),
iconCls: 'mnu-align-right',
icls: 'btn-align-right',
checkable: true,
toggleGroup: 'halignGroup',
value: 0
},
{
caption: this.tipAlignJust + Common.Utils.String.platformKey('Ctrl+J'),
iconCls: 'mnu-align-just',
icls: 'btn-align-just',
checkable: true,
toggleGroup: 'halignGroup',
value: 3
}
]
})
});
this.paragraphControls.push(this.btnHorizontalAlign);
this.btnDecLeftOffset = new Common.UI.Button({
id : 'id-toolbar-btn-decoffset',
cls : 'btn-toolbar',
iconCls : 'btn-decoffset',
hint : this.tipDecPrLeft + Common.Utils.String.platformKey('Ctrl+Shift+M')
});
this.paragraphControls.push(this.btnDecLeftOffset);
this.btnIncLeftOffset = new Common.UI.Button({
id : 'id-toolbar-btn-incoffset',
cls : 'btn-toolbar',
iconCls : 'btn-incoffset',
hint : this.tipIncPrLeft + Common.Utils.String.platformKey('Ctrl+M')
});
this.paragraphControls.push(this.btnIncLeftOffset);
this.btnLineSpace = new Common.UI.Button({
id : 'id-toolbar-btn-linespace',
cls : 'btn-toolbar',
iconCls : 'btn-linespace',
hint : this.tipLineSpace,
menu : new Common.UI.Menu({
style: 'min-width: 60px;',
items: [
{ caption: '1.0', value: 1.0, checkable: true, toggleGroup: 'linesize' },
{ caption: '1.15', value: 1.15, checkable: true, toggleGroup: 'linesize' },
{ caption: '1.5', value: 1.5, checkable: true, toggleGroup: 'linesize' },
{ caption: '2.0', value: 2.0, checkable: true, toggleGroup: 'linesize' },
{ caption: '2.5', value: 2.5, checkable: true, toggleGroup: 'linesize' },
{ caption: '3.0', value: 3.0, checkable: true, toggleGroup: 'linesize' }
]
})
});
this.paragraphControls.push(this.btnLineSpace);
this.btnShowHidenChars = new Common.UI.Button({
id : 'id-toolbar-btn-hidenchars',
cls : 'btn-toolbar',
iconCls : 'btn-hidenchars',
hint : this.tipShowHiddenChars,
enableToggle: true,
split : true,
menu : new Common.UI.Menu({
style: 'min-width: 60px;',
items: [
{ caption: this.mniHiddenChars, value: 'characters', checkable: true },
{ caption: this.mniHiddenBorders, value: 'table', checkable: true }
]
})
});
this.toolbarControls.push(this.btnShowHidenChars);
this.btnMarkers = new Common.UI.Button({
id : 'id-toolbar-btn-markers',
cls : 'btn-toolbar',
iconCls : 'btn-setmarkers',
hint : this.tipMarkers,
enableToggle: true,
toggleGroup : 'markersGroup',
split : true,
menu : new Common.UI.Menu({
items: [
{ template: _.template('') }
]
})
});
this.paragraphControls.push(this.btnMarkers);
this.textOnlyControls.push(this.btnMarkers);
this.btnNumbers = new Common.UI.Button({
id : 'id-toolbar-btn-numbering',
cls : 'btn-toolbar',
iconCls : 'btn-numbering',
hint : this.tipNumbers,
enableToggle: true,
toggleGroup : 'markersGroup',
split : true,
menu : new Common.UI.Menu({
items: [
{ template: _.template('') }
]
})
});
this.paragraphControls.push(this.btnNumbers);
this.textOnlyControls.push(this.btnNumbers);
this.btnMultilevels = new Common.UI.Button({
id : 'id-toolbar-btn-multilevels',
cls : 'btn-toolbar',
iconCls : 'btn-multilevels',
hint : this.tipMultilevels,
menu : new Common.UI.Menu({
items: [
{ template: _.template('') }
]
})
});
this.paragraphControls.push(this.btnMultilevels);
this.textOnlyControls.push(this.btnMultilevels);
this.btnInsertTable = new Common.UI.Button({
id : 'id-toolbar-btn-inserttable',
cls : 'btn-toolbar',
iconCls : 'btn-inserttable',
hint : this.tipInsertTable,
menu : new Common.UI.Menu({
items: [
{ template: _.template('') },
{ caption: this.mniCustomTable, value: 'custom' }
]
})
});
this.paragraphControls.push(this.btnInsertTable);
this.btnInsertImage = new Common.UI.Button({
id : 'id-toolbar-btn-insertimage',
cls : 'btn-toolbar',
iconCls : 'btn-insertimage',
hint : this.tipInsertImage,
menu : new Common.UI.Menu({
items: [
{ caption: this.mniImageFromFile, value: 'file' },
{ caption: this.mniImageFromUrl, value: 'url' }
]
})
});
this.paragraphControls.push(this.btnInsertImage);
this.btnInsertChart = new Common.UI.Button({
id : 'id-toolbar-btn-insertchart',
cls : 'btn-toolbar',
iconCls : 'btn-insertchart',
hint : this.tipInsertChart,
menu : new Common.UI.Menu({
style: 'width: 560px;',
items: [
{ template: _.template('') }
]
})
});
this.paragraphControls.push(this.btnInsertChart);
this.btnInsertText = new Common.UI.Button({
id : 'id-toolbar-btn-inserttext',
cls : 'btn-toolbar',
iconCls : 'btn-text',
hint : this.tipInsertText,
enableToggle: true,
split : true,
menu : new Common.UI.Menu({
items : [
{caption: this.textInsText, value: 'text'},
this.mnuInsertTextArt = new Common.UI.MenuItem({
caption: this.textInsTextArt,
value: 'art',
menu: new Common.UI.Menu({
menuAlign: 'tl-tr',
cls: 'menu-shapes',
items: [
{ template: _.template('') }
]
})
})
]
})
});
this.paragraphControls.push(this.btnInsertText);
this.btnInsertPageBreak = new Common.UI.Button({
id : 'id-toolbar-btn-pagebreak',
cls : 'btn-toolbar',
iconCls : 'btn-pagebreak',
hint : this.tipPageBreak,
split : true,
menu : new Common.UI.Menu({
items : [
{caption: this.textInsPageBreak},
{caption: this.textInsColumnBreak, value: 'column'},
this.mnuInsertSectionBreak = new Common.UI.MenuItem({
caption: this.textInsSectionBreak,
value: 'section',
menu: new Common.UI.Menu({
menuAlign: 'tl-tr',
items : [
{caption: this.textNextPage, value: Asc.c_oAscSectionBreakType.NextPage},
{caption: this.textContPage, value: Asc.c_oAscSectionBreakType.Continuous},
{caption: this.textEvenPage, value: Asc.c_oAscSectionBreakType.EvenPage},
{caption: this.textOddPage, value: Asc.c_oAscSectionBreakType.OddPage}
]
})
})
]
})
});
this.paragraphControls.push(this.btnInsertPageBreak);
this.btnInsertHyperlink = new Common.UI.Button({
id : 'id-toolbar-btn-inserthyperlink',
cls : 'btn-toolbar',
iconCls : 'btn-inserthyperlink',
hint : this.tipInsertHyperlink + Common.Utils.String.platformKey('Ctrl+K')
});
this.paragraphControls.push(this.btnInsertHyperlink);
this.btnEditHeader = new Common.UI.Button({
id : 'id-toolbar-btn-editheader',
cls : 'btn-toolbar',
iconCls : 'btn-editheader',
hint : this.tipEditHeader,
menu : new Common.UI.Menu({
items: [
{ caption: this.mniEditHeader, value: 'header' },
{ caption: this.mniEditFooter, value: 'footer' },
{ caption: '--' },
me.mnuInsertPageNum = new Common.UI.MenuItem({
caption: this.textInsertPageNumber,
menu: new Common.UI.Menu({
menuAlign: 'tl-tr',
items: [
{ template: _.template('') },
me.mnuPageNumCurrentPos = new Common.UI.MenuItem({
caption: this.textToCurrent,
value: 'current'
})
]
})
})
]
})
});
this.paragraphControls.push(this.mnuPageNumCurrentPos);
this.toolbarControls.push(this.btnEditHeader);
this.btnInsertShape = new Common.UI.Button({
id : 'id-toolbar-btn-insertshape',
cls : 'btn-toolbar',
iconCls : 'btn-insertshape',
hint : this.tipInsertShape,
enableToggle: true,
menu : new Common.UI.Menu({cls: 'menu-shapes'})
});
this.paragraphControls.push(this.btnInsertShape);
this.btnInsertEquation = new Common.UI.Button({
id : 'id-toolbar-btn-insertequation',
cls : 'btn-toolbar',
iconCls : 'btn-insertequation',
hint : this.tipInsertEquation,
split : true,
menu : new Common.UI.Menu({cls: 'menu-shapes'})
});
this.paragraphControls.push(this.btnInsertEquation);
this.btnDropCap = new Common.UI.Button({
id : 'id-toolbar-btn-dropcap',
cls : 'btn-toolbar',
iconCls : 'btn-dropcap',
hint : this.tipDropCap,
menu : new Common.UI.Menu({
cls: 'ppm-toolbar',
items: [
{ caption: this.textNone, iconCls: 'mnu-dropcap-none', checkable: true, toggleGroup: 'menuDropCap', value: Asc.c_oAscDropCap.None, checked: true },
{ caption: this.textInText, iconCls: 'mnu-dropcap-intext', checkable: true, toggleGroup: 'menuDropCap', value: Asc.c_oAscDropCap.Drop },
{ caption: this.textInMargin, iconCls: 'mnu-dropcap-inmargin', checkable: true, toggleGroup: 'menuDropCap', value: Asc.c_oAscDropCap.Margin },
{ caption: '--' },
this.mnuDropCapAdvanced = new Common.UI.MenuItem({ caption: this.mniEditDropCap })
]
})
});
this.paragraphControls.push(this.btnDropCap);
this.btnColumns = new Common.UI.Button({
id : 'id-toolbar-btn-columns',
cls : 'btn-toolbar',
iconCls : 'btn-columns',
hint : this.tipColumns,
menu : new Common.UI.Menu({
cls: 'ppm-toolbar',
items: [
{ caption: this.textColumnsOne, iconCls: 'mnu-columns-one', checkable: true, toggleGroup: 'menuColumns', value: 0 },
{ caption: this.textColumnsTwo, iconCls: 'mnu-columns-two', checkable: true, toggleGroup: 'menuColumns', value: 1 },
{ caption: this.textColumnsThree, iconCls: 'mnu-columns-three', checkable: true, toggleGroup: 'menuColumns', value: 2 },
{ caption: this.textColumnsLeft, iconCls: 'mnu-columns-left', checkable: true, toggleGroup: 'menuColumns', value: 3 },
{ caption: this.textColumnsRight, iconCls: 'mnu-columns-right', checkable: true, toggleGroup: 'menuColumns', value: 4 }
]
})
});
this.paragraphControls.push(this.btnColumns);
this.btnPageOrient = new Common.UI.Button({
id : 'id-toolbar-btn-pageorient',
cls : 'btn-toolbar',
iconCls : 'btn-pageorient',
hint : this.tipPageOrient,
enableToggle: true
});
this.toolbarControls.push(this.btnPageOrient);
var pageMarginsTemplate = _.template('