3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

View File

@@ -1,133 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("DE.controller.CreateFile", {
extend: "Ext.app.Controller",
views: ["CreateFile"],
stores: ["FileTemplates"],
refs: [{
ref: "filePanel",
selector: "defile"
}],
init: function () {
Common.Gateway.on("init", Ext.bind(this.loadConfig, this));
this.control({
"decreatenew": {
afterrender: Ext.bind(this.onRenderView, this, {
single: true
})
},
"decreatenew dataview": {
itemclick: this.onTemplateClick
}
});
},
applyConfig: function (config) {
if (config) {
this.createUrl = config.createUrl;
this.nativeApp = config.nativeApp;
var templates = this.getFileTemplatesStore();
if (templates && config.templates) {
templates.removeAll();
templates.add(config.templates);
}
}
},
loadConfig: function (data) {
if (data && data.config) {
this.createUrl = data.config.createUrl;
this.nativeApp = data.config.nativeApp;
var templates = this.getFileTemplatesStore();
if (templates && data.config.templates) {
templates.removeAll();
templates.add(data.config.templates);
}
}
},
onRenderView: function () {
var btnBlankDocument = Ext.fly("id-create-blank-document");
if (btnBlankDocument) {
btnBlankDocument.addClsOnOver("over");
btnBlankDocument.on("click", this.onBlankDocClick, this);
}
},
setApi: function (o) {
this.api = o;
return this;
},
onBlankDocClick: function (event, el) {
var filePanel = this.getFilePanel();
if (filePanel) {
filePanel.closeMenu();
}
if (this.nativeApp === true) {
if (this.api) {
this.api.OpenNewDocument();
}
} else {
if (Ext.isEmpty(this.createUrl)) {
Ext.MessageBox.show({
title: this.textError,
msg: this.textCanNotCreateNewDoc,
buttons: Ext.Msg.OK,
icon: Ext.Msg.ERROR,
width: 300
});
} else {
var newDocumentPage = window.open(Ext.String.format("{0}?title={1}&action=create&doctype=text", this.createUrl, this.newDocumentTitle));
if (newDocumentPage) {
newDocumentPage.focus();
}
Common.component.Analytics.trackEvent("Create New", "Blank");
}
}
},
onTemplateClick: function (view, record, item, index, e) {
var filePanel = this.getFilePanel();
if (filePanel) {
filePanel.closeMenu();
}
if (this.nativeApp === true) {
if (this.api) {
this.api.OpenNewDocument(record.data.name);
}
} else {
var newDocumentPage = window.open(Ext.String.format("{0}?title={1}&template={2}&action=create&doctype=text", this.createUrl, this.newDocumentTitle, record.data.name));
if (newDocumentPage) {
newDocumentPage.focus();
}
}
Common.component.Analytics.trackEvent("Create New");
},
newDocumentTitle: "Unnamed document",
textError: "Error",
textCanNotCreateNewDoc: "Can not create a new document. Address to create a document is not configured."
});

View File

