Ticket #28532: 28532.diff
File 28532.diff, 4.8 KB (added by , 11 years ago) |
---|
-
wp-includes/js/mce-view.js
687 687 return this.template({ content: this.parsed }); 688 688 } 689 689 } ), 690 edit: function() {} 690 691 edit: function( node ) { 692 var embed = media.embed, 693 self = this, 694 frame, data; 695 696 $( document ).trigger( 'media:edit' ); 697 698 data = window.decodeURIComponent( $( node ).attr('data-wpview-text') ); 699 frame = embed.edit( data ); 700 frame.on( 'close', function() { 701 frame.detach(); 702 } ); 703 frame.state( 'embed' ).props.on( 'change:url', function (model, url) { 704 if ( ! url ) { 705 return; 706 } 707 frame.state( 'embed' ).metadata = model.toJSON(); 708 } ); 709 frame.state( 'embed' ).on( 'select', function() { 710 var shortcode = embed.shortcode( frame.state( 'embed' ).metadata ).string(); 711 $( node ).attr( 'data-wpview-text', window.encodeURIComponent( shortcode ) ); 712 wp.mce.views.refreshView( self, shortcode ); 713 frame.detach(); 714 } ); 715 frame.open(); 716 } 691 717 } ); 692 718 693 719 }(jQuery)); -
wp-includes/js/media-editor.js
298 298 } 299 299 }; 300 300 301 wp.media.embed = { 302 coerce : wp.media.coerce, 303 304 defaults : { 305 url : '', 306 width: '', 307 height: '' 308 }, 309 310 edit : function( data ) { 311 var frame, props = {}, 312 shortcode = wp.shortcode.next( 'embed', data ).shortcode; 313 314 props = _.defaults( shortcode.attrs.named, this.defaults ); 315 if ( shortcode.content ) { 316 props.url = shortcode.content; 317 } 318 319 frame = wp.media({ 320 frame: 'post', 321 state: 'embed', 322 metadata: props 323 }); 324 325 return frame; 326 }, 327 328 shortcode : function( model ) { 329 var self = this, content; 330 331 _.each( this.defaults, function( value, key ) { 332 model[ key ] = self.coerce( model, key ); 333 334 if ( value === model[ key ] ) { 335 delete model[ key ]; 336 } 337 }); 338 339 content = model.url; 340 delete model.url; 341 342 return new wp.shortcode({ 343 tag: 'embed', 344 attrs: model, 345 content: content 346 }); 347 } 348 }; 349 301 350 wp.media.collection = function(attributes) { 302 351 var collections = {}; 303 352 -
wp-includes/js/media-views.js
1402 1402 1403 1403 priority: 120, 1404 1404 type: 'link', 1405 url: '' 1405 url: '', 1406 metadata: {} 1406 1407 }, 1407 1408 1408 1409 // The amount of time used when debouncing the scan. 1409 1410 sensitivity: 200, 1410 1411 1411 initialize: function() { 1412 initialize: function(options) { 1413 this.metadata = options.metadata; 1412 1414 this.debouncedScan = _.debounce( _.bind( this.scan, this ), this.sensitivity ); 1413 this.props = new Backbone.Model( { url: '' });1415 this.props = new Backbone.Model( this.metadata || { url: '' }); 1414 1416 this.props.on( 'change:url', this.debouncedScan, this ); 1415 1417 this.props.on( 'change:url', this.refresh, this ); 1416 1418 this.on( 'scan', this.scanImage, this ); … … 2278 2280 _.defaults( this.options, { 2279 2281 multiple: true, 2280 2282 editing: false, 2281 state: 'insert' 2283 state: 'insert', 2284 metadata: {} 2282 2285 }); 2283 2286 /** 2284 2287 * call 'initialize' directly on the parent class … … 2330 2333 }), 2331 2334 2332 2335 // Embed states. 2333 new media.controller.Embed( ),2336 new media.controller.Embed( { metadata: options.metadata } ), 2334 2337 2335 2338 new media.controller.EditImage( { model: options.editImage } ), 2336 2339 … … 6440 6443 }, 6441 6444 6442 6445 initialize: function() { 6443 this.$input = $('<input id="embed-url-field" />').attr( 'type', 'text' ).val( this.model.get('url') ); 6446 var self = this; 6447 6448 this.$input = $('<input id="embed-url-field" type="text" />').val( this.model.get('url') ); 6444 6449 this.input = this.$input[0]; 6445 6450 6446 6451 this.spinner = $('<span class="spinner" />')[0]; … … 6447 6452 this.$el.append([ this.input, this.spinner ]); 6448 6453 6449 6454 this.model.on( 'change:url', this.render, this ); 6455 6456 if ( this.model.get( 'url' ) ) { 6457 _.delay( function () { 6458 self.model.trigger( 'change:url' ); 6459 }, 500 ); 6460 } 6450 6461 }, 6451 6462 /** 6452 6463 * @returns {wp.media.view.EmbedUrl} Returns itself to allow chaining -
wp-includes/media-template.php
1077 1077 1078 1078 <script type="text/html" id="tmpl-editor-embed"> 1079 1079 <div class="toolbar"> 1080 <div class="dashicons dashicons-edit edit"></div> 1080 1081 <div class="dashicons dashicons-no-alt remove"></div> 1081 1082 </div> 1082 1083 {{{ data.content }}}