ExtJs4.0颜色控件



ExtJs4.0颜色控件

  1. /**
  2.  * @class Ext.app.ColorPicker
  3.  * @extends Ext.container.Container
  4.  * 定义颜色选取类
  5.  */
  6. Ext.define (‘Ext.app.ColorPicker’,
  7. {
  8.     extend: ’Ext.container.Container’,
  9.     alias: ’widget.smmcolorpicker’,
  10.     layout: ’hbox’,
  11.     initComponent:function()
  12.     {
  13.         var mefieldLabel = this.fieldLabel;
  14.         var mename = this.name;
  15.         var meheight = this.height;
  16.         var meid = this.id;
  17.         this.items =
  18.         [
  19.             {
  20.                 xtype: 'textfield',
  21.                 height: meheight,
  22.                 id:meid+'x',
  23.                 fieldLabel:mefieldLabel,
  24.                 name: mename,
  25.                 flex: 1,
  26.                 listeners:
  27.                 {
  28.                     change:function(me, newValue, oldValue)
  29.                     {
  30.                         me.bodyEl.down('input').setStyle('background-image', 'none');
  31.                         me.bodyEl.down('input').setStyle('background-color', newValue);
  32.                     }
  33.                 }
  34.             },
  35.             {
  36.                 xtype:'button',
  37.                 width:18,
  38.                 height: meheight,
  39.                 menu:
  40.                 {
  41.                     xtype:'colormenu',
  42.                     listeners:
  43.                     {
  44.                         select: function(picker, color)
  45.                         {
  46.                             var amclr = Ext.getCmp(meid+'x');
  47.                             amclr.setValue('#'+color);
  48.                         }
  49.                     }
  50.                 }
  51.             }
  52.         ];
  53.         Ext.app.ColorPicker.superclass.initComponent.call(this);
  54.     }
  55. });