From cbd293523a91b009249ae4dbd5c6eb8d60afca9c Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 15 Aug 2019 16:39:48 +0300 Subject: [PATCH] [DE] Refactoring math loading --- .../main/app/controller/Toolbar.js | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Toolbar.js b/apps/documenteditor/main/app/controller/Toolbar.js index 2a96c58f4..c53c0782c 100644 --- a/apps/documenteditor/main/app/controller/Toolbar.js +++ b/apps/documenteditor/main/app/controller/Toolbar.js @@ -2454,35 +2454,29 @@ define([ translationTable[Common.define.c_oAscMathType[name]] = this[translate]; } } - - var i,id = 0, count = 0, length = 0, width = 0, height = 0, store = null, list = null, eqStore = null, eq = null; + var i,id = 0, count = 0, length = 0, width = 0, height = 0, store = null, list = null, eqStore = null, eq = null, data; if (equation) { - - count = equation.get_Data().length; - + data = equation.get_Data(); + count = data.length; if (count) { for (var j = 0; j < count; ++j) { - id = equation.get_Data()[j].get_Id(); - width = equation.get_Data()[j].get_W(); - height = equation.get_Data()[j].get_H(); + var group = data[j]; + id = group.get_Id(); + width = group.get_W(); + height = group.get_H(); store = new Backbone.Collection([], { model: DE.Models.EquationModel }); if (store) { - - var allItemsCount = 0, itemsCount = 0, ids = 0; - - length = equation.get_Data()[j].get_Data().length; - + var allItemsCount = 0, itemsCount = 0, ids = 0, arr = []; + length = group.get_Data().length; for (i = 0; i < length; ++i) { - eqStore = equation.get_Data()[j].get_Data()[i]; - + eqStore = group.get_Data()[i]; itemsCount = eqStore.get_Data().length; for (var p = 0; p < itemsCount; ++p) { - eq = eqStore.get_Data()[p]; ids = eq.get_Id(); @@ -2491,8 +2485,7 @@ define([ if (translationTable.hasOwnProperty(ids)) { translate = translationTable[ids]; } - - store.add({ + arr.push({ data : {equationType: ids}, tip : translate, allowSelected : true, @@ -2506,7 +2499,7 @@ define([ allItemsCount += itemsCount; } - + store.add(arr); width = c_oAscMathMainTypeStrings[id][1] * (width + 10); // 4px margin + 4px margin + 1px border + 1px border var normHeight = parseInt(370 / (height + 10)) * (height + 10); @@ -2518,9 +2511,7 @@ define([ }); } } - equationsStore.add(equationgrouparray); - this.fillEquations(); } }