@@ -1,113 +1,103 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("DE.controller.DocumentHolder", {
extend: "Ext.app.Controller",
views: ["DocumentHolder"],
refs: [{
ref: "splitterMainMenu",
selector: "#main-menu-splitter"
}],
init: function () {
this.control({
"menuitem[group=popupparagraphvalign]": {
click: this._onParagraphVAlign
},
"#view-main-menu": {
panelbeforeshow: function (fullscreen) {
this._isMenuHided = true;
if (fullscreen !== true) {
this.getSplitterMainMenu().show();
}
},
panelbeforehide: function () {
this._isMenuHided = true;
},
panelshow: function (panel, fulscreen) {
this._isMenuHided = false;
if (!fulscreen) {
if (!panel.isSizeInit) {
panel.isSizeInit = true;
var view = panel.down("dataview");
if (view) {
var nodes = view.getNodes(),
width_parent = panel.getWidth();
for (var item in nodes) {
nodes[item].style["width"] = width_parent + "px";
}
}
}
}
},
panelhide: function (panel, fulscreen) {
this._isMenuHided = false;
this.getSplitterMainMenu().hide();
}
},
"#main-menu-splitter": {
beforedragstart: function (obj, event) {
return !event.currentTarget.disabled;
},
move: this._onDocumentSplitterMove
}
});
},
setApi: function (o) {
this.api = o;
return this;
},
_onDocumentSplitterMove: function (obj, x, y) {
if (this._isMenuHided) {
return;
}
var jsp_container, width_parent = obj.up("container").down("demainmenu").getWidth();
if (width_parent > 40) {
width_parent -= 40;
Ext.ComponentQuery.query("dataview[group=scrollable]").forEach(function (list) {
var nodes = list.getNodes();
for (var item in nodes) {
nodes[item].style["width"] = width_parent + "px";
}
list.getEl().setWidth(width_parent);
jsp_container = list.getEl().down(".jspContainer");
if (jsp_container) {
jsp_container.setWidth(width_parent);
list.getEl().down(".jspPane").setWidth(width_parent);
}
});
}
},
_onParagraphVAlign: function (item, e) {
var properties = new CImgProperty();
properties.put_VerticalTextAlign(item.valign);
this.api.ImgApply(properties);
}
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
var c_paragraphLinerule = {
LINERULE_LEAST: 0,
LINERULE_AUTO: 1,
LINERULE_EXACT: 2
};
var c_pageNumPosition = {
PAGE_NUM_POSITION_TOP: 1,
PAGE_NUM_POSITION_BOTTOM: 2,
PAGE_NUM_POSITION_RIGHT: 0,
PAGE_NUM_POSITION_LEFT: 1,
PAGE_NUM_POSITION_CENTER: 2
};
var c_tableWrap = {
TABLE_WRAP_NONE: 0,
TABLE_WRAP_PARALLEL: 1
};
var c_tableAlign = {
TABLE_ALIGN_LEFT: 0,
TABLE_ALIGN_CENTER: 1,
TABLE_ALIGN_RIGHT: 2
};
var c_tableBorder = {
BORDER_VERTICAL_LEFT: 0,
BORDER_HORIZONTAL_TOP: 1,
BORDER_VERTICAL_RIGHT: 2,
BORDER_HORIZONTAL_BOTTOM: 3,
BORDER_VERTICAL_CENTER: 4,
BORDER_HORIZONTAL_CENTER: 5,
BORDER_INNER: 6,
BORDER_OUTER: 7,
BORDER_ALL: 8,
BORDER_NONE: 9,
BORDER_ALL_TABLE: 10,
BORDER_NONE_TABLE: 11,
BORDER_INNER_TABLE: 12,
BORDER_OUTER_TABLE: 13
};
define(["core", "documenteditor/main/app/view/DocumentHolder"], function () {
DE.Controllers.DocumentHolder = Backbone.Controller.extend({
models: [],
collections: [],
views: ["DocumentHolder"],
initialize: function () {},
onLaunch: function () {
this.documentHolder = this.createView("DocumentHolder").render();
this.documentHolder.el.tabIndex = -1;
},
setApi: function (api) {
this.api = api;
},
createDelayedElements: function () {
var diagramEditor = this.getApplication().getController("Common.Controllers.ExternalDiagramEditor").getView("Common.Views.ExternalDiagramEditor");
if (diagramEditor) {
diagramEditor.on("internalmessage", _.bind(function (cmp, message) {
var command = message.data.command;
var data = message.data.data;
if (this.api) {
(diagramEditor.isEditMode()) ? this.api.asc_editChartDrawingObject(data) : this.api.asc_addChartDrawingObject(data);
}
},
this));
diagramEditor.on("hide", _.bind(function (cmp, message) {
this.documentHolder.fireEvent("editcomplete", this.documentHolder);
if (this.api) {
this.api.asc_enableKeyEvents(true);
}
},
this));
}
}
});
});

View File

@@ -0,0 +1,429 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["core", "common/main/lib/util/Shortcuts", "documenteditor/main/app/view/LeftMenu", "documenteditor/main/app/view/FileMenu"], function () {
DE.Controllers.LeftMenu = Backbone.Controller.extend(_.extend({
views: ["LeftMenu", "FileMenu"],
initialize: function () {
this.addListeners({
"Common.Views.Chat": {
"hide": _.bind(this.onHideChat, this)
},
"Statusbar": {
"click:users": _.bind(this.clickStatusbarUsers, this)
},
"LeftMenu": {
"comments:show": _.bind(this.commentsShowHide, this, "show"),
"comments:hide": _.bind(this.commentsShowHide, this, "hide")
},
"Common.Views.About": {
"show": _.bind(this.aboutShowHide, this, false),
"hide": _.bind(this.aboutShowHide, this, true)
},
"FileMenu": {
"filemenu:hide": _.bind(this.menuFilesHide, this),
"item:click": _.bind(this.clickMenuFileItem, this),
"saveas:format": _.bind(this.clickSaveAsFormat, this),
"settings:apply": _.bind(this.applySettings, this),
"create:new": _.bind(this.onCreateNew, this),
"recent:open": _.bind(this.onOpenRecent, this)
},
"Toolbar": {
"file:settings": _.bind(this.clickToolbarSettings, this)
},
"SearchDialog": {
"hide": _.bind(this.onSearchDlgHide, this),
"search:back": _.bind(this.onQuerySearch, this, "back"),
"search:next": _.bind(this.onQuerySearch, this, "next"),
"search:replace": _.bind(this.onQueryReplace, this),
"search:replaceall": _.bind(this.onQueryReplaceAll, this),
"search:highlight": _.bind(this.onSearchHighlight, this)
}
});
Common.NotificationCenter.on("leftmenu:change", _.bind(this.onMenuChange, this));
},
onLaunch: function () {
this.leftMenu = this.createView("LeftMenu").render();
this.leftMenu.btnSearch.on("toggle", _.bind(this.onMenuSearch, this));
Common.util.Shortcuts.delegateShortcuts({
shortcuts: {
"command+shift+s,ctrl+shift+s": _.bind(this.onShortcut, this, "save"),
"command+f,ctrl+f": _.bind(this.onShortcut, this, "search"),
"command+h,ctrl+h": _.bind(this.onShortcut, this, "replace"),
"alt+f": _.bind(this.onShortcut, this, "file"),
"esc": _.bind(this.onShortcut, this, "escape"),
"ctrl+alt+q": _.bind(this.onShortcut, this, "chat"),
"command+shift+h,ctrl+shift+h": _.bind(this.onShortcut, this, "comments"),
"f1": _.bind(this.onShortcut, this, "help")
}
});
Common.util.Shortcuts.suspendEvents();
},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback("asc_onReplaceAll", _.bind(this.onApiTextReplaced, this));
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", _.bind(this.onApiServerDisconnect, this));
Common.NotificationCenter.on("api:disconnect", _.bind(this.onApiServerDisconnect, this));
if (this.mode.canCoAuthoring) {
this.api.asc_registerCallback("asc_onCoAuthoringChatReceiveMessage", _.bind(this.onApiChatMessage, this));
}
this.leftMenu.getMenu("file").setApi(api);
return this;
},
setMode: function (mode) {
this.mode = mode;
this.leftMenu.setMode(mode);
this.leftMenu.getMenu("file").setMode(mode);
return this;
},
createDelayedElements: function () {
if (this.mode.canCoAuthoring) {
this.leftMenu.btnComments[this.mode.isEdit ? "show" : "hide"]();
this.leftMenu.btnChat.show();
this.leftMenu.setOptionsPanel("chat", this.getApplication().getController("Common.Controllers.Chat").getView("Common.Views.Chat"));
this.leftMenu.setOptionsPanel("comment", this.getApplication().getController("Common.Controllers.Comments").getView("Common.Views.Comments"));
} else {
this.leftMenu.btnChat.hide();
this.leftMenu.btnComments.hide();
}
Common.util.Shortcuts.resumeEvents();
return this;
},
clickMenuFileItem: function (menu, action, isopts) {
var close_menu = true;
switch (action) {
case "back":
break;
case "save":
this.api.asc_Save();
break;
case "print":
this.api.asc_Print();
break;
case "exit":
Common.Gateway.goBack();
break;
case "edit":
this.getApplication().getController("Statusbar").setStatusCaption(this.requestEditRightsText);
Common.Gateway.requestEditRights();
break;
case "new":
if (isopts) {
close_menu = false;
} else {
this.onCreateNew(undefined, "blank");
}
break;
default:
close_menu = false;
}
if (close_menu) {
menu.hide();
this.leftMenu.btnFile.toggle(false, true);
}
},
clickSaveAsFormat: function (menu, format) {
this.api.asc_DownloadAs(format);
menu.hide();
this.leftMenu.btnFile.toggle(false, true);
},
applySettings: function (menu) {
var value = window.localStorage.getItem("de-settings-inputmode");
this.api.SetTextBoxInputMode(parseInt(value) == 1);
switch (window.localStorage.getItem("de-settings-showchanges")) {
case "all":
value = c_oAscCollaborativeMarksShowType.All;
break;
case "none":
value = c_oAscCollaborativeMarksShowType.None;
break;
default:
value = c_oAscCollaborativeMarksShowType.LastChanges;
}
this.api.SetCollaborativeMarksShowType(value);
value = window.localStorage.getItem("de-settings-livecomment");
(!(value !== null && parseInt(value) == 0)) ? this.api.asc_showComments() : this.api.asc_hideComments();
value = window.localStorage.getItem("de-settings-fontrender");
switch (value) {
case "1":
this.api.SetFontRenderingMode(1);
break;
case "2":
this.api.SetFontRenderingMode(2);
break;
case "0":
this.api.SetFontRenderingMode(3);
break;
}
if (this.mode.canAutosave) {
value = window.localStorage.getItem("de-settings-autosave");
this.api.asc_setAutoSaveGap(parseInt(value));
}
value = window.localStorage.getItem("de-settings-spellcheck");
this.api.asc_setSpellCheck(value === null || parseInt(value) == 1);
value = window.localStorage.getItem("de-settings-showsnaplines");
this.api.put_ShowSnapLines(value === null || parseInt(value) == 1);
menu.hide();
this.leftMenu.btnFile.toggle(false, true);
},
onCreateNew: function (menu, type) {
if (this.mode.nativeApp === true) {
this.api.OpenNewDocument(type == "blank" ? "" : type);
} else {
var newDocumentPage = window.open(_.template("<%= url %>?title=<%= title %>" + '<% if (doctype != "blank") { %>&template=<%= doctype %><% } %>' + "&action=create&doctype=text", {
url: this.mode.createUrl,
title: this.newDocumentTitle,
doctype: type
}));
if (newDocumentPage) {
newDocumentPage.focus();
}
}
if (menu) {
menu.hide();
this.leftMenu.btnFile.toggle(false, true);
}
},
onOpenRecent: function (menu, url) {
if (menu) {
menu.hide();
this.leftMenu.btnFile.toggle(false, true);
}
var recentDocPage = window.open(url);
if (recentDocPage) {
recentDocPage.focus();
}
Common.component.Analytics.trackEvent("Open Recent");
},
clickToolbarSettings: function (obj) {
if (this.leftMenu.btnFile.pressed && this.leftMenu.btnFile.panel.active == "opts") {
this.leftMenu.close();
} else {
this.leftMenu.showMenu("file:opts");
}
},
clickStatusbarUsers: function () {
if (this.mode.canCoAuthoring) {
if (this.leftMenu.btnChat.pressed) {
this.leftMenu.close();
} else {
this.leftMenu.showMenu("chat");
}
}
},
onHideChat: function () {
$(this.leftMenu.btnChat.el).blur();
Common.NotificationCenter.trigger("layout:changed", "leftmenu");
},
onQuerySearch: function (d, w, opts) {
if (opts.textsearch && opts.textsearch.length) {
if (!this.api.asc_findText(opts.textsearch, d != "back", opts.matchcase, opts.matchword)) {
var me = this;
Common.UI.info({
msg: this.textNoTextFound,
callback: function () {
me.dlgSearch.focus();
}
});
}
}
},
onQueryReplace: function (w, opts) {
if (!_.isEmpty(opts.textsearch) && !_.isEmpty(opts.textreplace)) {
if (!this.api.asc_replaceText(opts.textsearch, opts.textreplace, false, opts.matchcase, opts.matchword)) {
var me = this;
Common.UI.info({
msg: this.textNoTextFound,
callback: function () {
me.dlgSearch.focus();
}
});
}
}
},
onQueryReplaceAll: function (w, opts) {
if (!_.isEmpty(opts.textsearch) && !_.isEmpty(opts.textreplace)) {
this.api.asc_replaceText(opts.textsearch, opts.textreplace, true, opts.matchcase, opts.matchword);
}
},
onSearchHighlight: function (w, highlight) {
this.api.asc_selectSearchingResults(highlight);
},
showSearchDlg: function (show, action) {
if (!this.dlgSearch) {
this.dlgSearch = (new Common.UI.SearchDialog({
matchcase: true,
markresult: {
applied: true
}
}));
}
if (show) {
var mode = this.mode.isEdit ? (action || undefined) : "no-replace";
if (this.dlgSearch.isVisible()) {
this.dlgSearch.setMode(mode);
this.dlgSearch.focus();
} else {
this.dlgSearch.show(mode);
}
} else {
this.dlgSearch["hide"]();
}
},
onMenuSearch: function (obj, show) {
this.showSearchDlg(show);
},
onSearchDlgHide: function () {
this.leftMenu.btnSearch.toggle(false, true);
this.api.asc_selectSearchingResults(false);
$(this.leftMenu.btnSearch.el).blur();
this.api.asc_enableKeyEvents(true);
},
onApiTextReplaced: function (found, replaced) {
var me = this;
if (found) { ! (found - replaced > 0) ? Common.UI.info({
msg: Common.Utils.String.format(this.textReplaceSuccess, replaced)
}) : Common.UI.warning({
msg: Common.Utils.String.format(this.textReplaceSkipped, found - replaced)
});
} else {
Common.UI.info({
msg: this.textNoTextFound
});
}
},
onApiServerDisconnect: function () {
this.mode.isEdit = false;
this.leftMenu.close();
this.leftMenu.btnComments.setDisabled(true);
this.leftMenu.btnChat.setDisabled(true);
this.leftMenu.getMenu("file").setMode({
isDisconnected: true
});
if (this.dlgSearch) {
this.leftMenu.btnSearch.toggle(false, true);
this.dlgSearch["hide"]();
}
},
onApiChatMessage: function () {
this.leftMenu.markCoauthOptions();
},
commentsShowHide: function (mode) {
var value = window.localStorage.getItem("de-settings-livecomment");
if (value !== null && 0 === parseInt(value)) {
(mode === "show") ? this.api.asc_showComments() : this.api.asc_hideComments();
}
if (mode === "show") {
this.getApplication().getController("Common.Controllers.Comments").focusOnInput();
} else {
$(this.leftMenu.btnComments.el).blur();
}
},
aboutShowHide: function (value) {
if (this.api) {
this.api.asc_enableKeyEvents(value);
}
if (value) {
$(this.leftMenu.btnAbout.el).blur();
}
},
menuFilesHide: function (obj) {
$(this.leftMenu.btnFile.el).blur();
},
onMenuChange: function (value) {
if ("hide" === value) {
if (this.leftMenu.btnComments.isActive() && this.api) {
this.leftMenu.btnComments.toggle(false);
this.leftMenu.onBtnMenuClick(this.leftMenu.btnComments);
this.api.asc_enableKeyEvents(true);
}
}
},
onShortcut: function (s, e) {
switch (s) {
case "replace":
case "search":
Common.UI.Menu.Manager.hideAll();
this.showSearchDlg(true, s);
this.leftMenu.btnSearch.toggle(true, true);
this.leftMenu.btnFile.toggle(false);
this.leftMenu.btnAbout.toggle(false);
return false;
case "save":
if (this.mode.canDownload) {
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu("file:saveas");
}
return false;
case "help":
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu("file:help");
return false;
case "file":
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu("file");
return false;
case "escape":
var statusbar = DE.getController("Statusbar");
var menu_opened = statusbar.statusbar.$el.find('.open > [data-toggle="dropdown"]');
if (menu_opened.length) {
$.fn.dropdown.Constructor.prototype.keydown.call(menu_opened[0], e);
return false;
}
if (this.leftMenu.btnFile.pressed || this.leftMenu.btnAbout.pressed || $(e.target).parents("#left-menu").length) {
this.leftMenu.close();
Common.NotificationCenter.trigger("layout:changed", "leftmenu");
return false;
}
break;
case "chat":
if (this.mode.canCoAuthoring) {
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu("chat");
}
return false;
case "comments":
if (this.mode.canCoAuthoring && this.mode.isEdit) {
Common.UI.Menu.Manager.hideAll();
this.leftMenu.showMenu("comments");
this.getApplication().getController("Common.Controllers.Comments").focusOnInput();
}
return false;
}
},
textNoTextFound: "Text not found",
newDocumentTitle: "Unnamed document",
requestEditRightsText: "Requesting editing rights...",
textReplaceSuccess: "Search has been done. {0} occurrences have been replaced",
textReplaceSkipped: "The replacement has been made. {0} occurrences were skipped."
},
DE.Controllers.LeftMenu || {}));
});

