Changeset 984
- Timestamp:
- 03/22/08 12:37:20 (5 years ago)
- Location:
- branches/ray
- Files:
-
- 9 modified
-
Xinha.css (modified) (1 diff)
-
XinhaCore.js (modified) (11 diffs)
-
modules/ColorPicker/ColorPicker.js (modified) (18 diffs)
-
modules/Dialogs/dialog.js (modified) (2 diffs)
-
modules/Gecko/Gecko.js (modified) (1 diff)
-
modules/InternetExplorer/InternetExplorer.js (modified) (2 diffs)
-
plugins/InsertAnchor/insert-anchor.css (modified) (1 diff)
-
plugins/InsertAnchor/insert-anchor.js (modified) (5 diffs)
-
plugins/SmartReplace/smart-replace.js (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/ray/Xinha.css
r975 r984 1 1 .htmlarea { background: #fff; } 2 2 .htmlarea td { margin:0;padding:0; } 3 4 .htmlarea .toolbarRow { 5 width:1px; 6 } 3 7 4 8 .htmlarea .toolbar { -
branches/ray/XinhaCore.js
r983 r984 134 134 @type string 135 135 */ 136 Xinha.opera_version = navigator.appVersion.substring(0, navigator.appVersion.indexOf(" "))*1; 136 if(Xinha.is_opera && Xinha.agt.match(/opera[\/ ]([0-9.]+)/)) 137 { 138 Xinha.opera_version = parseFloat(RegExp.$1); 139 } 140 else 141 { 142 Xinha.opera_version = 0; 143 } 137 144 /** Browserengine is KHTML (Konqueror, Safari) 138 145 @type string … … 143 150 */ 144 151 Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); 152 Xinha.webkit_version = parseInt(navigator.appVersion.replace(/.*?AppleWebKit\/([\d]).*?/,'$1')); 153 145 154 /** Browser is Safari 146 155 @type string … … 159 168 */ 160 169 Xinha.is_win_ie = (Xinha.is_ie && !Xinha.is_mac); 161 /** Browserengine is Gecko (Mozilla), applies also to Safari 170 /** Browser engine is Gecko (Mozilla), applies also to Safari and Opera which work 171 * largely similar. 162 172 @type string 163 173 */ 164 Xinha.is_gecko = (navigator.product == "Gecko") ;174 Xinha.is_gecko = (navigator.product == "Gecko") || Xinha.is_opera; 165 175 Xinha.is_real_gecko = (navigator.product == "Gecko" && !Xinha.is_webkit); 166 Xinha.is_ff3 = Xinha.is_real_gecko && parseInt(navigator.productSub) >= "2007121016";167 Xinha.is_ff2 = Xinha.is_real_gecko && parseInt(navigator.productSub) < "2007121016";176 Xinha.is_ff3 = Xinha.is_real_gecko && parseInt(navigator.productSub) >= 2007121016; 177 Xinha.is_ff2 = Xinha.is_real_gecko && parseInt(navigator.productSub) < 2007121016; 168 178 169 179 /** File is opened locally opened ("file://" protocol) … … 184 194 Xinha.checkSupportedBrowser = function() 185 195 { 186 if ( Xinha.is_opera ) 187 { 188 // alert("Sorry, Opera is not yet supported by Xinha."); 189 return false; 190 } 191 return Xinha.is_gecko || (Xinha.is_opera && 0 && Xinha.opera_version >= 9.1) || Xinha.ie_version >= 5.5; 196 return Xinha.is_real_gecko || (Xinha.is_opera && Xinha.opera_version >= 9.2) || Xinha.ie_version >= 5.5 || Xinha.webkit_version >= 522; 192 197 }; 193 198 /** Cache result of checking for browser support … … 454 459 * @type RegExp 455 460 */ 456 Xinha.RE_email = / [_a-z\d\-\.]{3,}@[_a-z\d\-]{2,}(\.[_a-z\d\-]{2,})+/i;461 Xinha.RE_email = /^[_a-z\d\-\.]{3,}@[_a-z\d\-]{2,}(\.[_a-z\d\-]{2,})+$/i; 457 462 /** Identifies URLs 458 463 * @type RegExp … … 2055 2060 editor._browserSpecificPlugin = editor.registerPlugin('WebKit'); 2056 2061 } 2062 else if (Xinha.is_opera) 2063 { 2064 url = _editor_url + 'modules/Opera/Opera.js'; 2065 if ( !Xinha.loadPlugins(["Opera"], function() { editor.generate(); }, url ) ) 2066 { 2067 return false; 2068 } 2069 editor._browserSpecificPlugin = editor.registerPlugin('Opera'); 2070 } 2057 2071 else if (Xinha.is_gecko) 2058 2072 { … … 2135 2149 editor.registerPlugin('EnterParagraphs'); 2136 2150 } 2151 //TEMPORARY FIX FOR IE8 see #1175 2152 if (Xinha.ie_version == 8) 2153 { 2154 this.config.getHtmlMethod = 'TransformInnerHTML'; 2155 } 2137 2156 2138 2157 switch (this.config.getHtmlMethod) … … 2340 2359 if (Xinha.is_opera) 2341 2360 { 2342 Xinha._addEvent(2343 this._iframe.contentWindow,2344 'load',2345 function(e)2346 {2347 if ( !editor._iframeLoadDone )2348 {2349 editor._iframeLoadDone = true;2350 2361 editor.initIframe(); 2351 2362 } 2352 return true;2353 }2354 )2355 }2356 2363 else 2357 2364 Xinha._addEvent( … … 5024 5031 if ( typeof this.config.baseHref != 'undefined' && this.config.baseHref !== null ) 5025 5032 { 5026 baseRe = new RegExp( "((href|src|background )=\")(" + Xinha.escapeStringForRegExp(this.config.baseHref.replace(/([^\/]\/)(?=.+\.)[^\/]*$/, "$1")) + ")", 'g' );5033 baseRe = new RegExp( "((href|src|background|action)=\")(" + Xinha.escapeStringForRegExp(this.config.baseHref.replace(/([^\/]\/)(?=.+\.)[^\/]*$/, "$1")) + ")", 'g' ); 5027 5034 } 5028 5035 else 5029 5036 { 5030 baseRe = new RegExp( "((href|src|background )=\")(" + Xinha.escapeStringForRegExp(document.location.href.replace( /^(https?:\/\/[^\/]*)(.*)/, '$1' )) + ")", 'g' );5037 baseRe = new RegExp( "((href|src|background|action)=\")(" + Xinha.escapeStringForRegExp(document.location.href.replace( /^(https?:\/\/[^\/]*)(.*)/, '$1' )) + ")", 'g' ); 5031 5038 } 5032 5039 … … 6128 6135 } 6129 6136 else 6137 { 6130 6138 s += prop + ' = ' + o[prop] + '\n'; 6131 6139 } 6140 6141 } 6132 6142 if (s) 6133 6143 { 6144 if (document.getElementById('errors')) 6145 { 6146 document.getElementById('errors').value += s; 6147 } 6148 else 6149 { 6134 6150 var x = window.open("", "debugger"); 6135 6151 x.document.write('<pre>' + s + '</pre>'); 6136 6152 } 6153 } 6137 6154 } 6138 6155 } … … 7137 7154 Xinha.init(); 7138 7155 7139 if ( Xinha.is_ie)7156 if ( Xinha.ie_version < 8 ) 7140 7157 { 7141 7158 Xinha.addDom0Event(window,'unload',Xinha.collectGarbageForIE); -
branches/ray/modules/ColorPicker/ColorPicker.js
r975 r984 90 90 function ColorPicker() 91 91 { 92 // dummy function for Xinha plugin api, note the different names92 // dummy function for Xinha plugin api, note the different names 93 93 } 94 if (window.opener && window.opener.Xinha) 95 { // this prevents that the Xinha.colorPicker object of the opening window is replaced by the one loaded in the popup 96 var openerColorPicker = window.opener.Xinha.colorPicker; 97 Xinha._addEvent(window,'unload', function() {Xinha.colorPicker = openerColorPicker;}); 98 } 94 try { 95 if (window.opener && window.opener.Xinha) 96 { // this prevents that the Xinha.colorPicker object of the opening window is replaced by the one loaded in the popup 97 var openerColorPicker = window.opener.Xinha.colorPicker; 98 Xinha._addEvent(window,'unload', function() {Xinha.colorPicker = openerColorPicker;}); 99 } 100 } catch(e) {} 99 101 //the actual function is below 100 102 Xinha.colorPicker = function (params) … … 105 107 Xinha.colorPicker.loadColors(); 106 108 } 107 108 this.is_ie_6 = (Xinha.is_ie && Xinha.ie_version < 7);109 110 this.is_ie_6 = (Xinha.is_ie && Xinha.ie_version < 7); 109 111 var picker = this; 110 112 var enablepick = false; … … 128 130 this.table.onmouseup = function() 129 131 { 130 enablepick = false;131 enablevalue = false;132 enablepick = false; 133 enablevalue = false; 132 134 }; 133 135 this.tbody = document.createElement('tbody'); … … 197 199 this.chosenColor.onchange = function() 198 200 { 199 if(/#[0-9a-f]{6,6}/i.test(this.value))200 {201 picker.backSample.style.backgroundColor = this.value;201 if(/#[0-9a-f]{6,6}/i.test(this.value)) 202 { 203 picker.backSample.style.backgroundColor = this.value; 202 204 picker.foreSample.style.color = this.value; 203 }205 } 204 206 }; 205 207 … … 353 355 { 354 356 this.chosenColor.value = initcolor; 355 this.backSample.style.backgroundColor = initcolor;357 this.backSample.style.backgroundColor = initcolor; 356 358 this.foreSample.style.color = initcolor; 357 359 } … … 385 387 else 386 388 { 387 this.table.style.top = 0;389 this.table.style.top = 0; 388 390 } 389 391 } … … 401 403 else 402 404 { 403 this.table.style.left = 0;405 this.table.style.left = 0; 404 406 } 405 407 } … … 410 412 // IE6 ONLY - prevent windowed elements (<SELECT>) to render above the colorpicker 411 413 if (this.is_ie_6) 412 {414 { 413 415 this.iframe.style.top = this.table.style.top; 414 416 this.iframe.style.left = this.table.style.left; … … 422 424 picker.foreSample.style.color = cell.colorCode; 423 425 if((cell.hue >= 195 && cell.saturation > 0.5) || 424 (cell.hue === 0 && cell.saturation === 0 && cell.value < 0.5) ||425 (cell.hue !== 0 && picker.value < 0.75))426 (cell.hue === 0 && cell.saturation === 0 && cell.value < 0.5) || 427 (cell.hue !== 0 && picker.value < 0.75)) 426 428 { 427 429 cell.style.borderColor = '#fff'; … … 445 447 else 446 448 { 447 cell.style.borderColor = '#000';449 cell.style.borderColor = '#000'; 448 450 } 449 451 valuerow = cell.thisrow; … … 456 458 function unpickCell(row,col) 457 459 { 458 picker.saved_cells[row][col].style.borderColor = picker.saved_cells[row][col].colorCode;460 picker.saved_cells[row][col].style.borderColor = picker.saved_cells[row][col].colorCode; 459 461 } 460 462 … … 510 512 { 511 513 enablepick = true; 512 // unpickCell(pickrow,pickcol);514 // unpickCell(pickrow,pickcol); 513 515 picker.saved_cells[pickrow][pickcol].style.borderColor = picker.saved_cells[pickrow][pickcol].colorCode; 514 516 pickCell(this); … … 516 518 td.onmouseover = function() 517 519 { 518 if(enablepick)519 {520 pickCell(this);521 }520 if(enablepick) 521 { 522 pickCell(this); 523 } 522 524 }; 523 525 td.onmouseout = function() 524 526 { 525 if(enablepick)526 {527 // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode;527 if(enablepick) 528 { 529 // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode; 528 530 this.style.borderColor = this.colorCode; 529 }531 } 530 532 }; 531 533 td.ondblclick = function() { Xinha.colorPicker.remember(this.colorCode, picker.savecolors); picker.callback(this.colorCode); picker.close(); }; … … 566 568 { 567 569 enablevalue = true; 568 // unpickCell(valuerow,valuecol);570 // unpickCell(valuerow,valuecol); 569 571 picker.saved_cells[valuerow][valuecol].style.borderColor = picker.saved_cells[valuerow][valuecol].colorCode; 570 572 picker.value = this.hsv_value; … … 643 645 // this.style.borderColor = picker.saved_cells[this.thisrow][this.thiscol].colorCode; 644 646 this.style.borderColor = this.colorCode; 645 }647 } 646 648 }; 647 649 td.ondblclick = function() { Xinha.colorPicker.remember(this.colorCode, picker.savecolors); picker.callback(this.colorCode); picker.close(); }; … … 786 788 this.foreSample.style.color = pickcell.colorCode; 787 789 if((pickcell.hue >= 195 && pickcell.saturation > 0.5) || 788 (pickcell.hue === 0 && pickcell.saturation === 0 && pickcell.value < 0.5) ||789 (pickcell.hue !== 0 && picker.value < 0.75))790 (pickcell.hue === 0 && pickcell.saturation === 0 && pickcell.value < 0.5) || 791 (pickcell.hue !== 0 && picker.value < 0.75)) 790 792 { 791 793 pickcell.style.borderColor = '#fff'; … … 793 795 else 794 796 { 795 pickcell.style.borderColor = '#000';797 pickcell.style.borderColor = '#000'; 796 798 } 797 799 } … … 892 894 { 893 895 var colPicker = new Xinha.colorPicker(pickerConfig); 894 colPicker.open("",chooser, input.value );896 colPicker.open("",chooser, input.value ); 895 897 } 896 898 Xinha.freeLater(this,"chooser"); -
branches/ray/modules/Dialogs/dialog.js
r975 r984 28 28 init = window; // pass this window object by default 29 29 } 30 if (typeof window.showModalDialog == 'function' )30 if (typeof window.showModalDialog == 'function' && !Xinha.is_webkit) // webkit easily looses the selection with window.showModalDialog 31 31 { 32 32 Dialog._return = function(retVal) { 33 33 if (typeof action == 'function') action (retVal); 34 34 } 35 var r = window.showModalDialog(url, init, "dialogheight= 10;dialogwidth=10;resizable=yes");35 var r = window.showModalDialog(url, init, "dialogheight=300;dialogwidth=400;resizable=yes"); 36 36 } 37 37 else … … 61 61 // the dialog will read it's args from this variable 62 62 Dialog._arguments = null; 63 64 Dialog._selection = null; 63 65 64 66 Dialog._geckoOpenModal = function(url, action, init) { -
branches/ray/modules/Gecko/Gecko.js
r975 r984 600 600 var sel = this.getSelection(); 601 601 range = this._doc.createRange(); 602 if ( !node ) 603 { 604 sel.removeAllRanges(); 605 return; 606 } 602 607 // Tables and Images get selected as "objects" rather than the text contents 603 608 if ( collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|textarea|select/) ) -
branches/ray/modules/InternetExplorer/InternetExplorer.js
r975 r984 495 495 { 496 496 var sel = this.getSelection(); 497 if (this.selectionEmpty ) return '';497 if (this.selectionEmpty(sel)) return ''; 498 498 var range = this.createRange(sel); 499 499 … … 638 638 Xinha.getDoctype = function (doc) 639 639 { 640 return (doc.compatMode == "CSS1Compat" ) ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' : '';641 }; 640 return (doc.compatMode == "CSS1Compat" && Xinha.ie_version < 8 ) ? '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">' : ''; 641 }; -
branches/ray/plugins/InsertAnchor/insert-anchor.css
r761 r984 5 5 background-repeat: no-repeat; 6 6 background-position: left top; 7 padding-left: 19px;8 7 border: 1px dotted blue; 9 8 } -
branches/ray/plugins/InsertAnchor/insert-anchor.js
r975 r984 4 4 var self = this; 5 5 6 this.placeholderImg = '<img class="IA_placeholder" src="'+_editor_url+'plugins/InsertAnchor/img/placeholder.gif" />'; 7 6 8 // register the toolbar buttons provided by this plugin 7 9 cfg.registerButton({ … … 37 39 }; 38 40 41 InsertAnchor.prototype.inwardHtml = function(html) 42 { 43 html= html.replace(/(<a[^>]*class="anchor"[^>]*>)/g,"$1"+this.placeholderImg); 44 return html; 45 } 46 InsertAnchor.prototype.outwardHtml = function(html) 47 { 48 html= html.replace(/(<img[^>]*class="?IA_placeholder"?[^>]*>)/ig,""); 49 return html; 50 } 39 51 InsertAnchor.prototype.onGenerateOnce = function() 40 52 { … … 101 113 var anchor = param['name']; 102 114 var a = this.a; 115 var self = this; 103 116 if (anchor == "" || anchor == null) 104 117 { 105 118 if (a) 106 119 { 107 var child = a.innerHTML;120 var child = self.outwardHtml(a.innerHTML); 108 121 a.parentNode.removeChild(a); 109 122 editor.insertHTML(child); … … 119 132 a.id = anchor; 120 133 a.name = anchor; 134 a.title = anchor; 121 135 a.className = "anchor"; 122 a.innerHTML = this.selectedHTML; 123 editor.insertNodeAtSelection(a); 136 a.innerHTML = self.placeholderImg; 137 var html = editor.getSelectedHTML(); 138 if (html) a.innerHTML += html; 139 if (Xinha.is_ie) 140 { 141 range.pasteHTML(a.outerHTML); 142 } 143 else 144 { 145 editor.insertNodeAtSelection(a); 146 } 124 147 } 125 148 else … … 127 150 a.id = anchor; 128 151 a.name = anchor; 152 a.title = anchor; 129 153 a.className = "anchor"; 130 154 } -
branches/ray/plugins/SmartReplace/smart-replace.js
r975 r984 68 68 69 69 var self = this; 70 Xinha._addEvent s(70 Xinha._addEvent( 71 71 self.editor._doc, 72 [ "keypress"],72 "keypress", 73 73 function (event) 74 74 { … … 106 106 if ( !this.active) return true; 107 107 var editor = this.editor; 108 var charCode = Xinha.is_ie ? ev.keyCode : ev. charCode;108 var charCode = Xinha.is_ie ? ev.keyCode : ev.which; 109 109 110 110 var key = String.fromCharCode(charCode); 111 111 112 if (charCode == 32) //space bar113 {114 return this.smartDash()115 }116 112 if ( key == '"' || key == "'") 117 113 { 118 114 Xinha._stopEvent(ev); 119 115 return this.smartQuotes(key); 116 } 117 if (charCode == 32) //space bar 118 { 119 return this.smartReplace(ev, 2, /^\s-/, ' â', false); // space-space -> dash 120 } 121 if ( key == '.' ) // ... -> ellipsis 122 { 123 return this.smartReplace(ev, 2, /\.\./, 'âŠ', true); 120 124 } 121 125 return true; … … 177 181 else 178 182 { 179 r.deleteContents(); 180 editor.insertNodeAtSelection(document.createTextNode(' '+opening)); 183 editor.insertNodeAtSelection(document.createTextNode(opening)); 181 184 } 182 185 editor.getSelection().collapseToEnd(); 183 186 } 184 } 185 186 SmartReplace.prototype.smartDash = function() 187 return false; 188 } 189 190 SmartReplace.prototype.smartReplace = function(ev, lookback, re, replace, stopEvent) 187 191 { 188 192 var editor = this.editor; … … 192 196 if (Xinha.is_ie) 193 197 { 194 r.moveStart('character', - 2);198 r.moveStart('character', -lookback); 195 199 196 if(r.text.match(/\s-/)) 197 { 198 r.text = ' '+ String.fromCharCode(8211); 200 if(r.text.match(re)) 201 { 202 r.text = replace; 203 if (stopEvent) 204 { 205 Xinha._stopEvent(ev); 206 return false 207 } 199 208 } 200 209 } 201 210 else 202 211 { 203 if (r.startOffset > 1) r.setStart(r.startContainer, r.startOffset -2); 204 205 if(r.toString().match(/^ -/)) 206 { 212 if (r.startOffset > 1) r.setStart(r.startContainer, r.startOffset -lookback); 213 214 if(r.toString().match(re)) 215 { 216 this.editor.insertNodeAtSelection(document.createTextNode(replace)); 207 217 r.deleteContents(); 208 this.editor.insertNodeAtSelection(document.createTextNode(' '+String.fromCharCode(8211))); 218 r.collapse(true); 219 if (stopEvent) 220 { 221 Xinha._stopEvent(ev); 222 return false 223 } 209 224 } 210 225 editor.getSelection().collapseToEnd(); 211 226 } 227 return true; 212 228 } 213 229
