Skip to content

Commit

Permalink
Labels now call focus action. Add supports for wrapper labels without…
Browse files Browse the repository at this point in the history
… for attribute
  • Loading branch information
Inviz committed Jun 7, 2011
1 parent e13b6cb commit 1b07b7f
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions Source/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ LSD.Widget.Label = new Class({
has: {
one: {
control: {
selector: ':form-associated',
expectation: function() {
var id = this.attributes['for'];
if (id) return {id: id, combinator: ' ', tag: '*'};
},
target: 'root',
target: function() {
return this.attributes['for'] ? 'root' : null;
},
collection: 'labels',
states: {
get: {
Expand All @@ -38,20 +41,20 @@ LSD.Widget.Label = new Class({
}
}
},
pseudos: Array.fast('form-associated', 'clickable'),
states: Array.fast('invalid')
},

click: function(event){
this.focusControl();
if (this.control && this.control.click) this.control.click();
return this.parent.apply(this, arguments);
},

focusControl: function(event) {
if (this.control && this.control.focus) {
this.control.focus();
if (event) event.preventDefault();
pseudos: Array.fast('form-associated', 'clickable', 'command'),
states: Array.fast('invalid'),
chain: {
focusControl: function() {
if (this.control) return {
target: this.control,
action: 'focus'
};
}
},
events: {
self: {
click: 'focusControl'
}
}
}
});

0 comments on commit 1b07b7f

Please sign in to comment.