/* This has to be a jsp page to parse the bean:write tags */ dojo.require("dojo.dnd.Source"); //dojo.require("dojo.dnd.Moveable"); dojo.require("dojo.parser"); var adminMode; var adminHelpMode; var saveImgSpot; var saveImgClass; var allViewer; var gifViewer; var footerViewer; var pages; var t; dojo.addOnLoad(function(){ adminMode="Off"; // dojo.query("#waitBox").style({"visibility":"visible"}); CANNOT do this here; it flashes the wait box when not logged in // SHOULD FIND A way to determine whether to do this only if admin is logged in; not just every time the page loads. // May be able to put this in a function and run it from ShowAdmin. Then we only populate the viewers when they might get used. var d = dojo.xhrGet({ url: "/ajaxActions.do?method=showViewer&imgSubDir=all", handleAs: "text", timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { allViewer = response; return response; }, error : function(response, ioArgs) { return response; } }); var d = dojo.xhrGet({ url: "/ajaxActions.do?method=showViewer&imgSubDir=gif", handleAs: "text", timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { //console.log("Success! ", response) ; gifViewer = response; return response; }, error : function(response, ioArgs) { //console.log("Error! ", response) ; return response; } }) ; var d = dojo.xhrGet({ url: "/ajaxActions.do?method=showViewer&imgSubDir=footer", handleAs: "text", timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { //console.log("Success! ", response) ; footerViewer = response; return response; }, error : function(response, ioArgs) { //console.log("Error! ", response) ; return response; } }) ; dojo.query("#pageLayoutButton").style({"visibility":"hidden"}); dojo.query("#waitBox").style({"visibility":"hidden"}); }); function hideImgSpots() { dojo.query(".imgSpot").style({"visibility":"hidden"}); dojo.query(".imgSpotLeft").style({"visibility":"hidden"}); dojo.query(".imgSpotRight").style({"visibility": "hidden"}); dojo.query(".imgViewer").style({"visibility":"hidden"}); dojo.query(".footer").style({"visibility":"hidden"}); } function showImgSpots() { dojo.query(".imgSpot").style({"visibility":"visible"}); dojo.query(".imgSpotLeft").style({"visibility":"visible"}); dojo.query(".imgSpotRight").style({"visibility":"visible"}); dojo.query(".footer").style({"visibility":"visible"}); } function toggleAdminHelp() { if (adminHelpMode != "On") { adminHelpMode="On"; dojo.byId("adminHelpButton").innerHTML=""; var pName=window.location.pathname.substring(window.location.pathname.lastIndexOf("/")); dojo.byId("adminHelpBox").innerHTML=eval(pName.substring(1,pName.indexOf("."))); dojo.query("#adminHelpBox").style({"visibility":"visible"}); } else { adminHelpMode="Off"; dojo.byId("adminHelpButton").innerHTML=""; dojo.query("#adminHelpBox").style({"visibility":"hidden"}); } } function toggleAdmin() { if (dojo.byId("insertImgSpots") == null) { var ok=confirm("This page is not ready to accept images.\n\n"+ "Click OK to prepare it.\n\n"+ "Or Cancel if you do not want images on this page."); if (ok){prepareImgSpots();}else{return;} } if (adminMode != "On") { adminMode="On"; dojo.byId("adminButton").innerHTML=""; showImgSpots(); dojo.byId("helpBox").innerHTML=adminOnMsg; dojo.byId("pageLayoutBox").innerHTML=""; dojo.query("#pageLayoutBox").style({"visibility":"visible"}); dojo.query("#helpBox").style({"visibility":"visible"}); dojo.query(".btn").style({"visibility":"visible"}); } else { adminMode="Off"; dojo.byId("adminButton").innerHTML=""; hideImgSpots(); dojo.query("#pageLayoutBox").style({"visibility":"hidden"}); dojo.query("#helpBox").style({"visibility":"hidden"}); dojo.query(".btn").style({"visibility":"hidden"}); } } function prepareImgSpots(){ dojo.byId("waitBox").innerHTML="Please wait...patiently...this can take a few minutes :(

