Installer/Updater
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.5 KiB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /*!
  2. * Ext JS Library 3.3.1
  3. * Copyright(c) 2006-2010 Sencha Inc.
  4. * licensing@sencha.com
  5. * http://www.sencha.com/license
  6. */
  7. Ext.ns('Ext.ux.form');
  8. Ext.ux.form.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
  9. initComponent : function(){
  10. Ext.ux.form.SearchField.superclass.initComponent.call(this);
  11. this.on('specialkey', function(f, e){
  12. if(e.getKey() == e.ENTER){
  13. this.onTrigger2Click();
  14. }
  15. }, this);
  16. },
  17. validationEvent:false,
  18. validateOnBlur:false,
  19. trigger1Class:'x-form-clear-trigger',
  20. trigger2Class:'x-form-search-trigger',
  21. hideTrigger1:true,
  22. width:180,
  23. hasSearch : false,
  24. paramName : 'query',
  25. onTrigger1Click : function(){
  26. if(this.hasSearch){
  27. this.el.dom.value = '';
  28. var o = {start: 0};
  29. this.store.baseParams = this.store.baseParams || {};
  30. this.store.baseParams[this.paramName] = '';
  31. this.store.reload({params:o});
  32. this.triggers[0].hide();
  33. this.hasSearch = false;
  34. }
  35. },
  36. onTrigger2Click : function(){
  37. var v = this.getRawValue();
  38. if(v.length < 1){
  39. this.onTrigger1Click();
  40. return;
  41. }
  42. var o = {start: 0};
  43. this.store.baseParams = this.store.baseParams || {};
  44. this.store.baseParams[this.paramName] = v;
  45. this.store.reload({params:o});
  46. this.hasSearch = true;
  47. this.triggers[0].show();
  48. }
  49. });