Registry.require(["crcrc","helper","promise"],function(){var m=Registry.get("helper"),u=Registry.get("crcrc").cr,h=Registry.get("crcrc").crc,N=Registry.get("promise"),c={};Registry.register("layout/default/tabview","6095",{create:function(x,l,e,O){var a=m.filter(x,/[0-9a-zA-Z]/g);x=!1;void 0==e&&(e={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=h("div",e.tv,"main"+a),v=h("table",e.tv_table+" noborder","main_table"+a);v.inserted?x=!0:(c[a]={},c[a].g_entries={},c[a].g_selectedId=null);var B=h("tr",e.tr_tabs,"tabs"+l.id+a),C=h("td",e.td_tabs,"pages"+a),D=h("div",e.tv_tabs_fill,"tv_tabs_fill"+a),E=h("div",e.tv_tabs_table,"tv_tabs_table"+a),n=h("div",e.tv_tabs_align,"tv_tabs_align"+a),F=h("tr",e.tr_content,
"content"+l.id+a),G=h("td",e.td_content,"content"+a),z=h("div",e.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(n);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,f){var b=d.getId();c[a].g_entries[b]&&f!=c[a].g_entries[b].visible&&(c[a].g_entries[b].visible=f,K(c[a].g_entries[b].tab,f))},y=function(a,c){a&&K(a.content,c,!1)},P=function(d){for(var f=Object.keys(c[a].g_entries),b,g=0;b=f[g];g++)if(b=c[a].g_entries[b],b.tab.id==d.id)return b;return null},w=function(d){if(null===d)return null;for(var f=Object.keys(c[a].g_entries),b,g=0;b=f[g];g++)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 f=d.getId();c[a].g_selectedId&&y(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()==f?b.visible?b.selected||(b.tab.setAttribute("class",e.tv_tab_selected),y(b,!0),b.selected=!0):console.log("tv: WARN: tab selected but not visible!"):b.selected&&(b.tab.setAttribute("class",e.tv_tab),y(b,!1),b.selected=!1)});c[a].g_selectedId=f}},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 f=Object.keys(c[a].g_entries),b,g=0;b=f[g];g++)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;x?l=c[a].tv:(l={getTabById:w,getSelectedTab:function(){return w(c[a].g_selectedId)},getAllTabs:function(){var a=$(n).find("div[tvid]"),c,b,g=[];a.each(function(e,
h){(c=$(a.get(e)).attr("tvid"))&&(b=w(c))&&g.push(b)});return g},getNextTab:function(d){var f=$(n).find("div[tvid]"),b;c[a].g_selectedId&&f.each(function(d,e){b||$(e).attr("tvid")===c[a].g_selectedId&&(b=$(f.get(d+1)).attr("tvid"))});return w(b||f.first().attr("tvid"))},getPreviousTab:function(d){var f=$(n).find("div[tvid]"),b;c[a].g_selectedId&&f.each(function(d,e){b||$(e).attr("tvid")===c[a].g_selectedId&&(b=$(f.get(d-1)).attr("tvid"))});return w(b||f.last().attr("tvid"))},removeTab:M,appendTab:function(a,
c,b,e,h){return this.insertTab(void 0,a,c,b,e,h)},insertTab:function(d,f,b,g,l,q){null===d&&(d=n.firstChild);var p="tab_"+f,k=u("div",p,"content"+a),r=void 0!==k.inserted&&1==k.inserted,m=u("div",p,"head_text"+a);b.appendChild(m);q&&(p=h("div",e.tv_tab_close,p,"tv_close"+a,"tab_close"),p.inserted||p.addEventListener("click",function(){q()}),b.appendChild(p));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==
e.tv_tab_close||t.select()};k.setAttribute("tvid",f);k.addEventListener("click",r);b.addEventListener("click",r);k.setAttribute("name","tabview_tab"+a);k.setAttribute("class",e.tv_tab);k.appendChild(b);d?n.insertBefore(k,d):n.appendChild(k);g.setAttribute("name","tabview_content"+a);g.setAttribute("class",e.tv_content);z.appendChild(g);t={getId:function(){return f},isVisible:function(){return"true"==k.getAttribute("vis")},isSelected:function(){return c[a].g_selectedId==this.getId()},isCloseable:function(){return!!q},
modified:function(){return $(b).hasClass("modified")},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[f]={entry:t,tab:k,content:g,closable:null!=q};y(c[a].g_entries[f],!1);t.show();
return t},setFooter:function(a){J.appendChild(a)}},c[a].tv=l);return l}})});
