OpenCCM.prototype.showImageDialog = function(image) { if (!this.dialogs["images"]) this.prepareImageDialog(); var editor = this.editor; if ( typeof image == "undefined" ) { image = editor.getParentElement(); if ( image && image.tagName.toLowerCase() != 'img' ) { image = null; } } if ( image ) { function getSpecifiedAttribute(element,attribute) { var a = element.attributes; for (var i=0;i 0) ? newHeightForPreview : 0) + "px"; // no-go beyond 0 this.getElementById("ipreview").style.width = this.width - 2 + 'px'; // and the width } */ this.imageDialogReady = true; }; // and finally ... take some action OpenCCM.prototype.imageApply = function() { var param = this.dialogs["images"].hide(); if (!param.f_url) { return; } var editor = this.editor; var img = this.image; if ( !img ) { if ( Xinha.is_ie ) { var sel = editor.getSelection(); var range = editor.createRange(sel); editor._doc.execCommand("insertimage", false, param.f_url); img = range.parentElement(); // wonder if this works... if ( img.tagName.toLowerCase() != "img" ) { img = img.previousSibling; } } else { img = document.createElement('img'); img.src = param.f_url; editor.insertNodeAtSelection(img); if ( !img.tagName ) { // if the cursor is at the beginning of the document img = range.startContainer.firstChild; } } } else { img.src = param.f_url; } for ( var field in param ) { var value = param[field]; switch (field) { case "f_alt": if (value) img.alt = value; else img.removeAttribute("alt"); break; case "f_border": if (value) img.border = parseInt(value || "0"); else img.removeAttribute("border"); break; case "f_align": if (value.value) img.align = value.value; else img.removeAttribute("align"); break; case "f_vert": if (value != "") img.vspace = parseInt(value || "0"); else img.removeAttribute("vspace"); break; case "f_horiz": if (value != "") img.hspace = parseInt(value || "0"); else img.removeAttribute("hspace"); break; case "f_width": if (value) img.width = parseInt(value || "0"); else img.removeAttribute("width"); break; case "f_height": if (value) img.height = parseInt(value || "0"); else img.removeAttribute("height"); break; } } };