[ Index ] |
|
Code source de eGroupWare 1.2.106-2 |
1 /**************************************************************************\ 2 * eGroupWare - UploadImage-plugin for htmlArea in eGroupWare * 3 * http://www.eGroupWare.org * 4 * Written and (c) by Xiang Wei ZHUO <wei@zhuo.org> * 5 * Used code fragments from plugins by Mihai Bazon * 6 * Modified for eGW by and (c) by Pim Snel <pim@lingewoud.nl> * 7 * -------------------------------------------- * 8 * This program is free software; you can redistribute it and/or modify it * 9 * under the terms of the GNU General Public License as published by the * 10 * Free Software Foundation; version 2 of the License. * 11 \**************************************************************************/ 12 13 // $Id: upload-image.js 17191 2004-10-08 10:15:51Z mipmip $ 14 15 // FIXME: clean up code 16 17 function UploadImage(editor) { 18 19 var self = this; 20 this.editor = editor; 21 22 var cfg = editor.config; 23 // cfg.fullPage = true; 24 var tt = UploadImage.I18N; 25 26 27 /* cfg.registerButton("UploadImage", tt["Upload Image"], editor.imgURL("up_image.gif", "UploadImage"), false, 28 function(editor, id) { 29 self.buttonPress(editor, id); 30 }); 31 */ 32 cfg.registerButton("UploadImage", tt["Upload Image"], editor.imgURL("up_image.gif", "UploadImage"), false, 33 function(editor, id) { 34 self.buttonPress(); 35 }); 36 37 // add a new line in the toolbar 38 cfg.toolbar[0].splice(29, 0, "separator"); 39 cfg.toolbar[0].splice(30, 0, "UploadImage"); 40 }; 41 42 UploadImage._pluginInfo = { 43 name : "UploadImage for eGroupWare", 44 version : "1.0", 45 developer : "Pim Snel", 46 developer_url : "http://lingewoud.com", 47 c_owner : "Pim Snel, Xiang Wei ZHUO, Mihai Bazon", 48 sponsor : "Lingewoud bv., Netherlands", 49 sponsor_url : "http://lingewoud.com", 50 license : "GPL" 51 }; 52 53 /*UploadImage.prototype.zzzbuttonPress = function(editor, id) 54 { 55 var self = this; 56 switch (id) 57 { 58 case "UploadImage": 59 var doc = editor._doc; 60 var links = doc.getElementsByTagName("link"); 61 var style1 = ''; 62 var style2 = ''; 63 for (var i = links.length; --i >= 0;) 64 { 65 var link = links[i]; 66 if (/stylesheet/i.test(link.rel)) 67 { 68 if (/alternate/i.test(link.rel)) 69 style2 = link.href; 70 else 71 style1 = link.href; 72 } 73 } 74 var title = doc.getElementsByTagName("title")[0]; 75 title = title ? title.innerHTML : ''; 76 77 var init = 78 { 79 f_doctype : editor.doctype, 80 f_title : title, 81 f_body_bgcolor : HTMLArea._colorToRgb(doc.body.style.backgroundColor), 82 f_body_fgcolor : HTMLArea._colorToRgb(doc.body.style.color), 83 f_base_style : style1, 84 f_alt_style : style2, 85 86 editor : editor 87 }; 88 89 Dialog(_editor_url+"plugins/UploadImage/popups/insert_image.php", function(image) 90 { 91 self._insertImage(image); 92 // self.setDocProp(params); 93 // alert(params[1]); 94 }, init); 95 96 /* editor._popupDialog("plugin://UploadImage/insert_image.php", function(params) { 97 self.setDocProp(params); 98 }, init);*/ 99 100 /*break; 101 } 102 }; 103 */ 104 105 106 // Called when the user clicks on "InsertImage" button. If an image is already 107 // there, it will just modify it's properties. 108 UploadImage.prototype.buttonPress = function(image) 109 { 110 var editor = this.editor; // for nested functions 111 var outparam = null; 112 //var doc = editor._doc; 113 114 /* var init = 115 { 116 f_doctype : editor.doctype, 117 editor : editor 118 }; 119 */ 120 /* if (typeof image == "undefined") 121 { 122 image = editor.getParentElement(); 123 if (image && !/^img$/i.test(image.tagName)) 124 image = null; 125 } 126 */ 127 Dialog(_editor_url+"plugins/UploadImage/popups/insert_image.php", function(param) 128 { 129 130 if (!param) 131 { 132 // user must have pressed Cancel 133 return false; 134 } 135 136 var img = image; 137 if (!img) 138 { 139 var sel = editor._getSelection(); 140 var range = editor._createRange(sel); 141 editor._doc.execCommand("insertimage", false, param.f_url); 142 143 if (HTMLArea.is_ie) 144 { 145 // ie gives errors 146 /* img = range.parentElement(); 147 148 149 // wonder if this works... 150 if (img.tagName.toLowerCase() != "img") { 151 img = img.previousSibling; 152 } 153 154 */ 155 } 156 else 157 { 158 img = range.startContainer.previousSibling; 159 } 160 161 } 162 else 163 { 164 img.src = param.f_url; 165 } 166 167 168 /* // FIXME setting img parameters is broken and thus deactivated atm 169 for (field in param) 170 { 171 var value = param[field]; 172 switch (field) 173 { 174 case "f_alt" : img.alt = value; break; 175 case "f_border" : img.border = parseInt(value || "0"); break; 176 case "f_align" : img.align = value; break; 177 case "f_vert" : img.vspace = parseInt(value || "0"); break; 178 case "f_horiz" : img.hspace = parseInt(value || "0"); break; 179 } 180 } 181 */ 182 183 }, outparam); 184 };
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Feb 25 17:20:01 2007 | par Balluche grâce à PHPXref 0.7 |