Changeset 19982
- Timestamp:
- 02/24/2012 01:58:18 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/css/wp-admin.dev.css
r19937 r19982 3874 3874 } 3875 3875 3876 .media-item .edit-caption-controls { 3877 margin: 5px 0; 3878 width: 460px; 3879 } 3880 3881 .media-item .edit-caption-controls label { 3882 margin: 5px 0; 3883 display: block; 3884 } 3885 3886 .media-item .edit-caption-controls label span { 3887 width: 100px; 3888 float: left; 3889 line-height: 22px; 3890 } 3891 3892 .media-item .edit-caption-controls input[type="text"] { 3893 width: 335px; 3894 } 3895 3896 .media-item .caption-insert-link-buttons { 3897 text-align: right; 3898 margin: 5px 12px; 3899 } 3900 3901 .media-item .caption-insert-link-wrap { 3902 padding: 5px 0 5px 12px; 3903 background-color: #f8f8f8; 3904 border: 1px solid #eee; 3905 -webkit-border-radius: 3px; 3906 border-radius: 3px; 3907 } 3908 3909 .media-item .post_excerpt textarea { 3910 height: 60px; 3911 } 3912 3876 3913 /*------------------------------------------------------------------------------ 3877 3914 14.1 - Media Library -
trunk/wp-admin/includes/media.php
r19871 r19982 150 150 $width = $matches[1]; 151 151 152 $caption = str_replace( array( '>', '<', '"', "'" ), 153 array( '>', '<', '"', ''' ), 154 $caption 155 ); 152 $caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption ); 153 $caption = str_replace( '"', '"', $caption ); 156 154 157 155 $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); … … 160 158 161 159 $shcode = '[caption id="' . $id . '" align="align' . $align 162 . '" width="' . $width . '" caption="' . addslashes($caption). '"]' . $html . '[/caption]';160 . '" width="' . $width . '" caption="' . $caption . '"]' . $html . '[/caption]'; 163 161 164 162 return apply_filters( 'image_add_caption_shortcode', $shcode, $html ); 165 163 } 166 164 add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); 165 166 // Private, preg_replace callback used in image_add_caption() 167 function _cleanup_image_add_caption($str) { 168 if ( isset($str[0]) ) 169 return str_replace( '"', "'", $str[0] ); 170 171 return ''; 172 } 167 173 168 174 /** … … 777 783 return " 778 784 <input type='text' class='text urlfield' name='attachments[$post->ID][url]' value='" . esc_attr($url) . "' /><br /> 779 <button type='button' class='button urlnone' title=''>" . __('None') . "</button>780 <button type='button' class='button urlfile' title='" . esc_attr($file) . "'>" . __('File URL') . "</button>781 <button type='button' class='button urlpost' title='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button>785 <button type='button' class='button urlnone' data-link-url=''>" . __('None') . "</button> 786 <button type='button' class='button urlfile' data-link-url='" . esc_attr($file) . "'>" . __('File URL') . "</button> 787 <button type='button' class='button urlpost' data-link-url='" . esc_attr($link) . "'>" . __('Attachment Post URL') . "</button> 782 788 "; 789 } 790 791 function wp_caption_input_textarea($edit_post) { 792 // post data is already escaped 793 $name = "attachments[{$edit_post->ID}][post_excerpt]"; 794 795 return ' 796 <textarea class="code" name="' . $name . '" id="' . $name . '">' . $edit_post->post_excerpt . '</textarea> 797 <div class="edit-caption-controls hide-if-no-js"> 798 <input type="button" class="button caption-insert-link" value="' . esc_attr__('Insert Link') . '" /> 799 <div class="caption-insert-link-wrap hidden"> 800 <label><span>' . __('Link URL') . '</span> 801 <input type="text" value="" class="caption-insert-link-url" /></label> 802 <label><span>' . __('Linked text') . '</span> 803 <input type="text" value="" class="caption-insert-link-text" /></label> 804 <div class="caption-insert-link-buttons"> 805 <input type="button" class="button caption-cancel" value="' . esc_attr__('Cancel') . '" /> 806 <input type="button" class="button-primary caption-save" value="' . esc_attr__('Insert') . '" /> 807 <br class="clear" /> 808 </div></div></div> 809 '; 783 810 } 784 811 … … 925 952 'image_alt' => array(), 926 953 'post_excerpt' => array( 927 'label' => __('Caption'), 928 'value' => $edit_post->post_excerpt 954 'label' => __('Default Caption'), 955 'input' => 'html', 956 'html' => wp_caption_input_textarea($edit_post) 929 957 ), 930 958 'post_content' => array( … … 1203 1231 $item .= $field[ $field['input'] ]; 1204 1232 elseif ( $field['input'] == 'textarea' ) { 1205 if ( user_can_richedit() ) { // textarea_escaped when user_can_richedit() = false 1206 $field['value'] = esc_textarea( $field['value'] ); 1233 if ( 'post_content' == $id && user_can_richedit() ) { 1234 // sanitize_post() skips the post_content when user_can_richedit 1235 $field['value'] = htmlspecialchars( $field['value'], ENT_QUOTES ); 1207 1236 } 1237 // post_excerpt is already escaped by sanitize_post() in get_attachment_fields_to_edit() 1208 1238 $item .= "<textarea id='$name' name='$name' $aria_required>" . $field['value'] . '</textarea>'; 1209 1239 } else { … … 1514 1544 1515 1545 <?php if ( ! apply_filters( 'disable_captions', '' ) ) { ?> 1516 if ( f.caption.value ) 1517 caption = f.caption.value.replace(/'/g, ''').replace(/"/g, '"').replace(/</g, '<').replace(/>/g, '>'); 1546 if ( f.caption.value ) { 1547 caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){ 1548 return a.replace(/"/g, "'"); 1549 }); 1550 1551 caption = caption.replace(/"/g, '"'); 1552 } 1518 1553 <?php } ?> 1519 1554 -
trunk/wp-admin/js/media-upload.dev.js
r18837 r19982 26 26 27 27 if ( h.indexOf('[caption') === 0 ) { 28 if ( ed. plugins.wpeditimage)29 h = ed. plugins.wpeditimage._do_shcode(h);28 if ( ed.wpSetImgCaption ) 29 h = ed.wpSetImgCaption(h); 30 30 } else if ( h.indexOf('[gallery') === 0 ) { 31 31 if ( ed.plugins.wpgallery ) -
trunk/wp-includes/formatting.php
r19933 r19982 1189 1189 * Acts on text which is about to be edited. 1190 1190 * 1191 * Unless $richedit is set, it is simply a holder for the 'format_to_edit'1192 * filter. If $richedit is set true htmlspecialchars(), through esc_textarea(),1193 * will be run on the content, converting special characters to HTML entities.1191 * The $content is run through esc_textarea(), which uses htmlspecialchars() 1192 * to convert special characters to HTML entities. If $richedit is set to true, 1193 * it is simply a holder for the 'format_to_edit' filter. 1194 1194 * 1195 1195 * @since 0.71 1196 1196 * 1197 1197 * @param string $content The text about to be edited. 1198 * @param bool $richedit Whether the $content should pass through htmlspecialchars(). Default false.1198 * @param bool $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed). 1199 1199 * @return string The text after the filter (and possibly htmlspecialchars()) has been run. 1200 1200 */ -
trunk/wp-includes/js/plupload/handlers.dev.js
r19367 r19982 339 339 340 340 jQuery(document).ready(function($){ 341 var insert_link, bookmark; 342 341 343 $('.media-upload-form').bind('click.uploader', function(e) { 342 var target = $(e.target), tr, c; 343 344 if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment 344 var target = $(e.target), tr, c, el, textarea, sel, text, startPos, endPos; 345 346 if ( target.hasClass('caption-insert-link') ) { 347 el = target.siblings('div.caption-insert-link-wrap'), textarea = target.parent().siblings('textarea').get(0); 348 349 if ( document.selection ) { 350 textarea.focus(); 351 sel = document.selection.createRange(); 352 bookmark = sel.getBookmark(); 353 354 if ( sel.text ) 355 el.find('.caption-insert-link-text').val(sel.text); 356 357 } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { 358 text = textarea.value; 359 startPos = textarea.selectionStart; 360 endPos = textarea.selectionEnd; 361 362 if ( startPos != endPos ) 363 el.find('.caption-insert-link-text').val( text.substring(startPos, endPos) ); 364 } 365 366 target.hide(); 367 el.show(); 368 el.find('.caption-insert-link-url').focus(); 369 } else if ( target.hasClass('caption-cancel') || target.hasClass('caption-save') ) { 370 el = target.closest('div.caption-insert-link-wrap'); 371 372 if ( target.hasClass('caption-save') ) 373 insert_link( el.closest('.edit-caption-controls').siblings('textarea'), el ); 374 375 el.hide(); 376 el.siblings('.caption-insert-link').show(); 377 } else if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment 345 378 tr = target.closest('tr'); 346 379 … … 356 389 if ( c && c[1] ) { 357 390 setUserSetting('urlbutton', c[1]); 358 target.siblings('.urlfield').val( target. attr('title') );391 target.siblings('.urlfield').val( target.data('link-url') ); 359 392 } 360 393 } else if ( target.is('a.dismiss') ) { … … 365 398 $('#media-items, p.submit, span.big-file-warning').css('display', 'none'); 366 399 switchUploader(0); 367 return false;400 e.preventDefault(); 368 401 } else if ( target.is('.upload-html-bypass a') ) { // switch uploader to multi-file 369 402 $('#media-items, p.submit, span.big-file-warning').css('display', ''); 370 403 switchUploader(1); 371 return false;404 e.preventDefault(); 372 405 } else if ( target.is('a.describe-toggle-on') ) { // Show 373 406 target.parent().addClass('open'); … … 387 420 } 388 421 }); 389 return false;422 e.preventDefault(); 390 423 } else if ( target.is('a.describe-toggle-off') ) { // Hide 391 424 target.siblings('.slidetoggle').fadeOut(250, function(){ 392 425 target.parent().removeClass('open'); 393 426 }); 394 return false;427 e.preventDefault(); 395 428 } 396 429 }); 430 431 insert_link = function(textarea, parent) { 432 var sel, content, startPos, endPos, scrollTop, text, 433 url = parent.find('.caption-insert-link-url'), link_text = parent.find('.caption-insert-link-text'); 434 435 if ( !url.length || !link_text.length ) 436 return; 437 438 textarea = textarea.get(0); 439 content = "<a href='"+url.val()+"'>"+link_text.val()+"</a>"; 440 441 if ( document.selection ) { 442 textarea.focus(); 443 sel = document.selection.createRange(); 444 445 if ( bookmark ) { 446 sel.moveToBookmark( bookmark ); 447 bookmark = ''; 448 } 449 450 sel.text = content; 451 textarea.focus(); 452 } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { 453 text = textarea.value; 454 startPos = textarea.selectionStart; 455 endPos = textarea.selectionEnd; 456 scrollTop = textarea.scrollTop; 457 458 textarea.value = text.substring(0, startPos) + content + text.substring(endPos, text.length); 459 460 textarea.focus(); 461 textarea.selectionStart = startPos + content.length; 462 textarea.selectionEnd = startPos + content.length; 463 textarea.scrollTop = scrollTop; 464 } 465 466 url.val(''); 467 link_text.val(''); 468 }; 397 469 398 470 // init and set the uploader -
trunk/wp-includes/js/tinymce/langs/wp-langs-en.js
r19263 r19982 13 13 clipboard_no_support:"Currently not supported by your browser, use keyboard shortcuts instead.", 14 14 popup_blocked:"Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool.", 15 invalid_data:"E rror: Invalid values entered, these are marked in red.",15 invalid_data:"ERROR: Invalid values entered, these are marked in red.", 16 16 invalid_data_number:"{#field} must be a number", 17 17 invalid_data_min:"{#field} must be a number greater than {#min}", … … 241 241 dt:"Definition term ", 242 242 dd:"Definition description", 243 bold_desc:"Bold (Ctrl / Alt + Shift+ B)",244 italic_desc:"Italic (Ctrl / Alt + Shift+ I)",243 bold_desc:"Bold (Ctrl + B)", 244 italic_desc:"Italic (Ctrl + I)", 245 245 underline_desc:"Underline", 246 246 striketrough_desc:"Strikethrough (Alt + Shift + D)", … … 267 267 backcolor_desc:"Select background color", 268 268 charmap_desc:"Insert custom character", 269 charmap_usage:"Use left and right arrows to navigate.", 269 270 visualaid_desc:"Toggle guidelines/invisible elements", 270 271 anchor_desc:"Insert/edit anchor", … … 499 500 img_title:"Title", 500 501 caption:"Caption", 502 insert_link:"Insert link", 503 linked_text:"Linked text", 501 504 alt:"Alternate Text" 502 505 }); -
trunk/wp-includes/js/tinymce/langs/wp-langs.php
r19420 r19982 276 276 backcolor_desc:"' . mce_escape( __('Select background color') ) . '", 277 277 charmap_desc:"' . mce_escape( __('Insert custom character') ) . '", 278 charmap_usage:"' . mce_escape( __('Use left and right arrows to navigate.') ) . '", 278 279 visualaid_desc:"' . mce_escape( __('Toggle guidelines/invisible elements') ) . '", 279 280 anchor_desc:"' . mce_escape( __('Insert/edit anchor') ) . '", … … 508 509 img_title:"' . mce_escape( __('Title') ) . '", 509 510 caption:"' . mce_escape( __('Caption') ) . '", 511 insert_link:"' . mce_escape( __('Insert link') ) . '", 512 linked_text:"' . mce_escape( __('Linked text') ) . '", 510 513 alt:"' . mce_escape( __('Alternate Text') ) . '" 511 514 }); -
trunk/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css
r19712 r19982 357 357 color: #CFCFCF; 358 358 } 359 360 #img-edit .edit-caption-controls { 361 margin: 5px 0; 362 } 363 364 #img-edit .edit-caption-controls label { 365 margin: 5px 0; 366 display: block; 367 } 368 369 #img-edit .edit-caption-controls label span { 370 width: 100px; 371 float: left; 372 line-height: 22px; 373 } 374 375 #img-edit .edit-caption-controls input[type="text"] { 376 width: 335px; 377 } 378 379 #img-edit .caption-insert-link-buttons { 380 text-align: right; 381 margin: 5px 12px; 382 } 383 384 #img-edit .caption-insert-link-wrap { 385 padding: 5px 0 5px 12px; 386 background-color: #f8f8f8; 387 border: 1px solid #eee; 388 -webkit-border-radius: 3px; 389 border-radius: 3px; 390 } 391 392 #img-edit #img_cap_text { 393 font: normal 12px/18px monospace; 394 } 395 396 .hidden { 397 display: none; 398 } 399 400 /* RTL */ 401 body#media-upload.rtl ul#sidemenu { 402 left: auto; 403 right: 0; 404 } 405 406 .rtl #basic .align .field label { 407 display: block; 408 float: right; 409 padding: 0 24px 0 0; 410 margin: 5px 3px 5px 5px; 411 } 412 413 .rtl .align .field input { 414 display: block; 415 float: right; 416 margin: 5px 15px 5px 0; 417 } 418 419 .rtl tr.image-size label { 420 margin: 0; 421 } 422 423 .rtl tr.image-size input { 424 margin: 3px 15px 0 5px; 425 } 426 427 .rtl .image-align-none-label, 428 .rtl .image-align-left-label, 429 .rtl .image-align-center-label, 430 .rtl .image-align-right-label { 431 background-position: center right; 432 } 433 434 #media-upload.rtl .describe th.label { 435 text-align: right; 436 } 437 438 .rtl .show-align, 439 .rtl .alignright, 440 .rtl #img_size { 441 float: left; 442 } 443 444 .rtl tr.image-size label, 445 .rtl tr.image-size input, 446 .rtl #img_dim label, 447 .rtl #img_dim input, 448 .rtl #img_prop label, 449 .rtl #img_prop input, 450 .rtl #img_size_div, 451 .rtl .alignleft { 452 float: right; 453 } 454 455 .rtl #img_dim label, 456 .rtl #img_prop label { 457 margin: 5px 0pt; 458 } 459 460 .rtl #img_dim input, 461 .rtl #img_prop input { 462 margin: 0 5px 0 10px; 463 } 464 465 .rtl #img_size_title { 466 text-align: left; 467 } -
trunk/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html
r12660 r19982 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">1 <!DOCTYPE html> 2 2 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"> 3 3 <head> … … 5 5 <title></title> 6 6 7 <script type="text/javascript" src="js/editimage.js?ver=327"></script> 8 <script type="text/javascript" src="../../utils/form_utils.js?ver=3223"></script> 9 10 <link rel="stylesheet" href="css/editimage.css?ver=327" type="text/css" media="all" /> 11 7 <link rel="stylesheet" href="css/editimage.css?ver=348" type="text/css" media="all" /> 8 <script type="text/javascript" src="js/editimage.js?ver=348"></script> 9 <script type="text/javascript" src="../../utils/form_utils.js?ver=348"></script> 10 <base target="_self" /> 11 </head> 12 13 <body id="media-upload" style="display:none;"> 12 14 <script type="text/javascript"> 13 15 if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') ) 14 document. write('<link rel="stylesheet" href="css/editimage-rtl.css?ver=3223" type="text/css" media="all" />');16 document.body.className += ' rtl'; 15 17 </script> 16 <base target="_self" />17 </head>18 19 <body id="media-upload" style="display:none;">20 18 <div id="media-upload-header"> 21 19 <ul id="sidemenu"> … … 104 102 </th> 105 103 <td class="field"> 106 <input type="text" id="img_cap" name="img_cap" value="" size="60" /> 104 <textarea id="img_cap_text"></textarea> 105 106 <div class="edit-caption-controls"> 107 <input type="button" class="button caption-insert-link" value="{#wpeditimage.insert_link}" /> 108 109 <div class="caption-insert-link-wrap hidden"> 110 <label><span>{#advanced_dlg.link_url}</span> 111 <input type="text" value="" class="caption-insert-link-url" /></label> 112 113 <label><span>{#wpeditimage.linked_text}</span> 114 <input type="text" value="" class="caption-insert-link-text" /></label> 115 116 <div class="caption-insert-link-buttons"> 117 <input type="button" class="button caption-cancel" value="{#cancel}" /> 118 <input type="button" class="button-primary caption-save" value="{#insert}" /> 119 <br class="clear" /> 120 </div></div></div> 107 121 </td> 108 122 </tr> -
trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js
r19977 r19982 2 2 (function() { 3 3 tinymce.create('tinymce.plugins.wpEditImage', { 4 5 init : function(ed, url) { 4 url: '', 5 editor: {}, 6 7 init: function(ed, url) { 6 8 var t = this, mouse = {}; 7 9 8 10 t.url = url; 11 t.editor = ed; 9 12 t._createButtons(); 10 13 … … 29 32 30 33 ed.onInit.add(function(ed) { 31 tinymce.dom.Event.add(ed.getBody(), 'dragstart', function(e) { 32 if ( !tinymce.isGecko && e.target.nodeName == 'IMG' && ed.dom.getParent(e.target, 'dl.wp-caption') ) 33 return tinymce.dom.Event.cancel(e); 34 ed.dom.events.add(ed.getBody(), 'dragstart', function(e) { 35 var parent; 36 37 if ( e.target.nodeName == 'IMG' && ( parent = ed.dom.getParent(e.target, 'div.mceTemp') ) ) { 38 ed.selection.select(parent); 39 } 34 40 }); 35 41 }); … … 45 51 if ( 'IMG' == n.nodeName ) { 46 52 window.setTimeout(function(){ 47 var DL , width;53 var DL = ed.dom.getParent(n, 'dl.wp-caption'), width; 48 54 49 55 if ( n.width != mouse.img_w || n.height != mouse.img_h ) 50 56 n.className = n.className.replace(/size-[^ "']+/, ''); 51 57 52 if ( ed.dom.getParent(n, 'div.mceTemp') ) { 53 DL = ed.dom.getParent(n, 'dl.wp-caption'); 54 55 if ( DL ) { 56 width = ed.dom.getAttrib(n, 'width') || n.width; 57 width = parseInt(width, 10); 58 ed.dom.setStyle(DL, 'width', 10 + width); 59 ed.execCommand('mceRepaint'); 60 } 61 58 if ( DL ) { 59 width = ed.dom.getAttrib(n, 'width') || n.width; 60 width = parseInt(width, 10); 61 ed.dom.setStyle(DL, 'width', 10 + width); 62 ed.execCommand('mceRepaint'); 62 63 } 63 64 }, 100); … … 83 84 }); 84 85 85 // when pressing Return inside a caption move the c ursorto a new parapraph under it86 // when pressing Return inside a caption move the caret to a new parapraph under it 86 87 ed.onKeyPress.add(function(ed, e) { 87 88 var n, DL, DIV, P; … … 90 91 n = ed.selection.getNode(); 91 92 DL = ed.dom.getParent(n, 'dl.wp-caption'); 92 DIV = ed.dom.getParent(DL, 'div.mceTemp'); 93 94 if ( DL && DIV ) { 95 P = ed.dom.create('p', {}, ' '); 93 94 if ( DL ) 95 DIV = ed.dom.getParent(DL, 'div.mceTemp'); 96 97 if ( DIV ) { 98 P = ed.dom.create('p', {}, '<br>'); 96 99 ed.dom.insertAfter( P, DIV ); 97 98 if ( P.firstChild ) 99 ed.selection.select(P.firstChild); 100 else 101 ed.selection.select(P); 102 103 tinymce.dom.Event.cancel(e); 100 ed.selection.select(P.firstChild); 101 102 if ( tinymce.isIE ) { 103 ed.selection.setContent(''); 104 } else { 105 ed.selection.setContent('<br _moz_dirty="">'); 106 ed.selection.setCursorLocation(P, 0); 107 } 108 109 ed.dom.events.cancel(e); 104 110 return false; 105 111 } … … 108 114 109 115 ed.onBeforeSetContent.add(function(ed, o) { 110 o.content = t._do_shcode(o.content);116 o.content = ed.wpSetImgCaption(o.content); 111 117 }); 112 118 113 119 ed.onPostProcess.add(function(ed, o) { 114 120 if (o.get) 115 o.content = t._get_shcode(o.content); 116 }); 117 }, 118 119 _do_shcode : function(co) { 120 return co.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?[\s\u00a0]*/g, function(a,b,c){ 121 o.content = ed.wpGetImgCaption(o.content); 122 }); 123 124 ed.wpSetImgCaption = function(content) { 125 return t._do_shcode(content); 126 }; 127 128 ed.wpGetImgCaption = function(content) { 129 return t._get_shcode(content); 130 }; 131 }, 132 133 _do_shcode : function(content) { 134 return content.replace(/(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function(a,b,c){ 121 135 var id, cls, w, cap, div_cls; 122 123 b = b.replace(/\\'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"'); 124 c = c.replace(/\\'|\\'/g, ''').replace(/\\"/g, '"'); 125 id = b.match(/id=['"]([^'"]+)/i); 126 cls = b.match(/align=['"]([^'"]+)/i); 127 w = b.match(/width=['"]([0-9]+)/); 128 cap = b.match(/caption=['"]([^'"]+)/i); 136 137 id = b.match(/id=['"]([^'"]+)['"] ?/); 138 b = b.replace(id[0], ''); 139 140 cls = b.match(/align=['"]([^'"]+)['"] ?/); 141 b = b.replace(cls[0], ''); 142 143 w = b.match(/width=['"]([0-9]+)['"] ?/); 144 b = b.replace(w[0], ''); 145 146 cap = tinymce.trim(b).replace(/caption=['"]/, '').replace(/['"]$/, ''); 129 147 130 148 id = ( id && id[1] ) ? id[1] : ''; 131 149 cls = ( cls && cls[1] ) ? cls[1] : 'alignnone'; 132 150 w = ( w && w[1] ) ? w[1] : ''; 133 cap = ( cap && cap[1] ) ? cap[1] : ''; 134 if ( ! w || ! cap ) return c; 135 151 152 if ( !w || !cap ) 153 return c; 154 136 155 div_cls = (cls == 'aligncenter') ? 'mceTemp mceIEcenter' : 'mceTemp'; 137 156 138 return '<div class="'+div_cls+'" draggable ><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+(10+parseInt(w))+157 return '<div class="'+div_cls+'" draggable="true"><dl id="'+id+'" class="wp-caption '+cls+'" style="width: '+( 10 + parseInt(w) )+ 139 158 'px"><dt class="wp-caption-dt">'+c+'</dt><dd class="wp-caption-dd">'+cap+'</dd></dl></div>'; 140 159 }); 141 160 }, 142 161 143 _get_shcode : function(co ) {144 return co .replace(/<div class="mceTemp[^"]*">\s*<dl([^>]+)>\s*<dt[^>]+>([\s\S]+?)<\/dt>\s*<dd[^>]+>(.+?)<\/dd>\s*<\/dl>\s*<\/div>\s*/gi, function(a,b,c,cap){162 _get_shcode : function(content) { 163 return content.replace(/<div class="mceTemp[^"]*">\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]+?)<\/dd>\s*<\/dl>\s*<\/div>/gi, function(a,b,c,cap){ 145 164 var id, cls, w; 146 147 id = b.match(/id=['"]([^'"]+)/i); 148 cls = b.match(/class=['"]([^'"]+)/i); 149 w = c.match(/width=['"]([0-9]+)/); 150 165 166 w = c.match(/width="([0-9]+)"/); 167 w = ( w && w[1] ) ? w[1] : ''; 168 169 if ( !w || !cap ) 170 return c; 171 172 id = b.match(/id="([^"]+)"/); 151 173 id = ( id && id[1] ) ? id[1] : ''; 152 cls = ( cls && cls[1] ) ? cls[1] : 'alignnone'; 153 w = ( w && w[1] ) ? w[1] : ''; 154 155 if ( ! w || ! cap ) return c; 156 cls = cls.match(/align[^ '"]+/) || 'alignnone'; 157 cap = cap.replace(/<\S[^<>]*>/gi, '').replace(/'/g, ''').replace(/"/g, '"'); 174 175 cls = b.match(/class="([^"]+)"/); 176 cls = ( cls && cls[1] ) ? cls[1] : ''; 177 cls = cls.match(/align[a-z]+/) || 'alignnone'; 178 179 cap = cap.replace(/<[a-z][^<>]+>/g, function(a){ 180 return a.replace(/"/g, "'"); 181 }); 182 183 cap = cap.replace(/"/g, '"'); 158 184 159 185 return '[caption id="'+id+'" align="'+cls+'" width="'+w+'" caption="'+cap+'"]'+c+'[/caption]'; -
trunk/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js
r18702 r19982 22 22 t.editor = tinymce.EditorManager.activeEditor; 23 23 t.params = t.editor.windowManager.params; 24 t.events = new tinymce.dom.EventUtils(); 24 25 25 26 // Setup local DOM … … 37 38 38 39 close : function() { 39 var t = this , win = t.getWin();40 var t = this; 40 41 41 42 // To avoid domain relaxing issue in Opera 42 43 function close() { 43 win.tb_remove();44 tinymce = tinyMCE = t.editor = t. dom = t.dom.doc = null; // Cleanup44 t.editor.windowManager.close(window); 45 tinymce = tinyMCE = t.editor = t.params = t.dom = t.dom.doc = null; // Cleanup 45 46 }; 46 47 47 48 if (tinymce.isOpera) 48 win.setTimeout(close, 0);49 t.getWin().setTimeout(close, 0); 49 50 else 50 51 close(); … … 75 76 preInit : function() { 76 77 // import colors stylesheet from parent 77 var win = tinyMCEPopup.getWin(), styles = win.document.styleSheets, url, i;78 var ed = tinyMCEPopup.editor, win = tinyMCEPopup.getWin(), styles = win.document.styleSheets, url, i; 78 79 79 80 for ( i = 0; i < styles.length; i++ ) { 80 81 url = styles.item(i).href; 81 if ( url && url.indexOf('colors') != -1 ) 82 document.write( '<link rel="stylesheet" href="'+url+'" type="text/css" media="all" />' ); 82 if ( url && url.indexOf('colors') != -1 ) { 83 document.getElementsByTagName('head')[0].appendChild( ed.dom.create('link', {rel:'stylesheet', href: url}) ); 84 break; 85 } 83 86 } 84 87 }, … … 243 246 setup : function() { 244 247 var t = this, c, el, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, 245 d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, caption = '', dlc, pa;248 d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, DD, caption = '', dlc, pa, bookmark, insert_link; 246 249 247 250 document.dir = tinyMCEPopup.editor.getParam('directionality',''); … … 268 271 } 269 272 270 tinymce.each(DL.childNodes, function(e) { 271 if ( e.nodeName == 'DD' && dom.hasClass(e, 'wp-caption-dd') ) { 272 caption = e.innerHTML; 273 return; 274 } 275 }); 276 } 277 278 f.img_cap.value = caption; 273 DD = ed.dom.select('dd.wp-caption-dd', DL); 274 if ( DD && DD[0] ) 275 caption = ed.serializer.serialize(DD[0]).replace(/^<p>/, '').replace(/<\/p>$/, ''); 276 } 277 278 f.img_cap_text.value = caption; 279 279 f.img_title.value = ed.dom.getAttrib(el, 'title'); 280 280 f.img_alt.value = ed.dom.getAttrib(el, 'alt'); … … 327 327 } 328 328 329 if ( t.width && t.preloadImg.width ) t.showSizeSet(); 329 if ( t.width && t.preloadImg.width ) 330 t.showSizeSet(); 331 330 332 document.body.style.display = ''; 333 334 tinyMCEPopup.events.add(document.body, 'click', function(e) { 335 var target = e.target, parent = target.parentNode, tr, c, el, textarea, sel, text, startPos, endPos; 336 337 if ( dom.hasClass(target, 'caption-insert-link') ) { 338 el = dom.select('div.caption-insert-link-wrap', parent)[0], textarea = dom.select('#img_cap_text')[0]; 339 340 if ( document.selection ) { 341 textarea.focus(); 342 sel = document.selection.createRange(); 343 bookmark = sel.getBookmark(); 344 345 if ( sel.text ) 346 dom.select('.caption-insert-link-text', el)[0].value = sel.text; 347 348 } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { 349 text = textarea.value; 350 startPos = textarea.selectionStart; 351 endPos = textarea.selectionEnd; 352 353 if ( startPos != endPos ) 354 dom.select('.caption-insert-link-text', el)[0].value = text.substring(startPos, endPos); 355 } 356 357 dom.hide(target); 358 dom.show(el); 359 dom.select('.caption-insert-link-url', el)[0].focus(); 360 } else if ( dom.hasClass(target, 'caption-cancel') || dom.hasClass(target, 'caption-save') ) { 361 if ( dom.hasClass(target, 'caption-save') ) 362 insert_link(); 363 364 dom.hide( dom.select('.caption-insert-link-wrap') ); 365 dom.show( dom.select('.caption-insert-link') ); 366 } 367 }); 368 369 insert_link = function() { 370 var sel, content, startPos, endPos, scrollTop, text, textarea = dom.select('#img_cap_text')[0], 371 url = dom.select('.caption-insert-link-url')[0], link_text = dom.select('.caption-insert-link-text')[0]; 372 373 if ( !url || !link_text ) 374 return; 375 376 content = "<a href='"+url.value+"'>"+link_text.value+"</a>"; 377 378 if ( document.selection ) { 379 textarea.focus(); 380 sel = document.selection.createRange(); 381 382 if ( bookmark ) { 383 sel.moveToBookmark( bookmark ); 384 bookmark = ''; 385 } 386 387 sel.text = content; 388 textarea.focus(); 389 } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { 390 text = textarea.value; 391 startPos = textarea.selectionStart; 392 endPos = textarea.selectionEnd; 393 scrollTop = textarea.scrollTop; 394 395 textarea.value = text.substring(0, startPos) + content + text.substring(endPos, text.length); 396 397 textarea.focus(); 398 textarea.selectionStart = startPos + content.length; 399 textarea.selectionEnd = startPos + content.length; 400 textarea.scrollTop = scrollTop; 401 } 402 403 url.value = ''; 404 link_text.value = ''; 405 }; 331 406 }, 332 407 … … 363 438 } 364 439 365 if ( f.img_cap .value != '' && f.width.value != '' ) {440 if ( f.img_cap_text.value != '' && f.width.value != '' ) { 366 441 do_caption = 1; 367 442 img_class = img_class.replace( /align[^ "']+\s?/gi, '' ); … … 441 516 442 517 if ( (DT = ed.dom.getParent(el, 'dt')) && (DD = DT.nextSibling) && ed.dom.hasClass(DD, 'wp-caption-dd') ) 443 ed.dom.setHTML(DD, f.img_cap .value);518 ed.dom.setHTML(DD, f.img_cap_text.value); 444 519 445 520 } else { … … 458 533 459 534 html = '<dl id="'+cap_id+'" class="wp-caption '+t.align+'" style="width: '+cap_width+ 460 'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap .value+'</dd></dl>';535 'px"><dt class="wp-caption-dt">'+html+'</dt><dd class="wp-caption-dd">'+f.img_cap_text.value+'</dd></dl>'; 461 536 462 537 cap = ed.dom.create('div', {'class': div_cls}, html); … … 615 690 window.onload = function(){wpImage.init();} 616 691 wpImage.preInit(); 692 -
trunk/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js
r18702 r19982 1 var tinymce=null,tinyMCEPopup,tinyMCE,wpImage;tinyMCEPopup={init:function(){var d=this,b,a,f,c,e;a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}b=d.getWin();tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.params=d.editor.windowManager.params;d. dom=d.editor.windowManager.createInstance("tinymce.dom.DOMUtils",document);d.editor.windowManager.onOpen.dispatch(d.editor.windowManager,window)},getWin:function(){return window.dialogArguments||opener||parent||top},getParam:function(b,a){return this.editor.getParam(b,a)},close:function(){var a=this,b=a.getWin();function c(){b.tb_remove();tinymce=tinyMCE=a.editor=a.dom=a.dom.doc=null}if(tinymce.isOpera){b.setTimeout(c,0)}else{c()}},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark("simple")},restoreSelection:function(){var a=tinyMCEPopup;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}}};tinyMCEPopup.init();wpImage={preInit:function(){var d=tinyMCEPopup.getWin(),c=d.document.styleSheets,a,b;for(b=0;b<c.length;b++){a=c.item(b).href;if(a&&a.indexOf("colors")!=-1){document.write('<link rel="stylesheet" href="'+a+'" type="text/css" media="all" />')}}},I:function(a){return document.getElementById(a)},current:"",link:"",link_rel:"",target_value:"",current_size_sel:"s100",width:"",height:"",align:"",img_alt:"",setTabs:function(b){var a=this;if("current"==b.className){return false}a.I("div_advanced").style.display=("tab_advanced"==b.id)?"block":"none";a.I("div_basic").style.display=("tab_basic"==b.id)?"block":"none";a.I("tab_basic").className=a.I("tab_advanced").className="";b.className="current";return false},img_seturl:function(b){var c=this,a=c.I("link_rel").value;if("current"==b){c.I("link_href").value=c.current;c.I("link_rel").value=c.link_rel}else{c.I("link_href").value=c.link;if(a){a=a.replace(/attachment|wp-att-[0-9]+/gi,"");c.I("link_rel").value=tinymce.trim(a)}}},imgAlignCls:function(b){var c=this,a=c.I("img_classes").value;c.I("img_demo").className=c.align=b;a=a.replace(/align[^ "']+/gi,"");a+=(" "+b);a=a.replace(/\s+/g," ").replace(/^\s/,"");if("aligncenter"==b){c.I("hspace").value="";c.updateStyle("hspace")}c.I("img_classes").value=a},showSize:function(e){var c=this,f=c.I("img_demo"),a=c.width,d=c.height,g=e.id||"s100",b;b=parseInt(g.substring(1))/200;f.width=Math.round(a*b);f.height=Math.round(d*b);c.showSizeClear();e.style.borderColor="#A3A3A3";e.style.backgroundColor="#E5E5E5"},showSizeSet:function(){var b=this,d,c,a;if((b.width*1.3)>parseInt(b.preloadImg.width)){d=b.I("s130"),c=b.I("s120"),a=b.I("s110");d.onclick=c.onclick=a.onclick=null;d.onmouseover=c.onmouseover=a.onmouseover=null;d.style.color=c.style.color=a.style.color="#aaa"}},showSizeRem:function(){var a=this,c=a.I("img_demo"),b=document.forms[0];c.width=Math.round(b.width.value*0.5);c.height=Math.round(b.height.value*0.5);a.showSizeClear();a.I(a.current_size_sel).style.borderColor="#A3A3A3";a.I(a.current_size_sel).style.backgroundColor="#E5E5E5";return false},showSizeClear:function(){var b=this.I("img_size").getElementsByTagName("div"),a;for(a=0;a<b.length;a++){b[a].style.borderColor="#f1f1f1";b[a].style.backgroundColor="#f1f1f1"}},imgEditSize:function(g){var d=this,i=document.forms[0],a,c,b,e,j;if(!d.preloadImg||!d.preloadImg.width||!d.preloadImg.height){return}a=parseInt(d.preloadImg.width),c=parseInt(d.preloadImg.height),b=d.width||a,e=d.height||c,j=g.id||"s100";size=parseInt(j.substring(1))/100;b=Math.round(b*size);e=Math.round(e*size);i.width.value=Math.min(a,b);i.height.value=Math.min(c,e);d.current_size_sel=j;d.demoSetSize()},demoSetSize:function(a){var c=this.I("img_demo"),b=document.forms[0];c.width=b.width.value?Math.round(b.width.value*0.5):"";c.height=b.height.value?Math.round(b.height.value*0.5):""},demoSetStyle:function(){var b=document.forms[0],a=this.I("img_demo"),c=tinyMCEPopup.editor.dom;if(a){c.setAttrib(a,"style",b.img_style.value);c.setStyle(a,"width","");c.setStyle(a,"height","")}},origSize:function(){var a=this,c=document.forms[0],b=a.I("s100");c.width.value=a.width=a.preloadImg.width;c.height.value=a.height=a.preloadImg.height;a.showSizeSet();a.demoSetSize();a.showSize(b)},init:function(){var a=tinyMCEPopup.editor,b;b=document.body.innerHTML;document.body.innerHTML=a.translate(b);window.setTimeout(function(){wpImage.setup()},500)},setup:function(){var p=this,k,b,l,e,i=document.forms[0],h=tinyMCEPopup.editor,j=p.I("img_demo"),g=tinyMCEPopup.dom,a,o="",n,m;document.dir=tinyMCEPopup.editor.getParam("directionality","");if(tinyMCEPopup.editor.getParam("wpeditimage_disable_captions",false)){p.I("cap_field").style.display="none"}tinyMCEPopup.restoreSelection();b=h.selection.getNode();if(b.nodeName!="IMG"){return}i.img_src.value=j.src=l=h.dom.getAttrib(b,"src");h.dom.setStyle(b,"float","");p.getImageData();k=h.dom.getAttrib(b,"class");if(a=g.getParent(b,"dl")){n=h.dom.getAttrib(a,"class");n=n.match(/align[^ "']+/i);if(n&&!g.hasClass(b,n)){k+=" "+n;tinymce.trim(k)}tinymce.each(a.childNodes,function(c){if(c.nodeName=="DD"&&g.hasClass(c,"wp-caption-dd")){o=c.innerHTML;return}})}i.img_cap.value=o;i.img_title.value=h.dom.getAttrib(b,"title");i.img_alt.value=h.dom.getAttrib(b,"alt");i.border.value=h.dom.getAttrib(b,"border");i.vspace.value=h.dom.getAttrib(b,"vspace");i.hspace.value=h.dom.getAttrib(b,"hspace");i.align.value=h.dom.getAttrib(b,"align");i.width.value=p.width=h.dom.getAttrib(b,"width");i.height.value=p.height=h.dom.getAttrib(b,"height");i.img_classes.value=k;i.img_style.value=h.dom.getAttrib(b,"style");if(g.getAttrib(b,"hspace")){p.updateStyle("hspace")}if(g.getAttrib(b,"border")){p.updateStyle("border")}if(g.getAttrib(b,"vspace")){p.updateStyle("vspace")}if(m=h.dom.getParent(b,"A")){i.link_href.value=p.current=h.dom.getAttrib(m,"href");i.link_title.value=h.dom.getAttrib(m,"title");i.link_rel.value=p.link_rel=h.dom.getAttrib(m,"rel");i.link_style.value=h.dom.getAttrib(m,"style");p.target_value=h.dom.getAttrib(m,"target");i.link_classes.value=h.dom.getAttrib(m,"class")}i.link_target.checked=(p.target_value&&p.target_value=="_blank")?"checked":"";e=l.substring(l.lastIndexOf("/"));e=e.replace(/-[0-9]{2,4}x[0-9]{2,4}/,"");p.link=l.substring(0,l.lastIndexOf("/"))+e;if(k.indexOf("alignleft")!=-1){p.I("alignleft").checked="checked";j.className=p.align="alignleft"}else{if(k.indexOf("aligncenter")!=-1){p.I("aligncenter").checked="checked";j.className=p.align="aligncenter"}else{if(k.indexOf("alignright")!=-1){p.I("alignright").checked="checked";j.className=p.align="alignright"}else{if(k.indexOf("alignnone")!=-1){p.I("alignnone").checked="checked";j.className=p.align="alignnone"}}}}if(p.width&&p.preloadImg.width){p.showSizeSet()}document.body.style.display=""},remove:function(){var a=tinyMCEPopup.editor,c,b;tinyMCEPopup.restoreSelection();b=a.selection.getNode();if(b.nodeName!="IMG"){return}if((c=a.dom.getParent(b,"div"))&&a.dom.hasClass(c,"mceTemp")){a.dom.remove(c)}else{if((c=a.dom.getParent(b,"A"))&&c.childNodes.length==1){a.dom.remove(c)}else{a.dom.remove(b)}}a.execCommand("mceRepaint");tinyMCEPopup.close();return},update:function(){var m=this,v=document.forms[0],g=tinyMCEPopup.editor,e,x,d=null,n,h,p,r,o=null,k=v.img_classes.value,l,q,u="",j,i,s,a,z,w="",c,y;tinyMCEPopup.restoreSelection();e=g.selection.getNode();if(e.nodeName!="IMG"){return}if(v.img_src.value===""){m.remove();return}if(v.img_cap.value!=""&&v.width.value!=""){o=1;k=k.replace(/align[^ "']+\s?/gi,"")}p=g.dom.getParent(e,"a");h=g.dom.getParent(e,"p");n=g.dom.getParent(e,"dl");r=g.dom.getParent(e,"div");tinyMCEPopup.execCommand("mceBeginUndoLevel");if(v.width.value!=e.width||v.height.value!=e.height){k=k.replace(/size-[^ "']+/,"")}g.dom.setAttribs(e,{src:v.img_src.value,title:v.img_title.value,alt:v.img_alt.value,width:v.width.value,height:v.height.value,style:v.img_style.value,"class":k});if(v.link_href.value){if(p==null){if(!v.link_href.value.match(/https?:\/\//i)){v.link_href.value=tinyMCEPopup.editor.documentBaseURI.toAbsolute(v.link_href.value)}if(tinymce.isWebKit&&g.dom.hasClass(e,"aligncenter")){g.dom.removeClass(e,"aligncenter");d=1}tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});if(d){g.dom.addClass(e,"aligncenter")}tinymce.each(g.dom.select("a"),function(b){if(g.dom.getAttrib(b,"href")=="#mce_temp_url#"){g.dom.setAttribs(b,{href:v.link_href.value,title:v.link_title.value,rel:v.link_rel.value,target:(v.link_target.checked==true)?"_blank":"","class":v.link_classes.value,style:v.link_style.value})}})}else{g.dom.setAttribs(p,{href:v.link_href.value,title:v.link_title.value,rel:v.link_rel.value,target:(v.link_target.checked==true)?"_blank":"","class":v.link_classes.value,style:v.link_style.value})}}if(o){a=10+parseInt(v.width.value);z=(m.align=="aligncenter")?"mceTemp mceIEcenter":"mceTemp";if(n){g.dom.setAttribs(n,{"class":"wp-caption "+m.align,style:"width: "+a+"px;"});if(r){g.dom.setAttrib(r,"class",z)}if((i=g.dom.getParent(e,"dt"))&&(s=i.nextSibling)&&g.dom.hasClass(s,"wp-caption-dd")){g.dom.setHTML(s,v.img_cap.value)}}else{if((q=v.img_classes.value.match(/wp-image-([0-9]{1,6})/))&&q[1]){u="attachment_"+q[1]}if(v.link_href.value&&(w=g.dom.getParent(e,"a"))){if(w.childNodes.length==1){l=g.dom.getOuterHTML(w)}else{l=g.dom.getOuterHTML(w);l=l.match(/<a[^>]+>/i);l=l+g.dom.getOuterHTML(e)+"</a>"}}else{l=g.dom.getOuterHTML(e)}l='<dl id="'+u+'" class="wp-caption '+m.align+'" style="width: '+a+'px"><dt class="wp-caption-dt">'+l+'</dt><dd class="wp-caption-dd">'+v.img_cap.value+"</dd></dl>";j=g.dom.create("div",{"class":z},l);if(h){h.parentNode.insertBefore(j,h);if(h.childNodes.length==1){g.dom.remove(h)}else{if(w&&w.childNodes.length==1){g.dom.remove(w)}else{g.dom.remove(e)}}}else{if(c=g.dom.getParent(e,"TD,TH,LI")){c.appendChild(j);if(w&&w.childNodes.length==1){g.dom.remove(w)}else{g.dom.remove(e)}}}}}else{if(n&&r){if(v.link_href.value&&(y=g.dom.getParent(e,"a"))){l=g.dom.getOuterHTML(y)}else{l=g.dom.getOuterHTML(e)}h=g.dom.create("p",{},l);r.parentNode.insertBefore(h,r);g.dom.remove(r)}}if(v.img_classes.value.indexOf("aligncenter")!=-1){if(h&&(!h.style||h.style.textAlign!="center")){g.dom.setStyle(h,"textAlign","center")}}else{if(h&&h.style&&h.style.textAlign=="center"){g.dom.setStyle(h,"textAlign","")}}if(!v.link_href.value&&p){x=g.selection.getBookmark();g.dom.remove(p,1);g.selection.moveToBookmark(x)}tinyMCEPopup.execCommand("mceEndUndoLevel");g.execCommand("mceRepaint");tinyMCEPopup.close()},updateStyle:function(a){var e=tinyMCEPopup.dom,c,d=document.forms[0],b=e.create("img",{style:d.img_style.value});if(tinyMCEPopup.editor.settings.inline_styles){if(a=="align"){e.setStyle(b,"float","");e.setStyle(b,"vertical-align","");c=d.align.value;if(c){if(c=="left"||c=="right"){e.setStyle(b,"float",c)}else{b.style.verticalAlign=c}}}if(a=="border"){e.setStyle(b,"border","");c=d.border.value;if(c||c=="0"){if(c=="0"){b.style.border="0"}else{b.style.border=c+"px solid black"}}}if(a=="hspace"){e.setStyle(b,"marginLeft","");e.setStyle(b,"marginRight","");c=d.hspace.value;if(c){b.style.marginLeft=c+"px";b.style.marginRight=c+"px"}}if(a=="vspace"){e.setStyle(b,"marginTop","");e.setStyle(b,"marginBottom","");c=d.vspace.value;if(c){b.style.marginTop=c+"px";b.style.marginBottom=c+"px"}}d.img_style.value=e.serializeStyle(e.parseStyle(b.style.cssText));this.demoSetStyle()}},checkVal:function(a){if(a.value==""){if(a.id=="img_src"){a.value=this.I("img_demo").src||this.preloadImg.src}}},resetImageData:function(){var a=document.forms[0];a.width.value=a.height.value=""},updateImageData:function(){var d=document.forms[0],b=wpImage,a=d.width.value,c=d.height.value;if(!a&&c){a=d.width.value=b.width=Math.round(b.preloadImg.width/(b.preloadImg.height/c))}else{if(a&&!c){c=d.height.value=b.height=Math.round(b.preloadImg.height/(b.preloadImg.width/a))}}if(!a){d.width.value=b.width=b.preloadImg.width}if(!c){d.height.value=b.height=b.preloadImg.height}b.showSizeSet();b.demoSetSize();if(d.img_style.value){b.demoSetStyle()}},getImageData:function(){var a=wpImage,b=document.forms[0];a.preloadImg=new Image();a.preloadImg.onload=a.updateImageData;a.preloadImg.onerror=a.resetImageData;a.preloadImg.src=tinyMCEPopup.editor.documentBaseURI.toAbsolute(b.img_src.value)}};window.onload=function(){wpImage.init()};wpImage.preInit();1 var tinymce=null,tinyMCEPopup,tinyMCE,wpImage;tinyMCEPopup={init:function(){var d=this,b,a,f,c,e;a=(""+document.location.search).replace(/^\?/,"").split("&");f={};for(c=0;c<a.length;c++){e=a[c].split("=");f[unescape(e[0])]=unescape(e[1])}if(f.mce_rdomain){document.domain=f.mce_rdomain}b=d.getWin();tinymce=b.tinymce;tinyMCE=b.tinyMCE;d.editor=tinymce.EditorManager.activeEditor;d.params=d.editor.windowManager.params;d.events=new tinymce.dom.EventUtils();d.dom=d.editor.windowManager.createInstance("tinymce.dom.DOMUtils",document);d.editor.windowManager.onOpen.dispatch(d.editor.windowManager,window)},getWin:function(){return window.dialogArguments||opener||parent||top},getParam:function(b,a){return this.editor.getParam(b,a)},close:function(){var a=this;function b(){a.editor.windowManager.close(window);tinymce=tinyMCE=a.editor=a.params=a.dom=a.dom.doc=null}if(tinymce.isOpera){a.getWin().setTimeout(b,0)}else{b()}},execCommand:function(d,c,e,b){b=b||{};b.skip_focus=1;this.restoreSelection();return this.editor.execCommand(d,c,e,b)},storeSelection:function(){this.editor.windowManager.bookmark=tinyMCEPopup.editor.selection.getBookmark("simple")},restoreSelection:function(){var a=tinyMCEPopup;if(tinymce.isIE){a.editor.selection.moveToBookmark(a.editor.windowManager.bookmark)}}};tinyMCEPopup.init();wpImage={preInit:function(){var a=tinyMCEPopup.editor,e=tinyMCEPopup.getWin(),d=e.document.styleSheets,b,c;for(c=0;c<d.length;c++){b=d.item(c).href;if(b&&b.indexOf("colors")!=-1){document.getElementsByTagName("head")[0].appendChild(a.dom.create("link",{rel:"stylesheet",href:b}));break}}},I:function(a){return document.getElementById(a)},current:"",link:"",link_rel:"",target_value:"",current_size_sel:"s100",width:"",height:"",align:"",img_alt:"",setTabs:function(b){var a=this;if("current"==b.className){return false}a.I("div_advanced").style.display=("tab_advanced"==b.id)?"block":"none";a.I("div_basic").style.display=("tab_basic"==b.id)?"block":"none";a.I("tab_basic").className=a.I("tab_advanced").className="";b.className="current";return false},img_seturl:function(b){var c=this,a=c.I("link_rel").value;if("current"==b){c.I("link_href").value=c.current;c.I("link_rel").value=c.link_rel}else{c.I("link_href").value=c.link;if(a){a=a.replace(/attachment|wp-att-[0-9]+/gi,"");c.I("link_rel").value=tinymce.trim(a)}}},imgAlignCls:function(b){var c=this,a=c.I("img_classes").value;c.I("img_demo").className=c.align=b;a=a.replace(/align[^ "']+/gi,"");a+=(" "+b);a=a.replace(/\s+/g," ").replace(/^\s/,"");if("aligncenter"==b){c.I("hspace").value="";c.updateStyle("hspace")}c.I("img_classes").value=a},showSize:function(e){var c=this,f=c.I("img_demo"),a=c.width,d=c.height,g=e.id||"s100",b;b=parseInt(g.substring(1))/200;f.width=Math.round(a*b);f.height=Math.round(d*b);c.showSizeClear();e.style.borderColor="#A3A3A3";e.style.backgroundColor="#E5E5E5"},showSizeSet:function(){var b=this,d,c,a;if((b.width*1.3)>parseInt(b.preloadImg.width)){d=b.I("s130"),c=b.I("s120"),a=b.I("s110");d.onclick=c.onclick=a.onclick=null;d.onmouseover=c.onmouseover=a.onmouseover=null;d.style.color=c.style.color=a.style.color="#aaa"}},showSizeRem:function(){var a=this,c=a.I("img_demo"),b=document.forms[0];c.width=Math.round(b.width.value*0.5);c.height=Math.round(b.height.value*0.5);a.showSizeClear();a.I(a.current_size_sel).style.borderColor="#A3A3A3";a.I(a.current_size_sel).style.backgroundColor="#E5E5E5";return false},showSizeClear:function(){var b=this.I("img_size").getElementsByTagName("div"),a;for(a=0;a<b.length;a++){b[a].style.borderColor="#f1f1f1";b[a].style.backgroundColor="#f1f1f1"}},imgEditSize:function(g){var d=this,i=document.forms[0],a,c,b,e,j;if(!d.preloadImg||!d.preloadImg.width||!d.preloadImg.height){return}a=parseInt(d.preloadImg.width),c=parseInt(d.preloadImg.height),b=d.width||a,e=d.height||c,j=g.id||"s100";size=parseInt(j.substring(1))/100;b=Math.round(b*size);e=Math.round(e*size);i.width.value=Math.min(a,b);i.height.value=Math.min(c,e);d.current_size_sel=j;d.demoSetSize()},demoSetSize:function(a){var c=this.I("img_demo"),b=document.forms[0];c.width=b.width.value?Math.round(b.width.value*0.5):"";c.height=b.height.value?Math.round(b.height.value*0.5):""},demoSetStyle:function(){var b=document.forms[0],a=this.I("img_demo"),c=tinyMCEPopup.editor.dom;if(a){c.setAttrib(a,"style",b.img_style.value);c.setStyle(a,"width","");c.setStyle(a,"height","")}},origSize:function(){var a=this,c=document.forms[0],b=a.I("s100");c.width.value=a.width=a.preloadImg.width;c.height.value=a.height=a.preloadImg.height;a.showSizeSet();a.demoSetSize();a.showSize(b)},init:function(){var a=tinyMCEPopup.editor,b;b=document.body.innerHTML;document.body.innerHTML=a.translate(b);window.setTimeout(function(){wpImage.setup()},500)},setup:function(){var s=this,n,e,o,g,k=document.forms[0],j=tinyMCEPopup.editor,m=s.I("img_demo"),i=tinyMCEPopup.dom,a,h,r="",q,p,l,b;document.dir=tinyMCEPopup.editor.getParam("directionality","");if(tinyMCEPopup.editor.getParam("wpeditimage_disable_captions",false)){s.I("cap_field").style.display="none"}tinyMCEPopup.restoreSelection();e=j.selection.getNode();if(e.nodeName!="IMG"){return}k.img_src.value=m.src=o=j.dom.getAttrib(e,"src");j.dom.setStyle(e,"float","");s.getImageData();n=j.dom.getAttrib(e,"class");if(a=i.getParent(e,"dl")){q=j.dom.getAttrib(a,"class");q=q.match(/align[^ "']+/i);if(q&&!i.hasClass(e,q)){n+=" "+q;tinymce.trim(n)}h=j.dom.select("dd.wp-caption-dd",a);if(h&&h[0]){r=j.serializer.serialize(h[0]).replace(/^<p>/,"").replace(/<\/p>$/,"")}}k.img_cap_text.value=r;k.img_title.value=j.dom.getAttrib(e,"title");k.img_alt.value=j.dom.getAttrib(e,"alt");k.border.value=j.dom.getAttrib(e,"border");k.vspace.value=j.dom.getAttrib(e,"vspace");k.hspace.value=j.dom.getAttrib(e,"hspace");k.align.value=j.dom.getAttrib(e,"align");k.width.value=s.width=j.dom.getAttrib(e,"width");k.height.value=s.height=j.dom.getAttrib(e,"height");k.img_classes.value=n;k.img_style.value=j.dom.getAttrib(e,"style");if(i.getAttrib(e,"hspace")){s.updateStyle("hspace")}if(i.getAttrib(e,"border")){s.updateStyle("border")}if(i.getAttrib(e,"vspace")){s.updateStyle("vspace")}if(p=j.dom.getParent(e,"A")){k.link_href.value=s.current=j.dom.getAttrib(p,"href");k.link_title.value=j.dom.getAttrib(p,"title");k.link_rel.value=s.link_rel=j.dom.getAttrib(p,"rel");k.link_style.value=j.dom.getAttrib(p,"style");s.target_value=j.dom.getAttrib(p,"target");k.link_classes.value=j.dom.getAttrib(p,"class")}k.link_target.checked=(s.target_value&&s.target_value=="_blank")?"checked":"";g=o.substring(o.lastIndexOf("/"));g=g.replace(/-[0-9]{2,4}x[0-9]{2,4}/,"");s.link=o.substring(0,o.lastIndexOf("/"))+g;if(n.indexOf("alignleft")!=-1){s.I("alignleft").checked="checked";m.className=s.align="alignleft"}else{if(n.indexOf("aligncenter")!=-1){s.I("aligncenter").checked="checked";m.className=s.align="aligncenter"}else{if(n.indexOf("alignright")!=-1){s.I("alignright").checked="checked";m.className=s.align="alignright"}else{if(n.indexOf("alignnone")!=-1){s.I("alignnone").checked="checked";m.className=s.align="alignnone"}}}}if(s.width&&s.preloadImg.width){s.showSizeSet()}document.body.style.display="";tinyMCEPopup.events.add(document.body,"click",function(v){var w=v.target,z=w.parentNode,y,x,t,A,f,B,u,d;if(i.hasClass(w,"caption-insert-link")){t=i.select("div.caption-insert-link-wrap",z)[0],A=i.select("#img_cap_text")[0];if(document.selection){A.focus();f=document.selection.createRange();l=f.getBookmark();if(f.text){i.select(".caption-insert-link-text",t)[0].value=f.text}}else{if(A.selectionStart||A.selectionStart=="0"){B=A.value;u=A.selectionStart;d=A.selectionEnd;if(u!=d){i.select(".caption-insert-link-text",t)[0].value=B.substring(u,d)}}}i.hide(w);i.show(t);i.select(".caption-insert-link-url",t)[0].focus()}else{if(i.hasClass(w,"caption-cancel")||i.hasClass(w,"caption-save")){if(i.hasClass(w,"caption-save")){b()}i.hide(i.select(".caption-insert-link-wrap"));i.show(i.select(".caption-insert-link"))}}});b=function(){var u,v,w,f,t,y,x=i.select("#img_cap_text")[0],d=i.select(".caption-insert-link-url")[0],c=i.select(".caption-insert-link-text")[0];if(!d||!c){return}v="<a href='"+d.value+"'>"+c.value+"</a>";if(document.selection){x.focus();u=document.selection.createRange();if(l){u.moveToBookmark(l);l=""}u.text=v;x.focus()}else{if(x.selectionStart||x.selectionStart=="0"){y=x.value;w=x.selectionStart;f=x.selectionEnd;t=x.scrollTop;x.value=y.substring(0,w)+v+y.substring(f,y.length);x.focus();x.selectionStart=w+v.length;x.selectionEnd=w+v.length;x.scrollTop=t}}d.value="";c.value=""}},remove:function(){var a=tinyMCEPopup.editor,c,b;tinyMCEPopup.restoreSelection();b=a.selection.getNode();if(b.nodeName!="IMG"){return}if((c=a.dom.getParent(b,"div"))&&a.dom.hasClass(c,"mceTemp")){a.dom.remove(c)}else{if((c=a.dom.getParent(b,"A"))&&c.childNodes.length==1){a.dom.remove(c)}else{a.dom.remove(b)}}a.execCommand("mceRepaint");tinyMCEPopup.close();return},update:function(){var m=this,v=document.forms[0],g=tinyMCEPopup.editor,e,x,d=null,n,h,p,r,o=null,k=v.img_classes.value,l,q,u="",j,i,s,a,z,w="",c,y;tinyMCEPopup.restoreSelection();e=g.selection.getNode();if(e.nodeName!="IMG"){return}if(v.img_src.value===""){m.remove();return}if(v.img_cap_text.value!=""&&v.width.value!=""){o=1;k=k.replace(/align[^ "']+\s?/gi,"")}p=g.dom.getParent(e,"a");h=g.dom.getParent(e,"p");n=g.dom.getParent(e,"dl");r=g.dom.getParent(e,"div");tinyMCEPopup.execCommand("mceBeginUndoLevel");if(v.width.value!=e.width||v.height.value!=e.height){k=k.replace(/size-[^ "']+/,"")}g.dom.setAttribs(e,{src:v.img_src.value,title:v.img_title.value,alt:v.img_alt.value,width:v.width.value,height:v.height.value,style:v.img_style.value,"class":k});if(v.link_href.value){if(p==null){if(!v.link_href.value.match(/https?:\/\//i)){v.link_href.value=tinyMCEPopup.editor.documentBaseURI.toAbsolute(v.link_href.value)}if(tinymce.isWebKit&&g.dom.hasClass(e,"aligncenter")){g.dom.removeClass(e,"aligncenter");d=1}tinyMCEPopup.execCommand("CreateLink",false,"#mce_temp_url#",{skip_undo:1});if(d){g.dom.addClass(e,"aligncenter")}tinymce.each(g.dom.select("a"),function(b){if(g.dom.getAttrib(b,"href")=="#mce_temp_url#"){g.dom.setAttribs(b,{href:v.link_href.value,title:v.link_title.value,rel:v.link_rel.value,target:(v.link_target.checked==true)?"_blank":"","class":v.link_classes.value,style:v.link_style.value})}})}else{g.dom.setAttribs(p,{href:v.link_href.value,title:v.link_title.value,rel:v.link_rel.value,target:(v.link_target.checked==true)?"_blank":"","class":v.link_classes.value,style:v.link_style.value})}}if(o){a=10+parseInt(v.width.value);z=(m.align=="aligncenter")?"mceTemp mceIEcenter":"mceTemp";if(n){g.dom.setAttribs(n,{"class":"wp-caption "+m.align,style:"width: "+a+"px;"});if(r){g.dom.setAttrib(r,"class",z)}if((i=g.dom.getParent(e,"dt"))&&(s=i.nextSibling)&&g.dom.hasClass(s,"wp-caption-dd")){g.dom.setHTML(s,v.img_cap_text.value)}}else{if((q=v.img_classes.value.match(/wp-image-([0-9]{1,6})/))&&q[1]){u="attachment_"+q[1]}if(v.link_href.value&&(w=g.dom.getParent(e,"a"))){if(w.childNodes.length==1){l=g.dom.getOuterHTML(w)}else{l=g.dom.getOuterHTML(w);l=l.match(/<a[^>]+>/i);l=l+g.dom.getOuterHTML(e)+"</a>"}}else{l=g.dom.getOuterHTML(e)}l='<dl id="'+u+'" class="wp-caption '+m.align+'" style="width: '+a+'px"><dt class="wp-caption-dt">'+l+'</dt><dd class="wp-caption-dd">'+v.img_cap_text.value+"</dd></dl>";j=g.dom.create("div",{"class":z},l);if(h){h.parentNode.insertBefore(j,h);if(h.childNodes.length==1){g.dom.remove(h)}else{if(w&&w.childNodes.length==1){g.dom.remove(w)}else{g.dom.remove(e)}}}else{if(c=g.dom.getParent(e,"TD,TH,LI")){c.appendChild(j);if(w&&w.childNodes.length==1){g.dom.remove(w)}else{g.dom.remove(e)}}}}}else{if(n&&r){if(v.link_href.value&&(y=g.dom.getParent(e,"a"))){l=g.dom.getOuterHTML(y)}else{l=g.dom.getOuterHTML(e)}h=g.dom.create("p",{},l);r.parentNode.insertBefore(h,r);g.dom.remove(r)}}if(v.img_classes.value.indexOf("aligncenter")!=-1){if(h&&(!h.style||h.style.textAlign!="center")){g.dom.setStyle(h,"textAlign","center")}}else{if(h&&h.style&&h.style.textAlign=="center"){g.dom.setStyle(h,"textAlign","")}}if(!v.link_href.value&&p){x=g.selection.getBookmark();g.dom.remove(p,1);g.selection.moveToBookmark(x)}tinyMCEPopup.execCommand("mceEndUndoLevel");g.execCommand("mceRepaint");tinyMCEPopup.close()},updateStyle:function(a){var e=tinyMCEPopup.dom,c,d=document.forms[0],b=e.create("img",{style:d.img_style.value});if(tinyMCEPopup.editor.settings.inline_styles){if(a=="align"){e.setStyle(b,"float","");e.setStyle(b,"vertical-align","");c=d.align.value;if(c){if(c=="left"||c=="right"){e.setStyle(b,"float",c)}else{b.style.verticalAlign=c}}}if(a=="border"){e.setStyle(b,"border","");c=d.border.value;if(c||c=="0"){if(c=="0"){b.style.border="0"}else{b.style.border=c+"px solid black"}}}if(a=="hspace"){e.setStyle(b,"marginLeft","");e.setStyle(b,"marginRight","");c=d.hspace.value;if(c){b.style.marginLeft=c+"px";b.style.marginRight=c+"px"}}if(a=="vspace"){e.setStyle(b,"marginTop","");e.setStyle(b,"marginBottom","");c=d.vspace.value;if(c){b.style.marginTop=c+"px";b.style.marginBottom=c+"px"}}d.img_style.value=e.serializeStyle(e.parseStyle(b.style.cssText));this.demoSetStyle()}},checkVal:function(a){if(a.value==""){if(a.id=="img_src"){a.value=this.I("img_demo").src||this.preloadImg.src}}},resetImageData:function(){var a=document.forms[0];a.width.value=a.height.value=""},updateImageData:function(){var d=document.forms[0],b=wpImage,a=d.width.value,c=d.height.value;if(!a&&c){a=d.width.value=b.width=Math.round(b.preloadImg.width/(b.preloadImg.height/c))}else{if(a&&!c){c=d.height.value=b.height=Math.round(b.preloadImg.height/(b.preloadImg.width/a))}}if(!a){d.width.value=b.width=b.preloadImg.width}if(!c){d.height.value=b.height=b.preloadImg.height}b.showSizeSet();b.demoSetSize();if(d.img_style.value){b.demoSetStyle()}},getImageData:function(){var a=wpImage,b=document.forms[0];a.preloadImg=new Image();a.preloadImg.onload=a.updateImageData;a.preloadImg.onerror=a.resetImageData;a.preloadImg.src=tinyMCEPopup.editor.documentBaseURI.toAbsolute(b.img_src.value)}};window.onload=function(){wpImage.init()};wpImage.preInit(); -
trunk/wp-includes/js/tinymce/themes/advanced/skins/wp_theme/content.css
r19830 r19982 1 body { 2 font: 13px/19px Georgia, "Times New Roman", "Bitstream Charter", Times, serif; 3 margin: 10px; 4 color: #000; 5 } 1 6 2 body.mceForceColors {background:#FFF; color:#000;} 7 3 body.mceBrowserDefaults {background:transparent; color:inherit; font-size:inherit; font-family:inherit;} … … 42 38 43 39 /* WordPress styles */ 40 body { 41 font-family: sans-serif; 42 font-size: 13px; 43 line-height: 19px; 44 color: #333; 45 margin: 10px; 46 min-height: 100%; 47 } 48 49 br[data-mce-bogus] { 50 line-height: 1em; 51 margin-top: -1em; 52 } 53 54 br[data-mce-bogus]:only-child { 55 line-height: inherit; 56 margin-top: inherit; 57 } 44 58 45 59 .aligncenter, … … 76 90 padding: 0; 77 91 border: 0 none; 92 -webkit-user-drag: none; 78 93 } 79 94
Note: See TracChangeset
for help on using the changeset viewer.