1addInitEvent(function() { 2 var form = $('tagging_edit'); 3 if (!form) return; 4 5 6 var input = form.getElementsByTagName('input')[2]; 7 if (typeof addAutoCompletion !== undefined) { 8 addAutoCompletion(input, 'tagging_auto', true, null, function (ul, input) { 9 // Overwrite to fix the width 10 ul.style.top = (findPosY(input) + input.offsetHeight - 1) + 'px'; 11 ul.style.left = findPosX(input) + 'px'; 12 ul.style.minWidth = (input.offsetWidth - 8) + 'px'; 13 }); 14 } 15 16 var buttons = getElementsByClass('btn_tagging_edit', document, 'form'); 17 18 for (var i = 0; i < buttons.length ; ++i) { 19 addEvent(buttons[i], 'submit', function () { 20 this.style.display = 'none'; 21 form.style.display = 'inline'; 22 input.focus(); 23 if (!input.value.match(/(^|, )$/)) { 24 input.value += ', '; 25 } 26 return false; 27 }); 28 } 29 30 addEvent($('tagging_edit_save'), 'click', function () { 31 form.previousSibling.style.display = 'inline'; 32 form.style.display = 'none'; 33 ajax_loader.sack_new_form(form, 'tagging', function () { 34 form.previousSibling.previousSibling.innerHTML = this.response; 35 }); 36 return false; 37 }); 38 39 addEvent($('tagging_edit_cancel'), 'click', function () { 40 form.previousSibling.style.display = 'inline'; 41 form.style.display = 'none'; 42 return false; 43 }); 44}); 45