"undefined"==typeof XWiki&&(XWiki={});"undefined"==typeof XWiki.editors&&(XWiki.editors={});
XWiki.editors.ColorThemeWizard=Class.create({classPrefix:".colorthemewizard-",inputNamePrefix:"ColorThemes.ColorThemeClass_0_",propertyMap:{},defaultValues:{},initialize:function(){this.pickerSelector=this.classPrefix+"picker";this.triggerSelector=this.classPrefix+"trigger";this.maquetteSelector=this.classPrefix+"page";this.tipSelector=this.classPrefix+"tip";this.editableGroupSelector=this.classPrefix+"editable-group";this.visibleTriggerSelector=this.triggerSelector+"-visible";this.logoProperty="logoImage";
this.logoSelector=this.classPrefix.substring(1)+"logo";this.logoPropertySelector=this.classPrefix+this.logoProperty;this.defaultLogoURL="";this.generateDefaultValues();this.createPropertyMap();this.hideCSSVersionPickers();this.redefineActivation();this.attachChangeListeners()},generateDefaultValues:function(){this.defaultValues.pageBackgroundColor="#D6E1E7";this.defaultValues.pageHeaderBackgroundColor="#FFFFFF";this.defaultValues.pageContentBackgroundColor="#FFFFFF";this.defaultValues.textColor="#222222";
this.defaultValues.textPrimaryColor="#555555";this.defaultValues.textSecondaryColor="#555555";this.defaultValues.titleColor="#005A83";this.defaultValues.borderColor="#D6E1E7";this.defaultValues.linkColor="#4791BC";this.defaultValues.highlightColor="#FFFFDD";this.defaultValues.fieldGradientColor="";this.defaultValues.menuBackgroundColor="#005A83";this.defaultValues.menuGradientColor="";this.defaultValues.menuLinkColor="#727272";this.defaultValues.menuContentBackgroundColor="#005A83";this.defaultValues.menuContentGradientColor=
"";this.defaultValues.menuContentLinkColor="#FFFFFF";this.defaultValues.menuSelectedEntryBackgroundColor="#006592";this.defaultValues.menuSelectedEntryLinkColor="#FFFFFF";this.defaultValues.menuAddEntryBackgroundColor="#4D9244";this.defaultValues.menuAddEntryLinkColor="#FFFFFF";this.defaultValues.submenuContentBackgroundColor="#005A83";this.defaultValues.panelBackgroundColor="#FFFFFF";this.defaultValues.panelHeaderBackgroundColor="#005A83";this.defaultValues.panelHeaderGradientColor="";this.defaultValues.panelHeaderTextColor=
"#FFFFFF";this.defaultValues.panelTextColor="#4D4D4D";this.defaultValues.panelCollapsedBackgroundColor="#EBF2F3";this.defaultValues.panelCollapsedGradientColor="";this.defaultValues.panelCollapsedTextColor="#005A83";this.defaultValues.buttonPrimaryBackgroundColor="#386da7";this.defaultValues.buttonPrimaryGradientColor="";this.defaultValues.buttonPrimaryTextColor="#FFFFFF";this.defaultValues.buttonSecondaryBackgroundColor="#FFFFFF";this.defaultValues.buttonSecondaryGradientColor="";this.defaultValues.buttonSecondaryTextColor=
"#005A83";this.defaultValues.backgroundSecondaryColor="#f5f5f5";this.defaultValues.notificationInfoColor="#336699";this.defaultValues.notificationSuccessColor="#077537";this.defaultValues.notificationWarningColor="#D09000";this.defaultValues.notificationErrorColor="#cc3333";this.defaultValues.pageBackgroundPosition="";this.defaultValues.headerBackgroundImage="";this.defaultValues.pageBackgroundImage="";this.defaultValues.headerBackgroundPosition="";this.defaultValues.logoImage=""},createPropertyMap:function(){this.propertyMap.page=
{};this.propertyMap.page.cssProperties=[];var a="background".camelize();this.propertyMap.page.cssProperties.push(a);this.propertyMap.page[a]=[];this.propertyMap.page[a].push("pageBackgroundColor");this.propertyMap.page[a].push("pageBackgroundImage");this.propertyMap.page[a].push("pageBackgroundPosition");a="color".camelize();this.propertyMap.page.cssProperties.push(a);this.propertyMap.page[a]=[];this.propertyMap.page[a].push("textColor");this.propertyMap.mainmenu={};this.propertyMap.mainmenu.cssProperties=
[];a="background".camelize();this.propertyMap.mainmenu.cssProperties.push(a);this.propertyMap.mainmenu[a]=[];this.propertyMap.mainmenu[a].push("menuBackgroundColor");a="color".camelize();this.propertyMap.mainmenu.cssProperties.push(a);this.propertyMap.mainmenu[a]=[];this.propertyMap.mainmenu[a].push("menuLinkColor");this.propertyMap.menuaddentry={};this.propertyMap.menuaddentry.cssProperties=[];a="background".camelize();this.propertyMap.menuaddentry.cssProperties.push(a);this.propertyMap.menuaddentry[a]=
[];this.propertyMap.menuaddentry[a].push("menuAddEntryBackgroundColor");a="color".camelize();this.propertyMap.menuaddentry.cssProperties.push(a);this.propertyMap.menuaddentry[a]=[];this.propertyMap.menuaddentry[a].push("menuAddEntryLinkColor");this.propertyMap.contentmenu={};this.propertyMap.contentmenu.cssProperties=[];a="background".camelize();this.propertyMap.contentmenu.cssProperties.push(a);this.propertyMap.contentmenu[a]=[];this.propertyMap.contentmenu[a].push("menuBackgroundColor");a="color".camelize();
this.propertyMap.contentmenu.cssProperties.push(a);this.propertyMap.contentmenu[a]=[];this.propertyMap.contentmenu[a].push("menuLinkColor");this.propertyMap.header={};this.propertyMap.header.cssProperties=[];a="background".camelize();this.propertyMap.header.cssProperties.push(a);this.propertyMap.header[a]=[];this.propertyMap.header[a].push("pageHeaderBackgroundColor");this.propertyMap.header[a].push("headerBackgroundImage");this.propertyMap.header[a].push("headerBackgroundPosition");this.propertyMap.panelheader=
{};this.propertyMap.panelheader.cssProperties=[];a="background".camelize();this.propertyMap.panelheader.cssProperties.push(a);this.propertyMap.panelheader[a]=[];this.propertyMap.panelheader[a].push("panelHeaderBackgroundColor");a="color".camelize();this.propertyMap.panelheader.cssProperties.push(a);this.propertyMap.panelheader[a]=[];this.propertyMap.panelheader[a].push("panelHeaderTextColor");a="border-color".camelize();this.propertyMap.panelheader.cssProperties.push(a);this.propertyMap.panelheader[a]=
[];this.propertyMap.panelheader[a].push("borderColor");this.propertyMap.panelcontents={};this.propertyMap.panelcontents.cssProperties=[];a="background".camelize();this.propertyMap.panelcontents.cssProperties.push(a);this.propertyMap.panelcontents[a]=[];this.propertyMap.panelcontents[a].push("panelBackgroundColor");a="color".camelize();this.propertyMap.panelcontents.cssProperties.push(a);this.propertyMap.panelcontents[a]=[];this.propertyMap.panelcontents[a].push("panelTextColor");this.propertyMap.collapsedpanel=
{};this.propertyMap.collapsedpanel.cssProperties=[];a="background".camelize();this.propertyMap.collapsedpanel.cssProperties.push(a);this.propertyMap.collapsedpanel[a]=[];this.propertyMap.collapsedpanel[a].push("panelCollapsedBackgroundColor");a="color".camelize();this.propertyMap.collapsedpanel.cssProperties.push(a);this.propertyMap.collapsedpanel[a]=[];this.propertyMap.collapsedpanel[a].push("panelCollapsedTextColor");this.propertyMap.content={};this.propertyMap.content.cssProperties=[];a="background".camelize();
this.propertyMap.content.cssProperties.push(a);this.propertyMap.content[a]=[];this.propertyMap.content[a].push("pageContentBackgroundColor");a="color".camelize();this.propertyMap.content.cssProperties.push(a);this.propertyMap.content[a]=[];this.propertyMap.content[a].push("textColor");this.propertyMap.title={};this.propertyMap.title.cssProperties=[];a="color".camelize();this.propertyMap.title.cssProperties.push(a);this.propertyMap.title[a]=[];this.propertyMap.title[a].push("titleColor");a="border-color".camelize();
this.propertyMap.title.cssProperties.push(a);this.propertyMap.title[a]=[];this.propertyMap.title[a].push("borderColor");this.propertyMap.link={};this.propertyMap.link.cssProperties=[];a="color".camelize();this.propertyMap.link.cssProperties.push(a);this.propertyMap.link[a]=[];this.propertyMap.link[a].push("linkColor");this.propertyMap.info={};this.propertyMap.info.cssProperties=[];a="color".camelize();this.propertyMap.info.cssProperties.push(a);this.propertyMap.info[a]=[];this.propertyMap.info[a].push("textPrimaryColor");
this.propertyMap.details={};this.propertyMap.details.cssProperties=[];a="color".camelize();this.propertyMap.details.cssProperties.push(a);this.propertyMap.details[a]=[];this.propertyMap.details[a].push("textSecondaryColor");this.propertyMap.highlight={};this.propertyMap.highlight.cssProperties=[];a="background".camelize();this.propertyMap.highlight.cssProperties.push(a);this.propertyMap.highlight[a]=[];this.propertyMap.highlight[a].push("highlightColor");this.propertyMap.table={};this.propertyMap.table.cssProperties=
[];a="border-color".camelize();this.propertyMap.table.cssProperties.push(a);this.propertyMap.table[a]=[];this.propertyMap.table[a].push("borderColor");this.propertyMap.th={};this.propertyMap.th.cssProperties=[];a="background".camelize();this.propertyMap.th.cssProperties.push(a);this.propertyMap.th[a]=[];this.propertyMap.th[a].push("backgroundSecondaryColor");a="border-color".camelize();this.propertyMap.th.cssProperties.push(a);this.propertyMap.th[a]=[];this.propertyMap.th[a].push("borderColor");this.propertyMap.td=
{};this.propertyMap.td.cssProperties=[];a="border-color".camelize();this.propertyMap.td.cssProperties.push(a);this.propertyMap.td[a]=[];this.propertyMap.td[a].push("borderColor");this.propertyMap.message={};this.propertyMap.message.cssProperties=[];a="background".camelize();this.propertyMap.message.cssProperties.push(a);this.propertyMap.message[a]=[];this.propertyMap.message[a].push("backgroundSecondaryColor");a="border-color".camelize();this.propertyMap.message.cssProperties.push(a);this.propertyMap.message[a]=
[];this.propertyMap.message[a].push("borderColor");this.propertyMap.button={};this.propertyMap.button.cssProperties=[];a="background".camelize();this.propertyMap.button.cssProperties.push(a);this.propertyMap.button[a]=[];this.propertyMap.button[a].push("buttonPrimaryBackgroundColor");a="color".camelize();this.propertyMap.button.cssProperties.push(a);this.propertyMap.button[a]=[];this.propertyMap.button[a].push("buttonPrimaryTextColor");this.propertyMap.secondaryButton={};this.propertyMap.secondaryButton.cssProperties=
[];a="background".camelize();this.propertyMap.secondaryButton.cssProperties.push(a);this.propertyMap.secondaryButton[a]=[];this.propertyMap.secondaryButton[a].push("buttonSecondaryBackgroundColor");a="color".camelize();this.propertyMap.secondaryButton.cssProperties.push(a);this.propertyMap.secondaryButton[a]=[];this.propertyMap.secondaryButton[a].push("buttonSecondaryTextColor");this.propertyMap.tabshead={};this.propertyMap.tabshead.cssProperties=[];a="background".camelize();this.propertyMap.tabshead.cssProperties.push(a);
this.propertyMap.tabshead[a]=[];this.propertyMap.tabshead[a].push("menuBackgroundColor");a="color".camelize();this.propertyMap.tabshead.cssProperties.push(a);this.propertyMap.tabshead[a]=[];this.propertyMap.tabshead[a].push("menuLinkColor");this.propertyMap.tabentryactive={};this.propertyMap.tabentryactive.cssProperties=[];a="background".camelize();this.propertyMap.tabentryactive.cssProperties.push(a);this.propertyMap.tabentryactive[a]=[];this.propertyMap.tabentryactive[a].push("pageContentBackgroundColor");
a="color".camelize();this.propertyMap.tabentryactive.cssProperties.push(a);this.propertyMap.tabentryactive[a]=[];this.propertyMap.tabentryactive[a].push("menuSelectedEntryLinkColor");this.propertyMap.tabdetails={};this.propertyMap.tabdetails.cssProperties=[];a="color".camelize();this.propertyMap.tabdetails.cssProperties.push(a);this.propertyMap.tabdetails[a]=[];this.propertyMap.tabdetails[a].push("textSecondaryColor");this.propertyMap.tabscontent={};this.propertyMap.tabscontent.cssProperties=[];a=
"background".camelize();this.propertyMap.tabscontent.cssProperties.push(a);this.propertyMap.tabscontent[a]=[];this.propertyMap.tabscontent[a].push("pageContentBackgroundColor");a="color".camelize();this.propertyMap.tabscontent.cssProperties.push(a);this.propertyMap.tabscontent[a]=[];this.propertyMap.tabscontent[a].push("textColor")},hideCSSVersionPickers:function(){$$(this.classPrefix+"picker-noscript").each(function(a){a.hide()})},fastUp:function(a,b){for(;a!=document.documentElement&&!a.hasClassName(b);)a=
a.up();return a},fastDown:function(a,b){var c,d=new RegExp("(^|\\s)"+b+"(\\s|$)");b=0;for(c=a.childNodes.length;b<c;++b)if(1==a.childNodes[b].nodeType&&d.test(a.childNodes[b].className))return a.childNodes[b]},getMainClassName:function(a){return a.className.substring(0,a.className.indexOf(" "))},getMarker:function(a){return a.className.substring(this.classPrefix.length-1,a.className.indexOf(" "))},redefineActivation:function(){$("body").hasClassName("inlinebody")&&$$(this.editableGroupSelector).each(function(a){a.observe("mouseover",
function(f){var e=this.getMainClassName(a);$(e+"-trigger");this.fastUp(Event.element(f),this.editableGroupSelector.substring(1))==a?a.removeClassName(e+"-unhover"):"block"!=this.fastDown(this.fastDown(a,"colorthemewizard-trigger"),"colorthemewizard-picker").style.display&&a.addClassName(e+"-unhover")}.bindAsEventListener(this));var b=$(this.fastDown(a,this.triggerSelector.substring(1)));b.observe("mouseover",function(f){"none"==this.fastDown(b,this.pickerSelector.substring(1)).style.display&&(this.fastDown(b,
this.tipSelector.substring(1)).style.display="block")}.bindAsEventListener(this));b.observe("mouseout",function(f){if("none"!=this.fastDown(b,this.pickerSelector.substring(1)).style.display||!f.toElement||!$(f.toElement).descendantOf(parent)&&f.toElement!=parent)this.fastDown(b,this.tipSelector.substring(1)).style.display=""}.bindAsEventListener(this));b.observe("click",this.displayPicker.bindAsEventListener(this,b));Prototype.Browser.IE||Prototype.Browser.WebKit?shortcut.add("Esc",this.hidePicker.bindAsEventListener(this,
b),{type:"keyup"}):shortcut.add("Esc",this.hidePicker.bindAsEventListener(this,b),{type:"keypress"});var c=$(this.fastDown(b,this.pickerSelector.substring(1))),d=(new Element("div",{"class":"close-button",title:"Close"})).update("X");c.insert({top:d});d.observe("click",this.hidePicker.bindAsEventListener(this,this.fastUp(d,this.triggerSelector.substring(1))));c.style.display="none"}.bind(this))},displayPicker:function(a,b){if(a&&(Event.stop(a),a.element()!=b))return;$$(this.visibleTriggerSelector).each(function(c){this.hidePicker(null,
c)}.bind(this));b.addClassName(this.visibleTriggerSelector.substring(1));this.fastDown(b,this.pickerSelector.substring(1)).style.display="block";this.fastDown(b,this.tipSelector.substring(1)).style.display=""},hidePicker:function(a,b){a&&Event.stop(a);b.removeClassName(this.visibleTriggerSelector.substring(1));this.fastDown(b,this.pickerSelector.substring(1)).style.display="none";b.select("input[type\x3dtext]").each(function(c){c._x_undoButton._x_value=c.value;if(/Color$/.test(c.id)&&(c.style.backgroundColor=
c.value,ProColor)){var d=ProColor.prototype.computeTextColor(ProColor.prototype.decodeHexColor(c.value));d="#"+d.r.toColorPart()+d.g.toColorPart()+d.b.toColorPart();c.style.color=d}c._x_undoButton.style.visibility="hidden"}.bind(this))},attachChangeListeners:function(){var a=["keyup","keypress","procolor:changed","procolor:closed"];$$(this.maquetteSelector+" input[type\x3dtext]").each(function(b){a.each(function(c){b.observe(c,this.inputValueChanged.bindAsEventListener(this,b))}.bind(this));b._x_undoButton=
(new Element("button",{"class":"undo",title:"Undo"})).update("Undo");b._x_undoButton._x_input=b;b._x_undoButton._x_value=b.value;b._x_undoButton.style.visibility="hidden";b.insert({after:b._x_undoButton});b._x_undoButton.observe("click",function(c){b.value=b._x_undoButton._x_value;this.inputValueChanged(null,b);b._x_undoButton.style.visibility="hidden"}.bindAsEventListener(this))}.bind(this));$$("input[type\x3dreset]").each(function(b){b.observe("click",function(c){c.stop();b.form.reset();$$(this.maquetteSelector+
", "+this.maquetteSelector+" *").each(function(d){this.refreshStyle(d)}.bind(this))}.bindAsEventListener(this))}.bind(this))},retrievePropertyName:function(a){return a.substring(this.inputNamePrefix.length)},inputValueChanged:function(a,b){a=this.retrievePropertyName(b.name);a==this.logoProperty?""!=b.value.trim()?$(this.logoSelector).src=this.wrapImagePropertyValue(a,b.value):$(this.logoSelector).src=this.defaultLogoURl:$$(this.classPrefix+a).each(function(c){this.refreshStyle(c)}.bind(this));b._x_undoButton.style.visibility=
"visible"},refreshStyle:function(a){this.propertyMap[this.getMarker(a)]&&this.propertyMap[this.getMarker(a)].cssProperties.each(function(b){var c="";this.propertyMap[this.getMarker(a)][b].each(function(d){var f=$(this.inputNamePrefix+d),e="";f&&(e=f.value);e&&""!=e||(e=this.defaultValues[d]);e&&""!=e&&(c+=" "+this.wrapCSSPropertyValue(d,e))}.bind(this));c=c.strip();if(""!=c)try{a.style[b]=c}catch(d){}}.bind(this))},wrapCSSPropertyValue:function(a,b){return 0<=a.indexOf("Image")?"url("+this.wrapImagePropertyValue(a,
b)+")":b},wrapImagePropertyValue:function(a,b){return 0<=a.indexOf("Image")?"/xwiki/bin/download/ColorThemes/WizardPropertyMapping/__attachment__name__placeholder__".replace("__attachment__name__placeholder__",b):b},info:function(a){new XWiki.widgets.Notification(a,"info",{timeout:!1})}});
document.observe("dom:loaded",function(){ProColor&&(ProColor.prototype.options.onChanged=function(a,b){Event.fire(a.input||a,"procolor:changed")},ProColor.prototype.options.onClosed=function(a,b){Event.fire(a.input||a,"procolor:closed")},ProColor.prototype.options.onCancelClick=function(a,b){Event.fire(a.input||a,"procolor:closed")});new XWiki.editors.ColorThemeWizard});