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