]> git.mjollnir.org Git - s9y.git/commitdiff
some try/catch for htmlarea, thanks to Jay Bertrandt
authorgarvinhicking <garvinhicking>
Thu, 23 Mar 2006 11:10:16 +0000 (11:10 +0000)
committergarvinhicking <garvinhicking>
Thu, 23 Mar 2006 11:10:16 +0000 (11:10 +0000)
htmlarea/htmlarea.js

index f22e11431e4bae5529f25fa8a4ae0cfa3dfcd6a1..0818f888d4f994592045a8797970c590986e3ae8 100644 (file)
@@ -734,9 +734,23 @@ HTMLArea.prototype.generate = function () {
        // add a handler for the "back/forward" case -- on body.unload we save
        // the HTML content into the original textarea.
        try {
-               window.onunload = function() {
+
+        function addWYSIWYGUnloadEvent(func) {
+          var oldonunload = window.onunload;
+          if (typeof window.onunload != 'function') {
+            window.onunload = func;
+          } else {
+            window.onunload = function() {
+              oldonunload();
+              func();
+            }
+          }
+        }
+
+               addWYSIWYGUnloadEvent(function() {
                        editor._textArea.value = editor.getHTML();
-               };
+               });
+
        } catch(e) {};
 
        // creates & appends the toolbar
@@ -858,13 +872,15 @@ HTMLArea.prototype.generate = function () {
 
                // check if any plugins have registered refresh handlers
                for (var i in editor.plugins) {
-                       var plugin = editor.plugins[i].instance;
-                       if (typeof plugin.onGenerate == "function")
-                               plugin.onGenerate();
-                       if (typeof plugin.onGenerateOnce == "function") {
-                               plugin.onGenerateOnce();
-                               plugin.onGenerateOnce = null;
-                       }
+                       try {
+                               var plugin = editor.plugins[i].instance;
+                               if (typeof plugin.onGenerate == "function")
+                                       plugin.onGenerate();
+                               if (typeof plugin.onGenerateOnce == "function") {
+                                       plugin.onGenerateOnce();
+                                       plugin.onGenerateOnce = null;
+                               }
+                       }catch(e) { /*alert(e);*/ }
                }
 
                setTimeout(function() {
@@ -925,8 +941,10 @@ HTMLArea.prototype.setMode = function(mode) {
        this.focusEditor();
 
        for (var i in this.plugins) {
-               var plugin = this.plugins[i].instance;
-               if (typeof plugin.onMode == "function") plugin.onMode(mode);
+               try {
+                       var plugin = this.plugins[i].instance;
+                       if (typeof plugin.onMode == "function") plugin.onMode(mode);
+               } catch(e) { /*alert(e);*/ };
        }
 };
 
@@ -1296,14 +1314,16 @@ HTMLArea.prototype.updateToolbar = function(noStatus) {
                                }
                        }
                }
+               try {
                btn.state("enabled", (!text || btn.text) && inContext);
+               } catch(e) { /*alert(e);*/ }
                if (typeof cmd == "function") {
                        continue;
                }
                // look-it-up in the custom dropdown boxes
                var dropdown = this.config.customSelects[cmd];
                if ((!text || btn.text) && (typeof dropdown != "undefined")) {
-                       dropdown.refresh(this);
+                       try { dropdown.refresh(this); } catch(e) { /*alert(e);*/ }
                        continue;
                }
                switch (cmd) {
@@ -1379,9 +1399,11 @@ HTMLArea.prototype.updateToolbar = function(noStatus) {
 
        // check if any plugins have registered refresh handlers
        for (var i in this.plugins) {
-               var plugin = this.plugins[i].instance;
-               if (typeof plugin.onUpdateToolbar == "function")
-                       plugin.onUpdateToolbar();
+               try {
+                       var plugin = this.plugins[i].instance;
+                       if (typeof plugin.onUpdateToolbar == "function")
+                               plugin.onUpdateToolbar();
+               } catch(e) { /*alert(e);*/ }
        }
 };
 
@@ -1866,10 +1888,12 @@ HTMLArea.prototype._editorEvent = function(ev) {
 
        if (keyEvent)
                for (var i in editor.plugins) {
-                       var plugin = editor.plugins[i].instance;
-                       if (typeof plugin.onKeyPress == "function")
-                               if (plugin.onKeyPress(ev))
-                                       return false;
+                       try {
+                               var plugin = editor.plugins[i].instance;
+                               if (typeof plugin.onKeyPress == "function")
+                                       if (plugin.onKeyPress(ev))
+                                               return false;
+                       } catch(e) { /*alert(e);*/ }
                }
        if (keyEvent && ev.ctrlKey && !ev.altKey) {
                var sel = null;