File diff suppressed because it is too large Load Diff

View File

@@ -1,66 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("DE.controller.RecentFiles", {
extend: "Ext.app.Controller",
views: ["RecentFiles"],
stores: ["RecentFiles"],
refs: [{
ref: "filePanel",
selector: "defile"
}],
init: function () {
Common.Gateway.on("init", Ext.bind(this.loadConfig, this));
this.control({
"derecentfiles dataview": {
itemclick: this.onRecentFileClick
}
});
},
loadConfig: function (data) {
var recent = this.getRecentFilesStore();
if (recent && data && data.config && data.config.recent) {
recent.removeAll();
recent.add(data.config.recent);
}
},
onRecentFileClick: function (view, record, item, index, e) {
var filePanel = this.getFilePanel();
if (filePanel) {
filePanel.closeMenu();
}
var recentDocPage = window.open(record.data.url);
if (recentDocPage) {
recentDocPage.focus();
}
Common.component.Analytics.trackEvent("Open Recent");
}
});

View File

@@ -0,0 +1,279 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["core", "documenteditor/main/app/view/RightMenu"], function () {
DE.Controllers.RightMenu = Backbone.Controller.extend({
models: [],
collections: [],
views: ["RightMenu"],
initialize: function () {
this.editMode = true;
this.addListeners({
"RightMenu": {
"rightmenuclick": this.onRightMenuClick
}
});
},
onLaunch: function () {
this.rightmenu = this.createView("RightMenu");
this.rightmenu.on("render:after", _.bind(this.onRightMenuAfterRender, this));
},
onRightMenuAfterRender: function (rightMenu) {
rightMenu.shapeSettings.application = this.getApplication();
this._settings = [];
this._settings[c_oAscTypeSelectElement.Paragraph] = {
panelId: "id-paragraph-settings",
panel: rightMenu.paragraphSettings,
btn: rightMenu.btnText,
hidden: 1,
locked: false
};
this._settings[c_oAscTypeSelectElement.Table] = {
panelId: "id-table-settings",
panel: rightMenu.tableSettings,
btn: rightMenu.btnTable,
hidden: 1,
locked: false
};
this._settings[c_oAscTypeSelectElement.Image] = {
panelId: "id-image-settings",
panel: rightMenu.imageSettings,
btn: rightMenu.btnImage,
hidden: 1,
locked: false
};
this._settings[c_oAscTypeSelectElement.Header] = {
panelId: "id-header-settings",
panel: rightMenu.headerSettings,
btn: rightMenu.btnHeaderFooter,
hidden: 1,
locked: false,
needShow: true
};
this._settings[c_oAscTypeSelectElement.Shape] = {
panelId: "id-shape-settings",
panel: rightMenu.shapeSettings,
btn: rightMenu.btnShape,
hidden: 1,
locked: false
};
this._settings[c_oAscTypeSelectElement.Chart] = {
panelId: "id-chart-settings",
panel: rightMenu.chartSettings,
btn: rightMenu.btnChart,
hidden: 1,
locked: false
};
},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on("api:disconnect", _.bind(this.onCoAuthoringDisconnect, this));
},
setMode: function (mode) {
this.editMode = mode.isEdit;
},
onRightMenuClick: function (menu, type, minimized) {
if (!minimized && this.editMode) {
var panel = this._settings[type].panel;
var props = this._settings[type].props;
if (props && panel) {
panel.ChangeSettings.call(panel, props);
}
}
Common.NotificationCenter.trigger("layout:changed", "rightmenu");
this.rightmenu.fireEvent("editcomplete", this.rightmenu);
},
onFocusObject: function (SelectedObjects) {
if (!this.editMode) {
return;
}
var needhide = true;
for (var i = 0; i < this._settings.length; i++) {
if (this._settings[i]) {
this._settings[i].hidden = 1;
this._settings[i].locked = false;
}
}
var isChart = false;
for (i = 0; i < SelectedObjects.length; i++) {
var type = SelectedObjects[i].get_ObjectType();
if (type >= this._settings.length || this._settings[type] === undefined) {
continue;
}
var value = SelectedObjects[i].get_ObjectValue();
if (type == c_oAscTypeSelectElement.Image) {
if (value.get_ChartProperties() !== null) {
isChart = true;
type = c_oAscTypeSelectElement.Chart;
} else {
if (value.get_ShapeProperties() !== null) {
isChart = value.get_ShapeProperties().get_FromChart();
type = c_oAscTypeSelectElement.Shape;
}
}
} else {
if (type == c_oAscTypeSelectElement.Paragraph) {
this._settings[type].panel.isChart = isChart;
}
}
this._settings[type].props = value;
this._settings[type].hidden = 0;
this._settings[type].locked = value.get_Locked();
}
if (this._settings[c_oAscTypeSelectElement.Header].locked) {
for (i = 0; i < this._settings.length; i++) {
if (this._settings[i]) {
this._settings[i].locked = true;
}
}
}
var lastactive = -1,
currentactive, priorityactive = -1;
for (i = 0; i < this._settings.length; i++) {
var pnl = this._settings[i];
if (pnl === undefined) {
continue;
}
if (pnl.hidden) {
if (!pnl.btn.isDisabled()) {
pnl.btn.setDisabled(true);
}
if (this.rightmenu.GetActivePane() == pnl.panelId) {
currentactive = -1;
}
} else {
if (pnl.btn.isDisabled()) {
pnl.btn.setDisabled(false);
}
lastactive = i;
if (pnl.needShow) {
pnl.needShow = false;
priorityactive = i;
} else {
if (this.rightmenu.GetActivePane() == pnl.panelId) {
currentactive = i;
}
}
pnl.panel.setLocked(pnl.locked);
}
}
if (!this.rightmenu.minimizedMode) {
var active;
if (priorityactive > -1) {
active = priorityactive;
} else {
if (lastactive >= 0 && currentactive < 0) {
active = lastactive;
} else {
if (currentactive >= 0) {
active = currentactive;
}
}
}
if (active !== undefined) {
this.rightmenu.SetActivePane(active);
this._settings[active].panel.ChangeSettings.call(this._settings[active].panel, this._settings[active].props);
}
}
this._settings[c_oAscTypeSelectElement.Image].needShow = false;
this._settings[c_oAscTypeSelectElement.Chart].needShow = false;
this._settings[c_oAscTypeSelectElement.Shape].needShow = false;
},
onCoAuthoringDisconnect: function () {
if (this.rightmenu) {
this.rightmenu.SetDisabled("", true, true);
}
this.setMode({
isEdit: false
});
},
onInsertTable: function () {
this._settings[c_oAscTypeSelectElement.Table].needShow = true;
},
onInsertImage: function () {
this._settings[c_oAscTypeSelectElement.Image].needShow = true;
},
onInsertChart: function () {
this._settings[c_oAscTypeSelectElement.Chart].needShow = true;
},
onInsertShape: function () {
this._settings[c_oAscTypeSelectElement.Shape].needShow = true;
},
UpdateThemeColors: function () {
this.rightmenu.paragraphSettings.UpdateThemeColors();
this.rightmenu.tableSettings.UpdateThemeColors();
this.rightmenu.shapeSettings.UpdateThemeColors();
},
updateMetricUnit: function () {
this.rightmenu.headerSettings.updateMetricUnit();
this.rightmenu.paragraphSettings.updateMetricUnit();
this.rightmenu.chartSettings.updateMetricUnit();
this.rightmenu.imageSettings.updateMetricUnit();
},
createDelayedElements: function () {
var me = this;
if (this.api) {
this.api.asc_registerCallback("asc_onFocusObject", _.bind(this.onFocusObject, this));
this.api.asc_registerCallback("asc_doubleClickOnObject", _.bind(this.onDoubleClickOnObject, this));
}
if (this.editMode && this.api) {
var selectedElements = this.api.getSelectedElements();
if (selectedElements.length > 0) {
this.onFocusObject(selectedElements);
}
}
},
onDoubleClickOnObject: function (obj) {
if (!this.editMode) {
return;
}
var type = obj.get_ObjectType();
if (type >= this._settings.length || this._settings[type] === undefined) {
return;
}
var value = obj.get_ObjectValue();
if (type == c_oAscTypeSelectElement.Image) {
if (value.get_ChartProperties() !== null) {
type = c_oAscTypeSelectElement.Chart;
} else {
if (value.get_ShapeProperties() !== null) {
type = c_oAscTypeSelectElement.Shape;
}
}
}
if (type !== c_oAscTypeSelectElement.Paragraph) {
this.rightmenu.SetActivePane(type, true);
this._settings[type].panel.ChangeSettings.call(this._settings[type].panel, this._settings[type].props);
}
}
});
});

