[ Index ] |
|
Code source de Seagull 0.6.1 |
1 // 2 3 var defaultDocTypes = 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">,' + 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">,' + 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">,' + 7 'XHTML 1.1=<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">">,' + 8 'HTML 4.01 Transitional=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">,' + 9 'HTML 4.01 Strict=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">,' + 10 'HTML 4.01 Frameset=<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'; 11 12 var defaultEncodings = 13 'Western european (iso-8859-1)=iso-8859-1,' + 14 'Central European (iso-8859-2)=iso-8859-2,' + 15 'Unicode (UTF-8)=utf-8,' + 16 'Chinese traditional (Big5)=big5,' + 17 'Cyrillic (iso-8859-5)=iso-8859-5,' + 18 'Japanese (iso-2022-jp)=iso-2022-jp,' + 19 'Greek (iso-8859-7)=iso-8859-7,' + 20 'Korean (iso-2022-kr)=iso-2022-kr,' + 21 'ASCII (us-ascii)=us-ascii'; 22 23 var defaultMediaTypes = 24 'all=all,' + 25 'screen=screen,' + 26 'print=print,' + 27 'tty=tty,' + 28 'tv=tv,' + 29 'projection=projection,' + 30 'handheld=handheld,' + 31 'braille=braille,' + 32 'aural=aural'; 33 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'; 35 var defaultFontSizes = '10px,11px,12px,13px,14px,15px,16px'; 36 37 var addMenuLayer = new MCLayer("addmenu"); 38 var lastElementType = null; 39 var topDoc; 40 41 function init() { 42 var f = document.forms['fullpage']; 43 var i, p, doctypes, encodings, mediaTypes, fonts; 44 var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); 45 46 // Setup doctype select box 47 doctypes = tinyMCE.getParam("fullpage_doctypes", defaultDocTypes).split(','); 48 for (i=0; i<doctypes.length; i++) { 49 p = doctypes[i].split('='); 50 51 if (p.length > 1) 52 addSelectValue(f, 'doctypes', p[0], p[1]); 53 } 54 55 // Setup fonts select box 56 fonts = tinyMCE.getParam("fullpage_fonts", defaultFontNames).split(';'); 57 for (i=0; i<fonts.length; i++) { 58 p = fonts[i].split('='); 59 60 if (p.length > 1) 61 addSelectValue(f, 'fontface', p[0], p[1]); 62 } 63 64 // Setup fontsize select box 65 fonts = tinyMCE.getParam("fullpage_fontsizes", defaultFontSizes).split(','); 66 for (i=0; i<fonts.length; i++) 67 addSelectValue(f, 'fontsize', fonts[i], fonts[i]); 68 69 // Setup mediatype select boxs 70 mediaTypes = tinyMCE.getParam("fullpage_media_types", defaultMediaTypes).split(','); 71 for (i=0; i<mediaTypes.length; i++) { 72 p = mediaTypes[i].split('='); 73 74 if (p.length > 1) { 75 addSelectValue(f, 'element_style_media', p[0], p[1]); 76 addSelectValue(f, 'element_link_media', p[0], p[1]); 77 } 78 } 79 80 // Setup encodings select box 81 encodings = tinyMCE.getParam("fullpage_encodings", defaultEncodings).split(','); 82 for (i=0; i<encodings.length; i++) { 83 p = encodings[i].split('='); 84 85 if (p.length > 1) { 86 addSelectValue(f, 'docencoding', p[0], p[1]); 87 addSelectValue(f, 'element_script_charset', p[0], p[1]); 88 addSelectValue(f, 'element_link_charset', p[0], p[1]); 89 } 90 } 91 92 document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor'); 93 document.getElementById('link_color_pickcontainer').innerHTML = getColorPickerHTML('link_color_pick','link_color'); 94 //document.getElementById('hover_color_pickcontainer').innerHTML = getColorPickerHTML('hover_color_pick','hover_color'); 95 document.getElementById('visited_color_pickcontainer').innerHTML = getColorPickerHTML('visited_color_pick','visited_color'); 96 document.getElementById('active_color_pickcontainer').innerHTML = getColorPickerHTML('active_color_pick','active_color'); 97 document.getElementById('textcolor_pickcontainer').innerHTML = getColorPickerHTML('textcolor_pick','textcolor'); 98 document.getElementById('stylesheet_browsercontainer').innerHTML = getBrowserHTML('stylesheetbrowser','stylesheet','file','fullpage'); 99 document.getElementById('link_href_pickcontainer').innerHTML = getBrowserHTML('link_href_browser','element_link_href','file','fullpage'); 100 document.getElementById('script_src_pickcontainer').innerHTML = getBrowserHTML('script_src_browser','element_script_src','file','fullpage'); 101 document.getElementById('bgimage_pickcontainer').innerHTML = getBrowserHTML('bgimage_browser','bgimage','image','fullpage'); 102 103 // Resize some elements 104 if (isVisible('stylesheetbrowser')) 105 document.getElementById('stylesheet').style.width = '220px'; 106 107 if (isVisible('link_href_browser')) 108 document.getElementById('element_link_href').style.width = '230px'; 109 110 if (isVisible('bgimage_browser')) 111 document.getElementById('bgimage').style.width = '210px'; 112 113 // Create iframe 114 var iframe = document.createElement('iframe'); 115 116 iframe.id = 'tempFrame'; 117 iframe.style.display = 'none'; 118 iframe.src = tinyMCE.baseURL + "/plugins/fullpage/blank.htm"; 119 120 document.body.appendChild(iframe); 121 122 tinyMCEPopup.resizeToInnerSize(); 123 } 124 125 function setupIframe(doc) { 126 var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); 127 var hc = inst.fullpageTopContent; 128 var f = document.forms[0]; 129 var xmlVer, xmlEnc, docType; 130 var nodes, i, x, name, value, tmp, l; 131 132 // Keep it from not loading/executing stuff 133 hc = hc.replace(/<script>/gi, '<script type="text/javascript">'); 134 hc = hc.replace(/\ssrc=/gi, " mce_src="); 135 hc = hc.replace(/\shref=/gi, " mce_href="); 136 hc = hc.replace(/\stype=/gi, " mce_type="); 137 hc = hc.replace(/<script/gi, '<script type="text/unknown" '); 138 139 // Add end to make it DOM parseable 140 hc += '</body></html>'; 141 142 topDoc = doc; 143 doc.open(); 144 doc.write(hc); 145 doc.close(); 146 147 // ------- Setup options for genral tab 148 149 // Parse xml and doctype 150 xmlVer = getReItem(/<\?\s*?xml.*?version\s*?=\s*?"(.*?)".*?\?>/gi, hc, 1); 151 xmlEnc = getReItem(/<\?\s*?xml.*?encoding\s*?=\s*?"(.*?)".*?\?>/gi, hc, 1); 152 docType = getReItem(/<\!DOCTYPE.*?>/gi, hc, 0); 153 f.langcode.value = getReItem(/lang="(.*?)"/gi, hc, 1); 154 155 // Get title 156 f.metatitle.value = tinyMCE.entityDecode(getReItem(/<title>(.*?)<\/title>/gi, hc, 1)); 157 158 // Check for meta encoding 159 nodes = doc.getElementsByTagName("meta"); 160 for (i=0; i<nodes.length; i++) { 161 name = tinyMCE.getAttrib(nodes[i], 'name'); 162 value = tinyMCE.getAttrib(nodes[i], 'content'); 163 httpEquiv = tinyMCE.getAttrib(nodes[i], 'httpEquiv'); 164 165 switch (name.toLowerCase()) { 166 case "keywords": 167 f.metakeywords.value = value; 168 break; 169 170 case "description": 171 f.metadescription.value = value; 172 break; 173 174 case "author": 175 f.metaauthor.value = value; 176 break; 177 178 case "copyright": 179 f.metacopyright.value = value; 180 break; 181 182 case "robots": 183 selectByValue(f, 'metarobots', value, true, true); 184 break; 185 } 186 187 switch (httpEquiv.toLowerCase()) { 188 case "content-type": 189 tmp = getReItem(/charset\s*=\s*(.*)\s*/gi, value, 1); 190 191 // Override XML encoding 192 if (tmp != "") 193 xmlEnc = tmp; 194 195 break; 196 } 197 } 198 199 selectByValue(f, 'doctypes', docType, true, true); 200 selectByValue(f, 'docencoding', xmlEnc, true, true); 201 selectByValue(f, 'langdir', tinyMCE.getAttrib(doc.body, 'dir'), true, true); 202 203 if (xmlVer != '') 204 f.xml_pi.checked = true; 205 206 // ------- Setup options for appearance tab 207 208 // Get primary stylesheet 209 nodes = doc.getElementsByTagName("link"); 210 for (i=0; i<nodes.length; i++) { 211 l = nodes[i]; 212 tmp = tinyMCE.getAttrib(l, 'media'); 213 214 if (tinyMCE.getAttrib(l, 'mce_type') == "text/css" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCE.getAttrib(l, 'rel') == "stylesheet") { 215 f.stylesheet.value = tinyMCE.getAttrib(l, 'mce_href'); 216 break; 217 } 218 } 219 220 // Get from style elements 221 nodes = doc.getElementsByTagName("style"); 222 for (i=0; i<nodes.length; i++) { 223 tmp = parseStyleElement(nodes[i]); 224 225 for (x=0; x<tmp.length; x++) { 226 // if (tmp[x].rule.indexOf('a:hover') != -1 && tmp[x].data['color']) 227 // f.hover_color.value = tmp[x].data['color']; 228 229 if (tmp[x].rule.indexOf('a:visited') != -1 && tmp[x].data['color']) 230 f.visited_color.value = tmp[x].data['color']; 231 232 if (tmp[x].rule.indexOf('a:link') != -1 && tmp[x].data['color']) 233 f.link_color.value = tmp[x].data['color']; 234 235 if (tmp[x].rule.indexOf('a:active') != -1 && tmp[x].data['color']) 236 f.active_color.value = tmp[x].data['color']; 237 } 238 } 239 240 // Get from body attribs 241 242 /* f.leftmargin.value = tinyMCE.getAttrib(doc.body, "leftmargin"); 243 f.rightmargin.value = tinyMCE.getAttrib(doc.body, "rightmargin"); 244 f.topmargin.value = tinyMCE.getAttrib(doc.body, "topmargin"); 245 f.bottommargin.value = tinyMCE.getAttrib(doc.body, "bottommargin");*/ 246 f.textcolor.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "text")); 247 f.active_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "alink")); 248 f.link_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "link")); 249 f.visited_color.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "vlink")); 250 f.bgcolor.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "bgcolor")); 251 f.bgimage.value = convertRGBToHex(tinyMCE.getAttrib(doc.body, "background")); 252 253 // Get from style info 254 var style = tinyMCE.parseStyle(tinyMCE.getAttrib(doc.body, 'style')); 255 256 if (style['font-family']) 257 selectByValue(f, 'fontface', style['font-family'], true, true); 258 else 259 selectByValue(f, 'fontface', tinyMCE.getParam("fullpage_default_fontface", ""), true, true); 260 261 if (style['font-size']) 262 selectByValue(f, 'fontsize', style['font-size'], true, true); 263 else 264 selectByValue(f, 'fontsize', tinyMCE.getParam("fullpage_default_fontsize", ""), true, true); 265 266 if (style['color']) 267 f.textcolor.value = convertRGBToHex(style['color']); 268 269 if (style['background-image']) 270 f.bgimage.value = style['background-image'].replace(new RegExp("url\\('?([^']*)'?\\)", 'gi'), "$1"); 271 272 if (style['background-color']) 273 f.bgcolor.value = convertRGBToHex(style['background-color']); 274 275 if (style['margin']) { 276 tmp = style['margin'].replace(/[^0-9 ]/g, ''); 277 tmp = tmp.split(/ +/); 278 f.topmargin.value = tmp.length > 0 ? tmp[0] : ''; 279 f.rightmargin.value = tmp.length > 1 ? tmp[1] : tmp[0]; 280 f.bottommargin.value = tmp.length > 2 ? tmp[2] : tmp[0]; 281 f.leftmargin.value = tmp.length > 3 ? tmp[3] : tmp[0]; 282 } 283 284 if (style['margin-left']) 285 f.leftmargin.value = style['margin-left'].replace(/[^0-9]/g, ''); 286 287 if (style['margin-right']) 288 f.rightmargin.value = style['margin-right'].replace(/[^0-9]/g, ''); 289 290 if (style['margin-top']) 291 f.topmargin.value = style['margin-top'].replace(/[^0-9]/g, ''); 292 293 if (style['margin-bottom']) 294 f.bottommargin.value = style['margin-bottom'].replace(/[^0-9]/g, ''); 295 296 f.style.value = tinyMCE.serializeStyle(style); 297 298 updateColor('textcolor_pick', 'textcolor'); 299 updateColor('bgcolor_pick', 'bgcolor'); 300 updateColor('visited_color_pick', 'visited_color'); 301 updateColor('active_color_pick', 'active_color'); 302 updateColor('link_color_pick', 'link_color'); 303 //updateColor('hover_color_pick', 'hover_color'); 304 } 305 306 function updateAction() { 307 var inst = tinyMCE.getInstanceById(tinyMCE.getWindowArg('editor_id')); 308 var f = document.forms[0]; 309 var nl, i, h, v, s, head, html, l, tmp, addlink = true; 310 311 head = topDoc.getElementsByTagName('head')[0]; 312 313 // Fix scripts without a type 314 nl = topDoc.getElementsByTagName('script'); 315 for (i=0; i<nl.length; i++) { 316 if (tinyMCE.getAttrib(nl[i], 'mce_type') == '') 317 nl[i].setAttribute('mce_type', 'text/javascript'); 318 } 319 320 // Get primary stylesheet 321 nl = topDoc.getElementsByTagName("link"); 322 for (i=0; i<nl.length; i++) { 323 l = nl[i]; 324 325 tmp = tinyMCE.getAttrib(l, 'media'); 326 327 if (tinyMCE.getAttrib(l, 'mce_type') == "text/css" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCE.getAttrib(l, 'rel') == "stylesheet") { 328 addlink = false; 329 330 if (f.stylesheet.value == '') 331 l.parentNode.removeChild(l); 332 else 333 l.setAttribute('mce_href', f.stylesheet.value); 334 335 break; 336 } 337 } 338 339 // Add new link 340 if (f.stylesheet.value != '') { 341 l = topDoc.createElement('link'); 342 343 l.setAttribute('mce_type', 'text/css'); 344 l.setAttribute('mce_href', f.stylesheet.value); 345 l.setAttribute('rel', 'stylesheet'); 346 347 head.appendChild(l); 348 } 349 350 setMeta(head, 'keywords', f.metakeywords.value); 351 setMeta(head, 'description', f.metadescription.value); 352 setMeta(head, 'author', f.metaauthor.value); 353 setMeta(head, 'copyright', f.metacopyright.value); 354 setMeta(head, 'robots', getSelectValue(f, 'metarobots')); 355 setMeta(head, 'Content-Type', getSelectValue(f, 'docencoding')); 356 357 topDoc.body.dir = getSelectValue(f, 'langdir'); 358 topDoc.body.style.cssText = f.style.value; 359 360 topDoc.body.setAttribute('vLink', f.visited_color.value); 361 topDoc.body.setAttribute('link', f.link_color.value); 362 topDoc.body.setAttribute('text', f.textcolor.value); 363 topDoc.body.setAttribute('aLink', f.active_color.value); 364 365 topDoc.body.style.fontFamily = getSelectValue(f, 'fontface'); 366 topDoc.body.style.fontSize = getSelectValue(f, 'fontsize'); 367 topDoc.body.style.backgroundColor = f.bgcolor.value; 368 369 if (f.leftmargin.value != '') 370 topDoc.body.style.marginLeft = f.leftmargin.value + 'px'; 371 372 if (f.rightmargin.value != '') 373 topDoc.body.style.marginRight = f.rightmargin.value + 'px'; 374 375 if (f.bottommargin.value != '') 376 topDoc.body.style.marginBottom = f.bottommargin.value + 'px'; 377 378 if (f.topmargin.value != '') 379 topDoc.body.style.marginTop = f.topmargin.value + 'px'; 380 381 html = topDoc.getElementsByTagName('html')[0]; 382 html.setAttribute('lang', f.langcode.value); 383 html.setAttribute('xml:lang', f.langcode.value); 384 385 if (f.bgimage.value != '') 386 topDoc.body.style.backgroundImage = "url('" + f.bgimage.value + "')"; 387 else 388 topDoc.body.style.backgroundImage = ''; 389 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'); 391 392 h = inst.cleanup.serializeNodeAsHTML(topDoc.documentElement); 393 394 h = h.substring(0, h.lastIndexOf('</body>')); 395 396 if (h.indexOf('<title>') == -1) 397 h = h.replace(/<head.*?>/, '$&\n' + '<title>' + inst.cleanup.xmlEncode(f.metatitle.value) + '</title>'); 398 else 399 h = h.replace(/<title>(.*?)<\/title>/, '<title>' + inst.cleanup.xmlEncode(f.metatitle.value) + '</title>'); 400 401 if ((v = getSelectValue(f, 'doctypes')) != '') 402 h = v + '\n' + h; 403 404 if (f.xml_pi.checked) { 405 s = '<?xml version="1.0"'; 406 407 if ((v = getSelectValue(f, 'docencoding')) != '') 408 s += ' encoding="' + v + '"'; 409 410 s += '?>\n'; 411 h = s + h; 412 } 413 414 inst.fullpageTopContent = h; 415 416 tinyMCEPopup.execCommand('mceFullPageUpdate', false, ''); 417 tinyMCEPopup.close(); 418 } 419 420 function setMeta(he, k, v) { 421 var nl, i, m; 422 423 nl = he.getElementsByTagName('meta'); 424 for (i=0; i<nl.length; i++) { 425 if (k == 'Content-Type' && tinyMCE.getAttrib(nl[i], 'http-equiv') == k) { 426 if (v == '') 427 nl[i].parentNode.removeChild(nl[i]); 428 else 429 nl[i].setAttribute('content', "text/html; charset=" + v); 430 431 return; 432 } 433 434 if (tinyMCE.getAttrib(nl[i], 'name') == k) { 435 if (v == '') 436 nl[i].parentNode.removeChild(nl[i]); 437 else 438 nl[i].setAttribute('content', v); 439 return; 440 } 441 } 442 443 if (v == '') 444 return; 445 446 m = topDoc.createElement('meta'); 447 448 if (k == 'Content-Type') 449 m.httpEquiv = k; 450 else 451 m.setAttribute('name', k); 452 453 m.setAttribute('content', v); 454 he.appendChild(m); 455 } 456 457 function parseStyleElement(e) { 458 var v = e.innerHTML; 459 var p, i, r; 460 461 v = v.replace(/<!--/gi, ''); 462 v = v.replace(/-->/gi, ''); 463 v = v.replace(/[\n\r]/gi, ''); 464 v = v.replace(/\s+/gi, ' '); 465 466 r = new Array(); 467 p = v.split(/{|}/); 468 469 for (i=0; i<p.length; i+=2) { 470 if (p[i] != "") 471 r[r.length] = {rule : tinyMCE.trim(p[i]), data : tinyMCE.parseStyle(p[i+1])}; 472 } 473 474 return r; 475 } 476 477 function serializeStyleElement(d) { 478 var i, s, st; 479 480 s = '<!--\n'; 481 482 for (i=0; i<d.length; i++) { 483 s += d[i].rule + ' {\n'; 484 485 st = tinyMCE.serializeStyle(d[i].data); 486 487 if (st != '') 488 st += ';'; 489 490 s += st.replace(/;/g, ';\n'); 491 s += '}\n'; 492 493 if (i != d.length - 1) 494 s += '\n'; 495 } 496 497 s += '\n-->'; 498 499 return s; 500 } 501 502 function getReItem(r, s, i) { 503 var c = r.exec(s); 504 505 if (c && c.length > i) 506 return c[i]; 507 508 return ''; 509 } 510 511 function changedStyleField(field) { 512 //alert(field.id); 513 } 514 515 function showAddMenu() { 516 var re = document.getElementById('addbutton'); 517 518 addMenuLayer.moveRelativeTo(re, 'tr'); 519 if (addMenuLayer.isMSIE) 520 addMenuLayer.moveBy(2, 0); 521 522 addMenuLayer.show(); 523 addMenuLayer.setAutoHide(true, hideAddMenu); 524 addMenuLayer.addCSSClass(re, 'selected'); 525 } 526 527 function hideAddMenu(l, e, mx, my) { 528 var re = document.getElementById('addbutton'); 529 addMenuLayer.removeCSSClass(re, 'selected'); 530 } 531 532 function addHeadElm(type) { 533 var le = document.getElementById('headlist'); 534 var re = document.getElementById('addbutton'); 535 var te = document.getElementById(type + '_element'); 536 537 if (lastElementType) 538 lastElementType.style.display = 'none'; 539 540 te.style.display = 'block'; 541 542 lastElementType = te; 543 544 addMenuLayer.hide(); 545 addMenuLayer.removeCSSClass(re, 'selected'); 546 547 document.getElementById(type + '_updateelement').value = tinyMCE.getLang('lang_insert', 'Insert', true); 548 549 le.size = 10; 550 } 551 552 function updateHeadElm(item) { 553 var type = item.substring(0, item.indexOf('_')); 554 var le = document.getElementById('headlist'); 555 var re = document.getElementById('addbutton'); 556 var te = document.getElementById(type + '_element'); 557 558 if (lastElementType) 559 lastElementType.style.display = 'none'; 560 561 te.style.display = 'block'; 562 563 lastElementType = te; 564 565 addMenuLayer.hide(); 566 addMenuLayer.removeCSSClass(re, 'selected'); 567 568 document.getElementById(type + '_updateelement').value = tinyMCE.getLang('lang_update', 'Update', true); 569 570 le.size = 10; 571 } 572 573 function cancelElementUpdate() { 574 var le = document.getElementById('headlist'); 575 576 if (lastElementType) 577 lastElementType.style.display = 'none'; 578 579 le.size = 26; 580 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 30 01:27:52 2007 | par Balluche grâce à PHPXref 0.7 |