r2691 - - move old files and initial import of malko's ui-button attempt

r2691 - - move old files and initial import of malko's ui-button attempt


Author: malk0.phpgtk
Date: Wed Jun 10 14:33:39 2009
New Revision: 2691
Added:
branches/labs/button/previousAttempts/
branches/labs/button/previousAttempts/filament/
branches/labs/button/previousAttempts/filament/index.html (props
changed)
- copied unchanged from r2690, /branches/labs/button/index.html
branches/labs/button/previousAttempts/filament/ui_demos.js (props
changed)
- copied unchanged from r2690, /branches/labs/button/ui_demos.js
branches/labs/button/previousAttempts/malko/
branches/labs/button/previousAttempts/malko/demo.html
branches/labs/button/previousAttempts/malko/jquery-ui-button.css
branches/labs/button/previousAttempts/malko/jquery-ui-button.js
(contents, props changed)
Removed:
branches/labs/button/index.html
branches/labs/button/ui_demos.js
Log:
- move old files and initial import of malko's ui-button attempt
Added: branches/labs/button/previousAttempts/malko/demo.html
==============================================================================
--- (empty file)
+++ branches/labs/button/previousAttempts/malko/demo.html    Wed Jun 10
14:33:39 2009
@@ -0,0 +1,211 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head>
+    <!--link rel="stylesheet" type="text/css"
href="css/redmond/jquery-ui-1.7.1.custom.css" /-->
+    <!--link rel="stylesheet" type="text/css"
href="css/trontastic/jquery-ui-1.7.1.custom.css" /-->
+    <link type="text/css" rel="stylesheet"
href="http://jqueryui.com/themes/base/ui.all.css" />
+    <script type="text/javascript"
src="http://jqueryui.com/js/jquery.js"></script>
+    <script type="text/javascript"
src="http://jqueryui.com/themeroller/themeswitchertool/"></script>
+    <!--script
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script-->
+    <script
src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7/jquery-ui.min.js"></script>
+
+    <link rel="stylesheet" type="text/css" href="jquery-ui-button.css" />
+    <script src="jquery-ui-button.js"></script>
+    <style>
+
+        body{
+            font-family:Arial, helvetica;
+            text-align:left;
+        }
+        div{
+            text-align:left;
+        }
+        td,th{
+            vertical-align:middle;
+            text-align:center;
+        }
+        table{
+            border:solid black 1px;
+        }
+        th{
+            border-right:solid silver 1px;
+            border-bottom:solid silver 1px;
+        }
+        p,li{
+            font-size:1em;
+        }
+        h1 {font-size:1.25em;}
+        h2 {font-size:1.1em;}
+
+
+    </style>
+
+    <script>
+    function show(){if(
typeof(console)!='undefined'){console.debug(arguments);}}
+
+    jQuery().ready(function(){
+        var icon = "info";
+        
$('[class*=ui-button]:gt(0)').button({checkButtonset:true,toggle:function(event,ui){alert('toggle
button '+(ui.isActive()?'on':'off'))}});
+        $('#settingBar select').change(function(){
+            if($(this).is('#bodySizeSelector'))
+                return $('body').css('fontSize',$(this).val());
+            
$('.ui-button:gt(18)').button('option',$(this).attr('name'),$(this).val());
+        });
+        $('select[class*=ui-buttonset]').selectbuttonset();
+ $('#switcher').themeswitcher();
+    });
+    </script>
+</head>
+<body>
+<h1>Jquery-ui-button proposal</h1>
+


+    Hi, I'm fond of jquery and jquery ui. I'm totally convinced by the "new"
ui-css-framework, but some stuff still need too more coding imho.
+
+




+


+    Part of the good stuff of this css-framework is you can easily change the
look and feel of a web application using theme-roller.
+    <br />
+    But the dark side started to show it's face on me when I wanted to use
simple buttons using for examples ui-icons
+






+


+So here we are, this is an attempt to create a jquery-ui-button plugin, my
first ui-plugin so i must learn all the standards of doing suchs things.
(please be kind if your see any bad practice or better way to do things
drop me a line by <a href="mailto:jgotti@jgotti.org">mail</a>)
+





+


+    This is page will be subject to many changes and is there only for
testing purpose, but don't hesitate to join me by mail for any ideas, bug
reports or any feedback you can provide
+    <br />
+    The reference project page i'm working from is <a
href="http://jqueryui.pbworks.com/Buttons" target="_blank">there</a>
+
+








+


+    <h2>current state</h2>
+    <ul>
+        <li>tested working under: firefox, chrome, midori, opera, ie6/7/8</li>
+        <li>Buttons elements don't succeed to render same size as other tags in
many browsers (notably ie)</li>
+        <li>
+            Opera fail to keep the full height when displaying only icons with
vertical orientations, but buttons behave like others elements regarding
padding
+        </li>
+
+        <li>Vertical orientations are buggy with ie6 (not >=7) and render the
full button as a block if original element is not a button.
+        <li>Destroy isn't functionnal for now (but will be soon)</li>
+        <li>
+            Toggle buttons are functionnal and use additional <em>toggle</em> and
<em>active</em> classes for detection and ui-state-highlight for rendering
the toggle state.
+            Toggle buttons have an option for toggle callback.
+        </li>
+        <li>
+            It totally work with theme-roller and jquery-ui css framework as it's
heavily based on it
+        </li>
+        <li>
+            you can parameter orientation, size and ui-icon all in one in the class
attribute like this:
+            ui-button-size-orientation-iconname for example at the start this demo
use class: ui-button-info        </li>
+        <li>
+            Buttonset can also be configured by class attribute to manage default
behaviour of contained buttons like this:
+            <br />ui-buttonset-size-orientation.
+        </li>
+        <li>
+            A special orientation <em>i</em> exists and mean Only icon so when
setted will hide the label (usefull to allow user to choose how to dispay
buttonset in future),
+            but for now changing orientation doesn't restore label (will be done at
same time than destroy support)
+        </li>
+
+        <li>
+            Select elements can be rendered as a group of toggle buttons using
ui-buttonset and a special $('select').selectbuttonset() method but this
will probably change as i doubt that it's the correct way to instantiate
this, but that's my first ui-widget try so a lot of reading is awaiting
me :)
+            you can see an example with the set icon selector.
+        </li>
+    </ul>
+    <h2>Changed</h2>
+    <ul>
+        <li>Now orientation are top left right bottom based instead of north
west south est</li>
+        <li>replace ui-icon- by ui-icon-none</li>
+        <li>change padding values to feat like existing buttons inside other
plugins</li>
+        <li>replace ui-widget-content on button by ui-widget but not for
buttonset</li>
+    </ul>
+






























































+
+<div id="demo1">
+    <h2>Testing single buttons</h2>
+    

Play with selectors here to change settings


+    <div id="settingBar">
+
+        <label>Set Icon:
+            <select id="iconSelector" class="ui-buttonset-small" name="icon">
+                <option value="">no icon</option>
+                <option class="ui-icon-info" value="info"
selected="selected">info</option>
+                <option class="ui-icon-wrench" value="wrench">wrench</option>
+                <option class="ui-icon-lightbulb" value="lightbulb">lightbulb</option>
+                <option class="ui-icon-image" value="go-home.png">image file</option>
+            </select>
+        </label>
+        <br />
+        <br />
+        <label>Play with size:
+            <select id="sizeSelector" class="ui-buttonset-small" name="size">
+                <option>tiny</option>
+                <option>small</option>
+                <option>normal</option>
+                <option>big</option>
+                <option>huge</option>
+            </select>
+        </label>
+        <br />
+        <br />
+        <label>Change icon position
+            <select id="orientationSelector" name="orientation"
class="ui-buttonset-small">
+                <option class="ui-icon-arrowthick-1-n" value="t">top</option>
+                <option class="ui-icon-arrowthick-1-w" value="l">left</option>
+                <option class="ui-icon-arrowthick-1-s" value="b">bottom</option>
+                <option class="ui-icon-arrowthick-1-e" value="r">right</option>
+            </select>
+        </label>
+        <br />
+        <br />
+        <label>change body police size:
+            <select id="bodySizeSelector" class="ui-buttonset-small" name="size">
+                <option value="" selected="selected">no size specified</option>
+                <option>10px</option>
+                <option>12px</option>
+                <option>14px</option>
+                <option>16px</option>
+            </select>
+        </label>
+        <br />
+        <br />
+        Or switch theme: <div id="switcher" style="display:inline-block;"></div>
+    </div>
+    <h3>Using A element</h3>
+
+    <a href="javascript:" class="ui-button-info">standard button</a>
+    <a href="javascript:" class="ui-button-info toggle">toggle button</a>
+    <h3>Using SPAN element</h3>
+    <span class="ui-button-info">standard button</span>
+    <span class="ui-button-info toggle">toggle button</span>
+    <h3>Using DIV element</h3>
+
+    <div class="ui-button-info">standard button</div>
+    <div class="ui-button-info toggle">toggle button</div>
+    <h3>Using BUTTON element</h3>
+    <button type="button" class="ui-button-info">standard button</button>
+    <button type="button" class="ui-button-info toggle">toggle button</button>
+</div>
+
+<div id="demo2">
+    <h2>Testing button sets</h2>
+
+    <h3>Using A element (start small size)</h3>
+    <div class="ui-buttonset-small">
+        <a href="javascript:" class="ui-button">standard button</a><a
href="javascript:" class="ui-button-info">standard button</a><a
href="javascript:" class="ui-button-info toggle">toggle button</a><a
href="javascript:" class="ui-button-info toggle">toggle button</a>
+    </div>
+
+    <h3>Using SPAN element (start with icon on the right )</h3>
+    <div class="ui-buttonset-r">
+        <span class="ui-button-l">standard with icon on the left</span><span
class="ui-button-info">standard button</span><span class="ui-button-info
toggle">toggle button</span><span class="ui-button-info toggle">toggle
button</span>
+    </div>
+    <h3>Using DIV element (start with no labels at all even if they're in the
original markup)</h3>
+    <div class="ui-buttonset-i">
+
+        <div class="ui-button-info">standard button</div><div
class="ui-button-info toggle">toggle button</div><div class="ui-button-info
toggle">toggle button</div>
+    </div>
+    <h3>Using BUTTON element</h3>
+    <div class="ui-buttonset">
+        <button type="button" class="ui-button-info">standard
button</button><button type="button" class="ui-button-info">standard
button</button><button type="button" class="ui-button-info toggle">toggle
button</button>
+    </div>
+</body>
+</html>
Added: branches/labs/button/previousAttempts/malko/jquery-ui-button.css
==============================================================================
--- (empty file)
+++ branches/labs/button/previousAttempts/malko/jquery-ui-button.css    Wed
Jun 10 14:33:39 2009
@@ -0,0 +1,95 @@
+.ui-buttonset{
+    padding:0.2em;
+    display:inline-block;
+    margin:0 0.1em;
+    vertical-align:bottom;
+    white-space:nowrap;
+}
+
+.ui-button-inlineBlockFix{
+    display:inline !important;
+}
+
+.ui-button, button.ui-button{
+    position:relative;
+    zoom:1; /** ie hasLayout trigger */
+    text-decoration:none;
+    cursor:pointer;
+    margin:0 0.1em;
+    padding: 0.2em 0.8em;
+    text-align:center;
+    display:inline-block;
+    vertical-align:bottom;
+    white-space:nowrap;
+    outline:none;
+    font-size:1em;
+}
+button.ui-button-inlineBlockFix{
+    display:inline !important;
+    width:1;
+}
+.ui-buttonset .ui-button,.ui-buttonset button.ui-button{
+    margin:0;
+}
+
+.ui-button-size-tiny, button.ui-button-size-tiny
{font-size:0.75em !important;}
+.ui-button-size-small, button.ui-button-size-small
{font-size:0.9em !important;}
+.ui-button-size-normal,
button.ui-button-size-normal{font-size:1em !important;}
+.ui-button-size-big, button.ui-button-size-big
{font-size:1.1em !important;}
+.ui-button-size-huge, button.ui-button-size-huge
{font-size:1.25em !important;}
+
+/** labels **/
+.ui-button-label{
+    font-size:1em;
+    display:inline-block;
+    padding:0.2em;
+    vertical-align:middle;
+    white-space:nowrap;
+    margin:auto;
+}
+
+.ui-button-label.ui-button-label-empty{
+    width:0px;
+    zoom:1;
+    overflow:visible;
+    white-space:nowrap;
+    padding:0.2em 0;
+    margin:0 !important;
+}
+
+/** icons **/
+.ui-button-icon {
+    position:relative;
+    zoom:1;
+    font-size:1em;
+    vertical-align:middle;
+    margin:auto;
+    text-align:center;
+}
+
+.ui-button-icon img{
+    border:none;
+    display:block;
+    margin:0 auto;
+}
+
+.ui-button-orientation-t .ui-button-icon { display:block !important;
margin:0 auto;width:100%;}
+.ui-button-orientation-b .ui-button-icon { display:block !important;
margin:0 auto;width:100%;}
+.ui-button-orientation-l .ui-button-icon {
display:inline-block !important;}
+.ui-button-orientation-r .ui-button-icon {
display:inline-block !important;}
+
+.ui-button-orientation-t .ui-icon, .ui-button-orientation-b .ui-icon{
margin:0 auto;}
+.ui-button-orientation-b .ui-icon-none, .ui-button-orientation-t .ui-icon-none
{
background:none !important;}
+.ui-button-orientation-r .ui-icon-none, .ui-button-orientation-l .ui-icon-none
{
display:none;}
+.ui-button-inlineBlockFix.ui-button-orientation-t .ui-button-icon {
width:1;}
+.ui-button-inlineBlockFix.ui-button-orientation-b .ui-button-icon {
width:1; }
+.ui-button-inlineBlockFix.ui-button-orientation-t .ui-button-label{
width:1; }
+.ui-button-inlineBlockFix.ui-button-orientation-b .ui-button-label{
width:1; }
+
+/*
+.ui-button-size-tiny .ui-icon {zoom:0.5;}
+.ui-button-size-small .ui-icon {zoom:0.75;}
+.ui-button-size-normal .ui-icon {zoom:1;}
+.ui-button-size-big .ui-icon {zoom:1.5;}
+.ui-button-size-huge .ui-icon {zoom:2;}
+*/
Added: branches/labs/button/previousAttempts/malko/jquery-ui-button.js
==============================================================================
--- (empty file)
+++ branches/labs/button/previousAttempts/malko/jquery-ui-button.js    Wed Jun
10 14:33:39 2009
@@ -0,0 +1,415 @@
+/**
+* jQuery UI Labs - buttons
+* - for experimental use only -
+* Copyleft (l) 2009 Jonathan gotti aka malko < jgotti at jgotti dot org >
+* Dual licensed under the MIT and GPL licenses.
+* http://docs.jquery.com/License
+* Depends:
+*        ui.core.js
+*/
+(function($){
+        $.widget("ui.button",{
+
+        elmt_icon:null,
+        elmt_iconContainer:null,
+        elmt_label:null,
+        iconIsImage:false,
+        iconBeforeLabel:true,
+        _isToggleCB:null,
+        _buttonset:null,
+        _cornersValue:'',
+        _orientationValue:'',
+        _sizeValue:'',
+        _init:function(){
+            var self = this;
+
+            // read inline options from class attribute (that can't be null!!!)
+            var inlineOptions = self.element.attr('class');
+            if( undefined === inlineOptions || null === inlineOptions ){
+                inlineOptions = ['ui-button','','',''];
+            }else{
+                _inlineOptions = inlineOptions.match(/(?:^|\s+)ui-button(?:-(tiny|
normal|small|big|huge))?(?:-([itlbr](?=$|\s|-)))?(?:-([\w0-9_-]+))?(?:$|
\s+)/);
+                if( null !== _inlineOptions){
+                    inlineOptions = _inlineOptions;
+                }else{
+                    if( this.element.attr('class').match(/(?:^|\s+)ui-buttonset/) )
+                        return null;
+                    else
+                        inlineOptions = ['ui-button','','',''];
+                }
+            }
+
+            self.element.addClass('ui-button ui-widget ui-state-default')
+                .hover(self._hover,self._blur);
+
+            // preapre wrapers elements
+            self._wrapLabel();
+            self._wrapIcon();
+
+            if( 'auto' == self.options.size && inlineOptions[1] &&
inlineOptions[1].length){
+                self.options.size = inlineOptions[1];
+            }
+            if( 'auto' == self.options.orientation && inlineOptions[2] &&
inlineOptions[2].length){
+                self.options.orientation = inlineOptions[2];
+            }
+
+            if( '' == self.options.icon ){
+                self.options.icon = (inlineOptions[3] &&
inlineOptions[3].length)?inlineOptions[3]:'';
+            }
+
+            if( self.element.hasClass('toggle') ){
+                self.options.isToggle = true;
+            }
+            if( self.element.hasClass('active')){
+                self.options.active = true;
+            }
+
+            self._setData('size',self.options.size);
+            self._setData('orientation',self.options.orientation);
+            self._setData('icon',self.options.icon);
+            self._setData('corners',self._getData('corners'));
+            if( self.options.isToggle){
+                self._setData('isToggle',self.options.isToggle);
+            }
+            if( self.options.active){
+                self._setData('active',self.options.active);
+            }
+            if( null!==self.options.label){
+                self._setData('label',self.options.label);
+            }
+
+            if(! $.support.style){
+                this.element.addClass('ui-button-inlineBlockFix');
+                this.elmt_iconContainer.css({margin:0});
+                if(null !== this.elmt_icon){
+                    this.elmt_icon.css({margin:0});
+                }
+            }
+            // auto initialisation of button set on last buttonset element
+            if( self.options.checkButtonset){
+                var buttonset = self.element.parent('[class*=ui-buttonset]');
+                if( buttonset.length > 0){
+                        self._buttonset = buttonset;
+                        if( this.element.is(':last-child')){
+                            buttonset.buttonset();
+                        }
+                }
+            }
+        },
+        _hover: function(){
+            $(this).addClass('ui-state-hover');
+        },
+        _blur: function(){
+            $(this).removeClass('ui-state-hover');
+        },
+
+        _setIcon:function(){
+            var ico = this._getData('icon');
+            this.iconIsImage =( ico.match(/\.(jpe?g|png|gif|ico)$/i) )?true:false;
+            if(null !== this.elmt_icon){
+                this.elmt_icon.remove();
+            }
+            if( '' === ico || null === ico){
+                this.elmt_icon = null;
+                this.elmt_iconContainer.hide();
+                ico='none';
+            }
+            if( this.iconIsImage){
+                this.elmt_icon=$('<img src="'+escape(ico)+'" />');
+            }else{
+                this.elmt_icon=$('<span class="ui-icon ui-icon-'+ico+'"></span>');
+            }
+            if(this.elmt_icon.length && ! $.support.style){
+                this.elmt_icon.css({margin:0});
+            }
+            this.elmt_iconContainer.append(this.elmt_icon);
+            this.elmt_iconContainer.show();
+        },
+
+        _wrapLabel:function(){
+            if( null!==this.elmt_label ){
+                return;
+           &n