Update copy/cut/paste from toolbar and context menu.

This commit is contained in:
Julia Radzhabova 2016-07-26 17:46:42 +03:00
parent c964e8a89d
commit 9297531dff
6 changed files with 26 additions and 66 deletions

View file

@ -873,29 +873,21 @@ define([
onCopyPaste: function(copy, e) { onCopyPaste: function(copy, e) {
var me = this; var me = this;
if (me.api) { if (me.api) {
if (typeof window['AscDesktopEditor'] === 'object') { // AscDesktopEditor object may exists in desktop version var res = (copy) ? me.api.Copy() : me.api.Paste();
copy ? me.api.Copy() : me.api.Paste(); if (!res) {
// window['AscDesktopEditor'][copy ? 'Copy' : 'Paste'](); // desktop editor's methods
} else {
var value = Common.localStorage.getItem("de-hide-copywarning"); var value = Common.localStorage.getItem("de-hide-copywarning");
if (!(value && parseInt(value) == 1)) { if (!(value && parseInt(value) == 1)) {
(new Common.Views.CopyWarningDialog({ (new Common.Views.CopyWarningDialog({
handler: function(dontshow) { handler: function(dontshow) {
copy ? me.api.Copy() : me.api.Paste();
if (dontshow) Common.localStorage.setItem("de-hide-copywarning", 1); if (dontshow) Common.localStorage.setItem("de-hide-copywarning", 1);
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
})).show(); })).show();
} else {
copy ? me.api.Copy() : me.api.Paste();
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
} } else
Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning'); Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning');
} else {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, },
onIncrease: function(e) { onIncrease: function(e) {

View file

@ -1663,26 +1663,20 @@ define([
onCutCopyPaste: function(item, e) { onCutCopyPaste: function(item, e) {
var me = this; var me = this;
if (me.api) { if (me.api) {
if (typeof window['AscDesktopEditor'] === 'object') { var res = (item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste());
(item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste()); if (!res) {
} else {
var value = Common.localStorage.getItem("de-hide-copywarning"); var value = Common.localStorage.getItem("de-hide-copywarning");
if (!(value && parseInt(value) == 1)) { if (!(value && parseInt(value) == 1)) {
(new Common.Views.CopyWarningDialog({ (new Common.Views.CopyWarningDialog({
handler: function(dontshow) { handler: function(dontshow) {
(item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste());
if (dontshow) Common.localStorage.setItem("de-hide-copywarning", 1); if (dontshow) Common.localStorage.setItem("de-hide-copywarning", 1);
me.fireEvent('editcomplete', me); me.fireEvent('editcomplete', me);
} }
})).show(); })).show();
} else { }
(item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste()); }
}
me.fireEvent('editcomplete', me); me.fireEvent('editcomplete', me);
}
}
} else {
me.fireEvent('editcomplete', me);
}
}, },
createDelayedElements: function() { createDelayedElements: function() {

View file

@ -879,29 +879,21 @@ define([
onCopyPaste: function(copy, e) { onCopyPaste: function(copy, e) {
var me = this; var me = this;
if (me.api) { if (me.api) {
if (typeof window['AscDesktopEditor'] === 'object') { var res = (copy) ? me.api.Copy() : me.api.Paste();
copy ? me.api.Copy() : me.api.Paste(); if (!res) {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} else {
var value = Common.localStorage.getItem("pe-hide-copywarning"); var value = Common.localStorage.getItem("pe-hide-copywarning");
if (!(value && parseInt(value) == 1)) { if (!(value && parseInt(value) == 1)) {
(new Common.Views.CopyWarningDialog({ (new Common.Views.CopyWarningDialog({
handler: function(dontshow) { handler: function(dontshow) {
copy ? me.api.Copy() : me.api.Paste();
if (dontshow) Common.localStorage.setItem("pe-hide-copywarning", 1); if (dontshow) Common.localStorage.setItem("pe-hide-copywarning", 1);
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
})).show(); })).show();
} else {
copy ? me.api.Copy() : me.api.Paste();
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
} } else
Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning'); Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning');
} else {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, },
onBold: function(btn, e) { onBold: function(btn, e) {

View file

@ -834,26 +834,20 @@ define([
onCutCopyPaste: function(item, e) { onCutCopyPaste: function(item, e) {
var me = this; var me = this;
if (me.api) { if (me.api) {
if (typeof window['AscDesktopEditor'] === 'object') { var res = (item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste());
(item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste()); if (!res) {
} else {
var value = Common.localStorage.getItem("pe-hide-copywarning"); var value = Common.localStorage.getItem("pe-hide-copywarning");
if (!(value && parseInt(value) == 1)) { if (!(value && parseInt(value) == 1)) {
(new Common.Views.CopyWarningDialog({ (new Common.Views.CopyWarningDialog({
handler: function(dontshow) { handler: function(dontshow) {
(item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste());
if (dontshow) Common.localStorage.setItem("pe-hide-copywarning", 1); if (dontshow) Common.localStorage.setItem("pe-hide-copywarning", 1);
me.fireEvent('editcomplete', me); me.fireEvent('editcomplete', me);
} }
})).show(); })).show();
} else { }
(item.value == 'cut') ? me.api.Cut() : ((item.value == 'copy') ? me.api.Copy() : me.api.Paste()); }
}
me.fireEvent('editcomplete', me); me.fireEvent('editcomplete', me);
}
}
} else {
me.fireEvent('editcomplete', me);
}
}, },
fullScreen: function(element) { fullScreen: function(element) {

View file

@ -265,25 +265,21 @@ define([
onCopyPaste: function(item) { onCopyPaste: function(item) {
var me = this; var me = this;
if (me.api) { if (me.api) {
if (typeof window['AscDesktopEditor'] === 'object') { var res = (item.value == 'cut') ? me.api.asc_Cut() : ((item.value == 'copy') ? me.api.asc_Copy() : me.api.asc_Paste());
(item.value == 'cut') ? me.api.asc_Cut() : ((item.value == 'copy') ? me.api.asc_Copy() : me.api.asc_Paste()); if (!res) {
} else {
var value = Common.localStorage.getItem("sse-hide-copywarning"); var value = Common.localStorage.getItem("sse-hide-copywarning");
if (!(value && parseInt(value) == 1)) { if (!(value && parseInt(value) == 1)) {
(new Common.Views.CopyWarningDialog({ (new Common.Views.CopyWarningDialog({
handler: function(dontshow) { handler: function(dontshow) {
(item.value == 'cut') ? me.api.asc_Cut() : ((item.value == 'copy') ? me.api.asc_Copy() : me.api.asc_Paste());
if (dontshow) Common.localStorage.setItem("sse-hide-copywarning", 1); if (dontshow) Common.localStorage.setItem("sse-hide-copywarning", 1);
Common.NotificationCenter.trigger('edit:complete', me.documentHolder); Common.NotificationCenter.trigger('edit:complete', me.documentHolder);
} }
})).show(); })).show();
} else {
(item.value == 'cut') ? me.api.asc_Cut() : ((item.value == 'copy') ? me.api.asc_Copy() : me.api.asc_Paste());
Common.NotificationCenter.trigger('edit:complete', me.documentHolder);
} }
} else
Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning'); Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning');
} }
} Common.NotificationCenter.trigger('edit:complete', me.documentHolder);
}, },
onInsertEntire: function(item) { onInsertEntire: function(item) {

View file

@ -327,29 +327,21 @@ define([
onCopyPaste: function(copy, e) { onCopyPaste: function(copy, e) {
var me = this; var me = this;
if (me.api) { if (me.api) {
if (typeof window['AscDesktopEditor'] === 'object') { var res = (copy) ? me.api.asc_Copy() : me.api.asc_Paste();
copy ? me.api.asc_Copy() : me.api.asc_Paste(); if (!res) {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} else {
var value = Common.localStorage.getItem("sse-hide-copywarning"); var value = Common.localStorage.getItem("sse-hide-copywarning");
if (!(value && parseInt(value) == 1)) { if (!(value && parseInt(value) == 1)) {
(new Common.Views.CopyWarningDialog({ (new Common.Views.CopyWarningDialog({
handler: function(dontshow) { handler: function(dontshow) {
copy ? me.api.asc_Copy() : me.api.asc_Paste();
if (dontshow) Common.localStorage.setItem("sse-hide-copywarning", 1); if (dontshow) Common.localStorage.setItem("sse-hide-copywarning", 1);
Common.NotificationCenter.trigger('edit:complete', me.toolbar); Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
})).show(); })).show();
} else {
copy ? me.api.asc_Copy() : me.api.asc_Paste();
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
} } else
Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning'); Common.component.Analytics.trackEvent('ToolBar', 'Copy Warning');
} else {
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
} }
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}, },
onIncreaseFontSize: function(e) { onIncreaseFontSize: function(e) {