webgui/www/extras/yui/examples/button/btn_example08_clean.html
2008-03-25 16:13:25 +00:00

222 lines
No EOL
6.6 KiB
HTML

<!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>Split Buttons</title>
<style type="text/css">
/*margin and padding on body element
can introduce errors in determining
element position and are not recommended;
we turn them off as a foundation for YUI
CSS treatments. */
body {
margin:0;
padding:0;
}
</style>
<link rel="stylesheet" type="text/css" href="../../build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="../../build/menu/assets/skins/sam/menu.css" />
<link rel="stylesheet" type="text/css" href="../../build/button/assets/skins/sam/button.css" />
<script type="text/javascript" src="../../build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="../../build/container/container_core-min.js"></script>
<script type="text/javascript" src="../../build/menu/menu-min.js"></script>
<script type="text/javascript" src="../../build/element/element-beta-min.js"></script>
<script type="text/javascript" src="../../build/button/button-min.js"></script>
<!--begin custom header content for this example-->
<style type="text/css">
/*
Set the "zoom" property to "normal" since it is set to "1" by the
".example-container .bd" rule in yui.css and this causes a Menu
instance's width to expand to 100% of the browser viewport.
*/
div.yuimenu .bd {
zoom: normal;
}
#button-example-form fieldset {
border: 2px groove #ccc;
margin: .5em;
padding: .5em;
}
#splitbutton3menu,
#splitbutton5menu {
position: absolute;
visibility: hidden;
border: solid 1px #000;
padding: .5em;
background-color: #ccc;
}
#button-example-form-postdata {
border: dashed 1px #666;
background-color: #ccc;
padding: 1em;
}
#button-example-form-postdata h2 {
margin: 0 0 .5em 0;
padding: 0;
border: none;
}
</style>
<!--end custom header content for this example-->
</head>
<body class=" yui-skin-sam">
<h1>Split Buttons</h1>
<div class="exampleIntro">
<p>This example demonstrates different ways to create a Split Button.</p>
</div>
<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->
<script type="text/javascript">
YAHOO.example.init = function () {
// "contentready" event handler for the "splitbuttonsfrommarkup" <fieldset>
YAHOO.util.Event.onContentReady("splitbuttonsfrommarkup", function () {
// Create a Button using an existing <input> element as a data source
var oSplitButton1 = new YAHOO.widget.Button("splitbutton1", { type: "split", menu: "splitbutton1select" });
var oSplitButton2 = new YAHOO.widget.Button("splitbutton2", { type: "split", menu: "splitbutton2select" });
// Create a Button using an existing <input> element and a YAHOO.widget.Overlay instance as its menu
var oSplitButton3 = new YAHOO.widget.Button("splitbutton3", { type: "split", menu: "splitbutton3menu" });
});
// Create a Button without using existing markup
// Create an array of YAHOO.widget.MenuItem configuration properties
var aSplitButton4Menu = [
{ text: "one", value: 1 },
{ text: "two", value: 2 },
{ text: "three", value: 3 }
];
/*
Instantiate a Split Button using the array of YAHOO.widget.MenuItem
configuration properties as the value for the "menu" configuration
attribute.
*/
var oSplitButton4 = new YAHOO.widget.Button({ type: "split", label: "Split Button 4", name: "splitbutton3", menu: aSplitButton4Menu, container: "splitbuttonsfromjavascript" });
/*
Search for an element to place the Split Button into via the
Event utilities "onContentReady" method
*/
YAHOO.util.Event.onContentReady("splitbuttonsfromjavascript", function () {
// Instantiate an Overlay instance
var oOverlay = new YAHOO.widget.Overlay("splitbutton5menu", { visible: false });
oOverlay.setBody("Split Button 5 Menu");
// Instantiate a Split Button
var oSplitButton5 = new YAHOO.widget.Button({ type: "split", label: "Split Button 5", menu: oOverlay });
/*
Append the Split Button and Overlay to the element with the id
of "splitbuttonsfromjavascript"
*/
oSplitButton5.appendTo(this);
oOverlay.render(this);
});
function onExampleSubmit(p_oEvent) {
var bSubmit = window.confirm("Are you sure you want to submit this form?");
if(!bSubmit) {
YAHOO.util.Event.preventDefault(p_oEvent);
}
}
YAHOO.util.Event.on("button-example-form", "submit", onExampleSubmit);
} ();
</script>
<form id="button-example-form" name="button-example-form" method="post" action="#">
<fieldset id="splitbuttons">
<legend>Split Buttons</legend>
<fieldset id="splitbuttonsfrommarkup">
<legend>From Markup</legend>
<input type="submit" id="splitbutton1" name="splitbutton1_button" value="Split Button 1">
<select id="splitbutton1select" name="splitbutton1select" multiple>
<option value="0">One</option>
<option value="1">Two</option>
<option value="2">Three</option>
</select>
<input type="button" id="splitbutton2" name="splitbutton2_button" value="Split Button 2">
<select id="splitbutton2select" name="splitbutton2select">
<option value="0">One</option>
<option value="1">Two</option>
<option value="2">Three</option>
</select>
<input type="button" id="splitbutton3" name="splitbutton3_button" value="Split Button 3">
<div id="splitbutton3menu" class="yui-overlay">
<div class="bd">Split Button 3 Menu</div>
</div>
</fieldset>
<fieldset id="splitbuttonsfromjavascript">
<legend>From JavaScript</legend>
</fieldset>
</fieldset>
</form>
<!--END SOURCE CODE FOR EXAMPLE =============================== -->
</body>
</html>