From 2ab911a439c904a1e1da81283b77639a1f1aa6b1 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 7 Feb 2020 13:15:30 +0300 Subject: [PATCH 01/11] [DE mobile] Disable editing in opensource version --- apps/documenteditor/mobile/app-dev.js | 6 ++- .../mobile/app/controller/Main.js | 27 ++++++++-- .../mobile/app/controller/add/AddImage.js | 7 --- .../mobile/app/controller/add/AddOther.js | 52 +----------------- .../mobile/app/controller/add/AddShape.js | 7 --- .../mobile/app/controller/add/AddTable.js | 26 ++------- .../mobile/app/controller/edit/EditChart.js | 53 +++++-------------- .../mobile/app/controller/edit/EditShape.js | 20 ------- .../mobile/app/controller/edit/EditTable.js | 25 --------- 9 files changed, 48 insertions(+), 175 deletions(-) diff --git a/apps/documenteditor/mobile/app-dev.js b/apps/documenteditor/mobile/app-dev.js index b5ab499510..0a49bab004 100644 --- a/apps/documenteditor/mobile/app-dev.js +++ b/apps/documenteditor/mobile/app-dev.js @@ -224,7 +224,11 @@ require([ 'common/mobile/lib/controller/Collaboration' ], function() { window.compareVersions = true; - app.start(); + require(['documenteditor/mobile/app/controller/FeatureEdit'], function () { + app.start(); + }, function (error) { + app.start(); + }); }); }); }, function(err) { diff --git a/apps/documenteditor/mobile/app/controller/Main.js b/apps/documenteditor/mobile/app/controller/Main.js index 73627b547a..17416b0877 100644 --- a/apps/documenteditor/mobile/app/controller/Main.js +++ b/apps/documenteditor/mobile/app/controller/Main.js @@ -643,6 +643,22 @@ define([ applyLicense: function() { var me = this; + if (this.editorConfig.mode !== 'view' && !this.isSupportEditFeature()) { + var value = Common.localStorage.getItem("de-opensource-warning"); + value = (value!==null) ? parseInt(value) : 0; + var now = (new Date).getTime(); + if (now - value > 86400000) { + Common.localStorage.setItem("de-opensource-warning", now); + uiApp.modal({ + title: me.notcriticalErrorTitle, + text : me.errorOpensource, + buttons: [{text: 'OK'}] + }); + } + DE.getController('Toolbar').activateControls(); + return; + } + if (this._state.licenseType) { var license = this._state.licenseType, buttons = [{text: 'OK'}]; @@ -737,7 +753,8 @@ define([ me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; me.appOptions.canEdit = (me.permissions.edit !== false || me.permissions.review === true) && // can edit or review (me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined - (!me.appOptions.isReviewOnly || me.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true + (!me.appOptions.isReviewOnly || me.appOptions.canLicense) && // if isReviewOnly==true -> canLicense must be true + me.isSupportEditFeature(); me.appOptions.isEdit = me.appOptions.canLicense && me.appOptions.canEdit && me.editorConfig.mode !== 'view'; me.appOptions.canReview = me.appOptions.canLicense && me.appOptions.isEdit && (me.permissions.review===true); me.appOptions.canUseHistory = me.appOptions.canLicense && !me.appOptions.isLightVersion && me.editorConfig.canUseHistory && me.appOptions.canCoAuthoring && !me.appOptions.isDesktopApp; @@ -1151,7 +1168,6 @@ define([ }, onSendThemeColors: function(colors, standart_colors) { - Common.Utils.ThemeColor.setColors(colors, standart_colors); }, onAdvancedOptions: function(type, advOptions, mode, formatOptions) { @@ -1344,6 +1360,10 @@ define([ } }, + isSupportEditFeature: function() { + return false; + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning', @@ -1470,7 +1490,8 @@ define([ textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.
Please contact our Sales Department to get a quote.', waitText: 'Please, wait...', errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
Please contact your Document Server administrator for details.', - errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.' + errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', + errorOpensource: 'Files can be opened for viewing only. Mobile web editors are not available in the Open Source version.' } })(), DE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/mobile/app/controller/add/AddImage.js b/apps/documenteditor/mobile/app/controller/add/AddImage.js index 0bb77ec69d..1f86be05c7 100644 --- a/apps/documenteditor/mobile/app/controller/add/AddImage.js +++ b/apps/documenteditor/mobile/app/controller/add/AddImage.js @@ -98,10 +98,6 @@ define([ onInsertByFile: function (e) { DE.getController('AddContainer').hideModal(); - - if (this.api) { - this.api.asc_addImage(); - } }, onUrlChange: function (e) { @@ -118,9 +114,6 @@ define([ if (!_.isEmpty(value)) { if ((/((^https?)|(^ftp)):\/\/.+/i.test(value))) { DE.getController('AddContainer').hideModal(); - _.defer(function () { - me.api.AddImageUrl(value); - }); } else { uiApp.alert(me.txtNotUrl); } diff --git a/apps/documenteditor/mobile/app/controller/add/AddOther.js b/apps/documenteditor/mobile/app/controller/add/AddOther.js index 8b14782a02..5d912e05f6 100644 --- a/apps/documenteditor/mobile/app/controller/add/AddOther.js +++ b/apps/documenteditor/mobile/app/controller/add/AddOther.js @@ -79,9 +79,6 @@ define([ setApi: function (api) { var me = this; me.api = api; - - // me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me)); - }, onLaunch: function () { @@ -145,28 +142,7 @@ define([ }, onClickInsertFootnote: function() { - var me = this, - format = $('input[name="doc-footnote-format"]:checked').data('value'), - start = $('#start-at-footnote .item-after label').text(), - position = $('input[name="doc-footnote-pos"]:checked').data('value'), - props = new Asc.CAscFootnotePr(); - var startTo10; - if (me.fromCustomFormat) { - startTo10 = parseInt(me.fromCustomFormat(start)); - } else { - startTo10 = me.api.asc_GetFootnoteProps().get_NumStart(); - } - props.put_Pos(position); - props.put_NumFormat(format); - props.put_NumStart(startTo10); - props.put_NumRestart(Asc.c_oAscFootnoteRestart.Continuous); - if (me.api) { - me.api.asc_SetFootnoteProps(props, false); - setTimeout(function() { - me.api.asc_AddFootnote(); - }, 1); - DE.getController('AddContainer').hideModal(); - } + DE.getController('AddContainer').hideModal(); }, onFormatFootnoteChange: function(e) { @@ -227,32 +203,6 @@ define([ }, onInsertLink: function (e) { - var me = this, - url = $('#add-link-url input').val(), - display = $('#add-link-display input').val(), - tip = $('#add-link-tip input').val(), - urltype = me.api.asc_getUrlType($.trim(url)), - isEmail = (urltype == 2); - - if (urltype < 1) { - uiApp.alert(me.txtNotUrl); - return; - } - - url = url.replace(/^\s+|\s+$/g,''); - - if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) - url = (isEmail ? 'mailto:' : 'http://' ) + url; - - url = url.replace(new RegExp("%20",'g')," "); - - var props = new Asc.CHyperlinkProperty(); - props.put_Value(url); - props.put_Text(_.isEmpty(display) ? url : display); - props.put_ToolTip(tip); - - me.api.add_Hyperlink(props); - DE.getController('AddContainer').hideModal(); }, diff --git a/apps/documenteditor/mobile/app/controller/add/AddShape.js b/apps/documenteditor/mobile/app/controller/add/AddShape.js index c8345c7af5..32047d3ddc 100644 --- a/apps/documenteditor/mobile/app/controller/add/AddShape.js +++ b/apps/documenteditor/mobile/app/controller/add/AddShape.js @@ -215,13 +215,6 @@ define([ }, onShapeClick: function (e) { - var me = this, - $target = $(e.currentTarget); - - if ($target && me.api) { - me.api.AddShapeOnCurrentPage($target.data('type')); - } - DE.getController('AddContainer').hideModal(); }, diff --git a/apps/documenteditor/mobile/app/controller/add/AddTable.js b/apps/documenteditor/mobile/app/controller/add/AddTable.js index e83918cc4e..a6c40ca7fe 100644 --- a/apps/documenteditor/mobile/app/controller/add/AddTable.js +++ b/apps/documenteditor/mobile/app/controller/add/AddTable.js @@ -51,8 +51,7 @@ define([ 'use strict'; DE.Controllers.AddTable = Backbone.Controller.extend(_.extend((function() { - var _styles = [], - _initDefaultStyles = false; + var _initDefaultStyles = false; return { models: [], @@ -69,13 +68,13 @@ define([ 'view:render' : this.onViewRender } }); + + this._styles = []; }, setApi: function (api) { var me = this; me.api = api; - - me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me)); }, onLaunch: function () { @@ -87,7 +86,7 @@ define([ if (!_initDefaultStyles) { _initDefaultStyles = true; - _styles = []; + this._styles = []; me.api.asc_GetDefaultTableStyles(); } @@ -172,22 +171,7 @@ define([ // Public getStyles: function () { - return _styles; - }, - - // API handlers - - onApiInitTemplates: function(templates) { - if (_styles.length < 1) { - _.each(templates, function(template){ - _styles.push({ - imageUrl : template.asc_getImage(), - templateId : template.asc_getId() - }); - }); - - this.getView('AddTable').render(); - } + return this._styles; }, textTableSize: 'Table Size', diff --git a/apps/documenteditor/mobile/app/controller/edit/EditChart.js b/apps/documenteditor/mobile/app/controller/edit/EditChart.js index d38fbf8a9a..bf18a3fcc3 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditChart.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditChart.js @@ -52,7 +52,6 @@ define([ DE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() { // Private var _stack = [], - _chartObject = undefined, _shapeObject = undefined, _metricText = Common.Utils.Metric.getCurrentMetricName(), _borderColor = 'transparent'; @@ -127,6 +126,8 @@ define([ 'page:show': this.onPageShow } }); + + this._chartObject = undefined; }, setApi: function (api) { @@ -134,7 +135,6 @@ define([ me.api = api; me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(me.onApiUpdateChartStyles, me)); }, onLaunch: function () { @@ -172,11 +172,11 @@ define([ initSettings: function (pageId) { var me = this; _metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()); - if (_chartObject) { + if (me._chartObject) { if (pageId == '#edit-chart-wrap') { me._initWrapView(); } else if (pageId == '#edit-chart-style') { - me._updateChartStyles(me.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType())); + me._updateChartStyles(me.api.asc_getChartPreviews(me._chartObject.get_ChartProperties().getType())); me._initStyleView(); } else if (pageId == '#edit-chart-border-color-view') { me._initStyleView(); @@ -187,7 +187,7 @@ define([ _initWrapView: function() { // Wrap type var me = this, - wrapping = _chartObject.get_WrappingStyle(), + wrapping = me._chartObject.get_WrappingStyle(), $chartWrapInput = $('.chart-wrap input'), chartWrapType = wrapTypesTransform.sdkToUi(wrapping); @@ -195,7 +195,7 @@ define([ me._uiTransformByWrap(chartWrapType); // Wrap align - var chartHAlign = _chartObject.get_PositionH().get_Align(); + var chartHAlign = me._chartObject.get_PositionH().get_Align(); $('.chart-wrap .align a[data-type=left]').toggleClass('active', chartHAlign == Asc.c_oAscAlignH.Left); $('.chart-wrap .align a[data-type=center]').toggleClass('active', chartHAlign == Asc.c_oAscAlignH.Center); @@ -203,11 +203,11 @@ define([ // Wrap flags - $('#edit-chart-movetext input').prop('checked', _chartObject.get_PositionV().get_RelativeFrom() == Asc.c_oAscRelativeFromV.Paragraph); - $('#edit-chart-overlap input').prop('checked', _chartObject.get_AllowOverlap()); + $('#edit-chart-movetext input').prop('checked', me._chartObject.get_PositionV().get_RelativeFrom() == Asc.c_oAscRelativeFromV.Paragraph); + $('#edit-chart-overlap input').prop('checked', me._chartObject.get_AllowOverlap()); // Wrap distance - var paddings = _chartObject.get_Paddings(); + var paddings = me._chartObject.get_Paddings(); if (paddings) { var distance = Common.Utils.Metric.fnRecalcFromMM(paddings.get_Top()); $('.chart-wrap .distance input').val(distance); @@ -217,7 +217,7 @@ define([ _initStyleView: function (updateStyles) { var me = this, - chartProperties = _chartObject.get_ChartProperties(), + chartProperties = me._chartObject.get_ChartProperties(), shapeProperties = _shapeObject.get_ShapeProperties(), paletteFillColor = me.getView('EditChart').paletteFillColor, paletteBorderColor = me.getView('EditChart').paletteBorderColor; @@ -295,29 +295,12 @@ define([ // Public getChart: function () { - return _chartObject; + return this._chartObject; }, // Handlers onType: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - var image = new Asc.asc_CImgProperty(), - chart = _chartObject.get_ChartProperties(); - - chart.changeType(type); - image.put_ChartProperties(chart); - - me.api.ImgApply(image); - - $('.chart-types li').removeClass('active'); - $target.addClass('active'); - - // Force update styles - me._updateChartStyles(me.api.asc_getChartPreviews(chart.getType())); }, onStyle: function (e) { @@ -326,7 +309,7 @@ define([ type = $target.data('type'); var image = new Asc.asc_CImgProperty(), - chart = _chartObject.get_ChartProperties(); + chart = me._chartObject.get_ChartProperties(); chart.putStyle(type); image.put_ChartProperties(chart); @@ -560,23 +543,13 @@ define([ } }; - _chartObject = getTopObject(charts); + this._chartObject = getTopObject(charts); _shapeObject = getTopObject(shapes); }, - onApiUpdateChartStyles: function () { - if (this.api && _chartObject && _chartObject.get_ChartProperties()) { - this._updateChartStyles(this.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType())); - } - }, - // Helpers _updateChartStyles: function(styles) { - Common.SharedSettings.set('chartstyles', styles); - Common.NotificationCenter.trigger('chartstyles:load', styles); - - $('#tab-chart-style li').single('click', _.bind(this.onStyle, this)); }, _uiTransformByWrap: function(type) { diff --git a/apps/documenteditor/mobile/app/controller/edit/EditShape.js b/apps/documenteditor/mobile/app/controller/edit/EditShape.js index e555066763..0382a0f5b9 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditShape.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditShape.js @@ -301,29 +301,9 @@ define([ }, onReorder: function (e) { - var $target = $(e.currentTarget), - type = $target.data('type'); - - var properties = new Asc.asc_CImgProperty(); - - if ('all-up' == type) { - properties.put_ChangeLevel(Asc.c_oAscChangeLevel.BringToFront); - } else if ('all-down' == type) { - properties.put_ChangeLevel(Asc.c_oAscChangeLevel.SendToBack); - } else if ('move-up' == type) { - properties.put_ChangeLevel(Asc.c_oAscChangeLevel.BringForward); - } else if ('move-down' == type) { - properties.put_ChangeLevel(Asc.c_oAscChangeLevel.BringBackward); - } - - this.api.ImgApply(properties); }, onReplace: function (e) { - var $target = $(e.currentTarget), - type = $target.data('type'); - - this.api.ChangeShapeType(type); }, onWrapType: function (e) { diff --git a/apps/documenteditor/mobile/app/controller/edit/EditTable.js b/apps/documenteditor/mobile/app/controller/edit/EditTable.js index 1f41d0d358..c94e62bbf1 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditTable.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditTable.js @@ -123,9 +123,6 @@ define([ setApi: function (api) { var me = this; me.api = api; - - me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me)); }, onLaunch: function () { @@ -134,15 +131,6 @@ define([ initEvents: function () { var me = this; - - $('#table-remove-all').single('click', _.bind(function(){me.api.remTable(); me._closeIfNeed()}, me)); - $('#insert-column-left').single('click', _.bind(function(){me.api.addColumnLeft(); me._closeIfNeed()}, me)); - $('#insert-column-right').single('click', _.bind(function(){me.api.addColumnRight(); me._closeIfNeed()}, me)); - $('#insert-row-above').single('click', _.bind(function(){me.api.addRowAbove(); me._closeIfNeed()}, me)); - $('#insert-row-below').single('click', _.bind(function(){me.api.addRowBelow(); me._closeIfNeed()}, me)); - $('#remove-column').single('click', _.bind(function(){me.api.remColumn(); me._closeIfNeed()}, me)); - $('#remove-row').single('click', _.bind(function(){me.api.remRow(); me._closeIfNeed()}, me)); - me.initSettings(); }, @@ -650,19 +638,6 @@ define([ } }, - onApiInitTemplates: function(templates) { - var styles = []; - - _.each(templates, function(template){ - styles.push({ - imageUrl : template.asc_getImage(), - templateId : template.asc_getId() - }); - }); - - this.getView('EditTable').updateStyles(styles); - }, - // Helpers _closeIfNeed: function () { From 1ed80f9497222038da8845985786f5f0f4f5ad79 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 7 Feb 2020 16:39:58 +0300 Subject: [PATCH 02/11] [DE mobile] Disable editing text properties --- .../app/controller/edit/EditParagraph.js | 80 ++++--------------- .../mobile/app/controller/edit/EditText.js | 37 +-------- 2 files changed, 20 insertions(+), 97 deletions(-) diff --git a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js index 23545050b7..6175d77c81 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditParagraph.js @@ -51,12 +51,8 @@ define([ DE.Controllers.EditParagraph = Backbone.Controller.extend(_.extend((function() { // Private - var _stack = [], - _paragraphInfo = {}, - _paragraphObject = undefined, + var _paragraphInfo = {}, _paragraphProperty = undefined, - _styles = [], - _styleThumbSize, _styleName, metricText = Common.Utils.Metric.getCurrentMetricName(); @@ -77,17 +73,15 @@ define([ 'style:click' : this.onStyleClick } }); + + this._styles = []; + this._styleThumbSize = undefined; + this._paragraphObject = undefined; }, setApi: function (api) { var me = this; me.api = api; - - me.api.asc_setParagraphStylesSizes(330, 38); - - me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me)); - me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onParaStyleName', _.bind(me.onApiParagraphStyleChange, me)); }, onLaunch: function () { @@ -148,23 +142,23 @@ define([ $('#paragraph-spin-first-line .item-after label').text(firstLineFix + ' ' + metricText); } - if (_paragraphObject) { - _paragraphInfo.spaceBefore = _paragraphObject.get_Spacing().get_Before() < 0 ? _paragraphObject.get_Spacing().get_Before() : Common.Utils.Metric.fnRecalcFromMM(_paragraphObject.get_Spacing().get_Before()); - _paragraphInfo.spaceAfter = _paragraphObject.get_Spacing().get_After() < 0 ? _paragraphObject.get_Spacing().get_After() : Common.Utils.Metric.fnRecalcFromMM(_paragraphObject.get_Spacing().get_After()); + if (me._paragraphObject) { + _paragraphInfo.spaceBefore = me._paragraphObject.get_Spacing().get_Before() < 0 ? me._paragraphObject.get_Spacing().get_Before() : Common.Utils.Metric.fnRecalcFromMM(me._paragraphObject.get_Spacing().get_Before()); + _paragraphInfo.spaceAfter = me._paragraphObject.get_Spacing().get_After() < 0 ? me._paragraphObject.get_Spacing().get_After() : Common.Utils.Metric.fnRecalcFromMM(me._paragraphObject.get_Spacing().get_After()); var distanceBeforeFix = parseFloat(_paragraphInfo.spaceBefore.toFixed(2)); var distanceAfterFix = parseFloat(_paragraphInfo.spaceAfter.toFixed(2)); $('#paragraph-distance-before .item-after label').text(_paragraphInfo.spaceBefore < 0 ? 'Auto' : distanceBeforeFix + ' ' + metricText); $('#paragraph-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : distanceAfterFix + ' ' + metricText); - $('#paragraph-space input:checkbox').prop('checked', _paragraphObject.get_ContextualSpacing()); - $('#paragraph-page-break input:checkbox').prop('checked', _paragraphObject.get_PageBreakBefore()); - $('#paragraph-page-orphan input:checkbox').prop('checked', _paragraphObject.get_WidowControl()); - $('#paragraph-page-keeptogether input:checkbox').prop('checked', _paragraphObject.get_KeepLines()); - $('#paragraph-page-keepnext input:checkbox').prop('checked', _paragraphObject.get_KeepNext()); + $('#paragraph-space input:checkbox').prop('checked', me._paragraphObject.get_ContextualSpacing()); + $('#paragraph-page-break input:checkbox').prop('checked', me._paragraphObject.get_PageBreakBefore()); + $('#paragraph-page-orphan input:checkbox').prop('checked', me._paragraphObject.get_WidowControl()); + $('#paragraph-page-keeptogether input:checkbox').prop('checked', me._paragraphObject.get_KeepLines()); + $('#paragraph-page-keepnext input:checkbox').prop('checked', me._paragraphObject.get_KeepNext()); // Background color - var shade = _paragraphObject.get_Shade(), + var shade = me._paragraphObject.get_Shade(), backColor = 'transparent'; if (!_.isNull(shade) && !_.isUndefined(shade) && shade.get_Value()===Asc.c_oAscShdClear) { @@ -203,11 +197,11 @@ define([ // Public getStyles: function () { - return _styles || []; + return this._styles || []; }, getThumbSize: function () { - return _styleThumbSize || {width: 0, height: 0}; + return this._styleThumbSize || {width: 0, height: 0}; }, // Handlers @@ -369,48 +363,6 @@ define([ // API handlers - onApiFocusObject: function (objects) { - _stack = objects; - - var paragraphs = []; - - _.each(_stack, function(object) { - if (object.get_ObjectType() == Asc.c_oAscTypeSelectElement.Paragraph) { - paragraphs.push(object); - } - }); - - if (paragraphs.length > 0) { - var object = paragraphs[paragraphs.length - 1]; // get top - _paragraphObject = object.get_ObjectValue(); - } else { - _paragraphObject = undefined; - } - }, - - onApiInitEditorStyles: function (styles) { - window.styles_loaded = false; - - if (styles.length < 1) { - return; - } - - _styles = []; - _styleThumbSize = { - width : styles.STYLE_THUMBNAIL_WIDTH, - height : styles.STYLE_THUMBNAIL_HEIGHT - }; - - _.each(styles.get_MergedStyles(), function(style){ - _styles.push({ - image : style.asc_getImage(), - name : style.get_Name() - }); - }); - - window.styles_loaded = true; - }, - onApiParagraphStyleChange: function(name) { _styleName = name; $('#paragraph-list input[name=paragraph-style]').val([_styleName]); diff --git a/apps/documenteditor/mobile/app/controller/edit/EditText.js b/apps/documenteditor/mobile/app/controller/edit/EditText.js index 92e9d5e66b..77cb799f6c 100644 --- a/apps/documenteditor/mobile/app/controller/edit/EditText.js +++ b/apps/documenteditor/mobile/app/controller/edit/EditText.js @@ -51,26 +51,10 @@ define([ 'use strict'; DE.Controllers.EditText = Backbone.Controller.extend(_.extend((function() { - var _fontsArray = [], - _stack = [], + var _stack = [], _paragraphObject = undefined, _fontInfo = {}; - function onApiLoadFonts(fonts, select) { - _.each(fonts, function(font){ - var fontId = font.asc_getFontId(); - _fontsArray.push({ - id : fontId, - name : font.asc_getFontName(), -// displayValue: font.asc_getFontName(), - imgidx : font.asc_getFontThumbnail(), - type : font.asc_getFontType() - }); - }); - - Common.NotificationCenter.trigger('fonts:load', _fontsArray, select); - } - return { models: [], collections: [], @@ -87,26 +71,13 @@ define([ 'font:click': this.onFontClick } }); + + this._fontsArray = []; }, setApi: function (api) { var me = this; me.api = api; - - me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me)); - me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onFontFamily', _.bind(me.onApiChangeFont, me)); - me.api.asc_registerCallback('asc_onFontSize', _.bind(me.onApiFontSize, me)); - me.api.asc_registerCallback('asc_onBold', _.bind(me.onApiBold, me)); - me.api.asc_registerCallback('asc_onItalic', _.bind(me.onApiItalic, me)); - me.api.asc_registerCallback('asc_onUnderline', _.bind(me.onApiUnderline, me)); - me.api.asc_registerCallback('asc_onStrikeout', _.bind(me.onApiStrikeout, me)); - me.api.asc_registerCallback('asc_onVerticalAlign', _.bind(me.onApiVerticalAlign, me)); - me.api.asc_registerCallback('asc_onListType', _.bind(me.onApiBullets, me)); - me.api.asc_registerCallback('asc_onPrAlign', _.bind(me.onApiParagraphAlign, me)); - me.api.asc_registerCallback('asc_onTextColor', _.bind(me.onApiTextColor, me)); - me.api.asc_registerCallback('asc_onParaSpacingLine', _.bind(me.onApiLineSpacing, me)); - me.api.asc_registerCallback('asc_onTextShd', _.bind(me.onApiTextShd, me)); }, onLaunch: function () { @@ -169,7 +140,7 @@ define([ // Public getFonts: function() { - return _fontsArray; + return this._fontsArray; }, getStack: function() { From 30ac0b8b9de2e7919f73c7c55d99f880f345341e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 7 Feb 2020 16:41:53 +0300 Subject: [PATCH 03/11] [DE mobile] Fix loading application --- apps/documenteditor/mobile/app.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/mobile/app.js b/apps/documenteditor/mobile/app.js index dba0a47b41..7906d27c3a 100644 --- a/apps/documenteditor/mobile/app.js +++ b/apps/documenteditor/mobile/app.js @@ -234,7 +234,11 @@ require([ 'documenteditor/mobile/app/controller/add/AddOther', 'common/mobile/lib/controller/Collaboration' ], function() { - app.start(); + require(['documenteditor/mobile/app/controller/FeatureEdit'], function () { + app.start(); + }, function (error) { + app.start(); + }); }); }); }, function(err) { From 19e4859e1051fe16697272be3bacaacc06cc9f40 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 10 Feb 2020 09:49:58 +0300 Subject: [PATCH 04/11] [PE mobile][SSE mobile] Disable editing --- apps/presentationeditor/mobile/app-dev.js | 6 ++++- apps/presentationeditor/mobile/app.js | 6 ++++- .../mobile/app/controller/Main.js | 27 +++++++++++++++++-- apps/spreadsheeteditor/mobile/app-dev.js | 6 ++++- apps/spreadsheeteditor/mobile/app.js | 6 ++++- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/apps/presentationeditor/mobile/app-dev.js b/apps/presentationeditor/mobile/app-dev.js index 4870f02afc..5229e143bf 100644 --- a/apps/presentationeditor/mobile/app-dev.js +++ b/apps/presentationeditor/mobile/app-dev.js @@ -221,7 +221,11 @@ require([ ], function() { window.compareVersions = true; - app.start(); + require(['presentationeditor/mobile/app/controller/FeatureEdit'], function () { + app.start(); + }, function (error) { + app.start(); + }); }); }); }, function(err) { diff --git a/apps/presentationeditor/mobile/app.js b/apps/presentationeditor/mobile/app.js index abcec73a80..04819cdf43 100644 --- a/apps/presentationeditor/mobile/app.js +++ b/apps/presentationeditor/mobile/app.js @@ -230,7 +230,11 @@ require([ 'presentationeditor/mobile/app/controller/add/AddSlide', 'common/mobile/lib/controller/Collaboration' ], function() { - app.start(); + require(['presentationeditor/mobile/app/controller/FeatureEdit'], function () { + app.start(); + }, function (error) { + app.start(); + }); }); }); }, function(err) { diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index af6760aec0..1932c5a934 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -575,6 +575,23 @@ define([ applyLicense: function() { var me = this; + if (this.editorConfig.mode !== 'view' && !this.isSupportEditFeature()) { + var value = Common.localStorage.getItem("pe-opensource-warning"); + value = (value!==null) ? parseInt(value) : 0; + var now = (new Date).getTime(); + if (now - value > 40) { + // if (now - value > 86400000) { + Common.localStorage.setItem("pe-opensource-warning", now); + uiApp.modal({ + title: me.notcriticalErrorTitle, + text : me.errorOpensource, + buttons: [{text: 'OK'}] + }); + } + PE.getController('Toolbar').activateControls(); + return; + } + if (this._state.licenseType) { var license = this._state.licenseType, buttons = [{text: 'OK'}]; @@ -669,7 +686,8 @@ define([ me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; me.appOptions.canEdit = (me.permissions.edit !== false || me.permissions.review === true) && // can edit or review (me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined - (!me.appOptions.isReviewOnly || me.appOptions.canLicense); // if isReviewOnly==true -> canLicense must be true + (!me.appOptions.isReviewOnly || me.appOptions.canLicense) && // if isReviewOnly==true -> canLicense must be true + me.isSupportEditFeature(); me.appOptions.isEdit = me.appOptions.canLicense && me.appOptions.canEdit && me.editorConfig.mode !== 'view'; me.appOptions.canReview = me.appOptions.canLicense && me.appOptions.isEdit && (me.permissions.review===true); me.appOptions.canUseHistory = me.appOptions.canLicense && !me.appOptions.isLightVersion && me.editorConfig.canUseHistory && me.appOptions.canCoAuthoring && !me.appOptions.isDesktopApp; @@ -1249,6 +1267,10 @@ define([ } }, + isSupportEditFeature: function() { + return false; + }, + // Translation leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', @@ -1412,7 +1434,8 @@ define([ textCustomLoader: 'Please note that according to the terms of the license you are not entitled to change the loader.
Please contact our Sales Department to get a quote.', waitText: 'Please, wait...', errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
Please contact your Document Server administrator for details.', - errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.' + errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', + errorOpensource: 'Files can be opened for viewing only. Mobile web editors are not available in the Open Source version.' } })(), PE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app-dev.js b/apps/spreadsheeteditor/mobile/app-dev.js index b19dcb0bf1..eaa939bfde 100644 --- a/apps/spreadsheeteditor/mobile/app-dev.js +++ b/apps/spreadsheeteditor/mobile/app-dev.js @@ -210,7 +210,11 @@ require([ ,'common/mobile/lib/controller/Collaboration' ], function() { window.compareVersions = true; - app.start(); + require(['spreadsheeteditor/mobile/app/controller/FeatureEdit'], function () { + app.start(); + }, function (error) { + app.start(); + }); }); }); }, function(err) { diff --git a/apps/spreadsheeteditor/mobile/app.js b/apps/spreadsheeteditor/mobile/app.js index 9536367dd0..8c44121018 100644 --- a/apps/spreadsheeteditor/mobile/app.js +++ b/apps/spreadsheeteditor/mobile/app.js @@ -220,7 +220,11 @@ require([ ,'spreadsheeteditor/mobile/app/controller/FilterOptions' ,'common/mobile/lib/controller/Collaboration' ], function() { - app.start(); + require(['spreadsheeteditor/mobile/app/controller/FeatureEdit'], function () { + app.start(); + }, function (error) { + app.start(); + }); }); }); }, function(err) { From dc46e1b97f6aa80eb3b5039c5a13ab10637115ac Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 10 Feb 2020 12:35:59 +0300 Subject: [PATCH 05/11] [PE mobile] Disable editing in opensource version --- .../mobile/app/controller/Main.js | 1 - .../mobile/app/controller/add/AddImage.js | 7 -- .../mobile/app/controller/add/AddLink.js | 99 ++++--------------- .../mobile/app/controller/add/AddShape.js | 7 -- .../mobile/app/controller/add/AddSlide.js | 39 +------- .../mobile/app/controller/add/AddTable.js | 26 +---- .../mobile/app/controller/edit/EditChart.js | 36 ++----- .../mobile/app/controller/edit/EditShape.js | 16 --- .../mobile/app/controller/edit/EditTable.js | 23 ----- 9 files changed, 33 insertions(+), 221 deletions(-) diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 1932c5a934..33e8267aa4 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -1115,7 +1115,6 @@ define([ }, onSendThemeColors: function(colors, standart_colors) { - Common.Utils.ThemeColor.setColors(colors, standart_colors); }, onFocusObject: function(SelectedObjects) { diff --git a/apps/presentationeditor/mobile/app/controller/add/AddImage.js b/apps/presentationeditor/mobile/app/controller/add/AddImage.js index afeda226ad..5bb96618d5 100644 --- a/apps/presentationeditor/mobile/app/controller/add/AddImage.js +++ b/apps/presentationeditor/mobile/app/controller/add/AddImage.js @@ -95,10 +95,6 @@ define([ onInsertByFile: function (e) { PE.getController('AddContainer').hideModal(); - - if (this.api) { - this.api.asc_addImage(); - } }, onUrlChange: function (e) { @@ -115,9 +111,6 @@ define([ if (!_.isEmpty(value)) { if ((/((^https?)|(^ftp)):\/\/.+/i.test(value))) { PE.getController('AddContainer').hideModal(); - _.defer(function () { - me.api.AddImageUrl(value); - }); } else { uiApp.alert(me.txtNotUrl); } diff --git a/apps/presentationeditor/mobile/app/controller/add/AddLink.js b/apps/presentationeditor/mobile/app/controller/add/AddLink.js index 009113f214..652839f773 100644 --- a/apps/presentationeditor/mobile/app/controller/add/AddLink.js +++ b/apps/presentationeditor/mobile/app/controller/add/AddLink.js @@ -57,9 +57,6 @@ define([ First: 3, Num: 4 }, - _linkType = c_oHyperlinkType.WebLink, - _slideLink = 0, - _slideNum = 0, _slidesCount = 0; return { @@ -83,6 +80,10 @@ define([ uiApp.onPageBack('addlink-type addlink-slidenumber', function (page) { me.initSettings(); }); + + this._linkType = c_oHyperlinkType.WebLink; + this._slideLink = 0; + this._slideNum = 0; }, setApi: function (api) { @@ -103,8 +104,8 @@ define([ var $target = $(e.currentTarget); if ($target && $target.prop('id') === 'add-link') { - _linkType = c_oHyperlinkType.WebLink; - _slideLink = _slideNum = 0; + this._linkType = c_oHyperlinkType.WebLink; + this._slideLink = this._slideNum = 0; var text = this.api.can_AddHyperlink(); if (text !== false) { $('#add-link-display input').val((text !== null) ? text : this.textDefault); @@ -119,17 +120,17 @@ define([ var me = this; if (pageId == '#addlink-type') { - $('#page-addlink-type input').val([_linkType]); + $('#page-addlink-type input').val([this._linkType]); } else if (pageId == '#addlink-slidenumber') { _slidesCount = me.api.getCountPages(); - $('#page-addlink-slidenumber input').val([_slideLink]); - $('#addlink-slide-number .item-after label').text(_slideNum+1); + $('#page-addlink-slidenumber input').val([this._slideLink]); + $('#addlink-slide-number .item-after label').text(this._slideNum+1); } else { - $('#add-link-type .item-after').text((_linkType==c_oHyperlinkType.WebLink) ? me.textExternalLink : me.textInternalLink); - $('#add-link-url')[(_linkType==c_oHyperlinkType.WebLink) ? 'show' : 'hide'](); - $('#add-link-number')[(_linkType==c_oHyperlinkType.WebLink) ? 'hide' : 'show'](); + $('#add-link-type .item-after').text((this._linkType==c_oHyperlinkType.WebLink) ? me.textExternalLink : me.textInternalLink); + $('#add-link-url')[(this._linkType==c_oHyperlinkType.WebLink) ? 'show' : 'hide'](); + $('#add-link-number')[(this._linkType==c_oHyperlinkType.WebLink) ? 'hide' : 'show'](); - if (_linkType==c_oHyperlinkType.WebLink) { + if (this._linkType==c_oHyperlinkType.WebLink) { $('#add-link-url input[type=url]').single('input', _.bind(function(e) { $('#add-link-insert').toggleClass('disabled', _.isEmpty($('#add-link-url input').val())); }, this)); @@ -138,7 +139,7 @@ define([ }, 1000); } else { var slidename = ''; - switch (_slideLink) { + switch (this._slideLink) { case 0: slidename = me.textNext; break; @@ -152,13 +153,13 @@ define([ slidename = me.textLast; break; case 4: - slidename = me.textSlide + ' ' + (_slideNum+1); + slidename = me.textSlide + ' ' + (this._slideNum+1); break; } $('#add-link-number .item-after').text(slidename); } - $('#add-link-insert').toggleClass('disabled', (_linkType==c_oHyperlinkType.WebLink) && _.isEmpty($('#add-link-url input').val())); + $('#add-link-insert').toggleClass('disabled', (this._linkType==c_oHyperlinkType.WebLink) && _.isEmpty($('#add-link-url input').val())); } }, @@ -174,66 +175,6 @@ define([ // Handlers onInsertLink: function (e) { - var me = this, - display = $('#add-link-display input').val(), - tip = $('#add-link-tip input').val(), - props = new Asc.CHyperlinkProperty(), - def_display = ''; - - if (_linkType==c_oHyperlinkType.WebLink) { - var url = $('#add-link-url input').val(), - urltype = me.api.asc_getUrlType($.trim(url)), - isEmail = (urltype == 2); - if (urltype < 1) { - uiApp.alert(me.txtNotUrl); - return; - } - - url = url.replace(/^\s+|\s+$/g,''); - if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) - url = (isEmail ? 'mailto:' : 'http://' ) + url; - url = url.replace(new RegExp("%20",'g')," "); - - props.put_Value( url ); - props.put_ToolTip(tip); - def_display = url; - } else { - var url = "ppaction://hlink"; - var slidetip = ''; - switch (_slideLink) { - case 0: - url = url + "showjump?jump=nextslide"; - slidetip = this.textNext; - break; - case 1: - url = url + "showjump?jump=previousslide"; - slidetip = this.textPrev; - break; - case 2: - url = url + "showjump?jump=firstslide"; - slidetip = this.textFirst; - break; - case 3: - url = url + "showjump?jump=lastslide"; - slidetip = this.textLast; - break; - case 4: - url = url + "sldjumpslide" + _slideNum; - slidetip = this.textSlide + ' ' + (_slideNum+1); - break; - } - props.put_Value( url ); - props.put_ToolTip(_.isEmpty(tip) ? slidetip : tip); - def_display = slidetip; - } - - if (!$('#add-link-display').hasClass('disabled')) { - props.put_Text(_.isEmpty(display) ? def_display : display); - } else - props.put_Text(null); - - me.api.add_Hyperlink(props); - PE.getController('AddContainer').hideModal(); }, @@ -241,7 +182,7 @@ define([ var $target = $(e.currentTarget).find('input'); if ($target && this.api) { - _linkType = parseFloat($target.prop('value')); + this._linkType = parseFloat($target.prop('value')); } }, @@ -249,20 +190,20 @@ define([ var $target = $(e.currentTarget).find('input'); if ($target && this.api) { - _slideLink = parseFloat($target.prop('value')); + this._slideLink = parseFloat($target.prop('value')); } }, onSlideNumber: function (e) { var $button = $(e.currentTarget), - slide = _slideNum; + slide = this._slideNum; if ($button.hasClass('decrement')) { slide = Math.max(0, --slide); } else { slide = Math.min(_slidesCount-1, ++slide); } - _slideNum = slide; + this._slideNum = slide; $('#addlink-slide-number .item-after label').text(slide+1); }, diff --git a/apps/presentationeditor/mobile/app/controller/add/AddShape.js b/apps/presentationeditor/mobile/app/controller/add/AddShape.js index 12c4c9f17e..be2ef1ecf2 100644 --- a/apps/presentationeditor/mobile/app/controller/add/AddShape.js +++ b/apps/presentationeditor/mobile/app/controller/add/AddShape.js @@ -212,13 +212,6 @@ define([ }, onShapeClick: function (e) { - var me = this, - $target = $(e.currentTarget); - - if ($target && me.api) { - me.api.AddShapeOnCurrentPage($target.data('type')); - } - PE.getController('AddContainer').hideModal(); }, diff --git a/apps/presentationeditor/mobile/app/controller/add/AddSlide.js b/apps/presentationeditor/mobile/app/controller/add/AddSlide.js index 054001224d..4ffccc101f 100644 --- a/apps/presentationeditor/mobile/app/controller/add/AddSlide.js +++ b/apps/presentationeditor/mobile/app/controller/add/AddSlide.js @@ -48,8 +48,6 @@ define([ 'use strict'; PE.Controllers.AddSlide = Backbone.Controller.extend(_.extend((function() { - var _layouts = []; - return { models: [], collections: [], @@ -59,12 +57,12 @@ define([ initialize: function () { Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this)); + this._layouts = []; }, setApi: function (api) { var me = this; me.api = api; - me.api.asc_registerCallback('asc_onUpdateLayout', _.bind(me.onUpdateLayout, me)); }, onLaunch: function () { @@ -73,49 +71,18 @@ define([ initEvents: function () { var me = this; - me.getView('AddSlide').updateLayouts(_layouts); + me.getView('AddSlide').updateLayouts(this._layouts); $('#add-slide .slide-layout li').single('click', _.buffered(me.onLayoutClick, 100, me)); }, onLayoutClick: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - me.api.AddSlide(type); - PE.getController('AddContainer').hideModal(); }, // Public getLayouts: function () { - return _layouts; - }, - - // API handlers - - onUpdateLayout: function(layouts){ - var me = this; - _layouts = []; - if (!_.isEmpty(layouts)){ - _.each(layouts, function(layout){ - var name = layout.get_Name(); - _layouts.push({ - imageUrl : layout.get_Image(), - title : (name !== '') ? name : PE.getController('Main').layoutNames[layout.getType()], - itemWidth : layout.get_Width(), - itemHeight : layout.get_Height(), - idx : layout.getIndex() - }); - }); - } - - Common.SharedSettings.set('slidelayouts', _layouts); - Common.NotificationCenter.trigger('slidelayouts:load', _layouts); - - this.getView('AddSlide').updateLayouts(_layouts); - $('#add-slide .slide-layout li').single('click', _.buffered(me.onLayoutClick, 100, me)); + return this._layouts; } } })(), PE.Controllers.AddSlide || {})) diff --git a/apps/presentationeditor/mobile/app/controller/add/AddTable.js b/apps/presentationeditor/mobile/app/controller/add/AddTable.js index a5fd03a021..79ff8faf18 100644 --- a/apps/presentationeditor/mobile/app/controller/add/AddTable.js +++ b/apps/presentationeditor/mobile/app/controller/add/AddTable.js @@ -48,8 +48,7 @@ define([ 'use strict'; PE.Controllers.AddTable = Backbone.Controller.extend(_.extend((function() { - var _styles = [], - _initDefaultStyles = false; + var _initDefaultStyles = false; return { models: [], @@ -60,13 +59,12 @@ define([ initialize: function () { Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this)); + this._styles = []; }, setApi: function (api) { var me = this; me.api = api; - - me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me)); }, onLaunch: function () { @@ -78,7 +76,7 @@ define([ if (!_initDefaultStyles) { _initDefaultStyles = true; - _styles = []; + me._styles = []; me.api.asc_GetDefaultTableStyles && me.api.asc_GetDefaultTableStyles(); } @@ -159,27 +157,11 @@ define([ // Public getStyles: function () { - return _styles; + return this._styles; }, // API handlers - onApiInitTemplates: function(templates){ - if (_styles.length < 1) { - _.each(templates, function(template){ - _styles.push({ - imageUrl : template.asc_getImage(), - templateId : template.asc_getId() - }); - }); - - this.getView('AddTable').render(); - } - - Common.SharedSettings.set('tablestyles', _styles); - Common.NotificationCenter.trigger('tablestyles:load', _styles); - }, - textTableSize: 'Table Size', textColumns: 'Columns', textRows: 'Rows', diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditChart.js b/apps/presentationeditor/mobile/app/controller/edit/EditChart.js index 1372edec87..c80df4edc7 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditChart.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditChart.js @@ -52,7 +52,6 @@ define([ PE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() { // Private var _stack = [], - _chartObject = undefined, _shapeObject = undefined, _metricText = Common.Utils.Metric.getCurrentMetricName(), _borderColor = 'transparent'; @@ -99,6 +98,7 @@ define([ 'page:show': this.onPageShow } }); + this._chartObject = undefined; }, setApi: function (api) { @@ -106,7 +106,6 @@ define([ me.api = api; me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(me.onApiUpdateChartStyles, me)); }, onLaunch: function () { @@ -139,9 +138,9 @@ define([ initSettings: function (pageId) { var me = this; - if (_chartObject) { + if (me._chartObject) { if (pageId == '#edit-chart-style') { - me._updateChartStyles(me.api.asc_getChartPreviews(_chartObject.getType())); + me._updateChartStyles(me.api.asc_getChartPreviews(me._chartObject.getType())); me._initStyleView(); } else if (pageId == '#edit-chart-border-color-view') { me._initStyleView(); @@ -151,7 +150,7 @@ define([ _initStyleView: function (updateStyles) { var me = this, - chartProperties = _chartObject, + chartProperties = me._chartObject, shapeProperties = _shapeObject, paletteFillColor = me.getView('EditChart').paletteFillColor, paletteBorderColor = me.getView('EditChart').paletteBorderColor; @@ -228,25 +227,12 @@ define([ // Public getChart: function () { - return _chartObject; + return this._chartObject; }, // Handlers onType: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - var chart = new Asc.CAscChartProp(); - chart.changeType(type); - me.api.ChartApply(chart); - - $('.chart-types li').removeClass('active'); - $target.addClass('active'); - - // Force update styles - me._updateChartStyles(me.api.asc_getChartPreviews(chart.getType())); }, onStyle: function (e) { @@ -405,23 +391,13 @@ define([ } }; - _chartObject = getTopObject(charts); + this._chartObject = getTopObject(charts); _shapeObject = getTopObject(shapes); }, - onApiUpdateChartStyles: function () { - if (this.api && _chartObject) { - this._updateChartStyles(this.api.asc_getChartPreviews(_chartObject.getType())); - } - }, - // Helpers _updateChartStyles: function(styles) { - Common.SharedSettings.set('chartstyles', styles); - Common.NotificationCenter.trigger('chartstyles:load', styles); - - $('#tab-chart-style li').single('click', _.bind(this.onStyle, this)); }, _closeIfNeed: function () { diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditShape.js b/apps/presentationeditor/mobile/app/controller/edit/EditShape.js index 3f264a65b6..78015826af 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditShape.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditShape.js @@ -234,18 +234,6 @@ define([ }, onReorder: function (e) { - var $target = $(e.currentTarget), - type = $target.data('type'); - - if ('all-up' == type) { - this.api.shapes_bringToFront(); - } else if ('all-down' == type) { - this.api.shapes_bringToBack(); - } else if ('move-up' == type) { - this.api.shapes_bringForward(); - } else if ('move-down' == type) { - this.api.shapes_bringBackward(); - } }, onAlign: function (e) { @@ -272,10 +260,6 @@ define([ }, onReplace: function (e) { - var $target = $(e.currentTarget), - type = $target.data('type'); - - this.api.ChangeShapeType(type); }, onBorderSize: function (e) { diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditTable.js b/apps/presentationeditor/mobile/app/controller/edit/EditTable.js index f181db8e6f..91d13c7c69 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditTable.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditTable.js @@ -112,9 +112,6 @@ define([ setApi: function (api) { var me = this; me.api = api; - - me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me)); }, onLaunch: function () { @@ -124,13 +121,6 @@ define([ initEvents: function () { var me = this; - $('#table-remove-all').single('click', _.bind(function(){me.api.remTable(); me._closeIfNeed()}, me)); - $('#insert-column-left').single('click', _.bind(function(){me.api.addColumnLeft(); me._closeIfNeed()}, me)); - $('#insert-column-right').single('click', _.bind(function(){me.api.addColumnRight(); me._closeIfNeed()}, me)); - $('#insert-row-above').single('click', _.bind(function(){me.api.addRowAbove(); me._closeIfNeed()}, me)); - $('#insert-row-below').single('click', _.bind(function(){me.api.addRowBelow(); me._closeIfNeed()}, me)); - $('#remove-column').single('click', _.bind(function(){me.api.remColumn(); me._closeIfNeed()}, me)); - $('#remove-row').single('click', _.bind(function(){me.api.remRow(); me._closeIfNeed()}, me)); $('#table-options-margins input').single('change touchend', _.buffered(me.onOptionMargin, 100, me)); $('#table-options-margins input').single('input', _.bind(me.onOptionMarginChanging, me)); @@ -548,19 +538,6 @@ define([ }); return tableExist; - }, - - onApiInitTemplates: function(templates) { - var styles = []; - - _.each(templates, function(template){ - styles.push({ - imageUrl : template.asc_getImage(), - templateId : template.asc_getId() - }); - }); - - this.getView('EditTable').updateStyles(styles); } } })(), PE.Controllers.EditTable || {})) From 35ea66e4407b8c948d5f5bb75b96c93a719ef210 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 10 Feb 2020 14:37:23 +0300 Subject: [PATCH 06/11] [PE mobile] Disable editing text and slide in opensource version --- .../mobile/app/controller/edit/EditSlide.js | 47 +------------------ .../mobile/app/controller/edit/EditText.js | 45 ++---------------- 2 files changed, 5 insertions(+), 87 deletions(-) diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditSlide.js b/apps/presentationeditor/mobile/app/controller/edit/EditSlide.js index 9fa0ba5fc8..ee367c7213 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditSlide.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditSlide.js @@ -53,7 +53,6 @@ define([ // Private var _stack = [], _slideObject = undefined, - _themes = [], _themeId = -1, _effect = Asc.c_oAscSlideTransitionTypes.None, _effectType = -1, @@ -81,6 +80,7 @@ define([ uiApp.onPageBack('editslide-effect-type editslide-effect', function (page) { me.initSettings('#edit-slide-transition'); }); + this._themes = []; }, setApi: function (api) { @@ -88,7 +88,6 @@ define([ me.api = api; me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me)); me.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(me.onApiUpdateThemeIndex, me)); }, @@ -210,28 +209,15 @@ define([ }, getThemes: function () { - return _themes || []; + return this._themes || []; }, // Handlers onLayoutClick: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - me.api.ChangeLayout(type); }, onThemeClick: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - $('.container-edit .slide-theme div').removeClass('active'); - $target.addClass('active'); - - me.api.ChangeTheme(type); }, onRemoveSlide: function () { @@ -386,35 +372,6 @@ define([ } }, - onApiInitEditorStyles: function(themes) { - if (themes) { - window.styles_loaded = false; - - var me = this, - defaultThemes = themes[0] || [], - docThemes = themes[1] || []; - - _themes = []; - - _.each(defaultThemes, function(theme, index) { - _themes.push({ - themeId : theme.get_Index(), - offsety : index * 38 - }); - }); - - _.each(docThemes, function(theme) { - _themes.push({ - imageUrl: theme.get_Image(), - themeId : theme.get_Index(), - offsety : 0 - }); - }); - - window.styles_loaded = true; - } - }, - onApiUpdateThemeIndex: function(themeId) { _themeId = themeId; $('.container-edit .slide-theme .row div').removeClass('active'); diff --git a/apps/presentationeditor/mobile/app/controller/edit/EditText.js b/apps/presentationeditor/mobile/app/controller/edit/EditText.js index 546cea3970..5b493dcfc5 100644 --- a/apps/presentationeditor/mobile/app/controller/edit/EditText.js +++ b/apps/presentationeditor/mobile/app/controller/edit/EditText.js @@ -51,28 +51,12 @@ define([ 'use strict'; PE.Controllers.EditText = Backbone.Controller.extend(_.extend((function() { - var _fontsArray = [], - _stack = [], + var _stack = [], _paragraphObject = undefined, _fontInfo = {}, _paragraphInfo = {}, metricText = Common.Utils.Metric.getCurrentMetricName(); - function onApiLoadFonts(fonts, select) { - _.each(fonts, function(font){ - var fontId = font.asc_getFontId(); - _fontsArray.push({ - id : fontId, - name : font.asc_getFontName(), -// displayValue: font.asc_getFontName(), - imgidx : font.asc_getFontThumbnail(), - type : font.asc_getFontType() - }); - }); - - Common.NotificationCenter.trigger('fonts:load', _fontsArray, select); - } - return { models: [], collections: [], @@ -90,35 +74,12 @@ define([ 'font:click': this.onFontClick } }); + this._fontsArray = []; }, setApi: function (api) { var me = this; me.api = api; - - me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me)); - me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - me.api.asc_registerCallback('asc_onFontFamily', _.bind(me.onApiChangeFont, me)); - me.api.asc_registerCallback('asc_onFontSize', _.bind(me.onApiFontSize, me)); - me.api.asc_registerCallback('asc_onBold', _.bind(me.onApiBold, me)); - me.api.asc_registerCallback('asc_onItalic', _.bind(me.onApiItalic, me)); - me.api.asc_registerCallback('asc_onUnderline', _.bind(me.onApiUnderline, me)); - me.api.asc_registerCallback('asc_onStrikeout', _.bind(me.onApiStrikeout, me)); - me.api.asc_registerCallback('asc_onVerticalAlign', _.bind(me.onApiVerticalAlign, me)); - me.api.asc_registerCallback('asc_onTextColor', _.bind(me.onApiTextColor, me)); - - me.api.asc_registerCallback('asc_onListType', _.bind(me.onApiBullets, me)); - me.api.asc_registerCallback('asc_onPrAlign', _.bind(me.onApiParagraphAlign, me)); - me.api.asc_registerCallback('asc_canIncreaseIndent', _.bind(me.onApiCanIncreaseIndent, me)); - me.api.asc_registerCallback('asc_canDecreaseIndent', _.bind(me.onApiCanDecreaseIndent, me)); - me.api.asc_registerCallback('asc_onLineSpacing', _.bind(me.onApiLineSpacing, me)); - me.api.asc_registerCallback('asc_onVerticalTextAlign', _.bind(me.onApiVerticalTextAlign, me)); - - // me.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(this.onApiUpdateThemeIndex, this)); - // me.api.asc_registerCallback('asc_onCanGroup', _.bind(this.onApiCanGroup, this)); - // me.api.asc_registerCallback('asc_onCanUnGroup', _.bind(this.onApiCanUnGroup, this)); - // me.api.asc_registerCallback('asc_onPresentationSize', _.bind(this.onApiPageSize, this)); - // me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); }, onLaunch: function () { @@ -199,7 +160,7 @@ define([ // Public getFonts: function() { - return _fontsArray; + return this._fontsArray; }, getStack: function() { From 32cb105d4d19fbe0dd19d6235608cfe0aea2aa29 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 10 Feb 2020 14:43:42 +0300 Subject: [PATCH 07/11] [PE mobile] Fix opensource warning --- apps/presentationeditor/mobile/app/controller/Main.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/presentationeditor/mobile/app/controller/Main.js b/apps/presentationeditor/mobile/app/controller/Main.js index 33e8267aa4..a004286647 100644 --- a/apps/presentationeditor/mobile/app/controller/Main.js +++ b/apps/presentationeditor/mobile/app/controller/Main.js @@ -579,8 +579,7 @@ define([ var value = Common.localStorage.getItem("pe-opensource-warning"); value = (value!==null) ? parseInt(value) : 0; var now = (new Date).getTime(); - if (now - value > 40) { - // if (now - value > 86400000) { + if (now - value > 86400000) { Common.localStorage.setItem("pe-opensource-warning", now); uiApp.modal({ title: me.notcriticalErrorTitle, From ae69d00eb7ca8874d7d645289f7bfecce2af5d37 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 10 Feb 2020 19:26:27 +0300 Subject: [PATCH 08/11] [SSE mobile] Disable editing in opensource version --- .../mobile/app/controller/Main.js | 28 +++++- .../mobile/app/controller/add/AddChart.js | 4 - .../mobile/app/controller/add/AddFunction.js | 38 +------- .../mobile/app/controller/add/AddLink.js | 54 ++---------- .../mobile/app/controller/add/AddOther.js | 10 --- .../mobile/app/controller/add/AddShape.js | 6 -- .../mobile/app/controller/edit/EditChart.js | 86 ++++--------------- .../mobile/app/controller/edit/EditShape.js | 19 ---- 8 files changed, 46 insertions(+), 199 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/app/controller/Main.js b/apps/spreadsheeteditor/mobile/app/controller/Main.js index c3eeaefc36..dd7a3cb23e 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/Main.js +++ b/apps/spreadsheeteditor/mobile/app/controller/Main.js @@ -606,6 +606,21 @@ define([ applyLicense: function() { var me = this; + if (this.editorConfig.mode !== 'view' && !this.isSupportEditFeature()) { + var value = Common.localStorage.getItem("sse-opensource-warning"); + value = (value!==null) ? parseInt(value) : 0; + var now = (new Date).getTime(); + if (now - value > 86400000) { + Common.localStorage.setItem("sse-opensource-warning", now); + uiApp.modal({ + title: me.notcriticalErrorTitle, + text : me.errorOpensource, + buttons: [{text: 'OK'}] + }); + } + SSE.getController('Toolbar').activateControls(); + return; + } if (this._state.licenseType) { var license = this._state.licenseType, buttons = [{text: 'OK'}]; @@ -712,8 +727,9 @@ define([ me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; me.appOptions.canEdit = me.permissions.edit !== false && // can edit - (me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined - me.appOptions.isEdit = (me.appOptions.canLicense || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && me.permissions.edit !== false && me.editorConfig.mode !== 'view'; + (me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view') && // if mode=="view" -> canRequestEditRights must be defined + me.isSupportEditFeature(); + me.appOptions.isEdit = (me.appOptions.canLicense || me.appOptions.isEditDiagram || me.appOptions.isEditMailMerge) && me.permissions.edit !== false && me.editorConfig.mode !== 'view' && me.isSupportEditFeature(); me.appOptions.canDownload = (me.permissions.download !== false); me.appOptions.canPrint = (me.permissions.print !== false); @@ -1247,7 +1263,6 @@ define([ }, onSendThemeColors: function(colors, standart_colors) { - Common.Utils.ThemeColor.setColors(colors, standart_colors); }, onAdvancedOptions: function(type, advOptions, mode, formatOptions) { @@ -1460,6 +1475,10 @@ define([ } }, + isSupportEditFeature: function() { + return false; + }, + leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' to await the autosave of the document. Click \'Leave this Page\' to discard all the unsaved changes.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning', @@ -1642,7 +1661,8 @@ define([ errorFrmlMaxTextLength: 'Text values in formulas are limited to 255 characters.
Use the CONCATENATE function or concatenation operator (&)', waitText: 'Please, wait...', errorFileSizeExceed: 'The file size exceeds the limitation set for your server.
Please contact your Document Server administrator for details.', - errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.' + errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.
Before you can continue working, you need to download the file or copy its content to make sure nothing is lost, and then reload this page.', + errorOpensource: 'Files can be opened for viewing only. Mobile web editors are not available in the Open Source version.' } })(), SSE.Controllers.Main || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddChart.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddChart.js index 58015d7474..bb91e2c398 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddChart.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddChart.js @@ -78,10 +78,6 @@ define([ onInsertChart: function (type) { SSE.getController('AddContainer').hideModal(); - - var settings = this.api.asc_getChartObject(); - settings.changeType(type); - this.api.asc_addChartDrawingObject(settings); }, txtDiagramTitle: 'Chart Title', diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js index 6dfa007d85..2f8e89353e 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddFunction.js @@ -69,6 +69,7 @@ define([ 'function:info': me.onFunctionInfo.bind(me) } }); + this.fd = fd; }, setApi: function (api) { @@ -111,40 +112,7 @@ define([ editorLang = (editorLang ? editorLang : 'en').split(/[\-\_]/)[0].toLowerCase(); - var localizationFunctionsDesc = function (data) { - var jsonDesc = {}, - view = me.getView('AddFunction'); - - fd = data; - - try { - jsonDesc = JSON.parse(fd); - } catch (e) { - jsonDesc = fd - } - - var grouparr = me.api.asc_getFormulasInfo(); - for (var g in grouparr) { - var group = grouparr[g]; - var groupname = group.asc_getGroupName(); - var funcarr = group.asc_getFormulasArray(); - - for (var f in funcarr) { - var func = funcarr[f]; - var _name = func.asc_getName(); - functions[_name] = { - type: _name, - group: groupname, - caption: func.asc_getLocaleName(), - args: (jsonDesc && jsonDesc[_name]) ? jsonDesc[_name].a : '', - descr: (jsonDesc && jsonDesc[_name]) ? jsonDesc[_name].d : '' - }; - } - } - - view.setFunctions(functions, editorLang); - view.render(); - }; + var localizationFunctionsDesc = function (data) {}; $.getJSON(Common.Utils.String.format("{0}/{1}_desc.json", "resources/l10n/functions", editorLang), function(json) { localizationFunctionsDesc(json); @@ -155,8 +123,6 @@ define([ onInsertFunction: function (type) { SSE.getController('AddContainer').hideModal(); - - this.api.asc_insertFormula(this.api.asc_getFormulaLocaleName(type), Asc.c_oAscPopUpSelectorType.Func, true); }, onFunctionInfo: function (type) { diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js index a4c42bd5e1..2ac49847a6 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddLink.js @@ -49,54 +49,6 @@ define([ var cfgLink; // Handlers - function onInsertLink (args) { - var link = new Asc.asc_CHyperlink(); - - if ( args.type == 'ext' ) { - var url = args.url, - urltype = this.api.asc_getUrlType($.trim(url)), - isEmail = (urltype == 2); - - if (urltype < 1) { - uiApp.alert(this.txtNotUrl); - return; - } - - url = url.replace(/^\s+|\s+$/g,''); - - if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) ) - url = (isEmail ? 'mailto:' : 'http://' ) + url; - - url = url.replace(new RegExp("%20",'g')," "); - - link.asc_setType(Asc.c_oAscHyperlinkType.WebLink); - link.asc_setHyperlinkUrl(url); - display = url; - } else { - var isValid = /^[A-Z]+[1-9]\d*:[A-Z]+[1-9]\d*$/.test(args.url); - - if (!isValid) - isValid = /^[A-Z]+[1-9]\d*$/.test(args.url); - - if (!isValid) { - uiApp.alert(this.textInvalidRange); - return; - } - - link.asc_setType(Asc.c_oAscHyperlinkType.RangeLink); - link.asc_setSheet(args.sheet); - link.asc_setRange(args.url); - - var display = args.sheet + '!' + args.url; - } - - link.asc_setText(args.text == null ? null : !!args.text ? args.text : display); - link.asc_setTooltip(args.tooltip); - - this.api.asc_insertHyperlink(link); - - SSE.getController('AddContainer').hideModal(); - } function onChangePanel (view, pageId) { var me = this; @@ -142,7 +94,7 @@ define([ this.addListeners({ 'AddLink': { 'panel:change' : onChangePanel.bind(this) - , 'link:insert': onInsertLink.bind(this) + , 'link:insert': this.onInsertLink.bind(this) , 'link:changetype': onChangeLinkType.bind(this) , 'link:changesheet': onChangeLinkSheet.bind(this) } @@ -218,6 +170,10 @@ define([ view.fireEvent('page:show', [this, '#addlink']); }, + onInsertLink: function(args){ + SSE.getController('AddContainer').hideModal(); + }, + textInvalidRange : 'ERROR! Invalid cells range', txtNotUrl : 'This field should be a URL in the format \"http://www.example.com\"' } diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js index f3e78efd05..570fec38c5 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddOther.js @@ -112,10 +112,6 @@ define([ if (!_.isEmpty(url)) { if ((/((^https?)|(^ftp)):\/\/.+/i.test(url))) { SSE.getController('AddContainer').hideModal(); - - _.defer(function () { - me.api.asc_addImageDrawingObject(url); - }); } else { uiApp.alert(me.txtNotUrl); } @@ -124,7 +120,6 @@ define([ } } else { SSE.getController('AddContainer').hideModal(); - this.api.asc_addImage(); } }, @@ -133,11 +128,6 @@ define([ }, onInsertFilter: function(checked) { - var formatTableInfo = this.api.asc_getCellInfo().asc_getFormatTableInfo(); - var tablename = (formatTableInfo) ? formatTableInfo.asc_getTableName() : undefined; - if (checked) - this.api.asc_addAutoFilter(); else - this.api.asc_changeAutoFilter(tablename, Asc.c_oAscChangeFilterOptions.filter, checked); }, onError: function(id, level, errData) { diff --git a/apps/spreadsheeteditor/mobile/app/controller/add/AddShape.js b/apps/spreadsheeteditor/mobile/app/controller/add/AddShape.js index b3411de3b0..b7a1cbcf23 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/add/AddShape.js +++ b/apps/spreadsheeteditor/mobile/app/controller/add/AddShape.js @@ -211,12 +211,6 @@ define([ }, onShapeClick: function (e) { - var $target = $(e.currentTarget); - - if ($target && this.api) { - this.api.asc_addShapeOnSheet($target.data('type')); - } - SSE.getController('AddContainer').hideModal(); }, diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js index dcdcfccf9c..f3e4206290 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditChart.js @@ -53,11 +53,9 @@ define([ SSE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() { var _stack = [], - _chartObject = undefined, _shapeObject = undefined, _borderInfo = {color: '000000', width: 1}, - _metricText = Common.Utils.Metric.getCurrentMetricName(), - _isEdit = false; + _metricText = Common.Utils.Metric.getCurrentMetricName(); var borderSizeTransform = (function() { var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6]; @@ -101,23 +99,19 @@ define([ 'page:show' : this.onPageShow } }); + this._chartObject = undefined; + this._isEdit = false; }, setApi: function (api) { var me = this; me.api = api; - me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me)); me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); - - me.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(me.onApiUpdateChartStyles, me)); - // me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me)); - // me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me)); - // me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me)); // TODO: It does not work until the error in the SDK }, setMode: function (mode) { - _isEdit = mode.isEdit; + this._isEdit = mode.isEdit; }, onLaunch: function () { @@ -178,15 +172,17 @@ define([ initRootPage: function () { $('#chart-remove').single('click', _.bind(this.onRemoveChart, this)); - if (!_.isUndefined(_chartObject)) { - this.updateAxisProps(_chartObject.get_ChartProperties().getType()); + if (!_.isUndefined(this._chartObject)) { + this.updateAxisProps(this._chartObject.get_ChartProperties().getType()); } }, initStylePage: function () { + if (_.isUndefined(this._chartObject)) return; + var me = this, color, - chartProperties = _chartObject.get_ChartProperties(), + chartProperties = me._chartObject.get_ChartProperties(), shapeProperties = _shapeObject.get_ShapeProperties(); // Type @@ -199,7 +195,7 @@ define([ // Styles _.defer(function () { - me._updateChartStyles(me.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType())); + me._updateChartStyles(me.api.asc_getChartPreviews(me._chartObject.get_ChartProperties().getType())); }); // Fill @@ -247,8 +243,10 @@ define([ }, initLayoutPage: function () { + if (_.isUndefined(this._chartObject)) return; + var me = this, - chartProperties = _chartObject.get_ChartProperties(), + chartProperties = me._chartObject.get_ChartProperties(), chartType = chartProperties.getType(), $layoutPage = $('.page[data-page=edit-chart-layout]'); @@ -564,41 +562,9 @@ define([ }, onType: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - $('.chart-types li').removeClass('active'); - $target.addClass('active'); - - _.defer(function() { - var image = new Asc.asc_CImgProperty(), - chart = _chartObject.get_ChartProperties(); - - chart.changeType(type); - image.put_ChartProperties(chart); - - me.api.asc_setGraphicObjectProps(image); - - // Force update styles - me._updateChartStyles(me.api.asc_getChartPreviews(chart.getType())); - - me.updateAxisProps(type); - }); }, onStyle: function (e) { - var me = this, - $target = $(e.currentTarget), - type = $target.data('type'); - - var image = new Asc.asc_CImgProperty(), - chart = _chartObject.get_ChartProperties(); - - chart.putStyle(type); - image.put_ChartProperties(chart); - - me.api.asc_setGraphicObjectProps(image); }, onFillColor:function (palette, color) { @@ -937,32 +903,10 @@ define([ // API handlers - onApiUpdateChartStyles: function () { - if (this.api && _chartObject && _chartObject.get_ChartProperties()) { - this._updateChartStyles(this.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType())); - } - }, - - onApiSelectionChanged: function(info) { - if (!_isEdit) { - return; - } - - var me = this, - selectedObjects = [], - selectType = info.asc_getFlags().asc_getSelectionType(); - - if (selectType == Asc.c_oAscSelectionType.RangeChart) { - selectedObjects = me.api.asc_getGraphicObjectProps(); - } - - me.onApiFocusObject(selectedObjects); - }, - onApiFocusObject: function (objects) { _stack = objects; - if (!_isEdit) { + if (!this._isEdit) { return; } @@ -989,7 +933,7 @@ define([ } }; - _chartObject = getTopObject(charts); + this._chartObject = getTopObject(charts); _shapeObject = getTopObject(shapes); }, diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js index 292e98b353..7d2fe608fb 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditShape.js @@ -241,28 +241,9 @@ define([ }, onReorder: function(e) { - var $target = $(e.currentTarget), - type = $target.data('type'), - ascType; - - if (type == 'all-up') { - ascType = Asc.c_oAscDrawingLayerType.BringToFront; - } else if (type == 'all-down') { - ascType = Asc.c_oAscDrawingLayerType.SendToBack; - } else if (type == 'move-up') { - ascType = Asc.c_oAscDrawingLayerType.BringForward; - } else { - ascType = Asc.c_oAscDrawingLayerType.SendBackward; - } - - this.api.asc_setSelectedDrawingObjectLayer(ascType); }, onReplace: function (e) { - var $target = $(e.currentTarget), - type = $target.data('type'); - - this.api.asc_changeShapeType(type); }, onBorderSize: function (e) { From 631cea5e0683c472ec5070f9f73f628def1fa259 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Mon, 10 Feb 2020 20:19:09 +0300 Subject: [PATCH 09/11] [SSE mobile] Disable cell editing in opensource version --- .../mobile/app/controller/edit/EditCell.js | 104 ++++++------------ 1 file changed, 32 insertions(+), 72 deletions(-) diff --git a/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js b/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js index b34602d994..c603a4903c 100644 --- a/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js +++ b/apps/spreadsheeteditor/mobile/app/controller/edit/EditCell.js @@ -51,29 +51,8 @@ define([ 'use strict'; SSE.Controllers.EditCell = Backbone.Controller.extend(_.extend((function() { - var _fontsArray = [], - _stack = [], - _cellInfo = undefined, - _cellStyles = [], - _fontInfo = {}, - _borderInfo = {color: '000000', width: Asc.c_oAscBorderStyles.Medium}, - _styleSize = {width: 100, height: 50}, - _isEdit = false; - - function onApiLoadFonts(fonts, select) { - _.each(fonts, function(font){ - var fontId = font.asc_getFontId(); - _fontsArray.push({ - id : fontId, - name : font.asc_getFontName(), -// displayValue: font.asc_getFontName(), - imgidx : font.asc_getFontThumbnail(), - type : font.asc_getFontType() - }); - }); - - Common.NotificationCenter.trigger('fonts:load', _fontsArray, select); - } + var _stack = [], + _borderInfo = {color: '000000', width: Asc.c_oAscBorderStyles.Medium}; return { models: [], @@ -92,22 +71,26 @@ define([ 'style:click' : this.onStyleClick } }); + this._fontsArray = []; + this._styleSize = {width: 100, height: 50}; + this._cellStyles = []; + this._cellInfo = undefined; + this._fontInfo = {}; + this._isEdit = false; }, setApi: function (api) { var me = this; me.api = api; - me.api.asc_setThumbnailStylesSizes(_styleSize.width, _styleSize.height); + me.api.asc_setThumbnailStylesSizes(me._styleSize.width, me._styleSize.height); - me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me)); me.api.asc_registerCallback('asc_onSelectionChanged', _.bind(me.onApiSelectionChanged, me)); me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me)); - me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me)); }, setMode: function (mode) { - _isEdit = mode.isEdit; + this._isEdit = mode.isEdit; }, onLaunch: function () { @@ -125,13 +108,11 @@ define([ $('#font-italic').single('click', _.bind(me.onItalic, me)); $('#font-underline').single('click', _.bind(me.onUnderline, me)); - me.getView('EditCell').renderStyles(_cellStyles); + me.getView('EditCell').renderStyles(me._cellStyles); me.initSettings(); }, - - onPageShow: function (view, pageId) { var me = this; @@ -156,14 +137,14 @@ define([ } else if (!_.isUndefined(pageId) && pageId.indexOf('#edit-cell-format') > -1) { me.initCellFormat(); } else { - me.initCellSettings(_cellInfo); + me.initCellSettings(me._cellInfo); } }, // Public getFonts: function() { - return _fontsArray; + return this._fontsArray; }, getStack: function() { @@ -171,20 +152,20 @@ define([ }, getFontInfo: function () { - return _fontInfo; + return this._fontInfo; }, getCell: function () { - return _cellInfo; + return this._cellInfo; }, getStyleSize: function () { - return _styleSize; + return this._styleSize; }, initFontsPage: function () { var me = this, - displaySize = _fontInfo.size; + displaySize = this._fontInfo.size; _.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt; @@ -195,7 +176,7 @@ define([ initTextColorPage: function () { var me = this, palette = me.getView('EditCell').paletteTextColor, - color = me._sdkToThemeColor(_fontInfo.color); + color = me._sdkToThemeColor(this._fontInfo.color); if (palette) { palette.select(color); @@ -204,9 +185,11 @@ define([ }, initFillColorPage: function () { + if (_.isUndefined(this._cellInfo)) return; + var me = this, palette = me.getView('EditCell').paletteFillColor, - color = me._sdkToThemeColor(_cellInfo.asc_getFill().asc_getColor()); + color = me._sdkToThemeColor(me._cellInfo.asc_getFill().asc_getColor()); if (palette) { palette.select(color); @@ -228,13 +211,15 @@ define([ }, initTextFormat: function () { + if (_.isUndefined(this._cellInfo)) return; + var me = this, $pageTextFormat = $('.page[data-page=edit-text-format]'), - hAlign = _cellInfo.asc_getHorAlign(), - vAlign = _cellInfo.asc_getVertAlign(), + hAlign = me._cellInfo.asc_getHorAlign(), + vAlign = me._cellInfo.asc_getVertAlign(), hAlignStr = 'left', vAlignStr = 'bottom', - isWrapText = _cellInfo.asc_getFlags().asc_getWrapText(); + isWrapText = me._cellInfo.asc_getFlags().asc_getWrapText(); if (vAlign == Asc.c_oAscVAlign.Top) vAlignStr = 'top'; @@ -294,7 +279,7 @@ define([ // Init font name var fontName = fontObj.asc_getName() || this.textFonts; - _fontInfo.name = fontName; + this._fontInfo.name = fontName; $('#font-fonts .item-title').html(fontName); @@ -306,8 +291,8 @@ define([ // Init font size - _fontInfo.size = fontObj.asc_getSize(); - var displaySize = _fontInfo.size; + this._fontInfo.size = fontObj.asc_getSize(); + var displaySize = this._fontInfo.size; _.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt; @@ -316,9 +301,9 @@ define([ // Init font color - _fontInfo.color = fontObj.asc_getColor(); + this._fontInfo.color = fontObj.asc_getColor(); - var color = _fontInfo.color, + var color = this._fontInfo.color, clr = me._sdkToThemeColor(color); $('#text-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr)); @@ -356,21 +341,12 @@ define([ me.initTextFormat(); }, - onApiInitEditorStyles: function(styles){ - window.styles_loaded = false; - _cellStyles = styles; - - this.getView('EditCell').renderStyles(styles); - - window.styles_loaded = true; - }, - // Handlers onFontSize: function (e) { var me = this, $button = $(e.currentTarget), - fontSize = _fontInfo.size; + fontSize = this._fontInfo.size; if ($button.hasClass('decrement')) { _.isUndefined(fontSize) ? me.api.asc_decreaseFontSize() : fontSize = Math.max(1, --fontSize); @@ -464,10 +440,6 @@ define([ }, onCellFormat: function (e) { - var $target = $(e.currentTarget), - type = decodeURIComponent(atob($target.data('type'))); - - this.api.asc_setCellFormat(type); }, onBorderStyle: function (e) { @@ -504,21 +476,9 @@ define([ // API handlers onApiEditorSelectionChanged: function(fontObj) { - if (!_isEdit) { - return; - } - - _fontInfo = fontObj; - this.initFontSettings(fontObj); }, onApiSelectionChanged: function(cellInfo) { - if (!_isEdit) { - return; - } - - _cellInfo = cellInfo; - this.initCellSettings(cellInfo); }, // Helpers From e6d871f060d33a6fe1bcae02abd74636222927df Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 11 Feb 2020 12:59:28 +0300 Subject: [PATCH 10/11] [DE PE SSE] correct paths --- apps/documenteditor/mobile/app-dev.js | 10 ++++------ apps/documenteditor/mobile/app.js | 6 +----- apps/presentationeditor/mobile/app-dev.js | 10 ++++------ apps/presentationeditor/mobile/app.js | 6 +----- apps/spreadsheeteditor/mobile/app-dev.js | 10 ++++------ apps/spreadsheeteditor/mobile/app.js | 6 +----- 6 files changed, 15 insertions(+), 33 deletions(-) diff --git a/apps/documenteditor/mobile/app-dev.js b/apps/documenteditor/mobile/app-dev.js index 0a49bab004..2cc307b68f 100644 --- a/apps/documenteditor/mobile/app-dev.js +++ b/apps/documenteditor/mobile/app-dev.js @@ -62,7 +62,8 @@ require.config({ gateway : 'common/Gateway', locale : 'common/locale', irregularstack : 'common/IrregularStack', - sharedsettings : 'common/mobile/utils/SharedSettings' + sharedsettings : 'common/mobile/utils/SharedSettings', + features : '../../web-apps-mobile/word/patch' }, shim: { @@ -224,11 +225,8 @@ require([ 'common/mobile/lib/controller/Collaboration' ], function() { window.compareVersions = true; - require(['documenteditor/mobile/app/controller/FeatureEdit'], function () { - app.start(); - }, function (error) { - app.start(); - }); + var _s = app.start.bind(app); + require(['features'], _s, _s); }); }); }, function(err) { diff --git a/apps/documenteditor/mobile/app.js b/apps/documenteditor/mobile/app.js index 7906d27c3a..dba0a47b41 100644 --- a/apps/documenteditor/mobile/app.js +++ b/apps/documenteditor/mobile/app.js @@ -234,11 +234,7 @@ require([ 'documenteditor/mobile/app/controller/add/AddOther', 'common/mobile/lib/controller/Collaboration' ], function() { - require(['documenteditor/mobile/app/controller/FeatureEdit'], function () { - app.start(); - }, function (error) { - app.start(); - }); + app.start(); }); }); }, function(err) { diff --git a/apps/presentationeditor/mobile/app-dev.js b/apps/presentationeditor/mobile/app-dev.js index 5229e143bf..931f572a88 100644 --- a/apps/presentationeditor/mobile/app-dev.js +++ b/apps/presentationeditor/mobile/app-dev.js @@ -61,7 +61,8 @@ require.config({ gateway : 'common/Gateway', locale : 'common/locale', irregularstack : 'common/IrregularStack', - sharedsettings : 'common/mobile/utils/SharedSettings' + sharedsettings : 'common/mobile/utils/SharedSettings', + features : '../../web-apps-mobile/slide/patch' }, shim: { @@ -221,11 +222,8 @@ require([ ], function() { window.compareVersions = true; - require(['presentationeditor/mobile/app/controller/FeatureEdit'], function () { - app.start(); - }, function (error) { - app.start(); - }); + var _s = app.start.bind(app); + require(['features'], _s, _s); }); }); }, function(err) { diff --git a/apps/presentationeditor/mobile/app.js b/apps/presentationeditor/mobile/app.js index 04819cdf43..abcec73a80 100644 --- a/apps/presentationeditor/mobile/app.js +++ b/apps/presentationeditor/mobile/app.js @@ -230,11 +230,7 @@ require([ 'presentationeditor/mobile/app/controller/add/AddSlide', 'common/mobile/lib/controller/Collaboration' ], function() { - require(['presentationeditor/mobile/app/controller/FeatureEdit'], function () { - app.start(); - }, function (error) { - app.start(); - }); + app.start(); }); }); }, function(err) { diff --git a/apps/spreadsheeteditor/mobile/app-dev.js b/apps/spreadsheeteditor/mobile/app-dev.js index eaa939bfde..ab63b4d3ce 100644 --- a/apps/spreadsheeteditor/mobile/app-dev.js +++ b/apps/spreadsheeteditor/mobile/app-dev.js @@ -61,7 +61,8 @@ require.config({ gateway : 'common/Gateway', locale : 'common/locale', irregularstack : 'common/IrregularStack', - sharedsettings : 'common/mobile/utils/SharedSettings' + sharedsettings : 'common/mobile/utils/SharedSettings', + features : '../../web-apps-mobile/cell/patch' }, shim: { @@ -210,11 +211,8 @@ require([ ,'common/mobile/lib/controller/Collaboration' ], function() { window.compareVersions = true; - require(['spreadsheeteditor/mobile/app/controller/FeatureEdit'], function () { - app.start(); - }, function (error) { - app.start(); - }); + var _s = app.start.bind(app); + require(['features'], _s, _s); }); }); }, function(err) { diff --git a/apps/spreadsheeteditor/mobile/app.js b/apps/spreadsheeteditor/mobile/app.js index 8c44121018..9536367dd0 100644 --- a/apps/spreadsheeteditor/mobile/app.js +++ b/apps/spreadsheeteditor/mobile/app.js @@ -220,11 +220,7 @@ require([ ,'spreadsheeteditor/mobile/app/controller/FilterOptions' ,'common/mobile/lib/controller/Collaboration' ], function() { - require(['spreadsheeteditor/mobile/app/controller/FeatureEdit'], function () { - app.start(); - }, function (error) { - app.start(); - }); + app.start(); }); }); }, function(err) { From 5303f4958b2bd4554d6ccdf7784539b9585bbf6b Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Tue, 11 Feb 2020 13:00:21 +0300 Subject: [PATCH 11/11] [build] extended deployment to load addons --- build/Gruntfile.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/build/Gruntfile.js b/build/Gruntfile.js index cdffd45a31..f3e16b586d 100644 --- a/build/Gruntfile.js +++ b/build/Gruntfile.js @@ -60,6 +60,14 @@ module.exports = function(grunt) { to: process.env['PLUGIN_LINK_MACROS'] || 'https://api.onlyoffice.com/plugin/macros' }]; + let path = require('path'); + let addons = grunt.option('addon') || []; + if (!Array.isArray(addons)) + addons = [addons]; + + addons.forEach((element,index,self) => self[index] = '../../web-apps-' + element + '/build'); + addons = addons.filter(element => grunt.file.isDir(element)); + grunt.loadNpmTasks('grunt-contrib-clean'); grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-uglify'); @@ -134,6 +142,14 @@ module.exports = function(grunt) { if (packageFile) { grunt.log.ok(appName + ' config loaded successfully'.green); + addons.forEach(element => { + let _path = path.join(element,configFile); + if (grunt.file.exists(_path)) { + _merge(packageFile, require(_path)); + grunt.log.ok('addon '.green + element + ' is merged successfully'.green); + } + }); + if ( !!_extConfig && _extConfig.name == packageFile.name ) { _merge(packageFile, _extConfig); }