-
-
Save cers/81748 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CmdUtils.CreateCommand({ | |
name: "selector", | |
description: "Finds a selector that will match element currently hovered, and highlights all matches", | |
execute: function() { | |
CmdUtils.loadJQuery(function(){ | |
var d = CmdUtils.getDocumentInsecure(); | |
var w = CmdUtils.getWindowInsecure(); | |
myId = function(me){ return me.id ? '#' + me.id : '' } | |
myTag = function(me){ return me.tagName ? me.tagName.toLowerCase() : '' } | |
myClass = function(me){ return me.className ? '.' + me.className.split(' ').join('.') : '' } | |
breadcrumbs = function(me){ | |
var path = [myTag(me) + myId(me) + myClass(me)]; | |
w.jQuery(me).parents().each(function() { | |
path[path.length] = myTag(this) + myId(this) + myClass(this); | |
}); | |
path.reverse(); | |
return path.join(' > ').replace(/.ubiquityHighlight/g,""); | |
} | |
if (!d.getElementById("ubiquityCss")) | |
w.jQuery('head').append('<style id="ubiquityCss" type="text/css">.ubiquityHighlight {border: 1px blue solid !important;}</style>'); | |
w.jQuery("*").each(function(){ | |
w.jQuery(this).mouseover(function(e){ | |
w.jQuery("*").removeClass("ubiquityHighlight"); | |
var path = breadcrumbs(this); | |
w.jQuery(path).addClass("ubiquityHighlight"); | |
e.stopPropagation(); | |
}); | |
w.jQuery(this).mouseout(function(e){ | |
w.jQuery(this).removeClass("ubiquityHighlight"); | |
}); | |
w.jQuery(this).click(function(e){ | |
displayMessage(breadcrumbs(this)); | |
e.stopPropagation(); | |
e.preventDefault(); | |
return false; | |
}); | |
}); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment