[DE] Add FeaturesManager component for features customization. Add spellcheck customization.
This commit is contained in:
parent
e1255c470e
commit
922f0bd3a2
|
@ -95,3 +95,50 @@ Common.UI.LayoutManager = new(function() {
|
||||||
isElementVisible: _isElementVisible
|
isElementVisible: _isElementVisible
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* features: {
|
||||||
|
* feature: { //can be object or init value
|
||||||
|
* mode: <init value> // value1 / value2 ...
|
||||||
|
* change: false/true // hide/show feature
|
||||||
|
* } / value1 / value2 ...
|
||||||
|
* }
|
||||||
|
*/
|
||||||
|
Common.UI.FeaturesManager = new(function() {
|
||||||
|
var _config;
|
||||||
|
var _init = function(config) {
|
||||||
|
_config = config;
|
||||||
|
};
|
||||||
|
|
||||||
|
var _canChange = function(name) {
|
||||||
|
return !(_config && typeof _config[name] === 'object' && _config[name] && _config[name].change===false);
|
||||||
|
};
|
||||||
|
|
||||||
|
var _getInitValue2 = function(name, defValue) {
|
||||||
|
if (_config && _config[name] !== undefined ) {
|
||||||
|
if (typeof _config[name] === 'object' && _config[name]) { // object and not null
|
||||||
|
if (_config[name].mode!==undefined)
|
||||||
|
return _config[name].mode;
|
||||||
|
} else
|
||||||
|
return _config[name];
|
||||||
|
}
|
||||||
|
|
||||||
|
return defValue;
|
||||||
|
};
|
||||||
|
|
||||||
|
var _getInitValue = function(name) {
|
||||||
|
if (_config && _config[name] !== undefined ) {
|
||||||
|
if (typeof _config[name] === 'object' && _config[name]) { // object and not null
|
||||||
|
if (_config[name].mode!==undefined)
|
||||||
|
return _config[name].mode;
|
||||||
|
} else
|
||||||
|
return _config[name];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
init: _init,
|
||||||
|
canChange: _canChange,
|
||||||
|
getInitValue: _getInitValue
|
||||||
|
}
|
||||||
|
})();
|
|
@ -585,13 +585,15 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onTurnSpelling: function (state) {
|
onTurnSpelling: function (state, suspend) {
|
||||||
state = (state == 'on');
|
state = (state == 'on');
|
||||||
this.view.turnSpelling(state);
|
this.view && this.view.turnSpelling(state);
|
||||||
|
|
||||||
|
if (Common.UI.FeaturesManager.canChange('spellcheck') && !suspend) {
|
||||||
Common.localStorage.setItem(this.view.appPrefix + "settings-spellcheck", state ? 1 : 0);
|
Common.localStorage.setItem(this.view.appPrefix + "settings-spellcheck", state ? 1 : 0);
|
||||||
this.api.asc_setSpellCheck(state);
|
this.api.asc_setSpellCheck(state);
|
||||||
Common.Utils.InternalSettings.set(this.view.appPrefix + "settings-spellcheck", state);
|
Common.Utils.InternalSettings.set(this.view.appPrefix + "settings-spellcheck", state);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onReviewViewClick: function(menu, item, e) {
|
onReviewViewClick: function(menu, item, e) {
|
||||||
|
@ -802,9 +804,6 @@ define([
|
||||||
|
|
||||||
onAppReady: function (config) {
|
onAppReady: function (config) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if ( me.view && Common.localStorage.getBool(me.view.appPrefix + "settings-spellcheck", !(config.customization && config.customization.spellcheck===false)))
|
|
||||||
me.view.turnSpelling(true);
|
|
||||||
|
|
||||||
if ( config.canReview ) {
|
if ( config.canReview ) {
|
||||||
(new Promise(function (resolve) {
|
(new Promise(function (resolve) {
|
||||||
resolve();
|
resolve();
|
||||||
|
|
|
@ -736,7 +736,8 @@ define([
|
||||||
enableToggle: true,
|
enableToggle: true,
|
||||||
dataHint: '0',
|
dataHint: '0',
|
||||||
dataHintDirection: 'top',
|
dataHintDirection: 'top',
|
||||||
dataHintOffset: 'small'
|
dataHintOffset: 'small',
|
||||||
|
visible: Common.UI.FeaturesManager.canChange('spellcheck')
|
||||||
});
|
});
|
||||||
this.btnsSpelling.push(button);
|
this.btnsSpelling.push(button);
|
||||||
|
|
||||||
|
@ -786,7 +787,7 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
turnSpelling: function (state) {
|
turnSpelling: function (state) {
|
||||||
this.btnsSpelling.forEach(function(button) {
|
this.btnsSpelling && this.btnsSpelling.forEach(function(button) {
|
||||||
if ( button && button.pressed != state ) {
|
if ( button && button.pressed != state ) {
|
||||||
button.toggle(state, true);
|
button.toggle(state, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -495,9 +495,11 @@ define([
|
||||||
this.api.asc_setAutoSaveGap(value);
|
this.api.asc_setAutoSaveGap(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Common.UI.FeaturesManager.canChange('spellcheck')) {
|
||||||
value = Common.localStorage.getBool("de-settings-spellcheck", true);
|
value = Common.localStorage.getBool("de-settings-spellcheck", true);
|
||||||
Common.Utils.InternalSettings.set("de-settings-spellcheck", value);
|
Common.Utils.InternalSettings.set("de-settings-spellcheck", value);
|
||||||
this.api.asc_setSpellCheck(value);
|
this.api.asc_setSpellCheck(value);
|
||||||
|
}
|
||||||
|
|
||||||
value = parseInt(Common.localStorage.getItem("de-settings-paste-button"));
|
value = parseInt(Common.localStorage.getItem("de-settings-paste-button"));
|
||||||
Common.Utils.InternalSettings.set("de-settings-paste-button", value);
|
Common.Utils.InternalSettings.set("de-settings-paste-button", value);
|
||||||
|
|
|
@ -1107,9 +1107,17 @@ define([
|
||||||
value = Common.localStorage.getItem("de-show-tableline");
|
value = Common.localStorage.getItem("de-show-tableline");
|
||||||
me.api.put_ShowTableEmptyLine((value!==null) ? eval(value) : true);
|
me.api.put_ShowTableEmptyLine((value!==null) ? eval(value) : true);
|
||||||
|
|
||||||
value = Common.localStorage.getBool("de-settings-spellcheck", !(this.appOptions.customization && this.appOptions.customization.spellcheck===false));
|
// spellcheck
|
||||||
|
value = Common.UI.FeaturesManager.getInitValue('spellcheck');
|
||||||
|
value = (value !== undefined) ? value : !(this.appOptions.customization && this.appOptions.customization.spellcheck===false);
|
||||||
|
if (this.appOptions.customization && this.appOptions.customization.spellcheck!==undefined)
|
||||||
|
console.log("Obsolete: The 'spellcheck' parameter of the 'customization' section is deprecated. Please use 'spellcheck' parameter in the 'customization.features' section instead.");
|
||||||
|
if (Common.UI.FeaturesManager.canChange('spellcheck')) { // get from local storage
|
||||||
|
value = Common.localStorage.getBool("de-settings-spellcheck", value);
|
||||||
Common.Utils.InternalSettings.set("de-settings-spellcheck", value);
|
Common.Utils.InternalSettings.set("de-settings-spellcheck", value);
|
||||||
|
}
|
||||||
me.api.asc_setSpellCheck(value);
|
me.api.asc_setSpellCheck(value);
|
||||||
|
Common.NotificationCenter.trigger('spelling:turn', value ? 'on' : 'off', true); // only toggle buttons
|
||||||
|
|
||||||
value = Common.localStorage.getBool("de-settings-compatible", false);
|
value = Common.localStorage.getBool("de-settings-compatible", false);
|
||||||
Common.Utils.InternalSettings.set("de-settings-compatible", value);
|
Common.Utils.InternalSettings.set("de-settings-compatible", value);
|
||||||
|
@ -1461,6 +1469,7 @@ define([
|
||||||
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
|
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
|
||||||
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
|
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions, this.api);
|
||||||
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout);
|
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.LayoutManager.init(this.editorConfig.customization.layout);
|
||||||
|
this.appOptions.canBrandingExt && this.editorConfig.customization && Common.UI.FeaturesManager.init(this.editorConfig.customization.features);
|
||||||
|
|
||||||
if (this.appOptions.canComments)
|
if (this.appOptions.canComments)
|
||||||
Common.NotificationCenter.on('comments:cleardummy', _.bind(this.onClearDummyComment, this));
|
Common.NotificationCenter.on('comments:cleardummy', _.bind(this.onClearDummyComment, this));
|
||||||
|
|
|
@ -113,9 +113,12 @@ define([
|
||||||
me.btnDocLang = review.getButton('doclang', 'statusbar');
|
me.btnDocLang = review.getButton('doclang', 'statusbar');
|
||||||
me.btnDocLang.render( me.statusbar.$layout.find('#btn-doc-lang') );
|
me.btnDocLang.render( me.statusbar.$layout.find('#btn-doc-lang') );
|
||||||
|
|
||||||
var isVisible = Common.UI.LayoutManager.isElementVisible('statusBar-textLang') || Common.UI.LayoutManager.isElementVisible('statusBar-docLang');
|
var isVisible = (Common.UI.LayoutManager.isElementVisible('statusBar-textLang') || Common.UI.LayoutManager.isElementVisible('statusBar-docLang'))
|
||||||
|
&& Common.UI.FeaturesManager.canChange('spellcheck');
|
||||||
me.btnDocLang.$el.find('+.separator.space')[isVisible?'show':'hide']();
|
me.btnDocLang.$el.find('+.separator.space')[isVisible?'show':'hide']();
|
||||||
|
isVisible = Common.UI.LayoutManager.isElementVisible('statusBar-textLang') || Common.UI.LayoutManager.isElementVisible('statusBar-docLang')
|
||||||
|
|| Common.UI.FeaturesManager.canChange('spellcheck');
|
||||||
|
me.statusbar.$el.find('.el-lang')[isVisible?'show':'hide']();
|
||||||
} else {
|
} else {
|
||||||
me.statusbar.$el.find('.el-edit, .el-review').hide();
|
me.statusbar.$el.find('.el-edit, .el-review').hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<span id="btn-doc-lang" class="el-edit" data-layout-name="statusBar-docLang"></span>
|
<span id="btn-doc-lang" class="el-edit" data-layout-name="statusBar-docLang"></span>
|
||||||
<div class="separator short el-edit space"></div>
|
<div class="separator short el-edit space"></div>
|
||||||
<span id="btn-doc-spell" class="el-edit"></span>
|
<span id="btn-doc-spell" class="el-edit"></span>
|
||||||
<div class="separator short el-edit"></div>
|
<div class="separator short el-edit el-lang"></div>
|
||||||
<div id="btn-doc-review" class="el-edit el-review" style="display: inline-block;"></div>
|
<div id="btn-doc-review" class="el-edit el-review" style="display: inline-block;"></div>
|
||||||
<div class="separator short el-edit el-review"></div>
|
<div class="separator short el-edit el-review"></div>
|
||||||
<button id="btn-zoom-topage" type="button" class="btn small btn-toolbar" data-hint="0" data-hint-direction="top" data-hint-offset="small"><span class="icon toolbar__icon btn-ic-zoomtopage"> </span></button>
|
<button id="btn-zoom-topage" type="button" class="btn small btn-toolbar" data-hint="0" data-hint-direction="top" data-hint-offset="small"><span class="icon toolbar__icon btn-ic-zoomtopage"> </span></button>
|
||||||
|
|
|
@ -216,10 +216,10 @@ define([
|
||||||
'<td class="left"><label><%= scope.strReviewHover %></label></td>',
|
'<td class="left"><label><%= scope.strReviewHover %></label></td>',
|
||||||
'<td class="right"><span id="fms-cmb-review-hover"></span></td>',
|
'<td class="right"><span id="fms-cmb-review-hover"></span></td>',
|
||||||
'</tr>','<tr class="divider view-review"></tr>',
|
'</tr>','<tr class="divider view-review"></tr>',
|
||||||
'<tr class="edit">',
|
'<tr class="edit spellcheck">',
|
||||||
'<td class="left"><label><%= scope.txtSpellCheck %></label></td>',
|
'<td class="left"><label><%= scope.txtSpellCheck %></label></td>',
|
||||||
'<td class="right"><div id="fms-chb-spell-check"></div></td>',
|
'<td class="right"><div id="fms-chb-spell-check"></div></td>',
|
||||||
'</tr>','<tr class="divider edit"></tr>',
|
'</tr>','<tr class="divider edit spellcheck"></tr>',
|
||||||
'<tr class="edit">',
|
'<tr class="edit">',
|
||||||
'<td class="left"><label><%= scope.txtProofing %></label></td>',
|
'<td class="left"><label><%= scope.txtProofing %></label></td>',
|
||||||
'<td class="right"><button type="button" class="btn btn-text-default" id="fms-btn-auto-correct" style="width:auto; display: inline-block;padding-right: 10px;padding-left: 10px;" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.txtAutoCorrect %></button></div></td>',
|
'<td class="right"><button type="button" class="btn btn-text-default" id="fms-btn-auto-correct" style="width:auto; display: inline-block;padding-right: 10px;padding-left: 10px;" data-hint="2" data-hint-direction="bottom" data-hint-offset="medium"><%= scope.txtAutoCorrect %></button></div></td>',
|
||||||
|
@ -606,6 +606,7 @@ define([
|
||||||
$('tr.coauth.changes-mode', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring && mode.canChangeCoAuthoring ? 'show' : 'hide']();
|
$('tr.coauth.changes-mode', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring && mode.canChangeCoAuthoring ? 'show' : 'hide']();
|
||||||
$('tr.coauth.changes-show', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
|
$('tr.coauth.changes-show', this.el)[mode.isEdit && !mode.isOffline && mode.canCoAuthoring ? 'show' : 'hide']();
|
||||||
$('tr.view-review', this.el)[mode.canViewReview ? 'show' : 'hide']();
|
$('tr.view-review', this.el)[mode.canViewReview ? 'show' : 'hide']();
|
||||||
|
$('tr.spellcheck', this.el)[mode.isEdit && Common.UI.FeaturesManager.canChange('spellcheck') ? 'show' : 'hide']();
|
||||||
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
|
$('tr.comments', this.el)[mode.canCoAuthoring ? 'show' : 'hide']();
|
||||||
/** coauthoring end **/
|
/** coauthoring end **/
|
||||||
|
|
||||||
|
@ -665,6 +666,7 @@ define([
|
||||||
if (this.mode.canForcesave)
|
if (this.mode.canForcesave)
|
||||||
this.chForcesave.setValue(Common.Utils.InternalSettings.get("de-settings-forcesave"));
|
this.chForcesave.setValue(Common.Utils.InternalSettings.get("de-settings-forcesave"));
|
||||||
|
|
||||||
|
if (Common.UI.FeaturesManager.canChange('spellcheck'))
|
||||||
this.chSpell.setValue(Common.Utils.InternalSettings.get("de-settings-spellcheck"));
|
this.chSpell.setValue(Common.Utils.InternalSettings.get("de-settings-spellcheck"));
|
||||||
this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("de-settings-showsnaplines"));
|
this.chAlignGuides.setValue(Common.Utils.InternalSettings.get("de-settings-showsnaplines"));
|
||||||
this.chCompatible.setValue(Common.Utils.InternalSettings.get("de-settings-compatible"));
|
this.chCompatible.setValue(Common.Utils.InternalSettings.get("de-settings-compatible"));
|
||||||
|
@ -715,6 +717,7 @@ define([
|
||||||
Common.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
|
Common.localStorage.setItem("de-settings-autosave", this.chAutosave.isChecked() ? 1 : 0);
|
||||||
if (this.mode.canForcesave)
|
if (this.mode.canForcesave)
|
||||||
Common.localStorage.setItem("de-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
|
Common.localStorage.setItem("de-settings-forcesave", this.chForcesave.isChecked() ? 1 : 0);
|
||||||
|
if (Common.UI.FeaturesManager.canChange('spellcheck'))
|
||||||
Common.localStorage.setItem("de-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
|
Common.localStorage.setItem("de-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
|
||||||
Common.localStorage.setItem("de-settings-compatible", this.chCompatible.isChecked() ? 1 : 0);
|
Common.localStorage.setItem("de-settings-compatible", this.chCompatible.isChecked() ? 1 : 0);
|
||||||
Common.Utils.InternalSettings.set("de-settings-compatible", this.chCompatible.isChecked() ? 1 : 0);
|
Common.Utils.InternalSettings.set("de-settings-compatible", this.chCompatible.isChecked() ? 1 : 0);
|
||||||
|
|
Loading…
Reference in a new issue