[DE] Add settings for check box. Refactoring symbol table
This commit is contained in:
parent
01ff598622
commit
475e9c0306
|
@ -453,6 +453,15 @@ define([
|
|||
var init = (aFontSelects.length<1);
|
||||
init && this.initFonts();
|
||||
|
||||
if (options.font) {
|
||||
for(var i = 0; i < aFontSelects.length; ++i){
|
||||
if(aFontSelects[i].displayValue === options.font){
|
||||
nCurrentFont = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nCurrentFont < 0)
|
||||
nCurrentFont = 0;
|
||||
|
||||
|
@ -477,6 +486,10 @@ define([
|
|||
nCurrentSymbol = aRanges[0].Start;
|
||||
}
|
||||
|
||||
if (options.code) {
|
||||
nCurrentSymbol = options.code;
|
||||
}
|
||||
|
||||
if (init && this.options.lang && this.options.lang != 'en') {
|
||||
var me = this;
|
||||
loadTranslation(this.options.lang, function(){
|
||||
|
@ -526,7 +539,6 @@ define([
|
|||
for(var key in oFontsByName){
|
||||
if(oFontsByName.hasOwnProperty(key)){
|
||||
data.push(oFontsByName[key]);
|
||||
data[data.length-1].value = i++;
|
||||
data[data.length-1].displayValue = oFontsByName[key].m_wsFontName;
|
||||
}
|
||||
}
|
||||
|
@ -534,6 +546,10 @@ define([
|
|||
//initialize params
|
||||
aFontSelects = data;
|
||||
aFontSelects.sort(function(a, b){return (a.displayValue.toLowerCase() > b.displayValue.toLowerCase()) ? 1 : -1;});
|
||||
for(i = 0; i < aFontSelects.length; ++i){
|
||||
aFontSelects[i].value = i;
|
||||
}
|
||||
|
||||
if(!oFontsByName[sInitFont]){
|
||||
if(oFontsByName['Cambria Math']){
|
||||
sInitFont = 'Cambria Math';
|
||||
|
@ -679,7 +695,7 @@ define([
|
|||
var nFontId = parseInt(cellId.split('_')[2]);
|
||||
sFont = aFontSelects[nFontId].displayValue;
|
||||
}
|
||||
return {font: sFont, symbol: this.encodeSurrogateChar(nCurrentSymbol), updateRecents: bUpdateRecents};
|
||||
return {font: sFont, symbol: this.encodeSurrogateChar(nCurrentSymbol), code: nCurrentSymbol, updateRecents: bUpdateRecents};
|
||||
},
|
||||
|
||||
onBtnClick: function(event) {
|
||||
|
@ -927,7 +943,7 @@ define([
|
|||
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);
|
||||
this.fireEvent('symbol:dblclick', this, 'ok', settings);
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1735,7 +1735,8 @@ define([
|
|||
(new DE.Views.ControlSettingsDialog({
|
||||
props: props,
|
||||
api: me.api,
|
||||
lang: me._state.lang,
|
||||
controlLang: me._state.lang,
|
||||
interfaceLang: me.mode.lang,
|
||||
handler: function(result, value) {
|
||||
if (result == 'ok') {
|
||||
me.api.asc_SetContentControlProperties(value, id);
|
||||
|
@ -2504,7 +2505,7 @@ define([
|
|||
}
|
||||
});
|
||||
win.show();
|
||||
win.on('symbol:dblclick', function(cmp, settings) {
|
||||
win.on('symbol:dblclick', function(cmp, result, settings) {
|
||||
me.api.pluginMethod_PasteHtml("<span style=\"font-family:'" + settings.font + "'\">" + settings.symbol + "</span>");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -115,4 +115,32 @@
|
|||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div id="id-adv-control-settings-checkbox" class="settings-panel">
|
||||
<div class="inner-content">
|
||||
<table cols="3" style="width: auto;">
|
||||
<tr>
|
||||
<td class="padding-small">
|
||||
<label class="input-label" style="margin-right: 10px;"><%= scope.textChecked %></label>
|
||||
</td>
|
||||
<td class="padding-small">
|
||||
<div id="control-settings-input-checked" style="margin-right: 10px;"></div>
|
||||
</td>
|
||||
<td class="padding-small">
|
||||
<button type="button" class="btn btn-text-default" id="control-settings-btn-checked-edit" style="min-width:86px;"><%= scope.textChange %></button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding-small">
|
||||
<label class="input-label" style="margin-right: 10px;"><%= scope.textUnchecked %></label>
|
||||
</td>
|
||||
<td class="padding-small">
|
||||
<div id="control-settings-input-unchecked" style="margin-right: 10px;"></div>
|
||||
</td>
|
||||
<td class="padding-small">
|
||||
<button type="button" class="btn btn-text-default" id="control-settings-btn-unchecked-edit" style="min-width:86px;"><%= scope.textChange %></button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -44,6 +44,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
'common/main/lib/component/CheckBox',
|
||||
'common/main/lib/component/InputField',
|
||||
'common/main/lib/view/AdvancedSettingsWindow',
|
||||
'common/main/lib/view/SymbolTableDialog',
|
||||
'documenteditor/main/app/view/EditListItemDialog'
|
||||
], function (contentTemplate) { 'use strict';
|
||||
|
||||
|
@ -64,7 +65,8 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
{panelId: 'id-adv-control-settings-general', panelCaption: this.strGeneral},
|
||||
{panelId: 'id-adv-control-settings-lock', panelCaption: this.textLock},
|
||||
{panelId: 'id-adv-control-settings-list', panelCaption: this.textCombobox},
|
||||
{panelId: 'id-adv-control-settings-date', panelCaption: this.textDate}
|
||||
{panelId: 'id-adv-control-settings-date', panelCaption: this.textDate},
|
||||
{panelId: 'id-adv-control-settings-checkbox',panelCaption: this.textCheckbox}
|
||||
],
|
||||
contentTemplate: _.template(contentTemplate)({
|
||||
scope: this
|
||||
|
@ -226,6 +228,39 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
});
|
||||
// this.listFormats.on('item:select', _.bind(this.onSelectFormat, this));
|
||||
|
||||
// Check Box
|
||||
this.txtChecked = new Common.UI.InputField({
|
||||
el : $('#control-settings-input-checked'),
|
||||
allowBlank : true,
|
||||
validateOnChange: false,
|
||||
validateOnBlur: false,
|
||||
style : 'width: 30px;',
|
||||
value : ''
|
||||
});
|
||||
this.txtChecked._input.attr('disabled', true);
|
||||
this.txtChecked._input.css({'text-align': 'center', 'font-size': '16px'});
|
||||
|
||||
this.txtUnchecked = new Common.UI.InputField({
|
||||
el : $('#control-settings-input-unchecked'),
|
||||
allowBlank : true,
|
||||
validateOnChange: false,
|
||||
validateOnBlur: false,
|
||||
style : 'width: 30px;',
|
||||
value : ''
|
||||
});
|
||||
this.txtUnchecked._input.attr('disabled', true);
|
||||
this.txtUnchecked._input.css({'text-align': 'center', 'font-size': '16px'});
|
||||
|
||||
this.btnEditChecked = new Common.UI.Button({
|
||||
el: $('#control-settings-btn-checked-edit')
|
||||
});
|
||||
this.btnEditChecked.on('click', _.bind(this.onEditCheckbox, this, true));
|
||||
|
||||
this.btnEditUnchecked = new Common.UI.Button({
|
||||
el: $('#control-settings-btn-unchecked-edit')
|
||||
});
|
||||
this.btnEditUnchecked.on('click', _.bind(this.onEditCheckbox, this, false));
|
||||
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
|
@ -320,7 +355,7 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
if (type == Asc.c_oAscContentControlSpecificType.DateTime) {
|
||||
var specProps = props.get_DateTimePr();
|
||||
if (specProps) {
|
||||
var lang = specProps.get_LangId() || this.options.lang;
|
||||
var lang = specProps.get_LangId() || this.options.controlLang;
|
||||
if (lang) {
|
||||
var item = this.cmbLang.store.findWhere({value: lang});
|
||||
item = item ? item.get('value') : 0x0409;
|
||||
|
@ -335,6 +370,25 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
}
|
||||
}
|
||||
|
||||
// for check box
|
||||
this.btnsCategory[4].setVisible(type == Asc.c_oAscContentControlSpecificType.CheckBox);
|
||||
if (type == Asc.c_oAscContentControlSpecificType.CheckBox) {
|
||||
var specProps = props.get_CheckBoxPr();
|
||||
if (specProps) {
|
||||
var code = specProps.get_CheckedSymbol(),
|
||||
font = specProps.get_CheckedFont();
|
||||
font && this.txtChecked.cmpEl.css('font-family', font);
|
||||
code && this.txtChecked.setValue(String.fromCharCode(code));
|
||||
this.checkedBox = {code: code, font: font};
|
||||
|
||||
code = specProps.get_UncheckedSymbol();
|
||||
font = specProps.get_UncheckedFont();
|
||||
font && this.txtUnchecked.cmpEl.css('font-family', font);
|
||||
code && this.txtUnchecked.setValue(String.fromCharCode(code));
|
||||
this.uncheckedBox = {code: code, font: font};
|
||||
}
|
||||
}
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
},
|
||||
|
@ -377,6 +431,22 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
// props.set_DateFormat(rec.get('format'));
|
||||
// }
|
||||
|
||||
// for check box
|
||||
if (this.type == Asc.c_oAscContentControlSpecificType.CheckBox) {
|
||||
if (this.checkedBox && this.checkedBox.changed || this.uncheckedBox && this.uncheckedBox.changed) {
|
||||
var specProps = new AscCommon.CSdtCheckBoxPr();
|
||||
if (this.checkedBox) {
|
||||
specProps.put_CheckedSymbol(this.checkedBox.code);
|
||||
specProps.put_CheckedFont(this.checkedBox.font);
|
||||
}
|
||||
if (this.uncheckedBox) {
|
||||
specProps.put_UncheckedSymbol(this.uncheckedBox.code);
|
||||
specProps.put_UncheckedFont(this.uncheckedBox.font);
|
||||
}
|
||||
props.put_CheckBoxPr(specProps);
|
||||
}
|
||||
}
|
||||
|
||||
return props;
|
||||
},
|
||||
|
||||
|
@ -509,6 +579,34 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
// this.onSelectFormat(this.listFormats, null, rec);
|
||||
},
|
||||
|
||||
onEditCheckbox: function(checked) {
|
||||
if (this.api) {
|
||||
var me = this,
|
||||
props = (checked) ? me.checkedBox : me.uncheckedBox,
|
||||
cmp = (checked) ? me.txtChecked : me.txtUnchecked,
|
||||
handler = function(dlg, result, settings) {
|
||||
if (result == 'ok') {
|
||||
props.changed = true;
|
||||
props.code = settings.code;
|
||||
props.font = settings.font;
|
||||
props.font && cmp.cmpEl.css('font-family', props.font);
|
||||
settings.symbol && cmp.setValue(settings.symbol);
|
||||
}
|
||||
},
|
||||
win = new Common.Views.SymbolTableDialog({
|
||||
api: me.api,
|
||||
lang: me.options.interfaceLang,
|
||||
modal: true,
|
||||
type: 0,
|
||||
font: props.font,
|
||||
code: props.code,
|
||||
handler: handler
|
||||
});
|
||||
win.show();
|
||||
win.on('symbol:dblclick', handler);
|
||||
}
|
||||
},
|
||||
|
||||
textTitle: 'Content Control Settings',
|
||||
textName: 'Title',
|
||||
textTag: 'Tag',
|
||||
|
@ -534,7 +632,10 @@ define([ 'text!documenteditor/main/app/template/ControlSettingsDialog.template',
|
|||
textValue: 'Value',
|
||||
textDate: 'Date Format',
|
||||
textLang: 'Language',
|
||||
textFormat: 'Formats'
|
||||
textFormat: 'Formats',
|
||||
textCheckbox: 'Check box',
|
||||
textChecked: 'Checked symbol',
|
||||
textUnchecked: 'Unchecked symbol'
|
||||
|
||||
}, DE.Views.ControlSettingsDialog || {}))
|
||||
});
|
|
@ -1843,7 +1843,7 @@ define([
|
|||
}
|
||||
});
|
||||
win.show();
|
||||
win.on('symbol:dblclick', function(cmp, settings) {
|
||||
win.on('symbol:dblclick', function(cmp, result, settings) {
|
||||
me.api.pluginMethod_PasteHtml("<span style=\"font-family:'" + settings.font + "'\">" + settings.symbol + "</span>");
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2781,7 +2781,7 @@ define([
|
|||
}
|
||||
});
|
||||
win.show();
|
||||
win.on('symbol:dblclick', function(cmp, settings) {
|
||||
win.on('symbol:dblclick', function(cmp, result, settings) {
|
||||
me.api.pluginMethod_PasteHtml("<span style=\"font-family:'" + settings.font + "'\">" + settings.symbol + "</span>");
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue