3 var defaultDocTypes =
\r
4 '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
5 '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
6 '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
7 'XHTML 1.1=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">">,' +
\r
8 'HTML 4.01 Transitional=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">,' +
\r
9 'HTML 4.01 Strict=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">,' +
\r
10 'HTML 4.01 Frameset=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">';
\r
12 var defaultEncodings =
\r
13 'Western european (iso-8859-1)=iso-8859-1,' +
\r
14 'Central European (iso-8859-2)=iso-8859-2,' +
\r
15 'Unicode (UTF-8)=utf-8,' +
\r
16 'Chinese traditional (Big5)=big5,' +
\r
17 'Cyrillic (iso-8859-5)=iso-8859-5,' +
\r
18 'Japanese (iso-2022-jp)=iso-2022-jp,' +
\r
19 'Greek (iso-8859-7)=iso-8859-7,' +
\r
20 'Korean (iso-2022-kr)=iso-2022-kr,' +
\r
21 'ASCII (us-ascii)=us-ascii';
\r
23 var defaultMediaTypes =
\r
29 'projection=projection,' +
\r
30 'handheld=handheld,' +
\r
31 'braille=braille,' +
\r
34 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
35 var defaultFontSizes = '10px,11px,12px,13px,14px,15px,16px';
\r
37 var addMenuLayer = new MCLayer("addmenu");
\r
38 var lastElementType = null;
\r
42 var f = document.forms['fullpage'];
\r
43 var i, p, doctypes, encodings, mediaTypes, fonts;
\r
44 var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
\r
46 // Setup doctype select box
\r
47 doctypes = tinyMCE.getParam("fullpage_doctypes", defaultDocTypes).split(',');
\r
48 for (i=0; i<doctypes.length; i++) {
\r
49 p = doctypes[i].split('=');
\r
52 addSelectValue(f, 'doctypes', p[0], p[1]);
\r
55 // Setup fonts select box
\r
56 fonts = tinyMCE.getParam("fullpage_fonts", defaultFontNames).split(';');
\r
57 for (i=0; i<fonts.length; i++) {
\r
58 p = fonts[i].split('=');
\r
61 addSelectValue(f, 'fontface', p[0], p[1]);
\r
64 // Setup fontsize select box
\r
65 fonts = tinyMCE.getParam("fullpage_fontsizes", defaultFontSizes).split(',');
\r
66 for (i=0; i<fonts.length; i++)
\r
67 addSelectValue(f, 'fontsize', fonts[i], fonts[i]);
\r
69 // Setup mediatype select boxs
\r
70 mediaTypes = tinyMCE.getParam("fullpage_media_types", defaultMediaTypes).split(',');
\r
71 for (i=0; i<mediaTypes.length; i++) {
\r
72 p = mediaTypes[i].split('=');
\r
75 addSelectValue(f, 'element_style_media', p[0], p[1]);
\r
76 addSelectValue(f, 'element_link_media', p[0], p[1]);
\r
80 // Setup encodings select box
\r
81 encodings = tinyMCE.getParam("fullpage_encodings", defaultEncodings).split(',');
\r
82 for (i=0; i<encodings.length; i++) {
\r
83 p = encodings[i].split('=');
\r
86 addSelectValue(f, 'docencoding', p[0], p[1]);
\r
87 addSelectValue(f, 'element_script_charset', p[0], p[1]);
\r
88 addSelectValue(f, 'element_link_charset', p[0], p[1]);
\r
92 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
\r
93 document.getElementById('link_color_pickcontainer').innerHTML = getColorPickerHTML('link_color_pick','link_color');
\r
94 //document.getElementById('hover_color_pickcontainer').innerHTML = getColorPickerHTML('hover_color_pick','hover_color');
\r
95 document.getElementById('visited_color_pickcontainer').innerHTML = getColorPickerHTML('visited_color_pick','visited_color');
\r
96 document.getElementById('active_color_pickcontainer').innerHTML = getColorPickerHTML('active_color_pick','active_color');
\r
97 document.getElementById('textcolor_pickcontainer').innerHTML = getColorPickerHTML('textcolor_pick','textcolor');
\r
98 document.getElementById('stylesheet_browsercontainer').innerHTML = getBrowserHTML('stylesheetbrowser','stylesheet','file','fullpage');
\r
99 document.getElementById('link_href_pickcontainer').innerHTML = getBrowserHTML('link_href_browser','element_link_href','file','fullpage');
\r
100 document.getElementById('script_src_pickcontainer').innerHTML = getBrowserHTML('script_src_browser','element_script_src','file','fullpage');
\r
101 document.getElementById('bgimage_pickcontainer').innerHTML = getBrowserHTML('bgimage_browser','bgimage','image','fullpage');
\r
103 // Resize some elements
\r
104 if (isVisible('stylesheetbrowser'))
\r
105 document.getElementById('stylesheet').style.width = '220px';
\r
107 if (isVisible('link_href_browser'))
\r
108 document.getElementById('element_link_href').style.width = '230px';
\r
110 if (isVisible('bgimage_browser'))
\r
111 document.getElementById('bgimage').style.width = '210px';
\r
114 var iframe = document.createElement('iframe');
\r
116 iframe.id = 'tempFrame';
\r
117 iframe.style.display = 'none';
\r
118 iframe.src = tinyMCE.baseURL + "/plugins/fullpage/blank.htm";
\r
120 document.body.appendChild(iframe);
\r
122 tinyMCEPopup.resizeToInnerSize();
\r
125 function setupIframe(doc) {
\r
126 var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
\r
127 var hc = inst.fullpageTopContent;
\r
128 var f = document.forms[0];
\r
129 var xmlVer, xmlEnc, docType;
\r
130 var nodes, i, x, name, value, tmp, l;
\r
132 // Keep it from not loading/executing stuff
\r
133 hc = hc.replace(/<script>/gi, '<script type="text/javascript">');
\r
134 hc = hc.replace(/\ssrc=/gi, " mce_src=");
\r
135 hc = hc.replace(/\shref=/gi, " mce_href=");
\r
136 hc = hc.replace(/\stype=/gi, " mce_type=");
\r
137 hc = hc.replace(/<script/gi, '<script type="text/unknown" ');
\r
139 // Add end to make it DOM parseable
\r
140 hc += '</body></html>';
\r
147 // ------- Setup options for genral tab
\r
149 // Parse xml and doctype
\r
150 xmlVer = getReItem(/<\?\s*?xml.*?version\s*?=\s*?"(.*?)".*?\?>/gi, hc, 1);
\r
151 xmlEnc = getReItem(/<\?\s*?xml.*?encoding\s*?=\s*?"(.*?)".*?\?>/gi, hc, 1);
\r
152 docType = getReItem(/<\!DOCTYPE.*?>/gi, hc, 0);
\r
153 f.langcode.value = getReItem(/lang="(.*?)"/gi, hc, 1);
\r
156 f.metatitle.value = tinyMCE.entityDecode(getReItem(/<title>(.*?)<\/title>/gi, hc, 1));
\r
158 // Check for meta encoding
\r
159 nodes = doc.getElementsByTagName("meta");
\r
160 for (i=0; i<nodes.length; i++) {
\r
161 name = tinyMCE.getAttrib(nodes[i], 'name');
\r
162 value = tinyMCE.getAttrib(nodes[i], 'content');
\r
163 httpEquiv = tinyMCE.getAttrib(nodes[i], 'httpEquiv');
\r
165 switch (name.toLowerCase()) {
\r
167 f.metakeywords.value = value;
\r
170 case "description":
\r
171 f.metadescription.value = value;
\r
175 f.metaauthor.value = value;
\r
179 f.metacopyright.value = value;
\r
183 selectByValue(f, 'metarobots', value, true, true);
\r
187 switch (httpEquiv.toLowerCase()) {
\r
188 case "content-type":
\r
189 tmp = getReItem(/charset\s*=\s*(.*)\s*/gi, value, 1);
\r
191 // Override XML encoding
\r
199 selectByValue(f, 'doctypes', docType, true, true);
\r
200 selectByValue(f, 'docencoding', xmlEnc, true, true);
\r
201 selectByValue(f, 'langdir', tinyMCE.getAttrib(doc.body, 'dir'), true, true);
\r
204 f.xml_pi.checked = true;
\r
206 // ------- Setup options for appearance tab
\r
208 // Get primary stylesheet
\r
209 nodes = doc.getElementsByTagName("link");
\r
210 for (i=0; i<nodes.length; i++) {
\r
212 tmp = tinyMCE.getAttrib(l, 'media');
\r
214 if (tinyMCE.getAttrib(l, 'mce_type') == "text/css" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCE.getAttrib(l, 'rel') == "stylesheet") {
\r
215 f.stylesheet.value = tinyMCE.getAttrib(l, 'mce_href');
\r
220 // Get from style elements
\r
221 nodes = doc.getElementsByTagName("style");
\r
222 for (i=0; i<nodes.length; i++) {
\r
223 tmp = parseStyleElement(nodes[i]);
\r
225 for (x=0; x<tmp.length; x++) {
\r
226 // if (tmp[x].rule.indexOf('a:hover') != -1 && tmp[x].data['color'])
\r
227 // f.hover_color.value = tmp[x].data['color'];
\r
229 if (tmp[x].rule.indexOf('a:visited') != -1 && tmp[x].data['color'])
\r
230 f.visited_color.value = tmp[x].data['color'];
\r
232 if (tmp[x].rule.indexOf('a:link') != -1 && tmp[x].data['color'])
\r
233 f.link_color.value = tmp[x].data['color'];
\r
235 if (tmp[x].rule.indexOf('a:active') != -1 && tmp[x].data['color'])
\r
236 f.active_color.value = tmp[x].data['color'];
\r
240 // Get from body attribs
\r
242 /* f.leftmargin.value = tinyMCE.getAttrib(doc.body, "leftmargin");
\r
243 f.rightmargin.value = tinyMCE.getAttrib(doc.body, "rightmargin");
\r
244 f.topmargin.value = tinyMCE.getAttrib(doc.body, "topmargin");
\r
245 f.bottommargin.value = tinyMCE.getAttrib(doc.body, "bottommargin");*/
\r
246 f.textcolor.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "text"));
\r
247 f.active_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "alink"));
\r
248 f.link_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "link"));
\r
249 f.visited_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "vlink"));
\r
250 f.bgcolor.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "bgcolor"));
\r
251 f.bgimage.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "background"));
\r
253 // Get from style info
\r
254 var style = tinyMCE.parseStyle(tinyMCE.getAttrib(doc.body, 'style'));
\r
256 if (style['font-family'])
\r
257 selectByValue(f, 'fontface', style['font-family'], true, true);
\r
259 selectByValue(f, 'fontface', tinyMCE.getParam("fullpage_default_fontface", ""), true, true);
\r
261 if (style['font-size'])
\r
262 selectByValue(f, 'fontsize', style['font-size'], true, true);
\r
264 selectByValue(f, 'fontsize', tinyMCE.getParam("fullpage_default_fontsize", ""), true, true);
\r
266 if (style['color'])
\r
267 f.textcolor.value = convertRGBToHex(style['color']);
\r
269 if (style['background-image'])
\r
270 f.bgimage.value = style['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1");
\r
272 if (style['background-color'])
\r
273 f.bgcolor.value = convertRGBToHex(style['background-color']);
\r
275 if (style['margin']) {
\r
276 tmp = style['margin'].replace(/[^0-9 ]/g, '');
\r
277 tmp = tmp.split(/ +/);
\r
278 f.topmargin.value = tmp.length > 0 ? tmp[0] : '';
\r
279 f.rightmargin.value = tmp.length > 1 ? tmp[1] : tmp[0];
\r
280 f.bottommargin.value = tmp.length > 2 ? tmp[2] : tmp[0];
\r
281 f.leftmargin.value = tmp.length > 3 ? tmp[3] : tmp[0];
\r
284 if (style['margin-left'])
\r
285 f.leftmargin.value = style['margin-left'].replace(/[^0-9]/g, '');
\r
287 if (style['margin-right'])
\r
288 f.rightmargin.value = style['margin-right'].replace(/[^0-9]/g, '');
\r
290 if (style['margin-top'])
\r
291 f.topmargin.value = style['margin-top'].replace(/[^0-9]/g, '');
\r
293 if (style['margin-bottom'])
\r
294 f.bottommargin.value = style['margin-bottom'].replace(/[^0-9]/g, '');
\r
296 f.style.value = tinyMCE.serializeStyle(style);
\r
298 updateColor('textcolor_pick', 'textcolor');
\r
299 updateColor('bgcolor_pick', 'bgcolor');
\r
300 updateColor('visited_color_pick', 'visited_color');
\r
301 updateColor('active_color_pick', 'active_color');
\r
302 updateColor('link_color_pick', 'link_color');
\r
303 //updateColor('hover_color_pick', 'hover_color');
\r
306 function updateAction() {
\r
307 var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id'));
\r
308 var f = document.forms[0];
\r
309 var nl, i, h, v, s, head, html, l, tmp, addlink = true;
\r
311 head = topDoc.getElementsByTagName('head')[0];
\r
313 // Fix scripts without a type
\r
314 nl = topDoc.getElementsByTagName('script');
\r
315 for (i=0; i<nl.length; i++) {
\r
316 if (tinyMCE.getAttrib(nl[i], 'mce_type') == '')
\r
317 nl[i].setAttribute('mce_type', 'text/javascript');
\r
320 // Get primary stylesheet
\r
321 nl = topDoc.getElementsByTagName("link");
\r
322 for (i=0; i<nl.length; i++) {
\r
325 tmp = tinyMCE.getAttrib(l, 'media');
\r
327 if (tinyMCE.getAttrib(l, 'mce_type') == "text/css" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCE.getAttrib(l, 'rel') == "stylesheet") {
\r
330 if (f.stylesheet.value == '')
\r
331 l.parentNode.removeChild(l);
\r
333 l.setAttribute('mce_href', f.stylesheet.value);
\r
340 if (f.stylesheet.value != '') {
\r
341 l = topDoc.createElement('link');
\r
343 l.setAttribute('mce_type', 'text/css');
\r
344 l.setAttribute('mce_href', f.stylesheet.value);
\r
345 l.setAttribute('rel', 'stylesheet');
\r
347 head.appendChild(l);
\r
350 setMeta(head, 'keywords', f.metakeywords.value);
\r
351 setMeta(head, 'description', f.metadescription.value);
\r
352 setMeta(head, 'author', f.metaauthor.value);
\r
353 setMeta(head, 'copyright', f.metacopyright.value);
\r
354 setMeta(head, 'robots', getSelectValue(f, 'metarobots'));
\r
355 setMeta(head, 'Content-Type', getSelectValue(f, 'docencoding'));
\r
357 topDoc.body.dir = getSelectValue(f, 'langdir');
\r
358 topDoc.body.style.cssText = f.style.value;
\r
360 topDoc.body.setAttribute('vLink', f.visited_color.value);
\r
361 topDoc.body.setAttribute('link', f.link_color.value);
\r
362 topDoc.body.setAttribute('text', f.textcolor.value);
\r
363 topDoc.body.setAttribute('aLink', f.active_color.value);
\r
365 topDoc.body.style.fontFamily = getSelectValue(f, 'fontface');
\r
366 topDoc.body.style.fontSize = getSelectValue(f, 'fontsize');
\r
367 topDoc.body.style.backgroundColor = f.bgcolor.value;
\r
369 if (f.leftmargin.value != '')
\r
370 topDoc.body.style.marginLeft = f.leftmargin.value + 'px';
\r
372 if (f.rightmargin.value != '')
\r
373 topDoc.body.style.marginRight = f.rightmargin.value + 'px';
\r
375 if (f.bottommargin.value != '')
\r
376 topDoc.body.style.marginBottom = f.bottommargin.value + 'px';
\r
378 if (f.topmargin.value != '')
\r
379 topDoc.body.style.marginTop = f.topmargin.value + 'px';
\r
381 html = topDoc.getElementsByTagName('html')[0];
\r
382 html.setAttribute('lang', f.langcode.value);
\r
383 html.setAttribute('xml:lang', f.langcode.value);
\r
385 if (f.bgimage.value != '')
\r
386 topDoc.body.style.backgroundImage = "url('" + f.bgimage.value + "')";
\r
388 topDoc.body.style.backgroundImage = '';
\r
390 inst.cleanup.addRuleStr('-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
392 h = inst.cleanup.serializeNodeAsHTML(topDoc.documentElement);
\r
394 h = h.substring(0, h.lastIndexOf('</body>'));
\r
396 if (h.indexOf('<title>') == -1)
\r
397 h = h.replace(/<head.*?>/, '$&\n' + '<title>' + inst.cleanup.xmlEncode(f.metatitle.value) + '</title>');
\r
399 h = h.replace(/<title>(.*?)<\/title>/, '<title>' + inst.cleanup.xmlEncode(f.metatitle.value) + '</title>');
\r
401 if ((v = getSelectValue(f, 'doctypes')) != '')
\r
404 if (f.xml_pi.checked) {
\r
405 s = '<?xml version="1.0"';
\r
407 if ((v = getSelectValue(f, 'docencoding')) != '')
\r
408 s += ' encoding="' + v + '"';
\r
414 inst.fullpageTopContent = h;
\r
416 tinyMCEPopup.execCommand('mceFullPageUpdate', false, '');
\r
417 tinyMCEPopup.close();
\r
420 function setMeta(he, k, v) {
\r
423 nl = he.getElementsByTagName('meta');
\r
424 for (i=0; i<nl.length; i++) {
\r
425 if (k == 'Content-Type' && tinyMCE.getAttrib(nl[i], 'http-equiv') == k) {
\r
427 nl[i].parentNode.removeChild(nl[i]);
\r
429 nl[i].setAttribute('content', "text/html; charset=" + v);
\r
434 if (tinyMCE.getAttrib(nl[i], 'name') == k) {
\r
436 nl[i].parentNode.removeChild(nl[i]);
\r
438 nl[i].setAttribute('content', v);
\r
446 m = topDoc.createElement('meta');
\r
448 if (k == 'Content-Type')
\r
451 m.setAttribute('name', k);
\r
453 m.setAttribute('content', v);
\r
457 function parseStyleElement(e) {
\r
458 var v = e.innerHTML;
\r
461 v = v.replace(/<!--/gi, '');
\r
462 v = v.replace(/-->/gi, '');
\r
463 v = v.replace(/[\n\r]/gi, '');
\r
464 v = v.replace(/\s+/gi, ' ');
\r
467 p = v.split(/{|}/);
\r
469 for (i=0; i<p.length; i+=2) {
\r
471 r[r.length] = {rule : tinyMCE.trim(p[i]), data : tinyMCE.parseStyle(p[i+1])};
\r
477 function serializeStyleElement(d) {
\r
482 for (i=0; i<d.length; i++) {
\r
483 s += d[i].rule + ' {\n';
\r
485 st = tinyMCE.serializeStyle(d[i].data);
\r
490 s += st.replace(/;/g, ';\n');
\r
493 if (i != d.length - 1)
\r
502 function getReItem(r, s, i) {
\r
505 if (c && c.length > i)
\r
511 function changedStyleField(field) {
\r
515 function showAddMenu() {
\r
516 var re = document.getElementById('addbutton');
\r
518 addMenuLayer.moveRelativeTo(re, 'tr');
\r
519 if (addMenuLayer.isMSIE)
\r
520 addMenuLayer.moveBy(2, 0);
\r
522 addMenuLayer.show();
\r
523 addMenuLayer.setAutoHide(true, hideAddMenu);
\r
524 addMenuLayer.addCSSClass(re, 'selected');
\r
527 function hideAddMenu(l, e, mx, my) {
\r
528 var re = document.getElementById('addbutton');
\r
529 addMenuLayer.removeCSSClass(re, 'selected');
\r
532 function addHeadElm(type) {
\r
533 var le = document.getElementById('headlist');
\r
534 var re = document.getElementById('addbutton');
\r
535 var te = document.getElementById(type + '_element');
\r
537 if (lastElementType)
\r
538 lastElementType.style.display = 'none';
\r
540 te.style.display = 'block';
\r
542 lastElementType = te;
\r
544 addMenuLayer.hide();
\r
545 addMenuLayer.removeCSSClass(re, 'selected');
\r
547 document.getElementById(type + '_updateelement').value = tinyMCE.getLang('lang_insert', 'Insert', true);
\r
552 function updateHeadElm(item) {
\r
553 var type = item.substring(0, item.indexOf('_'));
\r
554 var le = document.getElementById('headlist');
\r
555 var re = document.getElementById('addbutton');
\r
556 var te = document.getElementById(type + '_element');
\r
558 if (lastElementType)
\r
559 lastElementType.style.display = 'none';
\r
561 te.style.display = 'block';
\r
563 lastElementType = te;
\r
565 addMenuLayer.hide();
\r
566 addMenuLayer.removeCSSClass(re, 'selected');
\r
568 document.getElementById(type + '_updateelement').value = tinyMCE.getLang('lang_update', 'Update', true);
\r
573 function cancelElementUpdate() {
\r
574 var le = document.getElementById('headlist');
\r
576 if (lastElementType)
\r
577 lastElementType.style.display = 'none';
\r