commit 9cf671168d1af51f6084a362175d527ad0cd7954
parent bae78a0c8f9191122e1f783795c737319540f22f
Author: Felicitus <felicitus@felicitus.org>
Date: Tue, 10 Jul 2012 06:17:55 +0200
Added some documentation and fixed the ugly space
Diffstat:
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/src/frontend/js/Ext.ux/SearchField.js b/src/frontend/js/Ext.ux/SearchField.js
@@ -1,15 +1,32 @@
+/**
+ * Defines a search field, which automatically hooks into the passed store.
+ *
+ * The "clear" trigger is shown only when text is entered.
+ */
Ext.define('Ext.ux.form.SearchField', {
extend: 'Ext.form.field.Trigger',
-
alias: 'widget.searchfield',
-
+
+ /**
+ * Define the clear trigger
+ */
trigger1Cls: Ext.baseCSSPrefix + 'form-clear-trigger',
+ /**
+ * Define the clear trigger
+ */
trigger2Cls: Ext.baseCSSPrefix + 'form-search-trigger',
hasSearch : false,
+
+ /**
+ * Defines the parameter name which is being passed to the store's proxy.
+ */
paramName : 'query',
+ /**
+ * Initializes the component. Binds the enter key to startSearch.
+ */
initComponent: function(){
this.callParent(arguments);
this.on('specialkey', function(f, e){
@@ -18,29 +35,30 @@ Ext.define('Ext.ux.form.SearchField', {
}
}, this);
},
- setValue: function (value) {
- this.callParent(arguments);
-
- /*if (value.length < 1) {
- this.resetSearch();
- } else {
- this.startSearch();
- }*/
- },
+ /**
+ * Hides the "clear" trigger as soon as the component is rendered.
+ */
afterRender: function(){
this.callParent();
- this.triggerEl.item(0).setDisplayed('none');
+ this.triggerCell.item(0).setDisplayed('none');
this.doComponentLayout();
},
-
+ /**
+ * Handler for the "reset search" trigger
+ */
onTrigger1Click : function(){
this.resetSearch();
},
-
+ /**
+ * Handler for the "start search" trigger
+ */
onTrigger2Click : function(){
this.startSearch();
},
+ /**
+ * Resets the search field to empty and re-triggers the store to load the matching records.
+ */
resetSearch: function () {
var me = this,
store = me.store,
@@ -54,10 +72,13 @@ Ext.define('Ext.ux.form.SearchField', {
store.load({ start: 0 });
me.hasSearch = false;
- me.triggerEl.item(0).setDisplayed('none');
+ me.triggerCell.item(0).setDisplayed('none');
me.doComponentLayout();
}
},
+ /**
+ * Starts the search with the entered value.
+ */
startSearch: function () {
var me = this,
store = me.store,
@@ -73,7 +94,7 @@ Ext.define('Ext.ux.form.SearchField', {
store.load({ start: 0 });
me.hasSearch = true;
- me.triggerEl.item(0).setDisplayed('block');
+ me.triggerCell.item(0).setDisplayed('block');
me.doComponentLayout();
}
});
\ No newline at end of file