1 /* This compressed file is part of Xinha. For uncompressed sources, forum, and bug reports, go to xinha.org */
2 /* This file is part of version 0.96beta2 released Fri, 20 Mar 2009 11:01:14 +0100 */
3 function ExtendedFileManager(e
){this.editor
=e
;var a
=e
.config
;var f
=a
.toolbar
;var b
=this;if(a
.ExtendedFileManager
.use_linker
){a
.registerButton({id
:"linkfile",tooltip
:Xinha
._lc("Insert File Link","ExtendedFileManager"),image
:Xinha
.getPluginDir("ExtendedFileManager")+"/img/ed_linkfile.gif",textMode
:false,action:function(g
){g
._linkFile()}});a
.addToolbarElement("linkfile","createlink",1)}var d
=e
.config
.ExtendedFileManager
.backend
+"__function=manager";if(a
.ExtendedFileManager
.backend_config
!=null){d
+="&backend_config="+encodeURIComponent(a
.ExtendedFileManager
.backend_config
);d
+="&backend_config_hash="+encodeURIComponent(a
.ExtendedFileManager
.backend_config_hash
);d
+="&backend_config_secret_key_location="+encodeURIComponent(a
.ExtendedFileManager
.backend_config_secret_key_location
)}if(a
.ExtendedFileManager
.backend_data
!=null){for(var c
in a
.ExtendedFileManager
.backend_data
){d
+="&"+c
+"="+encodeURIComponent(a
.ExtendedFileManager
.backend_data
[c
])}}a
.ExtendedFileManager
.manager
=d
}ExtendedFileManager
._pluginInfo
={name
:"ExtendedFileManager",version
:"1.4",developer
:"Afru, Krzysztof Kotowicz, Raimund Meyer",developer_url
:"http://xinha.org",license
:"htmlArea"};Xinha
.Config
.prototype.ExtendedFileManager
={use_linker
:true,backend
:Xinha
.getPluginDir("ExtendedFileManager")+"/backend.php?__plugin=ExtendedFileManager&",backend_data
:null,backend_config
:null,backend_config_hash
:null,backend_config_secret_key_location
:"Xinha:ImageManager"};if(typeof ImageManager
=="undefined"){Xinha
.prototype._insertImage=function(b
){var a
=this;var c
={editor
:this,param
:null};if(typeof b
=="undefined"){b
=this.getParentElement();if(b
&&!/^img$/i.test(b
.tagName
)){b
=null}}if(b
){c
.param
={f_url
:Xinha
.is_ie
?b
.src
:b
.getAttribute("src"),f_alt
:b
.alt
,f_title
:b
.title
,f_border
:b
.style
.borderWidth
?b
.style
.borderWidth
:b
.border
,f_align
:b
.align
,f_width
:b
.width
,f_height
:b
.height
,f_padding
:b
.style
.padding
,f_margin
:b
.style
.margin
,f_backgroundColor
:b
.style
.backgroundColor
,f_borderColor
:b
.style
.borderColor
,baseHref
:a
.config
.baseHref
};c
.param
.f_border
=shortSize(c
.param
.f_border
);c
.param
.f_padding
=shortSize(c
.param
.f_padding
);c
.param
.f_margin
=shortSize(c
.param
.f_margin
);c
.param
.f_backgroundColor
=convertToHex(c
.param
.f_backgroundColor
);c
.param
.f_borderColor
=convertToHex(c
.param
.f_borderColor
)}Dialog(this.config
.ExtendedFileManager
.manager
,function(h
){if(!h
){return false}var e
=b
;if(!e
){if(!h
.f_url
){return false}if(Xinha
.is_ie
){var g
=a
.getSelection();var d
=a
.createRange(g
);a
._doc
.execCommand("insertimage",false,h
.f_url
);e
=d
.parentElement();if(e
.tagName
.toLowerCase()!="img"){e
=e
.previousSibling
}}else{e
=document
.createElement("img");e
.src
=h
.f_url
;a
.insertNodeAtSelection(e
)}}else{if(!h
.f_url
){e
.parentNode
.removeChild(e
);a
.updateToolbar();return false}else{e
.src
=h
.f_url
}}e
.alt
=e
.alt
?e
.alt
:"";for(field
in h
){var f
=h
[field
];switch(field
){case"f_alt":e
.alt
=f
;break;case"f_title":e
.title
=f
;break;case"f_border":if(f
){e
.style
.borderWidth
=/[^0-9]/.test(f
)?f
:(f
!="")?(parseInt(f
)+"px"):"";if(e
.style
.borderWidth
&&!e
.style
.borderStyle
){e
.style
.borderStyle
="solid"}else{if(!e
.style
.borderWidth
){e
.style
.border
=""}}}break;case"f_borderColor":e
.style
.borderColor
=f
;break;case"f_backgroundColor":e
.style
.backgroundColor
=f
;break;case"f_align":e
.align
=f
;break;case"f_width":if(parseInt(f
)>0){e
.width
=parseInt(f
)}break;case"f_height":if(parseInt(f
)>0){e
.height
=parseInt(f
)}break;case"f_padding":e
.style
.padding
=/[^0-9]/.test(f
)?f
:(f
!="")?(parseInt(f
)+"px"):"";break;case"f_margin":e
.style
.margin
=/[^0-9]/.test(f
)?f
:(f
!="")?(parseInt(f
)+"px"):"";break}}},c
)}}Xinha
.prototype._linkFile=function(c
){var b
=this;var f
={editor
:this,param
:null};if(typeof c
=="undefined"){c
=this.getParentElement();if(c
){if(/^img$/i.test(c
.tagName
)){c
=c
.parentNode
}if(!/^a$/i.test(c
.tagName
)){c
=null}}}if(!c
){var e
=b
.getSelection();var a
=b
.createRange(e
);var d
=0;if(Xinha
.is_ie
){if(e
.type
=="Control"){d
=a
.length
}else{d
=a
.compareEndPoints("StartToEnd",a
)}}else{d
=a
.compareBoundaryPoints(a
.START_TO_END
,a
)}if(d
==0){alert(Xinha
._lc("You must select some text before making a new link.","ExtendedFileManager"));return}f
.param
={f_href
:"",f_title
:"",f_target
:"",f_usetarget
:b
.config
.makeLinkShowsTarget
,baseHref
:b
.config
.baseHref
}}else{f
.param
={f_href
:Xinha
.is_ie
?c
.href
:c
.getAttribute("href"),f_title
:c
.title
,f_target
:c
.target
,f_usetarget
:b
.config
.makeLinkShowsTarget
,baseHref
:b
.config
.baseHref
}}Dialog(this.config
.ExtendedFileManager
.manager
+"&mode=link",function(l
){if(!l
){return false}var g
=c
;if(!g
){try{b
._doc
.execCommand("createlink",false,l
.f_href
);g
=b
.getParentElement();var j
=b
.getSelection();var i
=b
.createRange(j
);if(!Xinha
.is_ie
){g
=i
.startContainer
;if(!/^a$/i.test(g
.tagName
)){g
=g
.nextSibling
;if(g
==null){g
=i
.startContainer
.parentNode
}}}}catch(k
){}}else{var h
=l
.f_href
.trim();b
.selectNodeContents(g
);if(h
==""){b
._doc
.execCommand("unlink",false,null);b
.updateToolbar();return false}else{g
.href
=h
}}if(!(g
&&/^a$/i.test(g
.tagName
))){return false}g
.target
=l
.f_target
.trim();g
.title
=l
.f_title
.trim();b
.selectNodeContents(g
);b
.updateToolbar()},f
)};function shortSize(a
){if(/ /.test(a)){var d=a.split(" ");var c=true;for(var b=1;b<d.length;b++){if(d[0]!=d[b]){c=false;break}}if(c){a=d[0]}}return a}function convertToHex(c){if(typeof c=="string"&&/, /.test.color){c=c.replace(/, /,",")}if(typeof c=="string"&&/ /.test
.color
){var a
=c
.split(" ");var b
="";for(var d
=0;d
<a
.length
;d
++){b
+=Xinha
._colorToRgb(a
[d
]);if(d
+1<a
.length
){b
+=" "}}return b
}return Xinha
._colorToRgb(c
)};