diff rhodecode/public/js/rhodecode.js @ 2698:4debfe3b50be beta

ie8 fixes for inline comments :/
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 07 Aug 2012 22:10:44 +0200
parents 78694f9acd31
children 4eef5eeb81a3
line wrap: on
line diff
--- a/rhodecode/public/js/rhodecode.js	Tue Aug 07 02:55:15 2012 +0200
+++ b/rhodecode/public/js/rhodecode.js	Tue Aug 07 22:10:44 2012 +0200
@@ -75,6 +75,20 @@
     };
 }
 
+// IE(CRAP) doesn't support previousElementSibling
+var prevElementSibling = function( el ) {
+    if( el.previousElementSibling ) {
+        return el.previousElementSibling;
+    } else {
+        while( el = el.previousSibling ) {
+            if( el.nodeType === 1 ) return el;
+        }
+    }
+}
+
+
+
+
 /**
  * SmartColorGenerator
  *
@@ -483,7 +497,10 @@
 		  tooltip_activate();
 		  MentionsAutoComplete('text_'+lineno, 'mentions_container_'+lineno, 
 	                         _USERS_AC_DATA, _GROUPS_AC_DATA);
-		  YUD.get('text_'+lineno).focus();
+		  var _e = YUD.get('text_'+lineno);
+		  if(_e){
+			  _e.focus();
+		  }
 	  },10)
 };
 
@@ -492,7 +509,7 @@
     var postData = {'_method':'delete'};
     var success = function(o){
         var n = YUD.get('comment-tr-'+comment_id);
-        var root = n.previousElementSibling.previousElementSibling;
+        var root = prevElementSibling(prevElementSibling(n));
         n.parentNode.removeChild(n);
 
         // scann nodes, and attach add button to last one
@@ -1234,23 +1251,24 @@
 		return [null, null];
     };
     
-	ownerAC.textboxKeyUpEvent.subscribe(function(type, args){
-		
-		var ac_obj = args[0];
-		var currentMessage = args[1];
-		var currentCaretPosition = args[0]._elTextbox.selectionStart;
-
-		var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); 
-		var curr_search = null;
-		if(unam[0]){
-			curr_search = unam[0];
-		}
-		
-		ownerAC.dataSource.chunks = unam[1];
-		ownerAC.dataSource.mentionQuery = curr_search;
-
-	})
-
+    if (ownerAC.textboxKeyUpEvent){
+		ownerAC.textboxKeyUpEvent.subscribe(function(type, args){
+			
+			var ac_obj = args[0];
+			var currentMessage = args[1];
+			var currentCaretPosition = args[0]._elTextbox.selectionStart;
+	
+			var unam = ownerAC.get_mention(currentMessage, currentCaretPosition); 
+			var curr_search = null;
+			if(unam[0]){
+				curr_search = unam[0];
+			}
+			
+			ownerAC.dataSource.chunks = unam[1];
+			ownerAC.dataSource.mentionQuery = curr_search;
+	
+		})
+	}	
     return {
         ownerDS: ownerDS,
         ownerAC: ownerAC,