Sha256: fb07dae15445f5525d98aeec5e8c07f44c6578c864c96a29d2a34ae649c9b1f9

Contents?: true

Size: 1.38 KB

Versions: 7

Compression:

Stored size: 1.38 KB

Contents

/*
---
 
script: Input.js
 
description: Make it easy to use regular native input for the widget
 
license: Public domain (http://unlicense.org).
 
requires:
  - LSD.Trait
  - LSD.Mixin.Focusable

provides: 
  - LSD.Trait.Input
  
...
*/

LSD.Trait.Input = new Class({
  options: {
    input: {},
  },
  
  constructors: {
    input: function() {
      return {
        events: {
          self: {
            build: function() {
              this.getInput().inject(this.element);
            },
            focus: function() {
              this.document.activeElement = this;
              if (LSD.Mixin.Focusable) LSD.Mixin.Focusable.Propagation.focus(this);
            },
            blur: function() {
                if (this.document.activeElement == this) delete this.document.activeElement;
             //   if (LSD.Mixin.Focusable) LSD.Mixin.Focusable.Propagation.blur.delay(10, this, this);
            }
          },
          input: {
            focus: 'onFocus',
            blur: 'onBlur'
          },
        }
      }
    }
  },
  
  onFocus: function() {
    this.document.activeElement = this;
    this.focus();
  },
  
  getInput: Macro.getter('input', function() {
    var input = new Element('input', Object.append({'type': 'text'}, this.options.input));
    this.fireEvent('register', ['input', input]);
    return input;
  }),
  
  getValueInput: function() {
    return this.input;
  }
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
lsd_rails-0.1.6 Packages/lsd/Source/Trait/Input.js
lsd_rails-0.1.5 Packages/lsd/Source/Trait/Input.js
lsd_rails-0.1.4 Packages/lsd/Source/Trait/Input.js
lsd_rails-0.1.3 Packages/lsd/Source/Trait/Input.js
lsd_rails-0.1.2 Packages/lsd/Source/Trait/Input.js
lsd_rails-0.1.1 Packages/lsd/Source/Trait/Input.js
lsd_rails-0.1 Packages/lsd/Source/Trait/Input.js