annotate WebContent/jscripts/tiny_mce/plugins/xhtmlxtras/js/element_common.js @ 6:5bb7cc86069c

restlet.jar
author dwinter
date Wed, 14 Mar 2012 16:21:45 +0100
parents 0be9d53a6967
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
1 /**
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
2 * element_common.js
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
3 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
4 * Copyright 2009, Moxiecode Systems AB
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
5 * Released under LGPL License.
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
6 *
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
7 * License: http://tinymce.moxiecode.com/license
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
8 * Contributing: http://tinymce.moxiecode.com/contributing
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
9 */
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
10
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
11 tinyMCEPopup.requireLangPack();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
12
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
13 function initCommonAttributes(elm) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
14 var formObj = document.forms[0], dom = tinyMCEPopup.editor.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
15
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
16 // Setup form data for common element attributes
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
17 setFormValue('title', dom.getAttrib(elm, 'title'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
18 setFormValue('id', dom.getAttrib(elm, 'id'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
19 selectByValue(formObj, 'class', dom.getAttrib(elm, 'class'), true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
20 setFormValue('style', dom.getAttrib(elm, 'style'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
21 selectByValue(formObj, 'dir', dom.getAttrib(elm, 'dir'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
22 setFormValue('lang', dom.getAttrib(elm, 'lang'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
23 setFormValue('onfocus', dom.getAttrib(elm, 'onfocus'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
24 setFormValue('onblur', dom.getAttrib(elm, 'onblur'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
25 setFormValue('onclick', dom.getAttrib(elm, 'onclick'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
26 setFormValue('ondblclick', dom.getAttrib(elm, 'ondblclick'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
27 setFormValue('onmousedown', dom.getAttrib(elm, 'onmousedown'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
28 setFormValue('onmouseup', dom.getAttrib(elm, 'onmouseup'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
29 setFormValue('onmouseover', dom.getAttrib(elm, 'onmouseover'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
30 setFormValue('onmousemove', dom.getAttrib(elm, 'onmousemove'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
31 setFormValue('onmouseout', dom.getAttrib(elm, 'onmouseout'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
32 setFormValue('onkeypress', dom.getAttrib(elm, 'onkeypress'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
33 setFormValue('onkeydown', dom.getAttrib(elm, 'onkeydown'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
34 setFormValue('onkeyup', dom.getAttrib(elm, 'onkeyup'));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
35 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
36
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
37 function setFormValue(name, value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
38 if(document.forms[0].elements[name]) document.forms[0].elements[name].value = value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
39 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
40
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
41 function insertDateTime(id) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
42 document.getElementById(id).value = getDateTime(new Date(), "%Y-%m-%dT%H:%M:%S");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
43 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
44
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
45 function getDateTime(d, fmt) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
46 fmt = fmt.replace("%D", "%m/%d/%y");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
47 fmt = fmt.replace("%r", "%I:%M:%S %p");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
48 fmt = fmt.replace("%Y", "" + d.getFullYear());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
49 fmt = fmt.replace("%y", "" + d.getYear());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
50 fmt = fmt.replace("%m", addZeros(d.getMonth()+1, 2));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
51 fmt = fmt.replace("%d", addZeros(d.getDate(), 2));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
52 fmt = fmt.replace("%H", "" + addZeros(d.getHours(), 2));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
53 fmt = fmt.replace("%M", "" + addZeros(d.getMinutes(), 2));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
54 fmt = fmt.replace("%S", "" + addZeros(d.getSeconds(), 2));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
55 fmt = fmt.replace("%I", "" + ((d.getHours() + 11) % 12 + 1));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
56 fmt = fmt.replace("%p", "" + (d.getHours() < 12 ? "AM" : "PM"));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
57 fmt = fmt.replace("%%", "%");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
58
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
59 return fmt;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
60 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
61
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
62 function addZeros(value, len) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
63 var i;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
64
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
65 value = "" + value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
66
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
67 if (value.length < len) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
68 for (i=0; i<(len-value.length); i++)
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
69 value = "0" + value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
70 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
71
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
72 return value;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
73 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
74
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
75 function selectByValue(form_obj, field_name, value, add_custom, ignore_case) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
76 if (!form_obj || !form_obj.elements[field_name])
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
77 return;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
78
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
79 var sel = form_obj.elements[field_name];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
80
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
81 var found = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
82 for (var i=0; i<sel.options.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
83 var option = sel.options[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
84
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
85 if (option.value == value || (ignore_case && option.value.toLowerCase() == value.toLowerCase())) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
86 option.selected = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
87 found = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
88 } else
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
89 option.selected = false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
90 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
91
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
92 if (!found && add_custom && value != '') {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
93 var option = new Option('Value: ' + value, value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
94 option.selected = true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
95 sel.options[sel.options.length] = option;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
96 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
97
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
98 return found;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
99 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
100
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
101 function setAttrib(elm, attrib, value) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
102 var formObj = document.forms[0];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
103 var valueElm = formObj.elements[attrib.toLowerCase()];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
104 tinyMCEPopup.editor.dom.setAttrib(elm, attrib, value || valueElm.value);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
105 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
106
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
107 function setAllCommonAttribs(elm) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
108 setAttrib(elm, 'title');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
109 setAttrib(elm, 'id');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
110 setAttrib(elm, 'class');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
111 setAttrib(elm, 'style');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
112 setAttrib(elm, 'dir');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
113 setAttrib(elm, 'lang');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
114 /*setAttrib(elm, 'onfocus');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
115 setAttrib(elm, 'onblur');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
116 setAttrib(elm, 'onclick');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
117 setAttrib(elm, 'ondblclick');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
118 setAttrib(elm, 'onmousedown');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
119 setAttrib(elm, 'onmouseup');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
120 setAttrib(elm, 'onmouseover');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
121 setAttrib(elm, 'onmousemove');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
122 setAttrib(elm, 'onmouseout');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
123 setAttrib(elm, 'onkeypress');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
124 setAttrib(elm, 'onkeydown');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
125 setAttrib(elm, 'onkeyup');*/
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
126 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
127
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
128 SXE = {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
129 currentAction : "insert",
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
130 inst : tinyMCEPopup.editor,
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
131 updateElement : null
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
132 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
133
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
134 SXE.focusElement = SXE.inst.selection.getNode();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
135
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
136 SXE.initElementDialog = function(element_name) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
137 addClassesToList('class', 'xhtmlxtras_styles');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
138 TinyMCE_EditableSelects.init();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
139
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
140 element_name = element_name.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
141 var elm = SXE.inst.dom.getParent(SXE.focusElement, element_name.toUpperCase());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
142 if (elm != null && elm.nodeName.toUpperCase() == element_name.toUpperCase()) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
143 SXE.currentAction = "update";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
144 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
145
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
146 if (SXE.currentAction == "update") {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
147 initCommonAttributes(elm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
148 SXE.updateElement = elm;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
149 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
150
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
151 document.forms[0].insert.value = tinyMCEPopup.getLang(SXE.currentAction, 'Insert', true);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
152 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
153
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
154 SXE.insertElement = function(element_name) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
155 var elm = SXE.inst.dom.getParent(SXE.focusElement, element_name.toUpperCase()), h, tagName;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
156
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
157 if (elm == null) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
158 var s = SXE.inst.selection.getContent();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
159 if(s.length > 0) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
160 tagName = element_name;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
161
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
162 insertInlineElement(element_name);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
163 var elementArray = tinymce.grep(SXE.inst.dom.select(element_name));
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
164 for (var i=0; i<elementArray.length; i++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
165 var elm = elementArray[i];
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
166
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
167 if (SXE.inst.dom.getAttrib(elm, 'data-mce-new')) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
168 elm.id = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
169 elm.setAttribute('id', '');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
170 elm.removeAttribute('id');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
171 elm.removeAttribute('data-mce-new');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
172
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
173 setAllCommonAttribs(elm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
174 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
175 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
176 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
177 } else {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
178 setAllCommonAttribs(elm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
179 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
180 SXE.inst.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
181 tinyMCEPopup.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
182 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
183
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
184 SXE.removeElement = function(element_name){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
185 element_name = element_name.toLowerCase();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
186 elm = SXE.inst.dom.getParent(SXE.focusElement, element_name.toUpperCase());
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
187 if(elm && elm.nodeName.toUpperCase() == element_name.toUpperCase()){
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
188 tinyMCE.execCommand('mceRemoveNode', false, elm);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
189 SXE.inst.nodeChanged();
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
190 tinyMCEPopup.execCommand('mceEndUndoLevel');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
191 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
192 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
193
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
194 SXE.showRemoveButton = function() {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
195 document.getElementById("remove").style.display = '';
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
196 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
197
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
198 SXE.containsClass = function(elm,cl) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
199 return (elm.className.indexOf(cl) > -1) ? true : false;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
200 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
201
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
202 SXE.removeClass = function(elm,cl) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
203 if(elm.className == null || elm.className == "" || !SXE.containsClass(elm,cl)) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
204 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
205 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
206 var classNames = elm.className.split(" ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
207 var newClassNames = "";
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
208 for (var x = 0, cnl = classNames.length; x < cnl; x++) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
209 if (classNames[x] != cl) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
210 newClassNames += (classNames[x] + " ");
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
211 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
212 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
213 elm.className = newClassNames.substring(0,newClassNames.length-1); //removes extra space at the end
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
214 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
215
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
216 SXE.addClass = function(elm,cl) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
217 if(!SXE.containsClass(elm,cl)) elm.className ? elm.className += " " + cl : elm.className = cl;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
218 return true;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
219 }
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
220
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
221 function insertInlineElement(en) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
222 var ed = tinyMCEPopup.editor, dom = ed.dom;
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
223
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
224 ed.getDoc().execCommand('FontName', false, 'mceinline');
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
225 tinymce.each(dom.select('span,font'), function(n) {
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
226 if (n.style.fontFamily == 'mceinline' || n.face == 'mceinline')
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
227 dom.replace(dom.create(en, {'data-mce-new' : 1}), n, 1);
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
228 });
0be9d53a6967 editor for annotations
dwinter
parents:
diff changeset
229 }