Index: openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/InsertImage/insert_image.js =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/InsertImage/insert_image.js,v diff -u -r1.1 -r1.2 --- openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/InsertImage/insert_image.js 2 Feb 2007 21:04:47 -0000 1.1 +++ openacs-4/packages/acs-templating/www/resources/xinha-nightly/modules/InsertImage/insert_image.js 25 Feb 2007 19:06:07 -0000 1.2 @@ -1,159 +1,107 @@ - - /*--------------------------------------:noTabs=true:tabSize=2:indentSize=2:-- - -- Xinha (is not htmlArea) - http://xinha.gogo.co.nz/ - -- - -- Use of Xinha is granted by the terms of the htmlArea License (based on - -- BSD license) please read license.txt in this package for details. - -- - -- Xinha was originally based on work by Mihai Bazon which is: - -- Copyright (c) 2003-2004 dynarch.com. - -- Copyright (c) 2002-2003 interactivetools.com, inc. - -- This copyright notice MUST stay intact for use. - -- - -- This is the standard implementation of the Xinha.prototype._insertImage method, - -- which provides the functionality to insert an image in the editor. - -- - -- he file is loaded as a special plugin by the Xinha Core when no alternative method (plugin) is loaded. - -- - -- - -- $HeadURL: http://svn.xinha.python-hosting.com/trunk/modules/InsertImage/insert_image.js $ - -- $LastChangedDate: 2007-01-24 03:26:04 +1300 (Wed, 24 Jan 2007) $ - -- $LastChangedRevision: 694 $ - -- $LastChangedBy: gogo $ - --------------------------------------------------------------------------*/ -InsertImage._pluginInfo = { - name : "InsertImage", - origin : "Xinha Core", - version : "$LastChangedRevision: 694 $".replace(/^[^:]*: (.*) \$$/, '$1'), - developer : "The Xinha Core Developer Team", - developer_url : "$HeadURL: http://svn.xinha.python-hosting.com/trunk/modules/InsertImage/insert_image.js $".replace(/^[^:]*: (.*) \$$/, '$1'), - sponsor : "", - sponsor_url : "", - license : "htmlArea" +InsertImage._pluginInfo={name:"InsertImage",origin:"Xinha Core",version:"$LastChangedRevision: 733 $".replace(/^[^:]*: (.*) \$$/,"$1"),developer:"The Xinha Core Developer Team",developer_url:"$HeadURL: http://svn.xinha.python-hosting.com/tags/0.92beta/modules/InsertImage/insert_image.js $".replace(/^[^:]*: (.*) \$$/,"$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){ +_4={f_base:_5,f_url:Xinha.is_ie?_3.stripBaseURL(_2.src):_2.getAttribute("src"),f_alt:_2.alt,f_border:_2.border,f_align:_2.align,f_vert:(_2.vspace!=-1?_2.vspace:""),f_horiz:(_2.hspace!=-1?_2.hspace:""),f_width:_2.width,f_height:_2.height}; +}else{ +_4={f_base:_5,f_url:""}; +} +Dialog(_3.config.URIs.insert_image,function(_7){ +if(!_7){ +return false; +} +var _8=_2; +if(!_8){ +if(Xinha.is_ie){ +var _9=_3.getSelection(); +var _a=_3.createRange(_9); +_3._doc.execCommand("insertimage",false,_7.f_url); +_8=_a.parentElement(); +if(_8.tagName.toLowerCase()!="img"){ +_8=_8.previousSibling; +} +}else{ +_8=document.createElement("img"); +_8.src=_7.f_url; +_3.insertNodeAtSelection(_8); +if(!_8.tagName){ +_8=_a.startContainer.firstChild; +} +} +}else{ +_8.src=_7.f_url; +} +for(var _b in _7){ +var _c=_7[_b]; +switch(_b){ +case "f_alt": +if(_c){ +_8.alt=_c; +}else{ +_8.removeAttribute("alt"); +} +break; +case "f_border": +if(_c){ +_8.border=parseInt(_c||"0"); +}else{ +_8.removeAttribute("border"); +} +break; +case "f_align": +if(_c){ +_8.align=_c; +}else{ +_8.removeAttribute("align"); +} +break; +case "f_vert": +if(_c){ +_8.vspace=parseInt(_c||"0"); +}else{ +_8.removeAttribute("vspace"); +} +break; +case "f_horiz": +if(_c){ +_8.hspace=parseInt(_c||"0"); +}else{ +_8.removeAttribute("hspace"); +} +break; +case "f_width": +if(_c){ +_8.width=parseInt(_c||"0"); +}else{ +_8.removeAttribute("width"); +} +break; +case "f_height": +if(_c){ +_8.height=parseInt(_c||"0"); +}else{ +_8.removeAttribute("height"); +} +break; +} +} +},_4); }; - -function InsertImage(editor) { -} - -// Called when the user clicks on "InsertImage" button. If an image is already -// there, it will just modify it's properties. -Xinha.prototype._insertImage = function(image) -{ - var editor = this; // for nested functions - var outparam = null; - if ( typeof image == "undefined" ) - { - image = this.getParentElement(); - if ( image && image.tagName.toLowerCase() != 'img' ) - { - image = null; - } - } - if ( image ) - { - outparam = - { - f_base : editor.config.baseHref, - f_url : Xinha.is_ie ? editor.stripBaseURL(image.src) : image.getAttribute("src"), - f_alt : image.alt, - f_border : image.border, - f_align : image.align, - f_vert : image.vspace, - f_horiz : image.hspace, - f_width : image.width, - f_height : image.height - }; - } - Dialog( - editor.config.URIs.insert_image, - function(param) - { - // user must have pressed Cancel - if ( !param ) - { - return false; - } - var img = 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) - img.align = 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; - } - } - }, - outparam); -}; +