var pageTextMode; var adminMode; var styleElementsMode; var adminHelpMode; var saveImgClass; var pages; var activeStyleEle; var activeEle; var activeSection; var activeStyleAttrib; var cssMap=""; var ajaxResp; var saveHoverVal; var viewerClicked="false"; var currentTheme; var themeAction; var newCss; var pubOrAdmin; var a_handle="top,left,position,z-index"; var a_indexPageImg="visibility,top,left,width,src,border-all,z-index"; var a_loginPageImg="visibility,top,left,width,src,border-all,z-index"; var a_floatImg="visibility,top,left,width,src,border-all,position,z-index"; var a_bar="visibility,top,left,width,height,background-image,background-repeat,background-color,border-all,position,z-index"; var a_text="visibility,top,left,width,height,background-color,foreground-color,border-all,position,z-index"; var a_video="visibility,top,left,width,border-all,position,z-index"; var a_dataBlock="visibility,top,left,width,font-family,font-size,border-all,z-index"; var a_title="visibility,top,left,width,foreground-color,font-size,font-family,border-all,z-index"; var a_body="background-image,background-repeat,background-color"; var a_headerContainer="top,left,height,width,background-image,background-repeat,background-color,border-all"; var a_contentContainer="top,left,width,background-image,background-repeat,background-color,foreground-color,border-all"; var a_pageContainer="width"; var a_footerContainer="top,left,width,background-image,background-repeat,background-color,border-top"; var a_mainMenuContainer="top,left,background-color,foreground-color,border-all,separator"; var a_mainMenuItemSeparator="visibility"; var a_scroller="visibility,top,left,width,background-color,foreground-color,border-all,z-index"; /* prototypes */ String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } String.prototype.endsWith = function(suffix) { return (this.substr(this.length - suffix.length) === suffix); } String.prototype.startsWith = function(prefix) { return (this.substr(0, prefix.length) === prefix); } String.prototype.contains = function(prefix) { if (this.indexOf(prefix)>-1){return true;} else{return false;} } /* prototypes */ function rand2(maxVal,floatVal) /* if floatVal isn't supplied, we get an integer */ { var randVal = Math.random()*maxVal; var val=typeof floatVal=='undefined'?Math.round(randVal):randVal.toFixed(floatVal); return (val>0?val:1); } function rand(minV, maxV) { var range=maxV-minV+1; return Math.floor(Math.random()*range+minV); } dojo.addOnLoad(function(){ adminMode="Off"; currentTheme="CHCC Initial Theme"; if (currentTheme.substring(0,1)=="."){ if(dojo.byId("saveAttribsButton")!=null){ dojo.byId("saveAttribsButton").value="Protected Theme"; } } if (dojo.byId("indexPage")!=null){ $("#indexPageImg").css("display","inline"); $("#scroller").css("display","inline"); $("#dataBlock").css("display","inline"); } if (dojo.byId("loginPage")!=null){ $("#loginPageImg").css("display","inline"); } }); function showWait(){ $("#waitBoxWrap").css("visibility","visible"); $("#waitBox").css("visibility","visible"); } function hideWait(){ $("#waitBoxWrap").css("visibility","hidden"); $("#waitBox").css("visibility","hidden"); } /* * This a private function used only to set specific values to some * default values prior to loading their actual values from a CSS object. * * Used only when previewing themes. */ function firstClear(){ $("#contentContainer").css("width","870px"); $("#pageContainer").css("width","630px"); $("#footerContainer").css("width","900px"); $("#dataBlock").css("width","300px"); $(".hasBgImg").css("background-image","url(http://my2ws.com/images/private/trans10x10.gif)"); $(".hasBgImg").css("background-repeat","no-repeat"); $(".hasBgImg").css("background-color","Transparent"); $(".hasBgImg").css("border","0px solid"); $("#mainMenuContainer").css("background-color","Transparent"); $("#mainMenuContainer").css("border","0px solid"); $(".boxHeader").css("background-color","Transparent"); $("#title").css("font-family","Arial"); $("#title").css("width","800px"); $("#title").css("top","10px"); $("#title").css("left","30px"); $("#title").css("font-size","48px"); $("#title").css("visibility","visible"); $("#subTitle").css("font-family","Arial"); $("#subTitle").css("width","400px"); $("#subTitle").css("top","55px"); $("#subTitle").css("left","300px"); $("#subTitle").css("font-size","20px"); $("#subTitle").css("visibility","visible"); $("#dataBlock").css("font-family","Arial"); $("#dataBlock").css("top","160px"); $("#dataBlock").css("left","500px"); $("#dataBlock").css("font-size","14px"); $("#dataBlock").css("line-height","1.2em"); $(".hideit").css("visibility","hidden"); $(".hideit").css("background-color","transparent"); $(".hideit").css("background-repeat","no-repeat"); $(".hideit").css("position","fixed"); $(".hideit").css("top","-999"); $(".hideit").css("left","-999"); $(".hideit").css("border","0px solid"); $(".hideit").css("border-color","transparent"); $("#loginPageImg").css("width","150px"); $("#loginPageImg").css("top","130px"); $("#loginPageImg").css("left","500px"); $("#indexPageImg").css("width","300px"); $("#indexPageImg").css("top","30px"); $("#indexPageImg").css("left","300px"); separatorOff(); } /* Used only when previewing themes */ function loadCssObjects(cssStr){ firstClear(); var objs = cssStr.split("}"); for (var ii in objs){ if (typeof objs[0] != 'undefined' && typeof objs[1] != 'undefined'){ var eachObj = objs[ii].split("{"); for (var jj in eachObj){ if (eachObj[0].substr(0,4) == "#nav"){continue;} if (typeof eachObj[0] != 'undefined' && typeof eachObj[1] != 'undefined'){ var attrib = eachObj[1].split(";"); for (var hh in attrib){ if (typeof attrib[hh] != 'undefined' && typeof attrib[1] != 'undefined'){ var sel = attrib[hh].split(":"); if (typeof sel[0] != 'undefined' && typeof sel[1] != 'undefined'){ for (var kk in sel){ var selecter = sel[0]; var valu = sel[1]; if (selecter == "background-color"){ activeStyleEle=eachObj[0].replace("#",""); setBgColorStyle(valu) } if (selecter == "width"){ $(eachObj[0]).css("width",valu); } if (selecter == "height"){ $(eachObj[0]).css("height",valu); } if (selecter == "color"){ activeStyleEle=eachObj[0].replace("#",""); setFgColorStyle(valu) } if (selecter == "left"){ $(eachObj[0]).css("left",valu); } if (selecter == "top"){ $(eachObj[0]).css("top",valu); } if (selecter == "position"){ $(eachObj[0]).css("position",valu); } if (selecter == "background-repeat"){ $(eachObj[0]).css("backgroundRepeat",valu); } if (selecter == "visibility"){ $(eachObj[0]).css("visibility",valu); } if (selecter == "display"){ $(eachObj[0]).css("display",valu); } if (selecter == "border"){ activeStyleEle=eachObj[0].replace("#",""); setBorder(valu) } if (selecter == "font-family"){ $(eachObj[0]).css("font-family",valu); } if (selecter == "src"){ activeStyleEle=eachObj[0].replace("#",""); setImgStyle(valu.replace("http~","http:")); } if (selecter == "background-image"){ activeStyleEle=eachObj[0].replace("#",""); setImgStyle(valu.replace("url(http~","http:").replace(")","")); } } } } } } } } } if ($("#mainMenuItemSeparator").css("visibility")=="visible"){ separatorOn(); } } function makeMap(ele,attribs){ var obj=document.getElementById(ele); if (obj==null) { return }; if (ele=='undefined'){ return }; cssMap=cssMap+"#"+ele+"{"; if (attribs.indexOf("src") > -1){ /* src must be found with javascript, not css */ if (document.getElementById(ele).src.indexOf("images") > -1){ cssMap=cssMap+"src:"+document.getElementById(ele).src+";"; } } if (attribs.indexOf("background-image") > -1){ cssMap=cssMap+"background-image:"+$("#"+ele).css("background-image")+";"; } if (attribs.indexOf("position") > -1){ cssMap=cssMap+"position:"+$("#"+ele).css("position")+";"; } if (attribs.indexOf("background-repeat") > -1){ cssMap=cssMap+"background-repeat:"+$("#"+ele).css("background-repeat")+";"; } if (attribs.indexOf("foreground-color") > -1){ cssMap=cssMap+"color:"+getHexColor($("#"+ele).css("color"))+";"; } if (attribs.indexOf("background-color") > -1){ cssMap=cssMap+"background-color:"+getHexColor($("#"+ele).css("background-color"))+";"; } if (attribs.indexOf("left") > -1){ cssMap=cssMap+"left:"+$("#"+ele).css("left")+";"; } if (attribs.indexOf("top") > -1){ cssMap=cssMap+"top:"+$("#"+ele).css("top")+";"; } if (attribs.indexOf("border-all") > -1){ cssMap=cssMap+"border:"+$("#"+ele).css("border-top-style")+" "+$("#"+ele).css("border-top-width")+" "+getHexColor($("#contentContainer").css("border-top-color"))+";"; } if (attribs.indexOf("border-top") > -1){ cssMap=cssMap+"border-top:"+$("#"+ele).css("border-top-style")+" "+$("#"+ele).css("border-top-width")+" "+getHexColor($("#contentContainer").css("border-top-color"))+";"; } if (attribs.indexOf("font-family") > -1){ cssMap=cssMap+"font-family:"+$("#"+ele).css("font-family")+";"; } if (attribs.indexOf("font-size") > -1){ cssMap=cssMap+"font-size:"+$("#"+ele).css("font-size")+";"; } if (attribs.indexOf("width") > -1){ cssMap=cssMap+"width:"+$("#"+ele).css("width")+";"; } if (attribs.indexOf("height") > -1){ cssMap=cssMap+"height:"+$("#"+ele).css("height")+";"; } if (attribs.indexOf("visibility") > -1){ cssMap=cssMap+"visibility:"+$("#"+ele).css("visibility")+";"; } if (attribs.indexOf("z-index") > -1){ cssMap=cssMap+"z-index:"+$("#"+ele).css("z-index")+";"; } cssMap=cssMap+"}"; } /* The following are set based on some other value or element */ function setOthers(){ cssMap=cssMap+".boxHeader{color:"+getHexColor($("#title").css("color"))+";background-color:"+getHexColor($("#headerContainer").css("background-color"))+";border-color:"+getHexColor($("#contentContainer").css("color"))+";}"; cssMap=cssMap+"#dataBlock{color:"+getHexColor($("#contentContainer").css("color"))+";}"; cssMap=cssMap+"#userPage table tr th{color:"+getHexColor($("#title").css("color"))+";background-color:"+getHexColor($("#headerContainer").css("background-color"))+";}"; cssMap=cssMap+"#scroller{border-color:"+getHexColor($("#scroller").css("color"))+";}"; if ($("#mainMenuItemSeparator").css("visibility")=="visible"){ cssMap=cssMap+"#mainMenuContainer #flyoutMenu #nav .mainMenuLi{border-left:2px solid;border-right:2px solid;margin-left:-2px;}"; } else{ cssMap=cssMap+"#mainMenuContainer #flyoutMenu #nav .mainMenuLi{border-left:0px solid;border-right:0px solid;margin-left:0px;}"; } /* navigation menu */ /* the 'mainContainer' constrains the width of the navigation menu. So, set that container's * width to the greater of either headerContainer or contentContainer. */ var headWid=parseInt($('#headerContainer').css('width').replace("px","")); var headLft=parseInt($('#headerContainer').css('left').replace("px","")); var contWid=parseInt($('#contentContainer').css('width').replace("px","")); var contLft=parseInt($('#contentContainer').css('left').replace("px","")); var headTot=headWid+headLft; var contTot=contWid+contLft; var wid=(headTot>contTot?headTot:contTot)+40; cssMap=cssMap+"#mainContainer{width:"+wid+"px;}"; cssMap=cssMap+"#nav li ul:visited,#nav a:visited,#nav li ul a:visited,#nav,#nav li ul a,#nav a,#nav li ul{background-color:"+getHexColor($("#mainMenuContainer").css("background-color"))+";}"; cssMap=cssMap+"#nav li ul:visited,#nav a:visited,#nav li ul a:visited,#nav,#nav li ul a,#nav a,#nav li ul{color:"+getHexColor($("#mainMenuContainer").css("color"))+";}"; cssMap=cssMap+"#nav li ul:hover,#nav a:hover,#nav a:visited:hover,#nav li ul a:hover,#nav li ul a:visited:hover,#nav a:hover,#nav a:visited:hover{background-color:"+getHexColor($("#mainMenuContainer").css("color"))+";}"; cssMap=cssMap+"#nav li ul:hover,#nav a:hover,#nav a:visited:hover,#nav li ul a:hover,#nav li ul a:visited:hover,#nav a:hover,#nav a:visited:hover{color:"+getHexColor($("#mainMenuContainer").css("background-color"))+";}"; cssMap=cssMap+"#nav li ul{border-color:"+getHexColor($("#mainMenuContainer").css("color"))+";}"; /* set other links to complement the main navigation menu */ /* non-hover */ cssMap=cssMap+".credits,.credits:visited,#contentContainer a,#contentContainer a:visited,"+ "#messageContainer a,#messageContainer a:visited,#pageContainer a,"+ "#pageContainer a:visited,#extLinksContainer a,#extLinksContainer a:visited,"+ "#extLinksContainer a:visited"+ "{color:"+getHexColor($("#contentContainer").css("color"))+";}"; /* hovering */ cssMap=cssMap+".credits:hover,#contentContainer a:hover,"+ "#messageContainer a:hover,#pageContainer a:hover,#extLinksContainer a:hover,"+ ".credits:visited:hover,#contentContainer a:visited:hover,"+ "#messageContainer a:visited:hover,#pageContainer a:visited:hover,"+ "#extLinksContainer a:visited:hover"+ "{color:"+getHexColor($("#mainMenuContainer").css("background-color"))+";"+ "background-color:"+getHexColor($("#mainMenuContainer").css("color"))+";}"; } function saveAttribs(){ if (currentTheme.substring(0,1)=="."){ alert("You cannot save a protected theme... use Theme > 'Save As' first."); return; } showWait(); makeMap("body",a_body); makeMap("headerContainer",a_headerContainer); makeMap("contentContainer",a_contentContainer); makeMap("pageContainer",a_pageContainer); makeMap("footerContainer",a_footerContainer); makeMap("mainMenuContainer",a_mainMenuContainer); makeMap("mainMenuItemSeparator",a_mainMenuItemSeparator); makeMap("title",a_title); makeMap("subTitle",a_title); makeMap("loginPageImg",a_loginPageImg); makeMap("indexPageImg",a_indexPageImg); makeMap("dataBlock",a_dataBlock); makeMap("scroller",a_scroller); makeMap("video1",a_video); makeMap("video2",a_video); makeMap("indexPageImgHdl",a_handle); makeMap("loginPageImgHdl",a_handle); makeMap("floatImg1Hdl",a_handle); makeMap("floatImg2Hdl",a_handle); makeMap("floatImg3Hdl",a_handle); makeMap("floatImg4Hdl",a_handle); makeMap("floatImg5Hdl",a_handle); makeMap("floatImg6Hdl",a_handle); makeMap("floatImg1",a_floatImg); makeMap("floatImg2",a_floatImg); makeMap("floatImg3",a_floatImg); makeMap("floatImg4",a_floatImg); makeMap("floatImg5",a_floatImg); makeMap("floatImg6",a_floatImg); makeMap("bar1",a_bar); makeMap("bar2",a_bar); makeMap("bar3",a_bar); makeMap("bar4",a_bar); makeMap("bar5",a_bar); makeMap("bar6",a_bar); makeMap("text1",a_text); makeMap("text2",a_text); makeMap("text3",a_text); makeMap("text4",a_text); // makeMap("hyperLinks",a_); setOthers(); /* Need to use Post here since the string is too long for 'get' sometimes. */ $("#cssMapText").html(cssMap); // console.log($("#cssMapText").html()); ajaxPost("updateTheme"); window.location.reload(); } function moveableOn() { $(".movable").draggable({ disabled:false }); $("#mainMenuContainerHandle").css("border","6px solid"); $("#mainMenuContainerHandle").css("visibility","visible"); toggleAdmin(); hidePropsViewer(); $("#saveAttribsButton").css("visibility","visible"); $( ".resizable" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:false,helper:"ui-resizable-helper" }); $( "#scroller" ).resizable({ disabled:false,handles:"e,se",maxHeight:20,helper:"ui-resizable-helper" }); $( "#title" ).resizable({ disabled:false,handles:"e,se",maxHeight:40,helper:"ui-resizable-helper" }); $( "#subTitle" ).resizable({ disabled:false,handles:"e,se",maxHeight:20,helper:"ui-resizable-helper" }); $( "#contentContainer" ).resizable({ disabled:false,handles:"e",minWidth:500,maxWidth:1200,helper:"ui-resizable-helper" }); $( "#contentContainer" ).resizable( "option", "alsoResize", '#pageContainer' ); $( "#indexPageImgHdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#indexPageImgHdl" ).resizable( "option", "alsoResize", '#indexPageImg' ); $( "#loginPageImgHdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#loginPageImgHdl" ).resizable( "option", "alsoResize", '#loginPageImg' ); $( "#floatImg1Hdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#floatImg1Hdl" ).resizable( "option", "alsoResize", '#floatImg1' ); $( "#floatImg2Hdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#floatImg2Hdl" ).resizable( "option", "alsoResize", '#floatImg2' ); $( "#floatImg3Hdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#floatImg3Hdl" ).resizable( "option", "alsoResize", '#floatImg3' ); $( "#floatImg4Hdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#floatImg4Hdl" ).resizable( "option", "alsoResize", '#floatImg4' ); $( "#floatImg5Hdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#floatImg5Hdl" ).resizable( "option", "alsoResize", '#floatImg5' ); $( "#floatImg6Hdl" ).resizable({ disabled:false,handles:"e,s,se",aspectRatio:true,helper:"ui-resizable-helper" }); $( "#floatImg6Hdl" ).resizable( "option", "alsoResize", '#floatImg6' ); if (dojo.byId("indexPage")!=null){ $("#indexPageImgHdl").css("visibility",$("#indexPageImg").css("visibility")); } else{ $("#indexPageImgHdl").css("visibility","hidden"); } if (dojo.byId("loginPage")!=null){ $("#loginPageImgHdl").css("visibility",$("#loginPageImg").css("visibility")); } else{ $("#loginPageImgHdl").css("visibility","hidden"); } $("#floatImg1Hdl").css("visibility",$("#floatImg1").css("visibility")); $("#floatImg2Hdl").css("visibility",$("#floatImg2").css("visibility")); $("#floatImg3Hdl").css("visibility",$("#floatImg3").css("visibility")); $("#floatImg4Hdl").css("visibility",$("#floatImg4").css("visibility")); $("#floatImg5Hdl").css("visibility",$("#floatImg5").css("visibility")); $("#floatImg6Hdl").css("visibility",$("#floatImg6").css("visibility")); } function toggleAdminHelp() { if (adminHelpMode != "On") { adminHelpMode="On"; $("#adminHelpButton").html(""); var pName=window.location.pathname.substring(window.location.pathname.lastIndexOf("/")); $("#adminHelpBox").html(eval(pName.substring(1,pName.indexOf(".")))); } else { adminHelpMode="Off"; $("#styleMenu").css("visibility","hidden"); $("#adminHelpButton").html(""); $("#adminHelpBox").css("visibility","hidden"); } } function toggleAdmin() { if (adminMode == "On") { adminMode="Off"; propsMode="Off"; styleElementsMode="Off"; $("#adminButton").html(""); $("#colorViewer").css("visibility","hidden"); $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); $("#helpBox").css("visibility","hidden"); $("#styleMenu").css("visibility","hidden"); $(".editWindow").css("visibility","hidden"); styleElementsMode="On"; pageTextMode="On"; } else { adminMode="On"; $("#adminButton").html(""); $("#helpBox").html(adminOnMsg); $("#styleMenu").css("visibility","visible"); if (dojo.byId("loginPage")==null){ $('#loginPageStyleMenu').hide(); } if (dojo.byId("indexPage")==null){ $('#indexPageImgMenu').hide(); $('#indexPageDataMenu').hide(); $('#indexPageScrollerMenu').hide(); } if (dojo.byId("userPage")==null){ $('#userPageStyleMenu').hide(); } } } function promptTheme(action,sourceTheme){ hidePropsViewer(); if (action=="saveAs"){ var val=prompt("Save As... (3 to 45 characters)","Enter name to Save As"); val=val.trim(); if ( val!=null){ if (val.length<3){ alert("Theme must be at least 3 characters."); return; } ajaxGet("isAvailable&theme="+val); if (ajaxResp!='yes'){ alert("Theme name '"+val+"' is already in use. You must provide a unique name."); return; } ajaxGet("saveThemeAs&newName="+val+"&theme="+sourceTheme); window.location.reload(); } } else if (action=="rename"){ var val=prompt("Rename Current Theme to... (3 to 45 characters)","Enter name to Save As"); val=val.trim(); if ( val!=null){ if (val.length<3){ alert("Theme must be at least 3 characters."); return; } ajaxGet("isAvailable&theme="+val); if (ajaxResp!="yes"){ alert("Theme name '"+val+"' is already in use. You must provide a unique name."); return; } ajaxGet("renameTheme&newName="+val); window.location.reload(); } } else if (action=="select"){ $("#adminButton").html(""); $("#adminToggleButton").css("width","360px"); $("#saveAttribsButton").css("visibility","hidden"); $("#adminButtonHandle").css("visibility","hidden"); $("#styleMenu").css("visibility","hidden"); themeAction="setTheme"; pubOrAdmin="public"; ajaxGet("listThemes&purpose=public"); $("#gViewer").html(ajaxResp); $("#genViewerHandle").css("visibility","visible"); $("#genViewer").css("visibility","visible"); hideWait(); } else if (action=="selectAdmin"){ $("#adminButton").html(""); $("#adminToggleButton").css("width","360px"); $("#saveAttribsButton").css("visibility","hidden"); $("#adminButtonHandle").css("visibility","hidden"); $("#styleMenu").css("visibility","hidden"); themeAction="setTheme"; pubOrAdmin="admin"; ajaxGet("listThemes&purpose=admin"); $("#gViewer").html(ajaxResp); $("#genViewer").css("visibility","visible"); $("#genViewerHandle").css("visibility","visible"); $("#genViewer").css("visibility","visible"); hideWait(); } else if (action=="selectInitial"){ $("#realTxt").hide(); $("#ipsumTxt").show(); var ttl=$("#newSiteName").html(); $("#title").html(ttl); var stl=$("#newSiteSubtitle").html(); $("#subTitle").html(stl); themeAction="setInitialTheme"; pubOrAdmin="admin"; ajaxGet("listThemes&purpose=system"); $("#gViewer").html(ajaxResp); $("#genViewerContainer").css("top","160px"); $("#genViewerContainer").css("left","730px"); $("#genViewer").css("width","200px"); $("#genViewer").css("height","300px"); $("#genViewerHandle").css("width","175px"); $("#genViewer").css("visibility","visible"); $("#genViewerHandle").css("visibility","visible"); $("#genViewer").css("visibility","visible"); hideWait(); } else if (action=="delete"){ themeAction="deleteTheme"; ajaxGet("listThemes&purpose=delete"); $("#gViewer").html(ajaxResp); $("#genViewer").css("visibility","visible"); $("#genViewerHandle").css("visibility","visible"); $("#genViewer").css("visibility","visible"); hideWait(); } } function checkMenuItemName(action){ var val=document.getElementById("newMenuItemName"); ajaxGet("menuItemExists&menuItemName="+val.value); if (ajaxResp=="yes"){ alert("Menu Item Name '"+val.value+"' is already in use. You must provide a unique name."); hideWait(); return; } setMenuItem(action); } function themeHoverAction(theme){ $("#styleMenu").css("visibility","hidden"); ajaxGet("getThemeByName&theme="+theme); loadCssObjects(ajaxResp); if (themeAction=='setInitialTheme'){ $("#initialTheme").val(theme); } } function themeOutAction(theme){ if (viewerClicked=='true'){return;} } function themeClickAction(theme){ viewerClicked='true'; if (themeAction=='deleteTheme'){ var r=confirm("Are you certain you want to delete '"+theme+"'? This cannot be undone."); if (r!=true){ $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); return; } showWait(); ajaxGet("deleteTheme&theme="+theme); window.location.reload(); } else { if (themeAction=='setInitialTheme'){ $("#initialTheme").val(theme); setHidden("genViewer"); return; } // invoke for all other actions (now just select and selectAdmin) // if this is a system theme, prompt to saveAs else { if (theme.startsWith('.Theme_')){ promptTheme('saveAs',theme); return; } } showWait(); ajaxGet("setTheme&theme="+theme+"&pubOrAdmin="+pubOrAdmin); window.location.reload(); } } function hidePropsViewer(){ $("#spn").css("visibility","hidden"); $("#propsViewer").css("visibility","hidden"); } function setHidden(ele){ $("#"+ele).css("visibility","hidden"); if (ele=="genViewer"){ $("#genViewerHandle").css("visibility","hidden"); } if (themeAction=="setInitialTheme"){ $("#ipsumTxt").hide(); $("#realTxt").show(); } else if (ele=="styleMenu"){ toggleAdmin(); } if (ele!="propsViewer" && ele!="styleMenu" ){ getProps(activeStyleEle); } } function setPositionStyle(position){ if (activeStyleEle.startsWith("floatImg") || activeStyleEle=="loginPageImg" || activeStyleEle=="indexPageImg"){ $("#"+activeStyleEle+"Hdl").css("position",position); } else{ $("#"+activeStyleEle).css("position",position); } } function setRepeatStyle(repeat){ $("#"+activeStyleEle).css("backgroundRepeat",repeat); } function repeatHoverAction(repeat){ setRepeatStyle(repeat); } function repeatOutAction(repeat){ if (viewerClicked=="true"){return;} setRepeatStyle(saveHoverVal); } function repeatClickAction(repeat){ viewerClicked="true"; setRepeatStyle(repeat); $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); getProps(activeStyleEle); } /* fontFamily */ function setFontFamStyle(fontFam){ $("#"+activeStyleEle).css("fontFamily",fontFam); } function fontFamHoverAction(fontFam){ setFontFamStyle(fontFam); } function fontFamOutAction(fontFam){ if (viewerClicked=="true"){return;} setFontFamStyle(saveHoverVal); } function fontFamClickAction(fontFam){ viewerClicked="true"; setFontFamStyle(fontFam); $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); getProps(activeStyleEle); } function getFontFams(element){ hidePropsViewer(); viewerClicked="false"; activeStyleEle=element; saveHoverVal=document.getElementById(element).style.fontFamily; showWait(); $("#helpBox").html(imageViewerMsg); ajaxGetAction("getFontFams"); $("#gViewer").html(ajaxResp); $("#genViewer").css("height","405px"); $("#genViewer").css("visibility","visible"); $("#genViewerHandle").css("visibility","visible"); $("#genViewer").show("slow"); hideWait(); $("#saveAttribsButton").css("visibility","visible"); } /* fontSize */ function setFontSizeStyle(fontSize){ $("#"+activeStyleEle).css("fontSize",fontSize); } function fontSizeHoverAction(fontSize){ setFontSizeStyle(fontSize); } function fontSizeOutAction(fontSize){ if (viewerClicked=="true"){return;} setFontSizeStyle(saveHoverVal); } function fontSizeClickAction(fontSize){ viewerClicked="true"; setFontSizeStyle(fontSize); $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); getProps(activeStyleEle); } function getFontSizes(element){ hidePropsViewer(); viewerClicked="false"; activeStyleEle=element; saveHoverVal=document.getElementById(element).style.fontSize; showWait(); $("#helpBox").html(imageViewerMsg); ajaxGetAction("getFontSizes"); $("#gViewer").html(ajaxResp); $("#genViewer").css("height","405px"); $("#genViewer").css("visibility","visible"); $("#genViewerHandle").css("visibility","visible"); $("#genViewer").show("slow"); hideWait(); $("#saveAttribsButton").css("visibility","visible"); } /* Spinner for widths and heights */ function setSpin(val){ if (activeStyleEle == null){return;} val=val+"px"; if (activeStyleAttrib=='height'){ $("#"+activeStyleEle).css("height",val); } else if (activeStyleAttrib=='width'){ $("#"+activeStyleEle).css("width",val); if (activeStyleEle=='contentContainer'){ val=parseInt(val.replace("px","")); $("#pageContainer").css("width",val-240+"px"); $("#footerContainer").css("width",val+30+"px"); } } var xx = getEleVal(activeStyleEle,activeStyleAttrib); $("#"+activeStyleAttrib+"val").html(xx); } function setLeft(val){ if (activeStyleEle == null){return;} if (activeStyleAttrib != "left") {return;} val=val+"px"; val=parseInt(val.replace("px","")); if (activeStyleEle.startsWith("floatImg") || activeStyleEle=="loginPageImg" || activeStyleEle=="indexPageImg"){ $("#"+activeStyleEle+"Hdl").css("left",val); } else{ $("#"+activeStyleEle).css("left",val); } var xx = getEleVal(activeStyleEle,activeStyleAttrib); $("#"+activeStyleAttrib+"val").html(xx); } function setTop(val){ if (activeStyleEle == null){return;} if (activeStyleAttrib != "top") {return;} val=val+"px"; val=parseInt(val.replace("px","")); if (activeStyleEle.startsWith("floatImg") || activeStyleEle=="loginPageImg" || activeStyleEle=="indexPageImg"){ $("#"+activeStyleEle+"Hdl").css("top",val); } else{ $("#"+activeStyleEle).css("top",val); } var xx = getEleVal(activeStyleEle,activeStyleAttrib); $("#"+activeStyleAttrib+"val").html(xx); } function setZindex(val){ if (activeStyleEle == null){return;} if (activeStyleAttrib != "z-index") {return;} if (activeStyleEle.startsWith("floatImg") || activeStyleEle=="loginPageImg" || activeStyleEle=="indexPageImg"){ $("#"+activeStyleEle+"Hdl").css("z-index",val); } else{ $("#"+activeStyleEle).css("z-index",val); } var xx = getEleVal(activeStyleEle,activeStyleAttrib); $("#"+activeStyleAttrib+"val").html(xx); } /* border */ /* For previewing themes only */ function setBorder(border){ if (activeStyleEle=="contentContainer"){ $("#"+activeStyleEle).css("border",border); $("#headerContainer").css("border",border); } if (activeStyleEle=="footerContainer"){ $("#footerContainer").css("border-top",border); } else { $("#"+activeStyleEle).css("border",border); } } function setBorderWidth(border){ if (activeStyleAttrib != "border-all" && activeStyleAttrib != "border-top" ) {return;} if (activeStyleEle=="contentContainer"){ $("#"+activeStyleEle).css("border-width",border); $("#headerContainer").css("border-width",border); } if (activeStyleEle=="footerContainer"){ $("#footerContainer").css("border-top-width",border); } else { $("#"+activeStyleEle).css("border-width",border); } } function setBorderStyle(border){ if (activeStyleAttrib != "border-all" && activeStyleAttrib != "border-top" ) {return;} if (activeStyleEle=="contentContainer"){ $("#"+activeStyleEle).css("border-style",border); $("#headerContainer").css("border-style",border); } if (activeStyleEle=="footerContainer"){ $("#footerContainer").css("border-top-style",border); } else { $("#"+activeStyleEle).css("border-style",border); } } /* background color */ function setBgColorStyle(color){ color=getHexColor(color); $("#"+activeStyleEle).css("backgroundColor",color); if (activeStyleEle=="mainMenuContainer"){ $(".mainMenuItem").css("backgroundColor",color); } if (activeStyleEle=="headerContainer"){ $(".boxHeader").css("backgroundColor",color); } } function bgColorHoverAction(color){ setBgColorStyle(color); } function bgColorOutAction(color){ if (viewerClicked=="true"){return;} setBgColorStyle(saveHoverVal); } function bgColorClickAction(color){ viewerClicked="true"; setBgColorStyle(color); $("#colorViewer").css("visibility","hidden"); getProps(activeStyleEle); } /* foreground color */ function setFgColorStyle(color){ color=getHexColor(color); $("#"+activeStyleEle).css("color",color); if (activeStyleEle=="mainMenuContainer"){ $(".mainMenuItem").css("color",color); } if (activeStyleEle=="contentContainer"){ $("#contentContainer").css("borderColor",color); $("#headerContainer").css("borderColor",color); $(".boxHeader").css("borderColor",color); $(".hyperLinks").css("color",color); } if (activeStyleEle=="title"){ $(".boxHeader").css("color",color); } } function fgColorHoverAction(color){ setFgColorStyle(color); } function fgColorOutAction(color){ if (viewerClicked=="true"){return;} setFgColorStyle(saveHoverVal); } function fgColorClickAction(color){ viewerClicked="true"; setFgColorStyle(color); $("#colorViewer").css("visibility","hidden"); getProps(activeStyleEle); } /* image */ function setImgStyle(img){ var element=dojo.byId(activeStyleEle); if(element==null){return;} element.src=img; if (activeStyleEle=="body"){ document.getElementById("body").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("body").style.backgroundRepeat="repeat"; } else{ document.getElementById("body").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="contentContainer"){ document.getElementById("contentContainer").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("contentContainer").style.backgroundRepeat="repeat"; } else{ document.getElementById("contentContainer").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="headerContainer"){ document.getElementById("headerContainer").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("headerContainer").style.backgroundRepeat="repeat"; } else{ document.getElementById("headerContainer").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="footerContainer"){ document.getElementById("footerContainer").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("footerContainer").style.backgroundRepeat="repeat"; } else{ document.getElementById("footerContainer").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="bar1"){ document.getElementById("bar1").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("bar1").style.backgroundRepeat="repeat"; } else{ document.getElementById("bar1").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="bar2"){ document.getElementById("bar2").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("bar2").style.backgroundRepeat="repeat"; } else{ document.getElementById("bar2").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="bar3"){ document.getElementById("bar3").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("bar3").style.backgroundRepeat="repeat"; } else{ document.getElementById("bar3").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="bar4"){ document.getElementById("bar4").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("bar4").style.backgroundRepeat="repeat"; } else{ document.getElementById("bar4").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="bar5"){ document.getElementById("bar5").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("bar5").style.backgroundRepeat="repeat"; } else{ document.getElementById("bar5").style.backgroundRepeat="no-repeat"; } } else if (activeStyleEle=="bar6"){ document.getElementById("bar6").style.backgroundImage="url("+img+")"; if (element.src.indexOf("texture")>0){ document.getElementById("bar6").style.backgroundRepeat="repeat"; } else{ document.getElementById("bar6").style.backgroundRepeat="no-repeat"; } } } function imgHoverAction(img){ setImgStyle(img); $("#genViewerHandle").html(img.replace("http://my2ws.com/images","")); $("#colorViewerHandle").html(img.replace("http://my2ws.com/images","")); } function imgOutAction(img){ $("#genViewerHandle").html("Close | Move Handle"); $("#colorViewerHandle").html("Close | Move Handle"); if (viewerClicked=="true"){return;} setImgStyle(saveHoverVal); } function imgClickAction(img){ /* This sets what gets retrieved in cssMap */ var element=dojo.byId(activeStyleEle); element.src=img; viewerClicked="true"; setImgStyle(img); $("#colorViewer").css("visibility","hidden"); getProps(activeStyleEle); $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); $("#saveAttribsButton").css("visibility","visible"); } /* image (end) */ function showIdBox(ele){ if (adminMode != "On"){return;} $("#idBox").html(ele); $("#idBox").css("visibility","visible"); } function hideIdBox(){ $("#idBox").css("visibility","hidden"); } /* Make a call to the server to set the correct directory for the image to be * uploaded to. Then display the upload dialog. */ function setUploadDir(imgType){ showWait(); ajaxGetAction("setUploadDir&imgSubDir="+imgType); hideWait(); toggleAdmin(); $("#photoContainer").css("visibility","visible"); } function itemPhoto(){ $("#itemPhotoContainer").css("visibility","visible"); } function cancelPhoto(){ $("#photoContainer").css("visibility","hidden"); $("#itemPhotoContainer").css("visibility","hidden"); } function toggleVisible(ele){ if ($("#"+ele).css("visibility")=="visible"){ $("#"+ele).css("visibility","hidden"); } else { $("#"+ele).css("visibility","visible"); } $("#saveAttribsButton").css("visibility","visible"); } function togglePosition(ele){ if ($("#"+ele).css("position")=="fixed"){ $("#"+ele).css("position","absolute"); } else { $("#"+ele).css("position","fixed"); } $("#saveAttribsButton").css("visibility","visible"); } function toggleSeparator(){ if ($("#mainMenuItemSeparator").css("visibility")=="visible"){ $("#mainMenuItemSeparator").css("visibility","hidden"); separatorOff(); } else { $("#mainMenuItemSeparator").css("visibility","visible"); separatorOn(); } $("#saveAttribsButton").css("visibility","visible"); } /* * mainMenuItemSeparator is a hidden div whose purpose is to set the * indicator of whether the separator bars are to be visible or hidden. */ function separatorOn(){ var bColor = $("#mainMenuContainer").css("color"); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("border-left","2px solid"); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("border-right","2px solid"); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("border-left-color",bColor); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("border-right-color",bColor); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("margin-left","-2px"); } function separatorOff(){ $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("border-left","0px solid"); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("border-right","0px solid"); $("#mainMenuContainer #flyoutMenu #nav .mainMenuLi").css("margin-left","0px"); } function ajaxGet(meth){ dojo.xhrGet({ url: "/ajaxActions.do?method="+meth, handleAs: "text", timeout : 5000, preventCache: true, sync : true, load : function(response, ioArgs) { ajaxResp=response; ajaxResp=ajaxResp.trim(); return response; }, error : function(response, ioArgs) { return response; } }); } function ajaxPost(meth){ dojo.xhrPost({ url: "/ajaxActions.do?method="+meth, handleAs: "text", timeout : 5000, preventCache: true, form : "ajaxForm", sync : true, load : function(response, ioArgs) { ajaxResp=response; ajaxResp=ajaxResp.trim(); return response; }, error : function(response, ioArgs) { return response; } }); } /*** function ajaxPost(meth){ url = "/ajaxActions.do?method="+meth; $.post(url, $("#ajaxform").serialize()); } ********/ function ajaxPostAnnounce(){ dojo.xhrPost({ url: "/announce.do?method=updateAnnounceMaint", handleAs: "text", timeout : 5000, preventCache: true, form : "ajaxAnnounceForm", sync : true, load : function(response, ioArgs) { ajaxResp=response; ajaxResp=ajaxResp.trim(); return response; }, error : function(response, ioArgs) { /* alert("Sorry! An error has occurred. If this persists, please email support@yourchurchsite.com to report it. Thanks."); */ return response; } }); } function ajaxPostAction(form){ dojo.xhrPost({ url: "/ajaxActions?method=updateUserPage", handleAs: "text", timeout : 5000, preventCache: true, form : form, sync : true, load : function(response, ioArgs) { ajaxResp=response; return response; }, error : function(response, ioArgs) { return response; } }); } function ajaxGetAction(meth){ dojo.xhrGet({ url: "/ajaxActions?method="+meth, handleAs: "text", timeout : 5000, preventCache: true, sync : true, load : function(response, ioArgs) { ajaxResp=response; ajaxResp=ajaxResp.trim(); return response; }, error : function(response, ioArgs) { ajaxResponse=""; /* alert("Sorry! An error has occurred. If this persists, please email support@yourchurchsite.com to report it. Thanks."); */ return response; } }); } function resetPassword(id){ showWait(); ajaxGetAction("resetPassword&personId="+id); hideWait(); var obj = jQuery.parseJSON(ajaxResp); if (obj.status == 'success'){ $("#username").val(obj.username); $("#loginAllowedBx").prop("checked",obj.loginAllowed); $("#passwordChangeBx").prop("checked",obj.changePw); } alert( obj.msg ); } function makeSite(){ $("#buttonHider").css("visibility","hidden"); alert("Please wait while we create your new website. This can take a few minutes. When completed, we will send you another email outlining how to access your new website, and how to take the next steps of logging on, adding some content to the basic pages, and tweaking the Theme that you have chosen so it is unique to your website. Now, please click the OK button then wait patiently until the screen refreshes..."); showWait(); } /* Send the position from the top of this div, such as top=1, left=2, etc. so I can accurately * place the sTop value to get the spinner on the right div. Also, hide the spinner when not over * an applicable element. */ function setSpn(element,styleAttrib,divNo){ var initSpnVal=0; var initMax=0; var ininMin=0; var initCallback; var sTop=0; var adj=+5; var sHeight=19; activeStyleEle=element; activeStyleAttrib=styleAttrib; $("#spn").css("visibility","hidden"); $("#spn").css("left","163px"); $("#borders").css("visibility","hidden"); sTop=((divNo * sHeight)+adj)+"px"; if (styleAttrib=="width"){ initCallback=setSpin; initMin=10; initMax=1500; initSpnVal=$("#"+element).css("width").replace("px",""); } else if (styleAttrib=="height"){ initCallback=setSpin; initMin=10; initMax=1500; initSpnVal=$("#"+element).css("height").replace("px",""); } else if (styleAttrib=="z-index"){ initCallback=setZindex; initMin=10; initMax=30; if (element.startsWith("floatImg") || element=="loginPageImg" || element=="indexPageImg"){ initSpnVal=$("#"+element+"Hdl").css("z-index"); } else{ initSpnVal=$("#"+element).css("z-index"); } } else if (styleAttrib=="left"){ initCallback=setLeft; initMin=-300; initMax=1500; if (element.startsWith("floatImg") || element=="loginPageImg" || element=="indexPageImg"){ initSpnVal=$("#"+element+"Hdl").css("left").replace("px",""); } else{ initSpnVal=$("#"+element).css("left").replace("px",""); } } else if (styleAttrib=="top"){ initCallback=setTop; initMin=-300; initMax=1500; if (element.startsWith("floatImg") || element=="loginPageImg" || element=="indexPageImg"){ initSpnVal=$("#"+element+"Hdl").css("top").replace("px",""); } else{ initSpnVal=$("#"+element).css("top").replace("px",""); } } else if (styleAttrib=="border-all" || styleAttrib=="border-top"){ initCallback=setBorderWidth; initMin=0; initMax=10; initSpnVal=$("#"+element).css("border-top-width") .replace("px","") .replace(" ","") .replace("none","") .replace("solid","") .replace("ridge","") .replace("inset","") .replace("outset","") .replace("double","") .replace("dotted","") .replace("dashed",""); $("#borders").css("top",sTop); $("#spn").css("left","245px"); $("#borders").css("visibility","visible"); } else{return;} $('#spn').spinit({ min:initMin, max:initMax, stepInc:1, pageInc:20, height:16, initValue:initSpnVal, callback:initCallback }); $("#spn").css("top",sTop); $("#spn").css("visibility","visible"); } function spnOut(ele,attrib){ /* these use the spinner */ var str="top,left,width,height,z-index"; if (!str.contains(attrib)) {return;} // console.log("spnOut : " + attrib + " " + $("#"+attrib+"val").html()); } /* Itereate the css attributes of the selected element. Determine the * type of viewer to use for each. */ function getProps(ele){ /* If there is no propsViewer, the user is not logged in as Admin. So, we just want * to return. The length property will tell us whether that object exists. */ if (($('#propsViewer').length == 0) || (ele=="undefined")){ return; } var attribs=eval("a_"+ele.replace("1","").replace("2","").replace("3","").replace("4","").replace("5","").replace("6","").replace("subT","t")).split(","); var s; var element; s="
"+getElement(ele)+"
"; var label; var val; var controlType; var cAction; var tall=0; var count=1; var skip=false; for(var i in attribs) { skip=false; label=getLabel(attribs[i]); val=getEleVal(ele,attribs[i]); controlType=getControl(ele,attribs[i],val); cAction=getAttribClickAction(ele,attribs[i]); if (ele=="footerContainer" && (attribs[i]=="top"||attribs[i]=="left"||attribs[i]=="width")){skip=true;} if (skip==false){ count++; s+="
"+label+"" +""+controlType+"
"; } } tall=(count * 19)+43; $("#pViewer").html(s); $("#propsViewer").css("height",tall+"px"); $("#propsViewer").css("visibility","visible"); } function getElement(ele){ switch (ele){ case "mainMenuContainer": ele="Navigation Menu"; break; case "contentContainer": ele="Content Area"; break; case "footerContainer": ele="Footer Area"; break; case "headerContainer": ele="Header Area"; break; case "floatImg1": ele="Image 1"; break; case "floatImg2": ele="Image 2"; break; case "floatImg3": ele="Image 3"; break; case "floatImg4": ele="Image 4"; break; case "floatImg5": ele="Image 5"; break; case "floatImg6": ele="Image 6"; break; case "indexPageImg": ele="Index Page Image"; break; case "loginPageImg": ele="Login Page Image"; break; case "dataBlock": ele="Data Block"; break; } return "--- "+ele.toUpperCase()+" ---"; } function getLabel(attrib){ switch (attrib){ case "visibility": attrib="Visible"; break; case "position": attrib="Fixed"; break; case "src": attrib="Image"; break; case "border-all": attrib="Border"; break; case "foreground-color": attrib="font-color"; break; case "separator": attrib="item-separator"; break; case "z-index": attrib="Back / Forward"; break; case "left": attrib="Left / Right"; break; } return attrib.toUpperCase(); } /* What we do when user clicks each attribute in the Props Viewer */ function getAttribClickAction(ele,attrib){ var str=""; var categ=""; if (attrib=="font-family"){ str="getFontFams(\""+ele+"\")"; } else if (attrib=="font-size"){ str="getFontSizes(\""+ele+"\")"; } else if (attrib=="src"){ categ="bodybg"; str="imgBtn(\""+ele+"\")"; } else if (attrib=="background-image"){ categ="bodybg"; str="imgBtn(\""+ele+"\")"; } else if (attrib=="background-texture"){ categ="texture"; str="getImages(\""+ele+"\",\""+categ+"\")"; str="imgBtn(\""+ele+"\")"; } else if (attrib=="background-color"){ categ="bgColor"; str="getColors(\""+ele+"\",\""+categ+"\")"; } else if (attrib=="foreground-color"){ categ="fgColor"; str="getColors(\""+ele+"\",\""+categ+"\")"; } return str; } function getEleVal(ele,attrib){ var str; var val; if (attrib=="foreground-color"){ str=$("#"+ele).css("color"); } else if (attrib=="background-image"){ val=$("#"+ele).css(attrib); if (val.indexOf("images")<1){ str=""; } else{ str=val.substr(val.indexOf("images")+7).replace('")',""); } } else if (attrib=="background-texture"){ val=$("#"+ele).css("background-image"); if (val.indexOf("images")<1){ str=""; } else{ str=val.substr(val.indexOf("images")+7).replace('")',""); } } else if (attrib=="src"){ val=document.getElementById(ele).src; if (val.indexOf("images")<1){ str=""; } else{ str=val.substr(val.indexOf("images")+7).replace('")',""); } } else if (attrib=="border-all" || attrib=="border-top"){ str=$("#"+ele).css("border-top-style")+" "+$("#"+ele).css("border-top-width"); } else if ((ele.startsWith("floatImg") || ele=="loginPageImg" || ele=="indexPageImg") && (attrib=="left" || attrib=="top" || attrib=="z-index" || attrib=="position")){ str=$("#"+ele+"Hdl").css(attrib); } else{ str=$("#"+ele).css(attrib); } return str; } function getControl(ele,attrib,val){ if (ele.startsWith("floatImg") && attrib=="position"){ ele+="Hdl"; } var str=""; var checkd=""; var repeat1=""; var repeat2=""; var repeat3=""; var repeat4=""; if (attrib=="background-color"){ str="  "+getColorName(val)+""; } else if (attrib=="foreground-color"){ str="  "+getColorName(val)+""; } else if (attrib=="visibility"){ if ($("#"+ele).css("visibility")=="visible"){checkd="checked";} else {checkd="";} str=""; } else if (attrib=="position"){ if ($("#"+ele).css("position")=="fixed"){checkd="checked";} else {checkd="";} str=""; } else if (attrib=="separator"){ if ($("#mainMenuItemSeparator").css("visibility")=="visible"){checkd="checked";} else {checkd="";} str=""; } else if (attrib=="background-repeat"){ if (val=="repeat"){repeat2="checked";} else if (val=="repeat-x"){repeat3="checked";} else if (val=="repeat-y"){repeat4="checked";} else {repeat1="checked";} str="None"; str+="Both"; str+="X"; str+="Y"; } else{ str=val; } $("#saveAttribsButton").css("visibility","visible"); return str; } /* This does setup for background and font colors */ function getColors(element,fgOrbg){ hidePropsViewer(); activeStyleEle=element; colorSwatchClick(fgOrbg); } function colorSwatchClick(fgOrbg){ viewerClicked="false"; if (fgOrbg=="bgColor"){ saveHoverVal=document.getElementById(activeStyleEle).style.backgroundColor; } else if (fgOrbg=="fgColor"){ saveHoverVal=document.getElementById(activeStyleEle).style.color; } $("#cViewer").html(getColorSwatches(fgOrbg)); $("#colorViewer").css("visibility","visible"); $("#genViewer").css("visibility","hidden"); $("#genViewerHandle").css("visibility","hidden"); hideWait(); $("#saveAttribsButton").css("visibility","visible"); } /* Retrieve the Image menu (links) and display it */ function imgBtn(eleType){ hidePropsViewer(); activeEle=eleType; activeStyleEle=eleType; showWait(); ajaxGetAction("getImageMenu&eleType="+eleType); $("#gViewer").html(ajaxResp); $("#genViewer").css("height","400px"); $("#genViewer").css("width","600px"); $("#genViewer").css("visibility","visible"); $("#genViewerHandle").css("visibility","visible"); hideWait(); } /* This does setup for background images, colors, textures */ function getImages(element,category){ hidePropsViewer(); activeStyleEle=element; imgCatClick(category); } /* Click a link for specific images category (cakes,crosses, etc) */ function imgCatClick(category){ viewerClicked="false"; queryStr="getImages&imgSubDir="+category+"&activeEle="+activeEle; if (activeStyleEle=="userPage"){ /* No need to deal with saving previous values */ } else{ if (activeStyleEle=="body" || activeStyleEle=="headerContainer" || activeStyleEle=="contentContainer" || activeStyleEle=="bar1" || activeStyleEle=="bar2" || activeStyleEle=="bar3" || activeStyleEle=="bar4" || activeStyleEle=="bar5" || activeStyleEle=="bar6" ){ saveHoverVal=document.getElementById(activeStyleEle).style.backgroundImage; } else{ saveHoverVal=document.getElementById(activeStyleEle).src; } } showWait(); ajaxGetAction(queryStr); $("#imgs").html(ajaxResp+$("#imgs").html()); hideWait(); } function showAdmin(){ if (dojo.byId("adminHelpButton")!=null){ $("#adminHelpButton").html(""); } if (dojo.byId("adminButton")!=null){ $("#adminButton").html(""); $("adminButton").css("visibility","visible"); } hideWait(); } function fieldHover(field){ $("#helpBox").html(eval(field)); $("#helpBox").css("visibility","visible"); } function fieldOut(){ $("#helpBox").css("visibility","hidden"); } function setTheme(theme){ dojo.byId("initialTheme").value=theme; } function likeItem(itemId,itemNo,itemDesc){ dojo.byId("itemId").value=itemId; $("#itemNo").html(itemNo); $("#itemDesc").html(itemDesc); /* Hide the main menu because it floats above the order form */ $("#mainMenuContainer").css("visibility","hidden"); $("#itemEmailOrderContainer").css("visibility","visible"); } /* I don't believe this function is used. The order form submits directly to * the 'ItemActions' object. ********** function orderLikeItem(customer){ alert(currentItemId); ajaxGet("sendItemEmail&itemId="+currentItemId+"&customer="+escape(customer)); $("#mainMenuContainer").css("visibility","visible"); } **********/ function cancelLikeItem(){ $("#itemEmailOrderContainer").css("visibility","hidden"); $("#mainMenuContainer").css("visibility","visible"); } function mouseX(evt) { if (evt.pageX) return evt.pageX; else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); else return null; } function mouseY(evt) { if (evt.pageY) return evt.pageY; else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null; } function replaceAll(txt, replace, with_this) { return txt.replace(new RegExp(replace, 'g'),with_this); } namedColors=new Array( 'transparent-transparent' ,'#F0F8FF-aliceblue' ,'#FAEBD7-antiquewhite' ,'#00FFFF-aqua' ,'#7FFFD4-aquamarine' ,'#F0FFFF-azure' ,'#F5F5DC-beige' ,'#FFE4C4-bisque' ,'#000000-black' ,'#FFEBCD-blanchedalmond' ,'#0000FF-blue' ,'#8A2BE2-blueviolet' ,'#A52A2A-brown' ,'#DEB887-burlywood' ,'#5F9EA0-cadetblue' ,'#7FFF00-chartreuse' ,'#D2691E-chocolate' ,'#FF7F50-coral' ,'#6495ED-cornflowerblue' ,'#FFF8DC-cornsilk' ,'#DC143C-crimson' ,'#00008B-darkblue' ,'#008B8B-darkcyan' ,'#B8860B-darkgoldenrod' ,'#A9A9A9-darkgray' ,'#006400-darkgreen' ,'#BDB76B-darkkhaki' ,'#8B008B-darkmagenta' ,'#556B2F-darkolivegreen' ,'#FF8C00-darkorange' ,'#9932CC-darkorchid' ,'#8B0000-darkred' ,'#E9967A-darksalmon' ,'#8FBC8F-darkseagreen' ,'#483D8B-darkslateblue' ,'#2F4F4F-darkslategray' ,'#00CED1-darkturquoise' ,'#9400D3-darkviolet' ,'#FF1493-deeppink' ,'#00BFFF-deepskyblue' ,'#696969-dimgray' ,'#1E90FF-dodgerblue' ,'#B22222-firebrick' ,'#FFFAF0-floralwhite' ,'#228B22-forestgreen' ,'#FF00FF-fuchsia' ,'#DCDCDC-gainsboro' ,'#F8F8FF-ghostwhite' ,'#FFD700-gold' ,'#DAA520-goldenrod' ,'#808080-gray' ,'#008000-green' ,'#ADFF2F-greenyellow' ,'#F0FFF0-honeydew' ,'#FF69B4-hotpink' ,'#CD5C5C-indianred' ,'#4B0082-indigo' ,'#FFFFF0-ivory' ,'#F0E68C-khaki' ,'#E6E6FA-lavender' ,'#FFF0F5-lavenderblush' ,'#7CFC00-lawngreen' ,'#FFFACD-lemonchiffon' ,'#ADD8E6-lightblue' ,'#F08080-lightcoral' ,'#E0FFFF-lightcyan' ,'#FAFAD2-lightgoldenrodyellow' ,'#90EE90-lightgreen' ,'#D3D3D3-lightgrey' ,'#FFB6C1-lightpink' ,'#FFA07A-lightsalmon' ,'#20B2AA-lightseagreen' ,'#87CEFA-lightskyblue' ,'#778899-lightslategray' ,'#B0C4DE-lightsteelblue' ,'#FFFFE0-lightyellow' ,'#00FF00-lime' ,'#32CD32-limegreen' ,'#FAF0E6-linen' ,'#800000-maroon' ,'#66CDAA-mediumaquamarine' ,'#0000CD-mediumblue' ,'#BA55D3-mediumorchid' ,'#9370DB-mediumpurple' ,'#3CB371-mediumseagreen' ,'#7B68EE-mediumslateblue' ,'#00FA9A-mediumspringgreen' ,'#48D1CC-mediumturquoise' ,'#C71585-mediumvioletred' ,'#191970-midnightblue' ,'#F5FFFA-mintcream' ,'#FFE4E1-mistyrose' ,'#FFE4B5-moccasin' ,'#FFDEAD-navajowhite' ,'#000080-navy' ,'#FDF5E6-oldlace' ,'#808000-olive' ,'#6B8E23-olivedrab' ,'#FFA500-orange' ,'#FF4500-orangered' ,'#DA70D6-orchid' ,'#EEE8AA-palegoldenrod' ,'#98FB98-palegreen' ,'#AFEEEE-paleturquoise' ,'#DB7093-palevioletred' ,'#FFEFD5-papayawhip' ,'#FFDAB9-peachpuff' ,'#CD853F-peru' ,'#FFC0CB-pink' ,'#DDA0DD-plum' ,'#B0E0E6-powderblue' ,'#800080-purple' ,'#FF0000-red' ,'#BC8F8F-rosybrown' ,'#4169E1-royalblue' ,'#8B4513-saddlebrown' ,'#FA8072-salmon' ,'#FAA460-sandybrown' ,'#2E8B57-seagreen' ,'#FFF5EE-seashell' ,'#A0522D-sienna' ,'#C0C0C0-silver' ,'#87CEEB-skyblue' ,'#6A5ACD-slateblue' ,'#708090-slategray' ,'#FFFAFA-snow' ,'#00FF7F-springgreen' ,'#4682B4-steelblue' ,'#D2B48C-tan' ,'#008080-teal' ,'#D8BFD8-thistle' ,'#FF6347-tomato' ,'#40E0D0-turquoise' ,'#EE82EE-violet' ,'#F5DEB3-wheat' ,'#FFFFFF-white' ,'#F5F5F5-whitesmoke' ,'#FFFF00-yellow' ,'#9ACD32-yellowgreen' ); function getColorSwatches(fgOrbg){ var colorTemplate="COLOR_WORD
COLOR_WORD
"; var str2; var colorName; var str="
"; fgOrbg=fgOrbg.substring(0,2); for (var ii in namedColors){ var part=namedColors[ii].split("-"); colorName=part[1]; str2=replaceAll(colorTemplate,'XX',fgOrbg); str+=replaceAll(str2,'COLOR_WORD',colorName); } str+="
"; return str; } /* If colorName begins with hash, it is already hex; just return it. * If it begins with rgb, convert it to hex. * If it is a named color, translate it and return that. * If it is none of these, it is probably undefined or something; just return that. */ function getHexColor(color){ if (color==undefined){return "";} color=color.toLowerCase(); if (color.startsWith("#")){return color.toUpperCase();} if (color.startsWith("rgb")){return getHex(color.toUpperCase());} for (var ii in namedColors){ var part=namedColors[ii].split("-"); if (part[1]==color){ return part[0].toUpperCase(); } } return color.toLowerCase(); } function getColorName(color){ color=getHexColor(color); for (var ii in namedColors){ var part=namedColors[ii].split("-"); if (part[0]==color){ return part[1].toLowerCase(); } } return color.toLowerCase(); } function getHex(rgb){ rgb=replaceAll(rgb," ",""); rgb=rgb.replace("rgb(",""); rgb=rgb.replace("RGB(",""); rgb=rgb.replace(")",""); var vals=rgb.split(","); rgb=rgbToHex(vals[0],vals[1],vals[2]); return "#"+rgb; } function rgbToHex(R,G,B){ return toHex(R)+toHex(G)+toHex(B) } function toHex(n) { n = parseInt(n,10); if (isNaN(n)) return "00"; n = Math.max(0,Math.min(n,255)); return "0123456789ABCDEF".charAt((n-n%16)/16) + "0123456789ABCDEF".charAt(n%16); } /* alternate to 'getHex' - may not currently be used */ function rgbConvert(str) { str = str.replace(/rgb\(|\)/g, "").split(","); str[0] = parseInt(str[0], 10).toString(16).toLowerCase(); str[1] = parseInt(str[1], 10).toString(16).toLowerCase(); str[2] = parseInt(str[2], 10).toString(16).toLowerCase(); str[0] = (str[0].length == 1) ? '0' + str[0] : str[0]; str[1] = (str[1].length == 1) ? '0' + str[1] : str[1]; str[2] = (str[2].length == 1) ? '0' + str[2] : str[2]; return ('#' + str.join("")); } /* * Page editing routines */ function getThisPageName(){ var thisPageName; thisPageName=$('#pageName').html(); if (thisPageName==null || thisPageName==""){ thisPageName=$('#currentPageName').html(); } if (thisPageName==null || thisPageName==""){ thisPageName="unknown"; } return thisPageName; } function editUserPage(){ var thisPage = getThisPageName(); if (thisPage == 'unknown'){ alert("pageName needs to be set"); return; } $("#styleMenu").css("visibility","hidden"); hidePropsViewer(); $('#ckTextArea') .ckeditor( function() { callback1(); }, { filebrowserBrowseUrl : '/ajaxActions?method=getUserPgImageMenu', filebrowserWindowWidth : '740', filebrowserWindowHeight : '440' }) .ckeditor( callback2 ); showWait(); $("#ckEditDiv").css("top","2px"); $('#ckEditDiv').css("visibility","visible"); } function callback1(){ ajaxGetAction("getUserPage&page=" + getThisPageName()); $( '#ckTextArea' ).val( ajaxResp ); } function callback2(){ // console.log("editor loaded; callback2 fired"); } function ckSave(){ CKEDITOR.instances.ckTextArea.updateElement(); $('#page').val(getThisPageName()); ajaxPostAction("ckForm"); $('#pageSavedMsg').show("fast"); $('#pageSavedMsg').hide(2500); } function ckReload(){ window.location.reload(); } function ckCancel(){ $("#ckEditDiv").css("top","-1000px"); $('#ckEditDiv').css("visibility","hidden"); $("#waitBoxWrap").css("visibility","hidden"); $("#waitBox").css("visibility","hidden"); } $(document).ready(function() { var eSelect = document.getElementById('selBorder'); if (eSelect==null){return;} eSelect.onchange = function() { if(eSelect.selectedIndex === 0) { setBorderStyle("none"); } else if (eSelect.selectedIndex === 1) { setBorderStyle("solid"); } else if (eSelect.selectedIndex === 2) { setBorderStyle("dashed"); } else if (eSelect.selectedIndex === 3) { setBorderStyle("dotted"); } else if (eSelect.selectedIndex === 4) { setBorderStyle("groove"); } else if (eSelect.selectedIndex === 5) { setBorderStyle("inset"); } else if (eSelect.selectedIndex === 6) { setBorderStyle("outset"); } else if (eSelect.selectedIndex === 7) { setBorderStyle("ridge"); } $("#"+activeStyleAttrib+"val").html(getEleVal(activeStyleEle,"border-top")); } }); /* end of source */