Merge pull request #335 from ONLYOFFICE/feature/mobile-opensource

Feature/mobile opensource
This commit is contained in:
Alexey Golubev 2020-02-11 13:35:08 +03:00 committed by GitHub
commit 07b3d69d88
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 231 additions and 858 deletions

View file

@ -62,7 +62,8 @@ require.config({
gateway : 'common/Gateway', gateway : 'common/Gateway',
locale : 'common/locale', locale : 'common/locale',
irregularstack : 'common/IrregularStack', irregularstack : 'common/IrregularStack',
sharedsettings : 'common/mobile/utils/SharedSettings' sharedsettings : 'common/mobile/utils/SharedSettings',
features : '../../web-apps-mobile/word/patch'
}, },
shim: { shim: {
@ -224,7 +225,8 @@ require([
'common/mobile/lib/controller/Collaboration' 'common/mobile/lib/controller/Collaboration'
], function() { ], function() {
window.compareVersions = true; window.compareVersions = true;
app.start(); var _s = app.start.bind(app);
require(['features'], _s, _s);
}); });
}); });
}, function(err) { }, function(err) {

View file

@ -643,6 +643,22 @@ define([
applyLicense: function() { applyLicense: function() {
var me = this; 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) { if (this._state.licenseType) {
var license = this._state.licenseType, var license = this._state.licenseType,
buttons = [{text: 'OK'}]; buttons = [{text: 'OK'}];
@ -737,7 +753,8 @@ define([
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canEdit = (me.permissions.edit !== false || me.permissions.review === true) && // can edit or review 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.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.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.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; 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) { onSendThemeColors: function(colors, standart_colors) {
Common.Utils.ThemeColor.setColors(colors, standart_colors);
}, },
onAdvancedOptions: function(type, advOptions, mode, formatOptions) { 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.', 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', criticalErrorTitle: 'Error',
notcriticalErrorTitle: 'Warning', 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.', 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...', waitText: 'Please, wait...',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.', 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 || {})) })(), DE.Controllers.Main || {}))
}); });

View file

@ -98,10 +98,6 @@ define([
onInsertByFile: function (e) { onInsertByFile: function (e) {
DE.getController('AddContainer').hideModal(); DE.getController('AddContainer').hideModal();
if (this.api) {
this.api.asc_addImage();
}
}, },
onUrlChange: function (e) { onUrlChange: function (e) {
@ -118,9 +114,6 @@ define([
if (!_.isEmpty(value)) { if (!_.isEmpty(value)) {
if ((/((^https?)|(^ftp)):\/\/.+/i.test(value))) { if ((/((^https?)|(^ftp)):\/\/.+/i.test(value))) {
DE.getController('AddContainer').hideModal(); DE.getController('AddContainer').hideModal();
_.defer(function () {
me.api.AddImageUrl(value);
});
} else { } else {
uiApp.alert(me.txtNotUrl); uiApp.alert(me.txtNotUrl);
} }

View file

@ -79,9 +79,6 @@ define([
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; me.api = api;
// me.api.asc_registerCallback('asc_onInitEditorFonts', _.bind(onApiLoadFonts, me));
}, },
onLaunch: function () { onLaunch: function () {
@ -145,28 +142,7 @@ define([
}, },
onClickInsertFootnote: function() { onClickInsertFootnote: function() {
var me = this, DE.getController('AddContainer').hideModal();
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();
}
}, },
onFormatFootnoteChange: function(e) { onFormatFootnoteChange: function(e) {
@ -227,32 +203,6 @@ define([
}, },
onInsertLink: function (e) { 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(); DE.getController('AddContainer').hideModal();
}, },

View file

@ -215,13 +215,6 @@ define([
}, },
onShapeClick: function (e) { onShapeClick: function (e) {
var me = this,
$target = $(e.currentTarget);
if ($target && me.api) {
me.api.AddShapeOnCurrentPage($target.data('type'));
}
DE.getController('AddContainer').hideModal(); DE.getController('AddContainer').hideModal();
}, },

View file

@ -51,8 +51,7 @@ define([
'use strict'; 'use strict';
DE.Controllers.AddTable = Backbone.Controller.extend(_.extend((function() { DE.Controllers.AddTable = Backbone.Controller.extend(_.extend((function() {
var _styles = [], var _initDefaultStyles = false;
_initDefaultStyles = false;
return { return {
models: [], models: [],
@ -69,13 +68,13 @@ define([
'view:render' : this.onViewRender 'view:render' : this.onViewRender
} }
}); });
this._styles = [];
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; me.api = api;
me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me));
}, },
onLaunch: function () { onLaunch: function () {
@ -87,7 +86,7 @@ define([
if (!_initDefaultStyles) { if (!_initDefaultStyles) {
_initDefaultStyles = true; _initDefaultStyles = true;
_styles = []; this._styles = [];
me.api.asc_GetDefaultTableStyles(); me.api.asc_GetDefaultTableStyles();
} }
@ -172,22 +171,7 @@ define([
// Public // Public
getStyles: function () { 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();
}
}, },
textTableSize: 'Table Size', textTableSize: 'Table Size',

View file

@ -52,7 +52,6 @@ define([
DE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() { DE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() {
// Private // Private
var _stack = [], var _stack = [],
_chartObject = undefined,
_shapeObject = undefined, _shapeObject = undefined,
_metricText = Common.Utils.Metric.getCurrentMetricName(), _metricText = Common.Utils.Metric.getCurrentMetricName(),
_borderColor = 'transparent'; _borderColor = 'transparent';
@ -127,6 +126,8 @@ define([
'page:show': this.onPageShow 'page:show': this.onPageShow
} }
}); });
this._chartObject = undefined;
}, },
setApi: function (api) { setApi: function (api) {
@ -134,7 +135,6 @@ define([
me.api = api; me.api = api;
me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me));
me.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(me.onApiUpdateChartStyles, me));
}, },
onLaunch: function () { onLaunch: function () {
@ -172,11 +172,11 @@ define([
initSettings: function (pageId) { initSettings: function (pageId) {
var me = this; var me = this;
_metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric()); _metricText = Common.Utils.Metric.getMetricName(Common.Utils.Metric.getCurrentMetric());
if (_chartObject) { if (me._chartObject) {
if (pageId == '#edit-chart-wrap') { if (pageId == '#edit-chart-wrap') {
me._initWrapView(); me._initWrapView();
} else if (pageId == '#edit-chart-style') { } 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(); me._initStyleView();
} else if (pageId == '#edit-chart-border-color-view') { } else if (pageId == '#edit-chart-border-color-view') {
me._initStyleView(); me._initStyleView();
@ -187,7 +187,7 @@ define([
_initWrapView: function() { _initWrapView: function() {
// Wrap type // Wrap type
var me = this, var me = this,
wrapping = _chartObject.get_WrappingStyle(), wrapping = me._chartObject.get_WrappingStyle(),
$chartWrapInput = $('.chart-wrap input'), $chartWrapInput = $('.chart-wrap input'),
chartWrapType = wrapTypesTransform.sdkToUi(wrapping); chartWrapType = wrapTypesTransform.sdkToUi(wrapping);
@ -195,7 +195,7 @@ define([
me._uiTransformByWrap(chartWrapType); me._uiTransformByWrap(chartWrapType);
// Wrap align // 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=left]').toggleClass('active', chartHAlign == Asc.c_oAscAlignH.Left);
$('.chart-wrap .align a[data-type=center]').toggleClass('active', chartHAlign == Asc.c_oAscAlignH.Center); $('.chart-wrap .align a[data-type=center]').toggleClass('active', chartHAlign == Asc.c_oAscAlignH.Center);
@ -203,11 +203,11 @@ define([
// Wrap flags // Wrap flags
$('#edit-chart-movetext input').prop('checked', _chartObject.get_PositionV().get_RelativeFrom() == Asc.c_oAscRelativeFromV.Paragraph); $('#edit-chart-movetext input').prop('checked', me._chartObject.get_PositionV().get_RelativeFrom() == Asc.c_oAscRelativeFromV.Paragraph);
$('#edit-chart-overlap input').prop('checked', _chartObject.get_AllowOverlap()); $('#edit-chart-overlap input').prop('checked', me._chartObject.get_AllowOverlap());
// Wrap distance // Wrap distance
var paddings = _chartObject.get_Paddings(); var paddings = me._chartObject.get_Paddings();
if (paddings) { if (paddings) {
var distance = Common.Utils.Metric.fnRecalcFromMM(paddings.get_Top()); var distance = Common.Utils.Metric.fnRecalcFromMM(paddings.get_Top());
$('.chart-wrap .distance input').val(distance); $('.chart-wrap .distance input').val(distance);
@ -217,7 +217,7 @@ define([
_initStyleView: function (updateStyles) { _initStyleView: function (updateStyles) {
var me = this, var me = this,
chartProperties = _chartObject.get_ChartProperties(), chartProperties = me._chartObject.get_ChartProperties(),
shapeProperties = _shapeObject.get_ShapeProperties(), shapeProperties = _shapeObject.get_ShapeProperties(),
paletteFillColor = me.getView('EditChart').paletteFillColor, paletteFillColor = me.getView('EditChart').paletteFillColor,
paletteBorderColor = me.getView('EditChart').paletteBorderColor; paletteBorderColor = me.getView('EditChart').paletteBorderColor;
@ -295,29 +295,12 @@ define([
// Public // Public
getChart: function () { getChart: function () {
return _chartObject; return this._chartObject;
}, },
// Handlers // Handlers
onType: function (e) { 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) { onStyle: function (e) {
@ -326,7 +309,7 @@ define([
type = $target.data('type'); type = $target.data('type');
var image = new Asc.asc_CImgProperty(), var image = new Asc.asc_CImgProperty(),
chart = _chartObject.get_ChartProperties(); chart = me._chartObject.get_ChartProperties();
chart.putStyle(type); chart.putStyle(type);
image.put_ChartProperties(chart); image.put_ChartProperties(chart);
@ -560,23 +543,13 @@ define([
} }
}; };
_chartObject = getTopObject(charts); this._chartObject = getTopObject(charts);
_shapeObject = getTopObject(shapes); _shapeObject = getTopObject(shapes);
}, },
onApiUpdateChartStyles: function () {
if (this.api && _chartObject && _chartObject.get_ChartProperties()) {
this._updateChartStyles(this.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType()));
}
},
// Helpers // Helpers
_updateChartStyles: function(styles) { _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) { _uiTransformByWrap: function(type) {

View file

@ -51,12 +51,8 @@ define([
DE.Controllers.EditParagraph = Backbone.Controller.extend(_.extend((function() { DE.Controllers.EditParagraph = Backbone.Controller.extend(_.extend((function() {
// Private // Private
var _stack = [], var _paragraphInfo = {},
_paragraphInfo = {},
_paragraphObject = undefined,
_paragraphProperty = undefined, _paragraphProperty = undefined,
_styles = [],
_styleThumbSize,
_styleName, _styleName,
metricText = Common.Utils.Metric.getCurrentMetricName(); metricText = Common.Utils.Metric.getCurrentMetricName();
@ -77,17 +73,15 @@ define([
'style:click' : this.onStyleClick 'style:click' : this.onStyleClick
} }
}); });
this._styles = [];
this._styleThumbSize = undefined;
this._paragraphObject = undefined;
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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 () { onLaunch: function () {
@ -148,23 +142,23 @@ define([
$('#paragraph-spin-first-line .item-after label').text(firstLineFix + ' ' + metricText); $('#paragraph-spin-first-line .item-after label').text(firstLineFix + ' ' + metricText);
} }
if (_paragraphObject) { if (me._paragraphObject) {
_paragraphInfo.spaceBefore = _paragraphObject.get_Spacing().get_Before() < 0 ? _paragraphObject.get_Spacing().get_Before() : Common.Utils.Metric.fnRecalcFromMM(_paragraphObject.get_Spacing().get_Before()); _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 = _paragraphObject.get_Spacing().get_After() < 0 ? _paragraphObject.get_Spacing().get_After() : Common.Utils.Metric.fnRecalcFromMM(_paragraphObject.get_Spacing().get_After()); _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 distanceBeforeFix = parseFloat(_paragraphInfo.spaceBefore.toFixed(2));
var distanceAfterFix = parseFloat(_paragraphInfo.spaceAfter.toFixed(2)); var distanceAfterFix = parseFloat(_paragraphInfo.spaceAfter.toFixed(2));
$('#paragraph-distance-before .item-after label').text(_paragraphInfo.spaceBefore < 0 ? 'Auto' : distanceBeforeFix + ' ' + metricText); $('#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-distance-after .item-after label').text(_paragraphInfo.spaceAfter < 0 ? 'Auto' : distanceAfterFix + ' ' + metricText);
$('#paragraph-space input:checkbox').prop('checked', _paragraphObject.get_ContextualSpacing()); $('#paragraph-space input:checkbox').prop('checked', me._paragraphObject.get_ContextualSpacing());
$('#paragraph-page-break input:checkbox').prop('checked', _paragraphObject.get_PageBreakBefore()); $('#paragraph-page-break input:checkbox').prop('checked', me._paragraphObject.get_PageBreakBefore());
$('#paragraph-page-orphan input:checkbox').prop('checked', _paragraphObject.get_WidowControl()); $('#paragraph-page-orphan input:checkbox').prop('checked', me._paragraphObject.get_WidowControl());
$('#paragraph-page-keeptogether input:checkbox').prop('checked', _paragraphObject.get_KeepLines()); $('#paragraph-page-keeptogether input:checkbox').prop('checked', me._paragraphObject.get_KeepLines());
$('#paragraph-page-keepnext input:checkbox').prop('checked', _paragraphObject.get_KeepNext()); $('#paragraph-page-keepnext input:checkbox').prop('checked', me._paragraphObject.get_KeepNext());
// Background color // Background color
var shade = _paragraphObject.get_Shade(), var shade = me._paragraphObject.get_Shade(),
backColor = 'transparent'; backColor = 'transparent';
if (!_.isNull(shade) && !_.isUndefined(shade) && shade.get_Value()===Asc.c_oAscShdClear) { if (!_.isNull(shade) && !_.isUndefined(shade) && shade.get_Value()===Asc.c_oAscShdClear) {
@ -203,11 +197,11 @@ define([
// Public // Public
getStyles: function () { getStyles: function () {
return _styles || []; return this._styles || [];
}, },
getThumbSize: function () { getThumbSize: function () {
return _styleThumbSize || {width: 0, height: 0}; return this._styleThumbSize || {width: 0, height: 0};
}, },
// Handlers // Handlers
@ -369,48 +363,6 @@ define([
// API handlers // 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) { onApiParagraphStyleChange: function(name) {
_styleName = name; _styleName = name;
$('#paragraph-list input[name=paragraph-style]').val([_styleName]); $('#paragraph-list input[name=paragraph-style]').val([_styleName]);

View file

@ -301,29 +301,9 @@ define([
}, },
onReorder: function (e) { 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) { onReplace: function (e) {
var $target = $(e.currentTarget),
type = $target.data('type');
this.api.ChangeShapeType(type);
}, },
onWrapType: function (e) { onWrapType: function (e) {

View file

@ -123,9 +123,6 @@ define([
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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 () { onLaunch: function () {
@ -134,15 +131,6 @@ define([
initEvents: function () { initEvents: function () {
var me = this; 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(); 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 // Helpers
_closeIfNeed: function () { _closeIfNeed: function () {

View file

@ -51,26 +51,10 @@ define([
'use strict'; 'use strict';
DE.Controllers.EditText = Backbone.Controller.extend(_.extend((function() { DE.Controllers.EditText = Backbone.Controller.extend(_.extend((function() {
var _fontsArray = [], var _stack = [],
_stack = [],
_paragraphObject = undefined, _paragraphObject = undefined,
_fontInfo = {}; _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 { return {
models: [], models: [],
collections: [], collections: [],
@ -87,26 +71,13 @@ define([
'font:click': this.onFontClick 'font:click': this.onFontClick
} }
}); });
this._fontsArray = [];
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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 () { onLaunch: function () {
@ -169,7 +140,7 @@ define([
// Public // Public
getFonts: function() { getFonts: function() {
return _fontsArray; return this._fontsArray;
}, },
getStack: function() { getStack: function() {

View file

@ -61,7 +61,8 @@ require.config({
gateway : 'common/Gateway', gateway : 'common/Gateway',
locale : 'common/locale', locale : 'common/locale',
irregularstack : 'common/IrregularStack', irregularstack : 'common/IrregularStack',
sharedsettings : 'common/mobile/utils/SharedSettings' sharedsettings : 'common/mobile/utils/SharedSettings',
features : '../../web-apps-mobile/slide/patch'
}, },
shim: { shim: {
@ -221,7 +222,8 @@ require([
], function() { ], function() {
window.compareVersions = true; window.compareVersions = true;
app.start(); var _s = app.start.bind(app);
require(['features'], _s, _s);
}); });
}); });
}, function(err) { }, function(err) {

View file

@ -575,6 +575,22 @@ define([
applyLicense: function() { applyLicense: function() {
var me = this; 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 > 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) { if (this._state.licenseType) {
var license = this._state.licenseType, var license = this._state.licenseType,
buttons = [{text: 'OK'}]; buttons = [{text: 'OK'}];
@ -669,7 +685,8 @@ define([
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canEdit = (me.permissions.edit !== false || me.permissions.review === true) && // can edit or review 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.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.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.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; me.appOptions.canUseHistory = me.appOptions.canLicense && !me.appOptions.isLightVersion && me.editorConfig.canUseHistory && me.appOptions.canCoAuthoring && !me.appOptions.isDesktopApp;
@ -1097,7 +1114,6 @@ define([
}, },
onSendThemeColors: function(colors, standart_colors) { onSendThemeColors: function(colors, standart_colors) {
Common.Utils.ThemeColor.setColors(colors, standart_colors);
}, },
onFocusObject: function(SelectedObjects) { onFocusObject: function(SelectedObjects) {
@ -1249,6 +1265,10 @@ define([
} }
}, },
isSupportEditFeature: function() {
return false;
},
// Translation // 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.', 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', criticalErrorTitle: 'Error',
@ -1412,7 +1432,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.', 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...', waitText: 'Please, wait...',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.', 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.'
} }
})(), PE.Controllers.Main || {})) })(), PE.Controllers.Main || {}))
}); });

View file

@ -95,10 +95,6 @@ define([
onInsertByFile: function (e) { onInsertByFile: function (e) {
PE.getController('AddContainer').hideModal(); PE.getController('AddContainer').hideModal();
if (this.api) {
this.api.asc_addImage();
}
}, },
onUrlChange: function (e) { onUrlChange: function (e) {
@ -115,9 +111,6 @@ define([
if (!_.isEmpty(value)) { if (!_.isEmpty(value)) {
if ((/((^https?)|(^ftp)):\/\/.+/i.test(value))) { if ((/((^https?)|(^ftp)):\/\/.+/i.test(value))) {
PE.getController('AddContainer').hideModal(); PE.getController('AddContainer').hideModal();
_.defer(function () {
me.api.AddImageUrl(value);
});
} else { } else {
uiApp.alert(me.txtNotUrl); uiApp.alert(me.txtNotUrl);
} }

View file

@ -57,9 +57,6 @@ define([
First: 3, First: 3,
Num: 4 Num: 4
}, },
_linkType = c_oHyperlinkType.WebLink,
_slideLink = 0,
_slideNum = 0,
_slidesCount = 0; _slidesCount = 0;
return { return {
@ -83,6 +80,10 @@ define([
uiApp.onPageBack('addlink-type addlink-slidenumber', function (page) { uiApp.onPageBack('addlink-type addlink-slidenumber', function (page) {
me.initSettings(); me.initSettings();
}); });
this._linkType = c_oHyperlinkType.WebLink;
this._slideLink = 0;
this._slideNum = 0;
}, },
setApi: function (api) { setApi: function (api) {
@ -103,8 +104,8 @@ define([
var $target = $(e.currentTarget); var $target = $(e.currentTarget);
if ($target && $target.prop('id') === 'add-link') { if ($target && $target.prop('id') === 'add-link') {
_linkType = c_oHyperlinkType.WebLink; this._linkType = c_oHyperlinkType.WebLink;
_slideLink = _slideNum = 0; this._slideLink = this._slideNum = 0;
var text = this.api.can_AddHyperlink(); var text = this.api.can_AddHyperlink();
if (text !== false) { if (text !== false) {
$('#add-link-display input').val((text !== null) ? text : this.textDefault); $('#add-link-display input').val((text !== null) ? text : this.textDefault);
@ -119,17 +120,17 @@ define([
var me = this; var me = this;
if (pageId == '#addlink-type') { if (pageId == '#addlink-type') {
$('#page-addlink-type input').val([_linkType]); $('#page-addlink-type input').val([this._linkType]);
} else if (pageId == '#addlink-slidenumber') { } else if (pageId == '#addlink-slidenumber') {
_slidesCount = me.api.getCountPages(); _slidesCount = me.api.getCountPages();
$('#page-addlink-slidenumber input').val([_slideLink]); $('#page-addlink-slidenumber input').val([this._slideLink]);
$('#addlink-slide-number .item-after label').text(_slideNum+1); $('#addlink-slide-number .item-after label').text(this._slideNum+1);
} else { } else {
$('#add-link-type .item-after').text((_linkType==c_oHyperlinkType.WebLink) ? me.textExternalLink : me.textInternalLink); $('#add-link-type .item-after').text((this._linkType==c_oHyperlinkType.WebLink) ? me.textExternalLink : me.textInternalLink);
$('#add-link-url')[(_linkType==c_oHyperlinkType.WebLink) ? 'show' : 'hide'](); $('#add-link-url')[(this._linkType==c_oHyperlinkType.WebLink) ? 'show' : 'hide']();
$('#add-link-number')[(_linkType==c_oHyperlinkType.WebLink) ? 'hide' : 'show'](); $('#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-url input[type=url]').single('input', _.bind(function(e) {
$('#add-link-insert').toggleClass('disabled', _.isEmpty($('#add-link-url input').val())); $('#add-link-insert').toggleClass('disabled', _.isEmpty($('#add-link-url input').val()));
}, this)); }, this));
@ -138,7 +139,7 @@ define([
}, 1000); }, 1000);
} else { } else {
var slidename = ''; var slidename = '';
switch (_slideLink) { switch (this._slideLink) {
case 0: case 0:
slidename = me.textNext; slidename = me.textNext;
break; break;
@ -152,13 +153,13 @@ define([
slidename = me.textLast; slidename = me.textLast;
break; break;
case 4: case 4:
slidename = me.textSlide + ' ' + (_slideNum+1); slidename = me.textSlide + ' ' + (this._slideNum+1);
break; break;
} }
$('#add-link-number .item-after').text(slidename); $('#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 // Handlers
onInsertLink: function (e) { 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(); PE.getController('AddContainer').hideModal();
}, },
@ -241,7 +182,7 @@ define([
var $target = $(e.currentTarget).find('input'); var $target = $(e.currentTarget).find('input');
if ($target && this.api) { 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'); var $target = $(e.currentTarget).find('input');
if ($target && this.api) { if ($target && this.api) {
_slideLink = parseFloat($target.prop('value')); this._slideLink = parseFloat($target.prop('value'));
} }
}, },
onSlideNumber: function (e) { onSlideNumber: function (e) {
var $button = $(e.currentTarget), var $button = $(e.currentTarget),
slide = _slideNum; slide = this._slideNum;
if ($button.hasClass('decrement')) { if ($button.hasClass('decrement')) {
slide = Math.max(0, --slide); slide = Math.max(0, --slide);
} else { } else {
slide = Math.min(_slidesCount-1, ++slide); slide = Math.min(_slidesCount-1, ++slide);
} }
_slideNum = slide; this._slideNum = slide;
$('#addlink-slide-number .item-after label').text(slide+1); $('#addlink-slide-number .item-after label').text(slide+1);
}, },

View file

@ -212,13 +212,6 @@ define([
}, },
onShapeClick: function (e) { onShapeClick: function (e) {
var me = this,
$target = $(e.currentTarget);
if ($target && me.api) {
me.api.AddShapeOnCurrentPage($target.data('type'));
}
PE.getController('AddContainer').hideModal(); PE.getController('AddContainer').hideModal();
}, },

View file

@ -48,8 +48,6 @@ define([
'use strict'; 'use strict';
PE.Controllers.AddSlide = Backbone.Controller.extend(_.extend((function() { PE.Controllers.AddSlide = Backbone.Controller.extend(_.extend((function() {
var _layouts = [];
return { return {
models: [], models: [],
collections: [], collections: [],
@ -59,12 +57,12 @@ define([
initialize: function () { initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this)); Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
this._layouts = [];
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; me.api = api;
me.api.asc_registerCallback('asc_onUpdateLayout', _.bind(me.onUpdateLayout, me));
}, },
onLaunch: function () { onLaunch: function () {
@ -73,49 +71,18 @@ define([
initEvents: function () { initEvents: function () {
var me = this; 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)); $('#add-slide .slide-layout li').single('click', _.buffered(me.onLayoutClick, 100, me));
}, },
onLayoutClick: function (e) { onLayoutClick: function (e) {
var me = this,
$target = $(e.currentTarget),
type = $target.data('type');
me.api.AddSlide(type);
PE.getController('AddContainer').hideModal(); PE.getController('AddContainer').hideModal();
}, },
// Public // Public
getLayouts: function () { getLayouts: function () {
return _layouts; return this._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));
} }
} }
})(), PE.Controllers.AddSlide || {})) })(), PE.Controllers.AddSlide || {}))

View file

@ -48,8 +48,7 @@ define([
'use strict'; 'use strict';
PE.Controllers.AddTable = Backbone.Controller.extend(_.extend((function() { PE.Controllers.AddTable = Backbone.Controller.extend(_.extend((function() {
var _styles = [], var _initDefaultStyles = false;
_initDefaultStyles = false;
return { return {
models: [], models: [],
@ -60,13 +59,12 @@ define([
initialize: function () { initialize: function () {
Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this)); Common.NotificationCenter.on('addcontainer:show', _.bind(this.initEvents, this));
this._styles = [];
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; me.api = api;
me.api.asc_registerCallback('asc_onInitTableTemplates', _.bind(me.onApiInitTemplates, me));
}, },
onLaunch: function () { onLaunch: function () {
@ -78,7 +76,7 @@ define([
if (!_initDefaultStyles) { if (!_initDefaultStyles) {
_initDefaultStyles = true; _initDefaultStyles = true;
_styles = []; me._styles = [];
me.api.asc_GetDefaultTableStyles && me.api.asc_GetDefaultTableStyles(); me.api.asc_GetDefaultTableStyles && me.api.asc_GetDefaultTableStyles();
} }
@ -159,27 +157,11 @@ define([
// Public // Public
getStyles: function () { getStyles: function () {
return _styles; return this._styles;
}, },
// API handlers // 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', textTableSize: 'Table Size',
textColumns: 'Columns', textColumns: 'Columns',
textRows: 'Rows', textRows: 'Rows',

View file

@ -52,7 +52,6 @@ define([
PE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() { PE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() {
// Private // Private
var _stack = [], var _stack = [],
_chartObject = undefined,
_shapeObject = undefined, _shapeObject = undefined,
_metricText = Common.Utils.Metric.getCurrentMetricName(), _metricText = Common.Utils.Metric.getCurrentMetricName(),
_borderColor = 'transparent'; _borderColor = 'transparent';
@ -99,6 +98,7 @@ define([
'page:show': this.onPageShow 'page:show': this.onPageShow
} }
}); });
this._chartObject = undefined;
}, },
setApi: function (api) { setApi: function (api) {
@ -106,7 +106,6 @@ define([
me.api = api; me.api = api;
me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me));
me.api.asc_registerCallback('asc_onUpdateChartStyles', _.bind(me.onApiUpdateChartStyles, me));
}, },
onLaunch: function () { onLaunch: function () {
@ -139,9 +138,9 @@ define([
initSettings: function (pageId) { initSettings: function (pageId) {
var me = this; var me = this;
if (_chartObject) { if (me._chartObject) {
if (pageId == '#edit-chart-style') { if (pageId == '#edit-chart-style') {
me._updateChartStyles(me.api.asc_getChartPreviews(_chartObject.getType())); me._updateChartStyles(me.api.asc_getChartPreviews(me._chartObject.getType()));
me._initStyleView(); me._initStyleView();
} else if (pageId == '#edit-chart-border-color-view') { } else if (pageId == '#edit-chart-border-color-view') {
me._initStyleView(); me._initStyleView();
@ -151,7 +150,7 @@ define([
_initStyleView: function (updateStyles) { _initStyleView: function (updateStyles) {
var me = this, var me = this,
chartProperties = _chartObject, chartProperties = me._chartObject,
shapeProperties = _shapeObject, shapeProperties = _shapeObject,
paletteFillColor = me.getView('EditChart').paletteFillColor, paletteFillColor = me.getView('EditChart').paletteFillColor,
paletteBorderColor = me.getView('EditChart').paletteBorderColor; paletteBorderColor = me.getView('EditChart').paletteBorderColor;
@ -228,25 +227,12 @@ define([
// Public // Public
getChart: function () { getChart: function () {
return _chartObject; return this._chartObject;
}, },
// Handlers // Handlers
onType: function (e) { 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) { onStyle: function (e) {
@ -405,23 +391,13 @@ define([
} }
}; };
_chartObject = getTopObject(charts); this._chartObject = getTopObject(charts);
_shapeObject = getTopObject(shapes); _shapeObject = getTopObject(shapes);
}, },
onApiUpdateChartStyles: function () {
if (this.api && _chartObject) {
this._updateChartStyles(this.api.asc_getChartPreviews(_chartObject.getType()));
}
},
// Helpers // Helpers
_updateChartStyles: function(styles) { _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 () { _closeIfNeed: function () {

View file

@ -234,18 +234,6 @@ define([
}, },
onReorder: function (e) { 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) { onAlign: function (e) {
@ -272,10 +260,6 @@ define([
}, },
onReplace: function (e) { onReplace: function (e) {
var $target = $(e.currentTarget),
type = $target.data('type');
this.api.ChangeShapeType(type);
}, },
onBorderSize: function (e) { onBorderSize: function (e) {

View file

@ -53,7 +53,6 @@ define([
// Private // Private
var _stack = [], var _stack = [],
_slideObject = undefined, _slideObject = undefined,
_themes = [],
_themeId = -1, _themeId = -1,
_effect = Asc.c_oAscSlideTransitionTypes.None, _effect = Asc.c_oAscSlideTransitionTypes.None,
_effectType = -1, _effectType = -1,
@ -81,6 +80,7 @@ define([
uiApp.onPageBack('editslide-effect-type editslide-effect', function (page) { uiApp.onPageBack('editslide-effect-type editslide-effect', function (page) {
me.initSettings('#edit-slide-transition'); me.initSettings('#edit-slide-transition');
}); });
this._themes = [];
}, },
setApi: function (api) { setApi: function (api) {
@ -88,7 +88,6 @@ define([
me.api = api; me.api = api;
me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onApiFocusObject, me)); 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)); me.api.asc_registerCallback('asc_onUpdateThemeIndex', _.bind(me.onApiUpdateThemeIndex, me));
}, },
@ -210,28 +209,15 @@ define([
}, },
getThemes: function () { getThemes: function () {
return _themes || []; return this._themes || [];
}, },
// Handlers // Handlers
onLayoutClick: function (e) { onLayoutClick: function (e) {
var me = this,
$target = $(e.currentTarget),
type = $target.data('type');
me.api.ChangeLayout(type);
}, },
onThemeClick: function (e) { 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 () { 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) { onApiUpdateThemeIndex: function(themeId) {
_themeId = themeId; _themeId = themeId;
$('.container-edit .slide-theme .row div').removeClass('active'); $('.container-edit .slide-theme .row div').removeClass('active');

View file

@ -112,9 +112,6 @@ define([
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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 () { onLaunch: function () {
@ -124,13 +121,6 @@ define([
initEvents: function () { initEvents: function () {
var me = this; 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('change touchend', _.buffered(me.onOptionMargin, 100, me));
$('#table-options-margins input').single('input', _.bind(me.onOptionMarginChanging, me)); $('#table-options-margins input').single('input', _.bind(me.onOptionMarginChanging, me));
@ -548,19 +538,6 @@ define([
}); });
return tableExist; 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 || {})) })(), PE.Controllers.EditTable || {}))

View file

@ -51,28 +51,12 @@ define([
'use strict'; 'use strict';
PE.Controllers.EditText = Backbone.Controller.extend(_.extend((function() { PE.Controllers.EditText = Backbone.Controller.extend(_.extend((function() {
var _fontsArray = [], var _stack = [],
_stack = [],
_paragraphObject = undefined, _paragraphObject = undefined,
_fontInfo = {}, _fontInfo = {},
_paragraphInfo = {}, _paragraphInfo = {},
metricText = Common.Utils.Metric.getCurrentMetricName(); 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 { return {
models: [], models: [],
collections: [], collections: [],
@ -90,35 +74,12 @@ define([
'font:click': this.onFontClick 'font:click': this.onFontClick
} }
}); });
this._fontsArray = [];
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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 () { onLaunch: function () {
@ -199,7 +160,7 @@ define([
// Public // Public
getFonts: function() { getFonts: function() {
return _fontsArray; return this._fontsArray;
}, },
getStack: function() { getStack: function() {

View file

@ -61,7 +61,8 @@ require.config({
gateway : 'common/Gateway', gateway : 'common/Gateway',
locale : 'common/locale', locale : 'common/locale',
irregularstack : 'common/IrregularStack', irregularstack : 'common/IrregularStack',
sharedsettings : 'common/mobile/utils/SharedSettings' sharedsettings : 'common/mobile/utils/SharedSettings',
features : '../../web-apps-mobile/cell/patch'
}, },
shim: { shim: {
@ -210,7 +211,8 @@ require([
,'common/mobile/lib/controller/Collaboration' ,'common/mobile/lib/controller/Collaboration'
], function() { ], function() {
window.compareVersions = true; window.compareVersions = true;
app.start(); var _s = app.start.bind(app);
require(['features'], _s, _s);
}); });
}); });
}, function(err) { }, function(err) {

View file

@ -606,6 +606,21 @@ define([
applyLicense: function() { applyLicense: function() {
var me = this; 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) { if (this._state.licenseType) {
var license = this._state.licenseType, var license = this._state.licenseType,
buttons = [{text: 'OK'}]; buttons = [{text: 'OK'}];
@ -712,8 +727,9 @@ define([
me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights; me.appOptions.canRequestEditRights = me.editorConfig.canRequestEditRights;
me.appOptions.canEdit = me.permissions.edit !== false && // can edit me.appOptions.canEdit = me.permissions.edit !== false && // can edit
(me.editorConfig.canRequestEditRights || me.editorConfig.mode !== 'view'); // if mode=="view" -> canRequestEditRights must be defined (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.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.canDownload = (me.permissions.download !== false);
me.appOptions.canPrint = (me.permissions.print !== false); me.appOptions.canPrint = (me.permissions.print !== false);
@ -1247,7 +1263,6 @@ define([
}, },
onSendThemeColors: function(colors, standart_colors) { onSendThemeColors: function(colors, standart_colors) {
Common.Utils.ThemeColor.setColors(colors, standart_colors);
}, },
onAdvancedOptions: function(type, advOptions, mode, formatOptions) { 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.', 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', criticalErrorTitle: 'Error',
notcriticalErrorTitle: 'Warning', notcriticalErrorTitle: 'Warning',
@ -1642,7 +1661,8 @@ define([
errorFrmlMaxTextLength: 'Text values in formulas are limited to 255 characters.<br>Use the CONCATENATE function or concatenation operator (&)', errorFrmlMaxTextLength: 'Text values in formulas are limited to 255 characters.<br>Use the CONCATENATE function or concatenation operator (&)',
waitText: 'Please, wait...', waitText: 'Please, wait...',
errorFileSizeExceed: 'The file size exceeds the limitation set for your server.<br>Please contact your Document Server administrator for details.', 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.'
} }
})(), SSE.Controllers.Main || {})) })(), SSE.Controllers.Main || {}))
}); });

View file

@ -78,10 +78,6 @@ define([
onInsertChart: function (type) { onInsertChart: function (type) {
SSE.getController('AddContainer').hideModal(); SSE.getController('AddContainer').hideModal();
var settings = this.api.asc_getChartObject();
settings.changeType(type);
this.api.asc_addChartDrawingObject(settings);
}, },
txtDiagramTitle: 'Chart Title', txtDiagramTitle: 'Chart Title',

View file

@ -69,6 +69,7 @@ define([
'function:info': me.onFunctionInfo.bind(me) 'function:info': me.onFunctionInfo.bind(me)
} }
}); });
this.fd = fd;
}, },
setApi: function (api) { setApi: function (api) {
@ -111,40 +112,7 @@ define([
editorLang = (editorLang ? editorLang : 'en').split(/[\-\_]/)[0].toLowerCase(); editorLang = (editorLang ? editorLang : 'en').split(/[\-\_]/)[0].toLowerCase();
var localizationFunctionsDesc = function (data) { 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();
};
$.getJSON(Common.Utils.String.format("{0}/{1}_desc.json", "resources/l10n/functions", editorLang), function(json) { $.getJSON(Common.Utils.String.format("{0}/{1}_desc.json", "resources/l10n/functions", editorLang), function(json) {
localizationFunctionsDesc(json); localizationFunctionsDesc(json);
@ -155,8 +123,6 @@ define([
onInsertFunction: function (type) { onInsertFunction: function (type) {
SSE.getController('AddContainer').hideModal(); SSE.getController('AddContainer').hideModal();
this.api.asc_insertFormula(this.api.asc_getFormulaLocaleName(type), Asc.c_oAscPopUpSelectorType.Func, true);
}, },
onFunctionInfo: function (type) { onFunctionInfo: function (type) {

View file

@ -49,54 +49,6 @@ define([
var cfgLink; var cfgLink;
// Handlers // 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) { function onChangePanel (view, pageId) {
var me = this; var me = this;
@ -142,7 +94,7 @@ define([
this.addListeners({ this.addListeners({
'AddLink': { 'AddLink': {
'panel:change' : onChangePanel.bind(this) 'panel:change' : onChangePanel.bind(this)
, 'link:insert': onInsertLink.bind(this) , 'link:insert': this.onInsertLink.bind(this)
, 'link:changetype': onChangeLinkType.bind(this) , 'link:changetype': onChangeLinkType.bind(this)
, 'link:changesheet': onChangeLinkSheet.bind(this) , 'link:changesheet': onChangeLinkSheet.bind(this)
} }
@ -218,6 +170,10 @@ define([
view.fireEvent('page:show', [this, '#addlink']); view.fireEvent('page:show', [this, '#addlink']);
}, },
onInsertLink: function(args){
SSE.getController('AddContainer').hideModal();
},
textInvalidRange : 'ERROR! Invalid cells range', textInvalidRange : 'ERROR! Invalid cells range',
txtNotUrl : 'This field should be a URL in the format \"http://www.example.com\"' txtNotUrl : 'This field should be a URL in the format \"http://www.example.com\"'
} }

View file

@ -112,10 +112,6 @@ define([
if (!_.isEmpty(url)) { if (!_.isEmpty(url)) {
if ((/((^https?)|(^ftp)):\/\/.+/i.test(url))) { if ((/((^https?)|(^ftp)):\/\/.+/i.test(url))) {
SSE.getController('AddContainer').hideModal(); SSE.getController('AddContainer').hideModal();
_.defer(function () {
me.api.asc_addImageDrawingObject(url);
});
} else { } else {
uiApp.alert(me.txtNotUrl); uiApp.alert(me.txtNotUrl);
} }
@ -124,7 +120,6 @@ define([
} }
} else { } else {
SSE.getController('AddContainer').hideModal(); SSE.getController('AddContainer').hideModal();
this.api.asc_addImage();
} }
}, },
@ -133,11 +128,6 @@ define([
}, },
onInsertFilter: function(checked) { 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) { onError: function(id, level, errData) {

View file

@ -211,12 +211,6 @@ define([
}, },
onShapeClick: function (e) { onShapeClick: function (e) {
var $target = $(e.currentTarget);
if ($target && this.api) {
this.api.asc_addShapeOnSheet($target.data('type'));
}
SSE.getController('AddContainer').hideModal(); SSE.getController('AddContainer').hideModal();
}, },

View file

@ -51,29 +51,8 @@ define([
'use strict'; 'use strict';
SSE.Controllers.EditCell = Backbone.Controller.extend(_.extend((function() { SSE.Controllers.EditCell = Backbone.Controller.extend(_.extend((function() {
var _fontsArray = [], var _stack = [],
_stack = [], _borderInfo = {color: '000000', width: Asc.c_oAscBorderStyles.Medium};
_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);
}
return { return {
models: [], models: [],
@ -92,22 +71,26 @@ define([
'style:click' : this.onStyleClick '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) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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_onSelectionChanged', _.bind(me.onApiSelectionChanged, me));
me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me)); me.api.asc_registerCallback('asc_onEditorSelectionChanged', _.bind(me.onApiEditorSelectionChanged, me));
me.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(me.onApiInitEditorStyles, me));
}, },
setMode: function (mode) { setMode: function (mode) {
_isEdit = mode.isEdit; this._isEdit = mode.isEdit;
}, },
onLaunch: function () { onLaunch: function () {
@ -125,13 +108,11 @@ define([
$('#font-italic').single('click', _.bind(me.onItalic, me)); $('#font-italic').single('click', _.bind(me.onItalic, me));
$('#font-underline').single('click', _.bind(me.onUnderline, me)); $('#font-underline').single('click', _.bind(me.onUnderline, me));
me.getView('EditCell').renderStyles(_cellStyles); me.getView('EditCell').renderStyles(me._cellStyles);
me.initSettings(); me.initSettings();
}, },
onPageShow: function (view, pageId) { onPageShow: function (view, pageId) {
var me = this; var me = this;
@ -156,14 +137,14 @@ define([
} else if (!_.isUndefined(pageId) && pageId.indexOf('#edit-cell-format') > -1) { } else if (!_.isUndefined(pageId) && pageId.indexOf('#edit-cell-format') > -1) {
me.initCellFormat(); me.initCellFormat();
} else { } else {
me.initCellSettings(_cellInfo); me.initCellSettings(me._cellInfo);
} }
}, },
// Public // Public
getFonts: function() { getFonts: function() {
return _fontsArray; return this._fontsArray;
}, },
getStack: function() { getStack: function() {
@ -171,20 +152,20 @@ define([
}, },
getFontInfo: function () { getFontInfo: function () {
return _fontInfo; return this._fontInfo;
}, },
getCell: function () { getCell: function () {
return _cellInfo; return this._cellInfo;
}, },
getStyleSize: function () { getStyleSize: function () {
return _styleSize; return this._styleSize;
}, },
initFontsPage: function () { initFontsPage: function () {
var me = this, var me = this,
displaySize = _fontInfo.size; displaySize = this._fontInfo.size;
_.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt; _.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt;
@ -195,7 +176,7 @@ define([
initTextColorPage: function () { initTextColorPage: function () {
var me = this, var me = this,
palette = me.getView('EditCell').paletteTextColor, palette = me.getView('EditCell').paletteTextColor,
color = me._sdkToThemeColor(_fontInfo.color); color = me._sdkToThemeColor(this._fontInfo.color);
if (palette) { if (palette) {
palette.select(color); palette.select(color);
@ -204,9 +185,11 @@ define([
}, },
initFillColorPage: function () { initFillColorPage: function () {
if (_.isUndefined(this._cellInfo)) return;
var me = this, var me = this,
palette = me.getView('EditCell').paletteFillColor, palette = me.getView('EditCell').paletteFillColor,
color = me._sdkToThemeColor(_cellInfo.asc_getFill().asc_getColor()); color = me._sdkToThemeColor(me._cellInfo.asc_getFill().asc_getColor());
if (palette) { if (palette) {
palette.select(color); palette.select(color);
@ -228,13 +211,15 @@ define([
}, },
initTextFormat: function () { initTextFormat: function () {
if (_.isUndefined(this._cellInfo)) return;
var me = this, var me = this,
$pageTextFormat = $('.page[data-page=edit-text-format]'), $pageTextFormat = $('.page[data-page=edit-text-format]'),
hAlign = _cellInfo.asc_getHorAlign(), hAlign = me._cellInfo.asc_getHorAlign(),
vAlign = _cellInfo.asc_getVertAlign(), vAlign = me._cellInfo.asc_getVertAlign(),
hAlignStr = 'left', hAlignStr = 'left',
vAlignStr = 'bottom', vAlignStr = 'bottom',
isWrapText = _cellInfo.asc_getFlags().asc_getWrapText(); isWrapText = me._cellInfo.asc_getFlags().asc_getWrapText();
if (vAlign == Asc.c_oAscVAlign.Top) if (vAlign == Asc.c_oAscVAlign.Top)
vAlignStr = 'top'; vAlignStr = 'top';
@ -294,7 +279,7 @@ define([
// Init font name // Init font name
var fontName = fontObj.asc_getName() || this.textFonts; var fontName = fontObj.asc_getName() || this.textFonts;
_fontInfo.name = fontName; this._fontInfo.name = fontName;
$('#font-fonts .item-title').html(fontName); $('#font-fonts .item-title').html(fontName);
@ -306,8 +291,8 @@ define([
// Init font size // Init font size
_fontInfo.size = fontObj.asc_getSize(); this._fontInfo.size = fontObj.asc_getSize();
var displaySize = _fontInfo.size; var displaySize = this._fontInfo.size;
_.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt; _.isUndefined(displaySize) ? displaySize = this.textAuto : displaySize = displaySize + ' ' + this.textPt;
@ -316,9 +301,9 @@ define([
// Init font color // 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); clr = me._sdkToThemeColor(color);
$('#text-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr)); $('#text-color .color-preview').css('background-color', '#' + (_.isObject(clr) ? clr.color : clr));
@ -356,21 +341,12 @@ define([
me.initTextFormat(); me.initTextFormat();
}, },
onApiInitEditorStyles: function(styles){
window.styles_loaded = false;
_cellStyles = styles;
this.getView('EditCell').renderStyles(styles);
window.styles_loaded = true;
},
// Handlers // Handlers
onFontSize: function (e) { onFontSize: function (e) {
var me = this, var me = this,
$button = $(e.currentTarget), $button = $(e.currentTarget),
fontSize = _fontInfo.size; fontSize = this._fontInfo.size;
if ($button.hasClass('decrement')) { if ($button.hasClass('decrement')) {
_.isUndefined(fontSize) ? me.api.asc_decreaseFontSize() : fontSize = Math.max(1, --fontSize); _.isUndefined(fontSize) ? me.api.asc_decreaseFontSize() : fontSize = Math.max(1, --fontSize);
@ -464,10 +440,6 @@ define([
}, },
onCellFormat: function (e) { onCellFormat: function (e) {
var $target = $(e.currentTarget),
type = decodeURIComponent(atob($target.data('type')));
this.api.asc_setCellFormat(type);
}, },
onBorderStyle: function (e) { onBorderStyle: function (e) {
@ -504,21 +476,9 @@ define([
// API handlers // API handlers
onApiEditorSelectionChanged: function(fontObj) { onApiEditorSelectionChanged: function(fontObj) {
if (!_isEdit) {
return;
}
_fontInfo = fontObj;
this.initFontSettings(fontObj);
}, },
onApiSelectionChanged: function(cellInfo) { onApiSelectionChanged: function(cellInfo) {
if (!_isEdit) {
return;
}
_cellInfo = cellInfo;
this.initCellSettings(cellInfo);
}, },
// Helpers // Helpers

View file

@ -53,11 +53,9 @@ define([
SSE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() { SSE.Controllers.EditChart = Backbone.Controller.extend(_.extend((function() {
var _stack = [], var _stack = [],
_chartObject = undefined,
_shapeObject = undefined, _shapeObject = undefined,
_borderInfo = {color: '000000', width: 1}, _borderInfo = {color: '000000', width: 1},
_metricText = Common.Utils.Metric.getCurrentMetricName(), _metricText = Common.Utils.Metric.getCurrentMetricName();
_isEdit = false;
var borderSizeTransform = (function() { var borderSizeTransform = (function() {
var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6]; var _sizes = [0, 0.5, 1, 1.5, 2.25, 3, 4.5, 6];
@ -101,23 +99,19 @@ define([
'page:show' : this.onPageShow 'page:show' : this.onPageShow
} }
}); });
this._chartObject = undefined;
this._isEdit = false;
}, },
setApi: function (api) { setApi: function (api) {
var me = this; var me = this;
me.api = api; 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_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) { setMode: function (mode) {
_isEdit = mode.isEdit; this._isEdit = mode.isEdit;
}, },
onLaunch: function () { onLaunch: function () {
@ -178,15 +172,17 @@ define([
initRootPage: function () { initRootPage: function () {
$('#chart-remove').single('click', _.bind(this.onRemoveChart, this)); $('#chart-remove').single('click', _.bind(this.onRemoveChart, this));
if (!_.isUndefined(_chartObject)) { if (!_.isUndefined(this._chartObject)) {
this.updateAxisProps(_chartObject.get_ChartProperties().getType()); this.updateAxisProps(this._chartObject.get_ChartProperties().getType());
} }
}, },
initStylePage: function () { initStylePage: function () {
if (_.isUndefined(this._chartObject)) return;
var me = this, var me = this,
color, color,
chartProperties = _chartObject.get_ChartProperties(), chartProperties = me._chartObject.get_ChartProperties(),
shapeProperties = _shapeObject.get_ShapeProperties(); shapeProperties = _shapeObject.get_ShapeProperties();
// Type // Type
@ -199,7 +195,7 @@ define([
// Styles // Styles
_.defer(function () { _.defer(function () {
me._updateChartStyles(me.api.asc_getChartPreviews(_chartObject.get_ChartProperties().getType())); me._updateChartStyles(me.api.asc_getChartPreviews(me._chartObject.get_ChartProperties().getType()));
}); });
// Fill // Fill
@ -247,8 +243,10 @@ define([
}, },
initLayoutPage: function () { initLayoutPage: function () {
if (_.isUndefined(this._chartObject)) return;
var me = this, var me = this,
chartProperties = _chartObject.get_ChartProperties(), chartProperties = me._chartObject.get_ChartProperties(),
chartType = chartProperties.getType(), chartType = chartProperties.getType(),
$layoutPage = $('.page[data-page=edit-chart-layout]'); $layoutPage = $('.page[data-page=edit-chart-layout]');
@ -564,41 +562,9 @@ define([
}, },
onType: function (e) { 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) { 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) { onFillColor:function (palette, color) {
@ -937,32 +903,10 @@ define([
// API handlers // 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) { onApiFocusObject: function (objects) {
_stack = objects; _stack = objects;
if (!_isEdit) { if (!this._isEdit) {
return; return;
} }
@ -989,7 +933,7 @@ define([
} }
}; };
_chartObject = getTopObject(charts); this._chartObject = getTopObject(charts);
_shapeObject = getTopObject(shapes); _shapeObject = getTopObject(shapes);
}, },

View file

@ -241,28 +241,9 @@ define([
}, },
onReorder: function(e) { 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) { onReplace: function (e) {
var $target = $(e.currentTarget),
type = $target.data('type');
this.api.asc_changeShapeType(type);
}, },
onBorderSize: function (e) { onBorderSize: function (e) {

View file

@ -60,6 +60,14 @@ module.exports = function(grunt) {
to: process.env['PLUGIN_LINK_MACROS'] || 'https://api.onlyoffice.com/plugin/macros' 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-clean');
grunt.loadNpmTasks('grunt-contrib-copy'); grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-uglify');
@ -134,6 +142,14 @@ module.exports = function(grunt) {
if (packageFile) { if (packageFile) {
grunt.log.ok(appName + ' config loaded successfully'.green); 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 ) { if ( !!_extConfig && _extConfig.name == packageFile.name ) {
_merge(packageFile, _extConfig); _merge(packageFile, _extConfig);
} }