r3025 committed - - no more corners option...
Revision: 3025
Author: malk0.phpgtk
Date: Mon Aug 3 12:34:47 2009
Log: - no more corners option
- remove isActive getter ( double use with active option/property)
http://code.google.com/p/jquery-ui/source/detail?r=3025
Modified:
/branches/labs/button/demo.html
/branches/labs/button/ui.button.js
/branches/labs/button/ui.buttonset.js
=======================================
--- /branches/labs/button/demo.html Thu Jul 23 17:41:49 2009
+++ /branches/labs/button/demo.html Mon Aug 3 12:34:47 2009
@@ -67,13 +67,13 @@
$('.ui-button-toggle:gt(19)').click(function(){
var label = $(this).find('.ui-button-label');
if( label.html().match(/\s+o[fn]f?$/) )
-
label.html(label.html().replace(/\s+o[fn]f?$/,$(this).button('isActive')?'
on':' off'));
+
label.html(label.html().replace(/\s+o[fn]f?$/,$(this).button('option','active')?'
on':' off'));
else
- label.append($(this).button('isActive')?' on':' off');
+ label.append($(this).button('option','active')?' on':' off');
})
-
$('#toggleUnable').click(function(){$('#unable').button('option','disabled',$(this).button('isActive')?true:false);});
+
$('#toggleUnable').click(function(){$('#unable').button('option','disabled',$(this).button('option','active')?true:false);});
$('#defaultStateToggler').click(function(){
-
$(this).prev('.ui-button').button('option','overrideDefaultState',$(this).button('isActive')?'':false);
+
$(this).prev('.ui-button').button('option','overrideDefaultState',$(this).button('option','active')?'':false);
});
});
</script>
@@ -133,10 +133,15 @@
Or switch theme: <div id="switcher" style="display:inline-block;"></div>
</div>
<h3>Using A element</h3>
-
<a href="javascript:" class="ui-button">standard button starting with no
icon</a>
<a href="javascript:" class="ui-button ui-button-check">standard
button</a>
<a href="javascript:" class="ui-button ui-button-info toggle">toggle
button</a>
+
+ <!--h3>Using INPUT element</h3>
+ <input class="ui-button" value="standard button starting with no icon"
type="button"/>
+ <input class="ui-button ui-button-check" value="standard button"
type="submit" />
+ <label for="testCheck">CheckBox</label><input class="ui-button
ui-button-info" value="toggle button" type="checkbox" id="testCheck"
checked="checked"/-->
+
<h3>Using SPAN element</h3>
<span class="ui-button ui-button-wrench">standard button</span>
<span class="ui-button ui-button-flag toggle"
id="defaultStateToggler">toggle previous button defaultState class</span>
=======================================
--- /branches/labs/button/ui.button.js Thu Jul 23 17:43:10 2009
+++ /branches/labs/button/ui.button.js Mon Aug 3 12:34:47 2009
@@ -14,6 +14,7 @@
// base ui-button plugin
$.widget("ui.button",$.extend({},$.ui.classnameoptions,{
_originalClass: '',
+ _originalElement:null,
_elmt_icon:null,
_elmt_iconContainer:null,
@@ -22,14 +23,13 @@
_iconBeforeLabel:true,
_buttonset:null,
- _cornersValue:'',
_orientationValue:'',
_sizeValue:'',
-
_cbToggle:null,
_init:function(){
var self = this;
+
//-- should think about aborting or not init when ui-button-none,
ui-buttonset are used.
if( this.element.attr('class').match(/(?:^|\s+)ui-button(set|-none(\s|
$))/) ){
return $.widget.prototype.destroy.apply(this, arguments);
@@ -59,7 +59,7 @@
}
// apply some settings
-
self._applyOpts(['size','orientation','icon','corners','overrideDefaultState'])
+ self._applyOpts(['size','orientation','icon','overrideDefaultState'])
._applyOpts(['buttonMode','active','label'],true);
if( null!==self.options.disabled ){
@@ -67,7 +67,6 @@
}else if( self.element.attr('disabled') ){
self._setData('disabled',true);
}
-
if(! $.support.style){
this.element.addClass($.ui.button.classes.blockFix);
@@ -82,6 +81,9 @@
}
}
}
+ if(! self.element.attr('class').match(/ui-corner-[a-z]+/) ){
+ self.element.addClass('ui-corner-all');
+ }
self._bindCommonEvents();
return this;
},
@@ -207,10 +209,6 @@
this._setIcon();
return res;
break;
- case 'corners':
- self._cornersValue = value=='auto'?'all':value;
- self._rmExpClass('ui-corner-*','ui-corner-'+self._cornersValue);
- break;
case 'label': // @todo should think of a way to revert to original
label if changed
if( null!==value){
if( ''===value){
@@ -278,6 +276,7 @@
},
importButtonSetSettings:function(buttonSet){
var self=this;
+ self._buttonset = buttonSet.element;
var buttonSetSize = buttonSet._getData('size');
var buttonSetOrientation = buttonSet._getData('orientation');
if( self._getData('size')==='auto' && buttonSetSize !== 'auto'){
@@ -289,31 +288,26 @@
self._setData('orientation',buttonSetOrientation);
self.options.orientation=orientationOption;
}
-
- if( 'auto' == self._getData('corners')){
- var isOnlyChild = self.element.is(':only-child');
- if( self.element.is(':first-child') && ! isOnlyChild ){
- self._setData('corners','left');
- }else if(self.element.is(':last-child') && ! isOnlyChild ){
- self._setData('corners','right');
- }else{
- self._setData('corners',isOnlyChild?'all':'none');
- }
- self.options.corners='auto';
+ var isOnlyChild = self.element.is(':only-child');
+ if( self.element.is(':first-child') && ! isOnlyChild ){
+ self._rmExpClass('ui-corner-*','ui-corner-left');
+ }else if(self.element.is(':last-child') && ! isOnlyChild ){
+ self._rmExpClass('ui-corner-*','ui-corner-right');
+ }else{
+
self._rmExpClass('ui-corner-*','ui-corner-'+(isOnlyChild?'all':'none'));
}
- },
-
- //--- getter ---///
- isActive:function(){
- return this._getData('active');
},
//--- public methods ---//
destroy: function(){
- this.element.unbind('.uibutton').attr('class',this._originalClass);
- this._elmt_iconContainer.remove();
- this._elmt_label.contents().insertAfter(this._elmt_label)
- this._elmt_label.remove();
+ if( this._originalElement ){
+ this.element.replaceWith(this._originalElement);
+ }else{
+ this.element.unbind('.uibutton').attr('class',this._originalClass);
+ this._elmt_iconContainer.remove();
+ this._elmt_label.contents().insertAfter(this._elmt_label)
+ this._elmt_label.remove();
+ }
return $.widget.prototype.destroy.apply(this, arguments);
},
toggle: function(event){
@@ -325,11 +319,9 @@
$.extend($.ui.button, {
version: "@VERSION",
- getter:'isActive',
defaults:{
size:'auto',
orientation:'auto',
- corners:'auto',
icon:'',
label:null,
buttonMode:null,
=======================================
--- /branches/labs/button/ui.buttonset.js Mon Jun 22 16:11:22 2009
+++ /branches/labs/button/ui.buttonset.js Mon Aug 3 12:34:47 2009
@@ -22,7 +22,7 @@
var inlineOptions=self._readClassNameOpts({size:'|auto|tiny|small|
normal|big|huge',orientation:'|auto|[trbli]'})
self._mergeOpts(inlineOptions);
- self.element.addClass($.ui.buttonset.classes.base+'
ui-widget'+(self.element.is('[class*=ui-corner]')?'':' ui-corner-all'));
+ self.element.addClass($.ui.buttonset.classes.base+' ui-widget');
if( !$.support.style){
self.element.addClass($.ui.buttonset.classes.blockFix);
@@ -91,10 +91,10 @@
self.multiple = true;
}
self.buttonset = $('<div
class="'+$.ui.buttonset.classes.base+'"></div>');
- self.buttonset.buttonset(self.options);
self.element.hide();
self.element.after(self.buttonset);
self.refresh();
+ self.buttonset.buttonset(self.options);
},
refresh:function(){
var self = this;
@@ -109,9 +109,6 @@
optionIcon = optionIcon[1];
$('<a type="button"
class="ui-button-'+size+('auto'===orientation?'':'-'+orientation)+(optionIcon?'-'+optionIcon:'')+'
toggle'+(option.is(':selected')?' active':'')+'">'+label+'</a>')
.appendTo(self.buttonset)
- .button({
-
'corners':(i==0?'left':(i+1<self.element.attr('options').length?'none':'right'))
- })
.click(function(e){self._toggle(e,this,option)});
});
},