CKEDITOR.dialog.add("docProps",(function(t){function e(){var t=this.getDialog().getContentElement("general",this.id+"Other");t&&("other"==this.getValue()?(t.getInputElement().removeAttribute("readOnly"),t.focus(),t.getElement().removeClass("cke_disabled")):(t.getInputElement().setAttribute("readOnly",!0),t.getElement().addClass("cke_disabled")))}function i(e,i,n){return function(o,l,a){l=s,!(o=void 0!==n?n:this.getValue())&&e in l?l[e].remove():o&&e in l?l[e].setAttribute("content",o):o&&((l=new CKEDITOR.dom.element("meta",t.document)).setAttribute(i?"http-equiv":"name",e),l.setAttribute("content",o),a.append(l))}}function n(t,e){return function(){var i=t in(i=s)&&i[t].getAttribute("content")||"";return e?i:(this.setValue(i),null)}}function o(t){return function(e,i,n,o){o.removeAttribute("margin"+t),""!==(e=this.getValue())?o.setStyle("margin-"+t,CKEDITOR.tools.cssLength(e)):o.removeStyle("margin-"+t)}}function l(t,e,i){t.removeStyle(e),t.getComputedStyle(e)!=i&&t.setStyle(e,i)}var a=t.lang.docprops,r=t.lang.common,s={},c=function(e,i,n){return{type:"hbox",padding:0,widths:["60%","40%"],children:[CKEDITOR.tools.extend({type:"text",id:e,label:a[i]},n||{},1),{type:"button",id:e+"Choose",label:a.chooseColor,className:"colorChooser",onClick:function(){var i=this;!function(e,i){var n=function(){o(this),i(this,this._.parentDialog)},o=function(t){t.removeListener("ok",n),t.removeListener("cancel",o)},l=function(t){t.on("ok",n),t.on("cancel",o)};t.execCommand(e),t._.storedDialogs.colordialog?l(t._.storedDialogs.colordialog):CKEDITOR.on("dialogDefinition",(function(t){if(t.data.name==e){var i=t.data.definition;t.removeListener(),i.onLoad=CKEDITOR.tools.override(i.onLoad,(function(t){return function(){l(this),i.onLoad=t,"function"==typeof t&&t.call(this)}}))}}))}("colordialog",(function(t){var n=i.getDialog();n.getContentElement(n._.currentTabId,e).setValue(t.getContentElement("picker","selectedColor").getValue())}))}}]}},g="javascript:void((function(){"+encodeURIComponent("document.open();"+(CKEDITOR.env.ie?"("+CKEDITOR.tools.fixDomain+")();":"")+'document.write( \'<html style="background-color: #ffffff; height: 100%"><head></head><body style="width: 100%; height: 100%; margin: 0px">'+a.previewHtml+"</body></html>' );document.close();")+"})())";return{title:a.title,minHeight:330,minWidth:500,onShow:function(){for(var e=t.document,i=e.getElementsByTag("html").getItem(0),n=e.getHead(),o=e.getBody(),l={},a=e.getElementsByTag("meta"),r=a.count(),c=0;c<r;c++){var g=a.getItem(c);l[g.getAttribute(g.hasAttribute("http-equiv")?"http-equiv":"name").toLowerCase()]=g}s=l,this.setupContent(e,i,n,o)},onHide:function(){s={}},onOk:function(){var e=t.document,i=e.getElementsByTag("html").getItem(0),n=e.getHead(),o=e.getBody();this.commitContent(e,i,n,o)},contents:[{id:"general",label:r.generalTab,elements:[{type:"text",id:"title",label:a.docTitle,setup:function(t){this.setValue(t.getElementsByTag("title").getItem(0).data("cke-title"))},commit:function(t,e,i,n,o){o||t.getElementsByTag("title").getItem(0).data("cke-title",this.getValue())}},{type:"hbox",children:[{type:"select",id:"dir",label:r.langDir,style:"width: 100%",items:[[r.notSet,""],[r.langDirLtr,"ltr"],[r.langDirRtl,"rtl"]],setup:function(t,e,i,n){this.setValue(n.getDirection()||"")},commit:function(t,e,i,n){(t=this.getValue())?n.setAttribute("dir",t):n.removeAttribute("dir"),n.removeStyle("direction")}},{type:"text",id:"langCode",label:r.langCode,setup:function(t,e){this.setValue(e.getAttribute("xml:lang")||e.getAttribute("lang")||"")},commit:function(t,e,i,n,o){o||((t=this.getValue())?e.setAttributes({"xml:lang":t,lang:t}):e.removeAttributes({"xml:lang":1,lang:1}))}}]},{type:"hbox",children:[{type:"select",id:"charset",label:a.charset,style:"width: 100%",items:[[r.notSet,""],[a.charsetASCII,"us-ascii"],[a.charsetCE,"iso-8859-2"],[a.charsetCT,"big5"],[a.charsetCR,"iso-8859-5"],[a.charsetGR,"iso-8859-7"],[a.charsetJP,"iso-2022-jp"],[a.charsetKR,"iso-2022-kr"],[a.charsetTR,"iso-8859-9"],[a.charsetUN,"utf-8"],[a.charsetWE,"iso-8859-1"],[a.other,"other"]],default:"",onChange:function(){this.getDialog().selectedCharset="other"!=this.getValue()?this.getValue():"",e.call(this)},setup:function(){this.metaCharset="charset"in s;var t=n(this.metaCharset?"charset":"content-type",1).call(this);if(!this.metaCharset&&t.match(/charset=[^=]+$/)&&(t=t.substring(t.indexOf("=")+1)),t){if(this.setValue(t.toLowerCase()),!this.getValue()){this.setValue("other");var i=this.getDialog().getContentElement("general","charsetOther");i&&i.setValue(t)}this.getDialog().selectedCharset=t}e.call(this)},commit:function(t,e,n,o,l){l||(o=this.getValue(),l=this.getDialog().getContentElement("general","charsetOther"),"other"==o&&(o=l?l.getValue():""),o&&!this.metaCharset&&(o=(s["content-type"]?s["content-type"].getAttribute("content").split(";")[0]:"text/html")+"; charset="+o),i(this.metaCharset?"charset":"content-type",1,o).call(this,t,e,n))}},{type:"text",id:"charsetOther",label:a.charsetOther,onChange:function(){this.getDialog().selectedCharset=this.getValue()}}]},{type:"hbox",children:[{type:"select",id:"docType",label:a.docType,style:"width: 100%",items:[[r.notSet,""],["XHTML 1.1",'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">'],["XHTML 1.0 Transitional",'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'],["XHTML 1.0 Strict",'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'],["XHTML 1.0 Frameset",'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">'],["HTML 5","<!DOCTYPE html>"],["HTML 4.01 Transitional",'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'],["HTML 4.01 Strict",'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'],["HTML 4.01 Frameset",'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">'],["HTML 3.2",'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">'],["HTML 2.0",'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">'],[a.other,"other"]],onChange:e,setup:function(){if(t.docType&&(this.setValue(t.docType),!this.getValue())){this.setValue("other");var i=this.getDialog().getContentElement("general","docTypeOther");i&&i.setValue(t.docType)}e.call(this)},commit:function(e,i,n,o,l){l||(e=this.getValue(),i=this.getDialog().getContentElement("general","docTypeOther"),t.docType="other"==e?i?i.getValue():"":e)}},{type:"text",id:"docTypeOther",label:a.docTypeOther}]},{type:"checkbox",id:"xhtmlDec",label:a.xhtmlDec,setup:function(){this.setValue(!!t.xmlDeclaration)},commit:function(e,i,n,o,l){l||(this.getValue()?(t.xmlDeclaration='<?xml version="1.0" encoding="'+(this.getDialog().selectedCharset||"utf-8")+'"?>',i.setAttribute("xmlns","http://www.w3.org/1999/xhtml")):(t.xmlDeclaration="",i.removeAttribute("xmlns")))}}]},{id:"design",label:a.design,elements:[{type:"hbox",widths:["60%","40%"],children:[{type:"vbox",children:[c("txtColor","txtColor",{setup:function(t,e,i,n){this.setValue(n.getComputedStyle("color"))},commit:function(t,e,i,n,o){(this.isChanged()||o)&&(n.removeAttribute("text"),(t=this.getValue())?n.setStyle("color",t):n.removeStyle("color"))}}),c("bgColor","bgColor",{setup:function(t,e,i,n){t=n.getComputedStyle("background-color")||"",this.setValue("transparent"==t?"":t)},commit:function(t,e,i,n,o){(this.isChanged()||o)&&(n.removeAttribute("bgcolor"),(t=this.getValue())?n.setStyle("background-color",t):l(n,"background-color","transparent"))}}),{type:"hbox",widths:["60%","40%"],padding:1,children:[{type:"text",id:"bgImage",label:a.bgImage,setup:function(t,e,i,n){t="none"==(t=n.getComputedStyle("background-image")||"")?"":t.replace(/url\(\s*(["']?)\s*([^\)]*)\s*\1\s*\)/i,(function(t,e,i){return i})),this.setValue(t)},commit:function(t,e,i,n){n.removeAttribute("background"),(t=this.getValue())?n.setStyle("background-image","url("+t+")"):l(n,"background-image","none")}},{type:"button",id:"bgImageChoose",label:r.browseServer,style:"display:inline-block;margin-top:10px;",hidden:!0,filebrowser:"design:bgImage"}]},{type:"checkbox",id:"bgFixed",label:a.bgFixed,setup:function(t,e,i,n){this.setValue("fixed"==n.getComputedStyle("background-attachment"))},commit:function(t,e,i,n){this.getValue()?n.setStyle("background-attachment","fixed"):l(n,"background-attachment","scroll")}}]},{type:"vbox",children:[{type:"html",id:"marginTitle",html:'<div style="text-align: center; margin: 0px auto; font-weight: bold">'+a.margin+"</div>"},{type:"text",id:"marginTop",label:a.marginTop,style:"width: 80px; text-align: center",align:"center",inputStyle:"text-align: center",setup:function(t,e,i,n){this.setValue(n.getStyle("margin-top")||n.getAttribute("margintop")||"")},commit:o("top")},{type:"hbox",children:[{type:"text",id:"marginLeft",label:a.marginLeft,style:"width: 80px; text-align: center",align:"center",inputStyle:"text-align: center",setup:function(t,e,i,n){this.setValue(n.getStyle("margin-left")||n.getAttribute("marginleft")||"")},commit:o("left")},{type:"text",id:"marginRight",label:a.marginRight,style:"width: 80px; text-align: center",align:"center",inputStyle:"text-align: center",setup:function(t,e,i,n){this.setValue(n.getStyle("margin-right")||n.getAttribute("marginright")||"")},commit:o("right")}]},{type:"text",id:"marginBottom",label:a.marginBottom,style:"width: 80px; text-align: center",align:"center",inputStyle:"text-align: center",setup:function(t,e,i,n){this.setValue(n.getStyle("margin-bottom")||n.getAttribute("marginbottom")||"")},commit:o("bottom")}]}]}]},{id:"meta",label:a.meta,elements:[{type:"textarea",id:"metaKeywords",label:a.metaKeywords,setup:n("keywords"),commit:i("keywords")},{type:"textarea",id:"metaDescription",label:a.metaDescription,setup:n("description"),commit:i("description")},{type:"text",id:"metaAuthor",label:a.metaAuthor,setup:n("author"),commit:i("author")},{type:"text",id:"metaCopyright",label:a.metaCopyright,setup:n("copyright"),commit:i("copyright")}]},{id:"preview",label:r.preview,elements:[{type:"html",id:"previewHtml",html:'<iframe src="'+g+'" style="width: 100%; height: 310px" hidefocus="true" frameborder="0"></iframe>',onLoad:function(){var t=this.getElement();this.getDialog().on("selectPage",(function(e){if("preview"==e.data.page){var i=this;setTimeout((function(){var e=t.getFrameDocument(),n=e.getElementsByTag("html").getItem(0),o=e.getHead(),l=e.getBody();i.commitContent(e,n,o,l,1)}),50)}})),t.getAscendant("table").setStyle("height","100%")}}]}]}}));