1 tinyMCEPopup.requireLangPack();
\r
5 var defaultDocTypes =
\r
6 'XHTML 1.0 Transitional=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">,' +
\r
7 'XHTML 1.0 Frameset=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">,' +
\r
8 'XHTML 1.0 Strict=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">,' +
\r
9 'XHTML 1.1=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">,' +
\r
10 'HTML 4.01 Transitional=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">,' +
\r
11 'HTML 4.01 Strict=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">,' +
\r
12 'HTML 4.01 Frameset=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
\r
14 var defaultEncodings =
\r
15 'Western european (iso-8859-1)=iso-8859-1,' +
\r
16 'Central European (iso-8859-2)=iso-8859-2,' +
\r
17 'Unicode (UTF-8)=utf-8,' +
\r
18 'Chinese traditional (Big5)=big5,' +
\r
19 'Cyrillic (iso-8859-5)=iso-8859-5,' +
\r
20 'Japanese (iso-2022-jp)=iso-2022-jp,' +
\r
21 'Greek (iso-8859-7)=iso-8859-7,' +
\r
22 'Korean (iso-2022-kr)=iso-2022-kr,' +
\r
23 'ASCII (us-ascii)=us-ascii';
\r
25 var defaultMediaTypes =
\r
31 'projection=projection,' +
\r
32 'handheld=handheld,' +
\r
33 'braille=braille,' +
\r
36 var defaultFontNames = 'Arial=arial,helvetica,sans-serif;Courier New=courier new,courier,monospace;Georgia=georgia,times new roman,times,serif;Tahoma=tahoma,arial,helvetica,sans-serif;Times New Roman=times new roman,times,serif;Verdana=verdana,arial,helvetica,sans-serif;Impact=impact;WingDings=wingdings';
\r
37 var defaultFontSizes = '10px,11px,12px,13px,14px,15px,16px';
\r
40 var f = document.forms['fullpage'], el = f.elements, e, i, p, doctypes, encodings, mediaTypes, fonts, ed = tinyMCEPopup.editor, dom = tinyMCEPopup.dom, style;
\r
42 // Setup doctype select box
\r
43 doctypes = ed.getParam("fullpage_doctypes", defaultDocTypes).split(',');
\r
44 for (i=0; i<doctypes.length; i++) {
\r
45 p = doctypes[i].split('=');
\r
48 addSelectValue(f, 'doctypes', p[0], p[1]);
\r
51 // Setup fonts select box
\r
52 fonts = ed.getParam("fullpage_fonts", defaultFontNames).split(';');
\r
53 for (i=0; i<fonts.length; i++) {
\r
54 p = fonts[i].split('=');
\r
57 addSelectValue(f, 'fontface', p[0], p[1]);
\r
60 // Setup fontsize select box
\r
61 fonts = ed.getParam("fullpage_fontsizes", defaultFontSizes).split(',');
\r
62 for (i=0; i<fonts.length; i++)
\r
63 addSelectValue(f, 'fontsize', fonts[i], fonts[i]);
\r
65 // Setup mediatype select boxs
\r
66 mediaTypes = ed.getParam("fullpage_media_types", defaultMediaTypes).split(',');
\r
67 for (i=0; i<mediaTypes.length; i++) {
\r
68 p = mediaTypes[i].split('=');
\r
71 addSelectValue(f, 'element_style_media', p[0], p[1]);
\r
72 addSelectValue(f, 'element_link_media', p[0], p[1]);
\r
76 // Setup encodings select box
\r
77 encodings = ed.getParam("fullpage_encodings", defaultEncodings).split(',');
\r
78 for (i=0; i<encodings.length; i++) {
\r
79 p = encodings[i].split('=');
\r
82 addSelectValue(f, 'docencoding', p[0], p[1]);
\r
83 addSelectValue(f, 'element_script_charset', p[0], p[1]);
\r
84 addSelectValue(f, 'element_link_charset', p[0], p[1]);
\r
88 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
\r
89 document.getElementById('link_color_pickcontainer').innerHTML = getColorPickerHTML('link_color_pick','link_color');
\r
90 //document.getElementById('hover_color_pickcontainer').innerHTML = getColorPickerHTML('hover_color_pick','hover_color');
\r
91 document.getElementById('visited_color_pickcontainer').innerHTML = getColorPickerHTML('visited_color_pick','visited_color');
\r
92 document.getElementById('active_color_pickcontainer').innerHTML = getColorPickerHTML('active_color_pick','active_color');
\r
93 document.getElementById('textcolor_pickcontainer').innerHTML = getColorPickerHTML('textcolor_pick','textcolor');
\r
94 document.getElementById('stylesheet_browsercontainer').innerHTML = getBrowserHTML('stylesheetbrowser','stylesheet','file','fullpage');
\r
95 document.getElementById('link_href_pickcontainer').innerHTML = getBrowserHTML('link_href_browser','element_link_href','file','fullpage');
\r
96 document.getElementById('script_src_pickcontainer').innerHTML = getBrowserHTML('script_src_browser','element_script_src','file','fullpage');
\r
97 document.getElementById('bgimage_pickcontainer').innerHTML = getBrowserHTML('bgimage_browser','bgimage','image','fullpage');
\r
99 // Resize some elements
\r
100 if (isVisible('stylesheetbrowser'))
\r
101 document.getElementById('stylesheet').style.width = '220px';
\r
103 if (isVisible('link_href_browser'))
\r
104 document.getElementById('element_link_href').style.width = '230px';
\r
106 if (isVisible('bgimage_browser'))
\r
107 document.getElementById('bgimage').style.width = '210px';
\r
110 dom.add(document.body, 'iframe', {id : 'documentIframe', src : 'javascript:""', style : {display : 'none'}});
\r
111 doc = dom.get('documentIframe').contentWindow.document;
\r
112 h = tinyMCEPopup.getWindowArg('head_html');
\r
114 // Preprocess the HTML disable scripts and urls
\r
115 h = h.replace(/<script>/gi, '<script type="text/javascript">');
\r
116 h = h.replace(/type=([\"\'])?/gi, 'type=$1-mce-');
\r
117 h = h.replace(/(src=|href=)/g, 'mce_$1');
\r
119 // Write in the content in the iframe
\r
120 doc.write(h + '</body></html>');
\r
123 // Parse xml and doctype
\r
124 xmlVer = getReItem(/<\?\s*?xml.*?version\s*?=\s*?"(.*?)".*?\?>/gi, h, 1);
\r
125 xmlEnc = getReItem(/<\?\s*?xml.*?encoding\s*?=\s*?"(.*?)".*?\?>/gi, h, 1);
\r
126 docType = getReItem(/<\!DOCTYPE.*?>/gi, h, 0);
\r
127 f.langcode.value = getReItem(/lang="(.*?)"/gi, h, 1);
\r
130 if (e = doc.getElementsByTagName('title')[0])
\r
131 el.metatitle.value = e.textContent || e.text;
\r
134 tinymce.each(doc.getElementsByTagName('meta'), function(n) {
\r
135 var na = (n.getAttribute('name', 2) || '').toLowerCase(), va = n.getAttribute('content', 2), eq = n.getAttribute('httpEquiv', 2) || '';
\r
137 e = el['meta' + na];
\r
139 if (na == 'robots') {
\r
140 selectByValue(f, 'metarobots', tinymce.trim(va), true, true);
\r
144 switch (eq.toLowerCase()) {
\r
145 case "content-type":
\r
146 tmp = getReItem(/charset\s*=\s*(.*)\s*/gi, va, 1);
\r
148 // Override XML encoding
\r
159 selectByValue(f, 'doctypes', docType, true, true);
\r
160 selectByValue(f, 'docencoding', xmlEnc, true, true);
\r
161 selectByValue(f, 'langdir', doc.body.getAttribute('dir', 2) || '', true, true);
\r
164 el.xml_pi.checked = true;
\r
166 // Parse appearance
\r
168 // Parse primary stylesheet
\r
169 tinymce.each(doc.getElementsByTagName("link"), function(l) {
\r
170 var m = l.getAttribute('media', 2) || '', t = l.getAttribute('type', 2) || '';
\r
172 if (t == "-mce-text/css" && (m == "" || m == "screen" || m == "all") && (l.getAttribute('rel', 2) || '') == "stylesheet") {
\r
173 f.stylesheet.value = l.getAttribute('mce_href', 2) || '';
\r
178 // Get from style elements
\r
179 tinymce.each(doc.getElementsByTagName("style"), function(st) {
\r
180 var tmp = parseStyleElement(st);
\r
182 for (x=0; x<tmp.length; x++) {
\r
183 if (tmp[x].rule.indexOf('a:visited') != -1 && tmp[x].data['color'])
\r
184 f.visited_color.value = tmp[x].data['color'];
\r
186 if (tmp[x].rule.indexOf('a:link') != -1 && tmp[x].data['color'])
\r
187 f.link_color.value = tmp[x].data['color'];
\r
189 if (tmp[x].rule.indexOf('a:active') != -1 && tmp[x].data['color'])
\r
190 f.active_color.value = tmp[x].data['color'];
\r
194 f.textcolor.value = tinyMCEPopup.dom.getAttrib(doc.body, "text");
\r
195 f.active_color.value = tinyMCEPopup.dom.getAttrib(doc.body, "alink");
\r
196 f.link_color.value = tinyMCEPopup.dom.getAttrib(doc.body, "link");
\r
197 f.visited_color.value = tinyMCEPopup.dom.getAttrib(doc.body, "vlink");
\r
198 f.bgcolor.value = tinyMCEPopup.dom.getAttrib(doc.body, "bgcolor");
\r
199 f.bgimage.value = tinyMCEPopup.dom.getAttrib(doc.body, "background");
\r
201 // Get from style info
\r
202 style = tinyMCEPopup.dom.parseStyle(tinyMCEPopup.dom.getAttrib(doc.body, 'style'));
\r
204 if (style['font-family'])
\r
205 selectByValue(f, 'fontface', style['font-family'], true, true);
\r
207 selectByValue(f, 'fontface', ed.getParam("fullpage_default_fontface", ""), true, true);
\r
209 if (style['font-size'])
\r
210 selectByValue(f, 'fontsize', style['font-size'], true, true);
\r
212 selectByValue(f, 'fontsize', ed.getParam("fullpage_default_fontsize", ""), true, true);
\r
214 if (style['color'])
\r
215 f.textcolor.value = convertRGBToHex(style['color']);
\r
217 if (style['background-image'])
\r
218 f.bgimage.value = style['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
\r
220 if (style['background-color'])
\r
221 f.bgcolor.value = style['background-color'];
\r
223 if (style['margin']) {
\r
224 tmp = style['margin'].replace(/[^0-9 ]/g, '');
\r
225 tmp = tmp.split(/ +/);
\r
226 f.topmargin.value = tmp.length > 0 ? tmp[0] : '';
\r
227 f.rightmargin.value = tmp.length > 1 ? tmp[1] : tmp[0];
\r
228 f.bottommargin.value = tmp.length > 2 ? tmp[2] : tmp[0];
\r
229 f.leftmargin.value = tmp.length > 3 ? tmp[3] : tmp[0];
\r
232 if (style['margin-left'])
\r
233 f.leftmargin.value = style['margin-left'].replace(/[^0-9]/g, '');
\r
235 if (style['margin-right'])
\r
236 f.rightmargin.value = style['margin-right'].replace(/[^0-9]/g, '');
\r
238 if (style['margin-top'])
\r
239 f.topmargin.value = style['margin-top'].replace(/[^0-9]/g, '');
\r
241 if (style['margin-bottom'])
\r
242 f.bottommargin.value = style['margin-bottom'].replace(/[^0-9]/g, '');
\r
244 f.style.value = tinyMCEPopup.dom.serializeStyle(style);
\r
247 updateColor('textcolor_pick', 'textcolor');
\r
248 updateColor('bgcolor_pick', 'bgcolor');
\r
249 updateColor('visited_color_pick', 'visited_color');
\r
250 updateColor('active_color_pick', 'active_color');
\r
251 updateColor('link_color_pick', 'link_color');
\r
254 function getReItem(r, s, i) {
\r
257 if (c && c.length > i)
\r
263 function updateAction() {
\r
264 var f = document.forms[0], nl, i, h, v, s, head, html, l, tmp, addlink = true, ser;
\r
266 head = doc.getElementsByTagName('head')[0];
\r
268 // Fix scripts without a type
\r
269 nl = doc.getElementsByTagName('script');
\r
270 for (i=0; i<nl.length; i++) {
\r
271 if (tinyMCEPopup.dom.getAttrib(nl[i], 'mce_type') == '')
\r
272 nl[i].setAttribute('mce_type', 'text/javascript');
\r
275 // Get primary stylesheet
\r
276 nl = doc.getElementsByTagName("link");
\r
277 for (i=0; i<nl.length; i++) {
\r
280 tmp = tinyMCEPopup.dom.getAttrib(l, 'media');
\r
282 if (tinyMCEPopup.dom.getAttrib(l, 'mce_type') == "text/css" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCEPopup.dom.getAttrib(l, 'rel') == "stylesheet") {
\r
285 if (f.stylesheet.value == '')
\r
286 l.parentNode.removeChild(l);
\r
288 l.setAttribute('mce_href', f.stylesheet.value);
\r
295 if (f.stylesheet.value != '') {
\r
296 l = doc.createElement('link');
\r
298 l.setAttribute('type', 'text/css');
\r
299 l.setAttribute('mce_href', f.stylesheet.value);
\r
300 l.setAttribute('rel', 'stylesheet');
\r
302 head.appendChild(l);
\r
305 setMeta(head, 'keywords', f.metakeywords.value);
\r
306 setMeta(head, 'description', f.metadescription.value);
\r
307 setMeta(head, 'author', f.metaauthor.value);
\r
308 setMeta(head, 'copyright', f.metacopyright.value);
\r
309 setMeta(head, 'robots', getSelectValue(f, 'metarobots'));
\r
310 setMeta(head, 'Content-Type', getSelectValue(f, 'docencoding'));
\r
312 doc.body.dir = getSelectValue(f, 'langdir');
\r
313 doc.body.style.cssText = f.style.value;
\r
315 doc.body.setAttribute('vLink', f.visited_color.value);
\r
316 doc.body.setAttribute('link', f.link_color.value);
\r
317 doc.body.setAttribute('text', f.textcolor.value);
\r
318 doc.body.setAttribute('aLink', f.active_color.value);
\r
320 doc.body.style.fontFamily = getSelectValue(f, 'fontface');
\r
321 doc.body.style.fontSize = getSelectValue(f, 'fontsize');
\r
322 doc.body.style.backgroundColor = f.bgcolor.value;
\r
324 if (f.leftmargin.value != '')
\r
325 doc.body.style.marginLeft = f.leftmargin.value + 'px';
\r
327 if (f.rightmargin.value != '')
\r
328 doc.body.style.marginRight = f.rightmargin.value + 'px';
\r
330 if (f.bottommargin.value != '')
\r
331 doc.body.style.marginBottom = f.bottommargin.value + 'px';
\r
333 if (f.topmargin.value != '')
\r
334 doc.body.style.marginTop = f.topmargin.value + 'px';
\r
336 html = doc.getElementsByTagName('html')[0];
\r
337 html.setAttribute('lang', f.langcode.value);
\r
338 html.setAttribute('xml:lang', f.langcode.value);
\r
340 if (f.bgimage.value != '')
\r
341 doc.body.style.backgroundImage = "url('" + f.bgimage.value + "')";
\r
343 doc.body.style.backgroundImage = '';
\r
345 ser = tinyMCEPopup.editor.plugins.fullpage._createSerializer();
\r
346 ser.setRules('-title,meta[http-equiv|name|content],base[href|target],link[href|rel|type|title|media],style[type],script[type|language|src],html[lang|xml::lang|xmlns],body[style|dir|vlink|link|text|alink],head');
\r
348 h = ser.serialize(doc.documentElement);
\r
349 h = h.substring(0, h.lastIndexOf('</body>'));
\r
351 if (h.indexOf('<title>') == -1)
\r
352 h = h.replace(/<head.*?>/, '$&\n' + '<title>' + tinyMCEPopup.dom.encode(f.metatitle.value) + '</title>');
\r
354 h = h.replace(/<title>(.*?)<\/title>/, '<title>' + tinyMCEPopup.dom.encode(f.metatitle.value) + '</title>');
\r
356 if ((v = getSelectValue(f, 'doctypes')) != '')
\r
359 if (f.xml_pi.checked) {
\r
360 s = '<?xml version="1.0"';
\r
362 if ((v = getSelectValue(f, 'docencoding')) != '')
\r
363 s += ' encoding="' + v + '"';
\r
369 h = h.replace(/type=\"\-mce\-/gi, 'type="');
\r
371 tinyMCEPopup.editor.plugins.fullpage.head = h;
\r
372 tinyMCEPopup.editor.plugins.fullpage._setBodyAttribs(tinyMCEPopup.editor, {});
\r
373 tinyMCEPopup.close();
\r
376 function changedStyleField(field) {
\r
379 function setMeta(he, k, v) {
\r
382 nl = he.getElementsByTagName('meta');
\r
383 for (i=0; i<nl.length; i++) {
\r
384 if (k == 'Content-Type' && tinyMCEPopup.dom.getAttrib(nl[i], 'http-equiv') == k) {
\r
386 nl[i].parentNode.removeChild(nl[i]);
\r
388 nl[i].setAttribute('content', "text/html; charset=" + v);
\r
393 if (tinyMCEPopup.dom.getAttrib(nl[i], 'name') == k) {
\r
395 nl[i].parentNode.removeChild(nl[i]);
\r
397 nl[i].setAttribute('content', v);
\r
405 m = doc.createElement('meta');
\r
407 if (k == 'Content-Type')
\r
410 m.setAttribute('name', k);
\r
412 m.setAttribute('content', v);
\r
416 function parseStyleElement(e) {
\r
417 var v = e.innerHTML;
\r
420 v = v.replace(/<!--/gi, '');
\r
421 v = v.replace(/-->/gi, '');
\r
422 v = v.replace(/[\n\r]/gi, '');
\r
423 v = v.replace(/\s+/gi, ' ');
\r
426 p = v.split(/{|}/);
\r
428 for (i=0; i<p.length; i+=2) {
\r
430 r[r.length] = {rule : tinymce.trim(p[i]), data : tinyMCEPopup.dom.parseStyle(p[i+1])};
\r
436 function serializeStyleElement(d) {
\r
441 for (i=0; i<d.length; i++) {
\r
442 s += d[i].rule + ' {\n';
\r
444 st = tinyMCE.serializeStyle(d[i].data);
\r
449 s += st.replace(/;/g, ';\n');
\r
452 if (i != d.length - 1)
\r
461 tinyMCEPopup.onInit.add(init);
\r