Changeset 4828 for trunk/expressoMail1_2/js/rich_text_editor.js
- Timestamp:
- 07/19/11 16:54:27 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/expressoMail1_2/js/rich_text_editor.js
r4801 r4828 6 6 this.buildEditor(); 7 7 this.saveFlag = 0; 8 } 9 10 // This code was written by Tyler Akins and has been placed in the 11 // public domain. It would be nice if you left this header intact. 12 // Base64 code from Tyler Akins -- http://rumkin.com 13 14 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 15 16 var ua = navigator.userAgent.toLowerCase(); 17 if (ua.indexOf(" chrome/") >= 0 || ua.indexOf(" firefox/") >= 0 || ua.indexOf(' gecko/') >= 0) { 18 var StringMaker = function () { 19 this.str = ""; 20 this.length = 0; 21 this.append = function (s) { 22 this.str += s; 23 this.length += s.length; 24 } 25 this.prepend = function (s) { 26 this.str = s + this.str; 27 this.length += s.length; 28 } 29 this.toString = function () { 30 return this.str; 31 } 32 } 33 } else { 34 var StringMaker = function () { 35 this.parts = []; 36 this.length = 0; 37 this.append = function (s) { 38 this.parts.push(s); 39 this.length += s.length; 40 } 41 this.prepend = function (s) { 42 this.parts.unshift(s); 43 this.length += s.length; 44 } 45 this.toString = function () { 46 return this.parts.join(''); 47 } 48 } 49 } 50 51 function fromJSON( value ) 52 { 53 return (new Function( "return " + decode64( value )))(); 54 } 55 56 57 function decode64(input) { 58 59 if( typeof input === "undefined" ) return; 60 61 var output = new StringMaker(); 62 var chr1, chr2, chr3; 63 var enc1, enc2, enc3, enc4; 64 var i = 0; 65 66 // remove all characters that are not A-Z, a-z, 0-9, +, /, or = 67 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 68 69 while (i < input.length) { 70 enc1 = keyStr.indexOf(input.charAt(i++)); 71 enc2 = keyStr.indexOf(input.charAt(i++)); 72 enc3 = keyStr.indexOf(input.charAt(i++)); 73 enc4 = keyStr.indexOf(input.charAt(i++)); 74 75 chr1 = (enc1 << 2) | (enc2 >> 4); 76 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 77 chr3 = ((enc3 & 3) << 6) | enc4; 78 79 output.append(String.fromCharCode(chr1)); 80 81 if (enc3 != 64) { 82 output.append(String.fromCharCode(chr2)); 83 } 84 if (enc4 != 64) { 85 output.append(String.fromCharCode(chr3)); 86 } 87 } 88 89 return output.toString(); 90 91 8 92 } 9 93 … … 220 304 221 305 222 306 cRichTextEditor.prototype.buildSelect = function( selectId, label, options, decode ) { 307 308 var selectBox = document.createElement("SELECT"); 309 selectBox.id = selectId; 310 selectBox.setAttribute("tabIndex","-1"); 311 selectBox.onchange = function () {RichTextEditor.Select( selectId );}; 312 selectBox.className = 'select_richtext'; 313 selectBox.length = 0; 314 315 selectBox.options[0] = new Option( get_lang(label), label ); 316 317 for( var key in options ) 318 selectBox.options[ selectBox.length ] = new Option( key, unescape( options[key] ) ); 319 320 return selectBox; 321 } 223 322 224 323 cRichTextEditor.prototype.buildEditor = function() { … … 232 331 var div_button_rt = document.createElement("DIV"); 233 332 234 selectBox=document.createElement("SELECT"); 235 selectBox.id="fontname"; 236 selectBox.setAttribute("tabIndex","-1"); 237 selectBox.onchange = function () {RichTextEditor.Select("fontname");}; 238 selectBox.className = 'select_richtext'; 239 var option1 = new Option(get_lang('Font'), 'Font'); 240 var option2 = new Option('Arial', 'Arial'); 241 var option3 = new Option('Courier', 'Courier'); 242 var option4 = new Option('Times New Roman', 'Times'); 243 if (is_ie){ 244 selectBox.add(option1); 245 selectBox.add(option2); 246 selectBox.add(option3); 247 selectBox.add(option4); 248 } 249 else{ 250 selectBox.add(option1, null); 251 selectBox.add(option2, null); 252 selectBox.add(option3, null); 253 selectBox.add(option4, null); 254 } 255 div_button_rt.appendChild(selectBox); 256 257 selectBox=document.createElement("SELECT"); 258 selectBox.id="fontsize"; 259 selectBox.setAttribute("tabIndex","-1"); 260 selectBox.setAttribute("unselectable","on"); 261 selectBox.className = 'select_richtext'; 262 selectBox.onchange = function () {RichTextEditor.Select("fontsize");}; 263 var option1 = new Option(get_lang('Size'), 'Size'); 264 var option2 = new Option('1 (8 pt)','1' ); 265 var option3 = new Option('2 (10 pt)','2'); 266 var option4 = new Option('3 (12 pt)','3'); 267 var option5 = new Option('4 (14 pt)','4'); 268 var option6 = new Option('5 (18 pt)','5'); 269 var option7 = new Option('6 (24 pt)','6'); 270 var option8 = new Option('7 (36 pt)','7'); 271 if (is_ie){ 272 selectBox.add(option1); 273 selectBox.add(option2); 274 selectBox.add(option3); 275 selectBox.add(option4); 276 selectBox.add(option5); 277 selectBox.add(option6); 278 selectBox.add(option7); 279 selectBox.add(option8); 280 } 281 else{ 282 selectBox.add(option1, null); 283 selectBox.add(option2, null); 284 selectBox.add(option3, null); 285 selectBox.add(option4, null); 286 selectBox.add(option5, null); 287 selectBox.add(option6, null); 288 selectBox.add(option7, null); 289 selectBox.add(option8, null); 290 } 291 div_button_rt.appendChild(selectBox); 333 334 selectBox = this.buildSelect( "fontname", 'Font', { 'Arial' : 'Arial', 335 'Courier' : 'Courier', 336 'Times New Roman' : 'Times' }); 337 338 div_button_rt.appendChild( selectBox ); 339 340 selectBox = this.buildSelect( "fontsize", 'Size', { '1 (8 pt)': '1', 341 '2 (10 pt)': '2', 342 '3 (12 pt)': '3', 343 '4 (14 pt)': '4', 344 '5 (18 pt)': '5', 345 '6 (24 pt)': '6', 346 '7 (36 pt)': '7' }); 347 348 div_button_rt.appendChild( selectBox ); 292 349 293 350 var buttons = ['bold', 'italic', 'underline', 'forecolor', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', … … 355 412 } 356 413 414 preferences.signatures = fromJSON( preferences.signatures ); 415 preferences.signature_types = fromJSON( preferences.signature_types ); 416 417 for( key in preferences.signatures ) 418 if( !preferences.signature_types[key] ) 419 preferences.signatures[key] = preferences.signatures[key].replace( /\n/g, "<br>" ); 420 421 selectBox = this.buildSelect( "inserthtml", 'Signature', preferences.signatures ); 422 div_button_rt.appendChild( selectBox ); 357 423 358 424 td.appendChild(div_button_rt); … … 366 432 var mainField = document.getElementById(this.editor).contentWindow; 367 433 mainField.focus(); 368 var signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); 434 var signature = preferences.signature; 435 if( !preferences.signatures ) 436 signature = preferences.type_signature == 'html' ? preferences.signature : preferences.signature.replace(/\n/g, "<br>"); 369 437 if (command == 'signature'){ 370 438 if (is_ie){
Note: See TracChangeset
for help on using the changeset viewer.