X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/a5227bf01edbe6660486c9f5c0f0ed7b7fea3130..f9001779751f83dc8a10e478bfecb4d8dd5f964c:/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js index 68561ddc..ff3cb479 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin.dev.js @@ -43,22 +43,30 @@ }); }); + // resize the caption
when the image is soft-resized by the user (only possible in Firefox and IE) ed.onMouseUp.add(function(ed, e) { if ( tinymce.isWebKit || tinymce.isOpera ) return; - if ( ed.dom.getParent(e.target, 'div.mceTemp') || ed.dom.is(e.target, 'div.mceTemp') ) { + if ( ed.dom.getParent(e.target, 'div.mceTemp') || ed.dom.is(e.target, 'div.mceTemp') ) { window.setTimeout(function(){ - var ed = tinyMCE.activeEditor, n = ed.selection.getNode(), DL = ed.dom.getParent(n, 'dl.wp-caption'); + var ed = tinyMCE.activeEditor, n = ed.selection.getNode(), DL, width; - if ( DL && n.width != ( parseInt(ed.dom.getStyle(DL, 'width'), 10) - 10 ) ) { - ed.dom.setStyle(DL, 'width', parseInt(n.width, 10) + 10); - ed.execCommand('mceRepaint'); + if ( 'IMG' == n.nodeName ) { + DL = ed.dom.getParent(n, 'dl.wp-caption'); + width = ed.dom.getAttrib(n, 'width') || n.width; + width = parseInt(width, 10); + + if ( DL && width != ( parseInt(ed.dom.getStyle(DL, 'width'), 10) - 10 ) ) { + ed.dom.setStyle(DL, 'width', 10 + width); + ed.execCommand('mceRepaint'); + } } }, 100); } }); + // show editimage buttons ed.onMouseDown.add(function(ed, e) { var p; @@ -69,23 +77,27 @@ } }); + // when pressing Return inside a caption move the cursor to a new parapraph under it ed.onKeyPress.add(function(ed, e) { - var DL, DIV, P; + var n, DL, DIV, P; - if ( e.keyCode == 13 && (DL = ed.dom.getParent(ed.selection.getNode(), 'DL')) && ed.dom.hasClass(DL, 'wp-caption') ) { - P = ed.dom.create('p', {}, ' '); - if ( (DIV = DL.parentNode) && DIV.nodeName == 'DIV' ) - ed.dom.insertAfter( P, DIV ); - else - ed.dom.insertAfter( P, DL ); + if ( e.keyCode == 13 ) { + n = ed.selection.getNode(); + DL = ed.dom.getParent(n, 'dl.wp-caption'); + DIV = ed.dom.getParent(DL, 'div.mceTemp'); - if ( P.firstChild ) - ed.selection.select(P.firstChild); - else - ed.selection.select(P); - - tinymce.dom.Event.cancel(e); - return false; + if ( DL && DIV ) { + P = ed.dom.create('p', {}, ' '); + ed.dom.insertAfter( P, DIV ); + + if ( P.firstChild ) + ed.selection.select(P.firstChild); + else + ed.selection.select(P); + + tinymce.dom.Event.cancel(e); + return false; + } } }); @@ -100,7 +112,7 @@ }, _do_shcode : function(co) { - return co.replace(/\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\][\s\u00a0]*/g, function(a,b,c){ + return co.replace(/(?:

)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?[\s\u00a0]*/g, function(a,b,c){ var id, cls, w, cap, div_cls; b = b.replace(/\\'|\\'|\\'/g, ''').replace(/\\"|\\"/g, '"');