1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Example: OS-Style Programs Menu (YUI Library)</title>
<!-- Standard reset and fonts -->
<link rel="stylesheet" type="text/css" href="../../build/reset/reset.css">
<link rel="stylesheet" type="text/css" href="../../build/fonts/fonts.css">
<link rel="stylesheet" type="text/css" href="../../build/container/assets/skins/sam/container.css">
<!-- CSS for Menu -->
<link rel="stylesheet" type="text/css" href="../../build/menu/assets/skins/sam/menu.css">
<!-- Page-specific styles -->
<style type="text/css">
html {
overflow: hidden;
background-color: #dfb8df;
}
h1 {
font-weight: bold;
}
body {
overflow: hidden;
}
/* Define a style for the <H1> "toolbar" */
.ytoolbar {
border-top-width: 2px;
border-top-color: #ddd;
border-top-style: solid;
background-color: #ccc;
position: absolute;
bottom: 0;
width: 100%;
}
/* Style the "Yahoo!" anchor to look like a button */
.ytoolbar #yahoo {
border-width: 2px;
border-color: #ddd #666 #666 #ddd;
border-style: solid;
float: left;
*float: none; /* For IE */
*display: inline-block; /* For IE */
padding: 4px 12px 4px 28px;
margin: 4px;
background-color: #ccc;
color: #000;
text-decoration: none;
background: url(http://l.yimg.com/a/i/us/nt/b/purpley.1.0.gif) 10% 50% no-repeat;
}
.ytoolbar #yahoo: active {
border-color: #666 #ddd #ddd #666;
}
/* Define a new style for each menu */
.yui-skin-sam .yuimenu {
line-height: 2; /* ~24px */
*line-height: 1.9; /* For IE */
}
.yui-skin-sam .yuimenu .bd {
border-width: 2px;
border-color: #ddd #666 #666 #ddd;
border-style: solid;
background-color: #ccc;
}
/* Define a new style for each MenuItem instance. */
.yui-skin-sam #yproducts li.yuimenuitem .yuimenuitemlabel {
background: url(http://l.yimg.com/a/i/us/nt/b/purpley.1.0.gif) no-repeat 4px;
padding: 0 20px 0 24px;
}
.yui-skin-sam #yproducts li.yuimenuitem {
/*
For IE 7 Quirks and IE 6 Strict Mode and Quirks Mode:
Used to collapse superfluous white space between <li>
elements that is triggered by the "display" property of the
<a> elements being set to "block."
*/
_border-bottom: solid 1px #ccc;
}
/* Define a new style for a MenuItem instance's "selected" state. */
.yui-skin-sam #yproducts .yuimenuitem-selected {
background-color: #039;
}
.yui-skin-sam #yproducts .yuimenuitemlabel-selected {
color: #fff;
}
/* Add unique icons to some of the MenuItem instances. */
.yui-skin-sam #yproducts li#help .yuimenuitemlabel {
background-image: url(http://l.yimg.com/a/i/nt/ic/ut/bsc/hlp16_1.gif);
}
.yui-skin-sam #yproducts li#search .yuimenuitemlabel {
background-image: url(http://l.yimg.com/a/i/nt/ic/ut/bsc/srch16_1.gif);
}
.yui-skin-sam #yproducts li#goto .yuimenuitemlabel {
background-image: url(http://l.yimg.com/a/i/nt/ic/ut/bsc/arorght16_1.gif);
}
</style>
<!-- Dependency source files -->
<script type="text/javascript" src="../../build/utilities/utilities.js"></script>
<script type="text/javascript" src="../../build/container/container.js"></script>
<!-- Menu source file -->
<script type="text/javascript" src="../../build/menu/menu.js"></script>
<!-- Page-specific script -->
<script type="text/javascript">
/*
Initialize and render the MenuBar when its elements are ready
to be scripted.
*/
YAHOO.util.Event.onContentReady("yproducts", function () {
var oPanel = new YAHOO.widget.Panel(
"exampleinfo",
{
constraintoviewport: true,
fixedcenter: true,
width: "400px",
zindex: 1
}
);
oPanel.setHeader("OS-Style Programs Menu Example");
oPanel.setBody("This example demonstrates how to transform existing markup on the page into an operating-system-like menu.");
oPanel.render(document.body);
/*
Apply the "ytoolbar" class to the <H1> so that it is styled
like an application toolbar.
*/
var oH1 = document.getElementsByTagName("h1")[0];
YAHOO.util.Dom.addClass(oH1, "ytoolbar");
/*
Instantiate a Menu: The first argument passed to the
constructor is the id of the element in the page
representing the Menu; the second is an object literal
of configuration properties.
*/
var oMenu = new YAHOO.widget.Menu("yproducts", { zindex: 2 });
/*
Aligns the bottom-left corner of Menu instance to the
top-left corner of the Yahoo! anchor element that is
its context element.
*/
function positionMenu() {
oMenu.align("bl", "tl");
}
// "click" handler for the "Go to..." menu item
function onGotoClick() {
var sURL = window.prompt("Enter a URL: ","");
if (sURL && sURL.length > 0) {
document.location = sURL;
}
}
/*
Add an additional item to the Menu instance. Unlike the
other items in the Menu instance, this item is added via
script since its functionality requires JavaScript.
*/
oMenu.addItem({ text: "Go to...", id: "goto", onclick: { fn: onGotoClick } });
/*
"beforeShow" event listener - used to position the
root Menu instance when it is displayed.
*/
oMenu.subscribe("beforeShow", function () {
if (this.getRoot() == this) {
positionMenu();
}
});
/*
Call the "render" method with no arguments since the
markup for this menu already exists in the pages.
*/
oMenu.render();
/*
Position the bottom-left corner of the root menu to the
top-left corner of the "Yahoo!" anchor element.
*/
oMenu.cfg.setProperty("context", ["yahoo", "bl", "tl"]);
// "click" event handler for "Yahoo!" button
function onYahooClick(p_oEvent) {
// Position and display the menu
positionMenu();
oMenu.show();
// Stop propagation and prevent the default "click" behavior
YAHOO.util.Event.stopEvent(p_oEvent);
}
/*
Assign a "click" event handler to the "Yahoo!" anchor that
will display the menu
*/
YAHOO.util.Event.addListener("yahoo", "click", onYahooClick);
/*
Add a "resize" event handler for the window that will
reposition the H1 "toolbar" to the bottom of the viewport
*/
YAHOO.widget.Overlay.windowResizeEvent.subscribe(positionMenu);
// Hide the Menu the dialog is clicked
YAHOO.util.Event.on(oPanel.element, "mousedown", oMenu.hide, null, oMenu);
});
</script>
</head>
<body class="yui-skin-sam">
<h1><a id="yahoo" href="http://www.yahoo.com">Yahoo!</a></h1>
<div id="yproducts">
<div class="bd">
<ul>
<li><a href="#">Products</a>
<div id="products">
<div class="bd">
<ul>
<li><a href="http://mail.yahoo.com">Yahoo! Mail</a></li>
<li><a href="http://addressbook.yahoo.com">Yahoo! Address Book</a></li>
<li><a href="http://calendar.yahoo.com">Yahoo! Calender</a></li>
<li><a href="http://notepad.yahoo.com">Yahoo! Notepad</a></li>
<li><a href="http://messenger.yahoo.com">Yahoo! Messenger</a></li>
<li><a href="http://360.yahoo.com">Yahoo! 360</a></li>
<li><a href="http://www.flickr.com">Flickr Photo Sharing</a></li>
<li><a href="http://finance.yahoo.com/">Finance</a></li>
<li><a href="http://entertainment.yahoo.com/">Entertainment</a>
<div id="entertainmentproducts">
<div class="bd">
<ul>
<li><a href="http://music.yahoo.com/">Yahoo! Music</a></li>
<li><a href="http://movies.yahoo.com/">Yahoo! Movies</a></li>
<li><a href="http://tv.yahoo.com/">Yahoo! TV</a></li>
</ul>
</div>
</div>
</li>
</ul>
</div>
</div>
</li>
<li id="search"><a href="http://search.yahoo.com/">Search</a>
<div id="searchproducts">
<div class="bd">
<ul>
<li><a href="http://images.search.yahoo.com/images">Yahoo! Image Search</a></li>
<li><a href="http://dir.yahoo.com/">Yahoo! Directory</a></li>
<li><a href="http://local.yahoo.com">Yahoo! Local</a></li>
<li><a href="http://news.search.yahoo.com/news">Yahoo! News Search</a></li>
<li><a href="http://search.yahoo.com/people">Yahoo! People Search</a></li>
<li><a href="http://search.yahoo.com/products">Yahoo! Product Search</a></li>
</ul>
</div>
</div>
</li>
<li id="help"><a href="http://help.yahoo.com/">Help</a></li>
</ul>
</div>
</div>
</body>
</html>
|