/* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version * 1.1 (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS IS" basis, * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License * for the specific language governing rights and limitations under the * License. * * The Original Code is Mozilla Communicator client code, released * March 31, 1998. * * The Initial Developer of the Original Code is * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1999-2000 * the Initial Developer. All Rights Reserved. * * Contributor(s): * Dan Haddix (dan6992@hotmail.com) * Brian King (briano9@yahoo.com) * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), * in which case the provisions of the GPL or the LGPL are applicable instead * of those above. If you wish to allow use of your version of this file only * under the terms of either the GPL or the LGPL, and not to allow others to * use your version of this file under the terms of the MPL, indicate your * decision by deleting the provisions above and replace them with the notice * and other provisions required by the GPL or the LGPL. If you do not delete * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ var tHide = false; var highCont = false; var imageElement = null; var mapName = ''; var imageMap = null; var imageEl; var srcInputValue = null; var marquee = null; var frameDoc = null; var buttonArray = []; function Startup(){ if (!GetCurrentEditor()) { window.close(); return; } initDialog(); } function doHelpButton() { openHelp("imagemap_properties"); } function initDialog(){ //Get image element from parent imageElement = window.arguments[0]; if (!imageElement) //If not an image close window { window.close(); return; } //Get image map from parent imageMap = window.arguments[1]; if (!imageMap) //If no image map close window window.close(); //find parent inputs var srcInput = window.opener.document.getElementById("srcInput"); var widthInput = window.opener.document.getElementById("widthInput"); var heightInput = window.opener.document.getElementById("heightInput"); //check for relative url if (!((srcInput.value.indexOf("http://") != -1) || (srcInput.value.indexOf("file://") != -1))){ if (IsUrlAboutBlank(GetDocumentUrl())){ alert(GetString("SaveToUseRelativeUrl")); window.close(); //TODO: add option to save document now } else{ var edDoc = GetDocumentUrl(); var imgDoc = srcInput.value; imgDoc = imgDoc.split("../"); var len = imgDoc.length; for (var i=0; i (String(GetCurrentEditor().document.location.protocol).length+2)) edDoc = edDoc.substring(0, edDoc.lastIndexOf("/")); } imgDoc = edDoc+"/"+imgDoc[imgDoc.length-1]; srcInputValue = imgDoc; } } else{ srcInputValue = srcInput.value; } //Set iframe pointer frameDoc = window.frames[0].document; //Fill button array buttonArray[0] = document.getElementById("pointerButton"); buttonArray[1] = document.getElementById("rectButton"); buttonArray[2] = document.getElementById("cirButton"); buttonArray[3] = document.getElementById("polyButton"); //Create marquee var marquee = frameDoc.createElement("div"); marquee.setAttribute("id", "marquee"); frameDoc.body.appendChild(marquee); //Create background div var bgDiv = frameDoc.createElement("div"); if ( bgDiv ) { bgDiv.setAttribute("id", "bgDiv"); frameDoc.body.appendChild(bgDiv); } //Place Image var newImg = frameDoc.createElement("img"); if ( newImg ) { newImg.setAttribute("src", srcInputValue); if (parseInt(widthInput.value) > 0) newImg.setAttribute("width", widthInput.value); if (parseInt(heightInput.value) > 0) newImg.setAttribute("height", heightInput.value); newImg.setAttribute("id", "mainImg"); imageEl = frameDoc.getElementById("bgDiv").appendChild(newImg); imageEl.addEventListener("error", imgError, false); } //Resize background DIV to fit image fixBgDiv(); //Recreate Image Map if it exists recreateMap(); } function imgError(){ alert(GetString("ImapError")+" " + srcInputValue+"."+GetString("ImapCheck")); } function fixBgDiv(){ imageEl = frameDoc.getElementById("mainImg"); if (imageEl.offsetWidth != 0){ frameDoc.getElementById("bgDiv").style.width = imageEl.offsetWidth; frameDoc.getElementById("bgDiv").style.height = imageEl.offsetHeight; } else setTimeout("fixBgDiv()", 100); } function hideToolbar(){ // Check to see if toolbar is already hidden if (tHide){ // If it is show it document.getElementById("toolbar").collapsed = false; // Set the menu items text back to "Hide Toolbar" document.getElementById("view_hidetoolbar").setAttribute("label", GetString("HideToolbar")); tHide = false } else{ // If not hide it document.getElementById("toolbar").collapsed = true; //Set the menu items text to "Show Toolbar" document.getElementById("view_hidetoolbar").setAttribute("label", GetString("ShowToolbar")); tHide = true; } } function highContrast(){ if (highCont == true){ frameDoc.getElementById("bgDiv").style.background = "url('chrome://editor/skin/images/Map_checker.gif')"; frameDoc.getElementById("bgDiv").style.backgroundColor = "white"; imageEl.style.setProperty("opacity", "1.0", true); document.getElementById("Map:Contrast").setAttribute("checked", "false"); document.getElementById("Map:Contrast").setAttribute("toggled", "false"); highCont = false; } else{ frameDoc.getElementById("bgDiv").style.background = "url('')"; frameDoc.getElementById("bgDiv").style.backgroundColor = "#D2D2D2"; imageEl.style.setProperty("opacity", ".3", true); document.getElementById("Map:Contrast").setAttribute("checked", "true"); document.getElementById("Map:Contrast").setAttribute("toggled", "true"); highCont = true; } } function recreateMap(){ var areaCollection = imageMap.childNodes; var areaColLen = areaCollection.length; for(var j=0; j= 1){ for(i=0; i