Make WordPress Core

Changeset 22857


Ignore:
Timestamp:
11/27/2012 01:31:51 AM (14 years ago)
Author:
azaozz
Message:

TinyMCE: improve hiding of the image/gallery popup buttons, fix selecting a gallery in IE, don't leave empty paragraph after deleting an image with the popup button, fixes #22463, see #21390

Location:
trunk/wp-includes/js/tinymce/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin_src.js

    r22652 r22857  
    77
    88        tinymce.create('tinymce.plugins.WordPress', {
    9                 showButtons : 0,
    10 
    119                init : function(ed, url) {
    1210                        var t = this, tbId = ed.getParam('wordpress_adv_toolbar', 'toolbar2'), last = 0, moreHTML, nextpageHTML, closeOnClick, mod_key;
     
    375373                                'display' : 'block'
    376374                        });
    377 
    378                         this.showButtons = true;
    379375                },
    380376
    381377                _hideButtons : function() {
    382                         if ( ! this.showButtons )
    383                                 return;
    384 
    385                         if ( document.getElementById('wp_editbtns') )
    386                                 tinymce.DOM.hide('wp_editbtns');
    387 
    388                         if ( document.getElementById('wp_gallerybtns') )
    389                                 tinymce.DOM.hide('wp_gallerybtns');
    390 
    391                         this.showButtons = false;
     378                        tinymce.DOM.hide(['wp_editbtns', 'wp_gallerybtns']);
    392379                },
    393380
  • trunk/wp-includes/js/tinymce/plugins/wpeditimage/editor_plugin_src.js

    r22644 r22857  
    206206
    207207                _createButtons : function() {
    208                         var t = this, ed = t.editor, DOM = tinymce.DOM, editButton, dellButton, isRetina;
     208                        var t = this, ed = tinymce.activeEditor, DOM = tinymce.DOM, editButton, dellButton, isRetina;
     209
     210                        if ( DOM.get('wp_editbtns') )
     211                                return;
    209212
    210213                        isRetina = ( window.devicePixelRatio && window.devicePixelRatio > 1 ) || // WebKit, Opera
    211214                                ( window.matchMedia && window.matchMedia('(min-resolution:130dpi)').matches ); // Firefox, IE10, Opera
    212 
    213                         DOM.remove('wp_editbtns');
    214215
    215216                        DOM.add(document.body, 'div', {
     
    240241
    241242                        tinymce.dom.Event.add(dellButton, 'mousedown', function(e) {
    242                                 var el = ed.selection.getNode(), p;
     243                                var ed = tinymce.activeEditor, el = ed.selection.getNode(), parent;
    243244
    244245                                if ( el.nodeName == 'IMG' && ed.dom.getAttrib(el, 'class').indexOf('mceItem') == -1 ) {
    245                                         if ( (p = ed.dom.getParent(el, 'div')) && ed.dom.hasClass(p, 'mceTemp') )
    246                                                 ed.dom.remove(p);
    247                                         else if ( (p = ed.dom.getParent(el, 'A')) && p.childNodes.length == 1 )
    248                                                 ed.dom.remove(p);
    249                                         else
     246                                        if ( (parent = ed.dom.getParent(el, 'div')) && ed.dom.hasClass(parent, 'mceTemp') ) {
     247                                                ed.dom.remove(parent);
     248                                        } else {
     249                                                if ( el.parentNode.nodeName == 'A' && el.parentNode.childNodes.length == 1 )
     250                                                        el = el.parentNode;
     251
     252                                                if ( el.parentNode.nodeName == 'P' && el.parentNode.childNodes.length == 1 )
     253                                                        el = el.parentNode;
     254
    250255                                                ed.dom.remove(el);
     256                                        }
    251257
    252258                                        ed.execCommand('mceRepaint');
     
    258264               
    259265                _editImage : function() {
    260                         var ed = this.editor, url = this.url, el = ed.selection.getNode(), vp, H, W, cls = el.className;
     266                        var ed = tinymce.activeEditor, url = this.url, el = ed.selection.getNode(), vp, H, W, cls = el.className;
    261267
    262268                        if ( cls.indexOf('mceItem') != -1 || cls.indexOf('wpGallery') != -1 || el.nodeName != 'IMG' )
  • trunk/wp-includes/js/tinymce/plugins/wpgallery/editor_plugin_src.js

    r22602 r22857  
    1212                        // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
    1313                        ed.addCommand('WP_Gallery', function() {
     14                                if ( tinymce.isIE )
     15                                        ed.selection.moveToBookmark( ed.wpGalleryBookmark );
     16
    1417                                var el = ed.selection.getNode(),
    1518                                        gallery = wp.media.gallery,
     
    5053                        ed.onMouseDown.add(function(ed, e) {
    5154                                if ( e.target.nodeName == 'IMG' && ed.dom.hasClass(e.target, 'wpGallery') ) {
     55                                        ed.plugins.wordpress._hideButtons();
    5256                                        ed.plugins.wordpress._showButtons(e.target, 'wp_gallerybtns');
    5357                                }
     
    8892
    8993                _createButtons : function() {
    90                         var t = this, ed = t.editor, DOM = tinymce.DOM, editButton, dellButton, isRetina;
     94                        var t = this, ed = tinymce.activeEditor, DOM = tinymce.DOM, editButton, dellButton, isRetina;
     95
     96                        if ( DOM.get('wp_gallerybtns') )
     97                                return;
    9198
    9299                        isRetina = ( window.devicePixelRatio && window.devicePixelRatio > 1 ) || // WebKit, Opera
    93100                                ( window.matchMedia && window.matchMedia('(min-resolution:130dpi)').matches ); // Firefox, IE10, Opera
    94 
    95                         DOM.remove('wp_gallerybtns');
    96101
    97102                        DOM.add(document.body, 'div', {
     
    109114
    110115                        tinymce.dom.Event.add(editButton, 'mousedown', function(e) {
    111                                 ed.windowManager.bookmark = ed.selection.getBookmark('simple');
     116                                var ed = tinymce.activeEditor;
     117                                ed.wpGalleryBookmark = ed.selection.getBookmark('simple');
    112118                                ed.execCommand("WP_Gallery");
    113119                                ed.plugins.wordpress._hideButtons();
     
    123129
    124130                        tinymce.dom.Event.add(dellButton, 'mousedown', function(e) {
    125                                 var el = ed.selection.getNode();
     131                                var ed = tinymce.activeEditor, el = ed.selection.getNode();
    126132
    127133                                if ( el.nodeName == 'IMG' && ed.dom.hasClass(el, 'wpGallery') ) {
Note: See TracChangeset for help on using the changeset viewer.