67 lines
No EOL
2 KiB
JavaScript
67 lines
No EOL
2 KiB
JavaScript
/*
|
|
This file is part of Ext JS 3.4
|
|
|
|
Copyright (c) 2011-2013 Sencha Inc
|
|
|
|
Contact: http://www.sencha.com/contact
|
|
|
|
GNU General Public License Usage
|
|
This file may be used under the terms of the GNU General Public License version 3.0 as
|
|
published by the Free Software Foundation and appearing in the file LICENSE included in the
|
|
packaging of this file.
|
|
|
|
Please review the following information to ensure the GNU General Public License version 3.0
|
|
requirements will be met: http://www.gnu.org/copyleft/gpl.html.
|
|
|
|
If you are unsure which license is appropriate for your use, please contact the sales department
|
|
at http://www.sencha.com/contact.
|
|
|
|
Build date: 2013-04-03 15:07:25
|
|
*/
|
|
Ext.ns('Ext.ux.form');
|
|
|
|
Ext.ux.form.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
|
|
initComponent : function(){
|
|
Ext.ux.form.SearchField.superclass.initComponent.call(this);
|
|
this.on('specialkey', function(f, e){
|
|
if(e.getKey() == e.ENTER){
|
|
this.onTrigger2Click();
|
|
}
|
|
}, this);
|
|
},
|
|
|
|
validationEvent:false,
|
|
validateOnBlur:false,
|
|
trigger1Class:'x-form-clear-trigger',
|
|
trigger2Class:'x-form-search-trigger',
|
|
hideTrigger1:true,
|
|
width:180,
|
|
hasSearch : false,
|
|
paramName : 'query',
|
|
|
|
onTrigger1Click : function(){
|
|
if(this.hasSearch){
|
|
this.el.dom.value = '';
|
|
var o = {start: 0};
|
|
this.store.baseParams = this.store.baseParams || {};
|
|
this.store.baseParams[this.paramName] = '';
|
|
this.store.reload({params:o});
|
|
this.triggers[0].hide();
|
|
this.hasSearch = false;
|
|
}
|
|
},
|
|
|
|
onTrigger2Click : function(){
|
|
var v = this.getRawValue();
|
|
if(v.length < 1){
|
|
this.onTrigger1Click();
|
|
return;
|
|
}
|
|
var o = {start: 0};
|
|
this.store.baseParams = this.store.baseParams || {};
|
|
this.store.baseParams[this.paramName] = v;
|
|
this.store.reload({params:o});
|
|
this.hasSearch = true;
|
|
this.triggers[0].show();
|
|
}
|
|
}); |