Changeset 160
- Timestamp:
- 05/12/05 11:47:25 (8 years ago)
- Files:
-
- 1 modified
-
trunk/htmlarea.js (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/htmlarea.js
r149 r160 1503 1503 } 1504 1504 1505 /* 1506 * EDITOR ACTIVATION NOTES: 1507 * when a page has multiple Xinha editors, ONLY ONE should be activated at any time (this is mostly to 1508 * work around a bug in Mozilla, but also makes some sense). No editor should be activated or focused 1509 * automatically until at least one editor has been activated through user action (by mouse-clicking in 1510 * the editor). 1511 */ 1512 1505 1513 HTMLArea.prototype.editorIsActivated = function() { 1506 1514 try { … … 1513 1521 } 1514 1522 1523 HTMLArea._someEditorHasBeenActivated = false; 1524 HTMLArea._currentlyActiveEditor = false; 1515 1525 HTMLArea.prototype.activateEditor = function() 1516 1526 { 1517 if (HTMLArea.is_gecko && this._doc.designMode != 'on') { 1518 try { 1519 1527 // We only want ONE editor at a time to be active 1528 if(HTMLArea._currentlyActiveEditor) 1529 { 1530 if(HTMLArea._currentlyActiveEditor == this) return true; 1531 HTMLArea._currentlyActiveEditor.deactivateEditor(); 1532 } 1533 1534 if (HTMLArea.is_gecko && this._doc.designMode != 'on') 1535 { 1536 try 1537 { 1520 1538 // cannot set design mode if no display 1521 1539 if (this._iframe.style.display == 'none') … … 1535 1553 this._doc.body.contentEditable = true; 1536 1554 } 1555 1556 // We need to know that at least one editor on the page has been activated 1557 // this is because we will not focus any editor until an editor has been activated 1558 HTMLArea._someEditorHasBeenActivated = true; 1559 HTMLArea._currentlyActiveEditor = this; 1560 1561 var editor = this; 1562 this._timerToolbar = setTimeout(function() { 1563 editor.updateToolbar(); 1564 editor._timerToolbar = null; 1565 }, 250); 1537 1566 } 1538 1567 … … 1547 1576 this._doc.body.contentEditable = false; 1548 1577 } 1578 1579 if(HTMLArea._currentlyActiveEditor != this) 1580 { 1581 // We just deactivated an editor that wasn't marked as the currentlyActiveEditor 1582 1583 return; // I think this should really be an error, there shouldn't be a situation where 1584 // an editor is deactivated without first being activated. but it probably won't 1585 // hurt anything. 1586 } 1587 HTMLArea._currentlyActiveEditor = false; 1549 1588 } 1550 1589 … … 1572 1611 } 1573 1612 } 1574 editor.activateEditor();1575 1613 } 1576 1614 catch(e) … … 1621 1659 1622 1660 // if we have multiple editors some bug in Mozilla makes some lose editing ability 1623 // so activation is done only when mouse down 1624 if(HTMLArea.is_gecko) 1625 { 1626 HTMLArea._addEvents( 1627 editor._iframe.contentWindow, 1628 ["mousedown"], 1629 function() { editor.activateEditor(); } 1630 ); 1631 } 1632 else 1633 { 1634 // redo it for some obscure reason that IE need it.. 1635 editor.activateEditor(); 1636 } 1637 1638 // seems that focusEditor is redondant with the mouse down event handler 1639 // and should be better used 1640 // editor.focusEditor(); 1661 HTMLArea._addEvents 1662 ( 1663 doc, 1664 ["mousedown"], 1665 function() { editor.activateEditor(); return true; } 1666 ); 1667 1668 1641 1669 // intercept some events; for updating the toolbar & keyboard handlers 1642 1670 HTMLArea._addEvents … … 1656 1684 editor._onGenerate(); 1657 1685 } 1658 1659 // update toolbar (hope this will arrive enough late...)1660 editor._timerToolbar = setTimeout(function() {1661 editor.updateToolbar();1662 editor._timerToolbar = null;1663 }, 250);1664 1686 } 1665 1687 … … 1722 1744 } 1723 1745 this._editMode = mode; 1724 // this.focusEditor();1725 1746 1726 1747 for (var i in this.plugins) { … … 1750 1771 this._doc.close(); 1751 1772 this.activateEditor(); 1752 // this._doc.body.contentEditable = true;1753 1773 return true; 1754 1774 } … … 2068 2088 { 2069 2089 // We don't want to focus the field unless at least one field has been activated. 2070 if( !this.editorIsActivated())2090 if(HTMLArea._someEditorHasBeenActivated) 2071 2091 { 2072 this.activateEditor(); 2073 this._iframe.contentWindow.focus(); 2074 } 2075 2092 this.activateEditor(); // Ensure *this* editor is activated 2093 this._iframe.contentWindow.focus(); // and focus it 2094 } 2076 2095 } catch (e) {} break; 2077 2096 case "textmode": try { this._textArea.focus() } catch (e) {} break;
