ARIA-UAIG/1.0/tests/test-files/test104.html
author Richard Schwerdtfeger <schwer@us.ibm.com>
Mon, 11 Nov 2013 11:32:19 -0600
changeset 412 806564d2a54a
parent 410 6e6b1a84c669
child 415 6a00fe844179
permissions -rw-r--r--
Backout changeset 6e6b1a84c669380fc7f4ce270baccfb0a97af10f
409
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     1
<!DOCTYPE html>
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     2
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" >
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     3
  <head id="head">
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     4
    
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     5
    <title id="header_title">Example 25 - Menubar</title>
412
806564d2a54a Backout changeset 6e6b1a84c669380fc7f4ce270baccfb0a97af10f
Richard Schwerdtfeger <schwer@us.ibm.com>
parents: 410
diff changeset
     6
    
409
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     7
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
412
806564d2a54a Backout changeset 6e6b1a84c669380fc7f4ce270baccfb0a97af10f
Richard Schwerdtfeger <schwer@us.ibm.com>
parents: 410
diff changeset
     8
    
409
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
     9
    <link rel="stylesheet" href="http://www.oaa-accessibility.org/media/css/openajax-example-print.css"   type="text/css" media="print" />
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    10
    <link rel="stylesheet" href="http://www.oaa-accessibility.org/media/css/openajax-example-screen.css"  type="text/css" media="screen" title="screen" />
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    11
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    12
    <script type="text/javascript">
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    13
      var $URL_SITE = "http://www.oaa-accessibility.org/media//";
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    14
    </script>
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    15
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    16
<style type="text/css">
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    17
body {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    18
     background: white;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    19
     }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    20
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    21
#st1 {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    22
	padding: .5em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    23
	border: 1px solid black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    24
	height: 400px;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    25
	width: 70%;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    26
	font-size: medium;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    27
	font-family: sans-serif;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    28
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    29
ul.menubar {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    30
	margin: 0 !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    31
	padding: 0 .25em !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    32
	list-style: none !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    33
   font-size: 100% !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    34
	height: 1.85em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    35
	width: 20em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    36
	border: 1px solid black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    37
	background: #ccc;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    38
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    39
ul.menubar li {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    40
	float: left;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    41
	display: inline; position: relative;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    42
	margin: 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    43
	padding: .25em .35em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    44
	height: 1.25em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    45
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    46
ul.menu {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    47
	position: absolute;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    48
	left: 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    49
	top: 1.75em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    50
	display: none;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    51
	list-style: none;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    52
	margin: 0 !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    53
	padding: 0 !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    54
	font-weight: normal !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    55
   font-size: 100% !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    56
	border: 1px solid black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    57
	background-color: #ccc;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    58
	width: 8.5em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    59
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    60
ul.menu li {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    61
	float: none;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    62
	display: block;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    63
	white-space: nowrap;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    64
	padding: 2px 1em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    65
	color: black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    66
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    67
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    68
li.separator {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    69
	margin: 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    70
	margin-bottom: 4px !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    71
	height: 2px !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    72
	border-bottom: 1px solid black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    73
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    74
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    75
li.checked {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    76
	font-weight: bold;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    77
	background-image: url('http://www.oaa-accessibility.org/media/examples/images/dot.png');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    78
	background-repeat: no-repeat;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    79
	background-position: 5px 10px;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    80
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    81
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    82
.menu-hover {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    83
	background-color: #700 !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    84
	color: white !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    85
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    86
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    87
.menu-hover-checked {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    88
	background-color: #700 !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    89
	color: white !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    90
	background-image: url('http://www.oaa-accessibility.org/media/examples/images/dot-selected.png') !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    91
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    92
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    93
.menu-focus {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    94
	background-color: black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    95
	font-weight: bold;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    96
	color: white !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    97
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    98
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
    99
li.menu-focus-checked {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   100
	background-color: black;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   101
	font-weight: bold;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   102
	color: white !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   103
	background-image: url('http://www.oaa-accessibility.org/media/examples/images/dot-selected.png') !important;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   104
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   105
.hidden {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   106
   position: absolute;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   107
   left: -200em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   108
   top: -20em;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   109
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   110
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   111
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   112
/*
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   113
 * Text area styles
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   114
 */
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   115
.italic {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   116
	font-style: italic;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   117
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   118
.bold {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   119
	font-weight: bold;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   120
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   121
.underline {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   122
	text-decoration: underline;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   123
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   124
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   125
</style>
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   126
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   127
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   128
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   129
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   130
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   131
    
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   132
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   133
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   134
<script type="text/javascript" src="http://www.oaa-accessibility.org/media/examples/js/jquery-1.4.2.min.js"></script>
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   135
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   136
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   137
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   138
<script type="text/javascript">
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   139
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   140
$(document).ready(function() {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   141
      var menu1 = new menubar('mb1', false);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   142
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   143
}); // end ready()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   144
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   145
/////////////// begin textArea widget definition ////////////////////////
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   146
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   147
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   148
// Function textArea() is the constructor of a widget to manipulate the
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   149
// properties of a text area.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   150
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   151
// @param(id string) id is the HTML id of the text area to bind to
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   152
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   153
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   154
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   155
function textArea(id) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   156
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   157
	// define widget properties
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   158
	this.$id = $('#' + id);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   159
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   160
	this.fontSizes = new Array('x-small', 'small', 'medium', 'large', 'x-large');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   161
	this.sizeNdx = 2; // index of current size setting
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   162
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   163
} // end textArea() constructor
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   164
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   165
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   166
// setFont() is a member function to set the font family of the text area.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   167
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   168
// @param ( fontFamily string ) name of family to set
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   169
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   170
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   171
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   172
textArea.prototype.setFont = function(fontFamily) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   173
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   174
	this.$id.css('font-family', fontFamily);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   175
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   176
} // end setFont()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   177
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   178
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   179
// setStyle() is a member function to set the font style of the text area.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   180
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   181
// @param ( style string ) name of style to set
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   182
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   183
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   184
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   185
textArea.prototype.setStyle = function(style) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   186
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   187
	this.$id.toggleClass(style);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   188
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   189
} // end setStyle()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   190
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   191
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   192
// setAlignment() is a member function to set the text alignment of the text area
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   193
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   194
// @param ( justification string ) name of style to set
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   195
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   196
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   197
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   198
textArea.prototype.setAlignment = function(justification) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   199
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   200
	this.$id.css('text-align', justification);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   201
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   202
} // end setAlignment()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   203
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   204
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   205
// Function getSize() returns the size of text in the text area.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   206
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   207
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   208
// 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   209
textArea.prototype.getSize = function() {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   210
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   211
	return this.fontSizes[this.sizeNdx];
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   212
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   213
} // end getSize()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   214
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   215
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   216
// Function setSize() sets the size of text in the text area.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   217
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   218
// @param ( size string ) size of text to set
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   219
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   220
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   221
// 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   222
textArea.prototype.setSize = function(size) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   223
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   224
	switch (size) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   225
	    case 'larger': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   226
	        this.sizeNdx += 1;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   227
	        if (this.sizeNdx > 4) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   228
	            this.sizeNdx = 4;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   229
	        }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   230
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   231
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   232
	    case 'smaller': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   233
	        this.sizeNdx -= 1;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   234
	        if (this.sizeNdx < 0) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   235
	            this.sizeNdx = 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   236
	        }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   237
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   238
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   239
	    case 'x-small': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   240
	        this.sizeNdx = 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   241
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   242
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   243
	    case 'small': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   244
	        this.sizeNdx = 1;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   245
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   246
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   247
	    case 'medium': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   248
	        this.sizeNdx = 2;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   249
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   250
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   251
	    case 'large': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   252
	        this.sizeNdx = 3;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   253
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   254
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   255
	    case 'x-large': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   256
	        this.sizeNdx = 4;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   257
	        break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   258
	    }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   259
	} // end switch
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   260
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   261
	// set the new size
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   262
	this.$id.css('font-size', this.fontSizes[this.sizeNdx]);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   263
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   264
} // end setSize();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   265
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   266
/////////////// end textArea widget definition ////////////////////////
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   267
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   268
/////////////// begin menu widget definition /////////////////////
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   269
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   270
// Function menubar() is the constructor of a menu widget
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   271
// The widget will bind to the ul passed to it.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   272
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   273
// @param(id string) id is the HTML id of the ul to bind to
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   274
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   275
// @param(vmenu boolean) vmenu is true if menu is vertical; false if horizontal
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   276
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   277
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   278
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   279
function menubar(id, vmenu) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   280
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   281
   // define widget properties
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   282
   this.$id = $('#' + id);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   283
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   284
   this.$rootItems = this.$id.children('li'); // jQuerry array of all root-level menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   285
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   286
   this.$items = this.$id.find('.menu-item').not('.separator'); // jQuery array of menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   287
   this.$parents = this.$id.find('.menu-parent'); // jQuery array of menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   288
   this.$allItems = this.$parents.add(this.$items); // jQuery array of all menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   289
   this.$activeItem = null; // jQuery object of the menu item with focus
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   290
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   291
   this.vmenu = vmenu;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   292
   this.bChildOpen = false; // true if child menu is open
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   293
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   294
   this.keys = {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   295
            tab:    9,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   296
            enter:  13,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   297
            esc:    27,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   298
            space:  32,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   299
            left:   37,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   300
            up:     38,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   301
            right:  39,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   302
            down:   40 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   303
   };
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   304
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   305
   // bind event handlers
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   306
   this.bindHandlers();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   307
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   308
   // associate the menu with the textArea it controls
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   309
   this.textarea = new textArea(this.$id.attr('aria-controls'));
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   310
};
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   311
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   312
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   313
// Function bindHandlers() is a member function to bind event handlers for the widget.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   314
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   315
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   316
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   317
menubar.prototype.bindHandlers = function() {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   318
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   319
   var thisObj = this;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   320
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   321
   ///////// bind mouse event handlers //////////
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   322
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   323
   // bind a mouseenter handler for the menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   324
   this.$items.mouseenter(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   325
      if ($(this).is('.checked')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   326
         $(this).addClass('menu-hover-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   327
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   328
      else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   329
         $(this).addClass('menu-hover');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   330
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   331
      return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   332
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   333
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   334
   // bind a mouseout handler for the menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   335
   this.$items.mouseout(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   336
      $(this).removeClass('menu-hover menu-hover-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   337
      return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   338
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   339
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   340
   // bind a mouseenter handler for the menu parents
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   341
   this.$parents.mouseenter(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   342
      return thisObj.handleMouseEnter($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   343
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   344
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   345
   // bind a mouseleave handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   346
   this.$parents.mouseleave(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   347
      return thisObj.handleMouseLeave($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   348
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   349
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   350
   // bind a click handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   351
   this.$allItems.click(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   352
      return thisObj.handleClick($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   353
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   354
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   355
   //////////// bind key event handlers //////////////////
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   356
  
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   357
   // bind a keydown handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   358
   this.$allItems.keydown(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   359
      return thisObj.handleKeyDown($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   360
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   361
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   362
   // bind a keypress handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   363
   this.$allItems.keypress(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   364
      return thisObj.handleKeyPress($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   365
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   366
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   367
   // bind a focus handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   368
   this.$allItems.focus(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   369
      return thisObj.handleFocus($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   370
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   371
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   372
   // bind a blur handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   373
   this.$allItems.blur(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   374
      return thisObj.handleBlur($(this), e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   375
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   376
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   377
   // bind a document click handler
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   378
   $(document).click(function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   379
         return thisObj.handleDocumentClick(e);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   380
   });
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   381
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   382
} // end bindHandlers()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   383
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   384
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   385
// Function handleMouseEnter() is a member function to process mouseover
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   386
// events for the top menus.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   387
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   388
// @param($item object) $item is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   389
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   390
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   391
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   392
// @return(boolean) Returns false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   393
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   394
menubar.prototype.handleMouseEnter = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   395
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   396
   // add hover style
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   397
   if ($item.is('.checked')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   398
      $item.addClass('menu-hover-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   399
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   400
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   401
      $item.addClass('menu-hover');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   402
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   403
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   404
   // expand the first level submenu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   405
   if ($item.attr('aria-haspopup') == 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   406
      $item.children('ul').show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   407
      this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   408
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   409
   //e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   410
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   411
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   412
} // end handleMouseEnter()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   413
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   414
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   415
// Function handleMouseOut() is a member function to process mouseout
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   416
// events for the top menus.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   417
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   418
// @param($item object) $item is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   419
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   420
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   421
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   422
// @return(boolean) Returns false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   423
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   424
menubar.prototype.handleMouseOut = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   425
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   426
   // Remover hover styles
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   427
   $item.removeClass('menu-hover menu-hover-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   428
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   429
   //e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   430
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   431
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   432
} // end handleMouseOut()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   433
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   434
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   435
// Function handleMouseLeave() is a member function to process mouseout
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   436
// events for the top menus.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   437
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   438
// @param($menu object) $menu is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   439
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   440
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   441
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   442
// @return(boolean) Returns false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   443
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   444
menubar.prototype.handleMouseLeave = function($menu, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   445
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   446
   var $active = $menu.find('.menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   447
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   448
   $active = $active.add($menu.find('.menu-focus'));
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   449
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   450
   // Remove hover style
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   451
   $menu.removeClass('menu-hover menu-hover-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   452
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   453
   // if any item in the child menu has focus, move focus to the root item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   454
   if ($active.length > 0) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   455
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   456
      this.bChildOpen = false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   457
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   458
      // remove the focus style from the active item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   459
      $active.removeClass('menu-focus menu-focus-checked'); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   460
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   461
      // store the active item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   462
      this.$activeItem = $menu;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   463
 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   464
      // cannot hide items with focus -- move focus to root item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   465
      $menu.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   466
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   467
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   468
   // hide the child menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   469
   $menu.children('ul').hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   470
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   471
   //e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   472
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   473
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   474
} // end handleMouseLeave()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   475
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   476
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   477
// Function handleClick() is a member function to process click events
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   478
// for the top menus.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   479
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   480
// @param($item object) $item is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   481
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   482
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   483
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   484
// @return(boolean) Returns false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   485
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   486
menubar.prototype.handleClick = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   487
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   488
   var $parentUL = $item.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   489
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   490
   if ($parentUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   491
         // open the child menu if it is closed
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   492
         $item.children('ul').first().show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   493
         this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   494
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   495
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   496
      // process the menu choice
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   497
      this.processMenuChoice($item);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   498
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   499
      // remove hover and focus styling
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   500
      this.$allItems.removeClass('menu-hover menu-hover-checked menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   501
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   502
      // close the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   503
      this.$id.find('ul').not('.root-level').hide().attr('aria-hidden','true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   504
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   505
      // move focus to the text area
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   506
      this.textarea.$id.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   507
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   508
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   509
   e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   510
   return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   511
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   512
} // end handleClick()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   513
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   514
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   515
// Function handleFocus() is a member function to process focus events
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   516
// for the menu.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   517
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   518
// @param($item object) $item is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   519
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   520
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   521
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   522
// @return(boolean) Returns true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   523
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   524
menubar.prototype.handleFocus = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   525
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   526
   // if activeItem is null, we are getting focus from outside the menu. Store
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   527
   // the item that triggered the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   528
   if (this.$activeItem == null) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   529
      this.$activeItem = $item;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   530
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   531
   else if ($item[0] != this.$activeItem[0]) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   532
      return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   533
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   534
   
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   535
   // get the set of jquery objects for all the parent items of the active item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   536
   var $parentItems = this.$activeItem.parentsUntil('div').filter('li');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   537
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   538
   // remove focus styling from all other menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   539
   this.$allItems.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   540
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   541
   // add styling to the active item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   542
   if (this.$activeItem.is('.checked')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   543
      this.$activeItem.addClass('menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   544
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   545
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   546
      this.$activeItem.addClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   547
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   548
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   549
   // add styling to all parent items.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   550
   // This assumes that parent items do not have a checked state
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   551
   $parentItems.addClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   552
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   553
   if (this.vmenu == true) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   554
      // if the bChildOpen is true, open the active item's child menu (if applicable)
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   555
      if (this.bChildOpen == true) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   556
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   557
         var $itemUL = $item.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   558
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   559
         // if the itemUL is a root-level menu and item is a parent item,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   560
         // show the child menu.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   561
         if ($itemUL.is('.root-level') && ($item.attr('aria-haspopup') == 'true')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   562
            $item.children('ul').show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   563
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   564
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   565
      else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   566
         this.vmenu = false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   567
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   568
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   569
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   570
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   571
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   572
} // end handleFocus()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   573
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   574
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   575
// Function handleBlur() is a member function to process blur events
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   576
// for the menu.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   577
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   578
// @param($item object) $item is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   579
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   580
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   581
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   582
// @return(boolean) Returns true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   583
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   584
menubar.prototype.handleBlur = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   585
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   586
   $item.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   587
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   588
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   589
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   590
} // end handleBlur()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   591
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   592
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   593
// Function handleKeyDown() is a member function to process keydown events
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   594
// for the menus.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   595
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   596
// @param($item object) $item is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   597
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   598
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   599
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   600
// @return(boolean) Returns false if consuming; true if propagating
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   601
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   602
menubar.prototype.handleKeyDown = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   603
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   604
   if (e.altKey || e.ctrlKey) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   605
       // Modifier key pressed: Do not process
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   606
       return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   607
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   608
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   609
   switch(e.keyCode) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   610
      case this.keys.tab: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   611
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   612
         // hide all menu items and update their aria attributes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   613
         this.$id.find('ul').hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   614
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   615
         // remove focus styling from all menu items
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   616
         this.$allItems.removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   617
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   618
         this.$activeItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   619
         this.bChildOpen == false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   620
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   621
         break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   622
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   623
      case this.keys.esc: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   624
         var $itemUL = $item.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   625
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   626
         if ($itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   627
            // hide the child menu and update the aria attributes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   628
            $item.children('ul').first().hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   629
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   630
         else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   631
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   632
            // move up one level
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   633
            this.$activeItem = $itemUL.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   634
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   635
            // reset the childOpen flag
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   636
            this.bChildOpen = false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   637
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   638
            // set focus on the new item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   639
            this.$activeItem.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   640
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   641
            // hide the active menu and update the aria attributes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   642
            $itemUL.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   643
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   644
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   645
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   646
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   647
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   648
      case this.keys.enter:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   649
      case this.keys.space: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   650
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   651
         var $parentUL = $item.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   652
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   653
         if ($parentUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   654
            // open the child menu if it is closed
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   655
            $item.children('ul').first().show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   656
            this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   657
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   658
         else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   659
            // process the menu choice
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   660
            this.processMenuChoice($item);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   661
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   662
            // remove hover styling
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   663
            this.$allItems.removeClass('menu-hover menu-hover-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   664
            this.$allItems.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   665
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   666
            // close the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   667
            this.$id.find('ul').not('.root-level').hide().attr('aria-hidden','true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   668
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   669
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   670
            // clear the active item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   671
            this.$activeItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   672
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   673
            // move focus to the text area
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   674
            this.textarea.$id.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   675
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   676
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   677
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   678
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   679
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   680
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   681
      case this.keys.left: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   682
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   683
         if (this.vmenu == true && $itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   684
            // If this is a vertical menu and the root-level is active, move
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   685
            // to the previous item in the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   686
            this.$activeItem = this.moveUp($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   687
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   688
         else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   689
            this.$activeItem = this.moveToPrevious($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   690
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   691
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   692
         this.$activeItem.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   693
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   694
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   695
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   696
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   697
      case this.keys.right: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   698
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   699
         if (this.vmenu == true && $itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   700
            // If this is a vertical menu and the root-level is active, move
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   701
            // to the next item in the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   702
            this.$activeItem = this.moveDown($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   703
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   704
         else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   705
            this.$activeItem = this.moveToNext($item);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   706
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   707
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   708
         this.$activeItem.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   709
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   710
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   711
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   712
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   713
      case this.keys.up: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   714
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   715
         if (this.vmenu == true && $itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   716
            // If this is a vertical menu and the root-level is active, move
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   717
            // to the previous root-level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   718
            this.$activeItem = this.moveToPrevious($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   719
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   720
         else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   721
            this.$activeItem = this.moveUp($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   722
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   723
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   724
         this.$activeItem.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   725
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   726
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   727
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   728
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   729
      case this.keys.down: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   730
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   731
         if (this.vmenu == true && $itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   732
            // If this is a vertical menu and the root-level is active, move
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   733
            // to the next root-level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   734
            this.$activeItem = this.moveToNext($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   735
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   736
         else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   737
            this.$activeItem = this.moveDown($item); 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   738
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   739
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   740
         this.$activeItem.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   741
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   742
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   743
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   744
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   745
   } // end switch
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   746
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   747
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   748
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   749
} // end handleMenuKeyDown()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   750
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   751
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   752
// Function moveToNext() is a member function to move to the next menu level.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   753
// This will be either the next root-level menu or the child of a menu parent. If
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   754
// at the root level and the active item is the last in the menu, this function will loop
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   755
// to the first menu item.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   756
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   757
// If the menu is a horizontal menu, the first child element of the newly selected menu will
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   758
// be selected
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   759
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   760
// @param($item object) $item is the active menu item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   761
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   762
// @return (object) Returns the item to move to. Returns $item is no move is possible
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   763
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   764
menubar.prototype.moveToNext = function($item) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   765
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   766
   var $itemUL = $item.parent(); // $item's containing menu 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   767
   var $menuItems = $itemUL.children('li'); // the items in the currently active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   768
   var menuNum = $menuItems.length; // the number of items in the active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   769
   var menuIndex = $menuItems.index($item); // the items index in its menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   770
   var $newItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   771
   var $newItemUL = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   772
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   773
   if ($itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   774
      // this is the root level move to next sibling. This will require closing
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   775
      // the current child menu and opening the new one.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   776
 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   777
      if (menuIndex < menuNum-1) { // not the last root menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   778
         $newItem = $item.next();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   779
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   780
      else { // wrap to first item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   781
         $newItem = $menuItems.first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   782
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   783
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   784
      // close the current child menu (if applicable)
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   785
      if ($item.attr('aria-haspopup') == 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   786
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   787
         var $childMenu = $item.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   788
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   789
         if ($childMenu.attr('aria-hidden') == 'false') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   790
            // hide the child and update aria attributes accordingly
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   791
            $childMenu.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   792
            this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   793
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   794
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   795
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   796
      // remove the focus styling from the current menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   797
      $item.removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   798
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   799
      // open the new child menu (if applicable)
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   800
      if (($newItem.attr('aria-haspopup') == 'true') && (this.bChildOpen == true)) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   801
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   802
         var $childMenu = $newItem.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   803
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   804
         // open the child and update aria attributes accordingly
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   805
         $childMenu.show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   806
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   807
         /*
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   808
          * Uncomment this section if the first item in the child menu should be
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   809
          * automatically selected
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   810
          *
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   811
         if (!this.vmenu) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   812
            // select the first item in the child menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   813
            $newItem = $childMenu.children('li').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   814
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   815
         */
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   816
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   817
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   818
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   819
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   820
      // this is not the root level. If there is a child menu to be moved into, do that;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   821
      // otherwise, move to the next root-level menu if there is one
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   822
      if ($item.attr('aria-haspopup') == 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   823
         
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   824
         var $childMenu = $item.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   825
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   826
         $newItem = $childMenu.children('li').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   827
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   828
         // show the child menu and update its aria attributes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   829
         $childMenu.show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   830
         this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   831
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   832
      else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   833
         // at deepest level, move to the next root-level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   834
 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   835
         if (this.vmenu == true) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   836
            // do nothing
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   837
            return $item;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   838
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   839
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   840
         var $parentMenus = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   841
         var $rootItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   842
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   843
         // get list of all parent menus for item, up to the root level
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   844
         $parentMenus = $item.parentsUntil('div').filter('ul').not('.root-level');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   845
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   846
         // hide the current menu and update its aria attributes accordingly
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   847
         $parentMenus.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   848
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   849
         // remove the focus styling from the active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   850
         $parentMenus.find('li').removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   851
         $parentMenus.last().parent().removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   852
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   853
         $rootItem = $parentMenus.last().parent(); // the containing root for the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   854
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   855
         menuIndex = this.$rootItems.index($rootItem);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   856
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   857
         // if this is not the last root menu item, move to the next one
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   858
         if (menuIndex < this.$rootItems.length-1) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   859
            $newItem = $rootItem.next();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   860
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   861
         else { // loop
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   862
            $newItem = this.$rootItems.first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   863
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   864
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   865
         if ($newItem.attr('aria-haspopup') == 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   866
            var $childMenu = $newItem.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   867
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   868
            $newItem = $childMenu.children('li').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   869
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   870
            // show the child menu and update it's aria attributes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   871
            $childMenu.show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   872
            this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   873
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   874
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   875
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   876
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   877
   return $newItem;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   878
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   879
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   880
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   881
// Function moveToPrevious() is a member function to move to the previous menu level.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   882
// This will be either the previous root-level menu or the child of a menu parent. If
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   883
// at the root level and the active item is the first in the menu, this function will loop
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   884
// to the last menu item.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   885
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   886
// If the menu is a horizontal menu, the first child element of the newly selected menu will
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   887
// be selected
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   888
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   889
// @param($item object) $item is the active menu item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   890
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   891
// @return (object) Returns the item to move to. Returns $item is no move is possible
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   892
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   893
menubar.prototype.moveToPrevious = function($item) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   894
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   895
   var $itemUL = $item.parent(); // $item's containing menu 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   896
   var $menuItems = $itemUL.children('li'); // the items in the currently active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   897
   var menuNum = $menuItems.length; // the number of items in the active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   898
   var menuIndex = $menuItems.index($item); // the items index in its menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   899
   var $newItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   900
   var $newItemUL = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   901
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   902
   if ($itemUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   903
      // this is the root level move to previous sibling. This will require closing
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   904
      // the current child menu and opening the new one.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   905
 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   906
      if (menuIndex > 0) { // not the first root menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   907
         $newItem = $item.prev();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   908
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   909
      else { // wrap to last item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   910
         $newItem = $menuItems.last();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   911
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   912
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   913
      // close the current child menu (if applicable)
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   914
      if ($item.attr('aria-haspopup') == 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   915
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   916
         var $childMenu = $item.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   917
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   918
         if ($childMenu.attr('aria-hidden') == 'false') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   919
            // hide the child and update aria attributes accordingly
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   920
            $childMenu.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   921
            this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   922
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   923
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   924
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   925
      // remove the focus styling from the current menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   926
      $item.removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   927
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   928
      // open the new child menu (if applicable)
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   929
      if (($newItem.attr('aria-haspopup') == 'true') && this.bChildOpen == true) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   930
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   931
         var $childMenu = $newItem.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   932
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   933
         // open the child and update aria attributes accordingly
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   934
         $childMenu.show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   935
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   936
         /*
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   937
          * Uncomment this section if the first item in the child menu should be
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   938
          * automatically selected
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   939
          *
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   940
         if (!this.vmenu) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   941
            // select the first item in the child menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   942
            $newItem = $childMenu.children('li').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   943
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   944
         */
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   945
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   946
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   947
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   948
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   949
      // this is not the root level. If there is a parent menu that is not the
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   950
      // root menu, move up one level; otherwise, move to first item of the previous
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   951
      // root menu.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   952
 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   953
      var $parentLI = $itemUL.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   954
      var $parentUL = $parentLI.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   955
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   956
      var $parentMenus = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   957
      var $rootItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   958
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   959
      // if this is a vertical menu or is not the first child menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   960
      // of the root-level menu, move up one level.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   961
      if (this.vmenu == true || !$parentUL.is('.root-level')) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   962
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   963
         $newItem = $itemUL.parent();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   964
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   965
         // hide the active menu and update aria-hidden
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   966
         $itemUL.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   967
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   968
         // remove the focus highlight from the $item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   969
         $item.removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   970
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   971
         if (this.vmenu == true) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   972
            // set a flag so the focus handler does't reopen the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   973
            this.bChildOpen = false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   974
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   975
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   976
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   977
      else { // move to previous root-level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   978
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   979
         // hide the current menu and update the aria attributes accordingly
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   980
         $itemUL.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   981
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   982
         // remove the focus styling from the active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   983
         $item.removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   984
         $parentLI.removeClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   985
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   986
         menuIndex = this.$rootItems.index($parentLI);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   987
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   988
         if (menuIndex > 0) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   989
            // move to the previous root-level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   990
            $newItem = $parentLI.prev();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   991
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   992
         else { // loop to last root-level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   993
            $newItem = this.$rootItems.last();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   994
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   995
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   996
         // add the focus styling to the new menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   997
         $newItem.addClass('menu-focus');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   998
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
   999
         if ($newItem.attr('aria-haspopup') == 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1000
            var $childMenu = $newItem.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1001
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1002
            // show the child menu and update it's aria attributes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1003
            $childMenu.show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1004
            this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1005
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1006
            $newItem = $childMenu.children('li').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1007
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1008
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1009
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1010
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1011
   return $newItem;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1012
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1013
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1014
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1015
// Function moveDown() is a member function to select the next item in a menu.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1016
// If the active item is the last in the menu, this function will loop to the
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1017
// first menu item.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1018
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1019
// @param($item object) $item is the active menu item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1020
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1021
// @param(startChr char) [optional] startChr is the character to attempt to match against the beginning of the
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1022
// menu item titles. If found, focus moves to the next menu item beginning with that character.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1023
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1024
// @return (object) Returns the item to move to. Returns $item is no move is possible
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1025
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1026
menubar.prototype.moveDown = function($item, startChr) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1027
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1028
   var $itemUL = $item.parent(); // $item's containing menu 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1029
   var $menuItems = $itemUL.children('li').not('.separator'); // the items in the currently active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1030
   var menuNum = $menuItems.length; // the number of items in the active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1031
   var menuIndex = $menuItems.index($item); // the items index in its menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1032
   var $newItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1033
   var $newItemUL = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1034
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1035
   if ($itemUL.is('.root-level')) { // this is the root level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1036
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1037
      if ($item.attr('aria-haspopup') != 'true') {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1038
         // No child menu to move to
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1039
         return $item;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1040
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1041
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1042
      // Move to the first item in the child menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1043
      $newItemUL = $item.children('ul').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1044
      $newItem = $newItemUL.children('li').first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1045
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1046
      // make sure the child menu is visible
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1047
      $newItemUL.show().attr('aria-hidden', 'false');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1048
      this.bChildOpen = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1049
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1050
      return $newItem;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1051
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1052
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1053
   // if $item is not the last item in its menu, move to the next item. If startChr is specified, move
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1054
   // to the next item with a title that begins with that character.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1055
   //
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1056
   if (startChr) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1057
      var bMatch = false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1058
      var curNdx = menuIndex+1;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1059
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1060
      // check if the active item was the last one on the list
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1061
      if (curNdx == menuNum) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1062
         curNdx = 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1063
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1064
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1065
      // Iterate through the menu items (starting from the current item and wrapping) until a match is found
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1066
      // or the loop returns to the current menu item 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1067
      while (curNdx != menuIndex)  {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1068
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1069
         var titleChr = $menuItems.eq(curNdx).html().charAt(0);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1070
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1071
         if (titleChr.toLowerCase() == startChr) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1072
            bMatch = true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1073
            break;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1074
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1075
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1076
         curNdx = curNdx+1;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1077
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1078
         if (curNdx == menuNum) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1079
            // reached the end of the list, start again at the beginning
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1080
            curNdx = 0;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1081
         }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1082
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1083
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1084
      if (bMatch == true) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1085
         $newItem = $menuItems.eq(curNdx);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1086
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1087
         // remove the focus styling from the current item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1088
         $item.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1089
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1090
         return $newItem
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1091
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1092
      else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1093
         return $item;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1094
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1095
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1096
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1097
      if (menuIndex < menuNum-1) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1098
         $newItem = $menuItems.eq(menuIndex+1);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1099
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1100
      else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1101
         $newItem = $menuItems.first();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1102
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1103
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1104
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1105
   // remove the focus styling from the current item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1106
   $item.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1107
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1108
   return $newItem;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1109
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1110
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1111
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1112
// Function moveUp() is a member function to select the previous item in a menu.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1113
// If the active item is the first in the menu, this function will loop to the
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1114
// last menu item.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1115
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1116
// @param($item object) $item is the active menu item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1117
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1118
// @return (object) Returns the item to move to. Returns $item is no move is possible
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1119
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1120
menubar.prototype.moveUp = function($item) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1121
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1122
   var $itemUL = $item.parent(); // $item's containing menu 
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1123
   var $menuItems = $itemUL.children('li').not('.separator'); // the items in the currently active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1124
   var menuNum = $menuItems.length; // the number of items in the active menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1125
   var menuIndex = $menuItems.index($item); // the items index in its menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1126
   var $newItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1127
   var $newItemUL = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1128
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1129
   if ($itemUL.is('.root-level')) { // this is the root level menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1130
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1131
      // nothing to do
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1132
      return $item;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1133
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1134
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1135
   // if $item is not the first item in its menu, move to the previous item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1136
   if (menuIndex > 0) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1137
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1138
      $newItem = $menuItems.eq(menuIndex-1);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1139
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1140
   else {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1141
      // loop to top of menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1142
      $newItem = $menuItems.last();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1143
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1144
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1145
   // remove the focus styling from the current item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1146
   $item.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1147
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1148
   return $newItem;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1149
}
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1150
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1151
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1152
// Function handleKeyPress() is a member function to process keydown events
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1153
// for the menus.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1154
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1155
// The Opera browser performs some window commands from the keypress event,
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1156
// not keydown like Firefox, Safari, and IE. This event handler consumes
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1157
// keypresses for relevant keys so that Opera behaves when the user is
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1158
// manipulating the menu with the keyboard.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1159
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1160
// @param($item object) $menu is the jquery object of the item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1161
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1162
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1163
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1164
// @return(boolean) Returns false if consuming; true if propagating
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1165
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1166
menubar.prototype.handleKeyPress = function($item, e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1167
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1168
   if (e.altKey || e.ctrlKey || e.shiftKey) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1169
       // Modifier key pressed: Do not process
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1170
       return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1171
   }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1172
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1173
   switch(e.keyCode) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1174
      case this.keys.tab: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1175
         return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1176
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1177
      case this.keys.esc:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1178
      case this.keys.enter:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1179
      case this.keys.space:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1180
      case this.keys.up:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1181
      case this.keys.down:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1182
      case this.keys.left:
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1183
      case this.keys.right: {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1184
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1185
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1186
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1187
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1188
      default : {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1189
         var chr = String.fromCharCode(e.which);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1190
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1191
         this.$activeItem = this.moveDown($item, chr);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1192
         this.$activeItem.focus();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1193
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1194
         e.stopPropagation();
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1195
         return false;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1196
      }
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1197
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1198
   } // end switch
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1199
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1200
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1201
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1202
} // end handleKeyPress()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1203
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1204
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1205
// Function handleDocumentClick() is a member function to process click events on the document. Needed
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1206
// to close an open menu if a user clicks outside the menu
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1207
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1208
// @param(e object) e is the associated event object
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1209
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1210
// @return(boolean) Returns true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1211
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1212
menubar.prototype.handleDocumentClick = function(e) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1213
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1214
   // get a list of all child menus
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1215
   var $childMenus = this.$id.find('ul').not('.root-level');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1216
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1217
   // hide the child menus
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1218
   $childMenus.hide().attr('aria-hidden', 'true');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1219
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1220
   this.$allItems.removeClass('menu-focus menu-focus-checked');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1221
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1222
   this.$activeItem = null;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1223
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1224
   // allow the event to propagate
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1225
   return true;
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1226
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1227
} // end handleDocumentClick()
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1228
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1229
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1230
// Function processMenuChoice() is a member function to process the user's menu item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1231
// choice. Since the menu will close after this, highlight styling is simply removed.
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1232
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1233
// @param($item object) $item is the jquery object of the menu item firing the event
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1234
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1235
// @return N/A
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1236
//
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1237
menubar.prototype.processMenuChoice = function($item) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1238
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1239
	// find the parent menu for this item
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1240
	var menuName = $item.parent().attr('id');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1241
	var choice = $item.attr('id');
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1242
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1243
	// call the appropriate textarea function
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1244
	switch(menuName) {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1245
		case 'fontMenu': {
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1246
			this.textarea.setFont(choice);
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1247
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1248
			// update the aria-checked state of the menu items and apply
923202f69927 seed test104.html
Richard Schwerdtfeger <schwer@us.ibm.com>
parents:
diff changeset
  1249
			// appropriate styling