When the process finishes, the page will refresh and this box will disappear. Then we can continue."; dojo.query("#waitBox").style({"visibility":"visible"}); method="prepareImgSpots"; var d = dojo.xhrGet({ url: "/ajaxActions.do?method="+method+"&page=" + window.location, timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { return response; }, error : function(response, ioArgs) { return response; } }); window.location.reload(); } function saveImage(img,method){ dojo.query("#waitBox").style({"visibility":"visible"}); hideImgSpots(); var imgSpot = saveImgSpot; dojo.query("#imgViewer").style({"visibility":"hidden"}); if (imgSpot!=null) { div=imgSpot.replace("L","").replace("R",""); } var qStr = "imgSpot="+imgSpot+"\n img="+img+"\n div="+div+"\n method="+method; var d = dojo.xhrGet({ url: "/ajaxActions.do?method="+method+"&pic="+img+"&imgSpot="+imgSpot+"&div="+div+"&page="+window.location, timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { dojo.byId(imgSpot).value = ""; return response; }, error : function(response, ioArgs) { dojo.byId(imgSpot).value = ""; return response; } }); window.location.reload(); } function showViewer(imgType,imgSpot,imgClass){ saveImgSpot=imgSpot; saveImgClass=imgClass; hideImgSpots(); dojo.query("#waitBox").style({"visibility":"visible"}); dojo.byId("helpBox").innerHTML=imageViewerMsg; if (imgType == "gif") { dojo.byId("imgViewer").innerHTML=gifViewer; } else if (imgType == "all") { dojo.byId("imgViewer").innerHTML=allViewer; } else if (imgType == "footer") { dojo.byId("imgViewer").innerHTML=footerViewer; } dojo.query("#imgViewer").style({"visibility":"visible"}); dojo.query("#waitBox").style({"visibility":"hidden"}); } function imgClickAction(img){ saveImage(img,"insertImage"); } function remove(img){ if ( adminMode != "On") { return; } var ok=confirm("Click OK to remove this image."); if (!ok) { return; } saveImgSpot=img; saveImage(img,"removeImage"); } function pageLayout(newCss){ dojo.byId("helpBox").innerHTML=pageLayoutMsg; dojo.query("#helpBox").style({"visibility":"visible"}); newCss=prompt("Page Layout","Enter a Page Layout, 1,2, or 3"); if (newCss==null){return} var x="123"; if (x.indexOf(newCss)!=-1){ newCss="pgLayout0"+newCss+".css"; dojo.query("#waitBox").style({"visibility":"visible"}); var d = dojo.xhrGet({ url: "/ajaxActions.do?method=pageLayout&page="+window.location+"&id=pageLayoutId&css="+newCss, handleAs: "text", timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { return response; }, error : function(response, ioArgs) { return response; } }); dojo.query("#waitBox").style({"visibility":"visible"}); window.location.reload(); } else{ alert("Invalid Selection. Please try again."); } } function editBtn(page,section){ dojo.byId("helpBox").innerHTML=editorTipsMsg; var editDiv="#" + section; dojo.query(".btn").style({"visibility":"hidden"}); dojo.query("#reload"+section).style({"visibility":"visible"}); dojo.query(editDiv).style({"border":"1px dashed black"}); var url="/ajaxActions.do?method=savePage&page="+page+"&div="+section; new dijit.Editor({height: "", plugins: [{name: 'save', url: url},'|','bold','italic','|','insertOrderedList','insertUnorderedList','insertHorizontalRule','|','indent','outdent','|','createLink', 'unlink', 'insertImage','dijit._editor.plugins.AlwaysShowToolbar']}, dojo.byId(section)); dojo.query("#btn" + section).orphan(); } // This is where we determine whether to show Admin button or Admin Help button. // It is invoked in each layout page's body element function showAdmin(){ // Admin Help button; only used on Admin pages if (dojo.byId("adminHelpButton") != null){ dojo.byId("adminHelpButton").innerHTML=""; } else { var d = dojo.xhrGet({ url: "/ajaxActions.do?method=pagesToAdmin", handleAs: "text", timeout : 5000, preventCache: true, sync: true, load : function(response, ioArgs) { pages = response; return response; }, error : function(response, ioArgs) { pages = ""; return response; } }); // Admin button; used on 'adminReady' (pagesToAdmin) pages and userPages var showAdminButton=(pages.indexOf(window.location.pathname)>-1?true:false); if (dojo.byId("adminButton") != null && showAdminButton) { // loadViewers(); -- new function to populate viewer only when needed dojo.byId("adminButton").innerHTML=""; dojo.query("adminButton").style({"visibility":"visible"}); } dojo.query("#waitBox").style({"visibility":"hidden"}); } } /* end of source */