My favorites
▼
|
Sign in
jmesa
Table Rendering API
Project Home
Downloads
Wiki
Issues
Source
Export to GitHub
READ-ONLY: This project has been
archived
. For more information see
this post
.
Search
Search within:
All issues
Open issues
New issues
Issues to verify
for
Advanced search
Search tips
Subscriptions
Issue
207
attachment: Filter_tab_support_.patch
(11.1 KB)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
Index: resources/jquery.jmesa.js
===================================================================
--- resources/jquery.jmesa.js (revision 2348)
+++ resources/jquery.jmesa.js Thu Jul 23 20:41:38 BST 2009
@@ -352,6 +352,10 @@
/************* Filter ***********/
var dynFilter = null;
+ var ieTabPending = false;
+ var ieShifTab = false;
+ var ieTimeoutInput = null;
+ var operaTimeoutPending = false;
var filterapi = {
createDynFilter : function(filter, id, property) {
@@ -360,6 +364,7 @@
}
dynFilter = new classes.DynFilter(filter, id, property);
+ ieTabPending = false;
var cell = $(filter);
var width = cell.width();
@@ -374,28 +379,58 @@
var input = $('#dynFilterInput');
input.val(originalValue);
+
+ if (operaTimeoutPending) {
+ // focus is lost in opera after creation
+ // probably due to default tab handling.
+ // try a delayed focus to solve the problem
+ ieTimeoutInput = input;
+ setTimeout("jQuery.jmesa.transferDynFocusTimeout();", 50);
+ operaTimeoutPending = false;
+ }
+ else {
- input.focus();
+ input.focus();
+ }
- $(input).keypress(function(event) {
- if (event.keyCode == 13) { /* Press the enter key. */
+ var updateFilter = function() {
- var changedValue = input.val();
+ var changedValue = input.val();
+ $.jmesa.addFilterToLimit(dynFilter.id, dynFilter.property, changedValue);
- cell.text('');
- cell.css('overflow', 'hidden');
- cell.text(changedValue);
+ cell.text('');
+ cell.css('overflow', 'hidden');
+ cell.text(changedValue);
- $.jmesa.addFilterToLimit(dynFilter.id, dynFilter.property, changedValue);
- $.jmesa.onInvokeAction(dynFilter.id, 'filter');
- dynFilter = null;
+ dynFilter = null;
+ };
+
+
+ $(input).keypress(function(event) {
+ if (event.keyCode == 13 || event.keyCode == 9) { // enter or tab key.
+ var dynId = dynFilter.id;
+ updateFilter();
+ if (event.keyCode == 13) { // enter
+ $.jmesa.onInvokeAction(dynId, 'filter');
- }
+ }
+ else { // tab
+ event.stopPropagation();
+ $.jmesa.transferDynFocus(cell, event.shiftKey);
+ }
+ }
});
$(input).blur(function() {
- var changedValue = input.val();
- cell.text('');
- cell.css('overflow', 'hidden');
- cell.text(changedValue);
- $.jmesa.addFilterToLimit(dynFilter.id, dynFilter.property, changedValue);
- dynFilter = null;
+ updateFilter();
+ if (ieTabPending) {
+ $.jmesa.transferDynFocus(cell, ieShifTab);
+ }
});
+
+ if ($.browser.msie) { // no tab keypress in IE: catch keydown for blur processing
+ $(input).keydown(function(event, data) {
+ if (event.keyCode == 9 && !event.altKey) { // tab key
+ ieTabPending = true;
+ ieShifTab = event.shiftKey;
+ }
+ });
+ }
},
createDroplistDynFilter : function(filter, id, property, options) {
if (dynFilter) {
@@ -405,7 +440,8 @@
dynFilter = new classes.DynFilter(filter, id, property);
if ($('#dynFilterDroplistDiv').size() > 0) {
- return; /* Filter already created. */
+ return;
+ /* Filter already created. */
}
/* The cell that represents the filter. */
@@ -415,7 +451,7 @@
var originalValue = cell.text();
var width = cell.width();
- /* Need to first get the size of the arrary. */
+ /* Need to first get the size of the array. */
var size = 1;
$.each(options, function() {
size++;
@@ -430,12 +466,17 @@
cell.parent().width(width);
/* Create the dynamic select input box. */
- cell.html('<div id="dynFilterDroplistDiv" style="top:17px">');
+ cell.html('<span id="dynFilterDroplistText">' + originalValue + '</span><div id="dynFilterDroplistDiv" style="top:17px"> </div>');
var html = '<select id="dynFilterDroplist" name="filter" size="' + size + '">';
+ if ($.trim(originalValue) == '') {
+ html += '<option selected="selected" value=""> </option>';
+ }
+ else {
- html += '<option value=""> </option>';
+ html += '<option value=""> </option>';
+ }
$.each(options, function(key, value) {
- if (key == originalValue) {
+ if (value == originalValue) {
html += '<option selected="selected" value="' + key + '">' + value + '</option>';
} else {
html += '<option value="' + key + '">' + value + '</option>';
@@ -452,34 +493,122 @@
/* Resize the column if it is not at least as wide as the column. */
var selectWidth = input.width();
if (selectWidth < width) {
- input.width(width + 5); /* always make the droplist overlap some */
+ input.width(width + 5);
+ /* always make the droplist overlap some */
}
+
+ if (ieTabPending || operaTimeoutPending) {
+ // focus is lost after creation always in opera and after a transition
+ // by delayed tab in ie, probably due to default tab handling.
+ // try a delayed focus to solve the problem
+ ieTimeoutInput = input;
+ setTimeout("jQuery.jmesa.transferDynFocusTimeout();", 50);
+ ieTabPending = false;
+ operaTimeoutPending = false;
+ }
+ else {
- input.focus();
+ input.focus();
+ }
var originalBackgroundColor = cell.css("backgroundColor");
cell.css({backgroundColor:div.css("backgroundColor")});
- /* Something was selected or the clicked off the droplist. */
- $(input).change(function() {
+ var updateFilter = function() {
var changedValue = $("#dynFilterDroplistDiv option:selected").val();
- var changedText = $("#dynFilterDroplistDiv option:selected").text();
- cell.text(changedText);
$.jmesa.addFilterToLimit(dynFilter.id, dynFilter.property, changedValue);
- $.jmesa.onInvokeAction(dynFilter.id, 'filter');
- dynFilter = null;
- });
- $(input).blur(function() {
var changedText = $("#dynFilterDroplistDiv option:selected").text();
cell.text(changedText);
$('#dynFilterDroplistDiv').remove();
cell.css({backgroundColor:originalBackgroundColor});
+
dynFilter = null;
+ };
+
+ $(input).keypress(function(event) {
+ if (event.keyCode == 13 || event.keyCode == 9) { // enter or tab key.
+ var dynId = dynFilter.id;
+ updateFilter();
+
+ if (event.keyCode == 13) {
+ $.jmesa.onInvokeAction(dynId, 'filter');
+ }
+ else {
+ event.stopPropagation();
+ $.jmesa.transferDynFocus(cell, event.shiftKey);
+ }
+ }
+ else if (event.keyCode == 27) { // escape key.
+ cell.text(originalValue);
+ $('#dynFilterDroplistDiv').remove();
+ cell.css({backgroundColor:originalBackgroundColor});
+ dynFilter = null;
+ $.jmesa.transferDynFocus(cell, event.shiftKey);
+ }
});
+
+ $(input).click(function(event) {
+ updateFilter();
+ // prevent the createDroplistDynFilter handler being called after this handler finishes
+ event.stopPropagation();
+ $.jmesa.transferDynFocus(cell, false);
+ });
+
+ $(input).blur(function() {
+ updateFilter();
+ if (ieTabPending) {
+ $.jmesa.transferDynFocus(cell, ieShifTab);
- }
+ }
+ });
+
+ if ($.browser.msie) { // no tab keypress in IE: catch keydown for blur processing
+ $(input).keydown(function(event, data) {
+ if (event.keyCode == 9 && !event.altKey) { // tab key
+ ieTabPending = true;
+ ieShifTab = event.shiftKey;
- }
+ }
+ });
+ }
+ },
+ transferDynFocusTimeout: function() {
+ if (ieTimeoutInput != null) {
+ $(ieTimeoutInput).focus();
+ ieTimeoutInput = null;
+ }
+ },
+ transferDynFocus: function(filterCell, shift) {
+ var tabCell = null;
+ var tdParent = filterCell.closest('td');
+ if (shift) {
+ tdParent.prevAll().children('div.dynFilter').filter(':first').each(function () {
+ tabCell = this;
+ });
+ if (tabCell == null) { // no previous, find last dynFilter
+ tdParent.nextAll().children('div.dynFilter').filter(':last').each(function () {
+ tabCell = this;
+ });
+ }
+ }
+ else {
+ tdParent.nextAll().children('div.dynFilter').filter(':first').each(function () {
+ tabCell = this;
+ });
+ if (tabCell == null) { // no next, find first dynFilter
+ tdParent.prevAll().children('div.dynFilter').filter(':last').each(function () {
+ tabCell = this;
+ });
+ }
+ }
+ if (tabCell != null) { // found
+ if ($.browser.opera) { // opera 'bug'
+ operaTimeoutPending = true;
+ }
+ $(tabCell).click();
+ }
+ }
+ };
/*********** Worksheet ***********/
Powered by
Google Project Hosting