annotate static/js/tiny_mce/utils/editable_selects.js @ 1121:67c839267220

Finish the bio profile template for V3 design.
author Brian Neal <bgneal@gmail.com>
date Wed, 03 Aug 2016 19:35:54 -0500
parents 88b2b9cb8c1f
children
rev   line source
bgneal@312 1 /**
bgneal@312 2 * editable_selects.js
bgneal@312 3 *
bgneal@312 4 * Copyright 2009, Moxiecode Systems AB
bgneal@312 5 * Released under LGPL License.
bgneal@312 6 *
bgneal@312 7 * License: http://tinymce.moxiecode.com/license
bgneal@312 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@312 9 */
bgneal@312 10
bgneal@312 11 var TinyMCE_EditableSelects = {
bgneal@312 12 editSelectElm : null,
bgneal@312 13
bgneal@312 14 init : function() {
bgneal@312 15 var nl = document.getElementsByTagName("select"), i, d = document, o;
bgneal@312 16
bgneal@312 17 for (i=0; i<nl.length; i++) {
bgneal@312 18 if (nl[i].className.indexOf('mceEditableSelect') != -1) {
bgneal@312 19 o = new Option('(value)', '__mce_add_custom__');
bgneal@312 20
bgneal@312 21 o.className = 'mceAddSelectValue';
bgneal@312 22
bgneal@312 23 nl[i].options[nl[i].options.length] = o;
bgneal@312 24 nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect;
bgneal@312 25 }
bgneal@312 26 }
bgneal@312 27 },
bgneal@312 28
bgneal@312 29 onChangeEditableSelect : function(e) {
bgneal@312 30 var d = document, ne, se = window.event ? window.event.srcElement : e.target;
bgneal@312 31
bgneal@312 32 if (se.options[se.selectedIndex].value == '__mce_add_custom__') {
bgneal@312 33 ne = d.createElement("input");
bgneal@312 34 ne.id = se.id + "_custom";
bgneal@312 35 ne.name = se.name + "_custom";
bgneal@312 36 ne.type = "text";
bgneal@312 37
bgneal@312 38 ne.style.width = se.offsetWidth + 'px';
bgneal@312 39 se.parentNode.insertBefore(ne, se);
bgneal@312 40 se.style.display = 'none';
bgneal@312 41 ne.focus();
bgneal@312 42 ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput;
bgneal@312 43 ne.onkeydown = TinyMCE_EditableSelects.onKeyDown;
bgneal@312 44 TinyMCE_EditableSelects.editSelectElm = se;
bgneal@312 45 }
bgneal@312 46 },
bgneal@312 47
bgneal@312 48 onBlurEditableSelectInput : function() {
bgneal@312 49 var se = TinyMCE_EditableSelects.editSelectElm;
bgneal@312 50
bgneal@312 51 if (se) {
bgneal@312 52 if (se.previousSibling.value != '') {
bgneal@312 53 addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value);
bgneal@312 54 selectByValue(document.forms[0], se.id, se.previousSibling.value);
bgneal@312 55 } else
bgneal@312 56 selectByValue(document.forms[0], se.id, '');
bgneal@312 57
bgneal@312 58 se.style.display = 'inline';
bgneal@312 59 se.parentNode.removeChild(se.previousSibling);
bgneal@312 60 TinyMCE_EditableSelects.editSelectElm = null;
bgneal@312 61 }
bgneal@312 62 },
bgneal@312 63
bgneal@312 64 onKeyDown : function(e) {
bgneal@312 65 e = e || window.event;
bgneal@312 66
bgneal@312 67 if (e.keyCode == 13)
bgneal@312 68 TinyMCE_EditableSelects.onBlurEditableSelectInput();
bgneal@312 69 }
bgneal@312 70 };