/* * (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("SSE.view.File", { extend: "Ext.panel.Panel", alias: "widget.ssefile", cls: "sse-file-body", layout: "card", btnSaveCaption: "Save", btnDownloadCaption: "Download as...", btnInfoCaption: "Document Info...", btnCreateNewCaption: "Create New...", btnRecentFilesCaption: "Open Recent...", btnPrintCaption: "Print", btnHelpCaption: "Help...", btnReturnCaption: "Back to Document", btnToEditCaption: "Edit Document", btnBackCaption: "Go to Documents", btnSettingsCaption: "Advanced Settings...", toolbarWidth: 260, activeBtn: undefined, uses: ["Ext.container.Container", "Ext.toolbar.Toolbar", "Ext.button.Button", "SSE.view.DocumentInfo", "SSE.view.RecentFiles", "SSE.view.CreateFile", "SSE.view.DocumentHelp", "SSE.view.DocumentSettings"], listeners: { afterrender: function (Component, eOpts) { var cnt = this.ownerCt; if (Ext.isDefined(cnt)) { cnt.addListener("show", Ext.Function.bind(this._onShow, this)); } } }, constructor: function (config) { this.initConfig(config); this.callParent(arguments); return this; }, initComponent: function () { var me = this; this.addEvents("editdocument", "downloadas"); this.callParent(arguments); }, loadConfig: function (data) { this.editorConfig = data.config; }, _onShow: function () { if (this.activeBtn === undefined) { this.activeBtn = this.btnDownloadAs.isVisible() ? this.btnCreateNew : this.btnDocumentInfo; } if (this.activeBtn == this.btnDocumentInfo) { this.getLayout().setActiveItem(this.cardDocumentInfo); } else { if (this.activeBtn == this.btnDocumentSettings) { this.getLayout().setActiveItem(this.cardDocumentSettings); this.cardDocumentSettings.updateSettings(); } else { if (this.activeBtn == this.btnCreateNew) { if (this.btnDownloadAs.isVisible()) { this.getLayout().setActiveItem(this.cardDownloadAs); this.activeBtn = this.btnDownloadAs; } else { this.getLayout().setActiveItem(this.cardDocumentInfo); this.activeBtn = this.btnDocumentInfo; } } } } this.redrawButton(this.activeBtn); }, 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.btnDownloadAs = 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.btnPrint.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", Ext.apply(this.getFileMenuButton(this.btnCreateNewCaption, this.cardCreateNew), { id: "file-button-createnew", label: "Create", listeners: {}, enableToggle: false })); 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: "sse-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.btnDownloadAs, 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; }, setApi: function (api) { this.api = api; }, getSeparator: function () { return { xtype: "container", html: '