User:Westgrass/common.js

if("ontouchstart" in window){ $(function{		var procRule = function($rule){			switch($rule.constructor.name){				case "CSSStyleRule":			 		if( $rule.selectorText.indexOf(':hover') == -1){			  			return;			  		}			  		$rule.selectorText = $rule.selectorText.split(',').map(function($item){ if($item.indexOf(':hover')){ return $item + ', ' + $item.replace(':hover', '.hoverhover'); }else{ return $item; }			 		}).join(', ');			  		break;			  	case "CSSMediaRule":			  		for (var i = 0; i < $rule.cssRules.length; i++) {						procRule( $rule.cssRules[i]);					}					break;		  		default:		  			//skip.			  		break;			  }		}		for (var i = 0; i < document.styleSheets.length; i++) {			var styleSheet = document.styleSheets[i];			try{				for (var j = 0; j < styleSheet.cssRules.length; j++) {						procRule( styleSheet.cssRules[j], styleSheet );				}			}			catch(e){//cross domain				//console.log('Access to stylesheet %s is denied. Ignoring...', styleSheet.href);			}		}		var $hoverhoverElement = null; 		$("body").on("click", function{ if(!$hoverhoverElement){ return; }			$hoverhoverElement.removeClass('hoverhover'); $hoverhoverElement = null; });		$(".wds-dropdown:not(.more-menu)").click(function(event){ var $this = $(this); if($hoverhoverElement && ($hoverhoverElement.get(0) != $this.get(0))){ $hoverhoverElement.removeClass('hoverhover'); $hoverhoverElement = null; }			$this.toggleClass('hoverhover'); if($this.hasClass('hoverhover')){ $hoverhoverElement = $this; }			event.stopPropagation; });	}); }