Refactoring textures loading

This commit is contained in:
Julia Radzhabova 2019-08-30 15:04:02 +03:00
parent c022b065a0
commit 2bce4a8971
6 changed files with 219 additions and 163 deletions

View file

@ -78,6 +78,7 @@ define([
this.imgprops = null;
this._sendUndoPoint = true;
this._sliderChanged = false;
this._texturearray = null;
this.txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt);
@ -1516,6 +1517,7 @@ define([
this.PatternFillType = this.patternViewData[0].type;
}
this.onInitStandartTextures();
this.onApiAutoShapes();
this.UpdateThemeColors();
},
@ -1523,7 +1525,20 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
me._texturearray = [];
_.each(texture, function(item){
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
}
if (!me._texturearray || me._texturearray.length<1) return;
if (!this._initSettings && !this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#shape-combo-fill-texture'),
template: _.template([
@ -1541,27 +1556,20 @@ define([
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
}
var texturearray = [];
_.each(texture, function(item){
texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
mnuTexturePicker.on('item:click', _.bind(me.onSelectTexture, me));
menu.off('show:before', onShowBefore);
};
this.textureMenu.on('show:before', onShowBefore);
}
},

View file

@ -76,6 +76,7 @@ define([
this._noApply = true;
this._sendUndoPoint = true;
this._sliderChanged = false;
this._texturearray = null;
this.txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt);
@ -1391,6 +1392,7 @@ define([
this.PatternFillType = this.patternViewData[0].type;
}
this.onInitStandartTextures();
this.onApiAutoShapes();
this.UpdateThemeColors();
},
@ -1398,7 +1400,20 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
me._texturearray = [];
_.each(texture, function(item){
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
}
if (!me._texturearray || me._texturearray.length<1) return;
if (!this._initSettings && !this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#shape-combo-fill-texture'),
template: _.template([
@ -1416,26 +1431,20 @@ define([
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
}
var texturearray = [];
_.each(texture, function(item){
texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
mnuTexturePicker.on('item:click', _.bind(me.onSelectTexture, me));
menu.off('show:before', onShowBefore);
};
this.textureMenu.on('show:before', onShowBefore);
}
},

View file

@ -73,6 +73,7 @@ define([
this._noApply = true;
this._sendUndoPoint = true;
this._sliderChanged = false;
this._texturearray = null;
this.FillItems = [];
@ -842,13 +843,27 @@ define([
this.PatternFillType = this.patternViewData[0].type;
}
this.onInitStandartTextures();
this.UpdateThemeColors();
},
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
me._texturearray = [];
_.each(texture, function(item){
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
}
if (!me._texturearray || me._texturearray.length<1) return;
if (!this._initSettings && !this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#slide-combo-fill-texture'),
template: _.template([
@ -866,26 +881,20 @@ define([
});
this.textureMenu.render($('#slide-combo-fill-texture'));
this.FillItems.push(this.btnTexture);
}
var texturearray = [];
_.each(texture, function(item){
texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-slide-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
mnuTexturePicker.on('item:click', _.bind(me.onSelectTexture, me));
menu.off('show:before', onShowBefore);
};
this.textureMenu.on('show:before', onShowBefore);
}
},

View file

@ -75,6 +75,7 @@ define([
this.shapeprops = null;
this._sendUndoPoint = true;
this._sliderChanged = false;
this._texturearray = null;
this.txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt);
@ -1328,6 +1329,7 @@ define([
this.PatternFillType = this.patternViewData[0].type;
}
this.UpdateThemeColors();
this.onInitStandartTextures();
this.fillTextArt();
this.fillTransform(this.api.asc_getPropertyEditorTextArts());
},
@ -1335,7 +1337,20 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
me._texturearray = [];
_.each(texture, function(item){
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
}
if (!me._texturearray || me._texturearray.length<1) return;
if (!this._initSettings && !this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#textart-combo-fill-texture'),
template: _.template([
@ -1353,25 +1368,20 @@ define([
});
this.textureMenu.render($('#textart-combo-fill-texture'));
this.lockedControls.push(this.btnTexture);
}
var texturearray = [];
_.each(texture, function(item){
texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
selected: false
});
});
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-textart-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
mnuTexturePicker.on('item:click', _.bind(me.onSelectTexture, me));
menu.off('show:before', onShowBefore);
};
this.textureMenu.on('show:before', onShowBefore);
}
},

View file

@ -77,6 +77,7 @@ define([
this.imgprops = null;
this._sendUndoPoint = true;
this._sliderChanged = false;
this._texturearray = null;
this.txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt);
@ -1415,6 +1416,7 @@ define([
this.PatternFillType = this.patternViewData[0].type;
}
this.onInitStandartTextures();
this.onApiAutoShapes();
this.UpdateThemeColors();
},
@ -1422,7 +1424,20 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
me._texturearray = [];
_.each(texture, function(item){
me._texturearray.push({
imageUrl: item.asc_getImage(),
name : me.textureNames[item.asc_getId()],
type : item.asc_getId(),
// allowSelected : false,
selected: false
});
});
}
if (!me._texturearray || me._texturearray.length<1) return;
if (!this._initSettings && !this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#shape-combo-fill-texture'),
template: _.template([
@ -1440,26 +1455,20 @@ define([
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
}
var texturearray = [];
_.each(texture, function(item){
texturearray.push({
imageUrl: item.asc_getImage(),
name : me.textureNames[item.asc_getId()],
type : item.asc_getId(),
// allowSelected : false,
selected: false
});
});
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
mnuTexturePicker.on('item:click', _.bind(me.onSelectTexture, me));
menu.off('show:before', onShowBefore);
};
this.textureMenu.on('show:before', onShowBefore);
}
},

View file

@ -76,6 +76,7 @@ define([
this.shapeprops = null;
this._sendUndoPoint = true;
this._sliderChanged = false;
this._texturearray = null;
this.txtPt = Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt);
@ -1333,6 +1334,7 @@ define([
}
this.UpdateThemeColors();
this.onInitStandartTextures();
this.fillTextArt();
this.fillTransform(this.api.asc_getPropertyEditorTextArts());
},
@ -1340,6 +1342,20 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
me._texturearray = [];
_.each(texture, function(item){
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
}
if (!me._texturearray || me._texturearray.length<1) return;
if (!this._initSettings && !this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#textart-combo-fill-texture'),
template: _.template([
@ -1358,24 +1374,19 @@ define([
this.textureMenu.render($('#textart-combo-fill-texture'));
this.lockedControls.push(this.btnTexture);
var texturearray = [];
_.each(texture, function(item){
texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
selected: false
});
});
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-textart-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
mnuTexturePicker.on('item:click', _.bind(me.onSelectTexture, me));
menu.off('show:before', onShowBefore);
};
this.textureMenu.on('show:before', onShowBefore);
}
},