Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Toolbar Example: Add missing tooltips for issue 986 #1069

Merged
merged 21 commits into from
Jul 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
182f5e4
intial implementation of a tooltip
jongund Jun 4, 2019
2932caf
added escape key support
jongund Jun 4, 2019
bb0b117
added documentation for escape key
jongund Jun 4, 2019
1b9fc62
updated features based on feedback at June 4th teleconference
jongund Jun 4, 2019
f722e1a
updated aria-hidden documentation
jongund Jun 4, 2019
57c436e
restored escape key to hide tooltip
jongund Jun 5, 2019
c81e53e
added css arrow to tooltip
jongund Jun 5, 2019
920b627
removed code not needed
jongund Jun 5, 2019
b104585
updated behavior of the popup labels and edited the documentation to …
jongund Jun 18, 2019
875bda4
fixed css bug for popup label styling
jongund Jun 19, 2019
717b1e4
Merge branch 'master' into issue986-toolbar-button-tooltips
mcking65 Jul 5, 2019
54fabdb
Merge branch 'master' into issue986-toolbar-button-tooltips
mcking65 Jul 5, 2019
7a4e252
Editorial revisions to accessibility features
mcking65 Jul 6, 2019
087f35d
Editorial revision to toolbar esc key documentation
mcking65 Jul 6, 2019
3802d45
Remove Enter key from checkbox documentation and data-test-id attribute
mcking65 Jul 6, 2019
487f9e7
Toggle Buttons role and property documentation: remove button row
mcking65 Jul 6, 2019
7bfbcfd
Remove note from cut/copy/paste attribute documentation section descr…
mcking65 Jul 6, 2019
dc1943b
Satisfy eslint
Jul 8, 2019
c5e2127
Satisfy stylelint
Jul 8, 2019
cec9646
satisfy vnu-jar
Jul 8, 2019
917765c
Merge branch 'master' into issue986-toolbar-button-tooltips
mcking65 Jul 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions examples/toolbar/css/toolbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,54 @@
margin-right: 0.25em;
}

[role="toolbar"] button.popup {
position: relative;
}

[role="toolbar"] button .popup-label {
display: block;
width: initial;
border: 1px solid white;
padding: 2px 4px;
border-radius: 5px;
position: absolute;
top: -30000em;
background-color: black;
color: white;
font-weight: normal;
}

[role="toolbar"] button .popup-label.show {
text-align: center;
top: -2.5em;
}

[role="toolbar"] button .popup-label::after,
[role="toolbar"] button .popup-label::before {
top: 100%;
left: 50%;
border: solid transparent;
content: " ";
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}

[role="toolbar"] button .popup-label::after {
border-color: rgba(0, 0, 0, 0);
border-top-color: #000;
border-width: 10px;
margin-left: -10px;
}

[role="toolbar"] button .popup-label::before {
border-color: rgba(255, 255, 255, 0);
border-top-color: #fff;
border-width: 12px;
margin-left: -12px;
}

