Skip to content
Closed
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d0d24a1
Button: Inital commit of button refactor
arschmitz Jan 22, 2014
cf6e119
Checkboxradio: inital commit of new widget
arschmitz Feb 5, 2014
747635a
Checkboxradio: add test suit
arschmitz Feb 10, 2014
b408636
squash: updating tests
arschmitz Mar 7, 2014
d344b50
Button: changing option text to showLabel to avoid confusion
arschmitz Mar 7, 2014
d903e1a
Checkboxradio: use control.labels if defined
arschmitz Mar 7, 2014
6591ad1
Checkboxradio: move inital dom manipulation into its own method
arschmitz Mar 12, 2014
b782bfc
squash: code cleanup
arschmitz Mar 12, 2014
19c6b9e
checkboxradio: fix label selection if control.labels length is 0
arschmitz Mar 12, 2014
3223c29
Button: fixing missed instances of text option switching to showLabel
arschmitz Mar 12, 2014
01c54ec
Button: Fixing issues found by jscs
arschmitz Mar 28, 2014
fe00326
Dialog: Updating dialog and tests for new button API
arschmitz Mar 28, 2014
35564dd
Button: simplifying _create by setting label option first
arschmitz Mar 28, 2014
0d71cbf
Button: updates based on pr review
arschmitz Apr 2, 2014
995a855
Controlgroup: initial css prototyping and updating of selectmenu
arschmitz Apr 9, 2014
f55d4ce
Button: updates to demos based on pr review
arschmitz Apr 23, 2014
1e225e7
Button: updating tests
arschmitz Apr 30, 2014
d566fec
Button: Update css based on pr comments
arschmitz Apr 30, 2014
1ccec99
Button: remove duplicate rule from core.css
arschmitz Apr 30, 2014
8d64f1f
Button: Updates based on pr comments
arschmitz May 14, 2014
21afafd
Checkboxradio: updates based on pr review
arschmitz May 15, 2014
661ce0e
Checkboxradio: updates based on pr review
arschmitz May 21, 2014
d3b0f85
Checkboxradio: add option and method tests
arschmitz Jul 16, 2014
0fead84
Revert "Controlgroup: initial css prototyping and updating of select"
arschmitz Jul 16, 2014
9b7dbc6
Button: comment out test thats failing only in phantom
arschmitz Jul 16, 2014
234aeb1
Checkboxradio: add visual focus outline to checkbox and radio buttons
arschmitz Jul 24, 2014
06455ac
Build: Remove .DS_Store file
arschmitz Aug 13, 2014
320e2ec
Checkboxradio: remove ui-state-active in destroy
arschmitz Aug 13, 2014
c485bc5
Checkboxradio: Properly label unit test link for checkboxradio
arschmitz Aug 13, 2014
4ab74f1
Button: updated options in visual tests and removed checkbox and
arschmitz Aug 13, 2014
bad64ec
Button: Fix vertical position of icon when font size has been changed
arschmitz Aug 13, 2014
d95139e
Checkboxradio: fix csslint issues
arschmitz Aug 13, 2014
b865d59
Button: fix incorrect option name in demo
arschmitz Aug 13, 2014
baf108e
Checkboxradio: do not update label in demo if it is an empty string
arschmitz Aug 13, 2014
841abaf
Checkboxradio: add missing classes in destroy
arschmitz Aug 13, 2014
48c7481
Theme: tone down visual focus outline
arschmitz Aug 13, 2014
dae9466
Button: fix htmllint issues
arschmitz Aug 13, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Checkboxradio: move inital dom manipulation into its own method
Allows easy extension for mobiles enhanced option
  • Loading branch information
arschmitz committed Mar 28, 2014
commit 6591ad1f9f326ebbab4708412bd05fbfd4c8a4de
51 changes: 27 additions & 24 deletions ui/checkboxradio.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,22 @@ var baseClasses = "ui-button ui-widget ui-corner-all",
}, 1 );
},
radioGroup = function( radio ) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is double-indented in this function.

var name = radio.name,
form = radio.form,
radios = $( [] );
if ( name ) {
name = name.replace( /'/g, "\\'" );
if ( form ) {
radios = $( form ).find( "[name='" + name + "']" );
} else {
radios = $( "[name='" + name + "']", radio.ownerDocument )
.filter(function() {
return !this.form;
});
}
}
return radios;
};
var name = radio.name,
form = radio.form,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should either use .closest( form ) or the form property, not mixing both.

radios = $( [] );
if ( name ) {
name = name.replace( /'/g, "\\'" );
if ( form ) {
radios = $( form ).find( "[name='" + name + "']" );
} else {
radios = $( "[name='" + name + "']", radio.ownerDocument )
.filter(function() {
return !this.form;
});
}
}
return radios;
};

$.widget( "ui.checkboxradio", {
version: "@VERSION",
Expand Down Expand Up @@ -78,6 +78,16 @@ $.widget( "ui.checkboxradio", {

this._getLabel();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's reorder the method definitions based on how they're used here.


this._enhance();

this._on({
"change" : "_toggleClasses",
"focus": "_handleFocus",
"blur": "_handleBlur"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This two are so trivial, might as well define the functions here directly. The method names aren't great anyway.

});
},

enhance: function() {
this.element.addClass( "ui-helper-hidden-accessible ui-checkboxradio" );

this.label.addClass( baseClasses + " ui-" + this.type + "-label" );
Expand All @@ -98,12 +108,6 @@ $.widget( "ui.checkboxradio", {
if ( this.options.label ){
this.label.html( this.options.label );
}

this._on({
"change" : "_toggleClasses",
"focus": "_handleFocus",
"blur": "_handleBlur"
});
},

widget: function() {
Expand All @@ -124,7 +128,6 @@ $.widget( "ui.checkboxradio", {
// Check control.labels first
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's labels? A search for "html5 labels" didn't yield anything useful.

if ( this.element[ 0 ].labels !== undefined ){
this.label = $( this.element[ 0 ].labels );
console.log( this.element[ 0 ].labels );
} else {

// we don't search against the document in case the element
Expand Down Expand Up @@ -154,7 +157,7 @@ $.widget( "ui.checkboxradio", {
radioGroup( this.element[0] )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this even defined outside the widget? Could just make this an instance method _radioGroup.

.not( this.element )
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent this and the following lines.

.map(function() {
return $( this ).checkboxradio( "widget" )[ 0 ];
return $( this ).checkboxradio( "widget" )[ 0 ];
})
.removeClass( "ui-state-active ui-radio-checked" );
}
Expand Down