From 70ca82b0df0e0453be6ec5a70c3476713fabf2aa Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 17 Jul 2019 13:36:37 +0300 Subject: [PATCH] Create document api in viewport controller --- .../main/app/controller/Main.js | 68 ++++++++-------- .../main/app/controller/Viewport.js | 9 +++ .../main/app/controller/Main.js | 78 +++++++++---------- .../main/app/controller/Toolbar.js | 2 +- .../main/app/controller/Viewport.js | 9 +++ .../main/app/controller/Main.js | 57 +++++++------- .../main/app/controller/Viewport.js | 11 +++ 7 files changed, 126 insertions(+), 108 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 28b0d65d7..266e7e139 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -97,38 +97,9 @@ define([ 'settings:apply': _.bind(this.applySettings, this) } }); - }, - onLaunch: function() { - var me = this; - - this.stackLongActions = new Common.IrregularStack({ - strongCompare : function(obj1, obj2){return obj1.id === obj2.id && obj1.type === obj2.type;}, - weakCompare : function(obj1, obj2){return obj1.type === obj2.type;} - }); - - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; - this.languages = null; - this.translationTable = []; - this.isModalShowed = 0; - // Initialize viewport - - if (!Common.Utils.isBrowserSupported()){ - Common.Utils.showBrowserRestriction(); - Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); - return; - } - - var value = Common.localStorage.getItem("de-settings-fontrender"); - if (value === null) - window.devicePixelRatio > 1 ? value = '1' : '0'; - Common.Utils.InternalSettings.set("de-settings-fontrender", value); - - // Initialize api - - window["flat_desine"] = true; - - var styleNames = ['Normal', 'No Spacing', 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', + var me = this, + styleNames = ['Normal', 'No Spacing', 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Heading 5', 'Heading 6', 'Heading 7', 'Heading 8', 'Heading 9', 'Title', 'Subtitle', 'Quote', 'Intense Quote', 'List Paragraph', 'footnote text'], translate = { 'Series': this.txtSeries, @@ -164,16 +135,39 @@ define([ "Hyperlink": this.txtHyperlink }; styleNames.forEach(function(item){ - translate[item] = me.translationTable[item] = me['txtStyle_' + item.replace(/ /g, '_')] || item; + translate[item] = me['txtStyle_' + item.replace(/ /g, '_')] || item; }); - me.translationTable['Header'] = this.txtHeader; - me.translationTable['Footer'] = this.txtFooter; + me.translationTable = translate; + }, - this.api = new Asc.asc_docs_api({ - 'id-view' : 'editor_sdk', - 'translate': translate + onLaunch: function() { + var me = this; + + this.stackLongActions = new Common.IrregularStack({ + strongCompare : function(obj1, obj2){return obj1.id === obj2.id && obj1.type === obj2.type;}, + weakCompare : function(obj1, obj2){return obj1.type === obj2.type;} }); + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; + this.languages = null; + this.isModalShowed = 0; + // Initialize viewport + + if (!Common.Utils.isBrowserSupported()){ + Common.Utils.showBrowserRestriction(); + Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + return; + } + + var value = Common.localStorage.getItem("de-settings-fontrender"); + if (value === null) + window.devicePixelRatio > 1 ? value = '1' : '0'; + Common.Utils.InternalSettings.set("de-settings-fontrender", value); + + // Initialize api + window["flat_desine"] = true; + this.api = this.getApplication().getController('Viewport').getApi(); + if (this.api){ this.api.SetDrawingFreeze(true); switch (value) { diff --git a/apps/documenteditor/main/app/controller/Viewport.js b/apps/documenteditor/main/app/controller/Viewport.js index eef6af3e7..54ad031fd 100644 --- a/apps/documenteditor/main/app/controller/Viewport.js +++ b/apps/documenteditor/main/app/controller/Viewport.js @@ -116,11 +116,20 @@ define([ Common.NotificationCenter.on('api:disconnect', this.onApiCoAuthoringDisconnect.bind(this)); }, + getApi: function() { + return this.api; + }, // When our application is ready, lets get started onLaunch: function() { // Create and render main view this.viewport = this.createView('Viewport').render(); + + this.api = new Asc.asc_docs_api({ + 'id-view' : 'editor_sdk', + 'translate': this.getApplication().getController('Main').translationTable + }); + this.header = this.createView('Common.Views.Header', { headerCaption: 'Document Editor', storeUsers: DE.getCollection('Common.Collections.Users') diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index a16b70921..940a7106c 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -96,42 +96,10 @@ define([ 'settings:apply': _.bind(this.applySettings, this) } }); - }, - onLaunch: function() { - var me = this; - - this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; - this.languages = null; - this.translationTable = []; - this.isModalShowed = 0; - - window.storagename = 'presentation'; - - this.stackLongActions = new Common.IrregularStack({ - strongCompare : function(obj1, obj2){return obj1.id === obj2.id && obj1.type === obj2.type;}, - weakCompare : function(obj1, obj2){return obj1.type === obj2.type;} - }); - - // Initialize viewport - - if (!Common.Utils.isBrowserSupported()){ - Common.Utils.showBrowserRestriction(); - Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); - return; - } - - var value = Common.localStorage.getItem("pe-settings-fontrender"); - if (value===null) value = window.devicePixelRatio > 1 ? '1' : '3'; - Common.Utils.InternalSettings.set("pe-settings-fontrender", value); - - // Initialize api - - window["flat_desine"] = true; - - this.api = new Asc.asc_docs_api({ - 'id-view' : 'editor_sdk', - 'translate': { + var me = this, + themeNames = ['blank', 'pixel', 'classic', 'official', 'green', 'lines', 'office', 'safari', 'dotted', 'corner', 'turtle'], + translate = { 'Series': this.txtSeries, 'Diagram Title': this.txtDiagramTitle, 'X Axis': this.txtXAxis, @@ -154,13 +122,43 @@ define([ 'Loading': this.txtLoading, 'Click to add notes': this.txtAddNotes, 'Click to add first slide': this.txtAddFirstSlide - } + }; + + themeNames.forEach(function(item){ + translate[item] = me['txtTheme_' + item.replace(/ /g, '_')] || item; + }); + me.translationTable = translate; + }, + + onLaunch: function() { + var me = this; + + this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; + this.languages = null; + this.isModalShowed = 0; + + window.storagename = 'presentation'; + + this.stackLongActions = new Common.IrregularStack({ + strongCompare : function(obj1, obj2){return obj1.id === obj2.id && obj1.type === obj2.type;}, + weakCompare : function(obj1, obj2){return obj1.type === obj2.type;} }); - var themeNames = ['blank', 'pixel', 'classic', 'official', 'green', 'lines', 'office', 'safari', 'dotted', 'corner', 'turtle']; - themeNames.forEach(function(item){ - me.translationTable[item] = me['txtTheme_' + item.replace(/ /g, '_')] || item; - }); + // Initialize viewport + + if (!Common.Utils.isBrowserSupported()){ + Common.Utils.showBrowserRestriction(); + Common.Gateway.reportError(undefined, this.unsupportedBrowserErrorText); + return; + } + + var value = Common.localStorage.getItem("pe-settings-fontrender"); + if (value===null) value = window.devicePixelRatio > 1 ? '1' : '3'; + Common.Utils.InternalSettings.set("pe-settings-fontrender", value); + + // Initialize api + window["flat_desine"] = true; + this.api = this.getApplication().getController('Viewport').getApi(); if (this.api){ this.api.SetDrawingFreeze(true); diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 2692b5750..953e05705 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -1942,7 +1942,7 @@ define([ this._state.clrtext_asccolor = undefined; }, - _onInitEditorThemes: function(editorThemes, documentThemes) { + _onInitEditorThemes: function(editorThemes/*array */, documentThemes) { var me = this; window.styles_loaded = false; diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index 36aa2aab6..50de61e27 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -123,11 +123,20 @@ define([ Common.NotificationCenter.on('api:disconnect', this.onApiCoAuthoringDisconnect.bind(this)); }, + getApi: function() { + return this.api; + }, // When our application is ready, lets get started onLaunch: function() { // Create and render main view this.viewport = this.createView('Viewport').render(); + + this.api = new Asc.asc_docs_api({ + 'id-view' : 'editor_sdk', + 'translate': this.getApplication().getController('Main').translationTable + }); + this.header = this.createView('Common.Views.Header', { headerCaption: 'Presentation Editor', storeUsers: PE.getCollection('Common.Collections.Users') diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index b07853775..7ee72540f 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -99,6 +99,32 @@ define([ 'settings:apply': _.bind(this.applySettings, this) } }); + + var me = this, + styleNames = ['Normal', 'Neutral', 'Bad', 'Good', 'Input', 'Output', 'Calculation', 'Check Cell', 'Explanatory Text', 'Note', 'Linked Cell', 'Warning Text', + 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Title', 'Total', 'Currency', 'Percent', 'Comma'], + translate = { + 'Series': this.txtSeries, + 'Diagram Title': this.txtDiagramTitle, + 'X Axis': this.txtXAxis, + 'Y Axis': this.txtYAxis, + 'Your text here': this.txtArt, + 'Table': this.txtTable, + 'Print_Area': this.txtPrintArea + }; + styleNames.forEach(function(item){ + translate[item] = me['txtStyle_' + item.replace(/ /g, '_')] || item; + }); + translate['Currency [0]'] = me.txtStyle_Currency + ' [0]'; + translate['Comma [0]'] = me.txtStyle_Comma + ' [0]'; + + for (var i=1; i<7; i++) { + translate['Accent'+i] = me.txtAccent + i; + translate['20% - Accent'+i] = '20% - ' + me.txtAccent + i; + translate['40% - Accent'+i] = '40% - ' + me.txtAccent + i; + translate['60% - Accent'+i] = '60% - ' + me.txtAccent + i; + } + me.translationTable = translate; }, onLaunch: function() { @@ -106,7 +132,6 @@ define([ var me = this; this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseType: false}; - this.translationTable = []; this.isModalShowed = 0; if (!Common.Utils.isBrowserSupported()){ @@ -123,35 +148,7 @@ define([ Common.Utils.InternalSettings.set("sse-settings-fontrender", value); // Initialize api - var styleNames = ['Normal', 'Neutral', 'Bad', 'Good', 'Input', 'Output', 'Calculation', 'Check Cell', 'Explanatory Text', 'Note', 'Linked Cell', 'Warning Text', - 'Heading 1', 'Heading 2', 'Heading 3', 'Heading 4', 'Title', 'Total', 'Currency', 'Percent', 'Comma'], - translate = { - 'Series': this.txtSeries, - 'Diagram Title': this.txtDiagramTitle, - 'X Axis': this.txtXAxis, - 'Y Axis': this.txtYAxis, - 'Your text here': this.txtArt, - 'Table': this.txtTable, - 'Print_Area': this.txtPrintArea - }; - styleNames.forEach(function(item){ - translate[item] = me.translationTable[item] = me['txtStyle_' + item.replace(/ /g, '_')] || item; - }); - translate['Currency [0]'] = me.translationTable['Currency [0]'] = me.txtStyle_Currency + ' [0]'; - translate['Comma [0]'] = me.translationTable['Comma [0]'] = me.txtStyle_Comma + ' [0]'; - - for (var i=1; i<7; i++) { - translate['Accent'+i] = me.translationTable['Accent'+i] = me.txtAccent + i; - translate['20% - Accent'+i] = me.translationTable['20% - Accent'+i] = '20% - ' + me.txtAccent + i; - translate['40% - Accent'+i] = me.translationTable['40% - Accent'+i] = '40% - ' + me.txtAccent + i; - translate['60% - Accent'+i] = me.translationTable['60% - Accent'+i] = '60% - ' + me.txtAccent + i; - } - - this.api = new Asc.spreadsheet_api({ - 'id-view' : 'editor_sdk', - 'id-input' : 'ce-cell-content', - 'translate': translate - }); + this.api = this.getApplication().getController('Viewport').getApi(); this.api.asc_setFontRenderingMode(parseInt(value)); this.api.asc_registerCallback('asc_onOpenDocumentProgress', _.bind(this.onOpenDocument, this)); diff --git a/apps/spreadsheeteditor/main/app/controller/Viewport.js b/apps/spreadsheeteditor/main/app/controller/Viewport.js index 191521268..e1d3bd42a 100644 --- a/apps/spreadsheeteditor/main/app/controller/Viewport.js +++ b/apps/spreadsheeteditor/main/app/controller/Viewport.js @@ -130,6 +130,10 @@ define([ Common.NotificationCenter.on('api:disconnect', this.onApiCoAuthoringDisconnect.bind(this)); }, + getApi: function() { + return this.api; + }, + onAppShowed: function (config) { var me = this; me.appConfig = config; @@ -318,6 +322,13 @@ define([ onLaunch: function() { // Create and render main view this.viewport = this.createView('Viewport').render(); + + this.api = new Asc.spreadsheet_api({ + 'id-view' : 'editor_sdk', + 'id-input' : 'ce-cell-content', + 'translate': this.getApplication().getController('Main').translationTable + }); + this.header = this.createView('Common.Views.Header', { headerCaption: 'Spreadsheet Editor', storeUsers: SSE.getCollection('Common.Collections.Users')