!function(e,t){if("undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&"object"==typeof define.amd)define(t);else{if("function"==typeof jQuery)return function(e,t){jQuery.fn[e]=t};this[e]=t()}}("Radiogram",function(){var e,t,n,r,a=0,o="";return{expose:function(e,n){if(t=document.querySelector(e),Radiogram.isObject(n))var r=Object.keys(n).length;return r>0&&3>r&&(rtn=Radiogram.analyzer(n)),!0},isObject:function(e){return null===e||"function"==typeof e?!1:"object"==typeof e},bindEvents:function(t){var n=document.querySelector(t),r="";for(e=0;e<n.children.length;e++)r=n.children[e],r.addEventListener?r.addEventListener("click",Radiogram.eventHandler,!1):r.attachEvent&&r.attachEvent("onclick",Radiogram.eventHandler)},eventHandler:function(e){var t=this.lastChild.id,n=this.lastChild.name;Radiogram.removeSection(n),document.getElementById(t).setAttribute("checked","checked")},removeSection:function(t){var n=document.getElementsByName(t);for(e=0;e<n.length;e++)n[e].checked&&n[e].removeAttribute("checked");return!0},analyzer:function(e){var t,r="";for(var i in e)e.hasOwnProperty(i)&&("name"===i?r=e[i]:(n=e[i].toString(),t=n.split(",")));return Radiogram.finalizer(r,t)},finalizer:function(d,c){n="",i=0,a++,o="#radiogroup"+a,r=document.createElement("ul"),r.id="radiogroup"+a,r.setAttribute("class","radiogram");var u=document.createDocumentFragment();u=u.appendChild(r);var l;for(e=0;e<c.length;e++)i++,l=document.createElement("li"),n=c[e].toString()+'<input id="radio'+a+i+'" type="radio" name="'+d+'"/>',l.insertAdjacentHTML("beforeend",n),u.appendChild(l);return t.appendChild(u),Radiogram.bindEvents(o),!0}}});
|