Commit 1d7510d6 authored by Julia Radzhabova's avatar Julia Radzhabova

Added context menu in the viewer mode (Copy menu item).

parent a590cac3
......@@ -890,9 +890,11 @@ define([
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
} else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
} else {
documentHolderController.getView('DocumentHolder').createDelayedElementsViewer();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
}
if (this.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Document Editor');
......
......@@ -81,7 +81,7 @@ define([
me._currentParaObjDisabled = false;
var showPopupMenu = function(menu, value, event, docElement, eOpts){
if (!_.isUndefined(menu) && menu !== null && me.mode.isEdit){
if (!_.isUndefined(menu) && menu !== null){
Common.UI.Menu.Manager.hideAll();
var showPoint = [event.get_X(), event.get_Y()],
......@@ -186,9 +186,33 @@ define([
return (!noobject) ? {menu_to_show: menu_to_show, menu_props: menu_props} : null;
};
var fillViewMenuProps = function(selectedElements) {
if (!selectedElements || !_.isArray(selectedElements)) return;
var menu_props = {},
menu_to_show = me.viewModeMenu,
noobject = true;
for (var i = 0; i <selectedElements.length; i++) {
var elType = selectedElements[i].get_ObjectType();
var elValue = selectedElements[i].get_ObjectValue();
if (Asc.c_oAscTypeSelectElement.Image == elType) {
//image
menu_props.imgProps = {};
menu_props.imgProps.value = elValue;
noobject = false;
} else if (Asc.c_oAscTypeSelectElement.Paragraph == elType)
{
menu_props.paraProps = {};
menu_props.paraProps.value = elValue;
menu_props.paraProps.locked = (elValue) ? elValue.get_Locked() : false;
noobject = false;
}
}
return (!noobject) ? {menu_to_show: menu_to_show, menu_props: menu_props} : null;
};
var showObjectMenu = function(event, docElement, eOpts){
if (me.api && me.mode.isEdit){
var obj = fillMenuProps(me.api.getSelectedElements());
if (me.api){
var obj = (me.mode.isEdit) ? fillMenuProps(me.api.getSelectedElements()) : fillViewMenuProps(me.api.getSelectedElements());
if (obj) showPopupMenu(obj.menu_to_show, obj.menu_props, event, docElement, eOpts);
}
};
......@@ -204,8 +228,8 @@ define([
};
var onFocusObject = function(selectedElements) {
if (me.mode.isEdit && me.currentMenu && me.currentMenu.isVisible() && me.currentMenu !== me.hdrMenu){
var obj = fillMenuProps(selectedElements);
if (me.currentMenu && me.currentMenu.isVisible() && me.currentMenu !== me.hdrMenu){
var obj = (me.mode.isEdit) ? fillMenuProps(selectedElements) : fillViewMenuProps(selectedElements);
if (obj) {
if (obj.menu_to_show===me.currentMenu) {
me.currentMenu.options.initMenu(obj.menu_props);
......@@ -1769,6 +1793,58 @@ define([
me.fireEvent('editcomplete', me);
},
createDelayedElementsViewer: function() {
var me = this;
var menuViewCopy = new Common.UI.MenuItem({
caption: me.textCopy,
value: 'copy'
}).on('click', _.bind(me.onCutCopyPaste, me));
var menuViewUndo = new Common.UI.MenuItem({
caption: me.textUndo
}).on('click', function () {
me.api.Undo();
});
var menuViewCopySeparator = new Common.UI.MenuItem({
caption: '--'
});
var menuViewAddComment = new Common.UI.MenuItem({
caption: me.addCommentText
}).on('click', _.bind(me.addComment, me));
this.viewModeMenu = new Common.UI.Menu({
initMenu: function (value) {
var isInChart = (value.imgProps && value.imgProps.value && !_.isNull(value.imgProps.value.get_ChartProperties()));
menuViewUndo.setVisible(me.mode.isEdit);
menuViewCopySeparator.setVisible(!isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit);
menuViewAddComment.setVisible(!isInChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit);
menuViewAddComment.setDisabled(value.paraProps && value.paraProps.locked === true);
var cancopy = me.api && me.api.can_CopyCut();
menuViewCopy.setDisabled(!cancopy);
},
items: [
menuViewCopy,
menuViewUndo,
menuViewCopySeparator,
menuViewAddComment
]
}).on('hide:after', function (menu, e, isFromInputControl) {
if (me.suppressEditComplete) {
me.suppressEditComplete = false;
return;
}
if (!isFromInputControl) me.fireEvent('editcomplete', me);
me.currentMenu = null;
});
},
createDelayedElements: function() {
var me = this;
......@@ -3401,7 +3477,8 @@ define([
txtDeleteRadical: 'Delete radical',
txtDeleteChars: 'Delete enclosing characters',
txtDeleteCharsAndSeparators: 'Delete enclosing characters and separators',
txtKeepTextOnly: 'Keep text only'
txtKeepTextOnly: 'Keep text only',
textUndo: 'Undo'
}, DE.Views.DocumentHolder || {}));
});
\ No newline at end of file
......@@ -839,6 +839,7 @@
"DE.Views.DocumentHolder.updateStyleText": "Update %1 style",
"DE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"DE.Views.DocumentHolder.txtKeepTextOnly": "Keep text only",
"DE.Views.DocumentHolder.textUndo": "Undo",
"DE.Views.DropcapSettingsAdvanced.cancelButtonText": "Cancel",
"DE.Views.DropcapSettingsAdvanced.okButtonText": "Ok",
"DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill",
......
......@@ -670,9 +670,11 @@ define([
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
} else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
} else {
documentHolderController.getView('DocumentHolder').createDelayedElementsViewer();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
}
if (this.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Presentation Editor');
......
......@@ -181,10 +181,34 @@ define([
return {menu_to_show: menu_to_show, menu_props: menu_props};
};
var fillViewMenuProps = function(selectedElements) {
if (!selectedElements || !_.isArray(selectedElements)) return;
var menu_props = {},
menu_to_show = null;
_.each(selectedElements, function(element, index) {
var elType = element.get_ObjectType(),
elValue = element.get_ObjectValue();
if (Asc.c_oAscTypeSelectElement.Image == elType || Asc.c_oAscTypeSelectElement.Table == elType || Asc.c_oAscTypeSelectElement.Shape == elType ||
Asc.c_oAscTypeSelectElement.Chart == elType || Asc.c_oAscTypeSelectElement.Paragraph == elType) {
menu_to_show = me.viewModeMenu;
menu_props.locked = menu_props.locked || ((elValue) ? elValue.get_Locked() : false);
if (Asc.c_oAscTypeSelectElement.Chart == elType)
menu_props.isChart = true;
}
else if (Asc.c_oAscTypeSelectElement.Slide == elType) {
menu_props.locked = menu_props.locked || ((elValue) ? elValue.get_LockDelete() : false);
}
});
return (menu_to_show) ? {menu_to_show: menu_to_show, menu_props: menu_props} : null;
};
var showObjectMenu = function(event, docElement, eOpts){
if (me.api && me.mode.isEdit){
var obj = fillMenuProps(me.api.getSelectedElements());
if (me.api){
var obj = (me.mode.isEdit) ? fillMenuProps(me.api.getSelectedElements()) : fillViewMenuProps(me.api.getSelectedElements());
if (obj) showPopupMenu(obj.menu_to_show, obj.menu_props, event, docElement, eOpts);
}
};
......@@ -200,14 +224,14 @@ define([
};
var onFocusObject = function(selectedElements) {
if (me.mode.isEdit && me.currentMenu && me.currentMenu.isVisible()){
if (me.currentMenu && me.currentMenu.isVisible()){
if (me.api.asc_getCurrentFocusObject() === 0 ){ // thumbnails
if (me.slideMenu===me.currentMenu) {
me.currentMenu.options.initMenu({isSlideSelect: me.slideMenu.items[2].isVisible(), fromThumbs: true});
me.currentMenu.alignPosition();
}
} else {
var obj = fillMenuProps(selectedElements);
var obj = (me.mode.isEdit) ? fillMenuProps(selectedElements) : fillViewMenuProps(selectedElements);
if (obj) {
if (obj.menu_to_show===me.currentMenu) {
me.currentMenu.options.initMenu(obj.menu_props);
......@@ -1667,6 +1691,53 @@ define([
}
},
createDelayedElementsViewer: function() {
var me = this;
var menuViewCopy = new Common.UI.MenuItem({
caption: me.textCopy,
value: 'copy'
}).on('click', _.bind(me.onCutCopyPaste, me));
var menuViewUndo = new Common.UI.MenuItem({
caption: me.textUndo
}).on('click', function () {
me.api.Undo();
});
var menuViewCopySeparator = new Common.UI.MenuItem({
caption: '--'
});
var menuViewAddComment = new Common.UI.MenuItem({
caption: me.addCommentText
}).on('click', _.bind(me.addComment, me));
this.viewModeMenu = new Common.UI.Menu({
initMenu: function (value) {
menuViewUndo.setVisible(me.mode.isEdit);
menuViewCopySeparator.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit);
menuViewAddComment.setVisible(!value.isChart && me.api.can_AddQuotedComment() !== false && me.mode.canCoAuthoring && me.mode.canComments && me.mode.isEdit);
menuViewAddComment.setDisabled(value.locked);
},
items: [
menuViewCopy,
menuViewUndo,
menuViewCopySeparator,
menuViewAddComment
]
}).on('hide:after', function (menu, e, isFromInputControl) {
if (me.suppressEditComplete) {
me.suppressEditComplete = false;
return;
}
if (!isFromInputControl) me.fireEvent('editcomplete', me);
me.currentMenu = null;
});
},
createDelayedElements: function(){
var me = this;
......@@ -3176,7 +3247,8 @@ define([
noSpellVariantsText: 'No variants',
moreText: 'More variants...',
spellcheckText: 'Spellcheck',
langText: 'Select Language'
langText: 'Select Language',
textUndo: 'Undo'
}, PE.Views.DocumentHolder || {}));
});
\ No newline at end of file
......@@ -759,6 +759,7 @@
"PE.Views.DocumentHolder.moreText": "More variants...",
"PE.Views.DocumentHolder.spellcheckText": "Spellcheck",
"PE.Views.DocumentHolder.langText": "Select Language",
"PE.Views.DocumentHolder.textUndo": "Undo",
"PE.Views.DocumentPreview.goToSlideText": "Go to Slide",
"PE.Views.DocumentPreview.slideIndexText": "Slide {0} of {1}",
"PE.Views.DocumentPreview.txtClose": "Close Slideshow",
......
......@@ -670,8 +670,11 @@ define([
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
} else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
} else {
documentHolderView.createDelayedElementsViewer();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
}
if (me.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Spreadsheet Editor');
......
......@@ -86,6 +86,39 @@ define([
}, 50);
},
createDelayedElementsViewer: function() {
var me = this;
me.menuViewCopy = new Common.UI.MenuItem({
caption: me.txtCopy,
value: 'copy'
});
me.menuViewUndo = new Common.UI.MenuItem({
caption: me.textUndo
});
me.menuViewCopySeparator = new Common.UI.MenuItem({
caption: '--'
});
me.menuViewAddComment = new Common.UI.MenuItem({
id: 'id-context-menu-item-view-add-comment',
caption: me.txtAddComment
});
this.viewModeMenu = new Common.UI.Menu({
items: [
me.menuViewCopy,
me.menuViewUndo,
me.menuViewCopySeparator,
me.menuViewAddComment
]
});
me.fireEvent('createdelayedelements', [me]);
},
createDelayedElements: function() {
var me = this;
......@@ -667,8 +700,8 @@ define([
me.fireEvent('createdelayedelements', [me]);
},
setMenuItemCommentCaptionMode: function (add, editable) {
this.pmiAddComment.setCaption(add ? this.txtAddComment : (editable ? this.txtEditComment : this.txtShowComment), true);
setMenuItemCommentCaptionMode: function (item, add, editable) {
item.setCaption(add ? this.txtAddComment : (editable ? this.txtEditComment : this.txtShowComment), true);
},
txtSort: 'Sort',
......@@ -754,7 +787,8 @@ define([
txtShowComment: 'Show Comment',
advancedImgText: 'Image Advanced Settings',
textNone: 'None',
bulletsText: 'Bullets and Numbering'
bulletsText: 'Bullets and Numbering',
textUndo: 'Undo'
}, SSE.Views.DocumentHolder || {}));
});
\ No newline at end of file
......@@ -1022,6 +1022,7 @@
"SSE.Views.DocumentHolder.vertAlignText": "Vertical Alignment",
"SSE.Views.DocumentHolder.textNone": "None",
"SSE.Views.DocumentHolder.bulletsText": "Bullets and Numbering",
"SSE.Views.DocumentHolder.textUndo": "Undo",
"SSE.Views.FileMenu.btnBackCaption": "Go to Documents",
"SSE.Views.FileMenu.btnCloseMenuCaption": "Close Menu",
"SSE.Views.FileMenu.btnCreateNewCaption": "Create New",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment