Sha256: 905788ae95451dbb666c29f7a1ad5b33fbd0add1c7052b04f7074d6b3ae2b8d4

Contents?: true

Size: 822 Bytes

Versions: 4

Compression:

Stored size: 822 Bytes

Contents

SC.TextFieldSupport = {
  value: function(key, value) {
    if (value !== undefined) {
      this.$('input').val(value);
    } else {
      value = this.$('input').val();
    }

    return value;
  }.property().idempotent(),

  didCreateLayer: function() {
    SC.Event.add(this.$('input'), 'focus', this, this.focusIn);
    SC.Event.add(this.$('input'), 'blur', this, this.focusOut);
  },

  focusIn: function(event) {
    this.becomeFirstResponder();
    this.tryToPerform('focus', event);
  },

  focusOut: function(event) {
    this.resignFirstResponder();
    this.tryToPerform('blur', event);
  },

  keyUp: function(event) {
    if (event.keyCode === 13) {
      return this.tryToPerform('insertNewline', event);
    } else if (event.keyCode === 27) {
      return this.tryToPerform('cancel', event);
    }
  }
};

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
spade-0.0.1 sproutcore/frameworks/core_foundation/views/template/text_field_support.js
sproutcore-1.5.0.pre.5 lib/frameworks/sproutcore/frameworks/core_foundation/views/template/text_field_support.js
sproutcore-1.5.0.pre.4.1 lib/frameworks/sproutcore/frameworks/core_foundation/views/template/text_field_support.js
sproutcore-1.5.0.pre.4 lib/frameworks/sproutcore/frameworks/core_foundation/views/template/text_field_support.js