[ Index ] |
|
Code source de Seagull 0.6.1 |
1 /** 2 * $RCSfile: editor_plugin_src.js,v $ 3 * $Revision: 1.12 $ 4 * $Date: 2006/02/23 16:16:34 $ 5 * 6 * @author Moxiecode 7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 8 */ 9 10 /* Import plugin specific language pack */ 11 tinyMCE.importPluginLanguagePack('fullpage', 'en,tr,sv'); 12 13 var TinyMCE_FullPagePlugin = { 14 getInfo : function() { 15 return { 16 longname : 'Fullpage', 17 author : 'Moxiecode Systems', 18 authorurl : 'http://tinymce.moxiecode.com', 19 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_fullpage.html', 20 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 21 }; 22 }, 23 24 getControlHTML : function(cn) { 25 switch (cn) { 26 case "fullpage": 27 return tinyMCE.getButtonHTML(cn, 'lang_fullpage_desc', '{$pluginurl}/images/fullpage.gif', 'mceFullPageProperties'); 28 } 29 30 return ""; 31 }, 32 33 execCommand : function(editor_id, element, command, user_interface, value) { 34 // Handle commands 35 switch (command) { 36 case "mceFullPageProperties": 37 var template = new Array(); 38 39 template['file'] = '../../plugins/fullpage/fullpage.htm'; 40 template['width'] = 430; 41 template['height'] = 485 + (tinyMCE.isOpera ? 5 : 0); 42 43 template['width'] += tinyMCE.getLang('lang_fullpage_delta_width', 0); 44 template['height'] += tinyMCE.getLang('lang_fullpage_delta_height', 0); 45 46 tinyMCE.openWindow(template, {editor_id : editor_id, inline : "yes"}); 47 return true; 48 49 case "mceFullPageUpdate": 50 TinyMCE_FullPagePlugin._addToHead(tinyMCE.getInstanceById(editor_id)); 51 return true; 52 } 53 54 // Pass to next handler in chain 55 return false; 56 }, 57 58 cleanup : function(type, content, inst) { 59 switch (type) { 60 case "insert_to_editor": 61 var tmp = content.toLowerCase(); 62 var pos = tmp.indexOf('<body'), pos2; 63 64 // Split page in header and body chunks 65 if (pos != -1) { 66 pos = tmp.indexOf('>', pos); 67 pos2 = tmp.lastIndexOf('</body>'); 68 inst.fullpageTopContent = content.substring(0, pos + 1); 69 content = content.substring(pos + 1, pos2); 70 // tinyMCE.debug(inst.fullpageTopContent, content); 71 } else { 72 if (!inst.fullpageTopContent) { 73 var docType = tinyMCE.getParam("fullpage_default_doctype", '<!DOCTYPE html PUBLIC "-/'+'/W3C//DTD XHTML 1.0 Transitional/'+'/EN" "http:/'+'/www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'); 74 var enc = tinyMCE.getParam("fullpage_default_encoding", 'utf-8'); 75 var title = tinyMCE.getParam("fullpage_default_title", 'Untitled document'); 76 var lang = tinyMCE.getParam("fullpage_default_langcode", 'en'); 77 var pi = tinyMCE.getParam("fullpage_default_xml_pi", true); 78 var ff = tinyMCE.getParam("fullpage_default_font_family", ""); 79 var fz = tinyMCE.getParam("fullpage_default_font_size", ""); 80 var ds = tinyMCE.getParam("fullpage_default_style", ""); 81 var dtc = tinyMCE.getParam("fullpage_default_text_color", ""); 82 83 // Xml encode it 84 title = title.replace(/&/g, '&'); 85 title = title.replace(/\"/g, '"'); 86 title = title.replace(/</g, '<'); 87 title = title.replace(/>/g, '>'); 88 89 tmp = ''; 90 91 // Make default chunk 92 if (pi) 93 tmp += '<?xml version="1.0" encoding="' + enc + '"?>\n'; 94 95 tmp += docType + '\n'; 96 tmp += '<html xmlns="http:/'+'/www.w3.org/1999/xhtml" lang="' + lang + '" xml:lang="' + lang + '">\n'; 97 tmp += '<head>\n'; 98 tmp += '\t<title>' + title + '</title>\n'; 99 tmp += '\t<meta http-equiv="Content-Type" content="text/html; charset=' + enc + '" />\n'; 100 tmp += '</head>\n'; 101 tmp += '<body'; 102 103 if (ff != '' || fz != '') { 104 tmp += ' style="'; 105 106 if (ds != '') 107 tmp += ds + ";"; 108 109 if (ff != '') 110 tmp += 'font-family: ' + ff + ";"; 111 112 if (fz != '') 113 tmp += 'font-size: ' + fz + ";"; 114 115 tmp += '"'; 116 } 117 118 if (dtc != '') 119 tmp += ' text="' + dtc + '"'; 120 121 tmp += '>\n'; 122 123 inst.fullpageTopContent = tmp; 124 } 125 } 126 127 this._addToHead(inst); 128 129 break; 130 131 case "get_from_editor": 132 if (inst.fullpageTopContent) 133 content = inst.fullpageTopContent + content + "\n</body>\n</html>"; 134 135 break; 136 } 137 138 // Pass through to next handler in chain 139 return content; 140 }, 141 142 // Private plugin internal methods 143 144 _addToHead : function(inst) { 145 var doc = inst.getDoc(); 146 var head = doc.getElementsByTagName("head")[0]; 147 var body = doc.body; 148 var h = inst.fullpageTopContent; 149 var e = doc.createElement("body"); 150 var nl, i, le, tmp; 151 152 // Remove stuff we don't want 153 h = h.replace(/(\r|\n)/gi, ''); 154 h = h.replace(/<\?[^\>]*\>/gi, ''); 155 h = h.replace(/<\/?(!DOCTYPE|head|html)[^\>]*\>/gi, ''); 156 h = h.replace(/<script(.*?)<\/script>/gi, ''); 157 h = h.replace(/<title(.*?)<\/title>/gi, ''); 158 h = h.replace(/<(meta|base)[^>]*>/gi, ''); 159 160 // Make link and style elements into pre 161 h = h.replace(/<link([^>]*)\/>/gi, '<pre mce_type="link" $1></pre>'); 162 //h = h.replace(/<style([^>]*)>(.*?)<\/style>/gi, '<pre mce_type="style" $1>$2</pre>'); 163 164 // Make body a div 165 h = h.replace(/<body/gi, '<div mce_type="body"'); 166 h += '</div>'; 167 168 // Now crapy MSIE can parse it 169 e.innerHTML = h; 170 171 // Reset all body attributes 172 body.vLink = body.aLink = body.link = body.text = ''; 173 body.style.cssText = ''; 174 175 // Delete all old links 176 nl = head.getElementsByTagName('link'); 177 for (i=0; i<nl.length; i++) { 178 if (tinyMCE.getAttrib(nl[i], 'mce_head') == "true") 179 nl[i].parentNode.removeChild(nl[i]); 180 } 181 182 // Add link elements 183 nl = e.getElementsByTagName('pre'); 184 for (i=0; i<nl.length; i++) { 185 tmp = tinyMCE.getAttrib(nl[i], 'media'); 186 if (tinyMCE.getAttrib(nl[i], 'mce_type') == "link" && (tmp == "" || tmp == "screen" || tmp == "all") && tinyMCE.getAttrib(nl[i], 'rel') == "stylesheet") { 187 le = doc.createElement("link"); 188 189 le.rel = "stylesheet"; 190 le.href = tinyMCE.getAttrib(nl[i], 'href'); 191 le.setAttribute("mce_head", "true"); 192 193 head.appendChild(le); 194 } 195 } 196 197 // Add body attributes 198 nl = e.getElementsByTagName('div'); 199 if (nl.length > 0) { 200 body.style.cssText = tinyMCE.getAttrib(nl[0], 'style'); 201 202 if ((tmp = tinyMCE.getAttrib(nl[0], 'leftmargin')) != '' && body.style.marginLeft == '') 203 body.style.marginLeft = tmp + "px"; 204 205 if ((tmp = tinyMCE.getAttrib(nl[0], 'rightmargin')) != '' && body.style.marginRight == '') 206 body.style.marginRight = tmp + "px"; 207 208 if ((tmp = tinyMCE.getAttrib(nl[0], 'topmargin')) != '' && body.style.marginTop == '') 209 body.style.marginTop = tmp + "px"; 210 211 if ((tmp = tinyMCE.getAttrib(nl[0], 'bottommargin')) != '' && body.style.marginBottom == '') 212 body.style.marginBottom = tmp + "px"; 213 214 body.dir = tinyMCE.getAttrib(nl[0], 'dir'); 215 body.vLink = tinyMCE.getAttrib(nl[0], 'vlink'); 216 body.aLink = tinyMCE.getAttrib(nl[0], 'alink'); 217 body.link = tinyMCE.getAttrib(nl[0], 'link'); 218 body.text = tinyMCE.getAttrib(nl[0], 'text'); 219 220 if ((tmp = tinyMCE.getAttrib(nl[0], 'background')) != '') 221 body.style.backgroundImage = tmp; 222 223 if ((tmp = tinyMCE.getAttrib(nl[0], 'bgcolor')) != '') 224 body.style.backgroundColor = tmp; 225 } 226 } 227 }; 228 229 tinyMCE.addPlugin("fullpage", TinyMCE_FullPagePlugin);
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 |