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