[DE] Watermark: load text for different languages

This commit is contained in:
Julia Radzhabova 2019-05-08 14:38:39 +03:00
parent 82c4adf441
commit 8962ca6400
4 changed files with 97 additions and 12 deletions

View file

@ -90,7 +90,7 @@ define([
template: _.template([
'<span class="input-group combobox <%= cls %>" id="<%= id %>" style="<%= style %>">',
'<input type="text" class="form-control">',
'<input type="text" class="form-control" spellcheck="false">',
'<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret img-commonctrl"></span></button>',
'<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">',
'<% _.each(items, function(item) { %>',

View file

@ -6,17 +6,21 @@
<div id="watermark-radio-text"></div>
</td></tr>
<tr><td class="padding-large">
<table id="watermark-tbl-text" cols="1" style="margin-left: 22px;">
<table id="watermark-tbl-text" cols="2" style="margin-left: 22px;">
<tr>
<td class="padding-small">
<label style="display:block;" class="input-label" style=""><%= scope.textText %></label>
<td class="padding-small" style="width: 142px;">
<label style="display:block;" class="input-label"><%= scope.textLanguage %></label>
<div id="watermark-combo-lang" style="width: 100%;"></div>
</td>
<td class="padding-small" style="width: 215px; padding-left: 5px;">
<label style="display:block;" class="input-label"><%= scope.textText %></label>
<div id="watermark-combo-text" style="width: 100%;"></div>
</td>
</tr>
<tr>
<td class="padding-large">
<label style="display:block;" class="input-label" style=""><%= scope.textFont %></label>
<div id="watermark-fonts" class="input-row" style="display: inline-block; vertical-align: middle; margin-left: 2px;"></div>
<td class="padding-large" colspan="2">
<label style="display:block;" class="input-label"><%= scope.textFont %></label>
<div id="watermark-fonts" class="input-row" style="display: inline-block; vertical-align: middle;"></div>
<div id="watermark-font-size" class="input-row" style="display: inline-block; vertical-align: middle; margin-left: 2px;"></div>
<div id="watermark-textcolor" style="display: inline-block;margin-left: 6px;"></div>
<div id="watermark-bold" style="display: inline-block;margin-left: 2px;"></div><div id="watermark-italic" style="display: inline-block;margin-left: 6px;"></div>
@ -24,7 +28,7 @@
</td>
</tr>
<tr>
<td class="padding-small">
<td class="padding-small" colspan="2">
<label style="display:block;"><%= scope.textOpacity %></label>
<div style="display: inline-block; margin-top: 3px;">
<label id="watermark-lbl-opacity-start">0</label>
@ -35,7 +39,7 @@
</td>
</tr>
<tr>
<td>
<td colspan="2">
<label style="display:block;margin-bottom: 3px;"><%= scope.textLayout %></label>
<div id="watermark-radio-diag" style="display: inline-block;"></div>
<div id="watermark-radio-hor" style="display: inline-block;margin-left: 15px;"></div>

View file

@ -46,6 +46,37 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
'common/main/lib/view/AdvancedSettingsWindow'
], function (template) { 'use strict';
DE.Views.WatermarkText = new(function() {
var langs;
var _get = function() {
if (langs)
return langs;
langs = [];
try {
var langJson = Common.Utils.getConfigJson('resources/watermark/wm-text.json');
for (var lang in langJson) {
var val = Common.util.LanguageInfo.getLocalLanguageCode(lang);
if (val) {
langs.push({code: val, name: Common.util.LanguageInfo.getLocalLanguageName(val)[1], shortname: Common.util.LanguageInfo.getLocalLanguageName(val)[0], text: langJson[lang]});
}
}
langs.sort(function(a, b) {
if (a.shortname < b.shortname) return -1;
if (a.shortname > b.shortname) return 1;
return 0;
});
}
catch (e) {
}
return langs;
};
return {
get: _get
};
})();
DE.Views.WatermarkSettingsDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({
options: {
contentWidth: 400,
@ -164,13 +195,28 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
this.imageControls.push(this.cmbScale);
// Text watermark
this.cmbLang = new Common.UI.ComboBox({
el : $('#watermark-combo-lang'),
cls : 'input-group-nr',
editable : false,
menuStyle : 'min-width: 100%;max-height: 210px;',
scrollAlwaysVisible: true,
data : []
}).on('selected', _.bind(function(combo, record) {
this.loadWMText(record);
}, this));
this.textControls.push(this.cmbLang);
this.cmbText = new Common.UI.ComboBox({
el : $('#watermark-combo-text'),
cls : 'input-group-nr',
menuStyle : 'min-width: 100%;',
data : []
menuStyle : 'min-width: 100%;max-height: 210px;',
scrollAlwaysVisible: true,
displayField: 'value',
data : [{value: "ASAP"}, {value: "CONFIDENTIAL"}, {value: "COPY"}, {value: "DO NOT COPY"}, {value: "DRAFT"}, {value: "ORIGINAL"}, {value: "PERSONAL"}, {value: "SAMPLE"}, {value: "TOP SECRET"}, {value: "URGENT"} ]
}).on('selected', _.bind(function(combo, record) {
}, this));
this.cmbText.setValue(this.cmbText.options.data[0].value);
this.textControls.push(this.cmbText);
this.cmbFonts = new Common.UI.ComboBoxFonts({
@ -392,7 +438,33 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments);
},
loadLanguages: function() {
this.languages = DE.Views.WatermarkText.get();
var data = [];
this.languages && this.languages.forEach(function(item) {
data.push({displayValue: item.name, value: item.shortname, wmtext: item.text});
});
this.cmbLang.setData(data);
if (data.length) {
this.cmbLang.setValue('en', data[0].value);
this.loadWMText(this.cmbLang.getSelectedRecord());
} else
this.cmbLang.setDisabled(true);
},
loadWMText: function(record) {
if (!record) return;
var data = [];
record.wmtext.forEach(function(item) {
data.push({value: item});
});
this.cmbText.setData(data);
this.cmbText.setValue(data[0].value);
},
_setDefaults: function (props) {
this.loadLanguages();
if (props) {
var val = props.get_Alias();
this.txtName.setValue(val ? val : '');
@ -460,6 +532,7 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
_.each(this.textControls, function(item) {
item.setDisabled(disable);
});
this.cmbLang.setDisabled(disable || this.languages.length<1);
},
onDlgBtnClick: function(event) {
@ -495,7 +568,8 @@ define(['text!documenteditor/main/app/template/WatermarkSettings.template',
cancelButtonText: 'Cancel',
okButtonText: 'Ok',
textColor: 'Text color',
textNewColor: 'Add New Custom Color'
textNewColor: 'Add New Custom Color',
textLanguage: 'Language'
}, DE.Views.WatermarkSettingsDialog || {}))
});

View file

@ -0,0 +1,7 @@
{
"en": ["ASAP", "CONFIDENTIAL", "COPY", "DO NOT COPY", "DRAFT", "ORIGINAL", "PERSONAL", "SAMPLE", "TOP SECRET", "URGENT" ],
"ru": ["ДЛЯ СЛУЖЕБНОГО ПОЛЬЗОВАНИЯ", "ДСП", "КОПИРОВАТЬ НЕ РАЗРЕШАЕТСЯ", "КОПИЯ", "ЛИЧНОЕ", "ОБРАЗЕЦ", "ОРИГИНАЛ", "СЕКРЕТНО", "СОВ. СЕКРЕТНО", "СОВЕРШЕННО СЕКРЕТНО", "СРОЧНО", "ЧЕРНОВИК"],
"de": ["BEISPIEL", "DRINGEND", "ENTWURF", "KOPIE", "NICHT KOPIEREN", "ORIGINAL", "PERSÖNLICH", "STRENG VERTRAULICH", "VERTRAULICH"],
"es": ["BORRADOR", "CONFIDENCIAL", "COPIA", "EJEMPLO", "NO COPIAR", "ORIGINAL", "PERSONAL", "PRIORITARIO", "ULTRASECRETO", "URGENTE"],
"fr": ["BROUILLON", "CONFID", "COPIE", "DOCUMENT INTERNE", "EXEMPLE", "HAUTEMENT CONFIDENTIEL", "IMPORTANT", "NE PAS DIFFUSER", "NE PAS DISTRIB", "NE PAS DUPLIQUER", "ORIG", "PERSONNEL", "SPECIMEN", "TRES URGENT", "URGENT"]
}