[ Index ] |
|
Code source de SPIP Agora 1.4 |
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$ 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 for (var i = links.length; --i >= 0;) { 53 var link = links[i]; 54 if (/stylesheet/i.test(link.rel)) { 55 if (/alternate/i.test(link.rel)) 56 style2 = link.href; 57 else 58 style1 = link.href; 59 } 60 } 61 var title = doc.getElementsByTagName("title")[0]; 62 title = title ? title.innerHTML : ''; 63 var init = { 64 f_doctype : editor.doctype, 65 f_title : title, 66 f_body_bgcolor : HTMLArea._colorToRgb(doc.body.style.backgroundColor), 67 f_body_fgcolor : HTMLArea._colorToRgb(doc.body.style.color), 68 f_base_style : style1, 69 f_alt_style : style2, 70 71 editor : editor 72 }; 73 editor._popupDialog("plugin://FullPage/docprop", function(params) { 74 self.setDocProp(params); 75 }, init); 76 break; 77 } 78 }; 79 80 FullPage.prototype.setDocProp = function(params) { 81 var txt = ""; 82 var doc = this.editor._doc; 83 var head = doc.getElementsByTagName("head")[0]; 84 var links = doc.getElementsByTagName("link"); 85 var style1 = null; 86 var style2 = null; 87 for (var i = links.length; --i >= 0;) { 88 var link = links[i]; 89 if (/stylesheet/i.test(link.rel)) { 90 if (/alternate/i.test(link.rel)) 91 style2 = link; 92 else 93 style1 = link; 94 } 95 } 96 function createLink(alt) { 97 var link = doc.createElement("link"); 98 link.rel = alt ? "alternate stylesheet" : "stylesheet"; 99 head.appendChild(link); 100 return link; 101 }; 102 103 if (!style1 && params.f_base_style) 104 style1 = createLink(false); 105 if (params.f_base_style) 106 style1.href = params.f_base_style; 107 else if (style1) 108 head.removeChild(style1); 109 110 if (!style2 && params.f_alt_style) 111 style2 = createLink(true); 112 if (params.f_alt_style) 113 style2.href = params.f_alt_style; 114 else if (style2) 115 head.removeChild(style2); 116 117 for (var i in params) { 118 var val = params[i]; 119 switch (i) { 120 case "f_title": 121 var title = doc.getElementsByTagName("title")[0]; 122 if (!title) { 123 title = doc.createElement("title"); 124 head.appendChild(title); 125 } else while (node = title.lastChild) 126 title.removeChild(node); 127 if (!HTMLArea.is_ie) 128 title.appendChild(doc.createTextNode(val)); 129 else 130 doc.title = val; 131 break; 132 case "f_doctype": 133 this.editor.setDoctype(val); 134 break; 135 case "f_body_bgcolor": 136 doc.body.style.backgroundColor = val; 137 break; 138 case "f_body_fgcolor": 139 doc.body.style.color = val; 140 break; 141 } 142 } 143 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sat Feb 24 14:40:03 2007 | par Balluche grâce à PHPXref 0.7 |