Changeset 792
- Timestamp:
- 03/20/07 13:10:27 (6 years ago)
- Files:
-
- 1 modified
-
trunk/XinhaCore.js (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/XinhaCore.js
r785 r792 1543 1543 var editor = this; // we'll need "this" in some nested functions 1544 1544 1545 this.setLoadingMessage("Generate Xinha object"); 1546 1547 var url; 1548 1545 1549 // Now load a specific browser plugin which will implement the above for us. 1546 1550 if (Xinha.is_ie) 1547 1551 { 1548 if ( typeof InternetExplorer == 'undefined' ) 1552 url = _editor_url + 'modules/InternetExplorer/InternetExplorer.js'; 1553 if ( typeof InternetExplorer == 'undefined' && !document.getElementById(url) ) 1549 1554 { 1550 Xinha.loadPlugin("InternetExplorer", function() { editor.generate(); }, _editor_url + 'modules/InternetExplorer/InternetExplorer.js');1555 Xinha.loadPlugin("InternetExplorer", function() { editor.generate(); }, url ); 1551 1556 return false; 1552 1557 } … … 1555 1560 else 1556 1561 { 1557 if ( typeof Gecko == 'undefined' ) 1562 url = _editor_url + 'modules/Gecko/Gecko.js'; 1563 if ( typeof Gecko == 'undefined' && !document.getElementById(url) ) 1558 1564 { 1559 Xinha.loadPlugin("Gecko", function() { editor.generate(); }, _editor_url + 'modules/Gecko/Gecko.js');1565 Xinha.loadPlugin("Gecko", function() { editor.generate(); }, url ); 1560 1566 return false; 1561 1567 } … … 1563 1569 } 1564 1570 1565 this.setLoadingMessage('Generate Xinha object'); 1566 1567 if ( typeof Dialog == 'undefined' ) 1568 { 1569 Xinha._loadback(_editor_url + 'modules/Dialogs/dialog.js', this.generate, this ); 1571 if ( typeof Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/dialog.js', this.generate, this ) ) 1572 { 1570 1573 return false; 1571 1574 } 1572 1575 1573 if ( typeof Xinha.Dialog == 'undefined' ) 1574 { 1575 Xinha._loadback(_editor_url + 'modules/Dialogs/inline-dialog.js', this.generate, this ); 1576 if ( typeof Xinha.Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/inline-dialog.js' , this.generate, this ) ) 1577 { 1576 1578 return false; 1577 1579 } 1578 1580 1579 if ( typeof FullScreen == "undefined" ) 1580 { 1581 Xinha.loadPlugin("FullScreen", function() { editor.generate(); }, _editor_url + 'modules/FullScreen/full-screen.js' ); 1581 url = _editor_url + 'modules/FullScreen/full-screen.js'; 1582 if ( typeof FullScreen == "undefined" && !document.getElementById(url) ) 1583 { 1584 Xinha.loadPlugin("FullScreen", function() { editor.generate(); }, url ); 1582 1585 return false; 1583 1586 } 1587 1588 url = _editor_url + 'modules/ColorPicker/ColorPicker.js'; 1589 if ( typeof ColorPicker == 'undefined' && !document.getElementById(url) ) 1590 { 1591 Xinha.loadPlugin("ColorPicker", function() { editor.generate(); } , url ); 1592 return false; 1593 } 1594 else if ( typeof ColorPicker != 'undefined') editor.registerPlugin('ColorPicker'); 1584 1595 1585 1596 var toolbar = editor.config.toolbar; … … 1594 1605 break; 1595 1606 case "insertimage": 1596 if ( typeof InsertImage == 'undefined' && typeof Xinha.prototype._insertImage == 'undefined' ) 1607 url = _editor_url + 'modules/InsertImage/insert_image.js'; 1608 if ( typeof InsertImage == 'undefined' && typeof Xinha.prototype._insertImage == 'undefined' && !document.getElementById(url) ) 1597 1609 { 1598 Xinha.loadPlugin("InsertImage", function() { editor.generate(); } , _editor_url + 'modules/InsertImage/insert_image.js');1610 Xinha.loadPlugin("InsertImage", function() { editor.generate(); } , url ); 1599 1611 return false; 1600 1612 } … … 1602 1614 break; 1603 1615 case "createlink": 1604 if ( typeof CreateLink == 'undefined' && typeof Xinha.prototype._createLink == 'undefined' && typeof Linker == 'undefined' ) 1616 url = _editor_url + 'modules/CreateLink/link.js'; 1617 if ( typeof CreateLink == 'undefined' && typeof Xinha.prototype._createLink == 'undefined' && typeof Linker == 'undefined' && !document.getElementById(url)) 1605 1618 { 1606 Xinha.loadPlugin("CreateLink", function() { editor.generate(); } , _editor_url + 'modules/CreateLink/link.js');1619 Xinha.loadPlugin("CreateLink", function() { editor.generate(); } , url ); 1607 1620 return false; 1608 1621 } … … 1610 1623 break; 1611 1624 case "inserttable": 1612 if ( typeof InsertTable == 'undefined' && typeof Xinha.prototype._insertTable == 'undefined' ) 1625 url = _editor_url + 'modules/InsertTable/insert_table.js'; 1626 if ( typeof InsertTable == 'undefined' && typeof Xinha.prototype._insertTable == 'undefined' && !document.getElementById(url) ) 1613 1627 { 1614 Xinha.loadPlugin("InsertTable", function() { editor.generate(); } , _editor_url + 'modules/InsertTable/insert_table.js');1628 Xinha.loadPlugin("InsertTable", function() { editor.generate(); } , url ); 1615 1629 return false; 1616 1630 } 1617 1631 else if ( typeof InsertTable != 'undefined') editor.registerPlugin('InsertTable'); 1618 1632 break; 1619 case "hilitecolor":1620 case "forecolor":1621 if ( typeof ColorPicker == 'undefined')1622 {1623 Xinha.loadPlugin("ColorPicker", function() { editor.generate(); } , _editor_url + 'modules/ColorPicker/ColorPicker.js');1624 return false;1625 }1626 else if ( typeof ColorPicker != 'undefined') editor.registerPlugin('ColorPicker');1627 break;1628 1629 1633 } 1630 1634 } … … 1643 1647 break; 1644 1648 } 1645 if ( typeof EnterParagraphs == 'undefined' )1649 if ( typeof EnterParagraphs == 'undefined' && !document.getElementById(ParaHandlerPlugin) ) 1646 1650 { 1647 1651 Xinha.loadPlugin("EnterParagraphs", function() { editor.generate(); }, ParaHandlerPlugin ); … … 1661 1665 } 1662 1666 1663 if (typeof GetHtmlImplementation == 'undefined' )1667 if (typeof GetHtmlImplementation == 'undefined' && !document.getElementById(getHtmlMethodPlugin)) 1664 1668 { 1665 1669 Xinha.loadPlugin("GetHtmlImplementation", function() { editor.generate(); } , getHtmlMethodPlugin); … … 2730 2734 { 2731 2735 if ( !Xinha.isSupportedBrowser ) return; 2732 2736 2733 2737 // @todo : try to avoid the use of eval() 2734 2738 // Might already be loaded 2735 if ( eval('typeof ' + pluginName) != 'undefined' ) 2739 //if ( eval('typeof ' + pluginName) != 'undefined' ) 2740 // @todo: try if this works to avoid the use of eval, I've been never getting here when testing 2741 if ( typeof window['pluginName'] != 'undefined' ) 2736 2742 { 2737 2743 if ( callback ) … … 5384 5390 */ 5385 5391 5386 Xinha._loadback = function( Url, Callback, Scope, Bonus)5392 Xinha._loadback = function(url, callback, scope, bonus) 5387 5393 { 5388 var T = !Xinha.is_ie ? "onload" : 'onreadystatechange'; 5389 var S = document.createElement("script"); 5390 S.type = "text/javascript"; 5391 S.src = Url; 5392 if ( Callback ) 5393 { 5394 S[T] = function() 5394 if ( document.getElementById(url) ) 5395 { 5396 return true; 5397 } 5398 var t = !Xinha.is_ie ? "onload" : 'onreadystatechange'; 5399 var s = document.createElement("script"); 5400 s.type = "text/javascript"; 5401 s.src = url; 5402 s.id = url; 5403 if ( callback ) 5404 { 5405 s[t] = function() 5395 5406 { 5396 5407 if ( Xinha.is_ie && ( ! ( /loaded|complete/.test(window.event.srcElement.readyState) ) ) ) … … 5399 5410 } 5400 5411 5401 Callback.call(Scope ? Scope : this, Bonus);5402 S[T] = null;5412 callback.call(scope ? scope : this, bonus); 5413 s[t] = null; 5403 5414 }; 5404 5415 } 5405 document.getElementsByTagName("head")[0].appendChild(S); 5416 document.getElementsByTagName("head")[0].appendChild(s); 5417 return false; 5406 5418 }; 5407 5419 … … 5474 5486 { 5475 5487 this.setLoadingMessage('Register plugin $plugin', 'Xinha', {'plugin': plugin_names[i]}); 5476 this.registerPlugin( eval(plugin_names[i]));5488 this.registerPlugin(plugin_names[i]); 5477 5489 } 5478 5490 }
