Changeset 21254
- Timestamp:
- 07/10/2012 02:31:30 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js
r21232 r21254 12 12 t._createButtons(); 13 13 14 // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...'); 15 ed.addCommand('WP_EditImage', function() { 16 var el = ed.selection.getNode(), vp, H, W, cls = ed.dom.getAttrib(el, 'class'); 17 18 if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' ) 19 return; 20 21 vp = tinymce.DOM.getViewPort(); 22 H = 680 < (vp.h - 70) ? 680 : vp.h - 70; 23 W = 650 < vp.w ? 650 : vp.w; 24 25 ed.windowManager.open({ 26 file: url + '/editimage.html', 27 width: W+'px', 28 height: H+'px', 29 inline: true 30 }); 31 }); 14 ed.addCommand('WP_EditImage', t._editImage); 32 15 33 16 ed.onInit.add(function(ed) { … … 37 20 if ( e.target.nodeName == 'IMG' && ( parent = ed.dom.getParent(e.target, 'div.mceTemp') ) ) { 38 21 ed.selection.select(parent); 22 } 23 }); 24 25 // when pressing Return inside a caption move the caret to a new parapraph under it 26 ed.dom.events.add(ed.getBody(), 'keydown', function(e) { 27 var n, DL, DIV, P, content; 28 29 if ( e.keyCode == 13 ) { 30 n = ed.selection.getNode(); 31 DL = ed.dom.getParent(n, 'dl.wp-caption'); 32 33 if ( DL ) 34 DIV = ed.dom.getParent(DL, 'div.mceTemp'); 35 36 if ( DIV ) { 37 ed.dom.events.cancel(e); 38 P = ed.dom.create('p', {}, '\uFEFF'); 39 ed.dom.insertAfter( P, DIV ); 40 ed.selection.setCursorLocation(P, 0); 41 return false; 42 } 39 43 } 40 44 }); … … 91 95 }); 92 96 93 // when pressing Return inside a caption move the caret to a new parapraph under it94 ed.onKeyPress.add(function(ed, e) {95 var n, DL, DIV, P;96 97 if ( e.keyCode == 13 ) {98 n = ed.selection.getNode();99 DL = ed.dom.getParent(n, 'dl.wp-caption');100 101 if ( DL )102 DIV = ed.dom.getParent(DL, 'div.mceTemp');103 104 if ( DIV ) {105 P = ed.dom.create('p', {}, '<br>');106 ed.dom.insertAfter( P, DIV );107 ed.selection.select(P.firstChild);108 109 if ( tinymce.isIE ) {110 ed.selection.setContent('');111 } else {112 ed.selection.setContent('<br _moz_dirty="">');113 ed.selection.setCursorLocation(P, 0);114 }115 116 ed.dom.events.cancel(e);117 return false;118 }119 }120 });121 122 97 ed.onBeforeSetContent.add(function(ed, o) { 123 98 o.content = ed.wpSetImgCaption(o.content); … … 240 215 241 216 tinymce.dom.Event.add(editButton, 'mousedown', function(e) { 242 var ed = tinyMCE.activeEditor; 243 ed.windowManager.bookmark = ed.selection.getBookmark('simple'); 244 ed.execCommand("WP_EditImage"); 217 t._editImage(); 245 218 }); 246 219 … … 267 240 return false; 268 241 } 242 }); 243 }, 244 245 _editImage : function() { 246 var ed = this.editor, url = this.url, el = ed.selection.getNode(), vp, H, W, cls = el.className; 247 248 if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' ) 249 return; 250 251 vp = tinymce.DOM.getViewPort(); 252 H = 680 < (vp.h - 70) ? 680 : vp.h - 70; 253 W = 650 < vp.w ? 650 : vp.w; 254 255 ed.windowManager.open({ 256 file: url + '/editimage.html', 257 width: W+'px', 258 height: H+'px', 259 inline: true 269 260 }); 270 261 },
Note: See TracChangeset
for help on using the changeset viewer.