Changeset 22523
- Timestamp:
- 11/10/2012 07:51:37 AM (12 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/media.php
r22489 r22523 1276 1276 */ 1277 1277 function media_upload_header() { 1278 ?>1279 <script type="text/javascript">post_id = <?php echo intval($_REQUEST['post_id']); ?>;</script>1280 <div id="media-upload-header">1281 <?php the_media_upload_tabs(); ?>1282 </div>1283 <?php1278 echo '<script type="text/javascript">post_id = ' . intval( $_REQUEST['post_id'] ) . ";</script>\n"; 1279 if ( empty( $_GET['chromeless'] ) ) { 1280 echo '<div id="media-upload-header">'; 1281 the_media_upload_tabs(); 1282 echo '</div>'; 1283 } 1284 1284 } 1285 1285 -
trunk/wp-includes/css/media-views.css
r22466 r22523 252 252 .media-frame .media-toolbar .add-to-gallery { 253 253 display: none; 254 } 255 256 /** 257 * Iframes 258 */ 259 .media-frame .media-iframe { 260 overflow: hidden; 261 } 262 263 .media-iframe iframe { 264 height: 100%; 265 width: 100%; 254 266 } 255 267 -
trunk/wp-includes/js/media-models.js
r22495 r22523 31 31 32 32 delete attributes.frame; 33 // Set the default state. 34 frame.state( frame.options.state ); 35 // Render, attach, and open the frame. 33 36 return frame.render().attach().open(); 34 37 }; -
trunk/wp-includes/js/media-views.js
r22509 r22523 8 8 // Link any localized strings. 9 9 l10n = media.view.l10n = _.isUndefined( _wpMediaViewsL10n ) ? {} : _wpMediaViewsL10n; 10 11 // Link any settings. 12 media.view.settings = l10n.settings || {}; 13 delete l10n.settings; 10 14 11 15 // Check if the browser supports CSS 3.0 transitions … … 551 555 _createStates: function() { 552 556 // Create the default `states` collection. 553 this.states = new Backbone.Collection(); 557 this.states = new Backbone.Collection( null, { 558 model: media.controller.State 559 }); 554 560 555 561 // Ensure states have a reference to the frame. … … 626 632 627 633 return this; 634 }, 635 636 createIframeStates: function( options ) { 637 var settings = media.view.settings, 638 tabs = settings.tabs, 639 tabUrl = settings.tabUrl, 640 $postId; 641 642 if ( ! tabs || ! tabUrl ) 643 return; 644 645 // Add the post ID to the tab URL if it exists. 646 $postId = $('#post_ID'); 647 if ( $postId.length ) 648 tabUrl += '&post_id=' + $postId.val(); 649 650 // Generate the tab states. 651 _.each( tabs, function( title, id ) { 652 var frame = this.get( 'iframe:' + id ).set( _.defaults({ 653 tab: id, 654 src: tabUrl + '&tab=' + id, 655 title: title, 656 content: 'iframe', 657 menu: 'main' 658 }, options ) ); 659 }, this ); 660 661 this.content.on( 'activate:iframe', this.iframeContent, this ); 662 this.menu.on( 'activate:main', this.iframeMenu, this ); 663 this.on( 'open', this.hijackThickbox, this ); 664 this.on( 'close', this.restoreThickbox, this ); 665 }, 666 667 iframeContent: function() { 668 this.$el.addClass('hide-toolbar hide-sidebar'); 669 this.content.view( new media.view.Iframe({ 670 controller: this 671 }).render() ); 672 }, 673 674 iframeMenu: function() { 675 var views = {}; 676 677 _.each( media.view.settings.tabs, function( title, id ) { 678 views[ 'iframe:' + id ] = { 679 text: this.get( 'iframe:' + id ).get('title'), 680 priority: 200 681 }; 682 }, this ); 683 684 this.menu.view().add( views ); 685 }, 686 687 hijackThickbox: function() { 688 var frame = this; 689 690 if ( ! window.tb_remove || this._tb_remove ) 691 return; 692 693 this._tb_remove = window.tb_remove; 694 window.tb_remove = function() { 695 frame.close(); 696 frame.reset(); 697 frame.state( frame.options.state ); 698 frame._tb_remove.call( window ); 699 }; 700 }, 701 702 restoreThickbox: function() { 703 if ( ! this._tb_remove ) 704 return; 705 706 window.tb_remove = this._tb_remove; 707 delete this._tb_remove; 628 708 } 629 709 }); … … 632 712 _.each(['open','close','attach','detach'], function( method ) { 633 713 media.view.MediaFrame.prototype[ method ] = function( view ) { 714 this.trigger( method ); 634 715 if ( this.modal ) 635 716 this.modal[ method ].apply( this.modal, arguments ); … … 655 736 this.createStates(); 656 737 this.bindHandlers(); 657 658 // Set the default state.659 this.state( this.options.state );660 738 }, 661 739 … … 810 888 811 889 media.view.MediaFrame.Select.prototype.initialize.apply( this, arguments ); 890 this.createIframeStates(); 812 891 }, 813 892 … … 2506 2585 } 2507 2586 }); 2587 2588 /** 2589 * wp.media.view.Iframe 2590 */ 2591 media.view.Iframe = Backbone.View.extend({ 2592 className: 'media-iframe', 2593 2594 initialize: function() { 2595 this.controller = this.options.controller; 2596 }, 2597 2598 render: function() { 2599 this.$el.html( '<iframe src="' + this.controller.state().get('src') + '" />' ); 2600 return this; 2601 } 2602 }); 2508 2603 }(jQuery)); -
trunk/wp-includes/media.php
r22516 r22523 1298 1298 */ 1299 1299 function wp_enqueue_media() { 1300 // We're going to pass the old thickbox media tabs to `media_upload_tabs` 1301 // to ensure plugins will work. We will then unset those tabs. 1302 $tabs = array( 1303 // handler action suffix => tab text 1304 'type' => __('From Computer'), 1305 'type_url' => __('From URL'), 1306 'gallery' => __('Gallery'), 1307 'library' => __('Media Library'), 1308 ); 1309 1310 $tabs = apply_filters( 'media_upload_tabs', $tabs ); 1311 unset( $tabs['type'], $tabs['type_url'], $tabs['gallery'], $tabs['library'] ); 1312 1313 $settings = array( 1314 'tabs' => $tabs, 1315 'tabUrl' => add_query_arg( array( 1316 'chromeless' => true 1317 ), admin_url('media-upload.php') ), 1318 ); 1319 1300 1320 wp_localize_script( 'media-views', '_wpMediaViewsL10n', array( 1321 // Settings 1322 'settings' => $settings, 1323 1301 1324 // Generic 1302 1325 'insertMedia' => __( 'Insert Media' ),
Note: See TracChangeset
for help on using the changeset viewer.