includes/clientside/tinymce/plugins/safari/editor_plugin_src.js
changeset 1193 e3b94bd055dc
parent 778 57ce13805b6f
--- a/includes/clientside/tinymce/plugins/safari/editor_plugin_src.js	Mon Dec 21 15:41:05 2009 -0500
+++ b/includes/clientside/tinymce/plugins/safari/editor_plugin_src.js	Tue Dec 22 13:09:59 2009 -0500
@@ -6,7 +6,7 @@
  */
 
 (function() {
-	var Event = tinymce.dom.Event, grep = tinymce.grep, each = tinymce.each, inArray = tinymce.inArray, isOldWebKit = tinymce.isOldWebKit;
+	var Event = tinymce.dom.Event, grep = tinymce.grep, each = tinymce.each, inArray = tinymce.inArray;
 
 	function isEmpty(d, e, f) {
 		var w, n;
@@ -55,6 +55,8 @@
 					ed.getDoc().execCommand("CreateLink", false, v);
 			});
 
+/*
+			// WebKit generates spans out of thin air this patch used to remove them but it will also remove styles we want so it's disabled for now
 			ed.onPaste.add(function(ed, e) {
 				function removeStyles(e) {
 					e = e.target;
@@ -74,7 +76,7 @@
 					Event.remove(ed.getDoc(), 'DOMNodeInserted', removeStyles);
 				}, 0);
 			});
-
+*/
 			ed.onKeyUp.add(function(ed, e) {
 				var h, b, r, n, s;
 
@@ -116,6 +118,14 @@
 				ed.selection.select(ed.dom.get('_mce_tmp'));
 				ed.getDoc().execCommand("Delete", false, ' ');
 			});
+	
+	/*		ed.onKeyDown.add(function(ed, e) {
+				// Ctrl+A select all will fail on WebKit since if you paste the contents you selected it will produce a odd div wrapper
+				if ((e.ctrlKey || e.metaKey) && e.keyCode == 65) {
+					ed.selection.select(ed.getBody(), 1);
+					return Event.cancel(e);
+				}
+			});*/
 
 			ed.onKeyPress.add(function(ed, e) {
 				var se, li, lic, r1, r2, n, sel, doc, be, af, pa;
@@ -209,9 +219,6 @@
 
 			ed.onInit.add(function() {
 				t._fixWebKitSpans();
-
-				if (isOldWebKit)
-					t._patchSafari2x(ed);
 			});
 
 			ed.onSetContent.add(function() {
@@ -337,24 +344,13 @@
 		_fixWebKitSpans : function() {
 			var t = this, ed = t.editor;
 
-			if (!isOldWebKit) {
-				// Use mutator events on new WebKit
-				Event.add(ed.getDoc(), 'DOMNodeInserted', function(e) {
-					e = e.target;
+			// Use mutator events on new WebKit
+			Event.add(ed.getDoc(), 'DOMNodeInserted', function(e) {
+				e = e.target;
 
-					if (e && e.nodeType == 1)
-						t._fixAppleSpan(e);
-				});
-			} else {
-				// Do post command processing in old WebKit since the browser crashes on Mutator events :(
-				ed.onExecCommand.add(function() {
-					each(ed.dom.select('span'), function(n) {
-						t._fixAppleSpan(n);
-					});
-
-					ed.nodeChanged();
-				});
-			}
+				if (e && e.nodeType == 1)
+					t._fixAppleSpan(e);
+			});
 		},
 
 		_fixAppleSpan : function(e) {
@@ -414,78 +410,6 @@
 			}
 		},
 
-		_patchSafari2x : function(ed) {
-			var t = this, setContent, getNode, dom = ed.dom, lr;
-
-			// Inline dialogs
-			if (ed.windowManager.onBeforeOpen) {
-				ed.windowManager.onBeforeOpen.add(function() {
-					r = ed.selection.getRng();
-				});
-			}
-
-			// Fake select on 2.x
-			ed.selection.select = function(n) {
-				this.getSel().setBaseAndExtent(n, 0, n, 1);
-			};
-
-			getNode = ed.selection.getNode;
-			ed.selection.getNode = function() {
-				return t.selElm || getNode.call(this);
-			};
-
-			// Fake range on Safari 2.x
-			ed.selection.getRng = function() {
-				var t = this, s = t.getSel(), d = ed.getDoc(), r, rb, ra, di;
-
-				// Fake range on Safari 2.x
-				if (s.anchorNode) {
-					r = d.createRange();
-
-					try {
-						// Setup before range
-						rb = d.createRange();
-						rb.setStart(s.anchorNode, s.anchorOffset);
-						rb.collapse(1);
-
-						// Setup after range
-						ra = d.createRange();
-						ra.setStart(s.focusNode, s.focusOffset);
-						ra.collapse(1);
-
-						// Setup start/end points by comparing locations
-						di = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
-						r.setStart(di ? s.anchorNode : s.focusNode, di ? s.anchorOffset : s.focusOffset);
-						r.setEnd(di ? s.focusNode : s.anchorNode, di ? s.focusOffset : s.anchorOffset);
-
-						lr = r;
-					} catch (ex) {
-						// Sometimes fails, at least we tried to do it by the book. I hope Safari 2.x will go disappear soooon!!!
-					}
-				}
-
-				return r || lr;
-			};
-
-			// Fix setContent so it works
-			setContent = ed.selection.setContent;
-			ed.selection.setContent = function(h, s) {
-				var r = this.getRng(), b;
-
-				try {
-					setContent.call(this, h, s);
-				} catch (ex) {
-					// Workaround for Safari 2.x
-					b = dom.create('body');
-					b.innerHTML = h;
-
-					each(b.childNodes, function(n) {
-						r.insertNode(n.cloneNode(true));
-					});
-				}
-			};
-		},
-
 		_insertBR : function(ed) {
 			var dom = ed.dom, s = ed.selection, r = s.getRng(), br;