Sha256: f21e929eacd8a99cacdf708283e05b6fd3cc8a0234414ba0aab056ae0062376f

Contents?: true

Size: 1.21 KB

Versions: 11

Compression:

Stored size: 1.21 KB

Contents

sc_require('views/template');

SC.Button = SC.TemplateView.extend({
  classNames: ['sc-button'],

  // Setting isActive to true will trigger the classBinding and add
  // 'is-active' to our layer's class names.
  mouseDown: function() {
    this.set('isActive', true);
    this._isMouseDown = YES;
  },

  mouseExited: function() {
    this.set('isActive', false);
  },

  mouseEntered: function() {
    if (this._isMouseDown) {
      this.set('isActive', true);
    }
  },

  rootResponder: function() {
    var pane = this.get('pane');
    return pane.get('rootResponder');
  }.property('pane').cacheable(),

  // Setting isActive to false will remove 'is-active' from our
  // layer's class names.
  mouseUp: function(event) {
    if (this.get('isActive')) {
      var action = this.get('action'),
          target = this.get('target') || null,
          rootResponder = this.get('rootResponder');

      if (action && rootResponder) {
        rootResponder.sendAction(action, target, this, this.get('pane'), null, this);
      }

      this.set('isActive', false);
    }

    this._isMouseDown = NO;
  },

  touchStart: function(touch) {
    this.mouseDown(touch);
  },

  touchEnd: function(touch) {
    this.mouseUp(touch);
  }
});

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.1 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0-java lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.rc.2-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.rc.2 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.rc.2-java lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.rc.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.rc.1 lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js
sproutcore-1.6.0.rc.1-java lib/frameworks/sproutcore/frameworks/core_foundation/controls/button.js