At the moment I have have it in the skin.js, not as a proper plugin. It works quite well for my needs, but I imagine it might be need some tweaking for more general use (nested elements might need some more thought). Just thought I'd share - feel free to tell me if the code is full of holes or something!
- Code: Select all
jQuery(wym._options.classesSelector).hover(
function(){
jQuery("a",this).each(function(){
var link = jQuery(this);
var classtofind = "."+link.attr("name");
var selected = wym._selected_image || wym.selected() || wym._doc.body;
var matchedcontainer = jQuery(selected).parents().andSelf().filter(classtofind);
if(matchedcontainer.length > 0)
link.addClass("sel");
else
link.removeClass("sel");
});
},
function(){}
);
jQuery(wym._options.classesSelector + " a").click(function(){
var clicked = jQuery(this);
var classtofind = "."+clicked.attr("name");
var selected = wym._selected_image || wym.selected() || wym._doc.body;
setTimeout(function(){
var matchedcontainer = jQuery(selected).parents().andSelf().filter(classtofind);
if(matchedcontainer.length > 0)
clicked.addClass("sel");
else
clicked.removeClass("sel");
},2);
});