',
buttons: [{
text: 'OK',
onClick: function () {
var dontshow = $('input[name="checkbox-show-cut"]').prop('checked');
if (dontshow) Common.localStorage.setItem("sse-hide-copy-cut-paste-warning", 1);
}
}]
});
}
}
break;
case 'copy':
var res = me.api.asc_Copy();
if (!res) {
me.view.hideMenu();
if (!Common.localStorage.getBool("sse-hide-copy-cut-paste-warning")) {
uiApp.modal({
title: me.textCopyCutPasteActions,
afterText: '',
buttons: [{
text: 'OK',
onClick: function () {
var dontshow = $('input[name="checkbox-show-copy"]').prop('checked');
if (dontshow) Common.localStorage.setItem("sse-hide-copy-cut-paste-warning", 1);
}
}]
});
}
}
break;
case 'paste':
var res = me.api.asc_Paste();
if (!res) {
me.view.hideMenu();
if (!Common.localStorage.getBool("sse-hide-copy-cut-paste-warning")) {
uiApp.modal({
title: me.textCopyCutPasteActions,
text: me.errorCopyCutPaste,
afterText: '',
buttons: [{
text: 'OK',
onClick: function () {
var dontshow = $('input[name="checkbox-show-paste"]').prop('checked');
if (dontshow) Common.localStorage.setItem("sse-hide-copy-cut-paste-warning", 1);
}
}]
});
}
}
break;
case 'del':
me.api.asc_emptyCells(Asc.c_oAscCleanOptions.All, !_canDeleteComments);
break;
case 'wrap': me.api.asc_setCellTextWrap(true); break;
case 'unwrap': me.api.asc_setCellTextWrap(false); break;
case 'edit':
me.view.hideMenu();
SSE.getController('EditContainer').showModal();
// SSE.getController('EditCell').getView('EditCell');
break;
case 'merge':
if (me.api.asc_mergeCellsDataLost(Asc.c_oAscMergeOptions.Merge)) {
_.defer(function () {
uiApp.confirm(me.warnMergeLostData, me.notcriticalErrorTitle, function(){
me.api.asc_mergeCells(Asc.c_oAscMergeOptions.Merge);
});
});
} else {
me.api.asc_mergeCells(Asc.c_oAscMergeOptions.Merge);
}
break;
case 'unmerge':
me.api.asc_mergeCells(Asc.c_oAscMergeOptions.None);
break;
case 'hide':
me.api[info.asc_getSelectionType() == Asc.c_oAscSelectionType.RangeRow ? 'asc_hideRows' : 'asc_hideColumns']();
break;
case 'show':
me.api[info.asc_getSelectionType() == Asc.c_oAscSelectionType.RangeRow ? 'asc_showRows' : 'asc_showColumns']();
break;
case 'addlink':
me.view.hideMenu();
SSE.getController('AddContainer').showModal({
panel: 'hyperlink'
});
break;
case 'openlink':
var linkinfo = info.asc_getHyperlink();
if ( linkinfo.asc_getType() == Asc.c_oAscHyperlinkType.RangeLink ) {
var nameSheet = linkinfo.asc_getSheet();
var curActiveSheet = this.api.asc_getActiveWorksheetIndex();
me.api.asc_setWorksheetRange(linkinfo);
SSE.getController('Statusbar').onLinkWorksheetRange(nameSheet, curActiveSheet);
} else {
var url = linkinfo.asc_getHyperlinkUrl().replace(/\s/g, "%20");
me.api.asc_getUrlType(url) > 0 && openLink(url);
}
break;
case 'freezePanes':
me.api.asc_freezePane();
break;
case 'viewcomment':
me.view.hideMenu();
var cellinfo = this.api.asc_getCellInfo(),
comments = cellinfo.asc_getComments();
if (comments.length) {
SSE.getController('Common.Controllers.Collaboration').apiShowComments(comments[0].asc_getId());
SSE.getController('Common.Controllers.Collaboration').showCommentModal();
}
break;
case 'addcomment':
me.view.hideMenu();
SSE.getController('AddContainer').showModal();
SSE.getController('AddOther').getView('AddOther').showPageComment(false);
}
if ('showActionSheet' == event && _actionSheets.length > 0) {
_.delay(function () {
_.each(_actionSheets, function (action) {
action.text = action.caption;
action.onClick = function () {
me.onContextMenuClick(null, action.event)
}
});
uiApp.actions([_actionSheets, [
{
text: me.sheetCancel,
bold: true
}
]]);
}, 100);
}
me.view.hideMenu();
},
// API Handlers
onEditorResize: function(cmp) {
// Hide context menu
},
onApiShowPopMenu: function(posX, posY) {
if (this.isDisconnected) return;
if ($('.popover.settings, .popup.settings, .picker-modal.settings, .modal-in, .actions-modal').length > 0) {
return;
}
var me = this,
items;
items = me._initMenu(me.api.asc_getCellInfo());
me.view.showMenu(items, posX, posY);
},
onApiHidePopMenu: function() {
this.view.hideMenu();
},
onApiHyperlinkClick: function(url) {
if (!url) {
var me = this;
_.defer(function () {
uiApp.modal({
title: me.notcriticalErrorTitle,
text : me.errorInvalidLink,
buttons: [{text: 'OK'}]
});
});
}
},
// Internal
_initMenu: function (cellinfo) {
var me = this,
arrItems = [],
arrItemsIcon = [];
_actionSheets.length = 0;
var iscellmenu, isrowmenu, iscolmenu, isallmenu, ischartmenu, isimagemenu, istextshapemenu, isshapemenu, istextchartmenu;
var iscelllocked = cellinfo.asc_getLocked(),
seltype = cellinfo.asc_getSelectionType(),
xfs = cellinfo.asc_getXfs();
_isComments = cellinfo.asc_getComments().length>0; //prohibit adding multiple comments in one cell;
switch (seltype) {
case Asc.c_oAscSelectionType.RangeCells: iscellmenu = true; break;
case Asc.c_oAscSelectionType.RangeRow: isrowmenu = true; break;
case Asc.c_oAscSelectionType.RangeCol: iscolmenu = true; break;
case Asc.c_oAscSelectionType.RangeMax: isallmenu = true; break;
case Asc.c_oAscSelectionType.RangeImage: isimagemenu = true; break;
case Asc.c_oAscSelectionType.RangeShape: isshapemenu = true; break;
case Asc.c_oAscSelectionType.RangeChart: ischartmenu = true; break;
case Asc.c_oAscSelectionType.RangeChartText: istextchartmenu = true; break;
case Asc.c_oAscSelectionType.RangeShapeText: istextshapemenu = true; break;
}
if (!_isEdit) {
if (iscellmenu || istextchartmenu || istextshapemenu) {
arrItemsIcon = [{
caption: me.menuCopy,
event: 'copy',
icon: 'icon-copy'
}];
}
if (iscellmenu && cellinfo.asc_getHyperlink()) {
arrItems.push({
caption: me.menuOpenLink,
event: 'openlink'
});
}
if (_canViewComments && _isComments) {
arrItems.push({
caption: me.menuViewComment,
event: 'viewcomment'
});
}
} else {
if (!iscelllocked && (isimagemenu || isshapemenu || ischartmenu || istextshapemenu || istextchartmenu)) {
this.api.asc_getGraphicObjectProps().every(function (object) {
if (object.asc_getObjectType() == Asc.c_oAscTypeSelectElement.Image) {
iscelllocked = object.asc_getObjectValue().asc_getLocked();
}
return !iscelllocked;
});
}
if (iscelllocked || this.api.isCellEdited) {
arrItemsIcon = [{
caption: me.menuCopy,
event: 'copy',
icon: 'icon-copy'
}];
} else {
var arrItemsIcon = [{
caption: me.menuCut,
event: 'cut',
icon: 'icon-cut'
}, {
caption: me.menuCopy,
event: 'copy',
icon: 'icon-copy'
}, {
caption: me.menuPaste,
event: 'paste',
icon: 'icon-paste'
}];
arrItems.push({
caption: me.menuDelete,
event: 'del'
});
// isTableLocked = cellinfo.asc_getLockedTable()===true;
if (isimagemenu || isshapemenu || ischartmenu ||
istextshapemenu || istextchartmenu) {
arrItems.push({
caption: me.menuEdit,
event: 'edit'
});
} else {
if (iscolmenu || isrowmenu) {
arrItems.push({
caption: me.menuHide,
event: 'hide'
}, {
caption: me.menuShow,
event: 'show'
});
} else if (iscellmenu) {
!iscelllocked &&
arrItems.push({
caption: me.menuCell,
event: 'edit'
});
(cellinfo.asc_getMerge() == Asc.c_oAscMergeOptions.None) &&
arrItems.push({
caption: me.menuMerge,
event: 'merge'
});
(cellinfo.asc_getMerge() == Asc.c_oAscMergeOptions.Merge) &&
arrItems.push({
caption: me.menuUnmerge,
event: 'unmerge'
});
arrItems.push(
xfs.asc_getWrapText() ?
{
caption: me.menuUnwrap,
event: 'unwrap'
} :
{
caption: me.menuWrap,
event: 'wrap'
});
if (cellinfo.asc_getHyperlink() && !cellinfo.asc_getMultiselect()) {
arrItems.push({
caption: me.menuOpenLink,
event: 'openlink'
});
} else if (!cellinfo.asc_getHyperlink() && !cellinfo.asc_getMultiselect() &&
!cellinfo.asc_getLockText() && !!cellinfo.asc_getText()) {
arrItems.push({
caption: me.menuAddLink,
event: 'addlink'
});
}
}
arrItems.push({
caption: this.api.asc_getSheetViewSettings().asc_getIsFreezePane() ? me.menuUnfreezePanes : me.menuFreezePanes,
event: 'freezePanes'
});
}
if (_canViewComments) {
if (_isComments) {
arrItems.push({
caption: me.menuViewComment,
event: 'viewcomment'
});
} else if (iscellmenu) {
arrItems.push({
caption: me.menuAddComment,
event: 'addcomment'
});
}
}
}
if (Common.SharedSettings.get('phone') && arrItems.length > 2) {
_actionSheets = arrItems.slice(2);
arrItems = arrItems.slice(0, 2);
arrItems.push({
caption: me.menuMore,
event: 'showActionSheet'
});
}
}
var menuItems = {itemsIcon: arrItemsIcon, items: arrItems};
return menuItems;
},
onCoAuthoringDisconnect: function() {
this.isDisconnected = true;
},
onApiFilterOptions: function(config) {
if(_isEdit) {
var rect = config.asc_getCellCoord(),
posX = rect.asc_getX() + rect.asc_getWidth() - 9,
posY = rect.asc_getY() + rect.asc_getHeight() - 9;
SSE.getController('FilterOptions').showModal(posX,posY);
}
},
warnMergeLostData: 'Operation can destroy data in the selected cells.