1 |
3 |
ahitrov@rambler.ru |
/** |
2 |
|
|
* attributes.js |
3 |
|
|
* |
4 |
|
|
* Copyright 2009, Moxiecode Systems AB |
5 |
|
|
* Released under LGPL License. |
6 |
|
|
* |
7 |
|
|
* License: http://tinymce.moxiecode.com/license |
8 |
|
|
* Contributing: http://tinymce.moxiecode.com/contributing |
9 |
|
|
*/ |
10 |
|
|
|
11 |
|
|
function init() { |
12 |
|
|
tinyMCEPopup.resizeToInnerSize(); |
13 |
|
|
var inst = tinyMCEPopup.editor; |
14 |
|
|
var dom = inst.dom; |
15 |
|
|
var elm = inst.selection.getNode(); |
16 |
|
|
var f = document.forms[0]; |
17 |
|
|
var onclick = dom.getAttrib(elm, 'onclick'); |
18 |
|
|
|
19 |
|
|
setFormValue('title', dom.getAttrib(elm, 'title')); |
20 |
|
|
setFormValue('id', dom.getAttrib(elm, 'id')); |
21 |
|
|
setFormValue('style', dom.getAttrib(elm, "style")); |
22 |
|
|
setFormValue('dir', dom.getAttrib(elm, 'dir')); |
23 |
|
|
setFormValue('lang', dom.getAttrib(elm, 'lang')); |
24 |
|
|
setFormValue('tabindex', dom.getAttrib(elm, 'tabindex', typeof(elm.tabindex) != "undefined" ? elm.tabindex : "")); |
25 |
|
|
setFormValue('accesskey', dom.getAttrib(elm, 'accesskey', typeof(elm.accesskey) != "undefined" ? elm.accesskey : "")); |
26 |
|
|
setFormValue('onfocus', dom.getAttrib(elm, 'onfocus')); |
27 |
|
|
setFormValue('onblur', dom.getAttrib(elm, 'onblur')); |
28 |
|
|
setFormValue('onclick', onclick); |
29 |
|
|
setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick')); |
30 |
|
|
setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown')); |
31 |
|
|
setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup')); |
32 |
|
|
setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover')); |
33 |
|
|
setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove')); |
34 |
|
|
setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout')); |
35 |
|
|
setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress')); |
36 |
|
|
setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown')); |
37 |
|
|
setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup')); |
38 |
|
|
className = dom.getAttrib(elm, 'class'); |
39 |
|
|
|
40 |
|
|
addClassesToList('classlist', 'advlink_styles'); |
41 |
|
|
selectByValue(f, 'classlist', className, true); |
42 |
|
|
|
43 |
|
|
TinyMCE_EditableSelects.init(); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
function setFormValue(name, value) { |
47 |
|
|
if(value && document.forms[0].elements[name]){ |
48 |
|
|
document.forms[0].elements[name].value = value; |
49 |
|
|
} |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
function insertAction() { |
53 |
|
|
var inst = tinyMCEPopup.editor; |
54 |
|
|
var elm = inst.selection.getNode(); |
55 |
|
|
|
56 |
|
|
tinyMCEPopup.execCommand("mceBeginUndoLevel"); |
57 |
|
|
setAllAttribs(elm); |
58 |
|
|
tinyMCEPopup.execCommand("mceEndUndoLevel"); |
59 |
|
|
tinyMCEPopup.close(); |
60 |
|
|
} |
61 |
|
|
|
62 |
|
|
function setAttrib(elm, attrib, value) { |
63 |
|
|
var formObj = document.forms[0]; |
64 |
|
|
var valueElm = formObj.elements[attrib.toLowerCase()]; |
65 |
|
|
var inst = tinyMCEPopup.editor; |
66 |
|
|
var dom = inst.dom; |
67 |
|
|
|
68 |
|
|
if (typeof(value) == "undefined" || value == null) { |
69 |
|
|
value = ""; |
70 |
|
|
|
71 |
|
|
if (valueElm) |
72 |
|
|
value = valueElm.value; |
73 |
|
|
} |
74 |
|
|
|
75 |
|
|
if (value != "") { |
76 |
|
|
dom.setAttrib(elm, attrib.toLowerCase(), value); |
77 |
|
|
|
78 |
|
|
if (attrib == "style") |
79 |
|
|
attrib = "style.cssText"; |
80 |
|
|
|
81 |
|
|
if (attrib.substring(0, 2) == 'on') |
82 |
|
|
value = 'return true;' + value; |
83 |
|
|
|
84 |
|
|
if (attrib == "class") |
85 |
|
|
attrib = "className"; |
86 |
|
|
|
87 |
|
|
elm[attrib]=value; |
88 |
|
|
} else |
89 |
|
|
elm.removeAttribute(attrib); |
90 |
|
|
} |
91 |
|
|
|
92 |
|
|
function setAllAttribs(elm) { |
93 |
|
|
var f = document.forms[0]; |
94 |
|
|
|
95 |
|
|
setAttrib(elm, 'title'); |
96 |
|
|
setAttrib(elm, 'id'); |
97 |
|
|
setAttrib(elm, 'style'); |
98 |
|
|
setAttrib(elm, 'class', getSelectValue(f, 'classlist')); |
99 |
|
|
setAttrib(elm, 'dir'); |
100 |
|
|
setAttrib(elm, 'lang'); |
101 |
|
|
setAttrib(elm, 'tabindex'); |
102 |
|
|
setAttrib(elm, 'accesskey'); |
103 |
|
|
setAttrib(elm, 'onfocus'); |
104 |
|
|
setAttrib(elm, 'onblur'); |
105 |
|
|
setAttrib(elm, 'onclick'); |
106 |
|
|
setAttrib(elm, 'ondblclick'); |
107 |
|
|
setAttrib(elm, 'onmousedown'); |
108 |
|
|
setAttrib(elm, 'onmouseup'); |
109 |
|
|
setAttrib(elm, 'onmouseover'); |
110 |
|
|
setAttrib(elm, 'onmousemove'); |
111 |
|
|
setAttrib(elm, 'onmouseout'); |
112 |
|
|
setAttrib(elm, 'onkeypress'); |
113 |
|
|
setAttrib(elm, 'onkeydown'); |
114 |
|
|
setAttrib(elm, 'onkeyup'); |
115 |
|
|
|
116 |
|
|
// Refresh in old MSIE |
117 |
|
|
// if (tinyMCE.isMSIE5) |
118 |
|
|
// elm.outerHTML = elm.outerHTML; |
119 |
|
|
} |
120 |
|
|
|
121 |
|
|
function insertAttribute() { |
122 |
|
|
tinyMCEPopup.close(); |
123 |
|
|
} |
124 |
|
|
|
125 |
|
|
tinyMCEPopup.onInit.add(init); |
126 |
|
|
tinyMCEPopup.requireLangPack(); |