[PE] Optimize textart loading
This commit is contained in:
parent
b4530a252a
commit
dc74a49e97
|
@ -761,7 +761,6 @@ define([
|
||||||
|
|
||||||
me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onFocusObject, me));
|
me.api.asc_registerCallback('asc_onFocusObject', _.bind(me.onFocusObject, me));
|
||||||
|
|
||||||
me.fillTextArt(me.api.asc_getTextArtPreviews());
|
|
||||||
toolbarController.activateControls();
|
toolbarController.activateControls();
|
||||||
if (me.needToUpdateVersion)
|
if (me.needToUpdateVersion)
|
||||||
toolbarController.onApiCoAuthoringDisconnect();
|
toolbarController.onApiCoAuthoringDisconnect();
|
||||||
|
@ -1558,7 +1557,7 @@ define([
|
||||||
this.updateThemeColors();
|
this.updateThemeColors();
|
||||||
var me = this;
|
var me = this;
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
me.fillTextArt(me.api.asc_getTextArtPreviews());
|
me.fillTextArt();
|
||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1642,11 +1641,14 @@ define([
|
||||||
},
|
},
|
||||||
|
|
||||||
fillTextArt: function(shapes){
|
fillTextArt: function(shapes){
|
||||||
if (_.isEmpty(shapes)) return;
|
var arr = [],
|
||||||
|
|
||||||
var me = this, arr = [],
|
|
||||||
artStore = this.getCollection('Common.Collections.TextArt');
|
artStore = this.getCollection('Common.Collections.TextArt');
|
||||||
|
|
||||||
|
if (!shapes && artStore.length>0) {// shapes == undefined when update textart collection (from asc_onSendThemeColors)
|
||||||
|
shapes = this.api.asc_getTextArtPreviews();
|
||||||
|
}
|
||||||
|
if (_.isEmpty(shapes)) return;
|
||||||
|
|
||||||
_.each(shapes, function(shape, index){
|
_.each(shapes, function(shape, index){
|
||||||
arr.push({
|
arr.push({
|
||||||
imageUrl : shape,
|
imageUrl : shape,
|
||||||
|
@ -1656,11 +1658,6 @@ define([
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
artStore.reset(arr);
|
artStore.reset(arr);
|
||||||
|
|
||||||
setTimeout(function(){
|
|
||||||
me.getApplication().getController('RightMenu').fillTextArt();
|
|
||||||
}, 50);
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
loadLanguages: function(apiLangs) {
|
loadLanguages: function(apiLangs) {
|
||||||
|
|
|
@ -278,10 +278,6 @@ define([
|
||||||
this.rightmenu.tableSettings.updateMetricUnit();
|
this.rightmenu.tableSettings.updateMetricUnit();
|
||||||
},
|
},
|
||||||
|
|
||||||
fillTextArt: function() {
|
|
||||||
this.rightmenu.textartSettings.fillTextArt();
|
|
||||||
},
|
|
||||||
|
|
||||||
createDelayedElements: function() {
|
createDelayedElements: function() {
|
||||||
if (this.editMode && this.api) {
|
if (this.editMode && this.api) {
|
||||||
this.api.asc_registerCallback('asc_doubleClickOnObject', _.bind(this.onDoubleClickOnObject, this));
|
this.api.asc_registerCallback('asc_doubleClickOnObject', _.bind(this.onDoubleClickOnObject, this));
|
||||||
|
|
|
@ -234,10 +234,6 @@ define([
|
||||||
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me));
|
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(me));
|
||||||
Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me));
|
Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me));
|
||||||
|
|
||||||
PE.getCollection('Common.Collections.TextArt').bind({
|
|
||||||
reset: me.onResetTextArt.bind(this)
|
|
||||||
});
|
|
||||||
|
|
||||||
PE.getCollection('ShapeGroups').bind({
|
PE.getCollection('ShapeGroups').bind({
|
||||||
reset: me.onResetAutoshapes.bind(this)
|
reset: me.onResetAutoshapes.bind(this)
|
||||||
});
|
});
|
||||||
|
@ -1720,14 +1716,6 @@ define([
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
onResetTextArt: function (collection, opts) {
|
|
||||||
(new Promise(function (resolve, reject) {
|
|
||||||
resolve();
|
|
||||||
})).then(function () {
|
|
||||||
this.toolbar.updateTextartMenu(collection);
|
|
||||||
}.bind(this));
|
|
||||||
},
|
|
||||||
|
|
||||||
onResetSlides: function () {
|
onResetSlides: function () {
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
this.toolbar.updateAddSlideMenu(PE.getCollection('SlideLayouts'));
|
this.toolbar.updateAddSlideMenu(PE.getCollection('SlideLayouts'));
|
||||||
|
|
|
@ -123,6 +123,10 @@ define([
|
||||||
this.FillPatternContainer = $('#textart-panel-pattern-fill');
|
this.FillPatternContainer = $('#textart-panel-pattern-fill');
|
||||||
this.FillGradientContainer = $('#textart-panel-gradient-fill');
|
this.FillGradientContainer = $('#textart-panel-gradient-fill');
|
||||||
this.TransparencyContainer = $('#textart-panel-transparent-fill');
|
this.TransparencyContainer = $('#textart-panel-transparent-fill');
|
||||||
|
|
||||||
|
PE.getCollection('Common.Collections.TextArt').bind({
|
||||||
|
reset: this.fillTextArt.bind(this)
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function () {
|
render: function () {
|
||||||
|
@ -1431,6 +1435,10 @@ define([
|
||||||
|
|
||||||
var models = this.application.getCollection('Common.Collections.TextArt').models,
|
var models = this.application.getCollection('Common.Collections.TextArt').models,
|
||||||
count = this.cmbTextArt.menuPicker.store.length;
|
count = this.cmbTextArt.menuPicker.store.length;
|
||||||
|
if (models.length<1) {
|
||||||
|
PE.getController('Main').fillTextArt(this.api.asc_getTextArtPreviews());
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (count>0 && count==models.length) {
|
if (count>0 && count==models.length) {
|
||||||
var data = this.cmbTextArt.menuPicker.store.models;
|
var data = this.cmbTextArt.menuPicker.store.models;
|
||||||
_.each(models, function(template, index){
|
_.each(models, function(template, index){
|
||||||
|
|
|
@ -1148,6 +1148,26 @@ define([
|
||||||
};
|
};
|
||||||
this.btnInsertChart.menu.on('show:before', onShowBefore);
|
this.btnInsertChart.menu.on('show:before', onShowBefore);
|
||||||
|
|
||||||
|
var onShowBeforeTextArt = function (menu) {
|
||||||
|
var collection = PE.getCollection('Common.Collections.TextArt');
|
||||||
|
if (collection.length<1)
|
||||||
|
PE.getController('Main').fillTextArt(me.api.asc_getTextArtPreviews());
|
||||||
|
me.btnInsertTextArt.textartPicker = new Common.UI.DataView({
|
||||||
|
el: $('#view-insert-art', menu.$el),
|
||||||
|
store: collection,
|
||||||
|
parentMenu: menu,
|
||||||
|
showLast: false,
|
||||||
|
itemTemplate: _.template('<div class="item-art"><img src="<%= imageUrl %>" id="<%= id %>" style="width:50px;height:50px;"></div>')
|
||||||
|
});
|
||||||
|
me.btnInsertTextArt.textartPicker.on('item:click', function (picker, item, record, e) {
|
||||||
|
if (record)
|
||||||
|
me.fireEvent('insert:textart', [record.get('data')]);
|
||||||
|
if (e.type !== 'click') menu.hide();
|
||||||
|
});
|
||||||
|
menu.off('show:before', onShowBeforeTextArt);
|
||||||
|
};
|
||||||
|
this.btnInsertTextArt.menu.on('show:before', onShowBeforeTextArt);
|
||||||
|
|
||||||
// set dataviews
|
// set dataviews
|
||||||
|
|
||||||
var _conf = this.mnuMarkersPicker.conf;
|
var _conf = this.mnuMarkersPicker.conf;
|
||||||
|
@ -1420,40 +1440,6 @@ define([
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
updateTextartMenu: function (collection) {
|
|
||||||
var me = this;
|
|
||||||
|
|
||||||
var btn = me.btnInsertTextArt;
|
|
||||||
if ( btn.textartPicker ) {
|
|
||||||
if ( btn.textartPicker.store.size() == collection.size() ) {
|
|
||||||
btn.textartPicker.store.each(function (model, index) {
|
|
||||||
model.set('imageUrl', collection.at(index).get('imageUrl'));
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
btn.textartPicker.store.reset( collection.models );
|
|
||||||
}
|
|
||||||
} else if (!this.binding.onShowBeforeTextArt) {
|
|
||||||
me.binding.onShowBeforeTextArt = function(menu) {
|
|
||||||
btn.textartPicker = new Common.UI.DataView({
|
|
||||||
el: $('#view-insert-art', btn.menu.$el),
|
|
||||||
store: collection,
|
|
||||||
parentMenu: btn.menu,
|
|
||||||
showLast: false,
|
|
||||||
itemTemplate: _.template('<div class="item-art"><img src="<%= imageUrl %>" id="<%= id %>" style="width:50px;height:50px;"></div>')
|
|
||||||
});
|
|
||||||
|
|
||||||
btn.textartPicker.on('item:click', function(picker, item, record, e) {
|
|
||||||
if (record)
|
|
||||||
me.fireEvent('insert:textart', [record.get('data')]);
|
|
||||||
|
|
||||||
if (e.type !== 'click') btn.menu.hide();
|
|
||||||
});
|
|
||||||
menu.off('show:before', me.binding.onShowBeforeTextArt);
|
|
||||||
};
|
|
||||||
me.btnInsertTextArt.menu.on('show:before', me.binding.onShowBeforeTextArt);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
updateAutoshapeMenu: function (menuShape, collection) {
|
updateAutoshapeMenu: function (menuShape, collection) {
|
||||||
var me = this;
|
var me = this;
|
||||||
var onShowAfter = function(menu) {
|
var onShowAfter = function(menu) {
|
||||||
|
|
Loading…
Reference in a new issue