Merge branch 'feature/watermark' into develop
This commit is contained in:
commit
152a8d53f3
|
@ -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) { %>',
|
||||
|
|
|
@ -517,6 +517,7 @@
|
|||
.button-normal-icon(btn-cell-group, 59, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-cell-ungroup, 60, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-to-columns, 61, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-watermark, 63, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-color-schema, 64, @toolbar-big-icon-size);
|
||||
|
||||
.item-shape {
|
||||
|
|
|
@ -55,7 +55,8 @@ define([
|
|||
'documenteditor/main/app/view/PageSizeDialog',
|
||||
'documenteditor/main/app/controller/PageLayout',
|
||||
'documenteditor/main/app/view/CustomColumnsDialog',
|
||||
'documenteditor/main/app/view/ControlSettingsDialog'
|
||||
'documenteditor/main/app/view/ControlSettingsDialog',
|
||||
'documenteditor/main/app/view/WatermarkSettingsDialog'
|
||||
], function () {
|
||||
'use strict';
|
||||
|
||||
|
@ -304,6 +305,7 @@ define([
|
|||
toolbar.btnColumns.menu.on('item:click', _.bind(this.onColumnsSelect, this));
|
||||
toolbar.btnPageOrient.menu.on('item:click', _.bind(this.onPageOrientSelect, this));
|
||||
toolbar.btnPageMargins.menu.on('item:click', _.bind(this.onPageMarginsSelect, this));
|
||||
toolbar.btnWatermark.menu.on('item:click', _.bind(this.onWatermarkSelect, this));
|
||||
toolbar.btnClearStyle.on('click', _.bind(this.onClearStyleClick, this));
|
||||
toolbar.btnCopyStyle.on('toggle', _.bind(this.onCopyStyleToggle, this));
|
||||
toolbar.mnuPageSize.on('item:click', _.bind(this.onPageSizeClick, this));
|
||||
|
@ -823,6 +825,8 @@ define([
|
|||
if ( this.btnsComment && this.btnsComment.length > 0 )
|
||||
this.btnsComment.setDisabled(need_disable);
|
||||
|
||||
toolbar.btnWatermark.setDisabled(header_locked);
|
||||
|
||||
this._state.in_equation = in_equation;
|
||||
},
|
||||
|
||||
|
@ -1905,6 +1909,41 @@ define([
|
|||
Common.component.Analytics.trackEvent('ToolBar', 'Blank Page');
|
||||
},
|
||||
|
||||
onWatermarkSelect: function(menu, item) {
|
||||
if (this.api) {
|
||||
if (item.value == 'remove')
|
||||
this.api.asc_WatermarkRemove();
|
||||
else {
|
||||
var me = this;
|
||||
if (_.isUndefined(me.fontstore)) {
|
||||
me.fontstore = new Common.Collections.Fonts();
|
||||
var fonts = me.toolbar.cmbFontName.store.toJSON();
|
||||
var arr = [];
|
||||
_.each(fonts, function(font, index){
|
||||
if (!font.cloneid) {
|
||||
arr.push(_.clone(font));
|
||||
}
|
||||
});
|
||||
me.fontstore.add(arr);
|
||||
}
|
||||
|
||||
(new DE.Views.WatermarkSettingsDialog({
|
||||
props: me.api.asc_GetWatermarkProps(),
|
||||
api: me.api,
|
||||
fontStore: me.fontstore,
|
||||
handler: function(result, value) {
|
||||
if (result == 'ok') {
|
||||
me.api.asc_SetWatermarkProps(value);
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||
}
|
||||
})).show();
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||
Common.component.Analytics.trackEvent('ToolBar', 'Edit ' + item.value);
|
||||
}
|
||||
},
|
||||
|
||||
onListStyleSelect: function(combo, record) {
|
||||
this._state.prstyle = undefined;
|
||||
if (this.api)
|
||||
|
|
|
@ -134,6 +134,10 @@
|
|||
<span class="btn-slot text x-huge" id="slot-img-movebkwd"></span>
|
||||
<span class="btn-slot text x-huge" id="slot-img-wrapping"></span>
|
||||
</div>
|
||||
<div class="separator long"></div>
|
||||
<div class="group">
|
||||
<span class="btn-slot text x-huge" id="slot-btn-watermark"></span>
|
||||
</div>
|
||||
</section>
|
||||
<section class="panel" data-tab="links">
|
||||
<div class="group">
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<table cols="1">
|
||||
<tr><td class="padding-small">
|
||||
<div id="watermark-radio-none"></div>
|
||||
</td></tr>
|
||||
<tr><td class="padding-small">
|
||||
<div id="watermark-radio-text"></div>
|
||||
</td></tr>
|
||||
<tr><td class="padding-large">
|
||||
<table id="watermark-tbl-text" cols="2" style="margin-left: 22px;">
|
||||
<tr>
|
||||
<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" 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>
|
||||
<div id="watermark-underline" style="display: inline-block;margin-left: 6px;"></div><div id="watermark-strikeout" style="display: inline-block;margin-left: 6px;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="padding-small" colspan="2">
|
||||
<div id="watermark-chb-transparency"></div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<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>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
<tr><td class="padding-small">
|
||||
<div id="watermark-radio-image"></div>
|
||||
</td></tr>
|
||||
<tr><td class="padding-small">
|
||||
<table id="watermark-tbl-image" cols="3" style="margin-left: 22px;">
|
||||
<tr>
|
||||
<td style="vertical-align: top;">
|
||||
<button type="button" class="btn btn-text-default" id="watermark-from-file" style="width:90px;"><%= scope.textFromFile %></button>
|
||||
</td>
|
||||
<td style="vertical-align: top;">
|
||||
<button type="button" class="btn btn-text-default" id="watermark-from-url" style="width:90px;margin-left: 15px;"><%= scope.textFromUrl %></button>
|
||||
</td>
|
||||
<td rowspan="2">
|
||||
<div style="width: 80px; height: 70px; padding: 9px 14px; border: 1px solid #AFAFAF; border-radius: 2px; background: #ffffff;margin-left: 15px;">
|
||||
<div id="watermark-texture-img" style="width: 50px;height: 50px;"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="vertical-align: bottom;">
|
||||
<label class="input-label" style=""><%= scope.textScale %></label>
|
||||
<div id="watermark-combo-scale" style="width: 90px;"></div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td></tr>
|
||||
</table>
|
|
@ -1015,8 +1015,28 @@ define([
|
|||
caption: me.capImgWrapping,
|
||||
menu: true
|
||||
});
|
||||
|
||||
me.btnWatermark = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconCls: 'btn-watermark',
|
||||
caption: me.capBtnWatermark,
|
||||
menu: new Common.UI.Menu({
|
||||
cls: 'ppm-toolbar',
|
||||
items: [
|
||||
{
|
||||
caption: this.textEditWatermark,
|
||||
value: 'edit'
|
||||
},
|
||||
{
|
||||
caption: this.textRemWatermark,
|
||||
value: 'remove'
|
||||
}
|
||||
]
|
||||
})
|
||||
});
|
||||
|
||||
me.toolbarControls.push(me.btnImgAlign,
|
||||
me.btnImgGroup, me.btnImgForward, me.btnImgBackward, me.btnImgWrapping);
|
||||
me.btnImgGroup, me.btnImgForward, me.btnImgBackward, me.btnImgWrapping, me.btnWatermark);
|
||||
|
||||
//
|
||||
// Menus
|
||||
|
@ -1318,6 +1338,7 @@ define([
|
|||
_injectComponent('#slot-img-movefrwd', this.btnImgForward);
|
||||
_injectComponent('#slot-img-movebkwd', this.btnImgBackward);
|
||||
_injectComponent('#slot-img-wrapping', this.btnImgWrapping);
|
||||
_injectComponent('#slot-btn-watermark', this.btnWatermark);
|
||||
|
||||
this.btnsPageBreak = Common.Utils.injectButtons($host.find('.btn-slot.btn-pagebreak'), '', 'btn-pagebreak', this.capBtnInsPagebreak, undefined, true, true);
|
||||
Array.prototype.push.apply(this.paragraphControls, this.btnsPageBreak);
|
||||
|
@ -1519,6 +1540,8 @@ define([
|
|||
}
|
||||
]
|
||||
}));
|
||||
|
||||
me.btnWatermark.updateHint(me.tipWatermark);
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -2406,7 +2429,11 @@ define([
|
|||
txtDistribVert: 'Distribute Vertically',
|
||||
txtPageAlign: 'Align to Page',
|
||||
txtMarginAlign: 'Align to Margin',
|
||||
txtObjectsAlign: 'Align Selected Objects'
|
||||
txtObjectsAlign: 'Align Selected Objects',
|
||||
capBtnWatermark: 'Watermark',
|
||||
textEditWatermark: 'Custom Watermark',
|
||||
textRemWatermark: 'Remove Watermark',
|
||||
tipWatermark: 'Edit watermark'
|
||||
}
|
||||
})(), DE.Views.Toolbar || {}));
|
||||
});
|
||||
|
|
664
apps/documenteditor/main/app/view/WatermarkSettingsDialog.js
Normal file
664
apps/documenteditor/main/app/view/WatermarkSettingsDialog.js
Normal file
|
@ -0,0 +1,664 @@
|
|||
/*
|
||||
*
|
||||
* (c) Copyright Ascensio System SIA 2010-2019
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha
|
||||
* street, Riga, Latvia, EU, LV-1050.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* WatermarkSettingsDialog.js.js
|
||||
*
|
||||
* Created by Julia Radzhabova on 04.04.2019
|
||||
* Copyright (c) 2019 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define(['text!documenteditor/main/app/template/WatermarkSettings.template',
|
||||
'common/main/lib/util/utils',
|
||||
'common/main/lib/component/RadioBox',
|
||||
'common/main/lib/component/InputField',
|
||||
'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,
|
||||
height: 442
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
var me = this;
|
||||
|
||||
_.extend(this.options, {
|
||||
title: this.textTitle,
|
||||
template: _.template(
|
||||
[
|
||||
'<div class="box" style="height:' + (me.options.height - 85) + 'px;">',
|
||||
'<div class="content-panel" style="padding: 10px 5px;"><div class="inner-content">',
|
||||
'<div class="settings-panel active">',
|
||||
template,
|
||||
'</div></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="footer center">',
|
||||
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + me.okButtonText + '</button>',
|
||||
'<button class="btn normal dlg-btn" result="cancel">' + me.cancelButtonText + '</button>',
|
||||
'</div>'
|
||||
].join('')
|
||||
)({
|
||||
scope: this
|
||||
})
|
||||
}, options);
|
||||
|
||||
this.handler = options.handler;
|
||||
this.props = options.props;
|
||||
this.fontStore = options.fontStore;
|
||||
this.api = options.api;
|
||||
this.textControls = [];
|
||||
this.imageControls = [];
|
||||
this.fontName = 'Arial';
|
||||
this.lang = 'en';
|
||||
this.isAutoColor = false;
|
||||
this.isImageLoaded = false;
|
||||
|
||||
Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
Common.Views.AdvancedSettingsWindow.prototype.render.call(this);
|
||||
var me = this;
|
||||
|
||||
this.radioNone = new Common.UI.RadioBox({
|
||||
el: $('#watermark-radio-none'),
|
||||
name: 'asc-radio-watermark-type',
|
||||
labelText: this.textNone,
|
||||
checked: false
|
||||
});
|
||||
this.radioNone.on('change', _.bind(function(field, newValue, eOpts) {
|
||||
if (newValue) {
|
||||
// disable text and image
|
||||
this.props.put_Type(Asc.c_oAscWatermarkType.None);
|
||||
this.disableControls(Asc.c_oAscWatermarkType.None);
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.radioImage = new Common.UI.RadioBox({
|
||||
el: $('#watermark-radio-image'),
|
||||
name: 'asc-radio-watermark-type',
|
||||
labelText: this.textImageW,
|
||||
checked: false
|
||||
});
|
||||
this.radioImage.on('change', _.bind(function(field, newValue, eOpts) {
|
||||
if (newValue) {
|
||||
// disable text
|
||||
this.props.put_Type(Asc.c_oAscWatermarkType.Image);
|
||||
this.disableControls(Asc.c_oAscWatermarkType.Image);
|
||||
}
|
||||
}, this));
|
||||
|
||||
this.radioText = new Common.UI.RadioBox({
|
||||
el: $('#watermark-radio-text'),
|
||||
name: 'asc-radio-watermark-type',
|
||||
labelText: this.textTextW,
|
||||
checked: true
|
||||
});
|
||||
this.radioText.on('change', _.bind(function(field, newValue, eOpts) {
|
||||
if (newValue) {
|
||||
// disable image
|
||||
this.props.put_Type(Asc.c_oAscWatermarkType.Text);
|
||||
this.disableControls(Asc.c_oAscWatermarkType.Text);
|
||||
}
|
||||
}, this));
|
||||
|
||||
// Image watermark
|
||||
this.btnFromFile = new Common.UI.Button({
|
||||
el: $('#watermark-from-file')
|
||||
});
|
||||
this.btnFromFile.on('click', _.bind(function(btn){
|
||||
this.props.showFileDialog();
|
||||
}, this));
|
||||
this.imageControls.push(this.btnFromFile);
|
||||
|
||||
this.btnFromUrl = new Common.UI.Button({
|
||||
el: $('#watermark-from-url')
|
||||
});
|
||||
this.btnFromUrl.on('click', _.bind(this.insertFromUrl, this));
|
||||
this.imageControls.push(this.btnFromUrl);
|
||||
|
||||
this._arrScale = [
|
||||
{displayValue: this.textAuto, value: -1},
|
||||
{displayValue: '500%', value: 500},
|
||||
{displayValue: '200%', value: 200},
|
||||
{displayValue: '150%', value: 150},
|
||||
{displayValue: '100%', value: 100},
|
||||
{displayValue: '50%', value: 50}
|
||||
];
|
||||
this.cmbScale = new Common.UI.ComboBox({
|
||||
el : $('#watermark-combo-scale'),
|
||||
cls : 'input-group-nr',
|
||||
menuStyle : 'min-width: 90px;',
|
||||
data : this._arrScale
|
||||
}).on('selected', _.bind(function(combo, record) {
|
||||
}, this));
|
||||
this.cmbScale.setValue(this._arrScale[0].value);
|
||||
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(this.onSelectLang, this));
|
||||
this.textControls.push(this.cmbLang);
|
||||
|
||||
this.cmbText = new Common.UI.ComboBox({
|
||||
el : $('#watermark-combo-text'),
|
||||
cls : 'input-group-nr',
|
||||
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({
|
||||
el : $('#watermark-fonts'),
|
||||
cls : 'input-group-nr',
|
||||
style : 'width: 142px;',
|
||||
menuCls : 'scrollable-menu',
|
||||
menuStyle : 'min-width: 100%;max-height: 270px;',
|
||||
store : new Common.Collections.Fonts(),
|
||||
recent : 0,
|
||||
hint : this.tipFontName
|
||||
}).on('selected', _.bind(function(combo, record) {
|
||||
this.fontName = record.name;
|
||||
}, this));
|
||||
this.textControls.push(this.cmbFonts);
|
||||
|
||||
var data = [
|
||||
{ value: -1, displayValue: this.textAuto },
|
||||
{ value: 36, displayValue: "36" },
|
||||
{ value: 40, displayValue: "40" },
|
||||
{ value: 44, displayValue: "44" },
|
||||
{ value: 48, displayValue: "48" },
|
||||
{ value: 54, displayValue: "54" },
|
||||
{ value: 60, displayValue: "60" },
|
||||
{ value: 66, displayValue: "66" },
|
||||
{ value: 72, displayValue: "72" },
|
||||
{ value: 80, displayValue: "80" },
|
||||
{ value: 90, displayValue: "90" },
|
||||
{ value: 96, displayValue: "96" },
|
||||
{ value: 105, displayValue: "105" },
|
||||
{ value: 120, displayValue: "120" },
|
||||
{ value: 144, displayValue: "144" }
|
||||
];
|
||||
this.cmbFontSize = new Common.UI.ComboBox({
|
||||
el: $('#watermark-font-size'),
|
||||
cls: 'input-group-nr',
|
||||
style: 'width: 55px;',
|
||||
menuCls : 'scrollable-menu',
|
||||
menuStyle: 'min-width: 55px;max-height: 270px;',
|
||||
hint: this.tipFontSize,
|
||||
data: data
|
||||
});
|
||||
this.cmbFontSize.setValue(-1);
|
||||
this.textControls.push(this.cmbFontSize);
|
||||
|
||||
this.btnBold = new Common.UI.Button({
|
||||
cls: 'btn-toolbar',
|
||||
iconCls: 'btn-bold',
|
||||
enableToggle: true,
|
||||
hint: this.textBold
|
||||
});
|
||||
this.btnBold.render($('#watermark-bold')) ;
|
||||
this.textControls.push(this.btnBold);
|
||||
|
||||
this.btnItalic = new Common.UI.Button({
|
||||
cls: 'btn-toolbar',
|
||||
iconCls: 'btn-italic',
|
||||
enableToggle: true,
|
||||
hint: this.textItalic
|
||||
});
|
||||
this.btnItalic.render($('#watermark-italic')) ;
|
||||
this.textControls.push(this.btnItalic);
|
||||
|
||||
this.btnUnderline = new Common.UI.Button({
|
||||
cls : 'btn-toolbar',
|
||||
iconCls : 'btn-underline',
|
||||
enableToggle: true,
|
||||
hint: this.textUnderline
|
||||
});
|
||||
this.btnUnderline.render($('#watermark-underline')) ;
|
||||
this.textControls.push(this.btnUnderline);
|
||||
|
||||
this.btnStrikeout = new Common.UI.Button({
|
||||
cls: 'btn-toolbar',
|
||||
iconCls: 'btn-strikeout',
|
||||
enableToggle: true,
|
||||
hint: this.textStrikeout
|
||||
});
|
||||
this.btnStrikeout.render($('#watermark-strikeout')) ;
|
||||
this.textControls.push(this.btnStrikeout);
|
||||
|
||||
var initNewColor = function(btn, picker_el) {
|
||||
if (btn && btn.cmpEl) {
|
||||
btn.currentColor = '#c0c0c0';
|
||||
var colorVal = $('<div class="btn-color-value-line"></div>');
|
||||
$('button:first-child', btn.cmpEl).append(colorVal);
|
||||
colorVal.css('background-color', btn.currentColor);
|
||||
var picker = new Common.UI.ThemeColorPalette({
|
||||
el: $(picker_el)
|
||||
});
|
||||
}
|
||||
btn.menu.cmpEl.on('click', picker_el+'-new', _.bind(function() {
|
||||
picker.addNewColor((typeof(btn.color) == 'object') ? btn.color.color : btn.color);
|
||||
}, me));
|
||||
picker.on('select', _.bind(me.onColorSelect, me));
|
||||
return picker;
|
||||
};
|
||||
this.btnTextColor = new Common.UI.Button({
|
||||
cls : 'btn-toolbar',
|
||||
iconCls : 'btn-fontcolor',
|
||||
hint : this.textColor,
|
||||
menu : new Common.UI.Menu({
|
||||
items: [
|
||||
{
|
||||
id: 'watermark-auto-color',
|
||||
caption: this.textAuto,
|
||||
template: _.template('<a tabindex="-1" type="menuitem"><span class="menu-item-icon" style="background-image: none; width: 12px; height: 12px; margin: 1px 7px 0 -7px; background-color: #000;"></span><%= caption %></a>')
|
||||
},
|
||||
{caption: '--'},
|
||||
{ template: _.template('<div id="watermark-menu-textcolor" style="width: 169px; height: 220px; margin: 10px;"></div>') },
|
||||
{ template: _.template('<a id="watermark-menu-textcolor-new" style="padding-left:12px;">' + this.textNewColor + '</a>') }
|
||||
]
|
||||
})
|
||||
});
|
||||
this.btnTextColor.render($('#watermark-textcolor'));
|
||||
this.mnuTextColorPicker = initNewColor(this.btnTextColor, "#watermark-menu-textcolor");
|
||||
$('#watermark-auto-color').on('click', _.bind(this.onAutoColor, this));
|
||||
this.textControls.push(this.btnTextColor);
|
||||
|
||||
this.chTransparency = new Common.UI.CheckBox({
|
||||
el: $('#watermark-chb-transparency'),
|
||||
labelText: this.textTransparency,
|
||||
value: true
|
||||
});
|
||||
this.textControls.push(this.chTransparency);
|
||||
|
||||
this.radioDiag = new Common.UI.RadioBox({
|
||||
el: $('#watermark-radio-diag'),
|
||||
name: 'asc-radio-watermark-layout',
|
||||
labelText: this.textDiagonal,
|
||||
checked: true
|
||||
});
|
||||
this.textControls.push(this.radioDiag);
|
||||
|
||||
this.radioHor = new Common.UI.RadioBox({
|
||||
el: $('#watermark-radio-hor'),
|
||||
name: 'asc-radio-watermark-layout',
|
||||
labelText: this.textHor
|
||||
});
|
||||
this.textControls.push(this.radioHor);
|
||||
|
||||
this.btnOk = new Common.UI.Button({
|
||||
el: this.$window.find('.primary'),
|
||||
disabled: true
|
||||
});
|
||||
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
onColorSelect: function(picker, color) {
|
||||
var clr_item = this.btnTextColor.menu.$el.find('#watermark-auto-color > a');
|
||||
clr_item.hasClass('selected') && clr_item.removeClass('selected');
|
||||
this.isAutoColor = false;
|
||||
|
||||
var clr = (typeof(color) == 'object') ? color.color : color;
|
||||
this.btnTextColor.currentColor = color;
|
||||
$('.btn-color-value-line', this.btnTextColor.cmpEl).css('background-color', '#' + clr);
|
||||
},
|
||||
|
||||
updateThemeColors: function() {
|
||||
this.mnuTextColorPicker.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
|
||||
},
|
||||
|
||||
addNewColor: function(picker, btn) {
|
||||
picker.addNewColor((typeof(btn.color) == 'object') ? btn.color.color : btn.color);
|
||||
},
|
||||
|
||||
onAutoColor: function(e) {
|
||||
var clr_item = this.btnTextColor.menu.$el.find('#watermark-auto-color > a');
|
||||
!clr_item.hasClass('selected') && clr_item.addClass('selected');
|
||||
this.isAutoColor = true;
|
||||
|
||||
var color = "000";
|
||||
this.btnTextColor.currentColor = color;
|
||||
$('.btn-color-value-line', this.btnTextColor.cmpEl).css('background-color', '#' + color);
|
||||
this.mnuTextColorPicker.clearSelection();
|
||||
},
|
||||
|
||||
afterRender: function() {
|
||||
this.cmbFonts.fillFonts(this.fontStore);
|
||||
this.cmbFonts.selectRecord(this.fontStore.findWhere({name: this.fontName}));
|
||||
|
||||
this.updateThemeColors();
|
||||
this._setDefaults(this.props);
|
||||
|
||||
var me = this;
|
||||
var onApiWMLoaded = function() {
|
||||
me.isImageLoaded = true;
|
||||
me.btnOk.setDisabled(false);
|
||||
};
|
||||
this.api.asc_registerCallback('asc_onWatermarkImageLoaded', onApiWMLoaded);
|
||||
this.on('close', function(obj){
|
||||
me.api.asc_unregisterCallback('asc_onWatermarkImageLoaded', onApiWMLoaded);
|
||||
});
|
||||
},
|
||||
|
||||
show: function() {
|
||||
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) {
|
||||
var item = this.cmbLang.store.findWhere({value: this.lang}) || this.cmbLang.store.at(0);
|
||||
this.cmbLang.setValue(this.lang);
|
||||
this.onSelectLang(this.cmbLang, item.toJSON());
|
||||
} else
|
||||
this.cmbLang.setDisabled(true);
|
||||
},
|
||||
|
||||
onSelectLang: function(combo, record) {
|
||||
if (!record) return;
|
||||
|
||||
var data = [];
|
||||
record.wmtext.forEach(function(item) {
|
||||
data.push({value: item});
|
||||
});
|
||||
this.lang = record.value;
|
||||
this.cmbText.setData(data);
|
||||
this.cmbText.setValue(data[0].value);
|
||||
},
|
||||
|
||||
loadWMText: function(lang) {
|
||||
if (!lang) return;
|
||||
|
||||
var data = [];
|
||||
var item = this.cmbLang.store.findWhere({value: lang});
|
||||
if (!item)
|
||||
item = this.cmbLang.store.findWhere({value: lang.split(/[\-\_]/)[0]});
|
||||
if (!item)
|
||||
item = this.cmbLang.store.findWhere({value: 'en'});
|
||||
if (!item)
|
||||
item = this.cmbLang.store.at(0);
|
||||
|
||||
item && item.get('wmtext').forEach(function(item) {
|
||||
data.push({value: item});
|
||||
});
|
||||
this.cmbText.setData(data);
|
||||
this.cmbText.setValue(data[0].value);
|
||||
},
|
||||
|
||||
insertFromUrl: function() {
|
||||
var me = this;
|
||||
(new Common.Views.ImageFromUrlDialog({
|
||||
handler: function(result, value) {
|
||||
if (result == 'ok') {
|
||||
var checkUrl = value.replace(/ /g, '');
|
||||
if (!_.isEmpty(checkUrl)) {
|
||||
me.props.put_ImageUrl(checkUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
})).show();
|
||||
},
|
||||
|
||||
_setDefaults: function (props) {
|
||||
this.loadLanguages();
|
||||
if (props) {
|
||||
props.put_DivId('watermark-texture-img');
|
||||
props.put_Api(this.api);
|
||||
|
||||
var val,
|
||||
type = props.get_Type();
|
||||
if (type == Asc.c_oAscWatermarkType.None) {
|
||||
this.radioNone.setValue(true, true);
|
||||
} else if (type == Asc.c_oAscWatermarkType.Image) {
|
||||
this.radioImage.setValue(true, true);
|
||||
this.isImageLoaded = !!props.get_ImageUrl();
|
||||
val = props.get_Scale() || -1;
|
||||
this.cmbScale.setValue((val<0) ? -1 : Math.round(val*100), Math.round(val*100) + ' %');
|
||||
} else {
|
||||
this.radioText.setValue(true, true);
|
||||
!props.get_IsDiagonal() && this.radioHor.setValue(true);
|
||||
this.chTransparency.setValue(props.get_Opacity()<255);
|
||||
|
||||
val = props.get_TextPr();
|
||||
if (val) {
|
||||
var lang = Common.util.LanguageInfo.getLocalLanguageName(val.get_Lang());
|
||||
this.lang = lang[0];
|
||||
this.cmbLang.setValue(lang[1]);
|
||||
this.loadWMText(lang[0]);
|
||||
|
||||
var font = val.get_FontFamily().get_Name();
|
||||
if (font) {
|
||||
var rec = this.cmbFonts.store.findWhere({name: font});
|
||||
this.fontName = (rec) ? rec.get('name') : font;
|
||||
this.cmbFonts.setValue(this.fontName);
|
||||
}
|
||||
|
||||
this.cmbFontSize.setValue(val.get_FontSize());
|
||||
this.btnBold.toggle(val.get_Bold());
|
||||
this.btnItalic.toggle(val.get_Italic());
|
||||
this.btnUnderline.toggle(val.get_Underline());
|
||||
this.btnStrikeout.toggle(val.get_Strikeout());
|
||||
var color = val.get_Color(),
|
||||
clr_item = this.btnTextColor.menu.$el.find('#watermark-auto-color > a'),
|
||||
clr = "c0c0c0";
|
||||
|
||||
if (color.get_auto()) {
|
||||
clr = "000";
|
||||
this.isAutoColor = true;
|
||||
this.mnuTextColorPicker.clearSelection();
|
||||
!clr_item.hasClass('selected') && clr_item.addClass('selected');
|
||||
} else {
|
||||
clr_item.hasClass('selected') && clr_item.removeClass('selected');
|
||||
if (color) {
|
||||
color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME ?
|
||||
clr = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()} :
|
||||
clr = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
|
||||
}
|
||||
if ( typeof(clr) == 'object' ) {
|
||||
var isselected = false;
|
||||
for (var i=0; i<10; i++) {
|
||||
if ( Common.Utils.ThemeColor.ThemeValues[i] == clr.effectValue ) {
|
||||
this.mnuTextColorPicker.select(clr,true);
|
||||
isselected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!isselected) this.mnuTextColorPicker.clearSelection();
|
||||
} else {
|
||||
this.mnuTextColorPicker.select(clr,true);
|
||||
}
|
||||
}
|
||||
this.btnTextColor.currentColor = clr;
|
||||
$('.btn-color-value-line', this.btnTextColor.cmpEl).css('background-color', '#' + ((typeof(clr) == 'object') ? clr.color : clr));
|
||||
}
|
||||
val = props.get_Text();
|
||||
val && this.cmbText.setValue(val);
|
||||
}
|
||||
this.disableControls(type);
|
||||
}
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
var props = this.props;
|
||||
|
||||
var val = this.props.get_Type();
|
||||
if (val == Asc.c_oAscWatermarkType.Image) {
|
||||
val = this.cmbScale.getValue();
|
||||
val = props.put_Scale((val<0) ? val : val/100);
|
||||
} else {
|
||||
props.put_Text(this.cmbText.getValue());
|
||||
props.put_IsDiagonal(this.radioDiag.getValue());
|
||||
props.put_Opacity((this.chTransparency.getValue()=='checked') ? 128: 255);
|
||||
|
||||
val = props.get_TextPr() || new Asc.CTextProp();
|
||||
if (val) {
|
||||
val.put_FontSize(this.cmbFontSize.getValue());
|
||||
var font = new AscCommon.asc_CTextFontFamily();
|
||||
font.put_Name(this.fontName);
|
||||
font.put_Index(-1);
|
||||
val.put_FontFamily(font);
|
||||
val.put_Bold(this.btnBold.pressed);
|
||||
val.put_Italic(this.btnItalic.pressed);
|
||||
val.put_Underline(this.btnUnderline.pressed);
|
||||
val.put_Strikeout(this.btnStrikeout.pressed);
|
||||
|
||||
val.put_Lang(parseInt(Common.util.LanguageInfo.getLocalLanguageCode(this.lang)));
|
||||
|
||||
var color = new Asc.asc_CColor();
|
||||
if (this.isAutoColor) {
|
||||
color.put_auto(true);
|
||||
} else {
|
||||
color = Common.Utils.ThemeColor.getRgbColor(this.btnTextColor.currentColor);
|
||||
}
|
||||
val.put_Color(color);
|
||||
props.put_TextPr(val);
|
||||
}
|
||||
}
|
||||
|
||||
return this.props;
|
||||
},
|
||||
|
||||
disableControls: function(type) {// 0 - none, 1 - text, 2 - image
|
||||
var disable = (type!=Asc.c_oAscWatermarkType.Image);
|
||||
_.each(this.imageControls, function(item) {
|
||||
item.setDisabled(disable);
|
||||
});
|
||||
|
||||
disable = (type!=Asc.c_oAscWatermarkType.Text);
|
||||
_.each(this.textControls, function(item) {
|
||||
item.setDisabled(disable);
|
||||
});
|
||||
this.cmbLang.setDisabled(disable || this.languages.length<1);
|
||||
this.btnOk.setDisabled(type==Asc.c_oAscWatermarkType.Image && !this.isImageLoaded);
|
||||
},
|
||||
|
||||
onDlgBtnClick: function(event) {
|
||||
this._handleInput(event.currentTarget.attributes['result'].value);
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
this._handleInput('ok');
|
||||
return false;
|
||||
},
|
||||
|
||||
_handleInput: function(state) {
|
||||
if (this.handler) {
|
||||
if (state == 'ok' && this.btnOk.isDisabled()) {
|
||||
return;
|
||||
}
|
||||
this.handler.call(this, state, this.getSettings());
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
textTitle: 'Watermark Settings',
|
||||
textNone: 'None',
|
||||
textImageW: 'Image watermark',
|
||||
textTextW: 'Text watermark',
|
||||
textFromUrl: 'From URL',
|
||||
textFromFile: 'From File',
|
||||
textScale: 'Scale',
|
||||
textAuto: 'Auto',
|
||||
textText: 'Text',
|
||||
textFont: 'Font',
|
||||
tipFontName: 'Font Name',
|
||||
tipFontSize: 'Font Size',
|
||||
textBold: 'Bold',
|
||||
textItalic: 'Italic',
|
||||
textUnderline: 'Underline',
|
||||
textStrikeout: 'Strikeout',
|
||||
textTransparency: 'Semitransparent',
|
||||
textLayout: 'Layout',
|
||||
textDiagonal: 'Diagonal',
|
||||
textHor: 'Horizontal',
|
||||
cancelButtonText: 'Cancel',
|
||||
okButtonText: 'Ok',
|
||||
textColor: 'Text color',
|
||||
textNewColor: 'Add New Custom Color',
|
||||
textLanguage: 'Language'
|
||||
|
||||
}, DE.Views.WatermarkSettingsDialog || {}))
|
||||
});
|
|
@ -2196,5 +2196,30 @@
|
|||
"DE.Views.Toolbar.txtScheme6": "Concourse",
|
||||
"DE.Views.Toolbar.txtScheme7": "Equity",
|
||||
"DE.Views.Toolbar.txtScheme8": "Flow",
|
||||
"DE.Views.Toolbar.txtScheme9": "Foundry"
|
||||
"DE.Views.Toolbar.txtScheme9": "Foundry",
|
||||
"DE.Views.WatermarkSettingsDialog.textTitle": "Watermark Settings",
|
||||
"DE.Views.WatermarkSettingsDialog.textNone": "None",
|
||||
"DE.Views.WatermarkSettingsDialog.textImageW": "Image watermark",
|
||||
"DE.Views.WatermarkSettingsDialog.textTextW": "Text watermark",
|
||||
"DE.Views.WatermarkSettingsDialog.textFromUrl": "From URL",
|
||||
"DE.Views.WatermarkSettingsDialog.textFromFile": "From File",
|
||||
"DE.Views.WatermarkSettingsDialog.textScale": "Scale",
|
||||
"DE.Views.WatermarkSettingsDialog.textAuto": "Auto",
|
||||
"DE.Views.WatermarkSettingsDialog.textText": "Text",
|
||||
"DE.Views.WatermarkSettingsDialog.textFont": "Font",
|
||||
"DE.Views.WatermarkSettingsDialog.tipFontName": "Font Name",
|
||||
"DE.Views.WatermarkSettingsDialog.tipFontSize": "Font Size",
|
||||
"DE.Views.WatermarkSettingsDialog.textBold": "Bold",
|
||||
"DE.Views.WatermarkSettingsDialog.textItalic": "Italic",
|
||||
"DE.Views.WatermarkSettingsDialog.textUnderline": "Underline",
|
||||
"DE.Views.WatermarkSettingsDialog.textStrikeout": "Strikeout",
|
||||
"DE.Views.WatermarkSettingsDialog.textTransparency": "Semitransparent",
|
||||
"DE.Views.WatermarkSettingsDialog.textLayout": "Layout",
|
||||
"DE.Views.WatermarkSettingsDialog.textDiagonal": "Diagonal",
|
||||
"DE.Views.WatermarkSettingsDialog.textHor": "Horizontal",
|
||||
"DE.Views.WatermarkSettingsDialog.cancelButtonText": "Cancel",
|
||||
"DE.Views.WatermarkSettingsDialog.okButtonText": "Ok",
|
||||
"DE.Views.WatermarkSettingsDialog.textColor": "Text color",
|
||||
"DE.Views.WatermarkSettingsDialog.textNewColor": "Add New Custom Color",
|
||||
"DE.Views.WatermarkSettingsDialog.textLanguage": "Language"
|
||||
}
|
|
@ -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"]
|
||||
}
|
Loading…
Reference in a new issue