[DE][PE] Fix loading color palettes in the toolbar menu.

This commit is contained in:
Julia Radzhabova 2017-04-24 14:41:51 +03:00
parent aa74d1271e
commit e2363e519a
4 changed files with 51 additions and 58 deletions

View file

@ -178,7 +178,6 @@ define([
// Create toolbar view // Create toolbar view
this.toolbar = this.createView('Toolbar'); this.toolbar = this.createView('Toolbar');
// this.toolbar.on('render:after', _.bind(this.onToolbarAfterRender, this));
me.toolbar.on('render:before', function (cmp) { me.toolbar.on('render:before', function (cmp) {
}); });
@ -186,7 +185,7 @@ define([
Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me)); Common.NotificationCenter.on('app:face', me.onAppShowed.bind(me));
}, },
onToolbarAfterRender: function(toolbar) { attachUIEvents: function(toolbar) {
/** /**
* UI Events * UI Events
*/ */
@ -2749,7 +2748,7 @@ define([
createDelayedElements: function() { createDelayedElements: function() {
this.toolbar.createDelayedElements(); this.toolbar.createDelayedElements();
this.onToolbarAfterRender(this.toolbar); this.attachUIEvents(this.toolbar);
}, },
onAppShowed: function (config) { onAppShowed: function (config) {

View file

@ -1015,49 +1015,6 @@ define([
this.mnuPageSize = this.btnPageSize.menu; this.mnuPageSize = this.btnPageSize.menu;
this.mnuColorSchema = this.btnColorSchemas.menu; this.mnuColorSchema = this.btnColorSchemas.menu;
//
// DataView and pickers
//
this.btnHighlightColor.on('render:after', function (btn) {
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', btn.cmpEl).append(colorVal);
btn.currentColor = 'FFFF00';
colorVal.css('background-color', '#' + btn.currentColor);
me.mnuHighlightColorPicker = new Common.UI.ColorPalette({
el: $('#id-toolbar-menu-highlight'),
value: 'FFFF00',
colors: [
'FFFF00', '00FF00', '00FFFF', 'FF00FF', '0000FF', 'FF0000', '00008B', '008B8B',
'006400', '800080', '8B0000', '808000', 'FFFFFF', 'D3D3D3', 'A9A9A9', '000000'
]
});
me.mnuHighlightColorPicker.select('FFFF00');
});
this.btnFontColor.on('render:after', function (btn) {
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', btn.cmpEl).append(colorVal);
colorVal.css('background-color', btn.currentColor || 'transparent');
me.mnuFontColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-fontcolor')
});
});
this.btnParagraphColor.on('render:after', function (btn) {
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', btn.cmpEl).append(colorVal);
colorVal.css('background-color', btn.currentColor || 'transparent');
me.mnuParagraphColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-paracolor'),
transparent: true
});
});
this.cmbFontSize = new Common.UI.ComboBox({ this.cmbFontSize = new Common.UI.ComboBox({
cls: 'input-group-nr', cls: 'input-group-nr',
menuStyle: 'min-width: 55px;', menuStyle: 'min-width: 55px;',
@ -1198,6 +1155,8 @@ define([
}); });
} }
this.on('render:after', _.bind(this.onToolbarAfterRender, this));
Common.NotificationCenter.on('app:ready', me.onAppReady.bind(this)); Common.NotificationCenter.on('app:ready', me.onAppReady.bind(this));
return this; return this;
@ -2026,6 +1985,38 @@ define([
}); });
}, },
onToolbarAfterRender: function(toolbar) {
// DataView and pickers
//
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', this.btnHighlightColor.cmpEl).append(colorVal);
this.btnHighlightColor.currentColor = 'FFFF00';
colorVal.css('background-color', '#' + this.btnHighlightColor.currentColor);
this.mnuHighlightColorPicker = new Common.UI.ColorPalette({
el: $('#id-toolbar-menu-highlight'),
colors: [
'FFFF00', '00FF00', '00FFFF', 'FF00FF', '0000FF', 'FF0000', '00008B', '008B8B',
'006400', '800080', '8B0000', '808000', 'FFFFFF', 'D3D3D3', 'A9A9A9', '000000'
]
});
this.mnuHighlightColorPicker.select('FFFF00');
colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', this.btnFontColor.cmpEl).append(colorVal);
colorVal.css('background-color', this.btnFontColor.currentColor || 'transparent');
this.mnuFontColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-fontcolor')
});
colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', this.btnParagraphColor.cmpEl).append(colorVal);
colorVal.css('background-color', this.btnParagraphColor.currentColor || 'transparent');
this.mnuParagraphColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-paracolor'),
transparent: true
});
},
updateMetricUnit: function () { updateMetricUnit: function () {
var items = this.btnPageMargins.menu.items; var items = this.btnPageMargins.menu.items;
for (var i = 0; i < items.length; i++) { for (var i = 0; i < items.length; i++) {

View file

@ -185,8 +185,6 @@ define([
// Create toolbar view // Create toolbar view
this.toolbar = this.createView('Toolbar'); this.toolbar = this.createView('Toolbar');
// this.toolbar.on('render:after', _.bind(this.onToolbarAfterRender, this));
var me = this; var me = this;
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));
@ -200,7 +198,7 @@ define([
}); });
}, },
onToolbarAfterRender: function(toolbar) { attachUIEvents: function(toolbar) {
/** /**
* UI Events * UI Events
*/ */
@ -2039,7 +2037,7 @@ define([
createDelayedElements: function() { createDelayedElements: function() {
this.toolbar.createDelayedElements(); this.toolbar.createDelayedElements();
this.onToolbarAfterRender(this.toolbar); this.attachUIEvents(this.toolbar);
}, },
onAppShowed: function (config) { onAppShowed: function (config) {

View file

@ -353,14 +353,6 @@ define([
{ template: _.template('<a id="id-toolbar-menu-new-fontcolor" style="padding-left:12px;">' + me.textNewColor + '</a>') } { template: _.template('<a id="id-toolbar-menu-new-fontcolor" style="padding-left:12px;">' + me.textNewColor + '</a>') }
] ]
}) })
}).on('render:after', function(btn) {
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', btn.cmpEl).append(colorVal);
colorVal.css('background-color', btn.currentColor || 'transparent');
me.mnuFontColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-fontcolor')
});
}); });
me.paragraphControls.push(me.btnFontColor); me.paragraphControls.push(me.btnFontColor);
@ -850,6 +842,8 @@ define([
}); });
this.lockToolbar(PE.enumLock.disableOnStart, true, {array: me.slideOnlyControls.concat(me.shapeControls)}); this.lockToolbar(PE.enumLock.disableOnStart, true, {array: me.slideOnlyControls.concat(me.shapeControls)});
this.on('render:after', _.bind(this.onToolbarAfterRender, this));
return this; return this;
}, },
@ -1410,6 +1404,17 @@ define([
}, },
onToolbarAfterRender: function(toolbar) {
// DataView and pickers
//
var colorVal = $('<div class="btn-color-value-line"></div>');
$('button:first-child', this.btnFontColor.cmpEl).append(colorVal);
colorVal.css('background-color', this.btnFontColor.currentColor || 'transparent');
this.mnuFontColorPicker = new Common.UI.ThemeColorPalette({
el: $('#id-toolbar-menu-fontcolor')
});
},
setApi: function (api) { setApi: function (api) {
this.api = api; this.api = api;