Revision 48e32abf
Von Bernd Bleßmann vor mehr als 8 Jahren hinzugefügt
js/autocomplete_project.js | ||
---|---|---|
116 | 116 |
timer = window.setTimeout(update_results, 100); |
117 | 117 |
} |
118 | 118 |
|
119 |
function handle_changed_text(callbacks) { |
|
120 |
$.ajax({ |
|
121 |
url: 'controller.pl?action=Project/ajax_autocomplete', |
|
122 |
dataType: "json", |
|
123 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), |
|
124 |
success: function (data) { |
|
125 |
if (data.length == 1) { |
|
126 |
set_item(data[0]); |
|
127 |
if (callbacks && callbacks.match_one) callbacks.match_one(data[0]); |
|
128 |
} else if (data.length > 1) { |
|
129 |
state = STATES.UNDEFINED; |
|
130 |
if (callbacks && callbacks.match_many) callbacks.match_many(data); |
|
131 |
} else { |
|
132 |
state = STATES.UNDEFINED; |
|
133 |
if (callbacks &&callbacks.match_none) callbacks.match_none(); |
|
134 |
} |
|
135 |
annotate_state(); |
|
136 |
} |
|
137 |
}); |
|
138 |
}; |
|
139 |
|
|
119 | 140 |
$dummy.autocomplete({ |
120 | 141 |
source: function(req, rsp) { |
121 | 142 |
$.ajax($.extend(o, { |
... | ... | |
150 | 171 |
} else if (state == STATES.PICKED) { |
151 | 172 |
return true; |
152 | 173 |
} |
153 |
if (event.which == KEY.TAB) event.preventDefault(); |
|
154 |
$.ajax({ |
|
155 |
url: 'controller.pl?action=Project/ajax_autocomplete', |
|
156 |
dataType: "json", |
|
157 |
data: $.extend( ajax_data($dummy.val()), { prefer_exact: 1 } ), |
|
158 |
success: function (data) { |
|
159 |
if (data.length == 1) { |
|
160 |
set_item(data[0]); |
|
161 |
if (event.which == KEY.ENTER) |
|
162 |
$('#update_button').click(); |
|
163 |
} else { |
|
164 |
} |
|
165 |
annotate_state(); |
|
166 |
} |
|
167 |
}); |
|
168 |
if (event.which == KEY.ENTER) |
|
174 |
if (event.which == KEY.TAB) { |
|
175 |
event.preventDefault(); |
|
176 |
handle_changed_text(); |
|
177 |
} |
|
178 |
if (event.which == KEY.ENTER) { |
|
179 |
handle_changed_text({ |
|
180 |
match_one: function(){$('#update_button').click();}, |
|
181 |
}); |
|
169 | 182 |
return false; |
183 |
} |
|
170 | 184 |
} else { |
171 | 185 |
state = STATES.UNDEFINED; |
172 | 186 |
} |
173 | 187 |
}); |
174 | 188 |
|
189 |
$dummy.on('paste', function(){ |
|
190 |
setTimeout(function() { |
|
191 |
handle_changed_text(); |
|
192 |
}, 1); |
|
193 |
}); |
|
194 |
|
|
175 | 195 |
$dummy.blur(function(){ |
176 | 196 |
window.clearTimeout(timer); |
177 | 197 |
timer = window.setTimeout(annotate_state, 100); |
Auch abrufbar als: Unified diff
ProjectPicker: Auch auf Paste-Events reagieren.
Siehe auch commit 2cf7a2cd78d812d917fb4c92f8ee57f6a32f3685
(PartPicker: Auch auf Paste-Events reagieren.)