[DE mobile] Disable editing in opensource version

This commit is contained in:
Julia Radzhabova 2020-02-07 13:15:30 +03:00
parent c0734656fe
commit 2ab911a439
9 changed files with 48 additions and 175 deletions

View file

@ -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) {

View file

@ -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.<br>Please contact our Sales Department to get a quote.',
waitText: 'Please, wait...',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.',
errorUpdateVersionOnDisconnect: 'Internet connection has been restored, and the file version has been changed.<br>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.<br>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 || {}))
});

View file

@ -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);
}

View file

@ -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();
},

View file

@ -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();
},

View file

@ -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',

View file

@ -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) {

View file

@ -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) {

View file

@ -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 () {