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