wp/wp-includes/js/tinymce/plugins/wpgallery/plugin.js
changeset 16 a86126ab1dd4
parent 7 cf61fcea0001
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    55 				frame.detach();
    55 				frame.detach();
    56 			});
    56 			});
    57 		}
    57 		}
    58 	}
    58 	}
    59 
    59 
    60 	// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...');
    60 	// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('...').
    61 	editor.addCommand( 'WP_Gallery', function() {
    61 	editor.addCommand( 'WP_Gallery', function() {
    62 		editMedia( editor.selection.getNode() );
    62 		editMedia( editor.selection.getNode() );
    63 	});
    63 	});
    64 
    64 
    65 	editor.on( 'mouseup', function( event ) {
    65 	editor.on( 'mouseup', function( event ) {
    69 		function unselect() {
    69 		function unselect() {
    70 			dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' );
    70 			dom.removeClass( dom.select( 'img.wp-media-selected' ), 'wp-media-selected' );
    71 		}
    71 		}
    72 
    72 
    73 		if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
    73 		if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
    74 			// Don't trigger on right-click
    74 			// Don't trigger on right-click.
    75 			if ( event.button !== 2 ) {
    75 			if ( event.button !== 2 ) {
    76 				if ( dom.hasClass( node, 'wp-media-selected' ) ) {
    76 				if ( dom.hasClass( node, 'wp-media-selected' ) ) {
    77 					editMedia( node );
    77 					editMedia( node );
    78 				} else {
    78 				} else {
    79 					unselect();
    79 					unselect();
    83 		} else {
    83 		} else {
    84 			unselect();
    84 			unselect();
    85 		}
    85 		}
    86 	});
    86 	});
    87 
    87 
    88 	// Display gallery, audio or video instead of img in the element path
    88 	// Display gallery, audio or video instead of img in the element path.
    89 	editor.on( 'ResolveName', function( event ) {
    89 	editor.on( 'ResolveName', function( event ) {
    90 		var dom = editor.dom,
    90 		var dom = editor.dom,
    91 			node = event.target;
    91 			node = event.target;
    92 
    92 
    93 		if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
    93 		if ( node.nodeName === 'IMG' && dom.getAttrib( node, 'data-wp-media' ) ) {
    96 			}
    96 			}
    97 		}
    97 		}
    98 	});
    98 	});
    99 
    99 
   100 	editor.on( 'BeforeSetContent', function( event ) {
   100 	editor.on( 'BeforeSetContent', function( event ) {
   101 		// 'wpview' handles the gallery shortcode when present
   101 		// 'wpview' handles the gallery shortcode when present.
   102 		if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) {
   102 		if ( ! editor.plugins.wpview || typeof wp === 'undefined' || ! wp.mce ) {
   103 			event.content = replaceGalleryShortcodes( event.content );
   103 			event.content = replaceGalleryShortcodes( event.content );
   104 		}
   104 		}
   105 	});
   105 	});
   106 
   106