"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="#F5F5F5";this.defaultValues.pageHeaderBackgroundColor="#FFFFFF";this.defaultValues.pageContentBackgroundColor="#FFFFFF";this.defaultValues.textColor="#222222";
this.defaultValues.textPrimaryColor="#555555";this.defaultValues.textSecondaryColor="#555555";this.defaultValues.titleColor="#2173AF";this.defaultValues.borderColor="#E8E8E8";this.defaultValues.linkColor="#0089DC";this.defaultValues.highlightColor="#FFFFCC";this.defaultValues.fieldGradientColor="#F5F5F5";this.defaultValues.menuBackgroundColor="#0272A6";this.defaultValues.menuGradientColor="#3A8ABC";this.defaultValues.menuLinkColor="#727272";this.defaultValues.menuContentBackgroundColor="#E1E1E1";
this.defaultValues.menuContentGradientColor="#FFFFFF";this.defaultValues.menuContentLinkColor="#4D5860";this.defaultValues.menuSelectedEntryBackgroundColor="#027cb5";this.defaultValues.menuSelectedEntryLinkColor="#F3F3F3";this.defaultValues.menuAddEntryBackgroundColor="#4D9244";this.defaultValues.menuAddEntryLinkColor="#FFFFFF";this.defaultValues.submenuContentBackgroundColor="#F5F5F5";this.defaultValues.panelBackgroundColor="#FFFFFF";this.defaultValues.panelHeaderBackgroundColor="#E1E1E1";this.defaultValues.panelHeaderGradientColor=
"#FFFFFF";this.defaultValues.panelHeaderTextColor="#4D5860";this.defaultValues.panelTextColor="#636B75";this.defaultValues.panelCollapsedBackgroundColor="#E1E1E1";this.defaultValues.panelCollapsedGradientColor="#FFFFFF";this.defaultValues.panelCollapsedTextColor="#4D5860";this.defaultValues.buttonPrimaryBackgroundColor="#386da7";this.defaultValues.buttonPrimaryGradientColor="#0089DC";this.defaultValues.buttonPrimaryTextColor="#FFFFFF";this.defaultValues.buttonSecondaryBackgroundColor="#E1E1E1";this.defaultValues.buttonSecondaryGradientColor=
"#FFFFFF";this.defaultValues.buttonSecondaryTextColor="#4D5860";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="url(/xwiki/bin/download/ColorThemes/DefaultColorTheme/header.png?rev\x3d1.2)";this.defaultValues.pageBackgroundImage=
"";this.defaultValues.headerBackgroundPosition="";this.defaultValues.logoImage="url(/xwiki/bin/download/ColorThemes/DefaultColorTheme/logo.png?rev\x3d1.2)"},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");
a="background-image".camelize();this.propertyMap.mainmenu.cssProperties.push(a);this.propertyMap.mainmenu[a]=[];this.propertyMap.mainmenu[a].push("menuBackgroundColor");this.propertyMap.mainmenu[a].push("menuGradientColor");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("menuContentBackgroundColor");a="color".camelize();this.propertyMap.contentmenu.cssProperties.push(a);this.propertyMap.contentmenu[a]=
[];this.propertyMap.contentmenu[a].push("menuContentLinkColor");a="background-image".camelize();this.propertyMap.contentmenu.cssProperties.push(a);this.propertyMap.contentmenu[a]=[];this.propertyMap.contentmenu[a].push("menuContentBackgroundColor");this.propertyMap.contentmenu[a].push("menuContentGradientColor");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");a="background-image".camelize();this.propertyMap.panelheader.cssProperties.push(a);this.propertyMap.panelheader[a]=[];this.propertyMap.panelheader[a].push("panelHeaderBackgroundColor");this.propertyMap.panelheader[a].push("panelHeaderGradientColor");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");a="background-image".camelize();this.propertyMap.collapsedpanel.cssProperties.push(a);this.propertyMap.collapsedpanel[a]=[];this.propertyMap.collapsedpanel[a].push("panelCollapsedBackgroundColor");this.propertyMap.collapsedpanel[a].push("panelCollapsedGradientColor");
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");
a="background-image".camelize();this.propertyMap.button.cssProperties.push(a);this.propertyMap.button[a]=[];this.propertyMap.button[a].push("buttonPrimaryBackgroundColor");this.propertyMap.button[a].push("buttonPrimaryGradientColor");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");a="background-image".camelize();this.propertyMap.secondaryButton.cssProperties.push(a);this.propertyMap.secondaryButton[a]=[];this.propertyMap.secondaryButton[a].push("buttonSecondaryBackgroundColor");this.propertyMap.secondaryButton[a].push("buttonSecondaryGradientColor");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("menuContentBackgroundColor");a="color".camelize();this.propertyMap.tabshead.cssProperties.push(a);this.propertyMap.tabshead[a]=[];this.propertyMap.tabshead[a].push("menuContentLinkColor");a="background-image".camelize();this.propertyMap.tabshead.cssProperties.push(a);this.propertyMap.tabshead[a]=[];this.propertyMap.tabshead[a].push("menuContentBackgroundColor");
this.propertyMap.tabshead[a].push("menuContentGradientColor");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);if(!e||""==e)if(e=this.defaultValues[d],0<=d.indexOf("Gradient")||0<=d.indexOf("Image"))e="";e&&""!=e&&(c+=" "+this.wrapCSSPropertyValue(d,e))}.bind(this));c=c.strip();if(""!=c)try{"backgroundImage"===b?(c=this.wrapGradients(c),a.style.cssText=a.style.cssText+" "+c):a.style[b]=c}catch(d){}}.bind(this))},wrapGradients:function(a){var b=RegExp("__gradient1__name__placeholder__","g"),c=RegExp("__gradient2__name__placeholder__","g"),d=a.split(" ");return 2<=
d.size()&&""!=d[0]&&""!=d[1]?(a="                                                  background-image: linear-gradient(to top, __gradient1__name__placeholder__ 0%, __gradient2__name__placeholder__ 100%);\n".replace(b,d[1]).replace(c,d[0]),a+="#css_filterGradient(${gradient1Placeholder}, ${gradient2Placeholder})".replace(b,d[1]).replace(c,d[0])):a},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/Dusk/__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});