Move to sane directory structure. Don't make 'cms' the top level of the silverstripe...
[silverstripe-elijah.git] / javascript / MemberTableField_popup.js
blob5b2a52460b2a0169497da778acfb967e3ee8ad8f
1 MemberTableFieldPopupForm = Class.extend("ComplexTableFieldPopupForm");
2 MemberTableFieldPopupForm.prototype = {
3         initialize: function() {
4                 this.ComplexTableFieldPopupForm.initialize();
6                 Behaviour.register({
7                         "form#MemberTableField_Popup_DetailForm input.action": {
8                                 onclick: this.submitForm.bind(this)
9                         },
11                         'form#MemberTableField_Popup_DetailForm input' : {
12                                 initialise : function() {
13                                         if(this.name == 'FirstName' || this.name == 'Surname' || this.name == 'Email') {
14                                                 var div = document.createElement('div');
15                                                 div.id = this.id + '_ac';
16                                                 div.className = 'autocomplete';
17                                                 this.parentNode.appendChild(div);
18                                                 /*
19                                                 new Ajax.Autocompleter(this.id, div.id, 'admin/security/autocomplete/' + this.name, {
20                                                         afterUpdateElement : this.afterAutocomplete.bind(this)
21                                                 });
22                                                 */
23                                         }
24                                 },
25                                 afterAutocomplete : function(field, selectedItem) {
26                                         var data = selectedItem.getElementsByTagName('span')[1].innerHTML;
27                                         var items = data.split(",");
29                                         this.elements.FirstName.value = items[0];
30                                         this.elements.Surname.value = items[1];
31                                         this.elements.Email.value = items[2];
32                                         this.elements.Password.value = items[3];
33                                 }
34                         }
36                         //'form#MemberTableField_Popup_DetailForm input' : AjaxMemberLookup
37                 });
38         }
41 MemberTableFieldPopupForm.applyTo('form#MemberTableField_Popup_DetailForm');