Skip to content

Commit

Permalink
menubar examples: removed keypress events and use images instead of e…
Browse files Browse the repository at this point in the history
…ntities

* removed keypress events
* Updated to use images instead of entities for visual indicators of down arrow, right arrow and checked state 
* removed unused images
* updated example page notes to include information about using :before and :after CSS techniques for visual cues
  • Loading branch information
jongund authored and mcking65 committed Feb 14, 2017
1 parent 0000208 commit bbc4c09
Show file tree
Hide file tree
Showing 21 changed files with 60 additions and 81 deletions.
7 changes: 5 additions & 2 deletions examples/menubar/menubar-1/css/menubarLinks.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ ul[role="menubar"] > li {
}

ul[role="menubar"] > li > a:after {
content: url('../images/pull-down-menu-icon.png');
content: url('../images/down-arrow-brown.png');
padding-left: .25em;
}


Expand All @@ -61,8 +62,10 @@ ul[role="menubar"] ul[role="menu"] {

ul[role="menubar"] ul[role="menu"] li a {
display: block;
width: 10em;
}

ul[role="menubar"] ul[role="menu"] a[aria-haspopup="true"]:after {
content: " >";
content: url('../images/right-arrow-brown.png');
padding-right: 2em;
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/menubar/menubar-1/images/down-arrow.png
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 9 additions & 13 deletions examples/menubar/menubar-1/js/MenubarItemLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ MenubarItem.prototype.init = function () {
}

this.domNode.addEventListener('keydown', this.handleKeydown.bind(this));
this.domNode.addEventListener('keypress', this.handleKeypress.bind(this));
this.domNode.addEventListener('click', this.handleClick.bind(this));
this.domNode.addEventListener('focus', this.handleFocus.bind(this));
this.domNode.addEventListener('blur', this.handleBlur.bind(this));
Expand All @@ -93,9 +92,14 @@ MenubarItem.prototype.init = function () {

MenubarItem.prototype.handleKeydown = function (event) {
var tgt = event.currentTarget,
char = event.key,
flag = false,
clickEvent;

function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

switch (event.keyCode) {
case this.keyCode.SPACE:
case this.keyCode.RETURN:
Expand Down Expand Up @@ -138,6 +142,10 @@ MenubarItem.prototype.handleKeydown = function (event) {
break;

default:
if (isPrintableCharacter(char)) {
this.menubar.setFocusByFirstCharacter(this, char);
flag = true;
}
break;
}

Expand All @@ -147,18 +155,6 @@ MenubarItem.prototype.handleKeydown = function (event) {
}
};

MenubarItem.prototype.handleKeypress = function (event) {
var char = String.fromCharCode(event.charCode);

function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

if (isPrintableCharacter(char)) {
this.menubar.setFocusByFirstCharacter(this, char);
}
};

MenubarItem.prototype.handleClick = function (event) {
};

Expand Down
26 changes: 10 additions & 16 deletions examples/menubar/menubar-1/js/PopupMenuItemLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ MenuItem.prototype.init = function () {
}

this.domNode.addEventListener('keydown', this.handleKeydown.bind(this));
this.domNode.addEventListener('keypress', this.handleKeypress.bind(this));
this.domNode.addEventListener('click', this.handleClick.bind(this));
this.domNode.addEventListener('focus', this.handleFocus.bind(this));
this.domNode.addEventListener('blur', this.handleBlur.bind(this));
Expand All @@ -89,11 +88,14 @@ MenuItem.prototype.isExpanded = function () {
/* EVENT HANDLERS */

MenuItem.prototype.handleKeydown = function (event) {
var tgt = event.currentTarget,
var tgt = event.currentTarget,
char = event.key,
flag = false,
clickEvent;
clickEvent;

// Console.log("[MenuItem][handleKeydown]: " + event.keyCode + " " + this.menu)
function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

switch (event.keyCode) {
case this.keyCode.SPACE:
Expand Down Expand Up @@ -178,6 +180,10 @@ MenuItem.prototype.handleKeydown = function (event) {
break;

default:
if (isPrintableCharacter(char)) {
this.menu.setFocusByFirstCharacter(this, char);
flag = true;
}
break;
}

Expand All @@ -187,18 +193,6 @@ MenuItem.prototype.handleKeydown = function (event) {
}
};

MenuItem.prototype.handleKeypress = function (event) {
var char = String.fromCharCode(event.charCode);

function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

if (isPrintableCharacter(char)) {
this.menu.setFocusByFirstCharacter(this, char);
}
};

MenuItem.prototype.handleClick = function (event) {
this.menu.setFocusToController();
this.menu.close(true);
Expand Down
4 changes: 3 additions & 1 deletion examples/menubar/menubar-1/menubar-1.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ <h4>Notes</h4>
to easily see which elements the roles and properties need to be included.</li>
<li>This is useful for people writing their own scripts to see which elements need
roles and properties.</li>
</ol>
<li>CSS <code>:after</code> is used to render the down arrow in a menubar item using the CSS <code>content</code> property string using entity values.</li>
<li>CSS <code>:after</code> is used to render right arrow using the CSS <code>content</code> property string using entity values in pull down menu items that have sub-menus.</li>
</ol>
</section>
<section>
<h3 id="ex2_label">Example 2: ARIA markup added dynamically</h3>
Expand Down
30 changes: 11 additions & 19 deletions examples/menubar/menubar-2/css/menubarAction.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ ul[role="menubar"] > li {
position: relative;
}

ul[role="menubar"] > li > span:after {
content: url('../images/down-arrow-brown.png');
padding-left: 0.25em;
}

ul[role="menubar"] ul[role="menu"] {
display: none;
position: absolute;
Expand Down Expand Up @@ -50,6 +55,7 @@ ul[role="menubar"] ul li[role="menuitemcheckbox"],
ul[role="menubar"] ul li[role="menuitemradio"],
ul[role="menubar"] ul li[role="separator"] {
padding-left: 1.5em;
width: 8em;
}


Expand All @@ -75,31 +81,17 @@ ul[role="menubar"] [role="menu"] [role="separator"]:hover {

ul[role="menubar"] [role="menuitemcheckbox"][aria-checked='true'],
ul[role="menubar"] [role="menuitemradio"][aria-checked='true'] {
background-image: url('../images/checkmark.png');
background-repeat: no-repeat;
background-position: 0.1em 0.2em;
}


ul[role="menubar"] li[aria-checked='true']:hover,
ul[role="menubar"] li[aria-checked='true']:focus {
background-image: url('../images/checkmark-inverse.png');
background-repeat: no-repeat;
background-position: 0.1em 0.2em;
padding-left: 0.5em;
}


ul[role="menubar"] ul[role="menuitem"] > span:after {
/* content: url('../images/pull-down-menu-icon.png'); */
content: " \25bc";
font-size: 80%;
color: gray;
ul[role="menubar"] [role="menuitemcheckbox"][aria-checked='true']:before,
ul[role="menubar"] [role="menuitemradio"][aria-checked='true']:before {
content: url('../images/check-brown.png');
padding-right: 0.25em;
}





/*
* Text area styles
*/
Expand Down
Binary file added examples/menubar/menubar-2/images/check-brown.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed examples/menubar/menubar-2/images/checkmark.paint
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed examples/menubar/menubar-2/images/down-arrow.png
Binary file not shown.
Binary file not shown.
Binary file removed examples/menubar/menubar-2/images/separator.paint
Binary file not shown.
26 changes: 10 additions & 16 deletions examples/menubar/menubar-2/js/MenuItemAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ MenuItem.prototype.init = function () {
}

this.domNode.addEventListener('keydown', this.handleKeydown.bind(this));
this.domNode.addEventListener('keypress', this.handleKeypress.bind(this));
this.domNode.addEventListener('click', this.handleClick.bind(this));
this.domNode.addEventListener('focus', this.handleFocus.bind(this));
this.domNode.addEventListener('blur', this.handleBlur.bind(this));
Expand All @@ -65,11 +64,14 @@ MenuItem.prototype.init = function () {
/* EVENT HANDLERS */

MenuItem.prototype.handleKeydown = function (event) {
var tgt = event.currentTarget,
var tgt = event.currentTarget,
char = event.key,
flag = false,
clickEvent;
clickEvent;

// console.log("[MenuItem][handleKeydown]: " + event.keyCode + " " + this.menu)
function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

switch (event.keyCode) {
case this.keyCode.SPACE:
Expand Down Expand Up @@ -140,6 +142,10 @@ MenuItem.prototype.handleKeydown = function (event) {
break;

default:
if (isPrintableCharacter(char)) {
this.menu.setFocusByFirstCharacter(this, char);
flag = true;
}
break;
}

Expand All @@ -149,18 +155,6 @@ MenuItem.prototype.handleKeydown = function (event) {
}
};

MenuItem.prototype.handleKeypress = function (event) {
var char = String.fromCharCode(event.charCode);

function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

if (isPrintableCharacter(char)) {
this.menu.setFocusByFirstCharacter(this, char);
}
};

MenuItem.prototype.handleClick = function (event) {
this.menu.setFocusToController();
this.menu.close(true);
Expand Down
24 changes: 10 additions & 14 deletions examples/menubar/menubar-2/js/MenubarItemAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ MenubarItemAction.prototype.init = function () {
this.domNode.tabIndex = -1;

this.domNode.addEventListener('keydown', this.handleKeydown.bind(this));
this.domNode.addEventListener('keypress', this.handleKeypress.bind(this));
this.domNode.addEventListener('click', this.handleClick.bind(this));
this.domNode.addEventListener('focus', this.handleFocus.bind(this));
this.domNode.addEventListener('blur', this.handleBlur.bind(this));
Expand All @@ -87,8 +86,13 @@ MenubarItemAction.prototype.init = function () {

MenubarItemAction.prototype.handleKeydown = function (event) {
var tgt = event.currentTarget,
char = event.key,
flag = false,
clickEvent;
clickEvent;

function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

switch (event.keyCode) {
case this.keyCode.SPACE:
Expand Down Expand Up @@ -138,6 +142,10 @@ MenubarItemAction.prototype.handleKeydown = function (event) {
break;

default:
if (isPrintableCharacter(char)) {
this.menubar.setFocusByFirstCharacter(this, char);
flag = true;
}
break;
}

Expand All @@ -147,18 +155,6 @@ MenubarItemAction.prototype.handleKeydown = function (event) {
}
};

MenubarItemAction.prototype.handleKeypress = function (event) {
var char = String.fromCharCode(event.charCode);

function isPrintableCharacter (str) {
return str.length === 1 && str.match(/\S/);
}

if (isPrintableCharacter(char)) {
this.menubar.setFocusByFirstCharacter(this, char);
}
};

MenubarItemAction.prototype.handleClick = function (event) {
};

Expand Down
2 changes: 2 additions & 0 deletions examples/menubar/menubar-2/menubar-2.html
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ <h4>Notes</h4>
<ol>
<li>Menu radio buttons and checkboxes indicate the current format settings.</li>
<li>Disabled menu items are demonstrated in the font size menu, which includes two disabled menuitems .</li>
<li>CSS <code>:after</code> is used to render the down arrow in a menubar item using the CSS <code>content</code> property string using entity values.</li>
<li>CSS <code>:before</code> is used to render checks using the CSS <code>content</code> property string using entity values on <code>menuritemadio</code> and <code>menuitemcheckbox</code> items.</li>
</ol>
</section>

Expand Down

0 comments on commit bbc4c09

Please sign in to comment.