sku-pg
Version:
Skulpt is a Javascript implementation of Python 2.x. Python that runs in your browser!
90 lines (75 loc) • 2.65 kB
HTML
<html>
<!--
Copyright 2010 The Closure Library Authors. All Rights Reserved.
Use of this source code is governed by an Apache 2.0 License.
See the COPYING file for details.
-->
<head>
<title>goog.ui.PopupMenu</title>
<script src="../base.js"></script>
<script>
goog.require('goog.debug');
goog.require('goog.positioning.Corner');
goog.require('goog.ui.MenuItem');
goog.require('goog.ui.PopupMenu');
</script>
<link rel="stylesheet" href="css/demo.css">
<link rel="stylesheet" href="../css/menu.css">
<link rel="stylesheet" href="../css/menuitem.css">
<link rel="stylesheet" href="../css/menuseparator.css">
</head>
<body>
<h1>goog.ui.PopupMenu</h1>
<div>
This shows a 2 popup menus, each menu has been attached to two targets.
<br><br>
</div>
<div id="foo" style="width: 600px; height: 300px; background-color: #EEE">
<div>
<span>Hello there <i>I'm italic!</i></span>
</div>
<div><button id="bar">Decorated Popup attached to a Button</button></div>
</div>
<button id="bar2" style="position:absolute;left: 600px;top:330px;">Button</button>
<button id="dButton">Decorated Popup</button>
<div id="dMenu" for="dButton" class="goog-menu" style="display:none">
<div class="goog-menuitem">A a</div>
<div class="goog-menuitem">B b</div>
<div class="goog-menuitem">C c</div>
<div class="goog-menuitem">D d</div>
<div class="goog-menuitem">E e</div>
<div class="goog-menuitem">F f</div>
</div>
<script>
var pm = new goog.ui.PopupMenu();
pm.addItem(new goog.ui.MenuItem('One'));
pm.addItem(new goog.ui.MenuItem('Two'));
pm.addItem(new goog.ui.MenuItem('Three'));
pm.addItem(new goog.ui.MenuItem('Four'));
pm.addItem(new goog.ui.MenuItem('Five'));
pm.addItem(new goog.ui.MenuItem('Six'));
pm.addItem(new goog.ui.MenuItem('Seven'));
pm.render(document.body);
//pm.attach(document.getElementById('foo'), null, null);
pm.attach(
document.getElementById('bar2'),
goog.positioning.Corner.TOP_LEFT,
goog.positioning.Corner.BOTTOM_LEFT);
pm.attach(document.getElementById('foo'));
var pm2 = new goog.ui.PopupMenu();
pm2.setToggleMode(true);
pm2.decorate(document.getElementById('dMenu'));
pm2.attach(
document.getElementById('bar'),
goog.positioning.Corner.BOTTOM_LEFT,
goog.positioning.Corner.TOP_LEFT);
goog.events.listen(pm, 'action', function(e) {
alert(e.target.getCaption());
});
goog.events.listen(pm2, 'action', function(e) {
alert(e.target.getCaption());
});
</script>
</body>
</html>