[role="toolbar"] button[aria-pressed="true"],
[role="toolbar"] [role="radio"][aria-checked="true"] {
border-color: #555;
Expand Down
4 changes: 2 additions & 2 deletions examples/toolbar/js/FontMenuButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ FontMenuButton = function (node, toolbar, toolbarItem) {

this.keyCode = Object.freeze({
'TAB': 9,
'RETURN': 13,
'ENTER': 13,
'ESC': 27,
'SPACE': 32,
'UP': 38,
Expand Down Expand Up @@ -46,7 +46,7 @@ FontMenuButton.prototype.handleKeyDown = function (event) {

switch (event.keyCode) {
case this.keyCode.SPACE:
case this.keyCode.RETURN:
case this.keyCode.ENTER:
case this.keyCode.DOWN:
case this.keyCode.UP:
this.fontMenu.open();
Expand Down
4 changes: 2 additions & 2 deletions examples/toolbar/js/FontMenuItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ var FontMenuItem = function (domNode, fontMenu) {

this.keyCode = Object.freeze({
'TAB': 9,
'RETURN': 13,
'ENTER': 13,
'ESC': 27,
'SPACE': 32,
'PAGEUP': 33,
Expand Down Expand Up @@ -86,7 +86,7 @@ FontMenuItem.prototype.handleKeydown = function (event) {

switch (event.keyCode) {
case this.keyCode.SPACE:
case this.keyCode.RETURN:
case this.keyCode.ENTER:
this.handleClick(event);
flag = true;
break;
Expand Down
5 changes: 5 additions & 0 deletions examples/toolbar/js/FormatToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ FormatToolbar.prototype.setFocusToLast = function (currentItem) {
this.setFocusItem(this.lastItem);
};

FormatToolbar.prototype.hidePopupLabels = function () {
var tps = this.domNode.querySelectorAll('button .popup-label');
tps.forEach(function (tp) {tp.classList.remove('show');});
};


// Initialize toolbars

Expand Down
62 changes: 60 additions & 2 deletions examples/toolbar/js/FormatToolbarItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ FormatToolbarItem = function (domNode, toolbar) {
this.toolbar = toolbar;
this.buttonAction = '';
this.value = '';
this.popupLabelNode = null;
this.hasHover = false;
this.popupLabelDelay = 800;


this.keyCode = Object.freeze({
'TAB': 9,
'RETURN': 13,
'ENTER': 13,
'ESC': 27,
'SPACE': 32,
'PAGEUP': 33,
Expand All @@ -33,6 +36,11 @@ FormatToolbarItem.prototype.init = function () {
this.domNode.addEventListener('click', this.handleClick.bind(this));
this.domNode.addEventListener('focus', this.handleFocus.bind(this));
this.domNode.addEventListener('blur', this.handleBlur.bind(this));
this.domNode.addEventListener('mouseover', this.handleMouseOver.bind(this));
this.domNode.addEventListener('mouseleave', this.handleMouseLeave.bind(this));

document.body.addEventListener('keydown', this.handleHideAllPopupLabels.bind(this));


if (this.domNode.classList.contains('bold')) {
this.buttonAction = 'bold';
Expand Down Expand Up @@ -81,6 +89,15 @@ FormatToolbarItem.prototype.init = function () {
if (this.domNode.classList.contains('spinbutton')) {
this.buttonAction = 'changeFontSize';
}
// Initialize any popup label

this.popupLabelNode = this.domNode.querySelector('.popup-label');
if (this.popupLabelNode) {
var width = 8 * this.popupLabelNode.textContent.length;
this.popupLabelNode.style.width = width + 'px';
this.popupLabelNode.style.left = -1 * ((width - this.domNode.offsetWidth) / 2) - 5 + 'px';
}

};

FormatToolbarItem.prototype.isPressed = function () {
Expand Down Expand Up @@ -115,14 +132,45 @@ FormatToolbarItem.prototype.enable = function () {
this.domNode.removeAttribute('aria-disabled');
};

FormatToolbarItem.prototype.showPopupLabel = function () {
if (this.popupLabelNode) {
this.toolbar.hidePopupLabels();
this.popupLabelNode.classList.add('show');
}
};

FormatToolbarItem.prototype.hidePopupLabel = function () {
if (this.popupLabelNode && !this.hasHover) {
this.popupLabelNode.classList.remove('show');
}
};


// Events

FormatToolbarItem.prototype.handleHideAllPopupLabels = function (event) {

switch (event.keyCode) {

case this.keyCode.ESC:
this.toolbar.hidePopupLabels();
break;

default:
break;
}


};


FormatToolbarItem.prototype.handleBlur = function (event) {
this.toolbar.domNode.classList.remove('focus');

if (this.domNode.classList.contains('nightmode')) {
this.domNode.parentNode.classList.remove('focus');
}
this.hidePopupLabel();
};

FormatToolbarItem.prototype.handleFocus = function (event) {
Expand All @@ -131,15 +179,25 @@ FormatToolbarItem.prototype.handleFocus = function (event) {
if (this.domNode.classList.contains('nightmode')) {
this.domNode.parentNode.classList.add('focus');
}
this.showPopupLabel();
};

FormatToolbarItem.prototype.handleMouseLeave = function (event) {
this.hasHover = false;
setTimeout(this.hidePopupLabel.bind(this), this.popupLabelDelay);
};

FormatToolbarItem.prototype.handleMouseOver = function (event) {
this.showPopupLabel();
this.hasHover = true;
};

FormatToolbarItem.prototype.handleKeyDown = function (event) {
var flag = false;

switch (event.keyCode) {

case this.keyCode.RETURN:
case this.keyCode.ENTER:
case this.keyCode.SPACE:
if ((this.buttonAction !== '') &&
(this.buttonAction !== 'bold') &&
Expand Down
Loading