diff --git a/apps/common/main/lib/view/AutoCorrectDialog.js b/apps/common/main/lib/view/AutoCorrectDialog.js index 62aba478e..f031cd87e 100644 --- a/apps/common/main/lib/view/AutoCorrectDialog.js +++ b/apps/common/main/lib/view/AutoCorrectDialog.js @@ -45,6 +45,8 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', 'common/main/lib/component/Window', 'common/main/lib/component/CheckBox' ], function (contentTemplate) { 'use strict'; + var _mathStore = new Common.UI.DataViewStore(); + var _functionsStore = new Common.UI.DataViewStore(); Common.Views.AutoCorrectDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { @@ -90,8 +92,6 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', ].join('') }, options || {}); - this.mathStore = this.options.mathStore || new Common.UI.DataViewStore(); - this.functionsStore = this.options.functionsStore || new Common.UI.DataViewStore(); this.api = this.options.api; var path = this.appPrefix + "settings-math-correct"; @@ -168,7 +168,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', this.mathList = new Common.UI.ListView({ el: $window.find('#auto-correct-math-list'), - store: new Common.UI.DataViewStore(this.mathStore.slice(0, 9)), + store: new Common.UI.DataViewStore(_mathStore.slice(0, 9)), simpleAddMode: false, template: _.template(['
'].join('')), itemTemplate: _.template([ @@ -251,7 +251,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', this.mathRecList = new Common.UI.ListView({ el: $window.find('#auto-correct-recognized-list'), - store: new Common.UI.DataViewStore(this.functionsStore.slice(0, 9)), + store: new Common.UI.DataViewStore(_functionsStore.slice(0, 9)), simpleAddMode: false, template: _.template([''].join('')), itemTemplate: _.template([ @@ -419,9 +419,9 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', $('input', me.inputReplace.cmpEl).select().focus(); },delay ? 50 : 0); - if (me.mathList.store.length < me.mathStore.length) { + if (me.mathList.store.length < _mathStore.length) { _.delay(function(){ - me.mathList.setStore(me.mathStore); + me.mathList.setStore(_mathStore); me.mathList.onResetItems(); },delay ? 100 : 10); } @@ -444,7 +444,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', this.btnDelete.setCaption(disabled ? this.textRestore : this.textDelete); disabled ? this.api.asc_deleteFromAutoCorrectMathSymbols(rec.get('replaced')) : this.api.asc_AddOrEditFromAutoCorrectMathSymbols(rec.get('replaced'), rec.get('defaultValue')); } else { - this.mathStore.remove(rec); + _mathStore.remove(rec); this.mathList.scroller && this.mathList.scroller.update({}); this.api.asc_deleteFromAutoCorrectMathSymbols(rec.get('replaced')); } @@ -466,7 +466,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', me.mathList.scrollToRecord(record); }; if (!rec) { - rec = this.mathStore.findWhere({replaced: this.inputReplace.getValue()}) + rec = _mathStore.findWhere({replaced: this.inputReplace.getValue()}) } if (rec) { var idx = _.findIndex(this.arrAdd, function(item){return (item[0]==rec.get('replaced'));}); @@ -496,7 +496,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', }); } else { - rec = this.mathStore.add({ + rec = _mathStore.add({ replaced: this.inputReplace.getValue(), by: this.inputBy.getValue(), defaultDisabled: false @@ -533,8 +533,8 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', this.arrAdd = []; this.arrRem = []; - this.mathStore.remove(this.mathStore.where({defaultValue: undefined})); - this.mathStore.each(function(item, index){ + _mathStore.remove(_mathStore.where({defaultValue: undefined})); + _mathStore.each(function(item, index){ item.set('by', item.get('defaultValueStr')); item.set('defaultDisabled', false); }); @@ -547,9 +547,9 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', }, onInitList: function() { - if (this.mathStore.length>0) return; + if (_mathStore.length>0) return; - this.mathStore.comparator = function(item1, item2) { + _mathStore.comparator = function(item1, item2) { var n1 = item1.get('replaced').toLowerCase(), n2 = item2.get('replaced').toLowerCase(); if (n1==n2) return 0; @@ -593,14 +593,14 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', changed.by = item[1]; } }); - this.mathStore.reset(data.concat(dataAdd)); + _mathStore.reset(data.concat(dataAdd)); this.updateControls(); }, onInitRecList: function() { - if (this.functionsStore.length>0) return; + if (_functionsStore.length>0) return; - this.functionsStore.comparator = function(item1, item2) { + _functionsStore.comparator = function(item1, item2) { var n1 = item1.get('value').toLowerCase(), n2 = item2.get('value').toLowerCase(); if (n1==n2) return 0; @@ -630,7 +630,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', }); } }); - this.functionsStore.reset(data.concat(dataAdd)); + _functionsStore.reset(data.concat(dataAdd)); this.updateRecControls(); }, @@ -660,8 +660,8 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', this.arrAddRec = []; this.arrRemRec = []; - this.functionsStore.remove(this.functionsStore.where({defaultValue: false})); - this.functionsStore.each(function(item, index){ + _functionsStore.remove(_functionsStore.where({defaultValue: false})); + _functionsStore.each(function(item, index){ item.set('defaultDisabled', false); }); this.mathRecList.deselectAll(); @@ -680,9 +680,9 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', $('input', me.inputRecFind.cmpEl).select().focus(); },delay ? 50 : 0); - if (me.mathRecList.store.length < me.functionsStore.length) { + if (me.mathRecList.store.length < _functionsStore.length) { _.delay(function(){ - me.mathRecList.setStore(me.functionsStore); + me.mathRecList.setStore(_functionsStore); me.mathRecList.onResetItems(); },delay ? 100 : 10); } @@ -705,7 +705,7 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', this.btnDeleteRec.setCaption(disabled ? this.textRestore : this.textDelete); disabled ? this.api.asc_deleteFromAutoCorrectMathFunctions(rec.get('value')) : this.api.asc_AddFromAutoCorrectMathFunctions(rec.get('value')); } else { - this.functionsStore.remove(rec); + _functionsStore.remove(rec); this.mathRecList.scroller && this.mathRecList.scroller.update({}); this.api.asc_deleteFromAutoCorrectMathFunctions(rec.get('value')); } @@ -726,11 +726,11 @@ define([ 'text!common/main/lib/template/AutoCorrectDialog.template', me.mathRecList.scrollToRecord(record); }; if (!rec) { - rec = this.functionsStore.findWhere({value: this.inputRecFind.getValue()}) + rec = _functionsStore.findWhere({value: this.inputRecFind.getValue()}) } if (!rec) { if (/^[A-Z]+$/i.test(this.inputRecFind.getValue())) { - rec = this.functionsStore.add({ + rec = _functionsStore.add({ value: this.inputRecFind.getValue(), defaultValue: false, defaultDisabled: false diff --git a/apps/documenteditor/main/app/view/FileMenuPanels.js b/apps/documenteditor/main/app/view/FileMenuPanels.js index 13e08e864..c0930f086 100644 --- a/apps/documenteditor/main/app/view/FileMenuPanels.js +++ b/apps/documenteditor/main/app/view/FileMenuPanels.js @@ -631,13 +631,7 @@ define([ }, autoCorrect: function() { - if (!this._mathCorrect) - this._mathCorrect = new Common.UI.DataViewStore(); - if (!this._funcCorrect) - this._funcCorrect = new Common.UI.DataViewStore(); (new Common.Views.AutoCorrectDialog({ - mathStore: this._mathCorrect, - functionsStore: this._funcCorrect, api: this.api })).show(); }, diff --git a/apps/presentationeditor/main/app/view/FileMenuPanels.js b/apps/presentationeditor/main/app/view/FileMenuPanels.js index 9e82ceb79..6baae7269 100644 --- a/apps/presentationeditor/main/app/view/FileMenuPanels.js +++ b/apps/presentationeditor/main/app/view/FileMenuPanels.js @@ -543,13 +543,7 @@ define([ }, autoCorrect: function() { - if (!this._mathCorrect) - this._mathCorrect = new Common.UI.DataViewStore(); - if (!this._funcCorrect) - this._funcCorrect = new Common.UI.DataViewStore(); (new Common.Views.AutoCorrectDialog({ - mathStore: this._mathCorrect, - functionsStore: this._funcCorrect, api: this.api })).show(); }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index 2cdd37fb7..b5f954932 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -1443,13 +1443,7 @@ define([ }, autoCorrect: function() { - if (!this._mathCorrect) - this._mathCorrect = new Common.UI.DataViewStore(); - if (!this._funcCorrect) - this._funcCorrect = new Common.UI.DataViewStore(); (new Common.Views.AutoCorrectDialog({ - mathStore: this._mathCorrect, - functionsStore: this._funcCorrect, api: this.api })).show(); },