author | Dan |
Sat, 12 Jul 2008 12:25:25 -0400 | |
changeset 638 | 854652a5886a |
parent 588 | 20484deb89cd |
permissions | -rw-r--r-- |
1 | 1 |
/** |
588
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
2 |
* $Id: editable_selects.js 867 2008-06-09 20:33:40Z spocke $ |
1 | 3 |
* |
4 |
* Makes select boxes editable. |
|
5 |
* |
|
6 |
* @author Moxiecode |
|
395
fa4c5ecb7c9a
Fixed splitting bug (really the same issue from stable) in get_pageid_from_url(); upgraded TinyMCE to version 3.0-stable
Dan
parents:
335
diff
changeset
|
7 |
* @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved. |
1 | 8 |
*/ |
9 |
||
10 |
var TinyMCE_EditableSelects = { |
|
11 |
editSelectElm : null, |
|
12 |
||
13 |
init : function() { |
|
14 |
var nl = document.getElementsByTagName("select"), i, d = document, o; |
|
15 |
||
16 |
for (i=0; i<nl.length; i++) { |
|
17 |
if (nl[i].className.indexOf('mceEditableSelect') != -1) { |
|
18 |
o = new Option('(value)', '__mce_add_custom__'); |
|
19 |
||
20 |
o.className = 'mceAddSelectValue'; |
|
21 |
||
22 |
nl[i].options[nl[i].options.length] = o; |
|
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
1
diff
changeset
|
23 |
nl[i].onchange = TinyMCE_EditableSelects.onChangeEditableSelect; |
1 | 24 |
} |
25 |
} |
|
26 |
}, |
|
27 |
||
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
1
diff
changeset
|
28 |
onChangeEditableSelect : function(e) { |
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
1
diff
changeset
|
29 |
var d = document, ne, se = window.event ? window.event.srcElement : e.target; |
1 | 30 |
|
31 |
if (se.options[se.selectedIndex].value == '__mce_add_custom__') { |
|
32 |
ne = d.createElement("input"); |
|
33 |
ne.id = se.id + "_custom"; |
|
34 |
ne.name = se.name + "_custom"; |
|
35 |
ne.type = "text"; |
|
36 |
||
335
67bd3121a12e
Replaced TinyMCE 2.x with 3.0 beta 3. Supports everything but IE. Also rewrote the editor interface completely from the ground up.
Dan
parents:
1
diff
changeset
|
37 |
ne.style.width = se.offsetWidth + 'px'; |
1 | 38 |
se.parentNode.insertBefore(ne, se); |
39 |
se.style.display = 'none'; |
|
40 |
ne.focus(); |
|
41 |
ne.onblur = TinyMCE_EditableSelects.onBlurEditableSelectInput; |
|
588
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
42 |
ne.onkeydown = TinyMCE_EditableSelects.onKeyDown; |
1 | 43 |
TinyMCE_EditableSelects.editSelectElm = se; |
44 |
} |
|
45 |
}, |
|
46 |
||
47 |
onBlurEditableSelectInput : function() { |
|
48 |
var se = TinyMCE_EditableSelects.editSelectElm; |
|
49 |
||
50 |
if (se) { |
|
51 |
if (se.previousSibling.value != '') { |
|
52 |
addSelectValue(document.forms[0], se.id, se.previousSibling.value, se.previousSibling.value); |
|
53 |
selectByValue(document.forms[0], se.id, se.previousSibling.value); |
|
54 |
} else |
|
55 |
selectByValue(document.forms[0], se.id, ''); |
|
56 |
||
57 |
se.style.display = 'inline'; |
|
58 |
se.parentNode.removeChild(se.previousSibling); |
|
59 |
TinyMCE_EditableSelects.editSelectElm = null; |
|
60 |
} |
|
588
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
61 |
}, |
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
62 |
|
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
63 |
onKeyDown : function(e) { |
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
64 |
e = e || window.event; |
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
65 |
|
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
66 |
if (e.keyCode == 13) |
20484deb89cd
Upgraded TinyMCE to 3.1.0.1. Ported a couple special pages to the componentized JS system.
Dan
parents:
395
diff
changeset
|
67 |
TinyMCE_EditableSelects.onBlurEditableSelectInput(); |
1 | 68 |
} |
69 |
}; |