| 2482 | | if ( callback ) |
| 2483 | | { |
| 2484 | | HTMLArea._loadback(plugin_file, function() { callback(pluginName); }); |
| 2485 | | } |
| 2486 | | else |
| 2487 | | { |
| 2488 | | /** |
| 2489 | | * @todo : try to avoid the use of document.write, it's evil |
| 2490 | | * @todo : better yet, try to update HTMLArea._loadback to let it include |
| 2491 | | * the file without a callback function |
| 2492 | | * try |
| 2493 | | * { |
| 2494 | | * var head = document.getElementsByTagName('head')[0]; |
| 2495 | | * var script = document.createElement('script'); |
| 2496 | | * script.type = "text/javascript"; |
| 2497 | | * script.src = plugin_file; |
| 2498 | | * head.appendChild(script); |
| 2499 | | * } |
| 2500 | | * catch(ex) |
| 2501 | | * { |
| 2502 | | * document.write('<script type="text/javascript" src="' + plugin_file + '"></script>'); |
| 2503 | | * } |
| 2504 | | */ |
| 2505 | | document.write('<script type="text/javascript" src="' + plugin_file + '"></script>'); |
| 2506 | | } |
| | 2476 | HTMLArea._loadback(plugin_file, callback ? function() { callback(pluginName); } : null); |
| 6473 | | |
| 6474 | | HTMLArea._loadback = function(src, callback) |
| 6475 | | { |
| 6476 | | var head = document.getElementsByTagName("head")[0]; |
| 6477 | | var evt = HTMLArea.is_ie ? "onreadystatechange" : "onload"; |
| 6478 | | |
| 6479 | | var script = document.createElement("script"); |
| 6480 | | script.type = "text/javascript"; |
| 6481 | | script.src = src; |
| 6482 | | script[evt] = function() |
| 6483 | | { |
| 6484 | | if ( HTMLArea.is_ie && ! ( /loaded|complete/.test(window.event.srcElement.readyState) ) ) |
| 6485 | | { |
| 6486 | | return; |
| 6487 | | } |
| 6488 | | callback(); |
| 6489 | | }; |
| 6490 | | head.appendChild(script); |
| | 6443 | /** |
| | 6444 | * Load a javascript file by inserting it in the HEAD tag and eventually call a function when loaded |
| | 6445 | * @param {string} U (Url) Source url of the file to load |
| | 6446 | * @param {object} C {Callback} Callback function to launch once ready (optional) |
| | 6447 | * @param {object} O (scOpe) Application scope for the callback function (optional) |
| | 6448 | * @param {object} B (Bonus} Arbitrary object send as a param to the callback function (optional) |
| | 6449 | * @public |
| | 6450 | */ |
| | 6451 | HTMLArea._loadback = function(U, C, O, B) |
| | 6452 | { |
| | 6453 | var S = document.createElement("script"); |
| | 6454 | S.type = "text/javascript"; |
| | 6455 | S.src = U; |
| | 6456 | if ( C ) |
| | 6457 | { |
| | 6458 | S[HTMLArea.is_ie ? "onreadystatechange" : "onload"] = function() |
| | 6459 | { |
| | 6460 | if ( HTMLArea.is_ie && ! ( /loaded|complete/.test(window.event.srcElement.readyState) ) ) |
| | 6461 | { |
| | 6462 | return; |
| | 6463 | } |
| | 6464 | C.call(O ? O : this, B); |
| | 6465 | }; |
| | 6466 | } |
| | 6467 | document.getElementsByTagName("head")[0].appendChild(S); |