(function(){page.using={types:["Formats"]};var e,a,t=['<div style="position:fixed; right:0; bottom:0" class="u8-padding">','{{Button({ command: "Save", textId: "TXT_button_text_2" })}}',"&nbsp;",'{{Button({ command: "Cancel", textId: "TXT_button_text_10" })}}',"</div>"].join("");page.validationManager={summaryId:"validationSummary"};page.commandBindings={Save:n,Cancel:i};page.onLoad=function(){o(r)};function o(a){var t=page.url;e={formName:t.get("formName"),uid:t.getUid(),formatAlias:t.get("formatAlias"),includePublicFormats:t.getBoolean("includePublicFormats",true),includePrivateFormats:t.getBoolean("includePrivateFormats",true),local:t.getBoolean("local",true)};$.extend(e,t.getHeader());u8.services.formats.readXml({uid:e.uid,formatAlias:e.formatAlias},function(a,t){e.xml=t.xml;$assert(e.xml,"No format XML!");e.formatType=$(e.xml).xpath("/FormatDefinition/FormatHeader").attr("type")}.chain(a))}function r(){var o=e.xml,r=page.popup,i=!page.process&&u8.isValidRecordUid(e.uid),n=i?"#pageheader":"#header",m={headerName:e.headerName,headerGroupName:e.headerGroupName||"Special",uid:e.uid,parent:page,view:{hidden:r},isDefault:true,updatePopupTitle:true,onPreCreate:function(e){if(i){e.model.flags|=e.constructor.Flags.pageHeaderStyle}}};$(n).css("display",r?"none":"").widget("Header",m);a=new u8.Base.Widgets.Form($el("form"),{formName:e.formName,parent:page,onPreCreate:function(e){var a=e.components.$context;$assert(a,"Missing xml data source.");$.extend(a.options,{xml:o,xpathPrefix:"/FormatDefinition/Activity/"})}});if(r){$("#content").attr("class","u8-margin");$("body").removeClass("u8-panels");$("#buttons").utml({template:t,itemOptions:{parent:page}})}}function i(){page.popup.close({cancel:true})}function n(){var t=e.xml;a.updateBindingSources(function(){var a=$(t).xpath("/FormatDefinition/FormatHeader/Name").text(),r={formatName:a,forLoading:false,includePrivateFormats:e.includePrivateFormats,includePublicFormats:e.includePublicFormats,formatType:e.formatType};u8.services.formats.select(r,o)});function o(a,o){if(o.cancel){return}var r=u8.tools.extendSome({name:o.formatName,user:u8.session.identity.userName,local:e.local},["lock","private","user","local"],o.format);u8.services.formats.updateFormatHeaderXml(t,r);var i=u8.Base.Xml.serialize(t);u8.services.formats.writeXml({xml:i,options:{formatOwnerUid:e.uid,formatOwnerAlias:e.formatAlias}},function(e,a){if(a.error){page.notify(a.error);a.error.handled=true;return}if(page.popup){page.popup.close(a.response)}else{window.location.reload()}})}}})();