Merge pull request #1907 from ONLYOFFICE/fix/hint-manager
Fix/hint manager
This commit is contained in:
commit
1689451752
|
@ -44,6 +44,7 @@
|
||||||
* <button ... data-hint="1" data-hint-direction="right" data-hint-offset="big" data-hint-title="B">...</button>
|
* <button ... data-hint="1" data-hint-direction="right" data-hint-offset="big" data-hint-title="B">...</button>
|
||||||
* <label ... data-hint="1" data-hint-direction="bottom" data-hint-offset="medium" data-hint-title="L">...</label>
|
* <label ... data-hint="1" data-hint-direction="bottom" data-hint-offset="medium" data-hint-title="L">...</label>
|
||||||
*
|
*
|
||||||
|
*
|
||||||
* Example usage with components:
|
* Example usage with components:
|
||||||
*
|
*
|
||||||
* new Common.UI.Button({
|
* new Common.UI.Button({
|
||||||
|
@ -118,7 +119,10 @@ Common.UI.HintManager = new(function() {
|
||||||
_isDocReady = false,
|
_isDocReady = false,
|
||||||
_isEditDiagram = false,
|
_isEditDiagram = false,
|
||||||
_usedTitles = [],
|
_usedTitles = [],
|
||||||
_appPrefix;
|
_appPrefix,
|
||||||
|
_staticHints = { // for desktop buttons
|
||||||
|
"btnhome": 'K'
|
||||||
|
};
|
||||||
|
|
||||||
var _api;
|
var _api;
|
||||||
|
|
||||||
|
@ -223,6 +227,15 @@ Common.UI.HintManager = new(function() {
|
||||||
return arr;
|
return arr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var _getLetterInUILanguage = function (letter) {
|
||||||
|
var l = letter;
|
||||||
|
if (_arrAlphabet.indexOf(l) === -1) {
|
||||||
|
var ind = _arrEnAlphabet.indexOf(l);
|
||||||
|
l = _arrAlphabet[ind];
|
||||||
|
}
|
||||||
|
return l;
|
||||||
|
};
|
||||||
|
|
||||||
var _isItemDisabled = function (item) {
|
var _isItemDisabled = function (item) {
|
||||||
return (item.hasClass('disabled') || item.parent().hasClass('disabled') || item.attr('disabled'));
|
return (item.hasClass('disabled') || item.parent().hasClass('disabled') || item.attr('disabled'));
|
||||||
};
|
};
|
||||||
|
@ -268,21 +281,25 @@ Common.UI.HintManager = new(function() {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var _arrLetters = [];
|
var _arrLetters = [],
|
||||||
|
_usedLetters = [];
|
||||||
|
if (_currentLevel === 0) {
|
||||||
|
for (var key in _staticHints) {
|
||||||
|
var t = _staticHints[key].toLowerCase();
|
||||||
|
_usedTitles.push(t);
|
||||||
|
_usedLetters.push(_arrAlphabet.indexOf(t));
|
||||||
|
}
|
||||||
|
}
|
||||||
if (visibleItems.length > _arrAlphabet.length) {
|
if (visibleItems.length > _arrAlphabet.length) {
|
||||||
visibleItemsWithTitle.forEach(function (item) {
|
visibleItemsWithTitle.forEach(function (item) {
|
||||||
var t = $(item).data('hint-title').toLowerCase();
|
var t = $(item).data('hint-title').toLowerCase();
|
||||||
if (_arrAlphabet.indexOf(t) === -1) {
|
t = _getLetterInUILanguage(t);
|
||||||
var ind = _arrEnAlphabet.indexOf(t);
|
|
||||||
t = _arrAlphabet[ind];
|
|
||||||
}
|
|
||||||
_usedTitles.push(t);
|
_usedTitles.push(t);
|
||||||
});
|
});
|
||||||
_arrLetters = _getLetters(visibleItems.length);
|
_arrLetters = _getLetters(visibleItems.length + (_currentLevel === 0 ? _.size(_staticHints) : 0));
|
||||||
} else {
|
} else {
|
||||||
_arrLetters = _arrAlphabet.slice();
|
_arrLetters = _arrAlphabet.slice();
|
||||||
}
|
}
|
||||||
var usedLetters = [];
|
|
||||||
if (arrItemsWithTitle.length > 0) {
|
if (arrItemsWithTitle.length > 0) {
|
||||||
visibleItems.forEach(function (item) {
|
visibleItems.forEach(function (item) {
|
||||||
var el = $(item);
|
var el = $(item);
|
||||||
|
@ -290,9 +307,9 @@ Common.UI.HintManager = new(function() {
|
||||||
if (title) {
|
if (title) {
|
||||||
var ind = _arrEnAlphabet.indexOf(title.toLowerCase());
|
var ind = _arrEnAlphabet.indexOf(title.toLowerCase());
|
||||||
if (ind === -1) { // we have already changed
|
if (ind === -1) { // we have already changed
|
||||||
usedLetters.push(_arrAlphabet.indexOf(title.toLowerCase()));
|
_usedLetters.push(_arrAlphabet.indexOf(title.toLowerCase()));
|
||||||
} else {
|
} else {
|
||||||
usedLetters.push(ind);
|
_usedLetters.push(ind);
|
||||||
if (_lang !== 'en') {
|
if (_lang !== 'en') {
|
||||||
el.attr('data-hint-title', _arrLetters[ind].toUpperCase());
|
el.attr('data-hint-title', _arrLetters[ind].toUpperCase());
|
||||||
}
|
}
|
||||||
|
@ -303,7 +320,7 @@ Common.UI.HintManager = new(function() {
|
||||||
var index = 0;
|
var index = 0;
|
||||||
visibleItems.forEach(function (item) {
|
visibleItems.forEach(function (item) {
|
||||||
var el = $(item);
|
var el = $(item);
|
||||||
while (usedLetters.indexOf(index) !== -1) {
|
while (_usedLetters.indexOf(index) !== -1) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
var title = el.attr('data-hint-title');
|
var title = el.attr('data-hint-title');
|
||||||
|
@ -620,7 +637,16 @@ Common.UI.HintManager = new(function() {
|
||||||
_arrAlphabet = langsJson[lang];
|
_arrAlphabet = langsJson[lang];
|
||||||
return _arrAlphabet;
|
return _arrAlphabet;
|
||||||
};
|
};
|
||||||
return !_setAlphabet(lng) ? (!_setAlphabet(lng.split(/[\-_]/)[0]) ? _setAlphabet('en') : true) : true;
|
var loaded = !_setAlphabet(lng) ? (!_setAlphabet(lng.split(/[\-_]/)[0]) ? _setAlphabet('en') : true) : true;
|
||||||
|
if (loaded && _lang !== 'en') {
|
||||||
|
for (var key in _staticHints) {
|
||||||
|
var hint = _getLetterInUILanguage(_staticHints[key].toLowerCase());
|
||||||
|
if (hint) {
|
||||||
|
_staticHints[key] = hint.toUpperCase();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return loaded;
|
||||||
});
|
});
|
||||||
Common.Utils.loadConfig('../../common/main/resources/alphabetletters/qwertyletters.json', function (langsJson) {
|
Common.Utils.loadConfig('../../common/main/resources/alphabetletters/qwertyletters.json', function (langsJson) {
|
||||||
_arrQwerty = langsJson[_lang];
|
_arrQwerty = langsJson[_lang];
|
||||||
|
@ -661,11 +687,16 @@ Common.UI.HintManager = new(function() {
|
||||||
_isEditDiagram = mode.isEditDiagram || mode.isEditMailMerge || mode.isEditOle;
|
_isEditDiagram = mode.isEditDiagram || mode.isEditMailMerge || mode.isEditOle;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var _getStaticHint = function (key) {
|
||||||
|
return _staticHints[key];
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
init: _init,
|
init: _init,
|
||||||
setMode: _setMode,
|
setMode: _setMode,
|
||||||
clearHints: _clearHints,
|
clearHints: _clearHints,
|
||||||
needCloseFileMenu: _needCloseFileMenu,
|
needCloseFileMenu: _needCloseFileMenu,
|
||||||
isHintVisible: _isHintVisible
|
isHintVisible: _isHintVisible,
|
||||||
|
getStaticHint: _getStaticHint
|
||||||
}
|
}
|
||||||
})();
|
})();
|
|
@ -112,10 +112,13 @@
|
||||||
if (!me.options.keepvisible && !me.options.hideonclick && me.tip().is(':visible'))
|
if (!me.options.keepvisible && !me.options.hideonclick && me.tip().is(':visible'))
|
||||||
me.hide();
|
me.hide();
|
||||||
}});
|
}});
|
||||||
|
this.isDesktopApp = Common.Controllers.Desktop.isActive();
|
||||||
},
|
},
|
||||||
|
|
||||||
mousemove: function (e) {
|
mousemove: function (e) {
|
||||||
this.targetXY = [e.clientX*Common.Utils.zoom(), e.clientY*Common.Utils.zoom()];
|
var x = e.clientX*Common.Utils.zoom(),
|
||||||
|
y = e.clientY*Common.Utils.zoom();
|
||||||
|
this.targetXY = [x, this.isDesktopApp ? Math.max(y, 14) : y];
|
||||||
},
|
},
|
||||||
|
|
||||||
leave: function(obj) {
|
leave: function(obj) {
|
||||||
|
|
|
@ -516,7 +516,7 @@ define([
|
||||||
disabled: disabled === true,
|
disabled: disabled === true,
|
||||||
dataHint:'0',
|
dataHint:'0',
|
||||||
dataHintDirection: hintDirection ? hintDirection : (config.isDesktopApp ? 'right' : 'left'),
|
dataHintDirection: hintDirection ? hintDirection : (config.isDesktopApp ? 'right' : 'left'),
|
||||||
dataHintOffset: hintOffset ? hintOffset : (config.isDesktopApp ? '10, -10' : '10, 10'),
|
dataHintOffset: hintOffset ? hintOffset : (config.isDesktopApp ? '10, -18' : '10, 10'),
|
||||||
dataHintTitle: hintTitle
|
dataHintTitle: hintTitle
|
||||||
})).render(slot);
|
})).render(slot);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue