2019-10-30 11:01:02 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
|
|
|
|
* (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
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* ListSettingsDialog.js
|
|
|
|
|
*
|
|
|
|
|
* Created by Julia Radzhabova on 30.10.2019
|
|
|
|
|
* Copyright (c) 2019 Ascensio System SIA. All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
2019-11-07 10:37:14 +00:00
|
|
|
|
if (Common === undefined)
|
|
|
|
|
var Common = {};
|
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
define([
|
2019-11-07 10:38:42 +00:00
|
|
|
|
'common/main/lib/component/Window',
|
2019-10-30 11:01:02 +00:00
|
|
|
|
'common/main/lib/component/MetricSpinner',
|
|
|
|
|
'common/main/lib/component/ThemeColorPalette',
|
2019-11-19 14:05:02 +00:00
|
|
|
|
'common/main/lib/component/ColorButton',
|
|
|
|
|
'common/main/lib/view/SymbolTableDialog'
|
2019-10-30 11:01:02 +00:00
|
|
|
|
], function () { 'use strict';
|
|
|
|
|
|
2022-04-11 16:49:58 +00:00
|
|
|
|
var _BulletTypes = {};
|
|
|
|
|
_BulletTypes.none = -1;
|
|
|
|
|
_BulletTypes.symbol = 0;
|
|
|
|
|
_BulletTypes.image = 2;
|
|
|
|
|
_BulletTypes.newSymbol = 1;
|
|
|
|
|
_BulletTypes.newImage = -2;
|
|
|
|
|
|
2019-11-07 10:37:14 +00:00
|
|
|
|
Common.Views.ListSettingsDialog = Common.UI.Window.extend(_.extend({
|
2019-10-30 11:01:02 +00:00
|
|
|
|
options: {
|
2019-10-31 10:57:03 +00:00
|
|
|
|
type: 0, // 0 - markers, 1 - numbers
|
2020-06-17 13:55:01 +00:00
|
|
|
|
width: 280,
|
|
|
|
|
height: 255,
|
2019-11-19 14:05:02 +00:00
|
|
|
|
style: 'min-width: 240px;',
|
2019-10-30 11:01:02 +00:00
|
|
|
|
cls: 'modal-dlg',
|
|
|
|
|
split: false,
|
2020-10-13 11:30:52 +00:00
|
|
|
|
buttons: ['ok', 'cancel']
|
2019-10-30 11:01:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
initialize : function(options) {
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this.type = options.type || 0;
|
2019-10-31 10:57:03 +00:00
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
_.extend(this.options, {
|
2019-11-19 14:05:02 +00:00
|
|
|
|
title: this.txtTitle
|
2019-10-30 11:01:02 +00:00
|
|
|
|
}, options || {});
|
|
|
|
|
|
|
|
|
|
this.template = [
|
|
|
|
|
'<div class="box">',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
'<div style="margin-bottom: 16px;">',
|
|
|
|
|
'<button type="button" class="btn btn-text-default auto" id="id-dlg-list-bullet" style="border-top-right-radius: 0;border-bottom-right-radius: 0;">', this.textBulleted,'</button>',
|
|
|
|
|
'<button type="button" class="btn btn-text-default auto" id="id-dlg-list-numbering" style="border-top-left-radius: 0;border-bottom-left-radius: 0;border-left-width: 0;margin-left: -1px;">', this.textNumbering,'</button>',
|
2019-10-31 10:57:03 +00:00
|
|
|
|
'</div>',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
'<div style="height:120px;">',
|
|
|
|
|
'<table cols="3">',
|
|
|
|
|
'<tr>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;min-width: 50px;">',
|
|
|
|
|
'<label class="text">' + this.txtType + '</label>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;width: 100px;">',
|
|
|
|
|
'<div id="id-dlg-list-numbering-format" class="input-group-nr" style="width: 100px;"></div>',
|
|
|
|
|
'<div id="id-dlg-list-bullet-format" class="input-group-nr" style="width: 100px;"></div>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-bottom: 8px;"></td>',
|
|
|
|
|
'</tr>',
|
2022-04-07 21:28:59 +00:00
|
|
|
|
'<tr class="image">',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;min-width: 50px;">',
|
|
|
|
|
'<label class="text">' + this.txtImport + '</label>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;width: 100px;">',
|
|
|
|
|
'<div id="id-dlg-list-image" style="width: 100px;"></div>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-bottom: 8px;"></td>',
|
|
|
|
|
'</tr>',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
'<tr>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;min-width: 50px;">',
|
|
|
|
|
'<label class="text">' + this.txtSize + '</label>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;width: 100px;">',
|
|
|
|
|
'<div id="id-dlg-list-size"></div>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-bottom: 8px;">',
|
|
|
|
|
'<label class="text" style="white-space: nowrap;">' + this.txtOfText + '</label>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'</tr>',
|
|
|
|
|
'<tr class="numbering">',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;min-width: 50px;">',
|
|
|
|
|
'<label class="text" style="white-space: nowrap;">' + this.txtStart + '</label>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;width: 100px;">',
|
|
|
|
|
'<div id="id-dlg-list-start"></div>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-bottom: 8px;"></td>',
|
|
|
|
|
'</tr>',
|
2022-04-07 21:28:59 +00:00
|
|
|
|
'<tr class="color">',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;min-width: 50px;">',
|
|
|
|
|
'<label class="text">' + this.txtColor + '</label>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-right: 5px;padding-bottom: 8px;width: 100px;">',
|
|
|
|
|
'<div id="id-dlg-list-color"></div>',
|
|
|
|
|
'</td>',
|
|
|
|
|
'<td style="padding-bottom: 8px;"></td>',
|
|
|
|
|
'</tr>',
|
|
|
|
|
'</table>',
|
2019-10-31 10:57:03 +00:00
|
|
|
|
'</div>',
|
2019-10-30 11:01:02 +00:00
|
|
|
|
'</div>'
|
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
|
|
this.props = options.props;
|
|
|
|
|
this.options.tpl = _.template(this.template)(this.options);
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this.color = '000000';
|
2022-04-07 21:28:59 +00:00
|
|
|
|
this.storage = !!options.storage;
|
|
|
|
|
this.api = options.api;
|
2019-10-30 11:01:02 +00:00
|
|
|
|
|
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, this.options);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
|
|
|
|
|
|
var me = this,
|
|
|
|
|
$window = this.getChild();
|
|
|
|
|
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
|
|
|
|
|
2020-06-17 13:55:01 +00:00
|
|
|
|
me.btnBullet = new Common.UI.Button({
|
|
|
|
|
el: $('#id-dlg-list-bullet'),
|
|
|
|
|
enableToggle: true,
|
|
|
|
|
toggleGroup: 'list-type',
|
|
|
|
|
allowDepress: false,
|
|
|
|
|
pressed: true
|
|
|
|
|
});
|
|
|
|
|
me.btnBullet.on('click', _.bind(me.onListTypeClick, me, 0));
|
|
|
|
|
|
|
|
|
|
me.btnNumbering = new Common.UI.Button({
|
|
|
|
|
el: $('#id-dlg-list-numbering'),
|
|
|
|
|
enableToggle: true,
|
|
|
|
|
toggleGroup: 'list-type',
|
|
|
|
|
allowDepress: false
|
|
|
|
|
});
|
|
|
|
|
me.btnNumbering.on('click', _.bind(me.onListTypeClick, me, 1));
|
|
|
|
|
|
|
|
|
|
this.cmbNumFormat = new Common.UI.ComboBox({
|
|
|
|
|
el : $('#id-dlg-list-numbering-format'),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 183px;',
|
|
|
|
|
editable : false,
|
2020-09-26 21:14:04 +00:00
|
|
|
|
takeFocusOnClose: true,
|
2020-06-17 13:55:01 +00:00
|
|
|
|
cls : 'input-group-nr',
|
|
|
|
|
data : [
|
|
|
|
|
{ displayValue: this.txtNone, value: -1 },
|
|
|
|
|
{ displayValue: 'A, B, C,...', value: 4 },
|
2020-08-24 14:25:03 +00:00
|
|
|
|
{ displayValue: 'a), b), c),...', value: 5 },
|
2020-06-17 13:55:01 +00:00
|
|
|
|
{ displayValue: 'a, b, c,...', value: 6 },
|
|
|
|
|
{ displayValue: '1, 2, 3,...', value: 1 },
|
|
|
|
|
{ displayValue: '1), 2), 3),...', value: 2 },
|
|
|
|
|
{ displayValue: 'I, II, III,...', value: 3 },
|
|
|
|
|
{ displayValue: 'i, ii, iii,...', value: 7 }
|
|
|
|
|
]
|
|
|
|
|
});
|
|
|
|
|
this.cmbNumFormat.on('selected', _.bind(function (combo, record) {
|
|
|
|
|
if (this._changedProps) {
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this._changedProps.asc_putListType(1, record.value);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
}
|
|
|
|
|
}, this));
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this.cmbNumFormat.setValue(1);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
|
|
|
|
|
var itemsTemplate =
|
|
|
|
|
[
|
|
|
|
|
'<% _.each(items, function(item) { %>',
|
|
|
|
|
'<li id="<%= item.id %>" data-value="<%= item.value %>"><a tabindex="-1" type="menuitem">',
|
2022-04-11 20:08:36 +00:00
|
|
|
|
'<%= item.displayValue %>',
|
|
|
|
|
'<% if (item.value === 0) { %><span style="font-family:<%=item.font%>;"><%=item.symbol%></span>',
|
2022-04-11 21:11:09 +00:00
|
|
|
|
'<% } else if (item.value === 2) { %><span id="id-dlg-list-bullet-image-preview" style="width:12px; height: 12px; margin-left: 4px; margin-bottom: 1px;display: inline-block; vertical-align: middle;"></span><% } %>',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
'</a></li>',
|
|
|
|
|
'<% }); %>'
|
|
|
|
|
];
|
|
|
|
|
var template = [
|
|
|
|
|
'<div class="input-group combobox input-group-nr <%= cls %>" id="<%= id %>" style="<%= style %>">',
|
|
|
|
|
'<div class="form-control" style="padding-top:3px; line-height: 14px; cursor: pointer; <%= style %>"></div>',
|
|
|
|
|
'<div style="display: table-cell;"></div>',
|
2021-04-19 12:34:00 +00:00
|
|
|
|
'<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
'<ul class="dropdown-menu <%= menuCls %>" style="<%= menuStyle %>" role="menu">'].concat(itemsTemplate).concat([
|
|
|
|
|
'</ul>',
|
|
|
|
|
'</div>'
|
|
|
|
|
]);
|
|
|
|
|
this.cmbBulletFormat = new Common.UI.ComboBoxCustom({
|
|
|
|
|
el : $('#id-dlg-list-bullet-format'),
|
|
|
|
|
menuStyle : 'min-width: 100%;max-height: 183px;',
|
|
|
|
|
style : "width: 100px;",
|
|
|
|
|
editable : false,
|
2020-09-26 21:14:04 +00:00
|
|
|
|
takeFocusOnClose: true,
|
2020-06-17 13:55:01 +00:00
|
|
|
|
template : _.template(template.join('')),
|
|
|
|
|
itemsTemplate: _.template(itemsTemplate.join('')),
|
|
|
|
|
data : [
|
2022-04-11 16:49:58 +00:00
|
|
|
|
{ displayValue: this.txtNone, value: _BulletTypes.none },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "•", font: 'Arial' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "o", font: 'Courier New' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "§", font: 'Wingdings' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "v", font: 'Wingdings' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "Ø", font: 'Wingdings' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "ü", font: 'Wingdings' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "w", font: 'Wingdings' },
|
|
|
|
|
{ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: "–", font: 'Arial' },
|
|
|
|
|
{ displayValue: this.txtNewBullet, value: _BulletTypes.newSymbol },
|
|
|
|
|
{ displayValue: this.txtNewImage, value: _BulletTypes.newImage }
|
2020-06-17 13:55:01 +00:00
|
|
|
|
],
|
|
|
|
|
updateFormControl: function(record) {
|
|
|
|
|
var formcontrol = $(this.el).find('.form-control');
|
|
|
|
|
if (record) {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
if (record.get('value')===_BulletTypes.symbol)
|
2020-06-17 13:55:01 +00:00
|
|
|
|
formcontrol[0].innerHTML = record.get('displayValue') + '<span style="font-family:' + (record.get('font') || 'Arial') + '">' + record.get('symbol') + '</span>';
|
2022-04-11 20:08:36 +00:00
|
|
|
|
else if (record.get('value')===_BulletTypes.image) {
|
2022-04-11 21:11:09 +00:00
|
|
|
|
formcontrol[0].innerHTML = record.get('displayValue') + '<span id="id-dlg-list-bullet-combo-preview" style="width:12px; height: 12px; margin-left: 4px; margin-bottom: 1px;display: inline-block; vertical-align: middle;"></span>';
|
2022-04-11 20:08:36 +00:00
|
|
|
|
var bullet = new Asc.asc_CBullet();
|
|
|
|
|
bullet.asc_fillBulletImage(me.imageProps.id);
|
|
|
|
|
bullet.drawSquareImage('id-dlg-list-bullet-combo-preview');
|
|
|
|
|
} else if (record.get('value')===_BulletTypes.newImage)
|
2022-04-07 21:28:59 +00:00
|
|
|
|
formcontrol[0].innerHTML = me.txtImage;
|
2020-06-17 13:55:01 +00:00
|
|
|
|
else
|
|
|
|
|
formcontrol[0].innerHTML = record.get('displayValue');
|
|
|
|
|
} else
|
|
|
|
|
formcontrol[0].innerHTML = '';
|
|
|
|
|
}
|
|
|
|
|
});
|
2020-06-26 11:02:09 +00:00
|
|
|
|
var rec = this.cmbBulletFormat.store.at(1);
|
|
|
|
|
this.cmbBulletFormat.selectRecord(rec);
|
|
|
|
|
this.bulletProps = {symbol: rec.get('symbol'), font: rec.get('font')};
|
2020-06-17 13:55:01 +00:00
|
|
|
|
this.cmbBulletFormat.on('selected', _.bind(function (combo, record) {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.imageControls.toggleClass('hidden', !(record.value === _BulletTypes.image || record.value === _BulletTypes.newImage));
|
|
|
|
|
this.colorControls.toggleClass('hidden', record.value === _BulletTypes.image || record.value === _BulletTypes.newImage);
|
|
|
|
|
if (record.value === _BulletTypes.newSymbol) {
|
2020-07-27 07:38:54 +00:00
|
|
|
|
var me = this,
|
|
|
|
|
props = me.bulletProps,
|
|
|
|
|
handler = function(dlg, result, settings) {
|
|
|
|
|
if (result == 'ok') {
|
|
|
|
|
props.changed = true;
|
|
|
|
|
props.code = settings.code;
|
|
|
|
|
props.font = settings.font;
|
|
|
|
|
props.symbol = settings.symbol;
|
|
|
|
|
if (me._changedProps) {
|
|
|
|
|
me._changedProps.asc_putFont(props.font);
|
|
|
|
|
me._changedProps.asc_putSymbol(props.symbol);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
}
|
2020-07-27 07:38:54 +00:00
|
|
|
|
}
|
|
|
|
|
var store = combo.store;
|
2022-04-11 16:49:58 +00:00
|
|
|
|
if (!store.findWhere({value: _BulletTypes.symbol, symbol: props.symbol, font: props.font})) {
|
|
|
|
|
var idx = store.indexOf(store.findWhere({value: _BulletTypes.image}));
|
|
|
|
|
if (idx<0)
|
|
|
|
|
idx = store.indexOf(store.findWhere({value: _BulletTypes.newSymbol}));
|
|
|
|
|
store.add({ displayValue: me.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: props.symbol, font: props.font }, {at: idx});
|
|
|
|
|
}
|
2020-07-27 07:38:54 +00:00
|
|
|
|
combo.setData(store.models);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
combo.selectRecord(combo.store.findWhere({value: _BulletTypes.symbol, symbol: props.symbol, font: props.font}));
|
2020-07-27 07:38:54 +00:00
|
|
|
|
},
|
|
|
|
|
win = new Common.Views.SymbolTableDialog({
|
|
|
|
|
api: me.options.api,
|
|
|
|
|
lang: me.options.interfaceLang,
|
|
|
|
|
modal: true,
|
|
|
|
|
type: 0,
|
|
|
|
|
font: props.font,
|
|
|
|
|
symbol: props.symbol,
|
|
|
|
|
handler: handler
|
|
|
|
|
});
|
|
|
|
|
win.show();
|
|
|
|
|
win.on('symbol:dblclick', handler);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
} else if (record.value == _BulletTypes.newImage) { // new image
|
|
|
|
|
} else if (record.value == _BulletTypes.image) { // image
|
|
|
|
|
if (this._changedProps)
|
|
|
|
|
this._changedProps.asc_fillBulletImage(this.imageProps.id);
|
|
|
|
|
} else if (record.value == _BulletTypes.none) {
|
2020-07-27 07:38:54 +00:00
|
|
|
|
if (this._changedProps)
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this._changedProps.asc_putListType(0, record.value);
|
2020-07-27 07:38:54 +00:00
|
|
|
|
} else {
|
|
|
|
|
this.bulletProps.changed = true;
|
|
|
|
|
this.bulletProps.code = record.code;
|
|
|
|
|
this.bulletProps.font = record.font;
|
|
|
|
|
this.bulletProps.symbol = record.symbol;
|
|
|
|
|
if (this._changedProps) {
|
|
|
|
|
this._changedProps.asc_putFont(this.bulletProps.font);
|
|
|
|
|
this._changedProps.asc_putSymbol(this.bulletProps.symbol);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.btnOk.setDisabled(record.value === _BulletTypes.newImage);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
}, this));
|
2022-04-11 20:08:36 +00:00
|
|
|
|
this.cmbBulletFormat.on('show:after', _.bind(this.onBulletFormatOpen, this));
|
2020-06-17 13:55:01 +00:00
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
this.spnSize = new Common.UI.MetricSpinner({
|
|
|
|
|
el : $window.find('#id-dlg-list-size'),
|
|
|
|
|
step : 1,
|
2020-06-17 13:55:01 +00:00
|
|
|
|
width : 100,
|
2019-10-30 11:01:02 +00:00
|
|
|
|
value : 100,
|
|
|
|
|
defaultUnit : '',
|
|
|
|
|
maxValue : 400,
|
|
|
|
|
minValue : 25,
|
|
|
|
|
allowDecimal: false
|
|
|
|
|
}).on('change', function(field, newValue, oldValue, eOpts){
|
|
|
|
|
if (me._changedProps) {
|
2020-06-25 10:41:37 +00:00
|
|
|
|
me._changedProps.asc_putSize(field.getNumberValue());
|
2019-10-30 11:01:02 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
this.btnColor = new Common.UI.ColorButton({
|
2020-04-29 17:32:18 +00:00
|
|
|
|
parentEl: $window.find('#id-dlg-list-color'),
|
2020-06-17 13:55:01 +00:00
|
|
|
|
style: "width:45px;",
|
2020-06-25 14:28:38 +00:00
|
|
|
|
additionalAlign: this.menuAddAlign,
|
2021-07-11 13:12:05 +00:00
|
|
|
|
color: this.color,
|
|
|
|
|
cls: 'move-focus',
|
|
|
|
|
takeFocusOnClose: true
|
2019-10-30 11:01:02 +00:00
|
|
|
|
});
|
2020-04-29 17:32:18 +00:00
|
|
|
|
this.btnColor.on('color:select', _.bind(this.onColorsSelect, this));
|
|
|
|
|
this.colors = this.btnColor.getPicker();
|
2019-10-30 11:01:02 +00:00
|
|
|
|
|
2019-10-31 10:57:03 +00:00
|
|
|
|
this.spnStart = new Common.UI.MetricSpinner({
|
|
|
|
|
el : $window.find('#id-dlg-list-start'),
|
|
|
|
|
step : 1,
|
2020-06-17 13:55:01 +00:00
|
|
|
|
width : 100,
|
2019-10-31 10:57:03 +00:00
|
|
|
|
value : 1,
|
|
|
|
|
defaultUnit : '',
|
|
|
|
|
maxValue : 32767,
|
|
|
|
|
minValue : 1,
|
|
|
|
|
allowDecimal: false
|
|
|
|
|
}).on('change', function(field, newValue, oldValue, eOpts){
|
|
|
|
|
if (me._changedProps) {
|
2020-06-25 10:41:37 +00:00
|
|
|
|
me._changedProps.asc_putNumStartAt(field.getNumberValue());
|
2019-10-31 10:57:03 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-04-07 21:28:59 +00:00
|
|
|
|
this.btnSelectImage = new Common.UI.Button({
|
|
|
|
|
parentEl: $('#id-dlg-list-image'),
|
|
|
|
|
cls: 'btn-text-menu-default',
|
|
|
|
|
caption: this.textSelect,
|
|
|
|
|
style: 'width: 100%;',
|
|
|
|
|
menu: new Common.UI.Menu({
|
|
|
|
|
style: 'min-width: 100px;',
|
|
|
|
|
maxHeight: 200,
|
|
|
|
|
additionalAlign: this.menuAddAlign,
|
|
|
|
|
items: [
|
|
|
|
|
{caption: this.textFromFile, value: 0},
|
|
|
|
|
{caption: this.textFromUrl, value: 1},
|
|
|
|
|
{caption: this.textFromStorage, value: 2}
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
this.btnSelectImage.menu.on('item:click', _.bind(this.onImageSelect, this));
|
|
|
|
|
this.btnSelectImage.menu.items[2].setVisible(this.storage);
|
|
|
|
|
|
|
|
|
|
this.btnOk = new Common.UI.Button({
|
|
|
|
|
el: $window.find('.primary')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
me.numberingControls = $window.find('tr.numbering');
|
|
|
|
|
me.imageControls = $window.find('tr.image');
|
|
|
|
|
me.colorControls = $window.find('tr.color');
|
2020-06-17 13:55:01 +00:00
|
|
|
|
|
|
|
|
|
var el = $window.find('table tr:first() td:first()');
|
|
|
|
|
el.width(Math.max($window.find('.numbering .text').width(), el.width()));
|
2019-11-19 14:05:02 +00:00
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
this.afterRender();
|
2020-10-13 11:30:52 +00:00
|
|
|
|
},
|
2020-09-26 21:14:04 +00:00
|
|
|
|
|
2020-10-13 11:30:52 +00:00
|
|
|
|
getFocusedComponents: function() {
|
2022-04-07 21:28:59 +00:00
|
|
|
|
return [this.cmbNumFormat, this.cmbBulletFormat, this.btnSelectImage, this.spnSize, this.spnStart, this.btnColor];
|
2019-10-30 11:01:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
afterRender: function() {
|
|
|
|
|
this.updateThemeColors();
|
|
|
|
|
this._setDefaults(this.props);
|
2022-04-07 21:28:59 +00:00
|
|
|
|
|
|
|
|
|
var me = this;
|
2022-04-11 16:49:58 +00:00
|
|
|
|
var onApiImageLoaded = function(bullet) {
|
2022-04-11 20:08:36 +00:00
|
|
|
|
me.imageProps = {id: bullet.asc_getImageId(), redraw: true};
|
2022-04-11 16:49:58 +00:00
|
|
|
|
if (me._changedProps)
|
|
|
|
|
me._changedProps.asc_fillBulletImage(me.imageProps.id);
|
|
|
|
|
// add or update record for image to btnBulletFormat and select it
|
|
|
|
|
var store = me.cmbBulletFormat.store;
|
|
|
|
|
if (!store.findWhere({value: _BulletTypes.image})) {
|
|
|
|
|
var idx = store.indexOf(store.findWhere({value: _BulletTypes.newSymbol}));
|
2022-04-11 20:08:36 +00:00
|
|
|
|
store.add({ displayValue: me.txtImage + ':', value: _BulletTypes.image }, {at: idx});
|
2022-04-11 16:49:58 +00:00
|
|
|
|
}
|
|
|
|
|
me.cmbBulletFormat.setData(store.models);
|
|
|
|
|
me.cmbBulletFormat.selectRecord(me.cmbBulletFormat.store.findWhere({value: _BulletTypes.image}));
|
2022-04-07 21:28:59 +00:00
|
|
|
|
me.btnOk.setDisabled(false);
|
|
|
|
|
};
|
|
|
|
|
this.api.asc_registerCallback('asc_onBulletImageLoaded', onApiImageLoaded);
|
|
|
|
|
|
|
|
|
|
var insertImageFromStorage = function(data) {
|
|
|
|
|
if (data && data._urls && data.c=='bullet') {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
(new Asc.asc_CBullet()).asc_putImageUrl(data._urls[0], data.token);
|
2022-04-07 21:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
Common.NotificationCenter.on('storage:image-insert', insertImageFromStorage);
|
|
|
|
|
|
|
|
|
|
this.on('close', function(obj){
|
|
|
|
|
me.api.asc_unregisterCallback('asc_onBulletImageLoaded', onApiImageLoaded);
|
|
|
|
|
Common.NotificationCenter.off('storage:image-insert', insertImageFromStorage);
|
|
|
|
|
});
|
2019-10-30 11:01:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
2022-04-11 20:08:36 +00:00
|
|
|
|
onBulletFormatOpen: function(combo) {
|
|
|
|
|
var store = combo.store,
|
|
|
|
|
rec = store.findWhere({value: _BulletTypes.image});
|
|
|
|
|
if (rec && this.imageProps.redraw) {
|
|
|
|
|
var bullet = new Asc.asc_CBullet();
|
|
|
|
|
bullet.asc_fillBulletImage(this.imageProps.id);
|
|
|
|
|
bullet.drawSquareImage('id-dlg-list-bullet-image-preview');
|
|
|
|
|
this.imageProps.redraw = false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
updateThemeColors: function() {
|
|
|
|
|
this.colors.updateColors(Common.Utils.ThemeColor.getEffectColors(), Common.Utils.ThemeColor.getStandartColors());
|
|
|
|
|
},
|
|
|
|
|
|
2020-04-29 17:32:18 +00:00
|
|
|
|
onColorsSelect: function(btn, color) {
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this.color = color;
|
2019-10-30 11:01:02 +00:00
|
|
|
|
if (this._changedProps) {
|
2020-06-25 10:41:37 +00:00
|
|
|
|
this._changedProps.asc_putColor(Common.Utils.ThemeColor.getRgbColor(color));
|
2019-10-30 11:01:02 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2020-06-17 13:55:01 +00:00
|
|
|
|
onListTypeClick: function(type, btn, event) {
|
|
|
|
|
this.ShowHideElem(type);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ShowHideElem: function(value) {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
var isImage = value==0 && (this.cmbBulletFormat.getValue()===_BulletTypes.image || this.cmbBulletFormat.getValue()===_BulletTypes.newImage);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
this.numberingControls.toggleClass('hidden', value==0);
|
2022-04-07 21:28:59 +00:00
|
|
|
|
this.imageControls.toggleClass('hidden', !isImage);
|
|
|
|
|
this.colorControls.toggleClass('hidden', isImage);
|
2020-06-17 13:55:01 +00:00
|
|
|
|
this.cmbNumFormat.setVisible(value==1);
|
|
|
|
|
this.cmbBulletFormat.setVisible(value==0);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.btnOk.setDisabled(isImage && (this.cmbBulletFormat.getValue()===_BulletTypes.newImage));
|
2020-09-26 21:14:04 +00:00
|
|
|
|
var me = this;
|
|
|
|
|
_.delay(function(){
|
|
|
|
|
if (value)
|
|
|
|
|
me.cmbNumFormat.focus();
|
|
|
|
|
else
|
|
|
|
|
me.cmbBulletFormat.focus();
|
|
|
|
|
},50);
|
2019-11-19 14:05:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
_handleInput: function(state) {
|
2020-06-25 14:28:38 +00:00
|
|
|
|
if (this.options.handler)
|
|
|
|
|
{
|
2022-04-07 21:28:59 +00:00
|
|
|
|
if (state == 'ok' && this.btnOk.isDisabled()) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-06-25 14:28:38 +00:00
|
|
|
|
var type = this.btnBullet.pressed ? 0 : 1;
|
2020-06-26 11:02:09 +00:00
|
|
|
|
if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE) {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this._changedProps = new Asc.asc_CBullet();
|
|
|
|
|
this._changedProps.asc_putSize(this.spnSize.getNumberValue());
|
|
|
|
|
if (type==0 && this.cmbBulletFormat.getValue()===_BulletTypes.image && this.imageProps) {//image
|
|
|
|
|
this._changedProps.asc_fillBulletImage(this.imageProps.id);
|
2022-04-07 21:28:59 +00:00
|
|
|
|
} else {
|
|
|
|
|
this._changedProps.asc_putColor(Common.Utils.ThemeColor.getRgbColor(this.color));
|
|
|
|
|
}
|
2020-06-26 11:02:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE ||
|
2022-04-07 21:28:59 +00:00
|
|
|
|
(this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR || this.originalType == AscFormat.BULLET_TYPE_BULLET_BLIP) && type==1 ||
|
|
|
|
|
this.originalType == AscFormat.BULLET_TYPE_BULLET_AUTONUM && type==0) { // changed list type
|
2020-06-25 14:28:38 +00:00
|
|
|
|
if (type==0) {//markers
|
2022-04-11 16:49:58 +00:00
|
|
|
|
if (this.cmbBulletFormat.getValue()==_BulletTypes.none) {
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this._changedProps.asc_putListType(0, -1);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
} else if (this.cmbBulletFormat.getValue()==_BulletTypes.image) {
|
2022-04-07 21:28:59 +00:00
|
|
|
|
|
2020-06-25 14:28:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
this._changedProps.asc_putFont(this.bulletProps.font);
|
|
|
|
|
this._changedProps.asc_putSymbol(this.bulletProps.symbol);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this._changedProps.asc_putListType(1, this.cmbNumFormat.getValue());
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this._changedProps.asc_putNumStartAt(this.spnStart.getNumberValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.options.handler.call(this, state, this._changedProps);
|
2019-10-30 11:01:02 +00:00
|
|
|
|
}
|
|
|
|
|
this.close();
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onBtnClick: function(event) {
|
|
|
|
|
this._handleInput(event.currentTarget.attributes['result'].value);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
onPrimary: function(event) {
|
|
|
|
|
this._handleInput('ok');
|
|
|
|
|
return false;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
_setDefaults: function (props) {
|
|
|
|
|
if (props) {
|
2020-06-26 11:02:09 +00:00
|
|
|
|
var type = 0;
|
2020-06-25 10:41:37 +00:00
|
|
|
|
var bullet = props.asc_getBullet();
|
|
|
|
|
if (bullet) {
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this.originalType = bullet.asc_getType();
|
|
|
|
|
|
2020-06-25 10:41:37 +00:00
|
|
|
|
this.spnSize.setValue(bullet.asc_getSize() || '', true);
|
|
|
|
|
|
|
|
|
|
var color = bullet.asc_getColor();
|
|
|
|
|
if (color) {
|
|
|
|
|
if (color.get_type() == Asc.c_oAscColor.COLOR_TYPE_SCHEME) {
|
|
|
|
|
color = {color: Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b()), effectValue: color.get_value()};
|
|
|
|
|
} else {
|
|
|
|
|
color = Common.Utils.ThemeColor.getHexColor(color.get_r(), color.get_g(), color.get_b());
|
2019-10-30 11:01:02 +00:00
|
|
|
|
}
|
2020-06-25 10:41:37 +00:00
|
|
|
|
} else
|
|
|
|
|
color = 'transparent';
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this.color = Common.Utils.ThemeColor.colorValue2EffectId(color);
|
2020-06-25 10:41:37 +00:00
|
|
|
|
this.btnColor.setColor(color);
|
|
|
|
|
if ( typeof(color) == 'object' ) {
|
|
|
|
|
var isselected = false;
|
|
|
|
|
for (var i=0; i<10; i++) {
|
|
|
|
|
if ( Common.Utils.ThemeColor.ThemeValues[i] == color.effectValue ) {
|
|
|
|
|
this.colors.select(color,true);
|
|
|
|
|
isselected = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!isselected) this.colors.clearSelection();
|
|
|
|
|
} else
|
|
|
|
|
this.colors.select(color,true);
|
|
|
|
|
|
2020-06-26 11:02:09 +00:00
|
|
|
|
if (this.originalType == AscFormat.BULLET_TYPE_BULLET_NONE) {
|
|
|
|
|
this.cmbNumFormat.setValue(-1);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.cmbBulletFormat.setValue(_BulletTypes.none);
|
2020-06-26 11:02:09 +00:00
|
|
|
|
type = this.type;
|
|
|
|
|
} else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_CHAR) {
|
|
|
|
|
var symbol = bullet.asc_getSymbol();
|
|
|
|
|
if (symbol) {
|
|
|
|
|
this.bulletProps = {symbol: symbol, font: bullet.asc_getFont()};
|
2022-04-11 16:49:58 +00:00
|
|
|
|
if (!this.cmbBulletFormat.store.findWhere({value: _BulletTypes.symbol, symbol: this.bulletProps.symbol, font: this.bulletProps.font}))
|
|
|
|
|
this.cmbBulletFormat.store.add({ displayValue: this.txtSymbol + ': ', value: _BulletTypes.symbol, symbol: this.bulletProps.symbol, font: this.bulletProps.font }, {at: this.cmbBulletFormat.store.length-2});
|
2020-06-25 14:28:38 +00:00
|
|
|
|
this.cmbBulletFormat.setData(this.cmbBulletFormat.store.models);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: _BulletTypes.symbol, symbol: this.bulletProps.symbol, font: this.bulletProps.font}));
|
2020-06-25 14:28:38 +00:00
|
|
|
|
} else
|
|
|
|
|
this.cmbBulletFormat.setValue('');
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this._changedProps = bullet;
|
|
|
|
|
type = 0;
|
2022-04-07 21:28:59 +00:00
|
|
|
|
} else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_BLIP) {
|
2022-04-11 20:08:36 +00:00
|
|
|
|
this.imageProps = {id: bullet.asc_getImageId(), redraw: true};
|
2022-04-11 16:49:58 +00:00
|
|
|
|
if (!this.cmbBulletFormat.store.findWhere({value: _BulletTypes.image}))
|
2022-04-11 20:08:36 +00:00
|
|
|
|
this.cmbBulletFormat.store.add({ displayValue: this.txtImage + ':', value: _BulletTypes.image}, {at: this.cmbBulletFormat.store.length-2});
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.cmbBulletFormat.setData(this.cmbBulletFormat.store.models);
|
|
|
|
|
this.cmbBulletFormat.selectRecord(this.cmbBulletFormat.store.findWhere({value: _BulletTypes.image}));
|
2022-04-07 21:28:59 +00:00
|
|
|
|
this._changedProps = bullet;
|
|
|
|
|
type = 0;
|
2020-06-26 11:02:09 +00:00
|
|
|
|
} else if (this.originalType == AscFormat.BULLET_TYPE_BULLET_AUTONUM) {
|
|
|
|
|
var autonum = bullet.asc_getAutoNumType();
|
|
|
|
|
this.cmbNumFormat.setValue(autonum, '');
|
|
|
|
|
|
|
|
|
|
var value = bullet.asc_getNumStartAt();
|
|
|
|
|
this.spnStart.setValue(value || '', true);
|
|
|
|
|
this.spnStart.setDisabled(value===null);
|
|
|
|
|
this._changedProps = bullet;
|
|
|
|
|
type = 1;
|
2019-10-30 11:01:02 +00:00
|
|
|
|
}
|
2020-06-26 11:02:09 +00:00
|
|
|
|
} else {// different bullet types
|
|
|
|
|
this.cmbNumFormat.setValue(-1);
|
2022-04-11 16:49:58 +00:00
|
|
|
|
this.cmbBulletFormat.setValue(_BulletTypes.none);
|
2020-06-26 11:02:09 +00:00
|
|
|
|
this._changedProps = new Asc.asc_CBullet();
|
|
|
|
|
type = this.type;
|
2020-06-25 14:28:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2020-06-26 11:02:09 +00:00
|
|
|
|
|
|
|
|
|
(type == 1) ? this.btnNumbering.toggle(true) : this.btnBullet.toggle(true);
|
|
|
|
|
this.ShowHideElem(type);
|
2019-10-30 11:01:02 +00:00
|
|
|
|
},
|
|
|
|
|
|
2022-04-07 21:28:59 +00:00
|
|
|
|
onImageSelect: function(menu, item) {
|
|
|
|
|
if (item.value==1) {
|
|
|
|
|
var me = this;
|
|
|
|
|
(new Common.Views.ImageFromUrlDialog({
|
|
|
|
|
handler: function(result, value) {
|
|
|
|
|
if (result == 'ok') {
|
|
|
|
|
var checkUrl = value.replace(/ /g, '');
|
|
|
|
|
if (!_.isEmpty(checkUrl)) {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
(new Asc.asc_CBullet()).asc_putImageUrl(checkUrl);
|
2022-04-07 21:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})).show();
|
|
|
|
|
} else if (item.value==2) {
|
|
|
|
|
Common.NotificationCenter.trigger('storage:image-load', 'bullet');
|
|
|
|
|
} else {
|
2022-04-11 16:49:58 +00:00
|
|
|
|
(new Asc.asc_CBullet()).asc_showFileDialog();
|
2022-04-07 21:28:59 +00:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2019-10-30 11:01:02 +00:00
|
|
|
|
txtTitle: 'List Settings',
|
|
|
|
|
txtSize: 'Size',
|
|
|
|
|
txtColor: 'Color',
|
|
|
|
|
txtOfText: '% of text',
|
2019-11-19 14:05:02 +00:00
|
|
|
|
txtStart: 'Start at',
|
2020-06-17 13:55:01 +00:00
|
|
|
|
textBulleted: 'Bulleted',
|
|
|
|
|
textNumbering: 'Numbered',
|
|
|
|
|
txtType: 'Type',
|
|
|
|
|
txtNone: 'None',
|
|
|
|
|
txtNewBullet: 'New bullet',
|
2022-04-07 21:28:59 +00:00
|
|
|
|
txtSymbol: 'Symbol',
|
|
|
|
|
txtNewImage: 'New image',
|
|
|
|
|
txtImage: 'Image',
|
|
|
|
|
txtImport: 'Import',
|
|
|
|
|
textSelect: 'Select From',
|
|
|
|
|
textFromUrl: 'From URL',
|
|
|
|
|
textFromFile: 'From File',
|
|
|
|
|
textFromStorage: 'From Storage'
|
2019-11-07 10:37:14 +00:00
|
|
|
|
}, Common.Views.ListSettingsDialog || {}))
|
2019-10-30 11:01:02 +00:00
|
|
|
|
});
|