X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/a8617d4c86993e80b020b847c9b0cdd2da8473c6..53593baa211863fbf66540cf1bcc36c8fb37257f:/js/autocomplete_part.js diff --git a/js/autocomplete_part.js b/js/autocomplete_part.js deleted file mode 100644 index 451f96406..000000000 --- a/js/autocomplete_part.js +++ /dev/null @@ -1,98 +0,0 @@ -$(function(){ - $('input.part_autocomplete').each(function(i,real){ - var $dummy = $('#' + real.id + '_name'); - var $type = $('#' + real.id + '_type'); - var $column = $('#' + real.id + '_column'); - $dummy.autocomplete({ - source: function(req, rsp) { - $.ajax({ - url: 'controller.pl?action=Part/ajax_autocomplete', - dataType: "json", - data: { - term: req.term, - type: function() { return $type.val() }, - column: function() { return $column.val()===undefined ? '' : $column.val() }, - current: function() { return real.value }, - obsolete: 0, - }, - success: function (data){ rsp(data) } - }); - }, - limit: 20, - delay: 50, - select: function(event, ui) { - $(real).val(ui.item.id); - $dummy.val(ui.item.name); - }, - }); - - var open_dialog = function(){ - open_jqm_window({ - url: 'controller.pl', - data: { - action: 'Part/part_picker_search', - real_id: function() { return $(real).attr('id') }, - 'filter.all:substr::ilike': function(){ return $dummy.val() }, - 'filter.type': function(){ return $type.val() }, - 'column': function(){ return $column.val() }, - 'real_id': function() { return real.id }, - }, - id: 'part_selection', - }); - return true; - }; - /* In case users are impatient and want to skip ahead: - * Capture key events and check if it's a unique hit. - * If it is, go ahead and assume it was selected. If it wasn't don't do - * anything so that autocompletion kicks in. For don't prevent - * propagation. It would be nice to catch it, but javascript is too stupid - * to fire a tab event later on, so we'd have to reimplement the "find - * next active element in tabindex order and focus it". - */ - $dummy.keypress(function(event){ - if (event.keyCode == 13 || event.keyCode == 9) { // enter or tab or tab - // if string is empty asume they want to delete - if ($dummy.val() == '') { - $(real).val(''); - return true; - } - $.ajax({ - url: 'controller.pl?action=Part/ajax_autocomplete', - dataType: "json", - data: { - term: $dummy.val(), - type: function() { return $type.val() }, - column: function() { return $column.val()===undefined ? '' : $column.val() }, - current: function() { return real.value }, - obsolete: 0, - }, - success: function (data){ - // only one - if (data.length == 1) { - $(real).val(data[0].id); - $dummy.val(data[0].description); - if (event.keyCode == 13) - $('#update_button').click(); - } else { - open_dialog(); - } - } - }); - if (event.keyCode == 13) - return false; - }; - }); - - $dummy.blur(function(){ - if ($dummy.val() == '') - $(real).val(''); - }); - - // now add a picker div after the original input - var pcont = $('').addClass('position-absolute'); - var picker = $('
'); - $dummy.after(pcont); - pcont.append(picker); - picker.addClass('icon16 CRM--Schnellsuche').click(open_dialog); - }); -})