annotate media/js/tiny_mce/utils/editable_selects.js @ 162:6a5bdcf93ad3

Fix #48; shoutbox was no longer escaping user input on display.
author Brian Neal <bgneal@gmail.com>
date Tue, 22 Dec 2009 03:55:37 +0000
parents a5b4c5ce0658
children 149c3567fec1
rev   line source
bgneal@45 1 /**
bgneal@45 2 * $Id: editable_selects.js 867 2008-06-09 20:33:40Z spocke $
bgneal@45 3 *
bgneal@45 4 * Makes select boxes editable.
bgneal@45 5 *
bgneal@45 6 * @author Moxiecode
bgneal@45 7 * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45 8 */
bgneal@45 9
bgneal@45 10 var TinyMCE_EditableSelects = {
bgneal@45 11 editSelectElm : null,
bgneal@45 12
bgneal@45 13 init : function() {
bgneal@45 14 var nl = document.getElementsByTagName("select"), i, d = document, o;
bgneal@45 15
bgneal@45 16 for (i=0; i<nl.length; i++) {
bgneal@45 17 if (nl[i].className.indexOf('mceEditableSelect') != -1) {
bgneal@45 18 o = new Option('(value)', '__mce_add_custom__');
bgneal@45 19
bgneal@45 20 o.className = 'mceAddSelectValue';
bgneal@45 21
bgneal@45 22 nl[i].options[nl[i].options.length] = o;
bgneal@45 23 nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
bgneal@45 24 }
bgneal@45 25 }
bgneal@45 26 },
bgneal@45 27
bgneal@45 28 onChangeEditableSelect : function(e) {
bgneal@45 29 var d = document, ne, se = window.event ? window.event.srcElement : e.target;
bgneal@45 30
bgneal@45 31 if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
bgneal@45 32 ne = d.createElement("input");
bgneal@45 33 ne.id = se.id + "_custom";
bgneal@45 34 ne.name = se.name + "_custom";
bgneal@45 35 ne.type = "text";
bgneal@45 36
bgneal@45 37 ne.style.width = se.offsetWidth + 'px';
bgneal@45 38 se.parentNode.insertBefore(ne, se);
bgneal@45 39 se.style.display = 'none';
bgneal@45 40 ne.focus();
bgneal@45 41 ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
bgneal@45 42 ne.onkeydown = TinyMCE_EditableSelects.onKeyDown;
bgneal@45 43 TinyMCE_EditableSelects.editSelectElm = se;
bgneal@45 44 }
bgneal@45 45 },
bgneal@45 46
bgneal@45 47 onBlurEditableSelectInput : function() {
bgneal@45 48 var se = TinyMCE_EditableSelects.editSelectElm;
bgneal@45 49
bgneal@45 50 if (se) {
bgneal@45 51 if (se.previousSibling.value != '') {
bgneal@45 52 addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
bgneal@45 53 selectByValue(document.forms[0], se.id, se.previousSibling.value);
bgneal@45 54 } else
bgneal@45 55 selectByValue(document.forms[0], se.id, '');
bgneal@45 56
bgneal@45 57 se.style.display = 'inline';
bgneal@45 58 se.parentNode.removeChild(se.previousSibling);
bgneal@45 59 TinyMCE_EditableSelects.editSelectElm = null;
bgneal@45 60 }
bgneal@45 61 },
bgneal@45 62
bgneal@45 63 onKeyDown : function(e) {
bgneal@45 64 e = e || window.event;
bgneal@45 65
bgneal@45 66 if (e.keyCode == 13)
bgneal@45 67 TinyMCE_EditableSelects.onBlurEditableSelectInput();
bgneal@45 68 }
bgneal@45 69 };