[PE][SSE] Optimize equation loading
This commit is contained in:
parent
781950c412
commit
35e00505b4
|
@ -360,7 +360,7 @@ define([
|
||||||
this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this));
|
this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this));
|
||||||
|
|
||||||
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
|
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
|
||||||
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this));
|
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this));
|
||||||
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
||||||
this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this));
|
this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this));
|
||||||
},
|
},
|
||||||
|
@ -1716,55 +1716,19 @@ define([
|
||||||
|
|
||||||
var me = this, equationsStore = this.getApplication().getCollection('EquationGroups');
|
var me = this, equationsStore = this.getApplication().getCollection('EquationGroups');
|
||||||
|
|
||||||
me.equationPickers = [];
|
|
||||||
me.toolbar.btnInsertEquation.menu.removeAll();
|
me.toolbar.btnInsertEquation.menu.removeAll();
|
||||||
|
var onShowAfter = function(menu) {
|
||||||
for (var i = 0; i < equationsStore.length; ++i) {
|
for (var i = 0; i < equationsStore.length; ++i) {
|
||||||
var equationGroup = equationsStore.at(i);
|
var equationPicker = new Common.UI.DataViewSimple({
|
||||||
|
|
||||||
var menuItem = new Common.UI.MenuItem({
|
|
||||||
caption: equationGroup.get('groupName'),
|
|
||||||
menu: new Common.UI.Menu({
|
|
||||||
menuAlign: 'tl-tr',
|
|
||||||
items: [
|
|
||||||
{ template: _.template('<div id="id-toolbar-menu-equationgroup' + i +
|
|
||||||
'" class="menu-shape" style="width:' + (equationGroup.get('groupWidth') + 8) + 'px; ' +
|
|
||||||
equationGroup.get('groupHeight') + 'margin-left:5px;"></div>') }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
me.toolbar.btnInsertEquation.menu.addItem(menuItem);
|
|
||||||
|
|
||||||
var equationPicker = new Common.UI.DataView({
|
|
||||||
el: $('#id-toolbar-menu-equationgroup' + i),
|
el: $('#id-toolbar-menu-equationgroup' + i),
|
||||||
store: equationGroup.get('groupStore'),
|
parentMenu: menu.items[i].menu,
|
||||||
parentMenu: menuItem.menu,
|
store: equationsStore.at(i).get('groupStore'),
|
||||||
showLast: false,
|
scrollAlwaysVisible: true,
|
||||||
itemTemplate: _.template('<div class="item-equation" '+
|
itemTemplate: _.template('<div class="item-equation" '+
|
||||||
'style="background-position:<%= posX %>px <%= posY %>px;" >' +
|
'style="background-position:<%= posX %>px <%= posY %>px;" >' +
|
||||||
'<div style="width:<%= width %>px;height:<%= height %>px;" id="<%= id %>">')
|
'<div style="width:<%= width %>px;height:<%= height %>px;" id="<%= id %>"></div>' +
|
||||||
|
'</div>')
|
||||||
});
|
});
|
||||||
if (equationGroup.get('groupHeight').length) {
|
|
||||||
|
|
||||||
me.equationPickers.push(equationPicker);
|
|
||||||
me.toolbar.btnInsertEquation.menu.on('show:after', function () {
|
|
||||||
|
|
||||||
if (me.equationPickers.length) {
|
|
||||||
var element = $(this.el).find('.over').find('.menu-shape');
|
|
||||||
if (element.length) {
|
|
||||||
for (var i = 0; i < me.equationPickers.length; ++i) {
|
|
||||||
if (element[0].id == me.equationPickers[i].el.id) {
|
|
||||||
me.equationPickers[i].scroller.update({alwaysVisibleY: true});
|
|
||||||
me.equationPickers.splice(i, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
equationPicker.on('item:click', function(picker, item, record, e) {
|
equationPicker.on('item:click', function(picker, item, record, e) {
|
||||||
if (me.api) {
|
if (me.api) {
|
||||||
if (record)
|
if (record)
|
||||||
|
@ -1784,6 +1748,25 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
me.toolbar.btnInsertEquation.menu.off('show:after', onShowAfter);
|
||||||
|
};
|
||||||
|
me.toolbar.btnInsertEquation.menu.on('show:after', onShowAfter);
|
||||||
|
|
||||||
|
for (var i = 0; i < equationsStore.length; ++i) {
|
||||||
|
var equationGroup = equationsStore.at(i);
|
||||||
|
var menuItem = new Common.UI.MenuItem({
|
||||||
|
caption: equationGroup.get('groupName'),
|
||||||
|
menu: new Common.UI.Menu({
|
||||||
|
menuAlign: 'tl-tr',
|
||||||
|
items: [
|
||||||
|
{ template: _.template('<div id="id-toolbar-menu-equationgroup' + i +
|
||||||
|
'" class="menu-shape" style="width:' + (equationGroup.get('groupWidth') + 8) + 'px; ' +
|
||||||
|
equationGroup.get('groupHeight') + 'margin-left:5px;"></div>') }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
me.toolbar.btnInsertEquation.menu.addItem(menuItem);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onInsertEquationClick: function() {
|
onInsertEquationClick: function() {
|
||||||
|
@ -1794,6 +1777,16 @@ define([
|
||||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertEquation);
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertEquation);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onApiMathTypes: function(equation) {
|
||||||
|
this._equationTemp = equation;
|
||||||
|
var me = this;
|
||||||
|
var onShowBefore = function(menu) {
|
||||||
|
me.onMathTypes(me._equationTemp);
|
||||||
|
me.toolbar.btnInsertEquation.menu.off('show:before', onShowBefore);
|
||||||
|
};
|
||||||
|
me.toolbar.btnInsertEquation.menu.on('show:before', onShowBefore);
|
||||||
|
},
|
||||||
|
|
||||||
onMathTypes: function(equation) {
|
onMathTypes: function(equation) {
|
||||||
var equationgrouparray = [],
|
var equationgrouparray = [],
|
||||||
equationsStore = this.getCollection('EquationGroups');
|
equationsStore = this.getCollection('EquationGroups');
|
||||||
|
@ -1834,35 +1827,29 @@ define([
|
||||||
translationTable[Common.define.c_oAscMathType[name]] = this[translate];
|
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, data;
|
||||||
var i,id = 0, count = 0, length = 0, width = 0, height = 0, store = null, list = null, eqStore = null, eq = null;
|
|
||||||
|
|
||||||
if (equation) {
|
if (equation) {
|
||||||
|
data = equation.get_Data();
|
||||||
count = equation.get_Data().length;
|
count = data.length;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
for (var j = 0; j < count; ++j) {
|
for (var j = 0; j < count; ++j) {
|
||||||
id = equation.get_Data()[j].get_Id();
|
var group = data[j];
|
||||||
width = equation.get_Data()[j].get_W();
|
id = group.get_Id();
|
||||||
height = equation.get_Data()[j].get_H();
|
width = group.get_W();
|
||||||
|
height = group.get_H();
|
||||||
|
|
||||||
store = new Backbone.Collection([], {
|
store = new Backbone.Collection([], {
|
||||||
model: PE.Models.EquationModel
|
model: PE.Models.EquationModel
|
||||||
});
|
});
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
|
var allItemsCount = 0, itemsCount = 0, ids = 0, arr = [];
|
||||||
var allItemsCount = 0, itemsCount = 0, ids = 0;
|
length = group.get_Data().length;
|
||||||
|
|
||||||
length = equation.get_Data()[j].get_Data().length;
|
|
||||||
|
|
||||||
for (i = 0; i < length; ++i) {
|
for (i = 0; i < length; ++i) {
|
||||||
eqStore = equation.get_Data()[j].get_Data()[i];
|
eqStore = group.get_Data()[i];
|
||||||
|
|
||||||
itemsCount = eqStore.get_Data().length;
|
itemsCount = eqStore.get_Data().length;
|
||||||
for (var p = 0; p < itemsCount; ++p) {
|
for (var p = 0; p < itemsCount; ++p) {
|
||||||
|
|
||||||
eq = eqStore.get_Data()[p];
|
eq = eqStore.get_Data()[p];
|
||||||
ids = eq.get_Id();
|
ids = eq.get_Id();
|
||||||
|
|
||||||
|
@ -1871,8 +1858,7 @@ define([
|
||||||
if (translationTable.hasOwnProperty(ids)) {
|
if (translationTable.hasOwnProperty(ids)) {
|
||||||
translate = translationTable[ids];
|
translate = translationTable[ids];
|
||||||
}
|
}
|
||||||
|
arr.push({
|
||||||
store.add({
|
|
||||||
data : {equationType: ids},
|
data : {equationType: ids},
|
||||||
tip : translate,
|
tip : translate,
|
||||||
allowSelected : true,
|
allowSelected : true,
|
||||||
|
@ -1886,7 +1872,7 @@ define([
|
||||||
|
|
||||||
allItemsCount += itemsCount;
|
allItemsCount += itemsCount;
|
||||||
}
|
}
|
||||||
|
store.add(arr);
|
||||||
width = c_oAscMathMainTypeStrings[id][1] * (width + 10); // 4px margin + 4px margin + 1px border + 1px border
|
width = c_oAscMathMainTypeStrings[id][1] * (width + 10); // 4px margin + 4px margin + 1px border + 1px border
|
||||||
|
|
||||||
var normHeight = parseInt(370 / (height + 10)) * (height + 10);
|
var normHeight = parseInt(370 / (height + 10)) * (height + 10);
|
||||||
|
@ -1898,9 +1884,7 @@ define([
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
equationsStore.add(equationgrouparray);
|
equationsStore.add(equationgrouparray);
|
||||||
|
|
||||||
this.fillEquations();
|
this.fillEquations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -376,7 +376,7 @@ define([
|
||||||
var config = SSE.getController('Main').appOptions;
|
var config = SSE.getController('Main').appOptions;
|
||||||
if ( !config.isEditDiagram && !config.isEditMailMerge ) {
|
if ( !config.isEditDiagram && !config.isEditMailMerge ) {
|
||||||
this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this));
|
this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this));
|
||||||
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this));
|
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onApiMathTypes, this));
|
||||||
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2632,55 +2632,19 @@ define([
|
||||||
|
|
||||||
var me = this, equationsStore = this.getApplication().getCollection('EquationGroups');
|
var me = this, equationsStore = this.getApplication().getCollection('EquationGroups');
|
||||||
|
|
||||||
me.equationPickers = [];
|
|
||||||
me.toolbar.btnInsertEquation.menu.removeAll();
|
me.toolbar.btnInsertEquation.menu.removeAll();
|
||||||
|
var onShowAfter = function(menu) {
|
||||||
for (var i = 0; i < equationsStore.length; ++i) {
|
for (var i = 0; i < equationsStore.length; ++i) {
|
||||||
var equationGroup = equationsStore.at(i);
|
var equationPicker = new Common.UI.DataViewSimple({
|
||||||
|
|
||||||
var menuItem = new Common.UI.MenuItem({
|
|
||||||
caption: equationGroup.get('groupName'),
|
|
||||||
menu: new Common.UI.Menu({
|
|
||||||
menuAlign: 'tl-tr',
|
|
||||||
items: [
|
|
||||||
{ template: _.template('<div id="id-toolbar-menu-equationgroup' + i +
|
|
||||||
'" class="menu-shape" style="width:' + (equationGroup.get('groupWidth') + 8) + 'px; ' +
|
|
||||||
equationGroup.get('groupHeight') + 'margin-left:5px;"></div>') }
|
|
||||||
]
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
me.toolbar.btnInsertEquation.menu.addItem(menuItem);
|
|
||||||
|
|
||||||
var equationPicker = new Common.UI.DataView({
|
|
||||||
el: $('#id-toolbar-menu-equationgroup' + i),
|
el: $('#id-toolbar-menu-equationgroup' + i),
|
||||||
store: equationGroup.get('groupStore'),
|
parentMenu: menu.items[i].menu,
|
||||||
parentMenu: menuItem.menu,
|
store: equationsStore.at(i).get('groupStore'),
|
||||||
showLast: false,
|
scrollAlwaysVisible: true,
|
||||||
itemTemplate: _.template('<div class="item-equation" '+
|
itemTemplate: _.template('<div class="item-equation" '+
|
||||||
'style="background-position:<%= posX %>px <%= posY %>px;" >' +
|
'style="background-position:<%= posX %>px <%= posY %>px;" >' +
|
||||||
'<div style="width:<%= width %>px;height:<%= height %>px;" id="<%= id %>">')
|
'<div style="width:<%= width %>px;height:<%= height %>px;" id="<%= id %>"></div>' +
|
||||||
|
'</div>')
|
||||||
});
|
});
|
||||||
if (equationGroup.get('groupHeight').length) {
|
|
||||||
|
|
||||||
me.equationPickers.push(equationPicker);
|
|
||||||
me.toolbar.btnInsertEquation.menu.on('show:after', function () {
|
|
||||||
|
|
||||||
if (me.equationPickers.length) {
|
|
||||||
var element = $(this.el).find('.over').find('.menu-shape');
|
|
||||||
if (element.length) {
|
|
||||||
for (var i = 0; i < me.equationPickers.length; ++i) {
|
|
||||||
if (element[0].id == me.equationPickers[i].el.id) {
|
|
||||||
me.equationPickers[i].scroller.update({alwaysVisibleY: true});
|
|
||||||
me.equationPickers.splice(i, 1);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
equationPicker.on('item:click', function(picker, item, record, e) {
|
equationPicker.on('item:click', function(picker, item, record, e) {
|
||||||
if (me.api) {
|
if (me.api) {
|
||||||
if (record)
|
if (record)
|
||||||
|
@ -2700,6 +2664,25 @@ define([
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
me.toolbar.btnInsertEquation.menu.off('show:after', onShowAfter);
|
||||||
|
};
|
||||||
|
me.toolbar.btnInsertEquation.menu.on('show:after', onShowAfter);
|
||||||
|
|
||||||
|
for (var i = 0; i < equationsStore.length; ++i) {
|
||||||
|
var equationGroup = equationsStore.at(i);
|
||||||
|
var menuItem = new Common.UI.MenuItem({
|
||||||
|
caption: equationGroup.get('groupName'),
|
||||||
|
menu: new Common.UI.Menu({
|
||||||
|
menuAlign: 'tl-tr',
|
||||||
|
items: [
|
||||||
|
{ template: _.template('<div id="id-toolbar-menu-equationgroup' + i +
|
||||||
|
'" class="menu-shape" style="width:' + (equationGroup.get('groupWidth') + 8) + 'px; ' +
|
||||||
|
equationGroup.get('groupHeight') + 'margin-left:5px;"></div>') }
|
||||||
|
]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
me.toolbar.btnInsertEquation.menu.addItem(menuItem);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onInsertEquationClick: function() {
|
onInsertEquationClick: function() {
|
||||||
|
@ -2710,6 +2693,16 @@ define([
|
||||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertEquation);
|
Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertEquation);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onApiMathTypes: function(equation) {
|
||||||
|
this._equationTemp = equation;
|
||||||
|
var me = this;
|
||||||
|
var onShowBefore = function(menu) {
|
||||||
|
me.onMathTypes(me._equationTemp);
|
||||||
|
me.toolbar.btnInsertEquation.menu.off('show:before', onShowBefore);
|
||||||
|
};
|
||||||
|
me.toolbar.btnInsertEquation.menu.on('show:before', onShowBefore);
|
||||||
|
},
|
||||||
|
|
||||||
onMathTypes: function(equation) {
|
onMathTypes: function(equation) {
|
||||||
var equationgrouparray = [],
|
var equationgrouparray = [],
|
||||||
equationsStore = this.getCollection('EquationGroups');
|
equationsStore = this.getCollection('EquationGroups');
|
||||||
|
@ -2750,35 +2743,29 @@ define([
|
||||||
translationTable[Common.define.c_oAscMathType[name]] = this[translate];
|
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, data;
|
||||||
var i,id = 0, count = 0, length = 0, width = 0, height = 0, store = null, list = null, eqStore = null, eq = null;
|
|
||||||
|
|
||||||
if (equation) {
|
if (equation) {
|
||||||
|
data = equation.get_Data();
|
||||||
count = equation.get_Data().length;
|
count = data.length;
|
||||||
|
|
||||||
if (count) {
|
if (count) {
|
||||||
for (var j = 0; j < count; ++j) {
|
for (var j = 0; j < count; ++j) {
|
||||||
id = equation.get_Data()[j].get_Id();
|
var group = data[j];
|
||||||
width = equation.get_Data()[j].get_W();
|
id = group.get_Id();
|
||||||
height = equation.get_Data()[j].get_H();
|
width = group.get_W();
|
||||||
|
height = group.get_H();
|
||||||
|
|
||||||
store = new Backbone.Collection([], {
|
store = new Backbone.Collection([], {
|
||||||
model: SSE.Models.EquationModel
|
model: SSE.Models.EquationModel
|
||||||
});
|
});
|
||||||
|
|
||||||
if (store) {
|
if (store) {
|
||||||
|
var allItemsCount = 0, itemsCount = 0, ids = 0, arr = [];
|
||||||
var allItemsCount = 0, itemsCount = 0, ids = 0;
|
length = group.get_Data().length;
|
||||||
|
|
||||||
length = equation.get_Data()[j].get_Data().length;
|
|
||||||
|
|
||||||
for (i = 0; i < length; ++i) {
|
for (i = 0; i < length; ++i) {
|
||||||
eqStore = equation.get_Data()[j].get_Data()[i];
|
eqStore = group.get_Data()[i];
|
||||||
|
|
||||||
itemsCount = eqStore.get_Data().length;
|
itemsCount = eqStore.get_Data().length;
|
||||||
for (var p = 0; p < itemsCount; ++p) {
|
for (var p = 0; p < itemsCount; ++p) {
|
||||||
|
|
||||||
eq = eqStore.get_Data()[p];
|
eq = eqStore.get_Data()[p];
|
||||||
ids = eq.get_Id();
|
ids = eq.get_Id();
|
||||||
|
|
||||||
|
@ -2787,8 +2774,7 @@ define([
|
||||||
if (translationTable.hasOwnProperty(ids)) {
|
if (translationTable.hasOwnProperty(ids)) {
|
||||||
translate = translationTable[ids];
|
translate = translationTable[ids];
|
||||||
}
|
}
|
||||||
|
arr.push({
|
||||||
store.add({
|
|
||||||
data : {equationType: ids},
|
data : {equationType: ids},
|
||||||
tip : translate,
|
tip : translate,
|
||||||
allowSelected : true,
|
allowSelected : true,
|
||||||
|
@ -2802,7 +2788,7 @@ define([
|
||||||
|
|
||||||
allItemsCount += itemsCount;
|
allItemsCount += itemsCount;
|
||||||
}
|
}
|
||||||
|
store.add(arr);
|
||||||
width = c_oAscMathMainTypeStrings[id][1] * (width + 10); // 4px margin + 4px margin + 1px border + 1px border
|
width = c_oAscMathMainTypeStrings[id][1] * (width + 10); // 4px margin + 4px margin + 1px border + 1px border
|
||||||
|
|
||||||
var normHeight = parseInt(370 / (height + 10)) * (height + 10);
|
var normHeight = parseInt(370 / (height + 10)) * (height + 10);
|
||||||
|
@ -2814,9 +2800,7 @@ define([
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
equationsStore.add(equationgrouparray);
|
equationsStore.add(equationgrouparray);
|
||||||
|
|
||||||
this.fillEquations();
|
this.fillEquations();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue