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,29 +1525,9 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#shape-combo-fill-texture'),
template: _.template([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
}
var texturearray = [];
me._texturearray = [];
_.each(texture, function(item){
texturearray.push({
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
@ -1553,15 +1535,41 @@ define([
selected: false
});
});
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
}
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([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
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,28 +1400,9 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#shape-combo-fill-texture'),
template: _.template([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
}
var texturearray = [];
me._texturearray = [];
_.each(texture, function(item){
texturearray.push({
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
@ -1427,15 +1410,41 @@ define([
selected: false
});
});
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
}
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([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
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,34 +843,16 @@ 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) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#slide-combo-fill-texture'),
template: _.template([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-slide-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#slide-combo-fill-texture'));
this.FillItems.push(this.btnTexture);
}
var texturearray = [];
me._texturearray = [];
_.each(texture, function(item){
texturearray.push({
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
@ -877,15 +860,41 @@ define([
selected: false
});
});
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-slide-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
}
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([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-slide-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#slide-combo-fill-texture'));
this.FillItems.push(this.btnTexture);
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-slide-menu-texture'),
restoreHeight: 174,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
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,43 +1337,51 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#textart-combo-fill-texture'),
template: _.template([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-textart-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#textart-combo-fill-texture'));
this.lockedControls.push(this.btnTexture);
}
var texturearray = [];
me._texturearray = [];
_.each(texture, function(item){
texturearray.push({
me._texturearray.push({
imageUrl: item.get_image(),
name : me.textureNames[item.get_id()],
type : item.get_id(),
// allowSelected : false,
selected: false
});
});
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-textart-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
itemTemplate: _.template('<div><img src="<%= imageUrl %>" id="<%= id %>"></div>')
}
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([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-textart-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#textart-combo-fill-texture'));
this.lockedControls.push(this.btnTexture);
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-textart-menu-texture'),
restoreHeight: 174,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
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,28 +1424,9 @@ define([
onInitStandartTextures: function(texture) {
var me = this;
if (texture && texture.length>0){
if (!this.btnTexture) {
this.btnTexture = new Common.UI.ComboBox({
el: $('#shape-combo-fill-texture'),
template: _.template([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
}
var texturearray = [];
me._texturearray = [];
_.each(texture, function(item){
texturearray.push({
me._texturearray.push({
imageUrl: item.asc_getImage(),
name : me.textureNames[item.asc_getId()],
type : item.asc_getId(),
@ -1451,15 +1434,41 @@ define([
selected: false
});
});
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
showLast: false,
store: new Common.UI.DataViewStore(texturearray),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
}
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([
'<div class="input-group combobox combo-dataview-menu input-group-nr dropdown-toggle" tabindex="0" data-toggle="dropdown">',
'<div class="form-control text" style="width: 90px;">' + this.textSelectTexture + '</div>',
'<div style="display: table-cell;"></div>',
'<button type="button" class="btn btn-default"><span class="caret img-commonctrl"></span></button>',
'</div>'
].join(''))
});
mnuTexturePicker.on('item:click', _.bind(this.onSelectTexture, this));
this.textureMenu = new Common.UI.Menu({
items: [
{ template: _.template('<div id="id-shape-menu-texture" style="width: 233px; margin: 0 5px;"></div>') }
]
});
this.textureMenu.render($('#shape-combo-fill-texture'));
this.fillControls.push(this.btnTexture);
var onShowBefore = function(menu) {
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-shape-menu-texture'),
restoreHeight: 174,
parentMenu: menu,
showLast: false,
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div class="item-texture"><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
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: menu,
showLast: false,
store: new Common.UI.DataViewStore(me._texturearray || []),
itemTemplate: _.template('<div><img src="<%= imageUrl %>" id="<%= id %>"></div>')
});
});
var mnuTexturePicker = new Common.UI.DataView({
el: $('#id-textart-menu-texture'),
restoreHeight: 174,
parentMenu: me.textureMenu,
showLast: false,
store: new Common.UI.DataViewStore(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);
}
},