View File

@@ -1,207 +0,0 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* 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
*
*/
Ext.define("DE.controller.Search", {
extend: "Ext.app.Controller",
refs: [{
ref: "searchDialog",
selector: "commonsearchdialog"
},
{
ref: "searchQuery",
selector: "#search-dialog-text-search"
},
{
ref: "replaceQuery",
selector: "#search-dialog-text-replace"
}],
init: function () {
this.control({
"demainmenu #id-menu-search": {
toggle: this._showSearchDialog
},
"commonsearchdialog": {
show: function (obj) {
this.setDefaultView();
this.api.asc_selectSearchingResults(obj.getSettings().highlight);
},
hide: function () {
this.api.asc_selectSearchingResults(false);
this.api.asc_searchEnabled(false);
}
},
"commonsearchdialog button[group=search-text]": {
click: function (btn) {
this._startSearch(btn.direction);
}
},
"commonsearchdialog button[group=replace-text]": {
click: this.btnReplaceText
},
"#search-dialog-text-search": {
searchstart: function (obj, text) {
this._startSearch("next");
obj.stopSearch(true);
}
},
"commonsearchdialog checkbox[action=highlight]": {
change: function (obj, newValue, oldValue) {
this.api.asc_selectSearchingResults(newValue);
}
}
});
},
setApi: function (o) {
this.api = o;
this.api.asc_registerCallback("asc_onReplaceAll", Ext.bind(this._onReplaceText, this));
this.api.asc_registerCallback("asc_onСoAuthoringDisconnect", Ext.bind(this.onCoAuthoringDisconnect, this));
},
setMode: function (mode) {
this.mode = mode;
if (this._frmSearch) {
this._frmSearch.setViewMode(!this.mode.isEdit);
}
},
setDefaultView: function () {
this.getSearchDialog().searchMode();
},
_showSearchDialog: function (btn, pressed) {
var mainmenu = Ext.getCmp("view-main-menu");
if (pressed) {
mainmenu.closeFullScaleMenu();
var me = this;
if (!me._frmSearch) {
me._frmSearch = Ext.create("Common.view.SearchDialog", {
animateTarget: "id-menu-search",
closeAction: "hide",
wholewords: false,
highlight: {
checked: true
},
isViewMode: !this.mode.isEdit
});
me._frmSearch.addListener("hide", function (cnt, eOpts) {
if (!btn.ownrise) {
btn.ownrise = true;
btn.toggle(false);
if (!Ext.isDefined(mainmenu.currentFullScaleMenuBtn)) {
mainmenu.fireEvent("editcomplete", mainmenu);
}
}
btn.ownrise = false;
});
}
me._frmSearch.show();
} else {
if (this._frmSearch && !btn.ownrise) {
btn.ownrise = true;
this._frmSearch.hide();
if (!Ext.isDefined(mainmenu.currentFullScaleMenuBtn)) {
mainmenu.fireEvent("editcomplete", mainmenu);
}
}
}
},
btnReplaceText: function (btn, event, opts) {
var me = this;
if (me.getSearchQuery().isValueValid()) {
var sett = this.getSearchDialog().getSettings();
if (btn.type == "all") {
this.api.asc_replaceText(sett.textsearch, sett.textreplace, true, sett.casesensitive, sett.wholewords);
} else {
if (!this.api.asc_replaceText(sett.textsearch, sett.textreplace, false, sett.casesensitive, sett.wholewords)) {
this.showWarning(this.textNoTextFound);
}
}
}
},
_startSearch: function (direction) {
if (this.getSearchQuery().isValueValid()) {
var sett = this.getSearchDialog().getSettings();
if (!this.api.asc_findText(sett.textsearch, direction == "next", sett.casesensitive, sett.wholewords)) {
this.showWarning(this.textNoTextFound);
}
}
},
showWarning: function (text) {
var me = this;
if (!this.msgbox) {
this.msgbox = Ext.create("Ext.window.MessageBox", {
listeners: {
beforehide: function () {
me.getSearchQuery().focus(true, 100);
}
}
});
}
var config = {
title: this.textSearch,
msg: text,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK
};
if (Common.userAgent.isIE) {
var oldFn = {
enter: Ext.FocusManager.navigateIn,
esc: Ext.FocusManager.navigateOut
};
Ext.FocusManager.navigateIn = Ext.emptyFn;
Ext.FocusManager.navigateOut = function (event) {
me.msgbox.close();
};
config.fn = function (btn) {
Ext.FocusManager.navigateIn = oldFn.enter;
Ext.FocusManager.navigateOut = oldFn.esc;
};
}
this.msgbox.show(config);
},
_onReplaceText: function (found, replaced) {
var me = this;
if (found) {
if (! (found - replaced)) {
me.showWarning(Ext.String.format(this.textReplaceSuccess, replaced));
} else {
me.showWarning(Ext.String.format(this.textReplaceSkipped, found - replaced));
}
} else {
me.showWarning(me.textNoTextFound);
}
},
onCoAuthoringDisconnect: function () {
this.mode.isEdit = false;
this._frmSearch && this._frmSearch.setViewMode(true);
},
textSearch: "Search",
textNoTextFound: "Text not found",
textReplaceSuccess: "Search has been done. {0} occurrences have been replaced",
textReplaceSkipped: "The replacement has been made. {0} occurrences were skipped."
});

