[DE] Add warnings when change autocorrection
This commit is contained in:
parent
58d61f4d87
commit
5785527607
|
@ -48,6 +48,7 @@ define([
|
||||||
Common.Views.AutoCorrectDialog = Common.UI.Window.extend(_.extend({
|
Common.Views.AutoCorrectDialog = Common.UI.Window.extend(_.extend({
|
||||||
options: {
|
options: {
|
||||||
width: 448,
|
width: 448,
|
||||||
|
height: 444,
|
||||||
cls: 'modal-dlg',
|
cls: 'modal-dlg',
|
||||||
buttons: null
|
buttons: null
|
||||||
},
|
},
|
||||||
|
@ -302,10 +303,26 @@ define([
|
||||||
|
|
||||||
onEdit: function() {
|
onEdit: function() {
|
||||||
var rec = this.mathList.getSelectedRec(),
|
var rec = this.mathList.getSelectedRec(),
|
||||||
by = '';
|
by = '',
|
||||||
|
me = this,
|
||||||
|
applySettings = function(by) {
|
||||||
|
var path = me.appPrefix + "settings-math-correct-add";
|
||||||
|
var val = JSON.stringify(me.arrAdd);
|
||||||
|
Common.Utils.InternalSettings.set(path, val);
|
||||||
|
Common.localStorage.setItem(path, val);
|
||||||
|
me.api.asc_AddOrEditFromAutoCorrectMathSymbols(rec.get('replaced'), by);
|
||||||
|
};
|
||||||
if (rec) {
|
if (rec) {
|
||||||
var idx = _.findIndex(this.arrAdd, function(item){return (item[0]==rec.get('replaced'));});
|
var idx = _.findIndex(this.arrAdd, function(item){return (item[0]==rec.get('replaced'));});
|
||||||
if (!this.inputBy.getValue() && rec.get('defaultValue') && (rec.get('defaultValueStr')!==rec.get('by'))) {// reset to default
|
var restore = !this.inputBy.getValue() && rec.get('defaultValue') && (rec.get('defaultValueStr')!==rec.get('by'));
|
||||||
|
Common.UI.warning({
|
||||||
|
width: 500,
|
||||||
|
msg: restore ? this.warnRestore.replace('%1', rec.get('replaced')) : this.warnReplace.replace('%1', rec.get('replaced')),
|
||||||
|
buttons: ['yes', 'no'],
|
||||||
|
primary: 'yes',
|
||||||
|
callback: _.bind(function(btn, dontshow){
|
||||||
|
if (btn == 'yes') {
|
||||||
|
if (restore) {// reset to default
|
||||||
by = rec.get('defaultValue');
|
by = rec.get('defaultValue');
|
||||||
rec.set('by', rec.get('defaultValueStr'));
|
rec.set('by', rec.get('defaultValueStr'));
|
||||||
(idx>=0) && this.arrAdd.splice(idx, 1);
|
(idx>=0) && this.arrAdd.splice(idx, 1);
|
||||||
|
@ -317,6 +334,11 @@ define([
|
||||||
else
|
else
|
||||||
this.arrAdd[idx][1] = by;
|
this.arrAdd[idx][1] = by;
|
||||||
}
|
}
|
||||||
|
applySettings(by);
|
||||||
|
}
|
||||||
|
}, this)
|
||||||
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
rec = this.mathStore.add({
|
rec = this.mathStore.add({
|
||||||
replaced: this.inputReplace.getValue(),
|
replaced: this.inputReplace.getValue(),
|
||||||
|
@ -327,17 +349,23 @@ define([
|
||||||
this.mathList.scrollToRecord(rec);
|
this.mathList.scrollToRecord(rec);
|
||||||
by = rec.get('by');
|
by = rec.get('by');
|
||||||
this.arrAdd.push([rec.get('replaced'), by]);
|
this.arrAdd.push([rec.get('replaced'), by]);
|
||||||
|
applySettings(by);
|
||||||
}
|
}
|
||||||
var path = this.appPrefix + "settings-math-correct-add";
|
|
||||||
var val = JSON.stringify(this.arrAdd);
|
|
||||||
Common.Utils.InternalSettings.set(path, val);
|
|
||||||
Common.localStorage.setItem(path, val);
|
|
||||||
this.api.asc_AddOrEditFromAutoCorrectMathSymbols(rec.get('replaced'), by);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
onResetToDefault: function() {
|
onResetToDefault: function() {
|
||||||
|
Common.UI.warning({
|
||||||
|
width: 500,
|
||||||
|
msg: this.warnReset,
|
||||||
|
buttons: ['yes', 'no'],
|
||||||
|
primary: 'yes',
|
||||||
|
callback: _.bind(function(btn, dontshow){
|
||||||
|
if (btn == 'yes') {
|
||||||
this.api.asc_resetToDefaultAutoCorrectMathSymbols();
|
this.api.asc_resetToDefaultAutoCorrectMathSymbols();
|
||||||
this.onResetList();
|
this.onResetList();
|
||||||
|
}
|
||||||
|
}, this)
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onResetList: function() {
|
onResetList: function() {
|
||||||
|
@ -354,6 +382,7 @@ define([
|
||||||
this.mathStore.remove(this.mathStore.where({defaultValue: undefined}));
|
this.mathStore.remove(this.mathStore.where({defaultValue: undefined}));
|
||||||
this.mathStore.each(function(item, index){
|
this.mathStore.each(function(item, index){
|
||||||
item.set('by', item.get('defaultValueStr'));
|
item.set('by', item.get('defaultValueStr'));
|
||||||
|
item.set('defaultDisabled', false);
|
||||||
});
|
});
|
||||||
this.mathList.deselectAll();
|
this.mathList.deselectAll();
|
||||||
if (this.mathList.scroller) {
|
if (this.mathList.scroller) {
|
||||||
|
@ -424,7 +453,10 @@ define([
|
||||||
textDelete: 'Delete',
|
textDelete: 'Delete',
|
||||||
textRestore: 'Restore',
|
textRestore: 'Restore',
|
||||||
textReset: 'Reset',
|
textReset: 'Reset',
|
||||||
textReplaceType: 'Replace text as you type'
|
textReplaceType: 'Replace text as you type',
|
||||||
|
warnReset: 'Any autocorrect you added will be removed and the changed ones will be restored to their original values. Do you want to continue?',
|
||||||
|
warnReplace: 'The autocorrect entry for %1 already exists. Do you want to replace it?',
|
||||||
|
warnRestore: 'The autocorrect entry for %1 will be reset to its original value. Do you want to continue?'
|
||||||
|
|
||||||
}, Common.Views.AutoCorrectDialog || {}))
|
}, Common.Views.AutoCorrectDialog || {}))
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue