function EditImage (id) { var id = id; var form = new Form (); this.onload = function () { // Vorgabewerte vom opener holen if (parent_name) { var opener = top.getOpener (false); if (opener && opener.edit[parent_name]) { this.setValue (opener.edit[parent_name].getAttributes ().image); } } this.preview (); } this.setValue = function (value) { if (typeof value == "object") { if (/(http|file):\/\/.*/.exec (value.src)) { // URL von externen Bildern anzeigen form.set ("url["+id+"]", value.src); setTimeout (function () {edit[id].oldValue.url = ""; hasChanged (id)}, 0); } form.set ("value["+id+"]", value.src); form.set ("border["+id+"]", value.border); form.set ("margin["+id+"]", value.margin); form.set ("align["+id+"]", value.align); } else { form.set ("value["+id+"]", value); } this.preview (); } this.getValue = function () { return { src : form.get ("value["+id+"]"), url : form.get ("url["+id+"]"), file : form.get ("file["+id+"]"), border : form.get ("border["+id+"]", 0), margin : form.get ("margin["+id+"]", ""), align : form.get ("align["+id+"]", "") }; } this.getUpdateValue = function () { var src = form.get ("value["+id+"]"); var width = settings[id].image_width || src.replace (/.*width=(\d+).*|.*/, "$1"); var height = settings[id].image_height || src.replace (/.*height=(\d+).*|.*/, "$1"); var image = ""; if (src.match (/type=video\/mp4/)) { image = ""; } else if (src) { image = ""; } return image; } this.getAttributes = function (src) { if (typeof src == "object") { src = src.src; } return { type : "image", src : src, border : form.get ("border["+id+"]", 0), width : src.replace (/.*width=(\d+).*|.*/, "$1"), height : src.replace (/.*height=(\d+).*|.*/, "$1"), margin : form.get ("margin["+id+"]", ""), align : form.get ("align["+id+"]", "") }; } this.save = function () { form = new Form (); if (form.get ("url["+id+"]") || form.get ("file["+id+"]")) { // Bild in extra Fenster hochladen var target = "upload_" + new Date ().getTime (); try { var win = window.open ("", target, "width=200, height=100, status=no, toolbar=no, location=no, scrollbars=no"); } catch (e) {d (e)}; var node = win.document.createElement ("span"); node.innerHTML = "
Uploading...
"; win.document.body.insertBefore (node, win.document.body.firstChild); var form = document.getElementById ("form["+id+"]"); form.target = target; form.submit (); form.reset (); edit[id].oldValue = this.getValue (); return true; } else if (parent_name) { updateOpener (id, this.getValue ()); return true; } return false; } this.focus = function () { document.getElementById ("url["+id+"]").focus (); } /***********************************************************************/ this.changeValue = function (isUrl) { if (isUrl) { if (form.get ("file["+id+"]")) { var url = form.get ("url["+id+"]"); if (url != this.oldValue.url) { document.getElementById ("form["+id+"]").reset (); form.set ("url["+id+"]", url); } } } else { form.set ("url["+id+"]", ""); } hasChanged (id); } this.preview = function () { var preview = document.getElementById ("preview["+id+"]"); var src = form.get ("value["+id+"]"); var width = src.replace (/.*width=(\d+).*|.*/, "$1"); var height = src.replace (/.*height=(\d+).*|.*/, "$1"); var image = ""; if (src.match (/type=video\/mp4/)) { image = "
"; } else if (src) { image = "
"; } preview.innerHTML = image; } }