[ Index ] |
|
Code source de Serendipity 1.2 |
1 // FullPage Plugin for HTMLArea-3.0 2 // Implementation by Mihai Bazon. Sponsored by http://thycotic.com 3 // 4 // htmlArea v3.0 - Copyright (c) 2002 interactivetools.com, inc. 5 // This notice MUST stay intact for use (see license.txt). 6 // 7 // A free WYSIWYG editor replacement for <textarea> fields. 8 // For full source code and docs, visit http://www.interactivetools.com/ 9 // 10 // Version 3.0 developed by Mihai Bazon for InteractiveTools. 11 // http://dynarch.com/mishoo 12 // 13 // $Id: full-page.js,v 1.2 2005/01/11 15:00:57 garvinhicking Exp $ 14 15 function FullPage(editor) { 16 this.editor = editor; 17 18 var cfg = editor.config; 19 cfg.fullPage = true; 20 var tt = FullPage.I18N; 21 var self = this; 22 23 cfg.registerButton("FP-docprop", tt["Document properties"], editor.imgURL("docprop.gif", "FullPage"), false, 24 function(editor, id) { 25 self.buttonPress(editor, id); 26 }); 27 28 // add a new line in the toolbar 29 cfg.toolbar[0].splice(0, 0, "separator"); 30 cfg.toolbar[0].splice(0, 0, "FP-docprop"); 31 }; 32 33 FullPage._pluginInfo = { 34 name : "FullPage", 35 version : "1.0", 36 developer : "Mihai Bazon", 37 developer_url : "http://dynarch.com/mishoo/", 38 c_owner : "Mihai Bazon", 39 sponsor : "Thycotic Software Ltd.", 40 sponsor_url : "http://thycotic.com", 41 license : "htmlArea" 42 }; 43 44 FullPage.prototype.buttonPress = function(editor, id) { 45 var self = this; 46 switch (id) { 47 case "FP-docprop": 48 var doc = editor._doc; 49 var links = doc.getElementsByTagName("link"); 50 var style1 = ''; 51 var style2 = ''; 52 var charset = ''; 53 for (var i = links.length; --i >= 0;) { 54 var link = links[i]; 55 if (/stylesheet/i.test(link.rel)) { 56 if (/alternate/i.test(link.rel)) 57 style2 = link.href; 58 else 59 style1 = link.href; 60 } 61 } 62 var metas = doc.getElementsByTagName("meta"); 63 for (var i = metas.length; --i >= 0;) { 64 var meta = metas[i]; 65 if (/content-type/i.test(meta.httpEquiv)) { 66 r = /^text\/html; *charset=(.*)$/i.exec(meta.content); 67 charset = r[1]; 68 } 69 } 70 var title = doc.getElementsByTagName("title")[0]; 71 title = title ? title.innerHTML : ''; 72 var init = { 73 f_doctype : editor.doctype, 74 f_title : title, 75 f_body_bgcolor : HTMLArea._colorToRgb(doc.body.style.backgroundColor), 76 f_body_fgcolor : HTMLArea._colorToRgb(doc.body.style.color), 77 f_base_style : style1, 78 f_alt_style : style2, 79 f_charset : charset, 80 editor : editor 81 }; 82 editor._popupDialog("plugin://FullPage/docprop", function(params) { 83 self.setDocProp(params); 84 }, init); 85 break; 86 } 87 }; 88 89 FullPage.prototype.setDocProp = function(params) { 90 var txt = ""; 91 var doc = this.editor._doc; 92 var head = doc.getElementsByTagName("head")[0]; 93 var links = doc.getElementsByTagName("link"); 94 var metas = doc.getElementsByTagName("meta"); 95 var style1 = null; 96 var style2 = null; 97 var charset = null; 98 var charset_meta = null; 99 for (var i = links.length; --i >= 0;) { 100 var link = links[i]; 101 if (/stylesheet/i.test(link.rel)) { 102 if (/alternate/i.test(link.rel)) 103 style2 = link; 104 else 105 style1 = link; 106 } 107 } 108 for (var i = metas.length; --i >= 0;) { 109 var meta = metas[i]; 110 if (/content-type/i.test(meta.httpEquiv)) { 111 r = /^text\/html; *charset=(.*)$/i.exec(meta.content); 112 charset = r[1]; 113 charset_meta = meta; 114 } 115 } 116 function createLink(alt) { 117 var link = doc.createElement("link"); 118 link.rel = alt ? "alternate stylesheet" : "stylesheet"; 119 head.appendChild(link); 120 return link; 121 }; 122 function createMeta(name, content) { 123 var meta = doc.createElement("meta"); 124 meta.httpEquiv = name; 125 meta.content = content; 126 head.appendChild(meta); 127 return meta; 128 }; 129 130 if (!style1 && params.f_base_style) 131 style1 = createLink(false); 132 if (params.f_base_style) 133 style1.href = params.f_base_style; 134 else if (style1) 135 head.removeChild(style1); 136 137 if (!style2 && params.f_alt_style) 138 style2 = createLink(true); 139 if (params.f_alt_style) 140 style2.href = params.f_alt_style; 141 else if (style2) 142 head.removeChild(style2); 143 144 if (charset_meta) { 145 head.removeChild(charset_meta); 146 charset_meta = null; 147 } 148 if (!charset_meta && params.f_charset) 149 charset_meta = createMeta("Content-Type", "text/html; charset="+params.f_charset); 150 151 for (var i in params) { 152 var val = params[i]; 153 switch (i) { 154 case "f_title": 155 var title = doc.getElementsByTagName("title")[0]; 156 if (!title) { 157 title = doc.createElement("title"); 158 head.appendChild(title); 159 } else while (node = title.lastChild) 160 title.removeChild(node); 161 if (!HTMLArea.is_ie) 162 title.appendChild(doc.createTextNode(val)); 163 else 164 doc.title = val; 165 break; 166 case "f_doctype": 167 this.editor.setDoctype(val); 168 break; 169 case "f_body_bgcolor": 170 doc.body.style.backgroundColor = val; 171 break; 172 case "f_body_fgcolor": 173 doc.body.style.color = val; 174 break; 175 } 176 } 177 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Nov 24 09:00:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |