move over changes from Netscape branch to trunk; string changes for localization; submitted by briano9@yahoo.com and dan6992@yahoo.com

This commit is contained in:
brade%netscape.com 2000-10-06 12:01:23 +00:00
parent 71961279ca
commit a9b514f8f5
2 changed files with 57 additions and 35 deletions

View File

@ -19,7 +19,7 @@
* *
* Contributor(s): * Contributor(s):
* Dan Haddix (dan6992@hotmail.com) * Dan Haddix (dan6992@hotmail.com)
* Brian King * Brian King (briano9@yahoo.com)
*/ */
var tHide = false; var tHide = false;
@ -29,6 +29,9 @@ var mapName = '';
var imageMap = null; var imageMap = null;
var imageEl; var imageEl;
var srcInputValue = null; var srcInputValue = null;
var marquee = null;
var frameDoc = null;
var buttonArray = new Array();
function Startup(){ function Startup(){
if (!InitEditorShell()) if (!InitEditorShell())
@ -56,7 +59,7 @@ function initDialog(){
//check for relative url //check for relative url
if (!((srcInput.value.indexOf("http://") != -1) || (srcInput.value.indexOf("file://") != -1))){ if (!((srcInput.value.indexOf("http://") != -1) || (srcInput.value.indexOf("file://") != -1))){
if (editorShell.editorDocument.location == "about:blank"){ if (editorShell.editorDocument.location == "about:blank"){
alert("Relative URLs can only be used on documents which have been saved"); alert(GetString("ImapRelative"));
window.close(); window.close();
//TODO: add option to save document now //TODO: add option to save document now
} }
@ -119,7 +122,7 @@ function initDialog(){
} }
function imgError(){ function imgError(){
alert("Error loading image "+srcInputValue+"\nPlease check the URL and try again"); alert(GetString("ImapError")+" " + srcInputValue+"."+GetString("ImapCheck"));
} }
function fixBgDiv(){ function fixBgDiv(){
@ -138,23 +141,23 @@ function hideToolbar(){
// If it is show it // If it is show it
document.getElementById("toolbar").setAttribute("collapsed", "false"); document.getElementById("toolbar").setAttribute("collapsed", "false");
// Set the menu items text back to "Hide Toolbar" // Set the menu items text back to "Hide Toolbar"
document.getElementById("view_hidetoolbar").setAttribute("value", "Hide Toolbar"); document.getElementById("view_hidetoolbar").setAttribute("value", GetString("HideToolbar"));
tHide = false tHide = false
} }
else{ else{
// If not hide it // If not hide it
document.getElementById("toolbar").setAttribute("collapsed", "true"); document.getElementById("toolbar").setAttribute("collapsed", "true");
//Set the menu items text to "Show Toolbar" //Set the menu items text to "Show Toolbar"
document.getElementById("view_hidetoolbar").setAttribute("value", "Show Toolbar"); document.getElementById("view_hidetoolbar").setAttribute("value", GetString("ShowToolbar"));
tHide = true; tHide = true;
} }
} }
function highContrast(){ function highContrast(){
if (highCont){ if (highCont == true){
frameDoc.getElementById("bgDiv").style.background = "url('chrome://editor/skin/images/Map_checker.gif')"; frameDoc.getElementById("bgDiv").style.background = "url('chrome://editor/skin/images/Map_checker.gif')";
frameDoc.getElementById("bgDiv").style.backgroundColor = "white"; frameDoc.getElementById("bgDiv").style.backgroundColor = "white";
imageEl.style.opacity = "1.0"; imageEl.style.setProperty("-moz-opacity", "1.0", true);
document.getElementById("Map:Contrast").setAttribute("checked", "false"); document.getElementById("Map:Contrast").setAttribute("checked", "false");
document.getElementById("Map:Contrast").setAttribute("toggled", "false"); document.getElementById("Map:Contrast").setAttribute("toggled", "false");
highCont = false; highCont = false;
@ -162,7 +165,7 @@ function highContrast(){
else{ else{
frameDoc.getElementById("bgDiv").style.background = "url('')"; frameDoc.getElementById("bgDiv").style.background = "url('')";
frameDoc.getElementById("bgDiv").style.backgroundColor = "#D2D2D2"; frameDoc.getElementById("bgDiv").style.backgroundColor = "#D2D2D2";
imageEl.style.opacity = ".3"; imageEl.style.setProperty("-moz-opacity", ".3", true);
document.getElementById("Map:Contrast").setAttribute("checked", "true"); document.getElementById("Map:Contrast").setAttribute("checked", "true");
document.getElementById("Map:Contrast").setAttribute("toggled", "true"); document.getElementById("Map:Contrast").setAttribute("toggled", "true");
highCont = true; highCont = true;
@ -331,4 +334,12 @@ function deleteAreas(){
area = imageMap.firstChild; area = imageMap.firstChild;
} }
return true; return true;
} }
// This is contained in editor.js (should be in a common js file
// I did not want to include the whole file so I copied the function here
// It retrieves strings from editor string bundle
function GetString(id)
{
return editorShell.GetString(id);
}

View File

@ -41,9 +41,6 @@ var polyCount = 1;
var pointCount = 1; var pointCount = 1;
var xlock = false; var xlock = false;
var ylock = false; var ylock = false;
var marquee = null;
var frameDoc = null;
var buttonArray = new Array();
var resize = false; var resize = false;
var currentZoom = 1; var currentZoom = 1;
var clipBoard = new Array(); var clipBoard = new Array();
@ -169,11 +166,14 @@ function Poly(coords, href, target, alt, construct){
newPoly.setAttribute("id", "poly"+polyCount++); newPoly.setAttribute("id", "poly"+polyCount++);
newPoly.setAttribute("name", "hotspot"); newPoly.setAttribute("name", "hotspot");
currentPoly = selectElement(frameDoc.body.appendChild(newPoly)); currentPoly = selectElement(frameDoc.body.appendChild(newPoly));
if (currentZoom > 1){
currentPoly.style.width = imageEl.offsetWidth+"px";
currentPoly.style.height = imageEl.offsetHeight+"px";
}
if (!coords){ if (!coords){
addPoint(null, startX, startY, true); addPoint(null, startX, startY, true);
//currentPoly.onclick = addPoint; //currentPoly.onclick = addPoint;
currentPoly.style.cursor = "crosshair"; currentPoly.style.cursor = "crosshair";
currentPoly.addEventListener("click", addPoint, false);
} }
else{ else{
var coordArray = coords.split(','); var coordArray = coords.split(',');
@ -195,8 +195,8 @@ function Poly(coords, href, target, alt, construct){
function addPoint(event, pointX, pointY, start){ function addPoint(event, pointX, pointY, start){
if (event){ if (event){
dump('addPoint Called with event\n'); dump('addPoint Called with event\n');
pointX = event.clientX; pointX = event.clientX+window.frames[0].pageXOffset;
pointY = event.clientY; pointY = event.clientY+window.frames[0].pageYOffset;
event.preventBubble(); event.preventBubble();
if (event.detail == 2){ if (event.detail == 2){
polyFinish(); polyFinish();
@ -214,7 +214,7 @@ function addPoint(event, pointX, pointY, start){
newPoint.setAttribute("class", "pointStart"); newPoint.setAttribute("class", "pointStart");
newPoint.style.cursor = "pointer"; newPoint.style.cursor = "pointer";
//newPoint.onclick = polyFinish; //newPoint.onclick = polyFinish;
newPoint.addEventListener("click", polyFinish, false); //newPoint.addEventListener("click", polyFinish, false);
} }
currentPoly.appendChild(newPoint); currentPoly.appendChild(newPoint);
} }
@ -258,8 +258,8 @@ function polyFinish(event, construct){
//currentPoly.childNodes[0].onclick = null; //currentPoly.childNodes[0].onclick = null;
//currentPoly.onclick = null; //currentPoly.onclick = null;
currentPoly.style.cursor = "auto"; currentPoly.style.cursor = "auto";
currentPoly.childNodes[0].removeEventListener("click", polyFinish, false); //currentPoly.childNodes[0].removeEventListener("click", polyFinish, false);
currentPoly.removeEventListener("click", addPoint, false); //currentPoly.removeEventListener("click", addPoint, true);
if (!construct) if (!construct)
hotSpotProps(currentPoly); hotSpotProps(currentPoly);
} }
@ -416,8 +416,8 @@ function upMouse(event){
function moveMouse(event){ function moveMouse(event){
if (downTool){ if (downTool){
endX = event.clientX; endX = event.clientX+window.frames[0].pageXOffset;
endY = event.clientY; endY = event.clientY+window.frames[0].pageYOffset;
if (dragActive){ if (dragActive){
if (currentElement.length > 0){ if (currentElement.length > 0){
@ -517,8 +517,8 @@ function downMouse(event){
dump(event.target.parentNode.id+"\n"); dump(event.target.parentNode.id+"\n");
if (event.button == 1){ if (event.button == 1){
if (currentTool != "poly"){ if (currentTool != "poly"){
startX = event.clientX; startX = event.clientX+window.frames[0].pageXOffset;
startY = event.clientY; startY = event.clientY+window.frames[0].pageYOffset;
downTool = true; downTool = true;
if (currentTool == "pointer"){ if (currentTool == "pointer"){
if (event.target.getAttribute("name") == "hotspot"){ if (event.target.getAttribute("name") == "hotspot"){
@ -551,14 +551,14 @@ function downMouse(event){
if (isSelected){ if (isSelected){
var len = currentElement.length; var len = currentElement.length;
for(i=0; i<len; i++){ for(i=0; i<len; i++){
currentElement[i].startX = parseInt(event.clientX)-parseInt(currentElement[i].style.left); currentElement[i].startX = parseInt(event.clientX+window.frames[0].pageXOffset)-parseInt(currentElement[i].style.left);
currentElement[i].startY = parseInt(event.clientY)-parseInt(currentElement[i].style.top); currentElement[i].startY = parseInt(event.clientY+window.frames[0].pageYOffset)-parseInt(currentElement[i].style.top);
} }
} }
else{ else{
curObj = selectElement(el); curObj = selectElement(el);
curObj.startX = parseInt(event.clientX)-parseInt(curObj.style.left); curObj.startX = parseInt(event.clientX+window.frames[0].pageXOffset)-parseInt(curObj.style.left);
curObj.startY = parseInt(event.clientY)-parseInt(curObj.style.top); curObj.startY = parseInt(event.clientY+window.frames[0].pageYOffset)-parseInt(curObj.style.top);
} }
dragObject = true; dragObject = true;
} }
@ -616,8 +616,8 @@ function downMouse(event){
dump("down on a point\n"); dump("down on a point\n");
selectElement(event.target.parentNode); selectElement(event.target.parentNode);
currentPoint = event.target; currentPoint = event.target;
currentPoint.startX = parseInt(event.clientX)-(parseInt(currentPoint.style.left)+parseInt(currentPoint.parentNode.style.left)); currentPoint.startX = parseInt(event.clientX+window.frames[0].pageXOffset)-(parseInt(currentPoint.style.left)+parseInt(currentPoint.parentNode.style.left));
currentPoint.startY = parseInt(event.clientY)-(parseInt(currentPoint.style.top)+parseInt(currentPoint.parentNode.style.top)); currentPoint.startY = parseInt(event.clientY+window.frames[0].pageYOffset)-(parseInt(currentPoint.style.top)+parseInt(currentPoint.parentNode.style.top));
currentPoly = currentPoint.parentNode; currentPoly = currentPoint.parentNode;
} }
else{ else{
@ -633,13 +633,24 @@ function clickMouse(event){
if (event.button == 1){ if (event.button == 1){
dump("body clicked\n"); dump("body clicked\n");
//alert(frameDoc.+'\n'); //alert(frameDoc.+'\n');
startX = event.clientX; startX = event.clientX+window.frames[0].pageXOffset;
startY = event.clientY; startY = event.clientY+window.frames[0].pageYOffset;
if (currentTool == "poly"){ if (currentTool == "poly"){
//dump(event.detail+"\n");
if (event.target != currentPoly){ if (event.target != currentPoly){
//else if (event.target.getAttribute("class").indexOf("point") == -1) if (currentPoly != null){
Poly(); if (event.target == currentPoly.childNodes[0]){
polyFinish();
}
else if (event.detail == 2){
polyFinish();
}
}
else{
Poly();
}
}
else{
addPoint(event);
} }
} }
} }
@ -748,13 +759,13 @@ function zoom(direction, ratio){
dump(imgEl.getAttribute("width")+'\n'); dump(imgEl.getAttribute("width")+'\n');
if (ratio > currentZoom){ if (ratio > currentZoom){
imgEl.setAttribute("width", (parseInt(imgEl.offsetWidth)*(ratio/currentZoom))); imgEl.setAttribute("width", (parseInt(imgEl.offsetWidth)*(ratio/currentZoom)));
//imgEl.setAttribute("height", (parseInt(imgEl.offsetHeight)*(ratio/currentZoom)); imgEl.setAttribute("height", (parseInt(imgEl.offsetHeight)*(ratio/currentZoom)));
bgDiv.style.width = imgEl.offsetWidth; bgDiv.style.width = imgEl.offsetWidth;
bgDiv.style.height = imgEl.offsetHeight; bgDiv.style.height = imgEl.offsetHeight;
} }
else{ else{
imgEl.setAttribute("width", (parseInt(imgEl.offsetWidth)/(currentZoom/ratio))); imgEl.setAttribute("width", (parseInt(imgEl.offsetWidth)/(currentZoom/ratio)));
//imgEl.setAttribute("height", (parseInt(imgEl.offsetHeight)/(currentZoom/ratio))); imgEl.setAttribute("height", (parseInt(imgEl.offsetHeight)/(currentZoom/ratio)));
bgDiv.style.width = imgEl.offsetWidth; bgDiv.style.width = imgEl.offsetWidth;
bgDiv.style.height = imgEl.offsetHeight; bgDiv.style.height = imgEl.offsetHeight;
} }