Changeset 733
- Timestamp:
- 02/13/07 12:54:39 (6 years ago)
- Location:
- trunk/modules/InsertImage
- Files:
-
- 2 modified
-
insert_image.html (modified) (5 diffs)
-
insert_image.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/InsertImage/insert_image.html
r694 r733 16 16 } 17 17 18 function resolveRelativeUrl(base, url){ 19 if(url.match(/^([^:]+\:)?\//)){ 20 return url; 21 } 22 else{ 23 var b = base.split("/"); 24 if(b[b.length - 1] == ""){ 25 b.pop(); 26 } 27 var p = url.split("/"); 28 if(p[0] == "."){ 29 p.shift(); 30 } 31 while(p[0] == ".."){ 32 b.pop(); 33 p.shift(); 34 } 35 return b.join("/") + "/" + p.join("/"); 36 } 37 } 38 18 39 function Init() { 19 40 __dlg_translate('Xinha'); … … 23 44 document.getElementById("f_align").selectedIndex = 5; 24 45 var param = window.dialogArguments; 25 if (param) { 26 document.getElementById("f_url").value = param["f_url"]; 27 document.getElementById("f_alt").value = param["f_alt"]; 28 document.getElementById("f_border").value = param["f_border"]; 29 document.getElementById("f_align").value = param["f_align"]; 30 document.getElementById("f_vert").value = param["f_vert"]; 31 document.getElementById("f_horiz").value = param["f_horiz"]; 32 window.ipreview.location.replace(param.f_url); 46 if (param["f_base"]) { 47 document.getElementById("f_base").value = param["f_base"]; 48 } 49 document.getElementById("f_url").value = param["f_url"] ? param["f_url"] : ""; 50 document.getElementById("f_alt").value = param["f_alt"] ? param["f_alt"] : ""; 51 document.getElementById("f_border").value = (typeof param["f_border"]!="undefined") ? param["f_border"] : ""; 52 document.getElementById("f_align").value = param["f_align"] ? param["f_align"] : ""; 53 document.getElementById("f_vert").value = (typeof param["f_vert"]!="undefined") ? param["f_vert"] : ""; 54 document.getElementById("f_horiz").value = (typeof param["f_horiz"]!="undefined") ? param["f_horiz"] : ""; 55 if (param["f_url"]) { 56 window.ipreview.location.replace(resolveRelativeUrl(param.f_base, param.f_url)); 33 57 } 34 58 document.getElementById("f_url").focus(); … … 68 92 var f_url = document.getElementById("f_url"); 69 93 var url = f_url.value; 94 var base = document.getElementById("f_base").value; 70 95 if (!url) { 71 96 alert(i18n("You must enter the URL")); … … 73 98 return false; 74 99 } 75 window.ipreview.location.replace( url);100 window.ipreview.location.replace(resolveRelativeUrl(base, url)); 76 101 return false; 77 102 } … … 85 110 <!--- new stuff ---> 86 111 <form action="" method="get"> 112 <input type="hidden" name="base" id="f_base"/> 87 113 <table border="0" width="100%" style="padding: 0px; margin: 0px"> 88 114 <tbody> -
trunk/modules/InsertImage/insert_image.js
r694 r733 41 41 { 42 42 var editor = this; // for nested functions 43 var outparam = null;43 var outparam; 44 44 if ( typeof image == "undefined" ) 45 45 { … … 50 50 } 51 51 } 52 53 var base; 54 if ( typeof editor.config.baseHref != 'undefined' && editor.config.baseHref !== null ) { 55 base = editor.config.baseHref; 56 } 57 else { 58 var bdir = window.location.toString().split("/"); 59 bdir.pop(); 60 base = bdir.join("/"); 61 } 62 52 63 if ( image ) 53 64 { 54 65 outparam = 55 66 { 56 f_base : editor.config.baseHref,67 f_base : base, 57 68 f_url : Xinha.is_ie ? editor.stripBaseURL(image.src) : image.getAttribute("src"), 58 69 f_alt : image.alt, 59 70 f_border : image.border, 60 71 f_align : image.align, 61 f_vert : image.vspace,62 f_horiz : image.hspace,72 f_vert : (image.vspace!=-1 ? image.vspace : ""), //FireFox reports -1 when this attr has no value. 73 f_horiz : (image.hspace!=-1 ? image.hspace : ""), //FireFox reports -1 when this attr has no value. 63 74 f_width : image.width, 64 75 f_height : image.height 65 76 }; 66 77 } 78 else{ 79 outparam = 80 { 81 f_base : base, 82 f_url : "" 83 }; 84 } 85 67 86 Dialog( 68 87 editor.config.URIs.insert_image, … … 113 132 case "f_alt": 114 133 if (value) 115 img.alt = value 134 img.alt = value; 116 135 else 117 136 img.removeAttribute("alt"); … … 119 138 case "f_border": 120 139 if (value) 121 img.border = parseInt(value || "0") 140 img.border = parseInt(value || "0"); 122 141 else 123 142 img.removeAttribute("border"); … … 125 144 case "f_align": 126 145 if (value) 127 img.align = value 146 img.align = value; 128 147 else 129 148 img.removeAttribute("align"); … … 131 150 case "f_vert": 132 151 if (value) 133 img.vspace = parseInt(value || "0") 152 img.vspace = parseInt(value || "0"); 134 153 else 135 154 img.removeAttribute("vspace"); … … 137 156 case "f_horiz": 138 157 if (value) 139 img.hspace = parseInt(value || "0") 158 img.hspace = parseInt(value || "0"); 140 159 else 141 160 img.removeAttribute("hspace");
