Adding mapbox-gl branch
This commit is contained in:
@@ -0,0 +1,285 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<!--
|
||||
Copyright 2010 The Closure Library Authors. All Rights Reserved.
|
||||
|
||||
Use of this source code is governed by the Apache License, Version 2.0.
|
||||
See the COPYING file for details.
|
||||
-->
|
||||
<head>
|
||||
<title>goog.ui.Css3MenuButtonRenderer Demo</title>
|
||||
<script src="../base.js"></script>
|
||||
<script>
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.debug.DivConsole');
|
||||
goog.require('goog.debug.LogManager');
|
||||
goog.require('goog.events');
|
||||
goog.require('goog.events.EventType');
|
||||
goog.require('goog.log');
|
||||
goog.require('goog.object');
|
||||
goog.require('goog.ui.Css3MenuButtonRenderer');
|
||||
goog.require('goog.ui.Menu');
|
||||
goog.require('goog.ui.MenuButton');
|
||||
goog.require('goog.ui.MenuItem');
|
||||
goog.require('goog.ui.Separator');
|
||||
goog.require('goog.ui.decorate');
|
||||
</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">
|
||||
<link rel="stylesheet" href="../css/menubutton.css">
|
||||
<link rel="stylesheet" href="../css/css3button.css">
|
||||
<link rel="stylesheet" href="../css/css3menubutton.css">
|
||||
<style>
|
||||
/* Base class for all icon elements. */
|
||||
.icon {
|
||||
height: 16px;
|
||||
width: 16px;
|
||||
margin: 0 1px;
|
||||
background-image: url(../images/toolbar_icons.gif);
|
||||
background-repeat: no-repeat;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* "Format" icon. */
|
||||
.format-icon{
|
||||
background-position: -64px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>goog.ui.Css3MenuButtonRenderer</h1>
|
||||
<table border="0" cellpadding="0" cellspacing="4" width="100%">
|
||||
<tbody>
|
||||
<tr valign="top">
|
||||
<td width="67%">
|
||||
<fieldset>
|
||||
<legend>
|
||||
These <strong>MenuButton</strong>s were created programmatically:
|
||||
|
||||
</legend>
|
||||
<table border="0" cellpadding="0" cellspacing="4">
|
||||
<tbody>
|
||||
<tr valign="middle">
|
||||
<td>
|
||||
<div id="menuButtons"></div>
|
||||
</td>
|
||||
<td>
|
||||
Enable first button:
|
||||
<input type="checkbox" id="b1_enable" checked>
|
||||
|
||||
Show second button:
|
||||
<input type="checkbox" id="b2_show" checked>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<label>
|
||||
</label>
|
||||
<br>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>
|
||||
This <strong>MenuButton</strong> decorates an element:
|
||||
</legend>
|
||||
<table border="0" cellpadding="0" cellspacing="4">
|
||||
<tbody>
|
||||
<tr valign="middle">
|
||||
<td>
|
||||
<div id="formatButton" class="goog-css3-menu-button"
|
||||
title="Format">
|
||||
<!-- These elements will become the button's caption. -->
|
||||
<div class="icon format-icon goog-inline-block"></div>
|
||||
<span style="vertical-align:middle">Format</span>
|
||||
<!-- This DIV will be auto-decorated with a menu. -->
|
||||
<div id="formatMenu" class="goog-menu">
|
||||
<div class="goog-menuitem">Bold</div>
|
||||
<div class="goog-menuitem">Italic</div>
|
||||
<div class="goog-menuitem">Underline</div>
|
||||
<div class="goog-menuseparator"></div>
|
||||
<div class="goog-menuitem goog-menuitem-disabled">
|
||||
Strikethrough
|
||||
</div>
|
||||
<div class="goog-menuseparator"></div>
|
||||
<div class="goog-menuitem">Font...</div>
|
||||
<div class="goog-menuitem">Color...</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
Enable button:
|
||||
<input type="checkbox" id="formatButton_enable" checked>
|
||||
|
||||
Show button:
|
||||
<input type="checkbox" id="formatButton_show" checked>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<label>
|
||||
</label>
|
||||
<br>
|
||||
</fieldset>
|
||||
</td>
|
||||
<td width="33%">
|
||||
<!-- Event log. -->
|
||||
<fieldset class="goog-debug-panel">
|
||||
<legend>Event Log</legend>
|
||||
<div id="log"></div>
|
||||
</fieldset>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
<div id="perf"></div>
|
||||
<script>
|
||||
var timer = goog.now();
|
||||
|
||||
// Set up a logger.
|
||||
goog.debug.LogManager.getRoot().setLevel(goog.log.Level.ALL);
|
||||
var logger = goog.log.getLogger('demo');
|
||||
var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log'));
|
||||
logconsole.setCapturing(true);
|
||||
|
||||
var EVENTS = goog.object.getValues(goog.ui.Component.EventType);
|
||||
goog.log.fine(logger, 'Listening for: ' + EVENTS.join(', ') + '.');
|
||||
|
||||
function logEvent(e) {
|
||||
var component = e.target;
|
||||
var caption = (typeof component.getCaption == 'function') ?
|
||||
component.getCaption() : component.getId();
|
||||
goog.log.info(logger, '"' + caption + '" dispatched: ' + e.type);
|
||||
}
|
||||
|
||||
// Create a sample menu.
|
||||
var m1 = new goog.ui.Menu();
|
||||
m1.setId('FileMenu');
|
||||
goog.array.forEach(['New', 'Open', 'Save', 'Save as', null, 'Change label'],
|
||||
function(label) {
|
||||
var item;
|
||||
if (label) {
|
||||
item = new goog.ui.MenuItem(label + '...');
|
||||
item.setId(label);
|
||||
item.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
|
||||
if (label == 'Save as') {
|
||||
item.setEnabled(false);
|
||||
}
|
||||
} else {
|
||||
item = new goog.ui.MenuSeparator();
|
||||
}
|
||||
m1.addItem(item);
|
||||
});
|
||||
|
||||
// Create the first button programmatically.
|
||||
var b1 = new goog.ui.MenuButton('File', m1,
|
||||
new goog.ui.Css3MenuButtonRenderer());
|
||||
b1.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
|
||||
b1.setId('FileButton');
|
||||
b1.render(goog.dom.getElement('menuButtons'));
|
||||
b1.setTooltip('File menu demo');
|
||||
goog.events.listen(b1, EVENTS, logEvent);
|
||||
|
||||
goog.events.listen(goog.dom.getElement('b1_enable'),
|
||||
goog.events.EventType.CLICK,
|
||||
function(e) {
|
||||
b1.setEnabled(e.target.checked);
|
||||
});
|
||||
|
||||
goog.events.listen(b1, goog.ui.Component.EventType.ACTION,
|
||||
function(e) {
|
||||
if (e.target && e.target.getCaption() == 'Change label...') {
|
||||
var label = window.prompt('Enter new menu label:', b1.getCaption());
|
||||
b1.setCaption(label || 'Empty');
|
||||
}
|
||||
});
|
||||
|
||||
// Create another sample menu.
|
||||
var m2 = new goog.ui.Menu();
|
||||
m2.setId('EditMenu');
|
||||
goog.array.forEach(['Cut', 'Copy', 'Paste', null, 'Paste special'],
|
||||
function(label) {
|
||||
var item;
|
||||
if (label) {
|
||||
item = new goog.ui.MenuItem(label + '...');
|
||||
item.setId(label);
|
||||
item.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
|
||||
} else {
|
||||
item = new goog.ui.MenuSeparator();
|
||||
}
|
||||
m2.addItem(item);
|
||||
});
|
||||
|
||||
// Create the second button programmatically.
|
||||
var b2 = new goog.ui.MenuButton('Edit', m2,
|
||||
new goog.ui.Css3MenuButtonRenderer());
|
||||
b2.setId('EditButton');
|
||||
b2.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
|
||||
b2.render(goog.dom.getElement('menuButtons'));
|
||||
b2.setTooltip('Edit menu demo');
|
||||
goog.events.listen(b2, EVENTS, logEvent);
|
||||
|
||||
goog.events.listen(goog.dom.getElement('b2_show'),
|
||||
goog.events.EventType.CLICK,
|
||||
function(e) {
|
||||
b2.setVisible(e.target.checked);
|
||||
});
|
||||
|
||||
// Create another sample menu.
|
||||
var m3 = new goog.ui.Menu();
|
||||
m3.setId('WindowMenu');
|
||||
goog.array.forEach(['Tile', 'Cascade', null, 'Zoom in', 'Zoom out'],
|
||||
function(label) {
|
||||
var item;
|
||||
if (label) {
|
||||
item = new goog.ui.MenuItem(label + '...');
|
||||
item.setId(label);
|
||||
item.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
|
||||
} else {
|
||||
item = new goog.ui.MenuSeparator();
|
||||
}
|
||||
m3.addItem(item);
|
||||
});
|
||||
var unhighlightable = new goog.ui.MenuItem('Zoom control:');
|
||||
// Disabled implies unhighlightable, unless the menu is specifically set
|
||||
// to allow highlighting disabled items (but it doesn't by default).
|
||||
unhighlightable.setEnabled(false);
|
||||
unhighlightable.setId('unhighlightable');
|
||||
m3.addItemAt(unhighlightable, 3);
|
||||
|
||||
// Create a third button programmatically.
|
||||
var b3 = new goog.ui.MenuButton('Window', m3,
|
||||
new goog.ui.Css3MenuButtonRenderer());
|
||||
b3.setId('WindowButton');
|
||||
b3.setDispatchTransitionEvents(goog.ui.Component.State.ALL, true);
|
||||
b3.render(goog.dom.getElement('menuButtons'));
|
||||
b3.setTooltip('Windowm menu demo');
|
||||
goog.events.listen(b3, EVENTS, logEvent);
|
||||
|
||||
// Decorate a menu button. Note that since one of the child nodes of the
|
||||
// menu button element can be decorated as a menu, it is auto-decorated and
|
||||
// attached to the button.
|
||||
var formatButton = goog.ui.decorate(goog.dom.getElement('formatButton'));
|
||||
|
||||
goog.events.listen(goog.dom.getElement('formatButton_show'),
|
||||
goog.events.EventType.CLICK,
|
||||
function(e) {
|
||||
formatButton.setVisible(e.target.checked);
|
||||
});
|
||||
|
||||
goog.events.listen(goog.dom.getElement('formatButton_enable'),
|
||||
goog.events.EventType.CLICK,
|
||||
function(e) {
|
||||
formatButton.setEnabled(e.target.checked);
|
||||
});
|
||||
|
||||
goog.events.listen(formatButton, EVENTS, logEvent);
|
||||
|
||||
goog.dom.setTextContent(goog.dom.getElement('perf'),
|
||||
(goog.now() - timer) + 'ms');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user