web-apps/apps/spreadsheeteditor/main/app/view/Spellcheck.js

204 lines
7.7 KiB
JavaScript
Raw Normal View History

2019-07-31 12:46:50 +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
*
*/
/**
* User: Julia.Radzhabova
* Date: 30.07.19
*/
define([
'common/main/lib/util/utils',
'common/main/lib/component/BaseView',
2019-08-02 10:56:21 +00:00
'common/main/lib/component/Layout',
'common/main/lib/component/Button',
'common/main/lib/component/ListView',
'common/main/lib/component/InputField',
'common/main/lib/component/ComboBox',
'common/main/lib/component/ComboDataView'
2019-07-31 12:46:50 +00:00
], function (template) {
'use strict';
SSE.Views.Spellcheck = Common.UI.BaseView.extend(_.extend({
el: '#left-panel-spellcheck',
template: _.template([
2020-12-19 19:45:36 +00:00
'<div id="spellcheck-box" class="layout-ct vbox active">',
'<div id="spellcheck-header" style="font-size: 14px; padding-bottom: 16px;"><%= scope.txtSpelling %></div>',
'<div style="display: flex; width: 100%; padding-bottom: 8px;">',
'<div id="spellcheck-current-word"></div>',
'<div id="spellcheck-next" style=""></div>',
'</div>',
'<div id="spellcheck-suggestions-list"></div>',
'<div id="spellcheck-change" style=""></div>',
'<div id="spellcheck-ignore" class="padding-large"></div>',
'<button class="btn btn-text-default auto" id="spellcheck-add-to-dictionary"><%= scope.txtAddToDictionary %></button>',
'<label class="header" style="display: block;"><%= scope.txtDictionaryLanguage %></label>',
'<div id="spellcheck-dictionary-language"></div>',
'<div id="spellcheck-complete" class="hidden">',
'<i class="img-commonctrl img-colored img-complete" style="display: inline-block;margin-right: 10px;"></i>',
2020-12-19 19:45:36 +00:00
'<%= scope.txtComplete %>' ,
'</div>',
2019-07-31 12:46:50 +00:00
'</div>'
].join('')),
initialize: function(options) {
_.extend(this, options);
Common.UI.BaseView.prototype.initialize.call(this, arguments);
},
render: function(el) {
el = el || this.el;
this.$el = $(el);
this.$el.html(this.template({scope: this}));
2019-08-02 10:56:21 +00:00
this.currentWord = new Common.UI.InputField({
el : $('#spellcheck-current-word'),
allowBlank : true,
2019-08-06 06:33:16 +00:00
validateOnBlur: false,
disabled: true
2019-08-02 10:56:21 +00:00
});
this.buttonNext = new Common.UI.Button({
2020-04-29 07:36:53 +00:00
parentEl: $('#spellcheck-next'),
2019-08-02 10:56:21 +00:00
style: 'margin-left: 5px; width: 22px; height: 22px; border: 1px solid #cfcfcf;',
cls: 'btn-toolbar bg-white',
2019-11-27 17:15:14 +00:00
iconCls: 'toolbar__icon btn-nextitem',
2019-08-06 08:11:31 +00:00
hint: this.txtNextTip
2019-08-02 10:56:21 +00:00
});
this.suggestionList = new Common.UI.ListView({
el: $('#spellcheck-suggestions-list'),
emptyText: this.noSuggestions,
2019-08-06 10:36:02 +00:00
store: new Common.UI.DataViewStore(),
scrollAlwaysVisible: true
2019-08-02 10:56:21 +00:00
});
this.btnChange = new Common.UI.Button({
2020-04-29 07:36:53 +00:00
parentEl: $('#spellcheck-change'),
2019-08-02 10:56:21 +00:00
cls: 'btn-text-split-default',
caption: this.textChange,
split: true,
2019-08-06 10:36:02 +00:00
width: 110,
2019-08-06 06:33:16 +00:00
disabled: true,
2019-08-02 10:56:21 +00:00
menu : new Common.UI.Menu({
2019-08-06 10:36:02 +00:00
style : 'min-width: 110px',
2019-08-02 10:56:21 +00:00
items: [
{
caption: this.textChange,
value: 0
},
{
caption: this.textChangeAll,
2019-08-07 10:33:39 +00:00
value: 1
2019-08-02 10:56:21 +00:00
}
]
})
});
this.btnIgnore = new Common.UI.Button({
2020-04-29 07:36:53 +00:00
parentEl: $('#spellcheck-ignore'),
2019-08-02 10:56:21 +00:00
cls: 'btn-text-split-default',
caption: this.textIgnore,
split: true,
2019-08-06 10:36:02 +00:00
width: 110,
2019-08-06 06:33:16 +00:00
disabled: true,
2019-08-02 10:56:21 +00:00
menu : new Common.UI.Menu({
2019-08-06 10:36:02 +00:00
style : 'min-width: 110px;',
2019-08-02 10:56:21 +00:00
items: [
{
caption: this.textIgnore,
value: 0
},
{
caption: this.textIgnoreAll,
2019-08-15 07:23:43 +00:00
value: 1
2019-08-02 10:56:21 +00:00
}
]
})
});
this.cmbDictionaryLanguage = new Common.UI.ComboBox({
el : $('#spellcheck-dictionary-language'),
2019-08-06 06:47:59 +00:00
style : 'width: 100%',
2019-08-06 11:27:47 +00:00
menuStyle : 'width: 100%;max-height: 163px;',
2019-08-02 10:56:21 +00:00
editable : false,
2019-08-06 12:08:25 +00:00
cls : 'input-group-nr',
scroller : {
suppressScrollX: true
},
search: true
2019-08-02 10:56:21 +00:00
});
2019-08-05 13:37:09 +00:00
this.btnToDictionary = new Common.UI.Button({
el: $('#spellcheck-add-to-dictionary'),
disabled : true
2019-08-05 13:37:09 +00:00
});
2019-08-02 10:56:21 +00:00
2019-08-05 21:03:19 +00:00
this.lblComplete = this.$el.find('#spellcheck-complete');
2019-07-31 12:46:50 +00:00
this.trigger('render:after', this);
2019-08-06 12:08:25 +00:00
if (_.isUndefined(this.scroller)) {
this.scroller = new Common.UI.Scroller({
el: this.$el.find('#spellcheck-box'),
suppressScrollX: true
});
}
2019-07-31 12:46:50 +00:00
return this;
},
show: function () {
Common.UI.BaseView.prototype.show.call(this,arguments);
this.fireEvent('show', this );
},
hide: function () {
Common.UI.BaseView.prototype.hide.call(this,arguments);
this.fireEvent('hide', this );
},
ChangeSettings: function(props) {
},
2019-08-02 10:56:21 +00:00
txtSpelling: 'Spelling',
noSuggestions: 'No spelling suggestions',
textChange: 'Change',
textChangeAll: 'Change All',
textIgnore: 'Ignore',
textIgnoreAll: 'Ignore All',
txtAddToDictionary: 'Add To Dictionary',
txtDictionaryLanguage: 'Dictionary Language',
2019-08-06 08:11:31 +00:00
txtComplete: 'Spellcheck has been complete',
txtNextTip: 'Go to the next word'
2019-08-02 10:56:21 +00:00
2019-07-31 12:46:50 +00:00
}, SSE.Views.Spellcheck || {}));
});