[PE] Insert date&time
This commit is contained in:
parent
3bb1f0f7c4
commit
fa89f02b65
|
@ -51,6 +51,7 @@ define([
|
|||
'common/main/lib/util/define',
|
||||
'presentationeditor/main/app/collection/SlideThemes',
|
||||
'presentationeditor/main/app/view/Toolbar',
|
||||
'presentationeditor/main/app/view/DateTimeDialog',
|
||||
'presentationeditor/main/app/view/HyperlinkSettingsDialog',
|
||||
'presentationeditor/main/app/view/SlideSizeSettings',
|
||||
'presentationeditor/main/app/view/SlideshowSettings'
|
||||
|
@ -360,6 +361,7 @@ define([
|
|||
this.api.asc_registerCallback('asc_onCountPages', _.bind(this.onApiCountPages, this));
|
||||
this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this));
|
||||
this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this));
|
||||
this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this.onTextLanguage, this));
|
||||
},
|
||||
|
||||
onChangeCompactView: function(view, compact) {
|
||||
|
@ -1461,6 +1463,19 @@ define([
|
|||
this.api.asc_addSlideNumber();
|
||||
} else if (in_text && type=='datetime') {
|
||||
//insert date time
|
||||
var me = this;
|
||||
(new PE.Views.DateTimeDialog({
|
||||
api: this.api,
|
||||
lang: this._state.lang,
|
||||
handler: function(result, value) {
|
||||
if (result == 'ok') {
|
||||
if (me.api) {
|
||||
me.api.asc_addDateTime(value);
|
||||
}
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
|
||||
}
|
||||
})).show();
|
||||
} else {
|
||||
//insert header/footer
|
||||
}
|
||||
|
@ -2101,6 +2116,10 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onTextLanguage: function(langId) {
|
||||
this._state.lang = langId;
|
||||
},
|
||||
|
||||
textEmptyImgUrl : 'You need to specify image URL.',
|
||||
textWarning : 'Warning',
|
||||
textFontSizeErr : 'The entered value must be more than 0',
|
||||
|
|
215
apps/presentationeditor/main/app/view/DateTimeDialog.js
Normal file
215
apps/presentationeditor/main/app/view/DateTimeDialog.js
Normal file
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* DateTimeDialog.js
|
||||
*
|
||||
* Created by Julia Radzhabova on 26.06.2019
|
||||
* Copyright (c) 2019 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([
|
||||
'common/main/lib/component/Window',
|
||||
'common/main/lib/component/ComboBox',
|
||||
'common/main/lib/component/ListView'
|
||||
], function () {
|
||||
'use strict';
|
||||
|
||||
PE.Views.DateTimeDialog = Common.UI.Window.extend(_.extend({
|
||||
options: {
|
||||
width: 300,
|
||||
style: 'min-width: 230px;',
|
||||
cls: 'modal-dlg'
|
||||
},
|
||||
|
||||
initialize : function (options) {
|
||||
var t = this,
|
||||
_options = {};
|
||||
|
||||
_.extend(this.options, {
|
||||
title: this.txtTitle
|
||||
}, options || {});
|
||||
|
||||
this.template = [
|
||||
'<div class="box" style="height: 287px;">',
|
||||
'<div class="input-row">',
|
||||
'<label style="font-weight: bold;">' + this.textLang + '</label>',
|
||||
'</div>',
|
||||
'<div id="datetime-dlg-lang" class="input-row" style="margin-bottom: 8px;"></div>',
|
||||
'<div class="input-row">',
|
||||
'<label style="font-weight: bold;">' + this.textFormat + '</label>',
|
||||
'</div>',
|
||||
'<div id="datetime-dlg-format" class="" style="margin-bottom: 10px;width: 100%; height: 184px; overflow: hidden;"></div>',
|
||||
'<div class="input-row">',
|
||||
'<div id="datetime-dlg-update"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div class="footer center">',
|
||||
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + '</button>',
|
||||
'<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + '</button>',
|
||||
'</div>'
|
||||
].join('');
|
||||
|
||||
this.options.tpl = _.template(this.template)(this.options);
|
||||
this.api = this.options.api;
|
||||
this.lang = this.options.lang;
|
||||
this.handler = this.options.handler;
|
||||
|
||||
Common.UI.Window.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
render: function () {
|
||||
Common.UI.Window.prototype.render.call(this);
|
||||
|
||||
var data = [{ value: 0x042C }, { value: 0x0402 }, { value: 0x0405 }, { value: 0x0407 }, {value: 0x0807}, { value: 0x0408 }, { value: 0x0C09 }, { value: 0x0809 }, { value: 0x0409 }, { value: 0x0C0A }, { value: 0x080A },
|
||||
{ value: 0x040B }, { value: 0x040C }, { value: 0x0410 }, { value: 0x0411 }, { value: 0x0412 }, { value: 0x0426 }, { value: 0x0413 }, { value: 0x0415 }, { value: 0x0416 },
|
||||
{ value: 0x0816 }, { value: 0x0419 }, { value: 0x041B }, { value: 0x0424 }, { value: 0x081D }, { value: 0x041D }, { value: 0x041F }, { value: 0x0422 }, { value: 0x042A }, { value: 0x0804 }];
|
||||
data.forEach(function(item) {
|
||||
var langinfo = Common.util.LanguageInfo.getLocalLanguageName(item.value);
|
||||
item.displayValue = langinfo[1];
|
||||
item.langName = langinfo[0];
|
||||
});
|
||||
|
||||
this.cmbLang = new Common.UI.ComboBox({
|
||||
el : $('#datetime-dlg-lang'),
|
||||
menuStyle : 'min-width: 100%; max-height: 185px;',
|
||||
cls : 'input-group-nr',
|
||||
editable : false,
|
||||
data : data
|
||||
});
|
||||
this.cmbLang.setValue(0x0409);
|
||||
this.cmbLang.on('selected', _.bind(function(combo, record) {
|
||||
this.updateFormats(record.value);
|
||||
}, this));
|
||||
|
||||
this.chUpdate = new Common.UI.CheckBox({
|
||||
el: $('#datetime-dlg-update'),
|
||||
labelText: this.textUpdate
|
||||
});
|
||||
this.chUpdate.on('change', _.bind(function(field, newValue, oldValue, eOpts){
|
||||
this.onSelectFormat(this.listFormats, null, this.listFormats.getSelectedRec());
|
||||
}, this));
|
||||
|
||||
this.listFormats = new Common.UI.ListView({
|
||||
el: $('#datetime-dlg-format'),
|
||||
store: new Common.UI.DataViewStore(),
|
||||
scrollAlwaysVisible: true
|
||||
});
|
||||
|
||||
this.listFormats.on('item:select', _.bind(this.onSelectFormat, this));
|
||||
this.listFormats.on('item:dblclick', _.bind(this.onDblClickFormat, this));
|
||||
this.listFormats.on('entervalue', _.bind(this.onPrimary, this));
|
||||
this.listFormats.$el.find('.listview').focus();
|
||||
|
||||
this.$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
afterRender: function() {
|
||||
this._setDefaults();
|
||||
},
|
||||
|
||||
_setDefaults: function () {
|
||||
this.props = new AscCommonSlide.CAscDateTime();
|
||||
|
||||
if (this.lang) {
|
||||
var item = this.cmbLang.store.findWhere({value: this.lang});
|
||||
this.cmbLang.setValue(item ? item.get('value') : 0x0409);
|
||||
}
|
||||
this.updateFormats(this.cmbLang.getValue());
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
return this.props;
|
||||
},
|
||||
|
||||
updateFormats: function(lang) {
|
||||
this.props.put_Lang(lang);
|
||||
var data = this.props.get_DateTimeExamples(),
|
||||
arr = [];
|
||||
var store = this.listFormats.store;
|
||||
for (var name in data) {
|
||||
if (data[name]) {
|
||||
var rec = new Common.UI.DataViewModel();
|
||||
rec.set({
|
||||
format: name,
|
||||
value: data[name]
|
||||
});
|
||||
arr.push(rec);
|
||||
}
|
||||
}
|
||||
this.listFormats.store.reset(arr);
|
||||
this.listFormats.selectByIndex(0);
|
||||
this.onSelectFormat(this.listFormats, null, this.listFormats.getSelectedRec());
|
||||
},
|
||||
|
||||
onSelectFormat: function(lisvView, itemView, record) {
|
||||
if (!record) return;
|
||||
if (this.chUpdate.getValue()=='checked') {
|
||||
this.props.put_DateTime(record.get('format'));
|
||||
} else {
|
||||
this.props.put_DateTime(null);
|
||||
this.props.put_CustomDateTime(record.get('value'));
|
||||
}
|
||||
},
|
||||
|
||||
onBtnClick: function(event) {
|
||||
this._handleInput(event.currentTarget.attributes['result'].value);
|
||||
},
|
||||
|
||||
onDblClickFormat: function () {
|
||||
this._handleInput('ok');
|
||||
},
|
||||
|
||||
onPrimary: function(event) {
|
||||
this._handleInput('ok');
|
||||
return false;
|
||||
},
|
||||
|
||||
_handleInput: function(state) {
|
||||
if (this.options.handler) {
|
||||
this.options.handler.call(this, state, this.getSettings());
|
||||
}
|
||||
|
||||
this.close();
|
||||
},
|
||||
|
||||
//
|
||||
cancelButtonText: 'Cancel',
|
||||
okButtonText: 'Ok',
|
||||
txtTitle: 'Date & Time',
|
||||
textLang: 'Language',
|
||||
textFormat: 'Formats',
|
||||
textUpdate: 'Update automatically'
|
||||
|
||||
}, PE.Views.DateTimeDialog || {}));
|
||||
});
|
|
@ -945,6 +945,12 @@
|
|||
"PE.Views.ChartSettingsAdvanced.textAltTip": "The alternative text-based representation of the visual object information, which will be read to the people with vision or cognitive impairments to help them better understand what information there is in the image, autoshape, chart or table.",
|
||||
"PE.Views.ChartSettingsAdvanced.textAltTitle": "Title",
|
||||
"PE.Views.ChartSettingsAdvanced.textTitle": "Chart - Advanced Settings",
|
||||
"PE.Views.DateTimeDialog.cancelButtonText": "Cancel",
|
||||
"PE.Views.DateTimeDialog.okButtonText": "Ok",
|
||||
"PE.Views.DateTimeDialog.txtTitle": "Date & Time",
|
||||
"PE.Views.DateTimeDialog.textLang": "Language",
|
||||
"PE.Views.DateTimeDialog.textFormat": "Formats",
|
||||
"PE.Views.DateTimeDialog.textUpdate": "Update automatically",
|
||||
"PE.Views.DocumentHolder.aboveText": "Above",
|
||||
"PE.Views.DocumentHolder.addCommentText": "Add Comment",
|
||||
"PE.Views.DocumentHolder.advancedImageText": "Image Advanced Settings",
|
||||
|
|
Loading…
Reference in a new issue