Make WordPress Core

Ticket #33096: 33096.2.patch

File 33096.2.patch, 4.7 KB (added by iseulde, 11 years ago)
  • src/wp-includes/js/mce-view.js

     
    11/* global tinymce */
    22
    3 window.wp = window.wp || {};
    4 
    53/*
    64 * The TinyMCE view API.
    75 *
     
    2422 * |- registered view
    2523 * |  |- ...
    2624 */
    27 ( function( window, wp, $ ) {
     25( function( window, wp, shortcode, $ ) {
    2826        'use strict';
    2927
    3028        var views = {},
     
    671669                 * @return {Object}
    672670                 */
    673671                match: function( content ) {
    674                         var match = wp.shortcode.next( this.type, content );
     672                        var match = shortcode.next( this.type, content );
    675673
    676674                        if ( match ) {
    677675                                return {
     
    720718                        editor.focus();
    721719                }
    722720        } );
    723 } )( window, window.wp, window.jQuery );
     721} )( window, window.wp, window.wp.shortcode, window.jQuery );
    724722
    725723/*
    726724 * The WordPress core TinyMCE views.
    727725 * Views for the gallery, audio, video, playlist and embed shortcodes,
    728726 * and a view for embeddable URLs.
    729727 */
    730 ( function( window, views, $ ) {
    731         var postID = $( '#post_ID' ).val() || 0,
    732                 media, gallery, av, embed;
     728( function( window, views, media ) {
     729        var base, gallery, av, embed;
    733730
    734         media = {
     731        base = {
    735732                state: [],
    736733
    737734                edit: function( text, update ) {
    738735                        var type = this.type,
    739                                 media = wp.media[ type ],
    740                                 frame = media.edit( text );
     736                                frame = media[ type ].edit( text );
    741737
    742738                        this.pausePlayers && this.pausePlayers();
    743739
    744740                        _.each( this.state, function( state ) {
    745741                                frame.state( state ).on( 'update', function( selection ) {
    746                                         update( media.shortcode( selection ).string(), type === 'gallery' );
     742                                        update( media[ type ].shortcode( selection ).string(), type === 'gallery' );
    747743                                } );
    748744                        } );
    749745
     
    755751                }
    756752        };
    757753
    758         gallery = _.extend( {}, media, {
     754        gallery = _.extend( {}, base, {
    759755                state: [ 'gallery-edit' ],
    760                 template: wp.media.template( 'editor-gallery' ),
     756                template: media.template( 'editor-gallery' ),
    761757
    762758                initialize: function() {
    763                         var attachments = wp.media.gallery.attachments( this.shortcode, postID ),
     759                        var attachments = media.gallery.attachments( this.shortcode, media.view.settings.post.id ),
    764760                                attrs = this.shortcode.attrs.named,
    765761                                self = this;
    766762
     
    782778
    783779                                self.render( self.template( {
    784780                                        attachments: attachments,
    785                                         columns: attrs.columns ? parseInt( attrs.columns, 10 ) : wp.media.galleryDefaults.columns
     781                                        columns: attrs.columns ? parseInt( attrs.columns, 10 ) : media.galleryDefaults.columns
    786782                                } ) );
    787783                        } )
    788784                        .fail( function( jqXHR, textStatus ) {
     
    791787                }
    792788        } );
    793789
    794         av = _.extend( {}, media, {
     790        av = _.extend( {}, base, {
    795791                action: 'parse-media-shortcode',
    796792
    797793                initialize: function() {
     
    799795
    800796                        if ( this.url ) {
    801797                                this.loader = false;
    802                                 this.shortcode = wp.media.embed.shortcode( {
     798                                this.shortcode = media.embed.shortcode( {
    803799                                        url: this.text
    804800                                } );
    805801                        }
    806802
    807803                        wp.ajax.post( this.action, {
    808                                 post_ID: postID,
     804                                post_ID: media.view.settings.post.id,
    809805                                type: this.shortcode.tag,
    810806                                shortcode: this.shortcode.string()
    811807                        } )
     
    846842                action: 'parse-embed',
    847843
    848844                edit: function( text, update ) {
    849                         var media = wp.media.embed,
    850                                 frame = media.edit( text, this.url ),
     845                        var frame = media.embed.edit( text, this.url ),
    851846                                self = this;
    852847
    853848                        this.pausePlayers();
     
    864859                                if ( self.url ) {
    865860                                        update( data.url );
    866861                                } else {
    867                                         update( media.shortcode( data ).string() );
     862                                        update( media.embed.shortcode( data ).string() );
    868863                                }
    869864                        } );
    870865
     
    908903                        }
    909904                }
    910905        } ) );
    911 } )( window, window.wp.mce.views, window.jQuery );
     906} )( window, window.wp.mce.views, window.wp.media );
  • src/wp-includes/script-loader.php

     
    456456        $scripts->add( 'media-views',  "/wp-includes/js/media-views$suffix.js",  array( 'utils', 'media-models', 'wp-plupload', 'jquery-ui-sortable', 'wp-mediaelement' ), false, 1 );
    457457        $scripts->add( 'media-editor', "/wp-includes/js/media-editor$suffix.js", array( 'shortcode', 'media-views' ), false, 1 );
    458458        $scripts->add( 'media-audiovideo', "/wp-includes/js/media-audiovideo$suffix.js", array( 'media-editor' ), false, 1 );
    459         $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'media-models', 'media-audiovideo', 'wp-playlist' ), false, 1 );
     459        $scripts->add( 'mce-view', "/wp-includes/js/mce-view$suffix.js", array( 'shortcode', 'jquery', 'media-views', 'media-audiovideo' ), false, 1 );
    460460
    461461        if ( is_admin() ) {
    462462                $scripts->add( 'admin-tags', "/wp-admin/js/tags$suffix.js", array( 'jquery', 'wp-ajax-response' ), false, 1 );