Sha256: 7aad260f6dd7cff8fa31375eb96a92bdce6f4c5deab7ca2691955e106411bc9c

Contents?: true

Size: 1.42 KB

Versions: 7

Compression:

Stored size: 1.42 KB

Contents

// ==========================================================================
// Project:   SproutCore - JavaScript Application Framework
// Copyright: ©2006-2011 Strobe Inc. and contributors.
//            Portions ©2008-2011 Apple Inc. All rights reserved.
// License:   Licensed under MIT license (see license.js)
// ==========================================================================


SC.BaseTheme.imageButtonRenderDelegate = SC.RenderDelegate.create({
  className: 'image-button',

  render: function(dataSource, context) {
    var image = dataSource.get('image'),
        toolTip = dataSource.get('toolTip');

    // render controlSize
    this.addSizeClassName(dataSource, context);

    context.addClass('no-min-width');

    if (toolTip) {
      context.attr('title', toolTip);
      context.attr('alt', toolTip);
    }

    if (image) {
      context.push("<div class='img "+image+"'></div>");
    } else {
      context.push("<div class='img'></div>");
    }
  },

  update: function(dataSource, $) {
    var image, toolTip;

    this.updateSizeClassName(dataSource, $);

    if (dataSource.didChangeFor('imageButtonRenderDelegate', 'toolTip')) {
      toolTip = dataSource.get('toolTip');

      $.attr('title', toolTip);
      $.attr('alt', toolTip);
    }

    if (dataSource.didChangeFor('imageButtonRenderDelegate', 'image')) {
      image = dataSource.get('image');

      $.children()[0].className = 'img '+image;
    }
  }
});

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sproutcore-1.7.1.beta-java lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js
sproutcore-1.7.1.beta lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js
sproutcore-1.6.0.1-java lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js
sproutcore-1.6.0.1 lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js
sproutcore-1.6.0.1-x86-mingw32 lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js
sproutcore-1.6.0 lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js
sproutcore-1.6.0-java lib/frameworks/sproutcore/frameworks/desktop/render_delegates/image_button.js