Symbol table refactoring

This commit is contained in:
Julia Radzhabova 2019-11-11 17:48:09 +03:00
parent 28861851fb
commit 5fba110d35
2 changed files with 34 additions and 29 deletions

View file

@ -350,6 +350,7 @@ define([
Common.Views.SymbolTableDialog = Common.UI.Window.extend(_.extend({
options: {
width: 450,
height: 395,
style: 'min-width: 230px;',
cls: 'modal-dlg',
buttons: ['ok', 'cancel']
@ -413,6 +414,7 @@ define([
this.options.tpl = _.template(this.template)(this.options);
this.api = this.options.api;
this.type = this.options.type || 0; // 0 - close on OK, single adding symbol
var filter = Common.localStorage.getKeysFilter();
this.appPrefix = (filter && filter.length) ? filter.split(',')[0] : '';
@ -619,13 +621,6 @@ define([
Common.UI.Window.prototype.close.apply(this, arguments);
},
setSettings: function (props) {
},
getSettings: function () {
return this.getPasteSymbol(this.$window.find('.cell-selected').attr('id'));
},
getPasteSymbol: function(cellId) {
var bUpdateRecents = cellId[0] === 'c';
var sFont;
@ -649,14 +644,15 @@ define([
_handleInput: function(state) {
var settings = this.getPasteSymbol(this.$window.find('.cell-selected').attr('id'));
if (state=='ok') {
settings.updateRecents && this.checkRecent(nCurrentSymbol, settings.font);
settings.updateRecents && this.updateRecents();
}
if (this.options.handler) {
this.options.handler.call(this, this, state, settings);
}
if (state=='ok') {
settings.updateRecents && this.checkRecent(nCurrentSymbol, settings.font);
settings.updateRecents && this.updateRecents();
if (this.type)
return;
}
this.close();
},
@ -877,10 +873,14 @@ define([
},
cellDblClickHandler: function (e){
var settings = this.getPasteSymbol($(e.target).attr('id'));
settings.updateRecents && this.checkRecent(nCurrentSymbol, settings.font);
settings.updateRecents && this.updateView(false, undefined, undefined, true);
this.fireEvent('symbol:dblclick', [this, settings]);
if (!this.type)
this._handleInput('ok');
else {
var settings = this.getPasteSymbol($(e.target).attr('id'));
settings.updateRecents && this.checkRecent(nCurrentSymbol, settings.font);
settings.updateRecents && this.updateView(false, undefined, undefined, true);
this.fireEvent('symbol:dblclick', this, settings);
}
},
updateRecents: function(){
@ -1149,8 +1149,8 @@ define([
}
}
else if(value === 13){//enter
this.checkRecent(nCurrentSymbol, aFontSelects[nCurrentFont].displayName);
this.fireEvent('symbol:dblclick', {font: aFontSelects[nCurrentFont].displayName, symbol: this.encodeSurrogateChar(nCurrentSymbol)});
this.checkRecent(nCurrentSymbol, aFontSelects[nCurrentFont].displayValue);
this.fireEvent('symbol:dblclick', this, {font: aFontSelects[nCurrentFont].displayValue, symbol: this.encodeSurrogateChar(nCurrentSymbol)});
}
else{
bFill = false;
@ -1207,7 +1207,7 @@ define([
}
}
else if(value === 13){//enter
this.fireEvent('symbol:dblclick', {font: aFontSelects[nFontNameRecent].displayName, symbol: this.encodeSurrogateChar(nCurrentSymbol)});
this.fireEvent('symbol:dblclick', this, {font: aFontSelects[nFontNameRecent].displayValue, symbol: this.encodeSurrogateChar(nCurrentSymbol)});
}
else{
bFill = false;

View file

@ -2478,17 +2478,21 @@ define([
if (this.api) {
var me = this,
win = new Common.Views.SymbolTableDialog({
api: me.api,
handler: function(dlg, result) {
if (result == 'ok') {
var settings = dlg.getSettings();
me.api.pluginMethod_PasteHtml("<span style=\"font-family:'" + settings.font + "'\">" + settings.symbol + "</span>");
api: me.api,
// modal: false,
// type: 1,
// buttons: [{value: 'ok', caption: this.textInsert}, 'close'],
handler: function(dlg, result, settings) {
if (result == 'ok') {
me.api.pluginMethod_PasteHtml("<span style=\"font-family:'" + settings.font + "'\">" + settings.symbol + "</span>");
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
});
});
win.show();
// win.setSettings();
win.on('symbol:dblclick', function(cmp, settings) {
me.api.pluginMethod_PasteHtml("<span style=\"font-family:'" + settings.font + "'\">" + settings.symbol + "</span>");
});
}
Common.NotificationCenter.trigger('edit:complete', this.toolbar, this.toolbar.btnInsertSymbol);
},
@ -3291,7 +3295,8 @@ define([
confirmAddFontName: 'The font you are going to save is not available on the current device.<br>The text style will be displayed using one of the device fonts, the saved font will be used when it is available.<br>Do you want to continue?',
notcriticalErrorTitle: 'Warning',
txtMarginsW: 'Left and right margins are too high for a given page wight',
txtMarginsH: 'Top and bottom margins are too high for a given page height'
txtMarginsH: 'Top and bottom margins are too high for a given page height',
textInsert: 'Insert'
}, DE.Controllers.Toolbar || {}));
});