includes/clientside/tinymce/utils/editable_selects.js
changeset 335 67bd3121a12e
parent 1 fe660c52c48f
child 395 fa4c5ecb7c9a
equal deleted inserted replaced
334:c72b545f1304 335:67bd3121a12e
     1 /**
     1 /**
     2  * $Id: editable_selects.js 162 2007-01-03 16:16:52Z spocke $
     2  * $Id: editable_selects.js 324 2007-11-01 12:58:49Z spocke $
     3  *
     3  *
     4  * Makes select boxes editable.
     4  * Makes select boxes editable.
     5  *
     5  *
     6  * @author Moxiecode
     6  * @author Moxiecode
     7  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
     7  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
    18 				o = new Option('(value)', '__mce_add_custom__');
    18 				o = new Option('(value)', '__mce_add_custom__');
    19 
    19 
    20 				o.className = 'mceAddSelectValue';
    20 				o.className = 'mceAddSelectValue';
    21 
    21 
    22 				nl[i].options[nl[i].options.length] = o;
    22 				nl[i].options[nl[i].options.length] = o;
    23 				nl[i].setAttribute('onchange', 'TinyMCE_EditableSelects.onChangeEditableSelect(this);');
    23 				nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
    24 			}
    24 			}
    25 		}
    25 		}
    26 	},
    26 	},
    27 
    27 
    28 	onChangeEditableSelect : function(se) {
    28 	onChangeEditableSelect : function(e) {
    29 		var d = document, ne;
    29 		var d = document, ne, se = window.event ? window.event.srcElement : e.target;
    30 
    30 
    31 		if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
    31 		if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
    32 			ne = d.createElement("input");
    32 			ne = d.createElement("input");
    33 			ne.id = se.id + "_custom";
    33 			ne.id = se.id + "_custom";
    34 			ne.name = se.name + "_custom";
    34 			ne.name = se.name + "_custom";
    35 			ne.type = "text";
    35 			ne.type = "text";
    36 
    36 
    37 			ne.style.width = se.clientWidth;
    37 			ne.style.width = se.offsetWidth + 'px';
    38 			se.parentNode.insertBefore(ne, se);
    38 			se.parentNode.insertBefore(ne, se);
    39 			se.style.display = 'none';
    39 			se.style.display = 'none';
    40 			ne.focus();
    40 			ne.focus();
    41 			ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
    41 			ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
    42 			TinyMCE_EditableSelects.editSelectElm = se;
    42 			TinyMCE_EditableSelects.editSelectElm = se;