+ picker.addClass('icon16 crm--search').click(open_dialog);
+
+ var pp = {
+ real: function() { return $real },
+ dummy: function() { return $dummy },
+ type: function() { return $type },
+ unit: function() { return $unit },
+ convertible_unit: function() { return $convertible_unit },
+ column: function() { return $column },
+ update_results: update_results,
+ result_timer: result_timer,
+ set_item: set_item,
+ reset: make_defined_state,
+ is_defined_state: function() { return state == STATES.PICKED },
+ init_results: function () {
+ $('div.part_picker_part').each(function(){
+ $(this).click(function(){
+ set_item({
+ id: $(this).children('input.part_picker_id').val(),
+ name: $(this).children('input.part_picker_description').val(),
+ unit: $(this).children('input.part_picker_unit').val(),
+ });
+ close_popup();
+ $dummy.focus();
+ return true;
+ });
+ });
+ $('#part_selection').keydown(function(e){
+ if (e.which == KEY.ESCAPE) {
+ close_popup();
+ $dummy.focus();
+ }
+ });
+ }
+ }
+ $real.data('part_picker', pp);
+ return pp;