/* * (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.view.File", { extend: "Ext.panel.Panel", alias: "widget.defile", cls: "de-file-body", layout: "card", toolbarWidth: 260, activeBtn: undefined, requires: ["Ext.toolbar.Toolbar", "Ext.button.Button", "Ext.container.Container"], uses: ["DE.view.DocumentInfo", "DE.view.DocumentHelp", "DE.view.DocumentSettings", "Common.view.About"], listeners: { afterrender: function (Component, eOpts) { var cnt = this.ownerCt; if (Ext.isDefined(cnt)) { cnt.addListener("show", Ext.Function.bind(this._onShow, this)); cnt.addListener("hide", Ext.Function.bind(this._onHide, this)); } } }, initComponent: function () { this.addEvents("editdocument"); this.callParent(arguments); }, loadConfig: function (data) { this.editorConfig = data.config; }, loadDocument: function (data) { this.document = data.doc; }, _onShow: function () { if (this.activeBtn === undefined) { var btn = this[this.btnDomnloadAs.isVisible() ? "btnDomnloadAs" : "btnDocumentInfo"]; this.activeBtn = btn.toggle(true); } else { this.redrawButton(this.activeBtn); } if (this.activeBtn == this.btnDocumentInfo) { this.getLayout().setActiveItem(this.cardDocumentInfo); this.cardDocumentInfo.updateStatisticInfo(); } else { if (this.activeBtn == this.btnDocumentSettings) { this.getLayout().setActiveItem(this.cardDocumentSettings); this.cardDocumentSettings.updateSettings(); } } }, _onHide: function () { if (this.activeBtn == this.btnDocumentInfo) { this.cardDocumentInfo.stopUpdatingStatisticInfo(); } }, buildItems: function () { var docInfo = [{ name: "PDF", imgCls: "doc-format btn-pdf", type: c_oAscFileType.PDF }, { name: "DOCX", imgCls: "doc-format btn-docx", type: c_oAscFileType.DOCX }]; this.cardDownloadAs = Ext.widget("container", { cls: "de-file-table", layout: { type: "table", columns: 3 } }); var me = this; Ext.each(docInfo, function (item) { this.cardDownloadAs.add({ xtype: "container", items: [{ xtype: "button", id: "file-format-" + item.name, cls: item.imgCls + " download-button-style", docType: item.type, width: 102, height: 129, margin: "65px 25px 0 25px", listeners: { click: Ext.bind(function (btn) { var api = me.ownerCt.getApi(); if (api) { api.asc_DownloadAs(btn.docType); me.closeMenu(); } Common.component.Analytics.trackEvent("Download As", item.name); }, this) } }] }); }, this); this.cardDocumentInfo = Ext.widget("dedocumentinfo"); this.cardCreateNew = Ext.widget("decreatenew"); this.cardRecentFiles = Ext.widget("derecentfiles"); this.cardHelp = Ext.widget("dedocumenthelp"); this.cardDocumentSettings = Ext.widget("dedocumentsettings"); this.cardDocumentSettings.addListener("savedocsettings", Ext.bind(this.closeMenu, this)); return [this.cardDownloadAs, this.cardDocumentInfo, this.cardCreateNew, this.cardRecentFiles, this.cardHelp, this.cardDocumentSettings]; }, buildDockedItems: function () { this.btnSave = Ext.create("Ext.button.Button", { id: "file-button-save", text: this.btnSaveCaption, textAlign: "left", enableToggle: true, cls: "asc-filemenu-btn", padding: "0 27px", height: 27, listeners: { click: Ext.bind(function (btnCall) { if (btnCall.pressed) { this.api = this.ownerCt.getApi(); if (this.api) { this.redrawButton(btnCall); this.api.asc_Save(); this.closeMenu(); } Common.component.Analytics.trackEvent("Save"); Common.component.Analytics.trackEvent("File Menu", "Save"); } }, this) } }); this.btnPrint = this.btnSave.cloneConfig({ id: "file-button-print", text: this.btnPrintCaption, listeners: { click: Ext.bind(function (btnCall) { if (btnCall.pressed) { this.api = this.ownerCt.getApi(); if (this.api) { this.api.asc_Print(); this.closeMenu(); } Common.component.Analytics.trackEvent("Print"); Common.component.Analytics.trackEvent("File Menu", "Print"); } }, this) } }); this.btnToEdit = this.btnSave.cloneConfig({ id: "file-button-edit", text: this.btnToEditCaption, listeners: { click: Ext.bind(function (btnCall) { this.redrawButton(btnCall); if (btnCall.pressed) { this.closeMenu(); this.fireEvent("editdocument"); Common.component.Analytics.trackEvent("Edit"); Common.component.Analytics.trackEvent("File Menu", "Edit"); } }, this) } }); this.btnDomnloadAs = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnDownloadCaption, this.cardDownloadAs), { id: "file-button-download" })); this.btnDocumentInfo = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnInfoCaption, this.cardDocumentInfo), { id: "file-button-info" })); this.btnDocumentSettings = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnSettingsCaption, this.cardDocumentSettings), { id: "file-button-settings" })); this.btnBack = this.btnSave.cloneConfig({ id: "file-button-back", text: this.btnBackCaption, listeners: { click: Ext.bind(function (btnCall) { this.redrawButton(btnCall); if (btnCall.pressed) { Common.Gateway.goBack(); this.closeMenu(); } }, this) } }); this.btnHelp = Ext.create("Ext.button.Button", this.getFileMenuButton(this.btnHelpCaption, this.cardHelp)); this.btnReturn = Ext.create("Ext.button.Button", { id: "file-button-return", text: this.btnReturnCaption, textAlign: "left", enableToggle: true, cls: "asc-filemenu-btn", padding: "0 27px", height: 27, listeners: { click: Ext.bind(function (btnCall) { if (btnCall.pressed) { this.closeMenu(); Common.component.Analytics.trackEvent("File Menu", "Return"); } }, this) } }); this.btnCreateNew = Ext.create("Ext.button.Button", { id: "file-button-createnew", text: this.btnCreateNewCaption, textAlign: "left", enableToggle: true, cls: "asc-filemenu-btn", padding: "0 27px", height: 27 }); this.btnOpenRecent = Ext.create("Ext.button.Button", Ext.applyIf(this.getFileMenuButton(this.btnRecentFilesCaption, this.cardRecentFiles), { id: "file-button-recentfiles", label: "Recent" })); this.tbFileMenu = Ext.create("Ext.toolbar.Toolbar", { dock: "left", layout: { type: "vbox", align: "stretch" }, cls: "de-file-toolbar", vertical: true, width: this.toolbarWidth, defaults: { height: 22, width: "100%" }, items: [{ xtype: "container", height: 15 }, this.btnReturn, this.getSeparator(), this.btnSave, this.btnToEdit, this.btnDomnloadAs, this.btnPrint, this.getSeparator(), this.btnOpenRecent, this.btnCreateNew, this.getSeparator(), this.btnDocumentInfo, this.getSeparator(), this.btnDocumentSettings, this.getSeparator(), this.btnHelp, this.getSeparator(), this.btnBack] }); return this.tbFileMenu; }, getSeparator: function () { return { xtype: "container", html: '