3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">Ext.ns('Ext.ux.menu');
\r
10 <div id="cls-Ext.ux.menu.RangeMenu"></div>/**
\r
11 * @class Ext.ux.menu.RangeMenu
\r
12 * @extends Ext.menu.Menu
\r
13 * Custom implementation of Ext.menu.Menu that has preconfigured
\r
14 * items for gt, lt, eq.
\r
15 * <p><b><u>Example Usage:</u></b></p>
\r
20 Ext.ux.menu.RangeMenu = Ext.extend(Ext.menu.Menu, {
\r
22 constructor : function (config) {
\r
24 Ext.ux.menu.RangeMenu.superclass.constructor.call(this, config);
\r
27 <div id="event-Ext.ux.menu.RangeMenu-update"></div>/**
\r
29 * Fires when a filter configuration has changed
\r
30 * @param {Ext.ux.grid.filter.Filter} this The filter object.
\r
35 this.updateTask = new Ext.util.DelayedTask(this.fireUpdate, this);
\r
37 var i, len, item, cfg, Cls;
\r
39 for (i = 0, len = this.menuItems.length; i < len; i++) {
\r
40 item = this.menuItems[i];
\r
44 itemId: 'range-' + item,
\r
45 enableKeyEvents: true,
\r
46 iconCls: this.iconCls[item] || 'no-icon',
\r
49 keyup: this.onInputKeyUp
\r
55 Ext.applyIf(this.fields[item] || {}, this.fieldCfg[item]),
\r
56 // configurable defaults
\r
59 Cls = cfg.fieldCls || this.fieldCls;
\r
60 item = this.fields[item] = new Cls(cfg);
\r
68 * called by this.updateTask
\r
70 fireUpdate : function () {
\r
71 this.fireEvent('update', this);
\r
74 <div id="method-Ext.ux.menu.RangeMenu-getValue"></div>/**
\r
75 * Get and return the value of the filter.
\r
76 * @return {String} The value of this filter
\r
78 getValue : function () {
\r
79 var result = {}, key, field;
\r
80 for (key in this.fields) {
\r
81 field = this.fields[key];
\r
82 if (field.isValid() && String(field.getValue()).length > 0) {
\r
83 result[key] = field.getValue();
\r
89 <div id="method-Ext.ux.menu.RangeMenu-setValue"></div>/**
\r
90 * Set the value of this menu and fires the 'update' event.
\r
91 * @param {Object} data The data to assign to this menu
\r
93 setValue : function (data) {
\r
95 for (key in this.fields) {
\r
96 this.fields[key].setValue(data[key] !== undefined ? data[key] : '');
\r
98 this.fireEvent('update', this);
\r
103 * Handler method called when there is a keyup event on an input
\r
104 * item of this menu.
\r
106 onInputKeyUp : function (field, e) {
\r
107 var k = e.getKey();
\r
108 if (k == e.RETURN && field.isValid()) {
\r
114 if (field == this.fields.eq) {
\r
115 if (this.fields.gt) {
\r
116 this.fields.gt.setValue(null);
\r
118 if (this.fields.lt) {
\r
119 this.fields.lt.setValue(null);
\r
123 this.fields.eq.setValue(null);
\r
126 // restart the timer
\r
127 this.updateTask.delay(this.updateBuffer);
\r