Revision b3c6dbe1
Von Bernd Bleßmann vor mehr als 8 Jahren hinzugefügt
js/autocomplete_chart.js | ||
---|---|---|
164 | 164 |
$('#chart_selection').dialog('close'); |
165 | 165 |
}; |
166 | 166 |
|
167 |
function handle_changed_text(callbacks) { |
|
168 |
$.ajax({ |
|
169 |
url: 'controller.pl?action=Chart/ajax_autocomplete', |
|
170 |
dataType: "json", |
|
171 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), |
|
172 |
success: function (data) { |
|
173 |
if (data.length == 1) { |
|
174 |
set_item(data[0]); |
|
175 |
if (callbacks && callbacks.match_one) callbacks.match_one(data[0]); |
|
176 |
} else if (data.length > 1) { |
|
177 |
state = STATES.UNDEFINED; |
|
178 |
if (callbacks && callbacks.match_many) callbacks.match_many(data); |
|
179 |
} else { |
|
180 |
state = STATES.UNDEFINED; |
|
181 |
if (callbacks &&callbacks.match_none) callbacks.match_none(); |
|
182 |
} |
|
183 |
annotate_state(); |
|
184 |
} |
|
185 |
}); |
|
186 |
}; |
|
187 |
|
|
167 | 188 |
$dummy.autocomplete({ |
168 | 189 |
source: function(req, rsp) { |
169 | 190 |
$.ajax($.extend(o, { |
... | ... | |
199 | 220 |
} else if (state == STATES.PICKED) { |
200 | 221 |
return true; |
201 | 222 |
} |
202 |
if (event.which == KEY.TAB) event.preventDefault(); |
|
203 |
$.ajax({ |
|
204 |
url: 'controller.pl?action=Chart/ajax_autocomplete', |
|
205 |
dataType: "json", |
|
206 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), |
|
207 |
success: function (data) { |
|
208 |
if (data.length == 1) { |
|
209 |
set_item(data[0]); |
|
210 |
if (event.which == KEY.ENTER) |
|
211 |
$('#update_button').click(); |
|
212 |
} else if (data.length > 1) { |
|
213 |
if (event.which == KEY.ENTER) |
|
214 |
open_dialog(); |
|
215 |
} else { |
|
216 |
} |
|
217 |
annotate_state(); |
|
218 |
} |
|
219 |
}); |
|
220 |
if (event.which == KEY.ENTER) |
|
223 |
if (event.which == KEY.TAB) { |
|
224 |
event.preventDefault(); |
|
225 |
handle_changed_text(); |
|
226 |
} |
|
227 |
if (event.which == KEY.ENTER) { |
|
228 |
handle_changed_text({ |
|
229 |
match_one: function(){$('#update_button').click();}, |
|
230 |
match_many: function(){open_dialog();} |
|
231 |
}); |
|
221 | 232 |
return false; |
233 |
} |
|
222 | 234 |
} else { |
223 | 235 |
state = STATES.UNDEFINED; |
224 | 236 |
} |
225 | 237 |
}); |
226 | 238 |
|
239 |
$dummy.on('paste', function(){ |
|
240 |
setTimeout(function() { |
|
241 |
handle_changed_text(); |
|
242 |
}, 1); |
|
243 |
}); |
|
244 |
|
|
227 | 245 |
$dummy.blur(function(){ |
228 | 246 |
window.clearTimeout(timer); |
229 | 247 |
timer = window.setTimeout(annotate_state, 100); |
Auch abrufbar als: Unified diff
ChartPicker: Auch auf Paste-Events reagieren.
Siehe auch commit 2cf7a2cd78d812d917fb4c92f8ee57f6a32f3685
(PartPicker: Auch auf Paste-Events reagieren.)