| 
									
										
										
										
											2013-05-14 18:10:33 +04:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | //var DEBUG = DEBUG != null ? DEBUG : true
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | var CURSOR_SHOW_THRESHOLD = 10 | 
					
						
							|  |  |  | var CURSOR_HIDE_TIMEOUT = 2000 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-24 14:40:15 +04:00
										 |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | // XXX revise...
 | 
					
						
							| 
									
										
										
										
											2013-06-01 18:43:14 +04:00
										 |  |  | // NOTE: to catch the click event correctly while the cursor is hidden
 | 
					
						
							|  |  |  | //		this must be the first to get the event...
 | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | function autoHideCursor(elem){ | 
					
						
							|  |  |  | 	elem = $(elem) | 
					
						
							|  |  |  | 	elem | 
					
						
							|  |  |  | 		.on('mousemove', function(evt){ | 
					
						
							| 
									
										
										
										
											2013-06-01 18:43:14 +04:00
										 |  |  | 			_cursor_pos = window._cursor_pos == null || elem.css('cursor') == 'auto' ? | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | 						[evt.clientX, evt.clientY]  | 
					
						
							|  |  |  | 					: _cursor_pos | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			if(Math.abs(evt.clientX - _cursor_pos[0]) > CURSOR_SHOW_THRESHOLD  | 
					
						
							|  |  |  | 					|| Math.abs(evt.clientY - _cursor_pos[1]) > CURSOR_SHOW_THRESHOLD){ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if(window._cursor_timeout != null){ | 
					
						
							|  |  |  | 					clearTimeout(_cursor_timeout) | 
					
						
							| 
									
										
										
										
											2013-06-01 18:43:14 +04:00
										 |  |  | 					_cursor_timeout = null | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-06-01 18:43:14 +04:00
										 |  |  | 				elem.css('cursor', '') | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							|  |  |  | 				_cursor_timeout = setTimeout(function(){ | 
					
						
							|  |  |  | 					if(Math.abs(evt.clientX - _cursor_pos[0]) < CURSOR_SHOW_THRESHOLD  | 
					
						
							|  |  |  | 							|| Math.abs(evt.clientY - _cursor_pos[1]) < CURSOR_SHOW_THRESHOLD){ | 
					
						
							| 
									
										
										
										
											2013-06-01 18:43:14 +04:00
										 |  |  | 						elem.css('cursor', 'none') | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				}, CURSOR_HIDE_TIMEOUT) | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2013-06-01 18:43:14 +04:00
										 |  |  | 		.click(function(evt){ | 
					
						
							|  |  |  | 			if(elem.css('cursor') == 'none'){ | 
					
						
							|  |  |  | 				//event.stopImmediatePropagation()
 | 
					
						
							|  |  |  | 				//event.preventDefault()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				if(window._cursor_timeout != null){ | 
					
						
							|  |  |  | 					clearTimeout(_cursor_timeout) | 
					
						
							|  |  |  | 					_cursor_timeout = null | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				elem.css('cursor', '') | 
					
						
							|  |  |  | 				//return false
 | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}) | 
					
						
							| 
									
										
										
										
											2013-06-01 18:26:06 +04:00
										 |  |  | 	return elem | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-07-24 14:40:15 +04:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2012-08-10 18:31:32 +04:00
										 |  |  | // vim:set ts=4 sw=4 nowrap :
 |