/*
*
* (c) Copyright Ascensio System SIA 2010-2019
*
* 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 20A-12 Ernesta Birznieka-Upisha
* street, Riga, Latvia, EU, LV-1050.
*
* 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
*
*/
/**
* DocumentHolder.js
*
* DocumentHolder view
*
* Created by Julia Radzhabova on 3/28/14
* Copyright (c) 2018 Ascensio System SIA. All rights reserved.
*
*/
define([
'jquery',
'underscore',
'backbone',
'gateway',
'common/main/lib/component/Menu'
], function ($, _, Backbone, gateway) { 'use strict';
SSE.Views.DocumentHolder = Backbone.View.extend(_.extend({
el: '#editor_sdk',
// Compile our stats template
template: null,
// Delegated events for creating new items, and clearing completed ones.
events: {
},
initialize: function() {
var me = this;
this.setApi = function(api) {
me.api = api;
return me;
};
},
render: function() {
this.fireEvent('render:before', this);
this.cmpEl = $(this.el);
this.fireEvent('render:after', this);
return this;
},
focus: function() {
var me = this;
_.defer(function(){
me.cmpEl && me.cmpEl.focus();
}, 50);
},
createDelayedElementsViewer: function() {
var me = this;
me.menuViewCopy = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-copy',
caption: me.txtCopy,
value: 'copy'
});
me.menuViewUndo = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-undo',
caption: me.textUndo
});
me.menuViewCopySeparator = new Common.UI.MenuItem({
caption: '--'
});
me.menuViewAddComment = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-menu-comments',
id: 'id-context-menu-item-view-add-comment',
caption: me.txtAddComment
});
me.menuSignatureViewSign = new Common.UI.MenuItem({caption: this.strSign, value: 0 });
me.menuSignatureDetails = new Common.UI.MenuItem({caption: this.strDetails, value: 1 });
me.menuSignatureViewSetup = new Common.UI.MenuItem({caption: this.strSetup, value: 2 });
me.menuSignatureRemove = new Common.UI.MenuItem({caption: this.strDelete, value: 3 });
me.menuViewSignSeparator = new Common.UI.MenuItem({caption: '--' });
this.viewModeMenu = new Common.UI.Menu({
cls: 'shifted-right',
items: [
me.menuViewCopy,
me.menuViewUndo,
me.menuViewCopySeparator,
me.menuSignatureViewSign,
me.menuSignatureDetails,
me.menuSignatureViewSetup,
me.menuSignatureRemove,
me.menuViewSignSeparator,
me.menuViewAddComment
]
});
me.fireEvent('createdelayedelements', [me]);
},
createDelayedElements: function() {
var me = this;
me.pmiCut = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-cut',
caption : me.txtCut,
value : 'cut'
});
me.pmiCopy = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-copy',
caption : me.txtCopy,
value : 'copy'
});
me.pmiPaste = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-paste',
caption : me.txtPaste,
value : 'paste'
});
me.pmiSelectTable = new Common.UI.MenuItem({
caption : me.txtSelect,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{ caption: this.selectRowText, value: Asc.c_oAscChangeSelectionFormatTable.row},
{ caption: this.selectColumnText, value: Asc.c_oAscChangeSelectionFormatTable.column},
{ caption: this.selectDataText, value: Asc.c_oAscChangeSelectionFormatTable.data},
{ caption: this.selectTableText, value: Asc.c_oAscChangeSelectionFormatTable.all}
]
})
});
me.pmiInsertEntire = new Common.UI.MenuItem({
caption : me.txtInsert
});
me.pmiInsertCells = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-addcell',
caption : me.txtInsert,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{
caption : me.txtShiftRight,
value : Asc.c_oAscInsertOptions.InsertCellsAndShiftRight
},{
caption : me.txtShiftDown,
value : Asc.c_oAscInsertOptions.InsertCellsAndShiftDown
},{
caption : me.txtRow,
value : Asc.c_oAscInsertOptions.InsertRows
},{
caption : me.txtColumn,
value : Asc.c_oAscInsertOptions.InsertColumns
}
]
})
});
me.pmiInsertTable = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-addcell',
caption : me.txtInsert,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{ caption: me.insertRowAboveText, value: Asc.c_oAscInsertOptions.InsertTableRowAbove},
{ caption: me.insertRowBelowText, value: Asc.c_oAscInsertOptions.InsertTableRowBelow},
{ caption: me.insertColumnLeftText, value: Asc.c_oAscInsertOptions.InsertTableColLeft},
{ caption: me.insertColumnRightText, value: Asc.c_oAscInsertOptions.InsertTableColRight}
]
})
});
me.pmiDeleteEntire = new Common.UI.MenuItem({
caption : me.txtDelete
});
me.pmiDeleteCells = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-delcell',
caption : me.txtDelete,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{
caption : me.txtShiftLeft,
value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftLeft
},{
caption : me.txtShiftUp,
value : Asc.c_oAscDeleteOptions.DeleteCellsAndShiftTop
},{
caption : me.txtRow,
value : Asc.c_oAscDeleteOptions.DeleteRows
},{
caption : me.txtColumn,
value : Asc.c_oAscDeleteOptions.DeleteColumns
}
]
})
});
me.pmiDeleteTable = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-delcell',
caption : me.txtDelete,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{ caption: this.deleteRowText, value: Asc.c_oAscDeleteOptions.DeleteRows},
{ caption: this.deleteColumnText, value: Asc.c_oAscDeleteOptions.DeleteColumns},
{ caption: this.deleteTableText, value: Asc.c_oAscDeleteOptions.DeleteTable}
]
})
});
me.pmiClear = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-clearstyle',
caption : me.txtClear,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{
caption : me.txtClearAll,
value : Asc.c_oAscCleanOptions.All
},
{
caption : me.txtClearText,
value : Asc.c_oAscCleanOptions.Text
},
{
caption : me.txtClearFormat,
value : Asc.c_oAscCleanOptions.Format
},
{
caption : me.txtClearComments,
value : Asc.c_oAscCleanOptions.Comments
},
{
caption : me.txtClearHyper,
value : Asc.c_oAscCleanOptions.Hyperlinks
}
]
})
});
me.pmiSortCells = new Common.UI.MenuItem({
caption : me.txtSort,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{
iconCls: 'menu__icon btn-sort-down',
caption : me.txtAscending,
value : Asc.c_oAscSortOptions.Ascending
},{
iconCls: 'menu__icon btn-sort-up',
caption : me.txtDescending,
value : Asc.c_oAscSortOptions.Descending
},{
caption : me.txtSortCellColor,
value : Asc.c_oAscSortOptions.ByColorFill
},{
caption : me.txtSortFontColor,
value : Asc.c_oAscSortOptions.ByColorFont
},{
caption : me.txtCustomSort,
value : 'advanced'
}
]
})
});
me.pmiFilterCells = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-autofilter',
caption : me.txtFilter,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign : 'tl-tr',
items: [
{
caption : me.txtFilterValue,
value : 0
},{
caption : me.txtFilterCellColor,
value : 1
},{
caption : me.txtFilterFontColor,
value : 2
}
]
})
});
me.pmiReapply = new Common.UI.MenuItem({
caption : me.txtReapply
});
me.mnuGroupPivot = new Common.UI.MenuItem({
caption : this.txtGroup,
value : 'grouping'
});
me.mnuUnGroupPivot = new Common.UI.MenuItem({
caption : this.txtUngroup,
value : 'ungrouping'
});
me.pmiInsFunction = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-function',
caption : me.txtFormula
});
me.menuAddHyperlink = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-inserthyperlink',
caption : me.txtInsHyperlink,
inCell : true
});
me.menuEditHyperlink = new Common.UI.MenuItem({
caption : me.editHyperlinkText,
inCell : true
});
me.menuRemoveHyperlink = new Common.UI.MenuItem({
caption : me.removeHyperlinkText
});
me.menuHyperlink = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-inserthyperlink',
caption : me.txtInsHyperlink,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign: 'tl-tr',
items : [
me.menuEditHyperlink,
me.menuRemoveHyperlink
]
})
});
me.pmiRowHeight = new Common.UI.MenuItem({
caption : me.txtRowHeight,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign: 'tl-tr',
items : [
{ caption: me.txtAutoRowHeight, value: 'auto-row-height' },
{ caption: me.txtCustomRowHeight, value: 'row-height' }
]
})
});
me.pmiColumnWidth = new Common.UI.MenuItem({
caption : me.txtColumnWidth,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign: 'tl-tr',
items : [
{ caption: me.txtAutoColumnWidth, value: 'auto-column-width' },
{ caption: me.txtCustomColumnWidth, value: 'column-width' }
]
})
});
me.pmiEntireHide = new Common.UI.MenuItem({
caption : me.txtHide
});
me.pmiEntireShow = new Common.UI.MenuItem({
caption : me.txtShow
});
me.pmiAddComment = new Common.UI.MenuItem({
iconCls: 'menu__icon btn-menu-comments',
id : 'id-context-menu-item-add-comment',
caption : me.txtAddComment
});
me.pmiCellMenuSeparator = new Common.UI.MenuItem({
caption : '--'
});
me.pmiAddNamedRange = new Common.UI.MenuItem({
id : 'id-context-menu-item-add-named-range',
caption : me.txtAddNamedRange
});
me.pmiFreezePanes = new Common.UI.MenuItem({
caption : me.textFreezePanes
});
me.pmiEntriesList = new Common.UI.MenuItem({
caption : me.textEntriesList
});
me.pmiSparklines = new Common.UI.MenuItem({
caption : me.txtSparklines,
menu : new Common.UI.Menu({
cls: 'shifted-right',
menuAlign: 'tl-tr',
items : [
{ caption: me.txtClearSparklines, value: Asc.c_oAscCleanOptions.Sparklines },
{ caption: me.txtClearSparklineGroups, value: Asc.c_oAscCleanOptions.SparklineGroups }
]
})
});
var numFormatTemplate = _.template(''+
'