2 * $Id: editable_selects.js 18 2006-06-29 14:11:23Z spocke $
\r
4 * Makes select boxes editable.
\r
7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
\r
10 var TinyMCE_EditableSelects = {
\r
11 editSelectElm : null,
\r
14 var nl = document.getElementsByTagName("select"), i, d = document, o;
\r
16 for (i=0; i<nl.length; i++) {
\r
17 if (nl[i].className.indexOf('mceEditableSelect') != -1) {
\r
18 o = new Option('(value)', '__mce_add_custom__');
\r
20 o.className = 'mceAddSelectValue';
\r
22 nl[i].options[nl[i].options.length] = o;
\r
23 nl[i].setAttribute('onchange', 'TinyMCE_EditableSelects.onChangeEditableSelect(this);');
\r
28 onChangeEditableSelect : function(se) {
\r
29 var d = document, ne;
\r
31 if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
\r
32 ne = d.createElement("input");
\r
33 ne.id = se.id + "_custom";
\r
34 ne.name = se.name + "_custom";
\r
37 ne.style.width = se.clientWidth;
\r
38 se.parentNode.insertBefore(ne, se);
\r
39 se.style.display = 'none';
\r
41 ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
\r
42 TinyMCE_EditableSelects.editSelectElm = se;
\r
46 onBlurEditableSelectInput : function() {
\r
47 var se = TinyMCE_EditableSelects.editSelectElm;
\r
50 if (se.previousSibling.value != '') {
\r
51 addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
\r
52 selectByValue(document.forms[0], se.id, se.previousSibling.value);
\r
54 selectByValue(document.forms[0], se.id, '');
\r
56 se.style.display = 'inline';
\r
57 se.parentNode.removeChild(se.previousSibling);
\r
58 TinyMCE_EditableSelects.editSelectElm = null;
\r