Registry.require(["crcrc","helper","promise"],function(){var m=Registry.get("helper"),u=Registry.get("crcrc").cr,g=Registry.get("crcrc").crc,N=Registry.get("promise"),c={};Registry.register("layout/default/tabview","5770",{create:function(w,l,f,O){var a=m.filter(w,/[0-9a-zA-Z]/g);w=!1;void 0==f&&(f={tv:"tv",tv_table:"tv_table",tr_tabs:"tr_tabs",tr_content:"tr_content",td_content:"td_content",td_tabs:"td_tabs",tv_tabs_fill:"tv_tabs_fill",tv_tabs_table:"tv_tabs_table",tv_tabs_align:"tv_tabs_align",
tv_contents:"tv_contents",tv_tab_selected:"tv_tab tv_selected",tv_tab_close:"tv_tab_close",tv_tab:"tv_tab",tv_content:"tv_content"});var A=g("div",f.tv,"main"+a),v=g("table",f.tv_table+" noborder","main_table"+a);v.inserted?w=!0:(c[a]={},c[a].g_entries={},c[a].g_selectedId=null);var B=g("tr",f.tr_tabs,"tabs"+l.id+a),C=g("td",f.td_tabs,"pages"+a),D=g("div",f.tv_tabs_fill,"tv_tabs_fill"+a),E=g("div",f.tv_tabs_table,"tv_tabs_table"+a),p=g("div",f.tv_tabs_align,"tv_tabs_align"+a),F=g("tr",f.tr_content,
"content"+l.id+a),G=g("td",f.td_content,"content"+a),z=g("div",f.tv_contents,"tv_content"+a),H=u("tfoot","tv_footer_t"+a),I=u("tr","tv_footer_tr"+a),J=u("td","tv_footer_td"+a);H.appendChild(I);I.appendChild(J);E.appendChild(p);D.appendChild(E);C.appendChild(D);B.appendChild(C);v.appendChild(B);G.appendChild(z);F.appendChild(G);v.appendChild(F);v.appendChild(H);A.appendChild(v);l.appendChild(A);var K=function(a,c,b){c?a.setAttribute("style",b?m.staticVars.visible_move:m.staticVars.visible):a.setAttribute("style",
b?m.staticVars.invisible_move:m.staticVars.invisible);a.setAttribute("vis",c.toString())},L=function(d,e){var b=d.getId();c[a].g_entries[b]&&e!=c[a].g_entries[b].visible&&(c[a].g_entries[b].visible=e,K(c[a].g_entries[b].tab,e))},x=function(a,c){a&&K(a.content,c,!1)},P=function(d){for(var e=Object.keys(c[a].g_entries),b,h=0;b=e[h];h++)if(b=c[a].g_entries[b],b.tab.id==d.id)return b;return null},y=function(d){if(null===d)return null;for(var e=Object.keys(c[a].g_entries),b,h=0;b=e[h];h++)if(b=c[a].g_entries[b],
b.entry.getId()==d)return b.entry;return null},Q=function(d){if(d.getId()!=c[a].g_selectedId){var e=d.getId();c[a].g_selectedId&&x(c[a].g_entries[c[a].g_selectedId],!1);Object.keys(c[a].g_entries).forEach(function(b){b=c[a].g_entries[b];b.entry.getId()==e?b.visible?b.selected||(b.tab.setAttribute("class",f.tv_tab_selected),x(b,!0),b.selected=!0):console.log("tv: WARN: tab selected but not visible!"):b.selected&&(b.tab.setAttribute("class",f.tv_tab),x(b,!1),b.selected=!1)});c[a].g_selectedId=e}},M=
function(d){d.hide();d=d.getId();if(d=c[a].g_entries[d]){d.tab.parentNode.removeChild(d.tab);d.content.parentNode.removeChild(d.content);a:{d=d.tab;for(var e=Object.keys(c[a].g_entries),b,h=0;b=e[h];h++)if(c[a].g_entries[b].tab.id==d.id){d=b;break a}d=null}d&&delete c[a].g_entries[d]}else console.log("tv: WARN: tab not part of tabview!")};l=null;w?l=c[a].tv:(l={getTabById:y,getSelectedTab:function(){return y(c[a].g_selectedId)},getNextTab:function(d){var e=$(p).find("div[tvid]"),b;c[a].g_selectedId&&
e.each(function(d,f){b||$(f).attr("tvid")===c[a].g_selectedId&&(b=$(e.get(d+1)).attr("tvid"))});return y(b||e.first().attr("tvid"))},getPreviousTab:function(d){var e=$(p).find("div[tvid]"),b;c[a].g_selectedId&&e.each(function(d,f){b||$(f).attr("tvid")===c[a].g_selectedId&&(b=$(e.get(d-1)).attr("tvid"))});return y(b||e.last().attr("tvid"))},removeTab:M,appendTab:function(a,c,b,f,g){return this.insertTab(void 0,a,c,b,f,g)},insertTab:function(d,e,b,h,l,q){null===d&&(d=p.firstChild);var n="tab_"+e,k=
u("div",n,"content"+a),r=void 0!==k.inserted&&1==k.inserted,m=u("div",n,"head_text"+a);b.appendChild(m);q&&(n=g("div",f.tv_tab_close,n,"tv_close"+a,"tab_close"),n.inserted||n.addEventListener("click",function(){q()}),b.appendChild(n));if(r){if(r=P(k))return r.entry;console.log("tv: WARN: old tab, but not in tabs collection!")}var t,r=function(a){""!=a.target.className&&a.target.className==f.tv_tab_close||t.select()};k.setAttribute("tvid",e);k.addEventListener("click",r);b.addEventListener("click",
r);k.setAttribute("name","tabview_tab"+a);k.setAttribute("class",f.tv_tab);k.appendChild(b);d?p.insertBefore(k,d):p.appendChild(k);h.setAttribute("name","tabview_content"+a);h.setAttribute("class",f.tv_content);z.appendChild(h);t={getId:function(){return e},isVisible:function(){return"true"==k.getAttribute("vis")},isSelected:function(){return c[a].g_selectedId==this.getId()},isCloseable:function(){return!!q},remove:function(){M(this)},hide:function(){var b=this.getId(),d=b==c[a].g_selectedId;c[a].g_entries[b]?
L(this,!1):console.log("tv: WARN: tab not part of tabview!");if(d){var d=b=null,e;for(e in c[a].g_entries)c[a].g_entries[e].visible&&(b=c[a].g_entries[e],d||b.closable||(d=b));O||b.closable||(b=d);b?b.entry.select():(c[a].g_selectedId=null,console.log("tv: WARN: selected tab set, but entry collection empty!"))}},show:function(){var b=this.getId();c[a].g_entries[b]?L(this,!0):console.log("tv: WARN: tab not part of tabview!")},select:function(a){if(a||!t.isSelected())a=N(),l&&l(a.promise()),Q(this),
a.resolve()},setHeading:function(a,c,d){var e=b.firstChild;if(c&&a.length>c){var f=Math.round(c/2);e.textContent=a.substr(0,f)+"..."+a.substr(f-c);e.title=d||a}else e.textContent=a},toggleClass:function(a,c){$(b,z).toggleClass(a,c)},close:function(){q&&q()}};c[a].g_entries[e]={entry:t,tab:k,content:h,closable:null!=q};x(c[a].g_entries[e],!1);t.show();return t},setFooter:function(a){J.appendChild(a)}},c[a].tv=l);return l}})});
