Author: raintang
Date: 2009-10-20 10:18:07 +0200 (Tue, 20 Oct 2009)
New Revision: 39231

Modified:
   
CMSContainer/trunk/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/my-htmlarea.js
Log:
CMSC-1561 Rich text: title does not show up in the insert-image popup in IE;

Modified: 
CMSContainer/trunk/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/my-htmlarea.js
===================================================================
--- 
CMSContainer/trunk/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/my-htmlarea.js
    2009-10-20 07:11:53 UTC (rev 39230)
+++ 
CMSContainer/trunk/CMSContainer/cmsc/richtext/src/webapp/mmbase/edit/wizard/xinha/my-htmlarea.js
    2009-10-20 08:18:07 UTC (rev 39231)
@@ -286,20 +286,35 @@
        var range = this._createRange(sel);
        if(Xinha.is_ie) sel_value = range.text;
        if (link){
+            var title="";
+            if(/^a$/i.test(link.tagName) && 
/^img$/i.test(link.firstChild.tagName)) {
+                title = link.firstChild.getAttribute("title"); 
+            }else title = Xinha.is_ie ? link.innerText : link.textContent;
                outparam = {
                        f_href   : Xinha.is_ie ? editor.stripBaseURL(link.href) 
: link.getAttribute("href"),
                 f_destination : link.destination ,
-                       f_title   : link.name?link.name: sel_value,
+                f_title   : title,
                                f_tooltip : link.title,
                        f_target : link.target,
                        f_usetarget : editor.config.makeLinkShowsTarget
                };
        }
        else{
+            var html = this.getSelectedHTML();
+            var titleNoLink="";
+            if(Xinha.is_ie){
+                re = /title=([\s\S]*?)(\ssrc|\sborder|\swidth|\sheight|\")/i;
+                var matches = re.exec(html);
+                if(matches != null) {
+                    titleNoLink = matches[1];
+                }
+                if(titleNoLink=="") titleNoLink = sel_value;
+            }
+            else titleNoLink = sel_value;
                outparam = {
                        f_href   : "Click \"New Url\" to enter URL",
                 f_destination : null,
-                       f_title   : sel_value?sel_value:'',
+                       f_title   : titleNoLink,
                                f_tooltip : '',
                        f_target : '',
                        f_usetarget : editor.config.makeLinkShowsTarget
@@ -317,13 +332,33 @@
                         var range = editor._createRange(sel);
                         if(editor._selectionEmpty(sel))
                         {
-                              editor.insertHTML("<a href='" + param.f_href + 
"' title='" + param.f_tooltip + "' name='"+param.f_title+"' destination='"+ 
param.f_destination + "'>" + param.f_title+ "</a>");
+                              editor.insertHTML("<a href='" + param.f_href + 
"' title='" + param.f_tooltip + " 'destination='"+ param.f_destination + "'>" + 
param.f_title+ "</a>");
                         }
                         else{
-                              if ( !Xinha.is_ie )
-                              {
-                                    a.href = param.f_href.trim();
-                              }
+                               if (!Xinha.is_ie) {
+                                if (a == null || !(/^a$/i.test(a.tagName))) {
+                                    a = range.startContainer;
+                                    if ( ! ( /^a$/i.test(a.tagName) ) ) {
+                                          a = a.nextSibling;
+                                          if ( a === null ) {
+                                                a = 
range.startContainer.parentNode; 
+                                          }
+                                    }
+                                }
+                            }
+                            else{//for ie
+                                while (a) {
+                                   if (/^a$/i.test(a.tagName)) break; //Search 
for the enclosing A tag, if found: continue and use it.
+                                   if (/^body$/i.test(a.tagName)) { a = null; 
break } //Stop searching when Body-tag is found, don't go too deep.
+                                   if (/^img$/i.test(a.tagName)){a = 
a.parentNode;} //for image node, its parentNode is <a>
+                                }
+                            }
+                               //deal with link and image node
+                            if(/^a$/i.test(a.tagName)){
+                                if(!(/^img$/i.test(a.firstChild.tagName))){
+                                    a.innerHTML = param.f_title.trim();
+                                }
+                            }
                         }
                        } catch(ex) {}
                }
@@ -339,10 +374,15 @@
                        }
                        else
                        {
-                         a.href = href;
-                  a.name = param.f_title.trim();
+                               if(/^a$/i.test(a.tagName)){
+                                       a.href = href;
+                    if(!(/^img$/i.test(a.firstChild.tagName))){
+                       a.innerHTML = param.f_title.trim();
+                    }
+                               }
                        }
                }
+        a.href = param.f_href.trim();
                a.target = param.f_target.trim();
                a.title = param.f_tooltip.trim();
 

_______________________________________________
Cvs mailing list
Cvs@lists.mmbase.org
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to