includes/clientside/static/autofill.js
changeset 647 6bb3d447b4b8
parent 645 24f2fa13a2a0
child 649 74e03196fd43
equal deleted inserted replaced
646:55363ed1099e 647:6bb3d447b4b8
    46   }
    46   }
    47 };
    47 };
    48 
    48 
    49 function autofill_init_element(element, params)
    49 function autofill_init_element(element, params)
    50 {
    50 {
    51   if ( element.parentNode.id.match(/^autofill_wrap_/) )
       
    52     return false;
       
    53   
       
    54   if ( !Spry.Data );
    51   if ( !Spry.Data );
    55     load_spry_data();
    52     load_spry_data();
    56   
    53   
    57   params = params || {};
    54   params = params || {};
    58   // assign an ID if it doesn't have one yet
    55   // assign an ID if it doesn't have one yet
   110       }
   107       }
   111       
   108       
   112       // inject our HTML wrapper
   109       // inject our HTML wrapper
   113       var template = this.template.replace(new RegExp('--ID--', 'g'), element.id);
   110       var template = this.template.replace(new RegExp('--ID--', 'g'), element.id);
   114       var wrapper = element.parentNode; // document.createElement('div');
   111       var wrapper = element.parentNode; // document.createElement('div');
   115       wrapper.id = 'autofill_wrap_' + element.id;
   112       if ( !wrapper.id )
       
   113         wrapper.id = 'autofill_wrap_' + element.id;
   116       
   114       
   117       // a bunch of hacks to add a spry wrapper
   115       // a bunch of hacks to add a spry wrapper
   118       wrapper.innerHTML = template + wrapper.innerHTML;
   116       wrapper.innerHTML = template + wrapper.innerHTML;
   119       
   117       
   120       var autosuggest = new Spry.Widget.AutoSuggest("autofill_wrap_" + element.id, element.id + '_region', window.autofill_ds_username, 'name', {loadFromServer: true, urlParam: 'userinput', hoverSuggestClass: 'row2', minCharsType: 3});
   118       var autosuggest = new Spry.Widget.AutoSuggest(wrapper.id, element.id + '_region', window.autofill_ds_username, 'name', {loadFromServer: true, urlParam: 'userinput', hoverSuggestClass: 'row2', minCharsType: 3});
   121       var regiondiv = document.getElementById(element.id + '_region');
   119       var regiondiv = document.getElementById(element.id + '_region');
   122       regiondiv.style.position = 'absolute';
   120       regiondiv.style.position = 'absolute';
   123       regiondiv.style.top = top + 'px';
   121       regiondiv.style.top = top + 'px';
   124       regiondiv.style.left = left + 'px';
   122       regiondiv.style.left = left + 'px';
   125     }
   123     }