12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- Ext.ns("Ext.ux");
- Ext.ux.ClearableCombo = Ext.extend(Ext.form.ComboBox, {
- trigger1Class: 'x-form-clear-trigger',
- trigger2Class: 'x-form-search-trigger',
- initComponent: function(){
- Ext.ux.ClearableCombo.superclass.initComponent.call(this);
- this.triggerConfig = {
- tag:'span', cls:'x-form-twin-triggers', cn:[
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},
- {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}
- ]};
- },
- clearValue : function(){
- if(this.hiddenField){
- this.hiddenField.value = '';
- }
- this.setRawValue('');
- this.lastSelectionText = '';
- this.applyEmptyText();
- this.value = '';
- this.fireEvent('select', this, null, 0);
- },
- getTrigger: function(index){
- return this.triggers[index];
- },
- initTrigger: function(){
- var ts = this.trigger.select('.x-form-trigger', true);
- this.wrap.setStyle('overflow', 'hidden');
- var triggerField = this;
- ts.each(function(t, all, index){
- t.hide = function(){
- var w = triggerField.wrap.getWidth();
- this.dom.style.display = 'none';
- triggerField.el.setWidth(w-triggerField.trigger.getWidth());
- };
- t.show = function(){
- var w = triggerField.wrap.getWidth();
- this.dom.style.display = '';
- triggerField.el.setWidth(w-triggerField.trigger.getWidth());
- };
- var triggerIndex = 'Trigger'+(index+1);
- if(this['hide'+triggerIndex]){
- t.dom.style.display = 'none';
- }
- t.on("click", this['on'+triggerIndex+'Click'], this, {preventDefault:true});
- t.addClassOnOver('x-form-trigger-over');
- t.addClassOnClick('x-form-trigger-click');
- }, this);
- this.triggers = ts.elements;
- },
- onTrigger1Click: function() {
- this.clearValue();
- },
- onTrigger2Click: function() {
- this.onTriggerClick();
- }
- });
|