Archived
(Experimental) Replace htmlarea with XINHA. Thanks to abdussamad!
This commit is contained in:
+173
@@ -0,0 +1,173 @@
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<title>Insert Image</title>
|
||||
|
||||
<script type="text/javascript" src="../../popups/popup.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="../../popups/popup.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
Xinha = window.opener.Xinha;
|
||||
function i18n(str) {
|
||||
return (Xinha._lc(str, 'Xinha'));
|
||||
}
|
||||
|
||||
function Init() {
|
||||
__dlg_translate('Xinha');
|
||||
__dlg_init(null,{width:410,height:400});
|
||||
// Make sure the translated string appears in the drop down. (for gecko)
|
||||
document.getElementById("f_align").selectedIndex = 1;
|
||||
document.getElementById("f_align").selectedIndex = 5;
|
||||
var param = window.dialogArguments;
|
||||
if (param["f_base"]) {
|
||||
document.getElementById("f_base").value = param["f_base"];
|
||||
}
|
||||
document.getElementById("f_url").value = param["f_url"] ? param["f_url"] : "";
|
||||
document.getElementById("f_alt").value = param["f_alt"] ? param["f_alt"] : "";
|
||||
document.getElementById("f_border").value = (typeof param["f_border"]!="undefined") ? param["f_border"] : "";
|
||||
document.getElementById("f_align").value = param["f_align"] ? param["f_align"] : "";
|
||||
document.getElementById("f_vert").value = (typeof param["f_vert"]!="undefined") ? param["f_vert"] : "";
|
||||
document.getElementById("f_horiz").value = (typeof param["f_horiz"]!="undefined") ? param["f_horiz"] : "";
|
||||
if (param["f_url"]) {
|
||||
window.ipreview.location.replace(Xinha._resolveRelativeUrl(param.f_base, param.f_url));
|
||||
}
|
||||
document.getElementById("f_url").focus();
|
||||
}
|
||||
|
||||
function onOK() {
|
||||
var required = {
|
||||
"f_url": i18n("You must enter the URL")
|
||||
};
|
||||
for (var i in required) {
|
||||
var el = document.getElementById(i);
|
||||
if (!el.value) {
|
||||
alert(required[i]);
|
||||
el.focus();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// pass data back to the calling window
|
||||
var fields = ["f_url", "f_alt", "f_align", "f_border",
|
||||
"f_horiz", "f_vert"];
|
||||
var param = new Object();
|
||||
for (var i in fields) {
|
||||
var id = fields[i];
|
||||
var el = document.getElementById(id);
|
||||
param[id] = el.value;
|
||||
}
|
||||
__dlg_close(param);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onCancel() {
|
||||
__dlg_close(null);
|
||||
return false;
|
||||
}
|
||||
|
||||
function onPreview() {
|
||||
var f_url = document.getElementById("f_url");
|
||||
var url = f_url.value;
|
||||
var base = document.getElementById("f_base").value;
|
||||
if (!url) {
|
||||
alert(i18n("You must enter the URL"));
|
||||
f_url.focus();
|
||||
return false;
|
||||
}
|
||||
window.ipreview.location.replace(Xinha._resolveRelativeUrl(base, url));
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
</head>
|
||||
|
||||
<body class="dialog" onload="Init()">
|
||||
|
||||
<div class="title">Insert Image</div>
|
||||
<!--- new stuff --->
|
||||
<form action="" method="get">
|
||||
<input type="hidden" name="base" id="f_base"/>
|
||||
<table border="0" width="100%" style="padding: 0px; margin: 0px">
|
||||
<tbody>
|
||||
|
||||
<tr>
|
||||
<td style="width: 7em; text-align: right">Image URL:</td>
|
||||
<td><input type="text" name="url" id="f_url" style="width:75%"
|
||||
title="Enter the image URL here" />
|
||||
<button name="preview" onclick="return onPreview();"
|
||||
title="Preview the image in a new window">Preview</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width: 7em; text-align: right">Alternate text:</td>
|
||||
<td><input type="text" name="alt" id="f_alt" style="width:100%"
|
||||
title="For browsers that don't support images" /></td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<fieldset style="float: left; margin-left: 5px;">
|
||||
<legend>Layout</legend>
|
||||
|
||||
<div class="space"></div>
|
||||
|
||||
<div class="fl">Alignment:</div>
|
||||
<select size="1" name="align" id="f_align"
|
||||
title="Positioning of this image">
|
||||
<option value="" >Not set</option>
|
||||
<option value="left" >Left</option>
|
||||
<option value="right" >Right</option>
|
||||
<option value="texttop" >Texttop</option>
|
||||
<option value="absmiddle" >Absmiddle</option>
|
||||
<option value="baseline" selected="selected" >Baseline</option>
|
||||
<option value="absbottom" >Absbottom</option>
|
||||
<option value="bottom" >Bottom</option>
|
||||
<option value="middle" >Middle</option>
|
||||
<option value="top" >Top</option>
|
||||
</select>
|
||||
|
||||
<br />
|
||||
|
||||
<div class="fl">Border thickness:</div>
|
||||
<input type="text" name="border" id="f_border" size="5"
|
||||
title="Leave empty for no border" />
|
||||
|
||||
<div class="space"></div>
|
||||
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Spacing</legend>
|
||||
|
||||
<div class="space"></div>
|
||||
|
||||
<div class="fr">Horizontal:</div>
|
||||
<input type="text" name="horiz" id="f_horiz" size="5"
|
||||
title="Horizontal padding" />
|
||||
|
||||
<br />
|
||||
|
||||
<div class="fr">Vertical:</div>
|
||||
<input type="text" name="vert" id="f_vert" size="5"
|
||||
title="Vertical padding" />
|
||||
|
||||
<div class="space"></div>
|
||||
|
||||
</fieldset>
|
||||
<div class="space" style="clear:all"></div>
|
||||
<div>
|
||||
Image Preview:<br />
|
||||
<iframe name="ipreview" id="ipreview" frameborder="0" style="border : 1px solid gray;"
|
||||
height="200" width="100%" src="../../popups/blank.html"></iframe>
|
||||
</div>
|
||||
<div id="buttons">
|
||||
<button type="submit" name="ok" onclick="return onOK();">OK</button>
|
||||
<button type="button" name="cancel" onclick="return onCancel();">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,119 @@
|
||||
/* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
|
||||
/* This file is part of version 0.95 released Mon, 12 May 2008 17:33:15 +0200 */
|
||||
/* The URL of the most recent version of this file is http://svn.xinha.webfactional.com/trunk/modules/InsertImage/insert_image.js */
|
||||
InsertImage._pluginInfo={name:"InsertImage",origin:"Xinha Core",version:"$LastChangedRevision:992 $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),developer:"The Xinha Core Developer Team",developer_url:"$HeadURL:http://svn.xinha.webfactional.com/trunk/modules/InsertImage/insert_image.js $".replace(/^[^:]*:\s*(.*)\s*\$$/,"$1"),sponsor:"",sponsor_url:"",license:"htmlArea"};
|
||||
function InsertImage(_1){
|
||||
}
|
||||
Xinha.prototype._insertImage=function(_2){
|
||||
var _3=this;
|
||||
var _4;
|
||||
if(typeof _2=="undefined"){
|
||||
_2=this.getParentElement();
|
||||
if(_2&&_2.tagName.toLowerCase()!="img"){
|
||||
_2=null;
|
||||
}
|
||||
}
|
||||
var _5;
|
||||
if(typeof _3.config.baseHref!="undefined"&&_3.config.baseHref!==null){
|
||||
_5=_3.config.baseHref;
|
||||
}else{
|
||||
var _6=window.location.toString().split("/");
|
||||
_6.pop();
|
||||
_5=_6.join("/");
|
||||
}
|
||||
if(_2){
|
||||
function getSpecifiedAttribute(_7,_8){
|
||||
var a=_7.attributes;
|
||||
for(var i=0;i<a.length;i++){
|
||||
if(a[i].nodeName==_8&&a[i].specified){
|
||||
return a[i].value;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
_4={f_base:_5,f_url:this.stripBaseURL(_2.getAttribute("src",2)),f_alt:_2.alt,f_border:_2.border,f_align:_2.align,f_vert:getSpecifiedAttribute(_2,"vspace"),f_horiz:getSpecifiedAttribute(_2,"hspace"),f_width:_2.width,f_height:_2.height};
|
||||
}else{
|
||||
_4={f_base:_5,f_url:""};
|
||||
}
|
||||
Dialog(_3.config.URIs.insert_image,function(_b){
|
||||
if(!_b){
|
||||
return false;
|
||||
}
|
||||
var _c=_2;
|
||||
if(!_c){
|
||||
if(Xinha.is_ie){
|
||||
var _d=_3.getSelection();
|
||||
var _e=_3.createRange(_d);
|
||||
_3._doc.execCommand("insertimage",false,_b.f_url);
|
||||
_c=_e.parentElement();
|
||||
if(_c.tagName.toLowerCase()!="img"){
|
||||
_c=_c.previousSibling;
|
||||
}
|
||||
}else{
|
||||
_c=document.createElement("img");
|
||||
_c.src=_b.f_url;
|
||||
_3.insertNodeAtSelection(_c);
|
||||
if(!_c.tagName){
|
||||
_c=_e.startContainer.firstChild;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
_c.src=_b.f_url;
|
||||
}
|
||||
for(var _f in _b){
|
||||
var _10=_b[_f];
|
||||
switch(_f){
|
||||
case "f_alt":
|
||||
if(_10){
|
||||
_c.alt=_10;
|
||||
}else{
|
||||
_c.removeAttribute("alt");
|
||||
}
|
||||
break;
|
||||
case "f_border":
|
||||
if(_10){
|
||||
_c.border=parseInt(_10||"0");
|
||||
}else{
|
||||
_c.removeAttribute("border");
|
||||
}
|
||||
break;
|
||||
case "f_align":
|
||||
if(_10){
|
||||
_c.align=_10;
|
||||
}else{
|
||||
_c.removeAttribute("align");
|
||||
}
|
||||
break;
|
||||
case "f_vert":
|
||||
if(_10!=""){
|
||||
_c.vspace=parseInt(_10||"0");
|
||||
}else{
|
||||
_c.removeAttribute("vspace");
|
||||
}
|
||||
break;
|
||||
case "f_horiz":
|
||||
if(_10!=""){
|
||||
_c.hspace=parseInt(_10||"0");
|
||||
}else{
|
||||
_c.removeAttribute("hspace");
|
||||
}
|
||||
break;
|
||||
case "f_width":
|
||||
if(_10){
|
||||
_c.width=parseInt(_10||"0");
|
||||
}else{
|
||||
_c.removeAttribute("width");
|
||||
}
|
||||
break;
|
||||
case "f_height":
|
||||
if(_10){
|
||||
_c.height=parseInt(_10||"0");
|
||||
}else{
|
||||
_c.removeAttribute("height");
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
},_4);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user