View File

@@ -0,0 +1,165 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["core", "documenteditor/main/app/view/Statusbar", "common/main/lib/util/LanguageInfo"], function () {
DE.Controllers.Statusbar = Backbone.Controller.extend(_.extend({
models: [],
collections: [],
views: ["Statusbar"],
initialize: function () {
this.addListeners({
"FileMenu": {
"settings:apply": _.bind(this.applySettings, this)
},
"Statusbar": {
"langchanged": this.onLangMenu
}
});
},
events: function () {
return {
"click #btn-zoom-down": _.bind(this.zoomDocument, this, "down"),
"click #btn-zoom-up": _.bind(this.zoomDocument, this, "up"),
"click #btn-doc-lang": _.bind(this.onBtnLanguage, this)
};
},
onLaunch: function () {
this.statusbar = this.createView("Statusbar").render();
this.statusbar.$el.css("z-index", 1);
this.bindViewEvents(this.statusbar, this.events);
$("#status-label-zoom").css("min-width", 70);
this.statusbar.btnSetSpelling.on("click", _.bind(this.onBtnSpelling, this));
this.statusbar.btnZoomToPage.on("click", _.bind(this.onBtnZoomTo, this, "topage"));
this.statusbar.btnZoomToWidth.on("click", _.bind(this.onBtnZoomTo, this, "towidth"));
this.statusbar.zoomMenu.on("item:click", _.bind(this.menuZoomClick, this));
},
setApi: function (api) {
this.api = api;
this.api.asc_registerCallback("asc_onZoomChange", _.bind(this._onZoomChange, this));
this.api.asc_registerCallback("asc_onTextLanguage", _.bind(this._onTextLanguage, this));
this.statusbar.setApi(api);
},
onBtnZoomTo: function (d, b, e) {
if (!b.pressed) {
this.api.zoomCustomMode();
} else {
this.api[d == "topage" ? "zoomFitToPage" : "zoomFitToWidth"]();
}
},
zoomDocument: function (d, e) {
switch (d) {
case "up":
this.api.zoomIn();
break;
case "down":
this.api.zoomOut();
break;
}
},
menuZoomClick: function (menu, item) {
this.api.zoom(item.value);
},
_onZoomChange: function (percent, type) {
this.statusbar.btnZoomToPage.toggle(type == 2, true);
this.statusbar.btnZoomToWidth.toggle(type == 1, true);
$("#status-label-zoom").text(Common.Utils.String.format(this.zoomText, percent));
},
_onTextLanguage: function (langId) {
var info = Common.util.LanguageInfo.getLocalLanguageName(langId);
this.statusbar.setLanguage({
tip: info[0],
title: info[1],
code: langId
});
},
setLanguages: function (apiLangs) {
var langs = this.langs = [],
info;
_.each(apiLangs, function (lang, index, list) {
info = Common.util.LanguageInfo.getLocalLanguageName(lang.asc_getId());
langs.push({
title: info[1],
tip: info[0],
code: lang.asc_getId()
});
},
this);
this.statusbar.reloadLanguages(langs);
},
setStatusCaption: function (text) {
if (text.length) {
this.statusbar.showStatusMessage(text);
} else {
this.statusbar.clearStatusMessage();
}
},
createDelayedElements: function () {
this.statusbar.$el.css("z-index", "");
var value = window.localStorage.getItem("de-settings-spellcheck");
this.statusbar.btnSetSpelling.toggle(value === null || parseInt(value) == 1, true);
},
onBtnLanguage: function () {
var langs = _.map(this.langs, function (item) {
return {
displayValue: item.title,
value: item.tip,
code: item.code
};
});
var me = this;
(new DE.Views.Statusbar.LanguageDialog({
languages: langs,
current: me.api.asc_getDefaultLanguage(),
handler: function (result, tip) {
if (result == "ok") {
var record = _.findWhere(langs, {
"value": tip
});
record && me.api.asc_setDefaultLanguage(record.code);
}
}
})).show();
},
onLangMenu: function (obj, langid, title) {
this.api.put_TextPrLang(langid);
},
onBtnSpelling: function (d, b, e) {
window.localStorage.setItem("de-settings-spellcheck", d.pressed ? 1 : 0);
this.api.asc_setSpellCheck(d.pressed);
},
applySettings: function (menu) {
var value = window.localStorage.getItem("de-settings-spellcheck");
this.statusbar.btnSetSpelling.toggle(value === null || parseInt(value) == 1, true);
},
zoomText: "Zoom {0}%"
},
DE.Controllers.Statusbar || {}));
});

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* 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
*
*/
define(["core", "common/main/lib/view/Header", "documenteditor/main/app/view/Viewport", "documenteditor/main/app/view/LeftMenu"], function (Viewport) {
DE.Controllers.Viewport = Backbone.Controller.extend({
models: [],
collections: [],
views: ["Viewport", "Common.Views.Header"],
initialize: function () {},
setApi: function (api) {
this.api = api;
},
onLaunch: function () {
this.viewport = this.createView("Viewport").render();
this.header = this.createView("Common.Views.Header", {
headerCaption: "Document Editor"
}).render();
Common.NotificationCenter.on("layout:changed", _.bind(this.onLayoutChanged, this));
$(window).on("resize", _.bind(this.onWindowResize, this));
this.viewport.hlayout.on("layout:resizedrag", function () {
this.api.Resize();
},
this);
this.boxSdk = $("#editor_sdk");
this.boxSdk.css("border-left", "none");
},
onLayoutChanged: function (area) {
switch (area) {
default:
this.viewport.vlayout.doLayout();
case "rightmenu":
this.viewport.hlayout.doLayout();
break;
case "leftmenu":
var panel = this.viewport.hlayout.items[0];
if (panel.resize.el) {
if (panel.el.width() > 40) {
this.boxSdk.css("border-left", "");
panel.resize.el.show();
} else {
panel.resize.el.hide();
this.boxSdk.css("border-left", "0 none");
}
}
this.viewport.hlayout.doLayout();
break;
case "header":
case "toolbar":
case "status":
this.viewport.vlayout.doLayout();
break;
}
this.api.Resize();
},
onWindowResize: function (e) {
this.onLayoutChanged("window");
}
});
});