Skip to content

Commit

Permalink
Merge pull request #3000 from ONLYOFFICE/fix/fix-bugs
Browse files Browse the repository at this point in the history
Fix/fix bugs
  • Loading branch information
JuliaRadzhabova authored May 21, 2024
2 parents 7e167ec + 974bc98 commit 9a6b84c
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 67 deletions.
10 changes: 5 additions & 5 deletions apps/common/main/lib/controller/Desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ define([

if ( !!titlebuttons ) {
info.hints = {};
!!titlebuttons['print'] && (info.hints['print'] = titlebuttons['print'].btn.btnEl.attr('data-hint-title'));
!!titlebuttons['quickprint'] && (info.hints['quickprint'] = titlebuttons['quickprint'].btn.btnEl.attr('data-hint-title'));
!!titlebuttons['undo'] && (info.hints['undo'] = titlebuttons['undo'].btn.btnEl.attr('data-hint-title'));
!!titlebuttons['redo'] && (info.hints['redo'] = titlebuttons['redo'].btn.btnEl.attr('data-hint-title'));
!!titlebuttons['save'] && (info.hints['save'] = titlebuttons['save'].btn.btnEl.attr('data-hint-title'));
!!titlebuttons['print'] && (info.hints['print'] = titlebuttons['print'].btn.btnEl.attr('data-hint-title-lang'));
!!titlebuttons['quickprint'] && (info.hints['quickprint'] = titlebuttons['quickprint'].btn.btnEl.attr('data-hint-title-lang'));
!!titlebuttons['undo'] && (info.hints['undo'] = titlebuttons['undo'].btn.btnEl.attr('data-hint-title-lang'));
!!titlebuttons['redo'] && (info.hints['redo'] = titlebuttons['redo'].btn.btnEl.attr('data-hint-title-lang'));
!!titlebuttons['save'] && (info.hints['save'] = titlebuttons['save'].btn.btnEl.attr('data-hint-title-lang'));
}

native.execCommand('althints:show', JSON.stringify(info));
Expand Down
108 changes: 50 additions & 58 deletions apps/common/main/lib/controller/HintManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,20 +214,25 @@ Common.UI.HintManager = new(function() {
var arr = _arrAlphabet.slice(),
firstFreeLetter,
ind;
for (var i = 0; i < _arrAlphabet.length, !firstFreeLetter; i++) {
for (var i = 0; i < _arrAlphabet.length; i++) {
if (_usedTitles.indexOf(_arrAlphabet[i]) === -1) {
firstFreeLetter = _arrAlphabet[i];
ind = i;
}
if (firstFreeLetter)
break;
}
arr[ind] = firstFreeLetter + _arrAlphabet[0];
for (var i = 0; arr.length < countButtons; i++) {
var addTip = firstFreeLetter + _arrAlphabet[i];
if (addTip !== arr[ind]) {
arr.push(firstFreeLetter + _arrAlphabet[i]);
if (firstFreeLetter) {
arr[ind] = firstFreeLetter + _arrAlphabet[0];
for (var i = 0; arr.length < countButtons; i++) {
var addTip = firstFreeLetter + _arrAlphabet[i];
if (addTip !== arr[ind]) {
arr.push(firstFreeLetter + _arrAlphabet[i]);
}
}
return arr;
}
return arr;
return false;
};

var _getLetterInUILanguage = function (letter) {
Expand All @@ -247,42 +252,35 @@ Common.UI.HintManager = new(function() {
_currentControls = [];
_usedTitles = [];
var arr = [],
arrItemsWithTitle = [];
itemsWithTitle = [],
itemsWithStaticTitle = [];
if (_.isArray(_currentSection)) {
_currentSection.forEach(function (section) {
arr = arr.concat($(section).find('[data-hint=' + (_currentLevel) + ']').toArray());
arrItemsWithTitle = arrItemsWithTitle.concat($(section).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray());
itemsWithStaticTitle = itemsWithStaticTitle.concat($(section).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray());
itemsWithTitle = itemsWithTitle.concat($(section).find('[data-hint-title-lang][data-hint=' + (_currentLevel) + ']').toArray());
});
} else {
arr = $(_currentSection).find('[data-hint=' + (_currentLevel) + ']').toArray();
arrItemsWithTitle = $(_currentSection).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray();
itemsWithStaticTitle = $(_currentSection).find('[data-hint-title][data-hint=' + (_currentLevel) + ']').toArray();
itemsWithTitle = $(_currentSection).find('[data-hint-title-lang][data-hint=' + (_currentLevel) + ']').toArray();
}
var visibleItems = arr.filter(function (item) {
return $(item).is(':visible');
});
var visibleItemsWithTitle = arrItemsWithTitle.filter(function (item) {
var visibleItemsWithTitle = itemsWithTitle.filter(function (item) {
return $(item).is(':visible');
});
var visibleItemsWithStaticTitle = itemsWithStaticTitle.filter(function (item) {
return $(item).is(':visible');
});
if (visibleItems.length === visibleItemsWithTitle.length) { // all buttons have data-hint-title
if (visibleItems.length === visibleItemsWithTitle.length) { // all buttons have data-hint-title-lang
visibleItems.forEach(function (item) {
var el = $(item);
if (_lang !== 'en') {
var title = el.attr('data-hint-title').toLowerCase(),
firstLetter = title.charAt(0);
if (_arrAlphabet.indexOf(firstLetter) === -1) { // tip is in English
var newTip = '';
for (var i = 0; i < title.length; i++) {
var letter = title.charAt(i);
newTip += _getLetterInUILanguage(letter);
}
el.attr('data-hint-title', newTip.toUpperCase());
}

}
_currentControls.push(el);
_currentControls.push($(item));
});
return;
}
// create letter combinations
var _arrLetters = [],
_usedLetters = [];
if (_currentLevel === 0) {
Expand All @@ -296,7 +294,7 @@ Common.UI.HintManager = new(function() {
}
}
if (visibleItems.length + (_currentLevel === 0 ? _.size(_staticHints) : 0) > _arrAlphabet.length) {
visibleItemsWithTitle.forEach(function (item) {
visibleItemsWithStaticTitle.forEach(function (item) {
var t = $(item).data('hint-title').charAt(0).toLowerCase();
t = _getLetterInUILanguage(t);
if (_usedTitles.indexOf(t) < 0) {
Expand All @@ -307,35 +305,29 @@ Common.UI.HintManager = new(function() {
} else {
_arrLetters = _arrAlphabet.slice();
}
if (arrItemsWithTitle.length > 0) {
visibleItems.forEach(function (item) {
var el = $(item),
title = el.attr('data-hint-title');
if (title) {
title = title.toLowerCase();
var firstLetter = title.charAt(0),
ind = _arrEnAlphabet.indexOf(firstLetter),
i;
if (ind === -1) { // we have already changed
i = _arrAlphabet.indexOf(firstLetter);
if (_usedLetters.indexOf(i) < 0) {
_usedLetters.push(i);
}
} else {
if (_usedLetters.indexOf(ind) < 0) {
_usedLetters.push(ind);
}
if (_lang !== 'en') {
var newTitle = '';
for (i = 0; i < title.length; i++) {
newTitle += _getLetterInUILanguage(title.charAt(i));
}
el.attr('data-hint-title', newTitle.toUpperCase());
}
if (!_arrLetters.length) return;
// add attrs
visibleItemsWithStaticTitle.forEach(function (item) {
var el = $(item),
title = el.attr('data-hint-title');
if (title) {
title = title.toLowerCase();
var firstLetter = title.charAt(0),
ind = _arrEnAlphabet.indexOf(firstLetter),
i;
if (_usedLetters.indexOf(ind) < 0)
_usedLetters.push(ind);
if (_lang === 'en') {
el.attr('data-hint-title-lang', title.toUpperCase());
} else {
var newTitle = '';
for (i = 0; i < title.length; i++) {
newTitle += _getLetterInUILanguage(title.charAt(i));
}
el.attr('data-hint-title-lang', newTitle.toUpperCase());
}
});
}
}
});
var index = 0;
visibleItems.forEach(function (item) {
var el = $(item);
Expand All @@ -344,7 +336,7 @@ Common.UI.HintManager = new(function() {
}
var title = el.attr('data-hint-title');
if (!title && !(index > _arrLetters.length)) {
el.attr('data-hint-title', _arrLetters[index].toUpperCase());
el.attr('data-hint-title-lang', _arrLetters[index].toUpperCase());
index++;
}
_currentControls.push(el);
Expand Down Expand Up @@ -386,7 +378,7 @@ Common.UI.HintManager = new(function() {
rightBorder -= 20;
}
}
var hint = $('<div style="" class="hint-div">' + item.attr('data-hint-title') + '</div>');
var hint = $('<div style="" class="hint-div">' + item.attr('data-hint-title-lang') + '</div>');
var direction = item.attr('data-hint-direction');
// exceptions
if (window.SSE && !_isEditDiagram && _currentSection.nodeType !== 9 &&
Expand Down Expand Up @@ -555,7 +547,7 @@ Common.UI.HintManager = new(function() {
for (var i = 0; i < _currentControls.length; i++) {
var item = _currentControls[i];
if (!_isItemDisabled(item)) {
var title = item.attr('data-hint-title'),
var title = item.attr('data-hint-title-lang'),
regExp = new RegExp('^' + _inputLetters + '');
if (regExp.test(title)) {
match = true;
Expand Down
4 changes: 2 additions & 2 deletions apps/documenteditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ define([
autoText : this.txtAutoText,
lock: [_set.noParagraphSelected, _set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.fixedForm, _set.viewMode],
dataHint: '1',
dataHintDirection: 'bottom',
dataHintDirection: 'top',
dataHintOffset: 'big'
});
this.paragraphControls.push(this.numSpacingBefore);
Expand All @@ -637,7 +637,7 @@ define([
autoText : this.txtAutoText,
lock: [_set.noParagraphSelected, _set.paragraphLock, _set.headerLock, _set.richEditLock, _set.plainEditLock, _set.previewReviewMode, _set.viewFormMode, _set.lostConnect, _set.disableOnStart, _set.docLockView, _set.docLockForms, _set.docLockComments, _set.fixedForm, _set.viewMode],
dataHint: '1',
dataHintDirection: 'top',
dataHintDirection: 'bottom',
dataHintOffset: 'small'
});
this.paragraphControls.push(this.numSpacingAfter);
Expand Down
4 changes: 2 additions & 2 deletions apps/pdfeditor/main/app/view/Toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ define([
menu: true,
hideColorLine: true,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintDirection: 'top',
dataHintOffset: '0, -16',
penOptions: {color: 'D43230'},
type: AscPDF.ANNOTATIONS_TYPES.Strikeout
Expand Down Expand Up @@ -856,7 +856,7 @@ define([
menu: true,
type: AscPDF.ANNOTATIONS_TYPES.Highlight,
dataHint: '1',
dataHintDirection: 'bottom',
dataHintDirection: 'top',
dataHintOffset: '0, -16',
penOptions: {color: 'FFFC54', colors: [
'FFFC54', '72F54A', '74F9FD', 'EB51F7', 'A900F9', 'EF8B3A', '7272FF', 'FF63A4', '1DFF92', '03DA18',
Expand Down

0 comments on commit 9a6b84c

Please sign in to comment.