Commit 5ef1e5c3 authored by Julia Radzhabova's avatar Julia Radzhabova

[PE] Added spell check + changing document language. Moved LanguageDialog to Common.

parent 6448ebe8
/*
*
* (c) Copyright Ascensio System Limited 2010-2017
*
* 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 Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* 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
*
*/
/**
* LanguageDialog.js
*
* Created by Julia Radzhabova on 04/25/2017
* Copyright (c) 2017 Ascensio System SIA. All rights reserved.
*
*/
if (Common === undefined)
var Common = {};
define([
'common/main/lib/component/Window'
], function () { 'use strict';
Common.Views.LanguageDialog = Common.UI.Window.extend(_.extend({
options: {
header: false,
width: 350,
cls: 'modal-dlg'
},
template: '<div class="box">' +
'<div class="input-row">' +
'<label><%= label %></label>' +
'</div>' +
'<div class="input-row" id="id-document-language">' +
'</div>' +
'</div>' +
'<div class="footer right">' +
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;"><%= btns.ok %></button>'+
'<button class="btn normal dlg-btn" result="cancel"><%= btns.cancel %></button>'+
'</div>',
initialize : function(options) {
_.extend(this.options, options || {}, {
label: this.labelSelect,
btns: {ok: this.btnOk, cancel: this.btnCancel}
});
this.options.tpl = _.template(this.template)(this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function() {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.cmbLanguage = new Common.UI.ComboBox({
el: $window.find('#id-document-language'),
cls: 'input-group-nr',
menuStyle: 'min-width: 318px; max-height: 300px;',
editable: false,
template: _.template([
'<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">',
'<input type="text" class="form-control">',
'<span class="input-lang-icon lang-flag" style="position: absolute;"></span>',
'<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) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>">',
'<a tabindex="-1" type="menuitem" style="padding-left: 26px !important;">',
'<span class="lang-item-icon lang-flag <%= item.value %>" style="position: absolute;margin-left:-21px;"></span>',
'<%= scope.getDisplayValue(item) %>',
'</a>',
'</li>',
'<% }); %>',
'</ul>',
'</span>'
].join('')),
data: this.options.languages
});
if (this.cmbLanguage.scroller) this.cmbLanguage.scroller.update({alwaysVisibleY: true});
this.cmbLanguage.on('selected', _.bind(this.onLangSelect, this));
this.cmbLanguage.setValue(Common.util.LanguageInfo.getLocalLanguageName(this.options.current)[0]);
this.onLangSelect(this.cmbLanguage, this.cmbLanguage.getSelectedRecord());
},
close: function(suppressevent) {
var $window = this.getChild();
if (!$window.find('.combobox.open').length) {
Common.UI.Window.prototype.close.call(this, arguments);
}
},
onBtnClick: function(event) {
if (this.options.handler) {
this.options.handler.call(this, event.currentTarget.attributes['result'].value, this.cmbLanguage.getValue());
}
this.close();
},
onLangSelect: function(cmb, rec, e) {
var icon = cmb.$el.find('.input-lang-icon'),
plang = icon.attr('lang');
if (plang) icon.removeClass(plang);
icon.addClass(rec.value).attr('lang',rec.value);
},
labelSelect : 'Select document language',
btnCancel : 'Cancel',
btnOk : 'Ok'
}, Common.Views.LanguageDialog || {}))
});
\ No newline at end of file
......@@ -178,4 +178,20 @@
background-image: data-uri(%("%s",'@{common-image-path}/hsbcolorpicker/hsb-colorpicker@2x.png'));
background-size: @img-colorpicker-width auto;
}
}
@img-flags-width: 48px;
.lang-flag {
width: 16px;
height: 12px;
background-image: data-uri(%("%s",'@{common-image-path}/controls/flags.png'));
background-repeat: no-repeat;
@media
only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and (min-resolution: 2dppx),
only screen and (min-resolution: 192dpi) {
background-image: data-uri(%("%s",'@{common-image-path}/controls/flags@2x.png'));
background-size: @img-flags-width auto;
}
}
\ No newline at end of file
.combo-langs {
.dropdown-menu {
li .lang-item-icon {
margin-top: 1px;
}
}
.input-lang-icon {
position: absolute;
left: 5px;
top: 5px;
}
input {
padding-left: 25px !important;
}
}
.lang-flag {
background-position: -16px -108px;
&.ca, &.ca-ES {background-position: 0 0;}
&.cs, &.cs-CZ {background-position: -16px 0;}
&.da, &.da-DK {background-position: -32px 0;}
&.de, &.de-DE {background-position: 0 -12px;}
&.el, &.el-GR {background-position: -16px -12px;}
&.en, &.en-US {background-position: -32px -12px;}
&.fr, &.fr-FR {background-position: 0 -24px;}
&.hu, &.hu-HU {background-position: -16px -24px;}
&.it, &.it-IT {background-position: -32px -24px;}
&.ko, &.ko-KR {background-position: 0 -36px;}
&.nl, &.nl-NL {background-position: -16px -36px;}
&.nb, &.nb-NO {background-position: -32px -36px;}
&.pl, &.pl-PL {background-position: 0 -48px;}
&.pt, &.pt-BR {background-position: -16px -48px;}
&.ro, &.ro-RO {background-position: -32px -48px;}
&.ru, &.ru-RU {background-position: 0 -60px;}
&.sv, &.sv-SE {background-position: -32px -60px;}
&.tr, &.tr-TR {background-position: 0 -72px;}
&.uk, &.uk-UA {background-position: -16px -72px;}
&.lv, &.lv-LV {background-position: -32px -72px;}
&.lt, &.lt-LT {background-position: 0 -84px;}
&.vi, &.vi-VN {background-position: -16px -84px;}
&.de-CH {background-position: -32px -84px;}
&.nn, &.nn-NO {background-position: 0 -96px;}
&.pt-PT {background-position: -16px -96px;}
&.de-AT {background-position: -32px -96px;}
&.es, &.es-ES {background-position: 0 -108px;}
&.en-GB {background-position: -32px -108px;}
&.en-AU {background-position: 0 -120px;}
&.az-Latn-AZ {background-position: -16px -120px;}
&.id, &.id-ID {background-position: -32px -120px;}
&.bg, &.bg-BG {background-position: 0 -132px;}
&.ca-ES-valencia {background-position: -16px -132px;}
&.en-CA {background-position: -32px -132px;}
&.en-ZA {background-position: 0 -144px;}
&.eu, &.eu-ES {background-position: -16px -144px;}
&.gl, &.gl-ES {background-position: -32px -144px;}
&.hr, &.hr-HR {background-position: 0 -156px;}
&.lb, &.lb-LU {background-position: -16px -156px;}
&.mn, &.mn-MN {background-position: -32px -156px;}
&.sl, &.sl-SI {background-position: 0 -168px;}
&.sr, &.sr-Cyrl-RS, &.sr-Latn-RS {background-position: -16px -168px;}
&.sk, &.sk-SK {background-position: -32px -168px;}
&.kk, &.kk-KZ {background-position: 0 -180px;}
}
......@@ -44,7 +44,8 @@ define([
'core',
'documenteditor/main/app/view/Statusbar',
'common/main/lib/util/LanguageInfo',
'common/main/lib/view/ReviewChanges'
'common/main/lib/view/ReviewChanges',
'common/main/lib/view/LanguageDialog'
], function () {
'use strict';
......@@ -141,9 +142,6 @@ define([
});
},
/*
* */
setLanguages: function(langs) {
this.langs = langs;
this.statusbar.reloadLanguages(langs);
......@@ -239,7 +237,7 @@ define([
});
var me = this;
(new DE.Views.Statusbar.LanguageDialog({
(new Common.Views.LanguageDialog({
languages: langs,
current: me.api.asc_getDefaultLanguage(),
handler: function(result, tip) {
......
......@@ -29,7 +29,7 @@
<div class="separator short el-edit"></div>
<div class="cnt-lang el-edit">
<div class="dropdown-toggle" data-toggle="dropdown" style="margin-right: 6px;">
<span class="icon-lang-flag img-toolbarmenu lang-flag" data-vertical-offset="10" />
<span class="icon-lang-flag lang-flag" data-vertical-offset="10" />
<label id="status-label-lang" class="status-label">English (United States)</label>
<div class="caret up img-commonctrl" />
</div>
......
......@@ -79,9 +79,6 @@ define([
this.fireEvent('langchanged', [this, item.value.code, item.caption]);
}
if ( DE.Views.Statusbar )
var LanguageDialog = DE.Views.Statusbar.LanguageDialog || {};
DE.Views.Statusbar = Backbone.View.extend(_.extend({
el: '#statusbar',
template: _.template(template),
......@@ -194,7 +191,7 @@ define([
maxHeight: 300,
itemTemplate: _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem">',
'<span class="lang-item-icon img-toolbarmenu lang-flag <%= iconCls %>"></span>',
'<span class="lang-item-icon lang-flag <%= iconCls %>"></span>',
'<%= caption %>',
'</a>'
].join('')),
......@@ -486,7 +483,7 @@ define([
},
setLanguage: function(info) {
if (this.langMenu.prevTip != info.tip) {
if (this.langMenu.prevTip != info.tip && info.code !== undefined) {
var $parent = $(this.langMenu.el.parentNode, this.$el);
$parent.find('.icon-lang-flag')
.removeClass(this.langMenu.prevTip)
......@@ -542,99 +539,5 @@ define([
tipViewUsers : 'View users and manage document access rights',
txAccessRights : 'Change access rights'
}, DE.Views.Statusbar || {}));
DE.Views.Statusbar.LanguageDialog = Common.UI.Window.extend(_.extend({
options: {
header: false,
width: 350,
cls: 'modal-dlg'
},
template: '<div class="box">' +
'<div class="input-row">' +
'<label><%= label %></label>' +
'</div>' +
'<div class="input-row" id="id-document-language">' +
'</div>' +
'</div>' +
'<div class="footer right">' +
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;"><%= btns.ok %></button>'+
'<button class="btn normal dlg-btn" result="cancel"><%= btns.cancel %></button>'+
'</div>',
initialize : function(options) {
_.extend(this.options, options || {}, {
label: this.labelSelect,
btns: {ok: this.btnOk, cancel: this.btnCancel}
});
this.options.tpl = _.template(this.template)(this.options);
Common.UI.Window.prototype.initialize.call(this, this.options);
},
render: function() {
Common.UI.Window.prototype.render.call(this);
var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
this.cmbLanguage = new Common.UI.ComboBox({
el: $window.find('#id-document-language'),
cls: 'input-group-nr',
menuStyle: 'min-width: 318px; max-height: 300px;',
editable: false,
template: _.template([
'<span class="input-group combobox <%= cls %> combo-langs" id="<%= id %>" style="<%= style %>">',
'<input type="text" class="form-control">',
'<span class="input-lang-icon img-toolbarmenu lang-flag" style="position: absolute;"></span>',
'<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) { %>',
'<li id="<%= item.id %>" data-value="<%= item.value %>">',
'<a tabindex="-1" type="menuitem" style="padding-left: 26px !important;">',
'<span class="lang-item-icon img-toolbarmenu lang-flag <%= item.value %>" style="position: absolute;margin-left:-21px;"></span>',
'<%= scope.getDisplayValue(item) %>',
'</a>',
'</li>',
'<% }); %>',
'</ul>',
'</span>'
].join('')),
data: this.options.languages
});
if (this.cmbLanguage.scroller) this.cmbLanguage.scroller.update({alwaysVisibleY: true});
this.cmbLanguage.on('selected', _.bind(this.onLangSelect, this));
this.cmbLanguage.setValue(Common.util.LanguageInfo.getLocalLanguageName(this.options.current)[0]);
this.onLangSelect(this.cmbLanguage, this.cmbLanguage.getSelectedRecord());
},
close: function(suppressevent) {
var $window = this.getChild();
if (!$window.find('.combobox.open').length) {
Common.UI.Window.prototype.close.call(this, arguments);
}
},
onBtnClick: function(event) {
if (this.options.handler) {
this.options.handler.call(this, event.currentTarget.attributes['result'].value, this.cmbLanguage.getValue());
}
this.close();
},
onLangSelect: function(cmb, rec, e) {
var icon = cmb.$el.find('.input-lang-icon'),
plang = icon.attr('lang');
if (plang) icon.removeClass(plang);
icon.addClass(rec.value).attr('lang',rec.value);
},
labelSelect : 'Select document language',
btnCancel : 'Cancel',
btnOk : 'Ok'
}, LanguageDialog||{}));
}
);
\ No newline at end of file
......@@ -161,6 +161,9 @@
"Common.Views.InsertTableDialog.txtMinText": "The minimum value for this field is {0}.",
"Common.Views.InsertTableDialog.txtRows": "Number of Rows",
"Common.Views.InsertTableDialog.txtTitle": "Table Size",
"Common.Views.LanguageDialog.btnCancel": "Cancel",
"Common.Views.LanguageDialog.btnOk": "Ok",
"Common.Views.LanguageDialog.labelSelect": "Select document language",
"Common.Views.OpenDialog.cancelButtonText": "Cancel",
"Common.Views.OpenDialog.okButtonText": "OK",
"Common.Views.OpenDialog.txtEncoding": "Encoding ",
......@@ -1288,9 +1291,9 @@
"DE.Views.ShapeSettings.txtTopAndBottom": "Top and bottom",
"DE.Views.ShapeSettings.txtWood": "Wood",
"DE.Views.Statusbar.goToPageText": "Go to Page",
"DE.Views.Statusbar.LanguageDialog.btnCancel": "Cancel",
"DE.Views.Statusbar.LanguageDialog.btnOk": "Ok",
"DE.Views.Statusbar.LanguageDialog.labelSelect": "Select document language",
"del_DE.Views.Statusbar.LanguageDialog.btnCancel": "Cancel",
"del_DE.Views.Statusbar.LanguageDialog.btnOk": "Ok",
"del_DE.Views.Statusbar.LanguageDialog.labelSelect": "Select document language",
"DE.Views.Statusbar.pageIndexText": "Page {0} of {1}",
"DE.Views.Statusbar.textChangesPanel": "Changes Panel",
"DE.Views.Statusbar.textTrackChanges": "Track Changes",
......
......@@ -114,6 +114,7 @@
@import "../../../../common/main/resources/less/opendialog.less";
@import "../../../../common/main/resources/less/review-changes.less";
@import "../../../../common/main/resources/less/plugins.less";
@import "../../../../common/main/resources/less/language-dialog.less";
// App
// --------------------------------------------------
......
......@@ -78,13 +78,11 @@
color: #000;
margin-left: 6px;
.icon-lang-flag {
.dropdown-toggle > .icon-lang-flag {
position: relative;
top: 3px;
margin-left: 3px;
margin-right: 2px;
width: 16px;
height: 12px;
display: inline-block;
}
......@@ -102,9 +100,6 @@
.dropdown-menu {
li .lang-item-icon {
width: 16px;
height: 12px;
display: inline-block;
vertical-align: text-bottom;
margin: 1px 5px 0 2px;
......@@ -217,79 +212,6 @@
}
}
.combo-langs {
.dropdown-menu {
li .lang-item-icon {
margin-top: 1px;
width: 16px;
height: 12px;
}
}
.input-lang-icon {
position: absolute;
width: 16px;
height: 12px;
left: 5px;
top: 5px;
}
input {
padding-left: 25px !important;
}
}
.lang-flag {
background-position: -16px -1608px;
&.ca, &.ca-ES {background-position: 0 -1499px;}
&.cs, &.cs-CZ {background-position: -16px -1500px;}
&.da, &.da-DK {background-position: -32px -1500px;}
&.de, &.de-DE {background-position: 0 -1512px;}
&.el, &.el-GR {background-position: -16px -1512px;}
&.en, &.en-US {background-position: -32px -1512px;}
&.fr, &.fr-FR {background-position: 0 -1524px;}
&.hu, &.hu-HU {background-position: -16px -1524px;}
&.it, &.it-IT {background-position: -32px -1524px;}
&.ko, &.ko-KR {background-position: 0 -1536px;}
&.nl, &.nl-NL {background-position: -16px -1536px;}
&.nb, &.nb-NO {background-position: -32px -1536px;}
&.pl, &.pl-PL {background-position: 0 -1548px;}
&.pt, &.pt-BR {background-position: -16px -1548px;}
&.ro, &.ro-RO {background-position: -32px -1548px;}
&.ru, &.ru-RU {background-position: 0 -1560px;}
&.sv, &.sv-SE {background-position: -32px -1560px;}
&.tr, &.tr-TR {background-position: 0 -1572px;}
&.uk, &.uk-UA {background-position: -16px -1572px;}
&.lv, &.lv-LV {background-position: -32px -1572px;}
&.lt, &.lt-LT {background-position: 0 -1584px;}
&.vi, &.vi-VN {background-position: -16px -1584px;}
&.de-CH {background-position: -32px -1584px;}
&.nn, &.nn-NO {background-position: 0 -1596px;}
&.pt-PT {background-position: -16px -1596px;}
&.de-AT {background-position: -32px -1596px;}
&.es, &.es-ES {background-position: 0 -1608px;}
&.en-GB {background-position: -32px -1608px;}
&.en-AU {background-position: 0 -1620px;}
&.az-Latn-AZ {background-position: -16px -1620px;}
&.id, &.id-ID {background-position: -32px -1620px;}
&.bg, &.bg-BG {background-position: 0 -1720px;}
&.ca-ES-valencia {background-position: -16px -1720px;}
&.en-CA {background-position: -32px -1720px;}
&.en-ZA {background-position: 0 -1732px;}
&.eu, &.eu-ES {background-position: -16px -1732px;}
&.gl, &.gl-ES {background-position: -32px -1732px;}
&.hr, &.hr-HR {background-position: 0 -1744px;}
&.lb, &.lb-LU {background-position: -16px -1744px;}
&.mn, &.mn-MN {background-position: -32px -1744px;}
&.sl, &.sl-SI {background-position: 0 -1756px;}
&.sr, &.sr-Cyrl-RS, &.sr-Latn-RS {background-position: -16px -1756px;}
&.sk, &.sk-SK {background-position: -32px -1756px;}
&.kk, &.kk-KZ {background-position: 0 -1768px;}
}
.button-normal-icon(btn-ic-zoomtowidth, 55, @toolbar-icon-size);
.button-normal-icon(btn-ic-zoomtopage, 56, @toolbar-icon-size);
.button-normal-icon(btn-ic-zoomup, 57, @toolbar-icon-size);
......
......@@ -232,6 +232,9 @@ define([
var value = Common.localStorage.getItem("pe-settings-inputmode");
this.api.SetTextBoxInputMode(parseInt(value) == 1);
value = Common.localStorage.getItem("pe-settings-spellcheck");
this.api.asc_setSpellCheck(parseInt(value) == 1);
/** coauthoring begin **/
if (this.mode.isEdit && !this.mode.isOffline && this.mode.canCoAuthoring) {
value = Common.localStorage.getItem("pe-settings-coauthmode");
......
......@@ -99,6 +99,7 @@ define([
var me = this;
this._state = {isDisconnected: false, usersCount: 1, fastCoauth: true, lostEditingRights: false, licenseWarning: false};
this.languages = null;
window.storagename = 'presentation';
......@@ -136,6 +137,7 @@ define([
this.api.asc_registerCallback('asc_onPrintUrl', _.bind(this.onPrintUrl, this));
this.api.asc_registerCallback('asc_onMeta', _.bind(this.onMeta, this));
this.api.asc_registerCallback('asc_onAdvancedOptions', _.bind(this.onAdvancedOptions, this));
this.api.asc_registerCallback('asc_onSpellCheckInit', _.bind(this.loadLanguages, this));
Common.NotificationCenter.on('api:disconnect', _.bind(this.onCoAuthoringDisconnect, this));
Common.NotificationCenter.on('goback', _.bind(this.goBack, this));
......@@ -545,6 +547,9 @@ define([
var zf = (value!==null) ? parseInt(value) : (this.appOptions.customization && this.appOptions.customization.zoom ? parseInt(this.appOptions.customization.zoom) : -1);
(zf == -1) ? this.api.zoomFitToPage() : ((zf == -2) ? this.api.zoomFitToWidth() : this.api.zoom(zf>0 ? zf : 100));
value = Common.localStorage.getItem("pe-settings-spellcheck");
me.api.asc_setSpellCheck(value===null || parseInt(value) == 1);
function checkWarns() {
if (!window['AscDesktopEditor']) {
var tips = [];
......@@ -644,6 +649,7 @@ define([
toolbarController.createDelayedElements();
documentHolderController.getView('DocumentHolder').createDelayedElements();
me.setLanguages();
me.api.asc_registerCallback('asc_onUpdateLayout', _.bind(me.fillLayoutsStore, me)); // slide layouts loading
me.updateThemeColors();
......@@ -1479,6 +1485,35 @@ define([
},
loadLanguages: function(apiLangs) {
var langs = [], info;
_.each(apiLangs, function(lang, index, list){
lang = parseInt(lang);
info = Common.util.LanguageInfo.getLocalLanguageName(lang);
langs.push({
title: info[1],
tip: info[0],
code: lang
});
}, this);
langs.sort(function(a, b){
if (a.tip < b.tip) return -1;
if (a.tip > b.tip) return 1;
return 0;
});
this.languages = langs;
window.styles_loaded && this.setLanguages();
},
setLanguages: function() {
if (this.languages && this.languages.length>0) {
// this.getApplication().getController('DocumentHolder').getView().setLanguages(this.languages);
this.getApplication().getController('Statusbar').setLanguages(this.languages);
}
},
onTryUndoInFastCollaborative: function() {
var val = window.localStorage.getItem("pe-hide-try-undoredo");
if (!(val && parseInt(val) == 1))
......
......@@ -42,7 +42,9 @@
define([
'core',
'presentationeditor/main/app/view/Statusbar'
'presentationeditor/main/app/view/Statusbar',
'common/main/lib/util/LanguageInfo',
'common/main/lib/view/LanguageDialog'
], function () {
'use strict';
......@@ -55,7 +57,11 @@ define([
initialize: function() {
this.addListeners({
'FileMenu': {
'settings:apply': _.bind(this.applySettings, this)
},
'Statusbar': {
'langchanged': this.onLangMenu
}
});
this._state = {
......@@ -67,7 +73,8 @@ define([
events: function() {
return {
'click #btn-zoom-down': _.bind(this.zoomDocument,this,'down'),
'click #btn-zoom-up': _.bind(this.zoomDocument,this,'up')
'click #btn-zoom-up': _.bind(this.zoomDocument,this,'up'),
'click #btn-doc-lang':_.bind(this.onBtnLanguage,this)
};
},
......@@ -85,11 +92,13 @@ define([
this.statusbar.btnZoomToWidth.on('click', _.bind(this.onBtnZoomTo, this, 'towidth'));
this.statusbar.zoomMenu.on('item:click', _.bind(this.menuZoomClick, this));
this.statusbar.btnPreview.on('click', _.bind(this.onPreview, this));
this.statusbar.btnSetSpelling.on('click', _.bind(this.onBtnSpelling, this));
},
setApi: function(api) {
this.api = api;
this.api.asc_registerCallback('asc_onZoomChange', _.bind(this._onZoomChange, this));
this.api.asc_registerCallback('asc_onTextLanguage', _.bind(this._onTextLanguage, this));
this.statusbar.setApi(api);
},
......@@ -177,6 +186,20 @@ define([
}
},
_onTextLanguage: function(langId) {
var info = Common.util.LanguageInfo.getLocalLanguageName(langId);
this.statusbar.setLanguage({
tip: info[0],
title: info[1],
code: langId
});
},
setLanguages: function(langs) {
this.langs = langs;
this.statusbar.reloadLanguages(langs);
},
setStatusCaption: function(text, force, delay) {
if (this.timerCaption && ( ((new Date()) < this.timerCaption) || text.length==0 ) && !force )
return;
......@@ -191,9 +214,49 @@ define([
},
createDelayedElements: function() {
var value = Common.localStorage.getItem("pe-settings-spellcheck");
this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true);
this.statusbar.$el.css('z-index', '');
},
onBtnLanguage: function() {
var langs = _.map(this.langs, function(item){
return {
displayValue: item.title,
value: item.tip,
code: item.code
}
});
var me = this;
(new Common.Views.LanguageDialog({
languages: langs,
current: me.api.asc_getDefaultLanguage(),
handler: function(result, tip) {
if (result=='ok') {
var record = _.findWhere(langs, {'value':tip});
record && me.api.asc_setDefaultLanguage(record.code);
}
}
})).show();
},
onLangMenu: function(obj, langid, title) {
this.api.put_TextPrLang(langid);
},
onBtnSpelling: function(d, b, e) {
Common.localStorage.setItem("pe-settings-spellcheck", d.pressed ? 1 : 0);
this.api.asc_setSpellCheck(d.pressed);
Common.NotificationCenter.trigger('edit:complete', this.statusbar);
},
applySettings: function(menu) {
var value = Common.localStorage.getItem("pe-settings-spellcheck");
this.statusbar.btnSetSpelling.toggle(value===null || parseInt(value) == 1, true);
},
zoomText : 'Zoom {0}%'
}, PE.Controllers.Statusbar || {}));
});
\ No newline at end of file
......@@ -27,6 +27,16 @@
<label id="status-label-action" class="status-label"></label>
</div>
<div class="status-group" style="">
<div class="cnt-lang el-edit">
<div class="dropdown-toggle" data-toggle="dropdown" style="margin-right: 6px;">
<span class="icon-lang-flag lang-flag en" data-vertical-offset="10" />
<label id="status-label-lang" class="status-label">English (United States)</label>
<div class="caret up img-commonctrl" />
</div>
</div>
<button id="btn-doc-lang" type="button" class="btn small btn-toolbar el-edit"><span class="btn-icon"></span></button>
<button id="btn-doc-spell" type="button" class="btn small btn-toolbar el-edit"><span class="btn-icon"></span></button>
<div class="separator short el-edit"></div>
<button id="btn-zoom-topage" type="button" class="btn small btn-toolbar"><span class="btn-icon">&nbsp;</span></button>
<button id="btn-zoom-towidth" type="button" class="btn small btn-toolbar"><span class="btn-icon">&nbsp;</span></button>
<button id="btn-zoom-down" type="button" class="btn small btn-toolbar"><span class="btn-icon">&nbsp;</span></button>
......
......@@ -111,6 +111,10 @@ define([
template: _.template([
'<table><tbody>',
'<tr class="edit">',
'<td class="left"><label><%= scope.txtSpellCheck %></label></td>',
'<td class="right"><div id="fms-chb-spell-check"/></td>',
'</tr>','<tr class="divider edit"></tr>',
'<tr class="edit">',
'<td class="left"><label><%= scope.txtInput %></label></td>',
'<td class="right"><div id="fms-chb-input-mode"/></td>',
......@@ -159,6 +163,11 @@ define([
render: function() {
$(this.el).html(this.template({scope: this}));
this.chSpell = new Common.UI.CheckBox({
el: $('#fms-chb-spell-check'),
labelText: this.strSpellCheckMode
});
this.chInputMode = new Common.UI.CheckBox({
el: $('#fms-chb-input-mode'),
labelText: this.strInputMode
......@@ -279,6 +288,9 @@ define([
var value = Common.localStorage.getItem("pe-settings-inputmode");
this.chInputMode.setValue(value!==null && parseInt(value) == 1);
value = Common.localStorage.getItem("pe-settings-spellcheck");
this.chSpell.setValue(value===null || parseInt(value) == 1);
value = Common.localStorage.getItem("pe-settings-zoom");
value = (value!==null) ? parseInt(value) : (this.mode.customization && this.mode.customization.zoom ? parseInt(this.mode.customization.zoom) : -1);
var item = this.cmbZoom.store.findWhere({value: value});
......@@ -317,6 +329,7 @@ define([
},
applySettings: function() {
Common.localStorage.setItem("pe-settings-spellcheck", this.chSpell.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-inputmode", this.chInputMode.isChecked() ? 1 : 0);
Common.localStorage.setItem("pe-settings-zoom", this.cmbZoom.getValue());
/** coauthoring begin **/
......@@ -366,7 +379,9 @@ define([
txtInch: 'Inch',
txtFitWidth: 'Fit to Width',
textForceSave: 'Save to Server',
strForcesave: 'Always save to server (otherwise save to server on document close)'
strForcesave: 'Always save to server (otherwise save to server on document close)',
txtSpellCheck: 'Spell Checking',
strSpellCheckMode: 'Turn on spell checking option'
}, PE.Views.FileMenuPanels.Settings || {}));
PE.Views.FileMenuPanels.RecentFiles = Common.UI.BaseView.extend({
......
......@@ -66,6 +66,19 @@ define([
Common.Utils.String.format(this.pageIndexText, model.get('current'), model.get('count')) );
}
function _clickLanguage(menu, item, state) {
var $parent = menu.$el.parent();
$parent.find('#status-label-lang').text(item.caption);
$parent.find('.dropdown-toggle > .icon-lang-flag')
.removeClass(this.langMenu.prevTip)
.addClass(item.value.tip);
this.langMenu.prevTip = item.value.tip;
this.fireEvent('langchanged', [this, item.value.code, item.caption]);
}
PE.Views.Statusbar = Backbone.View.extend(_.extend({
el: '#statusbar',
template: _.template(template),
......@@ -271,6 +284,62 @@ define([
hintAnchor: 'top'
});
this.btnDocLanguage = new Common.UI.Button({
el: $('#btn-doc-lang',this.el),
hint: this.tipSetDocLang,
hintAnchor: 'top',
disabled: true
});
this.btnSetSpelling = new Common.UI.Button({
el: $('#btn-doc-spell',this.el),
enableToggle: true,
hint: this.tipSetSpelling,
hintAnchor: 'top'
});
var panelLang = $('.cnt-lang',this.el);
this.langMenu = new Common.UI.Menu({
style: 'margin-top:-5px;',
maxHeight: 300,
itemTemplate: _.template([
'<a id="<%= id %>" tabindex="-1" type="menuitem">',
'<span class="lang-item-icon lang-flag <%= iconCls %>"></span>',
'<%= caption %>',
'</a>'
].join('')),
menuAlign: 'bl-tl'
});
this.btnLanguage = new Common.UI.Button({
el: panelLang,
hint: this.tipSetLang,
hintAnchor: 'top-left',
disabled: true
});
this.btnLanguage.cmpEl.on({
'show.bs.dropdown': function () {
_.defer(function(){
me.btnLanguage.cmpEl.find('ul').focus();
}, 100);
},
'hide.bs.dropdown': function () {
_.defer(function(){
me.api.asc_enableKeyEvents(true);
}, 100);
},
'click': function (e) {
if (me.btnLanguage.isDisabled()) {
return false;
}
}
});
this.langMenu.render(panelLang);
this.langMenu.cmpEl.attr({tabindex: -1});
this.langMenu.prevTip = 'en';
this.langMenu.on('item:click', _.bind(_clickLanguage,this));
return this;
},
......@@ -375,6 +444,49 @@ define([
$('#status-label-action').text('');
},
reloadLanguages: function(array) {
this.langMenu.removeAll();
_.each(array, function(item) {
this.langMenu.addItem({
iconCls : item['tip'],
caption : item['title'],
value : {tip: item['tip'], code: item['code']},
checkable : true,
checked : this.langMenu.saved == item.title,
toggleGroup : 'language'
});
}, this);
this.langMenu.doLayout();
if (this.langMenu.items.length>0) {
this.btnLanguage.setDisabled(false);
this.btnDocLanguage.setDisabled(false);
}
},
setLanguage: function(info) {
if (this.langMenu.prevTip != info.tip && info.code !== undefined) {
var $parent = $(this.langMenu.el.parentNode, this.$el);
$parent.find('.dropdown-toggle > .icon-lang-flag')
.removeClass(this.langMenu.prevTip)
.addClass(info.tip);
this.langMenu.prevTip = info.tip;
$parent.find('#status-label-lang').text(info.title);
var index = $parent.find('ul li a:contains("'+info.title+'")').parent().index();
index < 0 ? this.langMenu.saved = info.title :
this.langMenu.items[index-1].setChecked(true);
}
},
SetDisabled: function(disable) {
var langs = this.langMenu.items.length>0;
this.btnLanguage.setDisabled(disable || !langs);
this.btnDocLanguage.setDisabled(disable || !langs);
},
pageIndexText : 'Slide {0} of {1}',
goToPageText : 'Go to Slide',
tipUsers : 'Document is currently being edited by several users.',
......@@ -389,7 +501,10 @@ define([
tipPreview : 'Start Slideshow',
tipAccessRights : 'Manage document access rights',
tipViewUsers : 'View users and manage document access rights',
txAccessRights : 'Change access rights'
txAccessRights : 'Change access rights',
tipSetLang : 'Set Text Language',
tipSetDocLang : 'Set Document Language',
tipSetSpelling : 'Spell checking'
}, PE.Views.Statusbar || {}));
}
);
\ No newline at end of file
......@@ -94,6 +94,9 @@
"Common.Views.InsertTableDialog.txtMinText": "The minimum value for this field is {0}.",
"Common.Views.InsertTableDialog.txtRows": "Number of Rows",
"Common.Views.InsertTableDialog.txtTitle": "Table Size",
"Common.Views.LanguageDialog.btnCancel": "Cancel",
"Common.Views.LanguageDialog.btnOk": "Ok",
"Common.Views.LanguageDialog.labelSelect": "Select document language",
"Common.Views.OpenDialog.cancelButtonText": "Cancel",
"Common.Views.OpenDialog.okButtonText": "OK",
"Common.Views.OpenDialog.txtEncoding": "Encoding ",
......@@ -821,6 +824,8 @@
"PE.Views.FileMenuPanels.Settings.txtInput": "Alternate Input",
"PE.Views.FileMenuPanels.Settings.txtLast": "View Last",
"PE.Views.FileMenuPanels.Settings.txtPt": "Point",
"PE.Views.FileMenuPanels.Settings.txtSpellCheck": "Spell Checking",
"PE.Views.FileMenuPanels.Settings.strSpellCheckMode": "Turn on spell checking option",
"PE.Views.HyperlinkSettingsDialog.cancelButtonText": "Cancel",
"PE.Views.HyperlinkSettingsDialog.okButtonText": "OK",
"PE.Views.HyperlinkSettingsDialog.strDisplay": "Display",
......@@ -1105,6 +1110,9 @@
"PE.Views.Statusbar.tipZoomIn": "Zoom In",
"PE.Views.Statusbar.tipZoomOut": "Zoom Out",
"PE.Views.Statusbar.txAccessRights": "Change access rights",
"PE.Views.Statusbar.tipSetLang": "Set Text Language",
"PE.Views.Statusbar.tipSetDocLang": "Set Document Language",
"PE.Views.Statusbar.tipSetSpelling": "Spell checking",
"PE.Views.Statusbar.txtPageNumInvalid": "Invalid slide number",
"PE.Views.TableSettings.deleteColumnText": "Delete Column",
"PE.Views.TableSettings.deleteRowText": "Delete Row",
......
......@@ -111,6 +111,7 @@
@import "../../../../common/main/resources/less/common.less";
@import "../../../../common/main/resources/less/opendialog.less";
@import "../../../../common/main/resources/less/plugins.less";
@import "../../../../common/main/resources/less/language-dialog.less";
// App
// --------------------------------------------------
......
......@@ -56,6 +56,16 @@
.btn-tpl(-1220px);
}
#btn-doc-lang {
.btn-tpl(-160px);
margin-right: 9px;
}
#btn-doc-spell {
.btn-tpl(-160px);
margin-right: 5px;
}
#status-btn-preview {
.btn-tpl(-160px);
}
......@@ -78,6 +88,49 @@
}
}
.cnt-lang {
display: inline-block;
cursor: pointer;
color: #000;
margin-left: 6px;
.dropdown-toggle > .icon-lang-flag {
position: relative;
top: 3px;
margin-left: 3px;
margin-right: 2px;
display: inline-block;
}
.caret.up {
background-position: @arrow-up-small-offset-x @arrow-up-small-offset-y;
border: none;
width: 7px;
height: 7px;
}
label {
cursor: pointer;
}
.dropdown-menu {
li .lang-item-icon {
display: inline-block;
vertical-align: text-bottom;
margin: 1px 5px 0 2px;
}
}
&.disabled {
cursor: default;
label, .icon-lang-flag {
cursor: default;
opacity: 0.4;
}
}
}
.cnt-zoom {
display: inline-block;
......@@ -165,4 +218,3 @@
}
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment