Changeset 193
- Timestamp:
- 05/24/05 21:30:03 (8 years ago)
- Files:
-
- 1 modified
-
trunk/htmlarea.js (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htmlarea.js
r192 r193 1293 1293 this._framework.ed_cell.appendChild(iframe); 1294 1294 this._iframe = iframe; 1295 this._iframe.className = 'xinha_iframe'; 1295 1296 1296 1297 // creates & appends the status bar … … 1301 1302 var textarea = this._textArea; 1302 1303 textarea.parentNode.insertBefore(htmlarea, textarea); 1304 textarea.className = 'xinha_textarea'; 1303 1305 1304 1306 // extract the textarea and insert it into the htmlarea 1305 textarea.parentNode.removeChild(textarea);1307 HTMLArea.removeFromParent(textarea); 1306 1308 this._framework.ed_cell.appendChild(textarea); 1307 1309 … … 1515 1517 var col_span = 1; 1516 1518 1517 if(panels.left.on && panels.left.panels.length && HTMLArea.hasDisplayedChildren(panels.left.container)) 1519 function panel_is_alive(pan) 1520 { 1521 if(panels[pan].on && panels[pan].panels.length && HTMLArea.hasDisplayedChildren(panels[pan].container)) 1522 { 1523 return true; 1524 } 1525 1526 // Otherwise make sure it's been removed from the framework 1527 else 1528 { 1529 HTMLArea.removeFromParent(panels[pan].container); 1530 return false; 1531 } 1532 } 1533 1534 if(panel_is_alive('left')) 1518 1535 { 1519 1536 col_span += 1; 1520 if(! panels.left.container.parentNode)1537 if(!HTMLArea.hasParentNode(panels.left.container)) 1521 1538 { 1522 1539 this._framework.ler_row.insertBefore(panels.left.container,this._framework.ed_cell); 1523 1540 } 1524 1541 } 1525 else 1526 { 1527 if(panels.left.container.parentNode) 1528 { 1529 panels.left.container.parentNode.removeChild(panels.left.container); 1530 } 1531 } 1532 1533 if(panels.top.on && panels.top.panels.length && HTMLArea.hasDisplayedChildren(panels.top.container)) 1534 { 1535 if(!panels.top.container.parentNode) 1542 1543 if(panel_is_alive('top')) 1544 { 1545 if(!HTMLArea.hasParentNode(panels.top.container)) 1536 1546 { 1537 1547 this._framework.tp_row.appendChild(panels.top.container); 1538 1548 } 1539 1549 } 1540 else 1541 { 1542 if(panels.top.container.parentNode) 1543 { 1544 panels.top.container.parentNode.removeChild(panels.top.container); 1545 } 1546 } 1547 1548 if(panels.right.on && panels.right.panels.length && HTMLArea.hasDisplayedChildren(panels.right.container)) 1550 1551 if(panel_is_alive('right')) 1549 1552 { 1550 1553 col_span += 1; 1551 if(! panels.right.container.parentNode)1554 if(!HTMLArea.hasParentNode(panels.right.container)) 1552 1555 { 1553 1556 this._framework.ler_row.insertBefore(panels.right.container, this._framework.ed_cell.nextSibling); 1554 1557 } 1555 1558 } 1556 else 1557 { 1558 if(panels.right.container.parentNode) 1559 { 1560 panels.right.container.parentNode.removeChild(panels.right.container); 1561 } 1562 } 1563 1564 if(panels.bottom.on && panels.bottom.panels.length && HTMLArea.hasDisplayedChildren(panels.bottom.container)) 1565 { 1566 if(!panels.bottom.container.parentNode) 1567 { 1568 this._framework.bp_row.appendChild(panels.right.container); 1569 } 1570 } 1571 else 1572 { 1573 if(panels.bottom.container.parentNode) 1574 { 1575 panels.bottom.container.parentNode.removeChild(panels.bottom.container); 1559 1560 if(panel_is_alive('bottom')) 1561 { 1562 if(!HTMLArea.hasParentNode(panels.bottom.container)) 1563 { 1564 this._framework.bp_row.appendChild(panels.bottom.container); 1576 1565 } 1577 1566 } … … 1585 1574 if(!this._framework.tp_row.childNodes.length) 1586 1575 { 1587 if(this._framework.tp_row.parentNode) 1588 { 1589 this._framework.tp_row.parentNode.removeChild(this._framework.tp_row); 1590 } 1576 HTMLArea.removeFromParent(this._framework.tp_row); 1591 1577 } 1592 1578 else 1593 1579 { 1594 if(! this._framework.tp_row.parentNode)1580 if(!HTMLArea.hasParentNode(this._framework.tp_row)) 1595 1581 { 1596 1582 this._framework.tbody.insertBefore(this._framework.tp_row, this._framework.ler_row); … … 1601 1587 if(!this._framework.bp_row.childNodes.length) 1602 1588 { 1603 if(this._framework.bp_row.parentNode) 1604 { 1605 this._framework.bp_row.parentNode.removeChild(this._framework.bp_row); 1606 } 1589 HTMLArea.removeFromParent(this._framework.bp_row); 1607 1590 } 1608 1591 else 1609 1592 { 1610 if(! this._framework.bp_row.parentNode)1593 if(!HTMLArea.hasParentNode(this._framework.bp_row)) 1611 1594 { 1612 1595 this._framework.tbody.insertBefore(this._framework.bp_row, this._framework.ler_row.nextSibling); … … 1615 1598 1616 1599 // finally if the statusbar is on, insert it 1617 if(this.config.statusBar) 1618 { 1619 if(!this._framework.sb_row.parentNode) 1600 if(!this.config.statusBar) 1601 { 1602 HTMLArea.removeFromParent(this._framework.sb_row); 1603 } 1604 else 1605 { 1606 if(!HTMLArea.hasParentNode(this._framework.sb_row)) 1620 1607 { 1621 1608 this._framework.table.appendChild(this._framework.sb_row); 1622 }1623 }1624 else1625 {1626 if(this._framework.sb_row.parentNode)1627 {1628 this._framework.sb_row.parentNode.removeChild(this._framework.sb_row);1629 1609 } 1630 1610 } … … 1893 1873 + ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;} \n" 1894 1874 + "</style>\n"; 1895 html += "<style>" 1896 + editor.config.pageStyle + "\n" 1875 html += "<style type=\"text/css\">" 1897 1876 + "html, body { border: 0px; } \n" 1898 1877 + "span.macro, span.macro ul, span.macro div, span.macro p {background : #CCCCCC;}\n" 1899 1878 + "</style>\n"; 1879 1880 if(editor.config.pageStyle) 1881 { 1882 html += "<style type=\"text/css\">\n" + editor.config.pageStyle + "\n</style>"; 1883 } 1884 1900 1885 if(typeof editor.config.pageStyleSheets !== 'undefined') 1901 1886 { … … 2303 2288 var txt = document.createTextNode(HTMLArea.getInnerText(el)); 2304 2289 el.parentNode.insertBefore(txt, el); 2305 el.parentNode.removeChild(el);2290 HTMLArea.removeFromParent(el); 2306 2291 } 2307 2292 ++stats.mso_xmlel; … … 2310 2295 if (/^(a|span|b|strong|i|em|font)$/i.test(el.tagName) && 2311 2296 !el.firstChild) { 2312 el.parentNode.removeChild(el);2297 HTMLArea.removeFromParent(el); 2313 2298 ++stats.empty_tags; 2314 2299 } … … 2737 2722 plugin.onUpdateToolbar(); 2738 2723 } 2724 2739 2725 2740 2726 } … … 3147 3133 this.forceRedraw(); 3148 3134 var range; 3149 var collapsed = (typeof pos != "undefined");3135 var collapsed = typeof pos == "undefined" ? true : false; 3150 3136 if (HTMLArea.is_ie) { 3151 3137 // Tables and Images get selected as "objects" rather than the text contents 3152 if( !collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img/))3138 if(collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|select|textarea/)) 3153 3139 { 3154 3140 range = this._doc.body.createControlRange(); … … 3166 3152 range = this._doc.createRange(); 3167 3153 // Tables and Images get selected as "objects" rather than the text contents 3168 if( !collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img/))3154 if(collapsed && node.tagName && node.tagName.toLowerCase().match(/table|img|input|textarea|select/)) 3169 3155 { 3170 3156 range.selectNode(node); 3171 (collapsed) && range.collapse(pos);3172 3157 } 3173 3158 else … … 3629 3614 if(typeof tag == 'string') tag = editor._doc.createElement(tag); 3630 3615 var a = textNode.parentNode.insertBefore(tag, rightText); 3631 textNode.parentNode.removeChild(textNode);3616 HTMLArea.removeFromParent(textNode); 3632 3617 a.appendChild(textNode); 3633 3618 rightText.data = ' ' + rightText.data; … … 3650 3635 a.removeChild(t); 3651 3636 a.parentNode.insertBefore(t, a); 3652 a.parentNode.removeChild(a);3637 HTMLArea.removeFromParent(a); 3653 3638 editor._unLink = null; 3654 3639 editor._unlinkOnUndo = false; … … 3804 3789 { 3805 3790 var elm = this._activeElement(sel); 3806 elm.parentNode.removeChild(elm);3791 HTMLArea.removeFromParent(elm); 3807 3792 return true; 3808 3793 } … … 3844 3829 p.appendChild(SC.firstChild); 3845 3830 SC.parentNode.insertBefore(p, SC); 3846 SC.parentNode.removeChild(SC);3831 HTMLArea.removeFromParent(SC); 3847 3832 var r = range.cloneRange(); 3848 3833 r.setStartBefore(newr); … … 4685 4670 for (i = 0; i < attrs.length; ++i) { 4686 4671 var a = attrs.item(i); 4687 if (!a.specified ) {4672 if (!a.specified && !(root.tagName.toLowerCase().match(/input|option/) && a.nodeName == 'value')) { 4688 4673 continue; 4689 4674 } … … 5005 4990 alert('An error has occurred: ' + req.statusText); 5006 4991 } 5007 req.onreadystatechange = null;5008 4992 } 5009 4993 } … … 5045 5029 alert('An error has occurred: ' + req.statusText); 5046 5030 } 5047 req.onreadystatechange = null;5048 5031 } 5049 5032 } … … 5314 5297 } 5315 5298 5299 /** Utility function to base64_encode some arbitrary data, uses the builtin btoa() if it exists (Moz) */ 5300 5301 HTMLArea.base64_encode = function(input) 5302 { 5303 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 5304 var output = ""; 5305 var chr1, chr2, chr3; 5306 var enc1, enc2, enc3, enc4; 5307 var i = 0; 5308 5309 do { 5310 chr1 = input.charCodeAt(i++); 5311 chr2 = input.charCodeAt(i++); 5312 chr3 = input.charCodeAt(i++); 5313 5314 enc1 = chr1 >> 2; 5315 enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 5316 enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 5317 enc4 = chr3 & 63; 5318 5319 if (isNaN(chr2)) { 5320 enc3 = enc4 = 64; 5321 } else if (isNaN(chr3)) { 5322 enc4 = 64; 5323 } 5324 5325 output = output + keyStr.charAt(enc1) + keyStr.charAt(enc2) + 5326 keyStr.charAt(enc3) + keyStr.charAt(enc4); 5327 } while (i < input.length); 5328 5329 return output; 5330 } 5331 5332 /** Utility function to base64_decode some arbitrary data, uses the builtin atob() if it exists (Moz) */ 5333 5334 HTMLArea.base64_decode =function(input) 5335 { 5336 var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; 5337 var output = ""; 5338 var chr1, chr2, chr3; 5339 var enc1, enc2, enc3, enc4; 5340 var i = 0; 5341 5342 // remove all characters that are not A-Z, a-z, 0-9, +, /, or = 5343 input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); 5344 5345 do { 5346 enc1 = keyStr.indexOf(input.charAt(i++)); 5347 enc2 = keyStr.indexOf(input.charAt(i++)); 5348 enc3 = keyStr.indexOf(input.charAt(i++)); 5349 enc4 = keyStr.indexOf(input.charAt(i++)); 5350 5351 chr1 = (enc1 << 2) | (enc2 >> 4); 5352 chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 5353 chr3 = ((enc3 & 3) << 6) | enc4; 5354 5355 output = output + String.fromCharCode(chr1); 5356 5357 if (enc3 != 64) { 5358 output = output + String.fromCharCode(chr2); 5359 } 5360 if (enc4 != 64) { 5361 output = output + String.fromCharCode(chr3); 5362 } 5363 } while (i < input.length); 5364 5365 return output; 5366 } 5367 5368 HTMLArea.removeFromParent = function(el) 5369 { 5370 if(!el.parentNode) return; 5371 var pN = el.parentNode; 5372 pN.removeChild(el); 5373 return el; 5374 } 5375 5376 HTMLArea.hasParentNode = function(el) 5377 { 5378 if(el.parentNode) 5379 { 5380 // When you remove an element from the parent in IE it makes the parent 5381 // of the element a document fragment. Moz doesn't. 5382 if(el.parentNode.nodeType == 11) 5383 { 5384 return false; 5385 } 5386 return true; 5387 } 5388 5389 return false; 5390 } 5391 5392 HTMLArea.getOuterHTML = function(element) 5393 { 5394 if(HTMLArea.is_ie) 5395 { 5396 return element.outerHTML; 5397 } 5398 else 5399 { 5400 return (new XMLSerializer()).serializeToString(element); 5401 } 5402 } 5403 5404 5316 5405 HTMLArea.init();
