everything.html revision bb34581aa2148e0cfe89fbb5473165ae35a87fb5
1N/A<!DOCTYPE html>
1N/A<html>
1N/A <head>
1N/A <script src='/build/yui/yui-min.js'></script>
1N/A
1N/A <script>
1N/A
1N/A YUI({
1N/A base: '/build/',
1N/A debug: true,
1N/A combo: false,
1N/A filter: 'raw'
1N/A }).use('button', 'cssfonts', 'console', function(Y){
1N/A
1N/A new Y.Console().render();
1N/A
1N/A Y.log('A ninja button called ' + new Y.Button({label:'Bruce Lee'}).getNode().getContent());
1N/A
1N/A /*
1N/A Just a basic test with a listener
1N/A */
1N/A var button = new Y.Button({
1N/A srcNode: Y.one('#event')
1N/A });
1N/A
1N/A button.getNode().on("click", function(e){
1N/A Y.log("click");
1N/A });
1N/A
1N/A
1N/A /*
1N/A A 'toggle' button listening for the selectedChange event
1N/A */
1N/A var button2 = new Y.Button({
1N/A srcNode: Y.one('#toggle'),
1N/A type: 'toggle',
1N/A on: {
1N/A selectedChange:function(){
1N/A Y.log('selectedChange');
1N/A }
1N/A }
1N/A });
1N/A
1N/A /*
1N/A A 'link' button
1N/A Preferably, the user would just apply a yui3-button style to an <a> element and not use JS
1N/A */
1N/A var button3 = new Y.Button({
1N/A srcNode: Y.one('#link')
1N/A });
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A /*
1N/A A disabled button
1N/A */
1N/A var button4 = new Y.Button({
1N/A srcNode: Y.one('#disabled'),
1N/A disabled: true
1N/A });
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A /*
1N/A A group of radio-like buttons
1N/A */
1N/A var buttonGroup = new Y.ButtonGroup({
1N/A srcNodes: Y.all('.group'),
1N/A type: 'radio'
1N/A });
1N/A
1N/A buttonGroup.after('selectionChange', function(e){
1N/A Y.log('buttonGroup selection changed');
1N/A });
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A /*
1N/A A group of checkbox-like buttons
1N/A */
1N/A var buttonGroup2 = new Y.ButtonGroup({
1N/A srcNodes: Y.all('.multigroup'),
1N/A type: 'checkbox'
1N/A });
1N/A
1N/A buttonGroup2.after('selectionChange', function(e){
1N/A var selection = buttonGroup2.getSelectedButtons();
1N/A Y.log('buttonGroup2 selected count = ' + selection.length);
1N/A });
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A
1N/A /*
1N/A A button generator
1N/A Y.Buttons adds nothing useful for the gernator buttons, so just add the class and a listener.
1N/A */
1N/A Y.all('.generator').addClass('yui3-button').on('click', function(e){
1N/A var button, type, config;
1N/A
1N/A type = e.target.getAttribute('data-type');
1N/A
1N/A config = {
1N/A label: type
1N/A };
1N/A
1N/A if (type === 'disabled') {
1N/A config.type = 'push';
1N/A config.disabled = true;
1N/A }
1N/A else {
1N/A config.type = type;
1N/A }
1N/A
1N/A config.srcNode = Y.Node.create('<button>' + config.label + '</button>');
1N/A button = new Y.Button(config);
1N/A
1N/A Y.one('#generated').append(button.getNode());
1N/A });
1N/A
1N/A });
1N/A </script>
1N/A </head>
1N/A
1N/A <body class='yui3-skin-sam'>
1N/A
1N/A <div id='yconsole'></div>
1N/A
1N/A <h1>Button prototype</h1>
1N/A
1N/A <hr />
1N/A
1N/A <h2>Event</h2>
1N/A <button id='event' tabindex='3'>Log a message</button>
1N/A
1N/A
1N/A <br>
1N/A
1N/A
1N/A <h2>Toggle w/ event</h2>
1N/A <input type='button' id='toggle' value='Toggle'></input>
1N/A
1N/A
1N/A <br>
1N/A
1N/A
1N/A <h2>Link</h2>
1N/A <a href='http://yahoo.com' id='link'>Go to yahoo.com</a>
1N/A
1N/A
1N/A <h2>Disabled</h2>
1N/A <button id='disabled'>Should be disabled</button>
1N/A
1N/A
1N/A <br>
1N/A
1N/A
1N/A <h2>Multi-Group (checkbox)</h2>
1N/A <button class='multigroup' id='btn4'>Button 4</button>
1N/A <button class='multigroup' id='btn5'>Button 5</button>
1N/A <button class='multigroup' id='btn6'>Button 6</button>
1N/A
1N/A
1N/A <br>
1N/A
1N/A
1N/A <h2>Group (radio)</h2>
1N/A <button class='group' id='btn1'>Button 13</button>
1N/A <button class='group' id='btn2'>Button 27</button>
1N/A <button class='group' id='btn3'>Button 40</button>
1N/A
1N/A
1N/A <br>
1N/A
1N/A
1N/A <h2>Generator</h2>
1N/A <button class='generator' data-type='push'>Generate Push Button</button>
1N/A <button class='generator' data-type='toggle'>Generate Toggle Button</button>
1N/A <button class='generator' data-type='disabled'>Generate Disabled Button</button>
1N/A <div id='generated' style='border:solid black 1px;'></div>
1N/A
1N/A </body>
1N/A</html>