Refactoring loading textarts
This commit is contained in:
parent
8332c3b133
commit
e9bf021e17
|
@ -103,6 +103,7 @@ define([
|
|||
this.diagramEditor = null;
|
||||
this._isAddingShape = false;
|
||||
this.editMode = true;
|
||||
this.binding = {};
|
||||
|
||||
this.addListeners({
|
||||
'Toolbar': {
|
||||
|
@ -2562,8 +2563,7 @@ define([
|
|||
|
||||
fillTextArt: function() {
|
||||
if (!this.toolbar.btnInsertTextArt.rendered) return;
|
||||
|
||||
var me = this;
|
||||
|
||||
if (this.toolbar.mnuTextArtPicker) {
|
||||
var models = this.getApplication().getCollection('Common.Collections.TextArt').models,
|
||||
count = this.toolbar.mnuTextArtPicker.store.length;
|
||||
|
@ -2575,31 +2575,36 @@ define([
|
|||
} else {
|
||||
this.toolbar.mnuTextArtPicker.store.reset(models);
|
||||
}
|
||||
} else {
|
||||
this.toolbar.mnuTextArtPicker = new Common.UI.DataView({
|
||||
el: $('#id-toolbar-menu-insart'),
|
||||
store: this.getApplication().getCollection('Common.Collections.TextArt'),
|
||||
parentMenu: this.toolbar.btnInsertTextArt.menu,
|
||||
showLast: false,
|
||||
itemTemplate: _.template('<div class="item-art"><img src="<%= imageUrl %>" id="<%= id %>" style="width:50px;height:50px;"></div>')
|
||||
});
|
||||
} else if (!this.binding.onShowBeforeTextArt) {
|
||||
var me = this;
|
||||
me.binding.onShowBeforeTextArt = function(menu) {
|
||||
me.toolbar.mnuTextArtPicker = new Common.UI.DataView({
|
||||
el: $('#id-toolbar-menu-insart'),
|
||||
store: me.getApplication().getCollection('Common.Collections.TextArt'),
|
||||
parentMenu: menu,
|
||||
showLast: false,
|
||||
itemTemplate: _.template('<div class="item-art"><img src="<%= imageUrl %>" id="<%= id %>" style="width:50px;height:50px;"></div>')
|
||||
});
|
||||
|
||||
this.toolbar.mnuTextArtPicker.on('item:click', function(picker, item, record, e) {
|
||||
if (me.api) {
|
||||
if (record) {
|
||||
me.toolbar.fireEvent('inserttextart', me.toolbar);
|
||||
me.api.AddTextArt(record.get('data'));
|
||||
me.toolbar.mnuTextArtPicker.on('item:click', function(picker, item, record, e) {
|
||||
if (me.api) {
|
||||
if (record) {
|
||||
me.toolbar.fireEvent('inserttextart', me.toolbar);
|
||||
me.api.AddTextArt(record.get('data'));
|
||||
}
|
||||
|
||||
if (me.toolbar.btnInsertShape.pressed)
|
||||
me.toolbar.btnInsertShape.toggle(false, true);
|
||||
|
||||
if (e.type !== 'click')
|
||||
me.toolbar.btnInsertTextArt.menu.hide();
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertTextArt);
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art');
|
||||
}
|
||||
|
||||
if (me.toolbar.btnInsertShape.pressed)
|
||||
me.toolbar.btnInsertShape.toggle(false, true);
|
||||
|
||||
if (e.type !== 'click')
|
||||
me.toolbar.btnInsertTextArt.menu.hide();
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertTextArt);
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art');
|
||||
}
|
||||
});
|
||||
});
|
||||
menu.off('show:before', me.binding.onShowBeforeTextArt);
|
||||
};
|
||||
me.toolbar.btnInsertTextArt.menu.on('show:before', me.binding.onShowBeforeTextArt);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -985,15 +985,17 @@ define([
|
|||
},
|
||||
|
||||
createDelayedElements: function() {
|
||||
this._initSettings = false;
|
||||
this.createDelayedControls();
|
||||
this.UpdateThemeColors();
|
||||
this.fillTransform(this.api.asc_getPropertyEditorTextArts());
|
||||
this._initSettings = false;
|
||||
this.fillTextArt();
|
||||
},
|
||||
|
||||
fillTextArt: function() {
|
||||
if (this._initSettings) return;
|
||||
|
||||
var me = this;
|
||||
|
||||
if (!this.cmbTextArt) {
|
||||
this.cmbTextArt = new Common.UI.ComboDataView({
|
||||
itemWidth: 50,
|
||||
|
@ -1132,7 +1134,6 @@ define([
|
|||
this.colorsBack.on('select', _.bind(this.onColorsBackSelect, this));
|
||||
this.btnBackColor.menu.items[1].on('click', _.bind(this.addNewColor, this, this.colorsBack, this.btnBackColor));
|
||||
}
|
||||
|
||||
this.colorsBorder.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
|
||||
this.colorsBack.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
|
||||
this.colorsGrad.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
|
||||
|
|
|
@ -1294,6 +1294,7 @@ define([
|
|||
},
|
||||
|
||||
createDelayedElements: function() {
|
||||
this._initSettings = false;
|
||||
this.createDelayedControls();
|
||||
|
||||
var global_hatch_menu_map = [
|
||||
|
@ -1327,8 +1328,8 @@ define([
|
|||
this.PatternFillType = this.patternViewData[0].type;
|
||||
}
|
||||
this.UpdateThemeColors();
|
||||
this.fillTextArt();
|
||||
this.fillTransform(this.api.asc_getPropertyEditorTextArts());
|
||||
this._initSettings = false;
|
||||
},
|
||||
|
||||
onInitStandartTextures: function(texture) {
|
||||
|
@ -1395,6 +1396,7 @@ define([
|
|||
},
|
||||
|
||||
fillTextArt: function() {
|
||||
if (this._initSettings) return;
|
||||
var me = this;
|
||||
if (!this.cmbTextArt) {
|
||||
this.cmbTextArt = new Common.UI.ComboDataView({
|
||||
|
|
|
@ -113,6 +113,7 @@ define([
|
|||
me._state = {
|
||||
hasCollaborativeChanges: undefined
|
||||
};
|
||||
me.binding = {};
|
||||
|
||||
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(this));
|
||||
return this;
|
||||
|
@ -1461,21 +1462,25 @@ define([
|
|||
} else {
|
||||
btn.textartPicker.store.reset( collection.models );
|
||||
}
|
||||
} else {
|
||||
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>')
|
||||
});
|
||||
} 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')]);
|
||||
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();
|
||||
});
|
||||
if (e.type !== 'click') btn.menu.hide();
|
||||
});
|
||||
menu.off('show:before', me.binding.onShowBeforeTextArt);
|
||||
};
|
||||
me.btnInsertTextArt.menu.on('show:before', me.binding.onShowBeforeTextArt);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -173,6 +173,7 @@ define([
|
|||
pgorient: undefined,
|
||||
lock_doc: undefined
|
||||
};
|
||||
this.binding = {};
|
||||
|
||||
var checkInsertAutoshape = function(e, action) {
|
||||
var cmp = $(e.target),
|
||||
|
@ -2620,8 +2621,6 @@ define([
|
|||
fillTextArt: function() {
|
||||
if (!this.toolbar.btnInsertTextArt.rendered) return;
|
||||
|
||||
var me = this;
|
||||
|
||||
if ( this.toolbar.mnuTextArtPicker ) {
|
||||
var models = this.getApplication().getCollection('Common.Collections.TextArt').models,
|
||||
count = this.toolbar.mnuTextArtPicker.store.length;
|
||||
|
@ -2633,31 +2632,36 @@ define([
|
|||
} else {
|
||||
this.toolbar.mnuTextArtPicker.store.reset(models);
|
||||
}
|
||||
} else {
|
||||
this.toolbar.mnuTextArtPicker = new Common.UI.DataView({
|
||||
el: $('#id-toolbar-menu-insart'),
|
||||
store: this.getApplication().getCollection('Common.Collections.TextArt'),
|
||||
parentMenu: this.toolbar.btnInsertTextArt.menu,
|
||||
showLast: false,
|
||||
itemTemplate: _.template('<div class="item-art"><img src="<%= imageUrl %>" id="<%= id %>" style="width:50px;height:50px;"></div>')
|
||||
});
|
||||
} else if (!this.binding.onShowBeforeTextArt) {
|
||||
var me = this;
|
||||
me.binding.onShowBeforeTextArt = function(menu) {
|
||||
me.toolbar.mnuTextArtPicker = new Common.UI.DataView({
|
||||
el: $('#id-toolbar-menu-insart'),
|
||||
store: me.getApplication().getCollection('Common.Collections.TextArt'),
|
||||
parentMenu: menu,
|
||||
showLast: false,
|
||||
itemTemplate: _.template('<div class="item-art"><img src="<%= imageUrl %>" id="<%= id %>" style="width:50px;height:50px;"></div>')
|
||||
});
|
||||
|
||||
this.toolbar.mnuTextArtPicker.on('item:click',
|
||||
function(picker, item, record, e) {
|
||||
if (record) {
|
||||
me.toolbar.fireEvent('inserttextart', me.toolbar);
|
||||
me.api.asc_addTextArt(record.get('data'));
|
||||
me.toolbar.mnuTextArtPicker.on('item:click',
|
||||
function(picker, item, record, e) {
|
||||
if (record) {
|
||||
me.toolbar.fireEvent('inserttextart', me.toolbar);
|
||||
me.api.asc_addTextArt(record.get('data'));
|
||||
}
|
||||
if ( me.toolbar.btnInsertShape.pressed )
|
||||
me.toolbar.btnInsertShape.toggle(false, true);
|
||||
|
||||
if ( e.type !== 'click' )
|
||||
me.toolbar.btnInsertTextArt.menu.hide();
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertTextArt);
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art');
|
||||
}
|
||||
if ( me.toolbar.btnInsertShape.pressed )
|
||||
me.toolbar.btnInsertShape.toggle(false, true);
|
||||
|
||||
if ( e.type !== 'click' )
|
||||
me.toolbar.btnInsertTextArt.menu.hide();
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar, me.toolbar.btnInsertTextArt);
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Add Text Art');
|
||||
}
|
||||
);
|
||||
);
|
||||
menu.off('show:before', me.binding.onShowBeforeTextArt);
|
||||
};
|
||||
me.toolbar.btnInsertTextArt.menu.on('show:before', me.binding.onShowBeforeTextArt);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1298,6 +1298,7 @@ define([
|
|||
},
|
||||
|
||||
createDelayedElements: function() {
|
||||
this._initSettings = false;
|
||||
this.createDelayedControls();
|
||||
|
||||
var global_hatch_menu_map = [
|
||||
|
@ -1332,8 +1333,8 @@ define([
|
|||
}
|
||||
|
||||
this.UpdateThemeColors();
|
||||
this.fillTextArt();
|
||||
this.fillTransform(this.api.asc_getPropertyEditorTextArts());
|
||||
this._initSettings = false;
|
||||
},
|
||||
|
||||
onInitStandartTextures: function(texture) {
|
||||
|
@ -1399,8 +1400,8 @@ define([
|
|||
},
|
||||
|
||||
fillTextArt: function() {
|
||||
if (this._initSettings) return;
|
||||
var me = this;
|
||||
|
||||
if (!this.cmbTextArt) {
|
||||
this.cmbTextArt = new Common.UI.ComboDataView({
|
||||
itemWidth: 50,
|
||||
|
|
Loading…
Reference in a new issue