mixElements.append("details");
document.createElement("details");
mixElements.append("mixlegend");
document.createElement("mixlegend");
mix.details = function (elements){
var details;
if (type(elements) == "undefined"){
details = $(document.createElement("details"));
}else{
details = $(elements).filter(function (){
var el = this.parentNode;
var inTemplate = false;
while (el.nodeType == 1 && el.nodeName.toLowerCase() != "html" && el.nodeName.toLowerCase() != "template")
el = el.parentNode;
return (("" + this.nodeName).toLowerCase() == "details"
&& this._mixInit !== true
&& el.nodeName.toLowerCase() != "template");
//node name is details and has not been initialized
});
}
details.each(function (){
this._mixInit = true;
}).find("mixlegend").bind("click", function (){
var opened = ($(this).parent().attr("open") == "open");
$(this).parent().attr("open", opened ? "" : "open");
}).end().redraw();
$(window).resize(function (){
details.redraw();
});
return details;
};
mix.details.redraw = function (el){
if ($(el).attr("open") == "open"){
$(el).children(":first").addClass("open").end().children(":not(:first)").show().children().redraw();
}else{
$(el).children(":first").removeClass("open").end().children(":not(:first)").hide();
}
};
mix.details.attr = function (el, name, value){
if (type(value) == "undefined"){ //getter
if (name == "open")
return el.getAttribute("open");
return;
}
el.setAttribute(name, value);
$(el).trigger("attrChange", [name, value]);
mix.details.redraw(el);
return value;
};
mix.details.customAttrList = "open".split(","); |