refactoring

This commit is contained in:
Maxim Kadushkin 2017-04-25 19:56:17 +03:00
parent e1385f1c11
commit fe3bd89aa9
3 changed files with 49 additions and 56 deletions

View file

@ -723,12 +723,11 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.NotificationCenter.trigger('app:ready', this.appOptions);
var me = this, var me = this,
value; value;
me._isDocReady = true; me._isDocReady = true;
Common.NotificationCenter.trigger('app:ready', this.appOptions);
me.api.SetDrawingFreeze(false); me.api.SetDrawingFreeze(false);
me.hidePreloader(); me.hidePreloader();

View file

@ -2091,9 +2091,7 @@ define([
} }
} }
(new Promise(function(accept) { Common.Utils.asyncCall(function () {
accept();
})).then(function () {
if ( config.isEdit ) { if ( config.isEdit ) {
me.toolbar.onAppReady(config); me.toolbar.onAppReady(config);
} }

View file

@ -1041,61 +1041,57 @@ define([
onAppReady: function (config) { onAppReady: function (config) {
var me = this; var me = this;
(new Promise( function(resolve, reject) { if (!config.isEdit) return;
resolve();
})).then(function () {
if ( !config.isEdit ) return;
me.btnsInsertImage.forEach(function (btn) { me.btnsInsertImage.forEach(function (btn) {
btn.updateHint(me.tipInsertImage); btn.updateHint(me.tipInsertImage);
btn.setMenu( btn.setMenu(
new Common.UI.Menu({ new Common.UI.Menu({
items: [ items: [
{ caption: me.mniImageFromFile, value: 'file' }, {caption: me.mniImageFromFile, value: 'file'},
{ caption: me.mniImageFromUrl, value: 'url' } {caption: me.mniImageFromUrl, value: 'url'}
] ]
}).on('item:click', function (menu, item, e) { }).on('item:click', function (menu, item, e) {
me.fireEvent('insert:image', [item.value]); me.fireEvent('insert:image', [item.value]);
}) })
); );
}); });
me.btnsInsertText.forEach(function (btn) { me.btnsInsertText.forEach(function (btn) {
btn.updateHint(me.tipInsertText); btn.updateHint(me.tipInsertText);
btn.setMenu( btn.setMenu(
new Common.UI.Menu({ new Common.UI.Menu({
items : [ items: [
{caption: me.textInsText, value: 'text'}, {caption: me.textInsText, value: 'text'},
{caption: me.textInsTextArt, value: 'art', {caption: me.textInsTextArt, value: 'art',
menu: new Common.UI.Menu({ menu: new Common.UI.Menu({
menuAlign: 'tl-tr', menuAlign: 'tl-tr',
cls: 'menu-shapes', cls: 'menu-shapes',
items: [ items: [
{ template: _.template('<div class="view-insert-art" style="width: 239px; margin-left: 5px;"></div>') } {template: _.template('<div class="view-insert-art" style="width: 239px; margin-left: 5px;"></div>')}
] ]
}) })
} }
] ]
}).on('item:click', function (menu, item, e) { }).on('item:click', function (menu, item, e) {
if ( item.value == 'text' ) if (item.value == 'text')
me.fireEvent('insert:text', ['begin']); me.fireEvent('insert:text', ['begin']);
}) })
); );
btn.on('click', function (btn, e) { btn.on('click', function (btn, e) {
me.fireEvent('insert:text', [btn.pressed?'begin':'end']); me.fireEvent('insert:text', [btn.pressed ? 'begin' : 'end']);
});
}); });
});
me.btnsInsertShape.forEach(function (btn) { me.btnsInsertShape.forEach(function (btn) {
btn.updateHint(me.tipInsertShape); btn.updateHint(me.tipInsertShape);
btn.setMenu( btn.setMenu(
new Common.UI.Menu({ new Common.UI.Menu({
cls: 'menu-shapes' cls: 'menu-shapes'
}).on('hide:after', function (e) { }).on('hide:after', function (e) {
me.fireEvent('insert:shape', ['menu:hide']); me.fireEvent('insert:shape', ['menu:hide']);
}) })
); );
});
}); });
}, },