Sha256: 8f95d5cb7aeb4c7eff526df87dd27b246d915746c6b3dedb7af96162d7afed55

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

/*
---
 
script: Label.js
 
description: A label for a form field
 
license: Public domain (http://unlicense.org).

authors: Yaroslaff Fedin
 
requires:
  - LSD/LSD.Widget

provides: 
  - LSD.Widget.Label
 
...
*/

LSD.Widget.Label = new Class({
  options: {
    tag: 'label',
    has: {
      one: {
        control: {
          collection: 'labels',
          states: {
            get: {
              invalid: 'invalid'
            }
          }
        }
      }
    },
    expects: {
      '[for]': function(widget, state) {
        widget[state ? 'addRelation' : 'removeRelation']('control', {
          expectation: function() {
            var id = this.attributes['for'];
            if (id) return {id: id, combinator: '&&', tag: '*'};
          }
        });
      }
    },
    pseudos: Array.object('form-associated', 'clickable', 'command'),
    states: Array.object('invalid'),
    chain: {
      focusControl: function() {
        if (this.control) return {
          target: this.control,
          action: this.control.pseudos.clickable ? 'submit' : 'focus'
        };
      }
    },
    events: {
      self: {
        click: 'focusControl'
      }
    }
  }
});

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/lsd-widgets/Source/Label.js
lsd_rails-0.1.5 Packages/lsd-widgets/Source/Label.js
lsd_rails-0.1.4 Packages/lsd-widgets/Source/Label.js
lsd_rails-0.1.3 Packages/lsd-widgets/Source/Label.js