zoukankan      html  css  js  c++  java
  • EXT自定义颜色表单域控件

    Ext.ns('Ext.ux');
    Ext.ux.ColorField = Ext.extend(Ext.form.TriggerField,{
    	  editable:false,
    	  triggerClass : 'x-form-arrow-trigger',
    	  initComponent : function(){
    	        Ext.ux.ColorField.superclass.initComponent.call(this);
    	        this.addEvents(
    	            'select'
    	        );
    	  },
    	  initEvents: function() {
    	        Ext.ux.ColorField.superclass.initEvents.call(this);
    	        this.keyNav = new Ext.KeyNav(this.el, {
    	            "down": function(e) {
    	                this.onTriggerClick();
    	            },
    	            scope: this,
    	            forceKeyDown: true
    	        });
    	  },
    		onDestroy : function(){
    			 Ext.destroy(this.menu, this.keyNav);
    			 Ext.ux.ColorField.superclass.onDestroy.call(this);
    		},
    		validateBlur : function(){
    			return !this.menu || !this.menu.isVisible();
    		},
    	  onTriggerClick : function(){
            if(this.disabled){
                return;
            }
            if(this.menu == null){
    			this.menu = new Ext.menu.ColorMenu();
    			if(this.getValue()) 
    				this.menu.palette.value=this.getValue();
              
            }else{
    			if(this.getValue())
    				this.menu.palette.select(this.getValue());
    			else if(this.menu.palette.value){
    				 this.menu.palette.el.child('a.color-'+this.menu.palette.value).removeClass('x-color-palette-sel');
    			}
    		}
    		
            this.onFocus();
            this.menu.show(this.el, "tl-bl?");//tl-bl?
            this.menuEvents('on');
        },
    
        //private
        menuEvents: function(method){
            this.menu[method]('select', this.onSelect, this);
            this.menu[method]('hide', this.onMenuHide, this);
            this.menu[method]('show', this.onFocus, this);
        },
    
        onSelect: function(m, color){
            this.setValue(color);
            this.fireEvent('select', this, color);
            this.menu.hide();
        },
        onMenuHide: function(){
            this.focus(false, 60);
            this.menuEvents('un');
        }
    });
    Ext.reg('colorfield', Ext.ux.ColorField);
    

      

  • 相关阅读:
    python2
    python1
    jmeter基础使用
    LoadRuuner资源监控
    UI自动化
    MYSQL增删改查添加外键
    DW网页代码笔记
    Linux常用命令(常用)
    Linux常用命令大全(全全全!!!)
    第十二章 : shell 环境
  • 原文地址:https://www.cnblogs.com/tazi/p/2575594.html
Copyright © 2011-2022 走看看