commit bedb957949b0fa8f84e92bb3b1a8f86e045799d0
parent cf50997a12c2d11950533835831d727121ecfab9
Author: Felicitus <felicitus@felicitus.org>
Date: Tue, 10 Jul 2012 03:48:34 +0200
Refactored method names to make them self-explanatory
Diffstat:
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/src/frontend/js/Ext.ux/SearchField.js b/src/frontend/js/Ext.ux/SearchField.js
@@ -14,11 +14,19 @@ Ext.define('Ext.ux.form.SearchField', {
this.callParent(arguments);
this.on('specialkey', function(f, e){
if(e.getKey() == e.ENTER){
- this.onTrigger2Click();
+ this.startSearch();
}
}, this);
},
-
+ setValue: function (value) {
+ this.callParent(arguments);
+
+ /*if (value.length < 1) {
+ this.resetSearch();
+ } else {
+ this.startSearch();
+ }*/
+ },
afterRender: function(){
this.callParent();
this.triggerEl.item(0).setDisplayed('none');
@@ -26,7 +34,15 @@ Ext.define('Ext.ux.form.SearchField', {
},
onTrigger1Click : function(){
- var me = this,
+ this.resetSearch();
+ },
+
+ onTrigger2Click : function(){
+ this.startSearch();
+ },
+
+ resetSearch: function () {
+ var me = this,
store = me.store,
proxy = store.getProxy(),
val;
@@ -41,16 +57,15 @@ Ext.define('Ext.ux.form.SearchField', {
me.triggerEl.item(0).setDisplayed('none');
me.doComponentLayout();
}
- },
-
- onTrigger2Click : function(){
- var me = this,
+ },
+ startSearch: function () {
+ var me = this,
store = me.store,
proxy = store.getProxy(),
value = me.getValue();
if (value.length < 1) {
- me.onTrigger1Click();
+ me.resetSearch();
return;
}
proxy.extraParams[me.paramName] = value;
@@ -60,5 +75,5 @@ Ext.define('Ext.ux.form.SearchField', {
me.hasSearch = true;
me.triggerEl.item(0).setDisplayed('block');
me.doComponentLayout();
- }
+ }
});
\ No newline at end of file