isc.defineClass("ImageElement", "Canvas"); isc.ImageElement.addProperties({ zoomFactor: 1, showHiliteCanvas: false, hiliteCanvasProperties: null, imageElement: null, imageFrame: null, imagePath: null, publicationPath: null, isDynamic: false, dynamicFrameWidth: -1, dynamicFrameHeight: -1, // Override initWidget to populate the button content calculateImage : function () { //isc.logWarn("calculateImage"); var zoomFactor = this.zoomFactor; var imageElement = this.imageElement; var imageFrame = this.imageFrame; this.setLeft(Math.floor(imageFrame.rightX * zoomFactor)); this.setTop(Math.floor(imageFrame.rightY * zoomFactor)); var frameWidth = imageFrame.width * zoomFactor; var frameHeight = imageFrame.height * zoomFactor; this.setWidth(Math.floor(frameWidth)); this.setHeight(Math.floor(frameHeight)); if (this.showHiliteCanvas) { this.mouseOver = function () { this.hiliteCanvas.show(); }; } //isc.logWarn("calculateImage: imageFrame (width=" + frameWidth + ", height=" + frameWidth + ")"); //isc.logWarn("calculateImage: zoomFactor=" + zoomFactor); var imageEntry = imageElement.imageEntry; var imageBounds = imageElement.imageBounds; var imageFilename = ""; // TODO: Use path to dummy image file? var editType = imageElement.editType; var imageLeft = 0; var imageTop = 0; var imageWidth = this.width; var imageHeight = this.height; if (isc.isAn.Object(imageEntry)) { if(this.isDynamic){ //isc.logWarn("calculateImage: DYNAMIC"); imageWidth = this.dynamicFrameWidth; imageHeight = this.dynamicFrameHeight; } else if (isc.isAn.Object(imageBounds)) { //isc.logWarn("calculateImage: STATIC - imageBounds (x=" + imageBounds.x + ", y=" + imageBounds.y + ", width=" + imageBounds.width + ", height=" + imageBounds.height + ")"); imageLeft = imageBounds.x * zoomFactor, imageTop = imageBounds.y * zoomFactor, imageWidth = imageBounds.width * zoomFactor; imageHeight = imageBounds.height * zoomFactor; } else { imageWidth = imageWidth * zoomFactor; imageHeight = imageHeight * zoomFactor; //isc.logWarn("calculateImage: STATIC - imageFrame (width=" + imageWidth + ", height=" + imageHeight + ")"); } if ((editType == "CUT") || (editType == "CROP_AND_SCALE")) { imageFilename = this.publicationPath + imageElement.lowResCutImage; } else { imageFilename = this.imagePath + imageEntry.lowResImageFile.systemFilename; } } var img = isc.Img.create({ left: Math.floor(imageLeft), top: Math.floor(imageTop), width: Math.floor(imageWidth), height: Math.floor(imageHeight), imageType: ((editType == "PROPORTIONAL") ? "center" : "stretch"), imageWidth: Math.floor(imageWidth), imageHeight: Math.floor(imageHeight), src: imageFilename }); return img; }, initWidget : function () { var img = this.calculateImage(); // isc.logWarn("FRAME " + Math.floor(frameWidth) + "x" + Math.floor(frameHeight) + " IMAGE " + Math.floor(imageWidth) + "x" + Math.floor(imageHeight)); this.Super("initWidget", arguments); var defaultHiliteCanvasProperties = { width: this.getWidth(), height: this.getHeight(), backgroundColor: "#C1CAE5", visibility: "hidden", opacity: 50, zIndex: 2, prompt: ge.message("bild.bearbeiten"), hoverStyle: "toolTip" }; if (this.showHiliteCanvas) { defaultHiliteCanvasProperties.mouseOut = function () { this.parentElement.hiliteCanvas.hide(); } } var hiliteCanvasProperties = isc.addProperties({}, defaultHiliteCanvasProperties, this.hiliteCanvasProperties); this.hiliteCanvas = isc.Canvas.create(hiliteCanvasProperties); img.zIndex = 1; this.addChild(img); this.addChild(this.hiliteCanvas); } });