- Timestamp:
- 07/06/2008 04:38:37 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js
r8245 r8260 261 261 var dlc = ed.dom.getAttrib(DL, 'class'); 262 262 dlc = dlc.match(/align[^ "']+/i); 263 if ( ! dom.hasClass(el, dlc) )263 if ( dlc && ! dom.hasClass(el, dlc) ) 264 264 c += ' '+dlc; 265 265 266 266 tinymce.each(DL.childNodes, function(e) { 267 if ( e.nodeName == 'DD' ) {267 if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp_caption_dd') ) { 268 268 caption = e.innerHTML; 269 269 return; … … 378 378 }); 379 379 380 if ( ! f.link_href.value ) { 381 if ( A ) { 382 b = ed.selection.getBookmark(); 383 ed.dom.remove(A, 1); 384 ed.selection.moveToBookmark(b); 385 } 386 } else { 380 if ( f.link_href.value ) { 387 381 // Create new anchor elements 388 382 if ( A == null ) { 389 if ( ! f.link_href.value.match(/https?:\/\// ) )383 if ( ! f.link_href.value.match(/https?:\/\//i) ) 390 384 f.link_href.value = tinyMCEPopup.editor.documentBaseURI.toAbsolute(f.link_href.value); 391 385 … … 432 426 }); 433 427 434 if ( DIV ) 428 if ( DIV ) 435 429 ed.dom.setAttrib(DIV, 'class', div_cls); 436 430 … … 439 433 440 434 } else { 435 var lnk = '', pa; 441 436 if ( (id = f.img_classes.value.match( /wp-image-([0-9]{1,6})/ )) && id[1] ) 442 437 cap_id = 'attachment_'+id[1]; 443 438 444 if ( f.link_href.value ) html = ed.dom.getOuterHTML(ed.dom.getParent(el, 'a')); 445 else html = ed.dom.getOuterHTML(el); 439 if ( f.link_href.value && (lnk = ed.dom.getParent(el, 'a')) ) { 440 if ( lnk.childNodes.length == 1 ) 441 html = ed.dom.getOuterHTML(lnk); 442 else { 443 html = ed.dom.getOuterHTML(lnk); 444 html = html.match(/<a[^>]+>/i); 445 html = html+ed.dom.getOuterHTML(el)+'</a>'; 446 } 447 } else html = ed.dom.getOuterHTML(el); 446 448 447 449 html = '<dl id="'+cap_id+'" class="wp_caption '+t.align+'" style="width: '+cap_width+ … … 452 454 if ( P ) { 453 455 P.parentNode.insertBefore(cap, P); 454 ed.dom.remove(P); 456 if ( P.childNodes.length == 1 ) 457 ed.dom.remove(P); 458 else if ( lnk && lnk.childNodes.length == 1 ) 459 ed.dom.remove(lnk); 460 else ed.dom.remove(el); 461 } else if ( pa = ed.dom.getParent(el, 'TD,TH,LI') ) { 462 pa.appendChild(cap); 463 if ( lnk && lnk.childNodes.length == 1 ) 464 ed.dom.remove(lnk); 465 else ed.dom.remove(el); 455 466 } 456 467 } 457 468 458 tinyMCEPopup.execCommand("mceEndUndoLevel");459 ed.execCommand('mceRepaint');460 tinyMCEPopup.close();461 return;462 469 } else { 463 470 if ( DL && DIV ) { 464 if ( f.link_href.value ) html = ed.dom.getOuterHTML(ed.dom.getParent(el, 'a')); 471 var aa; 472 if ( f.link_href.value && (aa = ed.dom.getParent(el, 'a')) ) html = ed.dom.getOuterHTML(aa); 465 473 else html = ed.dom.getOuterHTML(el); 466 474 467 475 P = ed.dom.create('p', {}, html); 468 476 DIV.parentNode.insertBefore(P, DIV); … … 477 485 if ( P && P.style && P.style.textAlign == 'center' ) 478 486 ed.dom.setStyle(P, 'textAlign', ''); 487 } 488 489 if ( ! f.link_href.value && A ) { 490 b = ed.selection.getBookmark(); 491 ed.dom.remove(A, 1); 492 ed.selection.moveToBookmark(b); 479 493 } 480 494
Note: See TracChangeset
for help on using the changeset viewer.