src/cm/media/js/site/c_text_view_comments.js
changeset 184 0d9a2a99ffda
parent 144 e7e1bc64f613
child 186 04644502cb79
equal deleted inserted replaced
183:f1c6f8fadfef 184:0d9a2a99ffda
   180 	gTimer = CY.Lang.later(200, this, checkForAlignement, [], true) ;
   180 	gTimer = CY.Lang.later(200, this, checkForAlignement, [], true) ;
   181 	CY.on('scroll', onFrameScroll, window, this, true);
   181 	CY.on('scroll', onFrameScroll, window, this, true);
   182 	CY.on('resize', onFrameScroll, window, this, true);
   182 	CY.on('resize', onFrameScroll, window, this, true);
   183 };
   183 };
   184 
   184 
   185 // serious tests were made : various browsers + comments on a link.
       
   186 preventLinksInText = function() {
   185 preventLinksInText = function() {
   187 	var interceptLink = function(e) {
   186 	var interceptLink = function(e) {
   188 		e.preventDefault();
       
   189 
       
   190 		var a = e.target;
   187 		var a = e.target;
   191 		while (a != null && a.get("href") == null) {
   188 		var href = null;
       
   189 		while (a != null && href == null) {
   192 			a = a.get('parentNode');
   190 			a = a.get('parentNode');
   193 		}
   191 			href = a.get("href");
   194 
   192 		}
   195 		if (a != null && a.get("href") != null) {
   193 		
   196 			window.open(a.get("href"));
   194 		if (a != null && href != null) {
   197 		}
   195 			//alert(window.location) ;
   198 
   196 			var loc = (new String(window.location)) ;
       
   197 			
       
   198 			var clean_window_location = loc ;
       
   199 			
       
   200 			var ind = loc.indexOf('#') ;
       
   201 			if (ind != -1)
       
   202 				clean_window_location = loc.substring(0, ind) ;
       
   203 			
       
   204 			if (href.indexOf(clean_window_location) == -1q ) {
       
   205 				window.open(a.get("href"));
       
   206 				e.preventDefault(); ;
       
   207 			}
       
   208 		}
   199 	} ;
   209 	} ;
   200 
   210 
   201 	CY.all("#textcontainer a").on("click", interceptLink);
   211 	CY.all("#textcontainer a").on("click", interceptLink);
   202 };
   212 };
   203 
   213