From e169217ad0c6e16d790bab7611d48fd15fa6db4c Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Mon, 5 Mar 2012 07:31:31 +0000 Subject: [PATCH] Based on the current UX feedback, remove the "Insert Link" UI from under the caption fields, see #18311 git-svn-id: https://develop.svn.wordpress.org/trunk@20114 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-admin/css/wp-admin.dev.css | 39 +-------- wp-admin/includes/media.php | 38 +++++---- wp-includes/js/plupload/handlers.dev.js | 80 +------------------ wp-includes/js/tinymce/langs/wp-langs-en.js | 2 - wp-includes/js/tinymce/langs/wp-langs.php | 2 - .../plugins/wpeditimage/css/editimage.css | 32 -------- .../plugins/wpeditimage/editimage.html | 16 ---- .../plugins/wpeditimage/editor_plugin_src.js | 2 +- .../plugins/wpeditimage/js/editimage.dev.js | 76 +----------------- .../plugins/wpeditimage/js/editimage.js | 2 +- 10 files changed, 29 insertions(+), 260 deletions(-) diff --git a/wp-admin/css/wp-admin.dev.css b/wp-admin/css/wp-admin.dev.css index 1adbf0b98e..d2356a1070 100644 --- a/wp-admin/css/wp-admin.dev.css +++ b/wp-admin/css/wp-admin.dev.css @@ -3888,41 +3888,10 @@ abbr.required { padding-left: 15px; } -.media-item .edit-caption-controls { - margin: 5px 0; - width: 460px; -} - -.media-item .edit-caption-controls label { - margin: 5px 0; - display: block; -} - -.media-item .edit-caption-controls label span { - width: 100px; - float: left; - line-height: 22px; -} - -.media-item .edit-caption-controls input[type="text"] { - width: 335px; -} - -.media-item .caption-insert-link-buttons { - text-align: right; - margin: 5px 12px; -} - -.media-item .caption-insert-link-wrap { - padding: 5px 0 5px 12px; - background-color: #f8f8f8; - border: 1px solid #eee; - -webkit-border-radius: 3px; - border-radius: 3px; -} - -.media-item .post_excerpt textarea { - height: 60px; +.media-item .post_excerpt textarea, +.media-item .post_content textarea, +.media-item textarea#caption { + min-height: 5em; } /*------------------------------------------------------------------------------ diff --git a/wp-admin/includes/media.php b/wp-admin/includes/media.php index a30076996b..5f9740daf0 100644 --- a/wp-admin/includes/media.php +++ b/wp-admin/includes/media.php @@ -149,7 +149,8 @@ function image_add_caption( $html, $id, $caption, $title, $align, $url, $size, $ $width = $matches[1]; - $caption = preg_replace_callback( '/<[a-zA-Z][^<>]+>/', '_cleanup_image_add_caption', $caption ); + // look only for html tags with attributes + $caption = preg_replace_callback( '/<[a-zA-Z0-9]+ [^<>]+>/', '_cleanup_image_add_caption', $caption ); $caption = str_replace( '"', '"', $caption ); $html = preg_replace( '/(class=["\'][^\'"]*)align(none|left|right|center)\s?/', '$1', $html ); @@ -165,12 +166,20 @@ add_filter( 'image_send_to_editor', 'image_add_caption', 20, 8 ); // Private, preg_replace callback used in image_add_caption() function _cleanup_image_add_caption($str) { - if ( isset($str[0]) ) - return str_replace( '"', "'", $str[0] ); + if ( isset($str[0]) ) { + // look for single quotes inside html attributes (for example in title) + $s = preg_replace_callback( '/="[^"]+"/', '_cleanup_image_add_caption2', $str[0] ); + return str_replace( '"', "'", $s ); + } return ''; } +// Private, preg_replace callback used in image_add_caption() +function _cleanup_image_add_caption2($str) { + return str_replace( "'", ''', $str ); +} + /** * {@internal Missing Short Description}} * @@ -795,21 +804,7 @@ function wp_caption_input_textarea($edit_post) { // post data is already escaped $name = "attachments[{$edit_post->ID}][post_excerpt]"; - return ' - -
- -
- '; + return ''; } /** @@ -1547,7 +1542,10 @@ var addExtImage = { if ( f.caption.value ) { - caption = f.caption.value.replace(/<[a-z][^<>]+>/g, function(a){ + caption = f.caption.value.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){ + a = a.replace(/="[^"]+"/, function(b){ + return b.replace(/'/g, '''); + }); return a.replace(/"/g, "'"); }); @@ -1954,7 +1952,7 @@ function wp_media_insert_url_form( $default_view = 'image' ) { - + '; } else { diff --git a/wp-includes/js/plupload/handlers.dev.js b/wp-includes/js/plupload/handlers.dev.js index 3ea0fcfec9..5786febc8d 100644 --- a/wp-includes/js/plupload/handlers.dev.js +++ b/wp-includes/js/plupload/handlers.dev.js @@ -338,48 +338,15 @@ function uploadSizeError( up, file, over100mb ) { } jQuery(document).ready(function($){ - var insert_link, bookmark; - $('.media-upload-form').bind('click.uploader', function(e) { - var target = $(e.target), tr, c, el, textarea, sel, text, startPos, endPos; + var target = $(e.target), tr, c; - if ( target.hasClass('caption-insert-link') ) { - el = target.siblings('div.caption-insert-link-wrap'), textarea = target.parent().siblings('textarea').get(0); - - if ( document.selection ) { - textarea.focus(); - sel = document.selection.createRange(); - bookmark = sel.getBookmark(); - - if ( sel.text ) - el.find('.caption-insert-link-text').val(sel.text); - - } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { - text = textarea.value; - startPos = textarea.selectionStart; - endPos = textarea.selectionEnd; - - if ( startPos != endPos ) - el.find('.caption-insert-link-text').val( text.substring(startPos, endPos) ); - } - - target.hide(); - el.show(); - el.find('.caption-insert-link-url').focus(); - } else if ( target.hasClass('caption-cancel') || target.hasClass('caption-save') ) { - el = target.closest('div.caption-insert-link-wrap'); - - if ( target.hasClass('caption-save') ) - insert_link( el.closest('.edit-caption-controls').siblings('textarea'), el ); - - el.hide(); - el.siblings('.caption-insert-link').show(); - } else if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment + if ( target.is('input[type="radio"]') ) { // remember the last used image size and alignment tr = target.closest('tr'); - if ( $(tr).hasClass('align') ) + if ( tr.hasClass('align') ) setUserSetting('align', target.val()); - else if ( $(tr).hasClass('image-size') ) + else if ( tr.hasClass('image-size') ) setUserSetting('imgsize', target.val()); } else if ( target.is('button.button') ) { // remember the last used image link url @@ -427,45 +394,6 @@ jQuery(document).ready(function($){ e.preventDefault(); } }); - - insert_link = function(textarea, parent) { - var sel, content, startPos, endPos, scrollTop, text, - url = parent.find('.caption-insert-link-url'), link_text = parent.find('.caption-insert-link-text'); - - if ( !url.length || !link_text.length ) - return; - - textarea = textarea.get(0); - content = ""+link_text.val()+""; - - if ( document.selection ) { - textarea.focus(); - sel = document.selection.createRange(); - - if ( bookmark ) { - sel.moveToBookmark( bookmark ); - bookmark = ''; - } - - sel.text = content; - textarea.focus(); - } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { - text = textarea.value; - startPos = textarea.selectionStart; - endPos = textarea.selectionEnd; - scrollTop = textarea.scrollTop; - - textarea.value = text.substring(0, startPos) + content + text.substring(endPos, text.length); - - textarea.focus(); - textarea.selectionStart = startPos + content.length; - textarea.selectionEnd = startPos + content.length; - textarea.scrollTop = scrollTop; - } - - url.val(''); - link_text.val(''); - }; // init and set the uploader uploader_init = function() { diff --git a/wp-includes/js/tinymce/langs/wp-langs-en.js b/wp-includes/js/tinymce/langs/wp-langs-en.js index 6921eab163..53d784a28a 100644 --- a/wp-includes/js/tinymce/langs/wp-langs-en.js +++ b/wp-includes/js/tinymce/langs/wp-langs-en.js @@ -499,7 +499,5 @@ s120:"120%", s130:"130%", img_title:"Title", caption:"Caption", -insert_link:"Insert link", -linked_text:"Linked text", alt:"Alternate Text" }); diff --git a/wp-includes/js/tinymce/langs/wp-langs.php b/wp-includes/js/tinymce/langs/wp-langs.php index 625ef75889..6100383fcd 100644 --- a/wp-includes/js/tinymce/langs/wp-langs.php +++ b/wp-includes/js/tinymce/langs/wp-langs.php @@ -542,8 +542,6 @@ function wp_mce_translation() { 's130' => __('130%'), 'img_title' => __('Title'), 'caption' => __('Caption'), - 'insert_link' => __('Insert link'), - 'linked_text' => __('Linked text'), 'alt' => __('Alternate Text') ); diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css b/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css index 72f313d269..f071fd06fc 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css +++ b/wp-includes/js/tinymce/plugins/wpeditimage/css/editimage.css @@ -357,38 +357,6 @@ div#media-upload-error { color: #CFCFCF; } -#img-edit .edit-caption-controls { - margin: 5px 0; -} - -#img-edit .edit-caption-controls label { - margin: 5px 0; - display: block; -} - -#img-edit .edit-caption-controls label span { - width: 100px; - float: left; - line-height: 22px; -} - -#img-edit .edit-caption-controls input[type="text"] { - width: 335px; -} - -#img-edit .caption-insert-link-buttons { - text-align: right; - margin: 5px 12px; -} - -#img-edit .caption-insert-link-wrap { - padding: 5px 0 5px 12px; - background-color: #f8f8f8; - border: 1px solid #eee; - -webkit-border-radius: 3px; - border-radius: 3px; -} - #img-edit #img_cap_text { font: normal 12px/18px monospace; } diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html b/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html index 643780104f..886cd941e1 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editimage.html @@ -102,22 +102,6 @@ if ( 'rtl' == tinyMCEPopup.editor.getParam('directionality','') ) - -
- - -
diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js index 89cf947b34..11265780dd 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js @@ -186,7 +186,7 @@ cls = ( cls && cls[1] ) ? cls[1] : ''; cls = cls.match(/align[a-z]+/) || 'alignnone'; - cap = cap.replace(/<[a-z][^<>]+>/g, function(a){ + cap = cap.replace(/<[a-zA-Z0-9]+ [^<>]+>/g, function(a){ // look only for html tags with attributes a = a.replace(/="[^"]+"/, function(b){ return b.replace(/'/g, '''); }); diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js b/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js index 5a27d10fcf..213e87b130 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.dev.js @@ -21,7 +21,6 @@ tinyMCEPopup = { tinyMCE = w.tinyMCE; t.editor = tinymce.EditorManager.activeEditor; t.params = t.editor.windowManager.params; - t.events = new tinymce.dom.EventUtils(); // Setup local DOM t.dom = t.editor.windowManager.createInstance('tinymce.dom.DOMUtils', document); @@ -245,7 +244,7 @@ wpImage = { setup : function() { var t = this, c, el, link, fname, f = document.forms[0], ed = tinyMCEPopup.editor, - d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, DD, caption = '', dlc, pa, bookmark, insert_link; + d = t.I('img_demo'), dom = tinyMCEPopup.dom, DL, DD, caption = '', dlc, pa; document.dir = tinyMCEPopup.editor.getParam('directionality',''); @@ -330,79 +329,6 @@ wpImage = { t.showSizeSet(); document.body.style.display = ''; - - tinyMCEPopup.events.add(document.body, 'click', function(e) { - var target = e.target, parent = target.parentNode, tr, c, el, textarea, sel, text, startPos, endPos; - - if ( dom.hasClass(target, 'caption-insert-link') ) { - el = dom.select('div.caption-insert-link-wrap', parent)[0], textarea = dom.select('#img_cap_text')[0]; - - if ( document.selection ) { - textarea.focus(); - sel = document.selection.createRange(); - bookmark = sel.getBookmark(); - - if ( sel.text ) - dom.select('.caption-insert-link-text', el)[0].value = sel.text; - - } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { - text = textarea.value; - startPos = textarea.selectionStart; - endPos = textarea.selectionEnd; - - if ( startPos != endPos ) - dom.select('.caption-insert-link-text', el)[0].value = text.substring(startPos, endPos); - } - - dom.hide(target); - dom.show(el); - dom.select('.caption-insert-link-url', el)[0].focus(); - } else if ( dom.hasClass(target, 'caption-cancel') || dom.hasClass(target, 'caption-save') ) { - if ( dom.hasClass(target, 'caption-save') ) - insert_link(); - - dom.hide( dom.select('.caption-insert-link-wrap') ); - dom.show( dom.select('.caption-insert-link') ); - } - }); - - insert_link = function() { - var sel, content, startPos, endPos, scrollTop, text, textarea = dom.select('#img_cap_text')[0], - url = dom.select('.caption-insert-link-url')[0], link_text = dom.select('.caption-insert-link-text')[0]; - - if ( !url || !link_text ) - return; - - content = ""+link_text.value+""; - - if ( document.selection ) { - textarea.focus(); - sel = document.selection.createRange(); - - if ( bookmark ) { - sel.moveToBookmark( bookmark ); - bookmark = ''; - } - - sel.text = content; - textarea.focus(); - } else if ( textarea.selectionStart || textarea.selectionStart == '0' ) { - text = textarea.value; - startPos = textarea.selectionStart; - endPos = textarea.selectionEnd; - scrollTop = textarea.scrollTop; - - textarea.value = text.substring(0, startPos) + content + text.substring(endPos, text.length); - - textarea.focus(); - textarea.selectionStart = startPos + content.length; - textarea.selectionEnd = startPos + content.length; - textarea.scrollTop = scrollTop; - } - - url.value = ''; - link_text.value = ''; - }; }, remove : function() { diff --git a/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js b/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js index b37ebc33dd..2a74235d42 100644 --- a/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js +++ b/wp-includes/js/tinymce/plugins/wpeditimage/js/editimage.js @@ -1 +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;cparseInt(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/,"").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=""+c.value+"";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(/]+>/i);l=l+g.dom.getOuterHTML(e)+""}}else{l=g.dom.getOuterHTML(e)}l='
'+l+'
'+v.img_cap_text.value+"
";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(); \ No newline at end of file +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;cparseInt(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/,"").replace(/<\/p>$/,"")}}j.img_cap_text.value=p;j.img_title.value=i.dom.getAttrib(b,"title");j.img_alt.value=i.dom.getAttrib(b,"alt");j.border.value=i.dom.getAttrib(b,"border");j.vspace.value=i.dom.getAttrib(b,"vspace");j.hspace.value=i.dom.getAttrib(b,"hspace");j.align.value=i.dom.getAttrib(b,"align");j.width.value=q.width=i.dom.getAttrib(b,"width");j.height.value=q.height=i.dom.getAttrib(b,"height");j.img_classes.value=l;j.img_style.value=i.dom.getAttrib(b,"style");if(h.getAttrib(b,"hspace")){q.updateStyle("hspace")}if(h.getAttrib(b,"border")){q.updateStyle("border")}if(h.getAttrib(b,"vspace")){q.updateStyle("vspace")}if(n=i.dom.getParent(b,"A")){j.link_href.value=q.current=i.dom.getAttrib(n,"href");j.link_title.value=i.dom.getAttrib(n,"title");j.link_rel.value=q.link_rel=i.dom.getAttrib(n,"rel");j.link_style.value=i.dom.getAttrib(n,"style");q.target_value=i.dom.getAttrib(n,"target");j.link_classes.value=i.dom.getAttrib(n,"class")}j.link_target.checked=(q.target_value&&q.target_value=="_blank")?"checked":"";e=m.substring(m.lastIndexOf("/"));e=e.replace(/-[0-9]{2,4}x[0-9]{2,4}/,"");q.link=m.substring(0,m.lastIndexOf("/"))+e;if(l.indexOf("alignleft")!=-1){q.I("alignleft").checked="checked";k.className=q.align="alignleft"}else{if(l.indexOf("aligncenter")!=-1){q.I("aligncenter").checked="checked";k.className=q.align="aligncenter"}else{if(l.indexOf("alignright")!=-1){q.I("alignright").checked="checked";k.className=q.align="alignright"}else{if(l.indexOf("alignnone")!=-1){q.I("alignnone").checked="checked";k.className=q.align="alignnone"}}}}if(q.width&&q.preloadImg.width){q.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_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(/]+>/i);l=l+g.dom.getOuterHTML(e)+""}}else{l=g.dom.getOuterHTML(e)}l='
'+l+'
'+v.img_cap_text.value+"
";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(); \ No newline at end of file