Ticket #27423: 27423.17.patch
File 27423.17.patch, 12.8 KB (added by , 10 years ago) |
---|
-
src/wp-includes/css/media-views.css
700 700 */ 701 701 .attachments { 702 702 margin: 0; 703 padding -right: 16px;703 padding: 8px; 704 704 -webkit-overflow-scrolling: touch; 705 705 } 706 706 … … 710 710 .attachment { 711 711 position: relative; 712 712 float: left; 713 padding: 0;714 margin: 0 10px 20px;713 padding: 8px; 714 margin: 0; 715 715 color: #464646; 716 cursor: pointer; 716 717 list-style: none; 717 718 text-align: center; 718 719 -webkit-user-select: none; … … 719 720 -moz-user-select: none; 720 721 -ms-user-select: none; 721 722 user-select: none; 723 width: 20%; 724 box-sizing: border-box; 722 725 } 723 726 724 727 .attachment:focus { 725 728 -webkit-box-shadow: 726 0 0 0 1px #5b9dd9,727 0 0 2px 2px #5b9dd9;729 inset 0 0 0 5px #fff, 730 inset 0 0 1px 7px #5b9dd9; 728 731 box-shadow: 729 0 0 0 1px #5b9dd9,730 0 0 2px 2px #5b9dd9;732 inset 0 0 0 5px #fff, 733 inset 0 0 1px 7px #5b9dd9; 731 734 outline: none; 732 735 } 733 736 734 737 .selected.attachment { 735 738 -webkit-box-shadow: 736 0 0 0 1px #fff,737 0 0 0 3px #ccc;739 inset 0 0 0 5px #fff, 740 inset 0 0 0 7px #ccc; 738 741 box-shadow: 739 0 0 0 1px #fff,740 0 0 0 3px #ccc;742 inset 0 0 0 5px #fff, 743 inset 0 0 0 7px #ccc; 741 744 } 742 745 743 .selected.attachment:focus {744 -webkit-box-shadow:745 0 0 0 1px #fff,746 0 0 0 5px #1e8cbe;747 box-shadow:748 0 0 0 1px #fff,749 0 0 0 5px #1e8cbe;750 }751 752 746 .attachment-preview { 753 747 position: relative; 754 width: 199px;755 height: 199px;756 -webkit-box-shadow:757 inset 0 0 15px rgba( 0, 0, 0, 0.1 ),758 inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );759 box-shadow:760 inset 0 0 15px rgba( 0, 0, 0, 0.1 ),761 inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );762 background: #eee;763 cursor: pointer;764 748 } 765 749 750 .attachment-preview:before { 751 content: ''; 752 display: block; 753 padding-top: 100%; 754 } 755 766 756 .attachment .icon { 767 757 margin: 0 auto; 768 758 overflow: hidden; 769 padding-top: 20%;770 759 } 771 760 772 761 .attachment .thumbnail { 773 display: block;762 overflow: hidden; 774 763 position: absolute; 775 764 top: 0; 765 right: 0; 766 bottom: 0; 776 767 left: 0; 777 margin: 0 auto;778 overflow: hidden;779 max-width: 100%;780 max-height: 100%;781 768 } 782 769 783 .attachment-preview.type-audio .thumbnail, 784 .attachment-preview.type-video .thumbnail { 785 z-index: 1; 786 margin: 1%; 787 max-width: 98%; 788 max-height: 98%; 770 .attachment .portrait img { 771 max-width: 100%; 789 772 } 790 773 791 .media-frame-content .attachment-preview.type-audio .icon, 792 .media-frame-content .attachment-preview.type-video .icon { 793 z-index: 2; 794 background: #f1f1f1; 795 position: relative; 796 padding: 0; 797 top: 15%; 798 left: auto; 799 right: auto; 774 .attachment .landscape img { 775 max-height: 100%; 800 776 } 801 777 802 .attachment-preview.type-audio .filename, 803 .attachment-preview.type-video .filename { 804 z-index: 3; 805 } 806 807 .attachment-preview .thumbnail:after { 778 .attachment .thumbnail:after { 808 779 content: ''; 809 780 display: block; 810 781 position: absolute; … … 848 819 bottom: 0; 849 820 overflow: hidden; 850 821 max-height: 100%; 851 852 822 word-wrap: break-word; 853 823 text-align: center; 854 824 font-weight: bold; … … 861 831 padding: 5px 10px; 862 832 } 863 833 864 .attachment-preview .thumbnail {865 width: 199px;866 height: 199px;867 }868 869 834 .attachment .thumbnail img { 870 835 position: absolute; 871 836 } … … 907 872 width: 24px; 908 873 position: absolute; 909 874 z-index: 10; 910 top: -6px;911 right: -6px;875 top: 0; 876 right: 0; 912 877 outline: none; 913 878 background: #eee; 914 879 -webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 ); … … 930 895 display: block; 931 896 } 932 897 898 .selected.attachment:focus, 933 899 .attachment.details, 934 900 .media-frame.mode-grid .selected.attachment { 935 -webkit-box-shadow: 0 0 0 1px #fff, 936 0 0 0 5px #1e8cbe; 937 box-shadow: 0 0 0 1px #fff, 938 0 0 0 5px #1e8cbe; 901 -webkit-box-shadow: 902 inset 0 0 0 3px #fff, 903 inset 0 0 0 7px #1e8cbe; 904 box-shadow: 905 inset 0 0 0 3px #fff, 906 inset 0 0 0 7px #1e8cbe; 939 907 } 940 908 941 909 .attachment.details .check, … … 942 910 .attachment.selected .check:focus, 943 911 .media-frame.mode-grid .attachment.selected .check { 944 912 background-color: #1e8cbe; 945 -webkit-box-shadow: 0 0 0 1px #fff, 946 0 0 0 2px #1e8cbe; 947 box-shadow: 0 0 0 1px #fff, 948 0 0 0 2px #1e8cbe; 913 -webkit-box-shadow: 914 0 0 0 1px #fff, 915 0 0 0 2px #1e8cbe; 916 box-shadow: 917 0 0 0 1px #fff, 918 0 0 0 2px #1e8cbe; 949 919 } 950 920 951 921 .media-frame.mode-grid .attachment .check { … … 971 941 position: relative; 972 942 display: block; 973 943 width: 100%; 974 margin: -1px 00;944 margin: 0; 975 945 padding: 8px; 976 946 font-size: 12px; 977 947 -webkit-border-radius: 0; … … 1381 1351 .media-selection .attachments { 1382 1352 display: inline-block; 1383 1353 height: 48px; 1384 margin-top: 5px; 1354 margin: 6px; 1355 padding: 0; 1385 1356 overflow: hidden; 1386 1357 vertical-align: top; 1387 1358 } 1388 1359 1360 .media-selection .attachment { 1361 width: 48px; 1362 padding: 0; 1363 margin: 0; 1364 box-shadow: none; 1365 } 1366 1367 .media-selection .attachment .thumbnail { 1368 top: 4px; 1369 right: 4px; 1370 bottom: 4px; 1371 left: 4px; 1372 } 1373 1389 1374 .media-selection .attachment .icon { 1390 1375 width: 50%; 1391 1376 } 1392 1393 .attachment.selection.selected {1377 /* 1378 .attachment.selection.selected .thumbnail { 1394 1379 -webkit-box-shadow: none; 1395 1380 box-shadow: none; 1396 1381 } … … 1413 1398 0 0 0 1px #fff, 1414 1399 0 0 0 4px #1e8cbe; 1415 1400 } 1416 1417 .media-selection .attachment.selection.details {1401 */ 1402 .media-selection .attachment.selection.details .thumbnail { 1418 1403 -webkit-box-shadow: 1419 1404 0 0 0 1px #fff, 1420 1405 0 0 0 3px #1e8cbe; … … 2914 2899 max-width: none !important; 2915 2900 } 2916 2901 } 2902 2903 .attachments[data-columns="1"] .attachment { 2904 width: 100%; 2905 } 2906 2907 .attachments[data-columns="2"] .attachment { 2908 width: 50%; 2909 } 2910 2911 .attachments[data-columns="3"] .attachment { 2912 width: 33.3%; 2913 } 2914 2915 .attachments[data-columns="4"] .attachment { 2916 width: 25%; 2917 } 2918 2919 .attachments[data-columns="5"] .attachment { 2920 width: 20%; 2921 } 2922 2923 .attachments[data-columns="6"] .attachment { 2924 width: 16.6%; 2925 } 2926 2927 .attachments[data-columns="7"] .attachment { 2928 width: 14.2%; 2929 } 2930 2931 .attachments[data-columns="8"] .attachment { 2932 width: 12.5%; 2933 } 2934 2935 .attachments[data-columns="9"] .attachment { 2936 width: 11.1%; 2937 } 2938 2939 .attachments[data-columns="10"] .attachment { 2940 width: 10%; 2941 } 2942 2943 .attachments[data-columns="11"] .attachment { 2944 width: 9%; 2945 } 2946 2947 .attachments[data-columns="12"] .attachment { 2948 width: 8.3%; 2949 } -
src/wp-includes/js/media-views.js
630 630 }) ); 631 631 } 632 632 633 if ( ! this.get('edge') ) {634 this.set( 'edge', 150 );635 }636 637 if ( ! this.get('gutter') ) {638 this.set( 'gutter', 8 );639 }640 641 633 this.resetDisplays(); 642 634 }, 643 635 … … 838 830 describe: true, 839 831 displaySettings: true, 840 832 dragInfo: true, 841 edge: 199,842 833 editing: false, 843 834 priority: 60, 844 835 … … 991 982 992 983 describe: true, 993 984 dragInfo: true, 994 edge: 199,995 985 editing: false, 996 986 priority: 60, 997 987 SettingsView: false, … … 4805 4795 arrowEvent: function( event ) { 4806 4796 var attachment = $('.attachments-browser .attachment'), 4807 4797 attachmentsWidth = $('.attachments-browser .attachments').width(), 4808 thumbnailWidth = attachment.first(). innerWidth() + 16,4809 thumbnailsPerRow = Math. floor(attachmentsWidth/thumbnailWidth),4798 thumbnailWidth = attachment.first().width(), 4799 thumbnailsPerRow = Math.round( attachmentsWidth / thumbnailWidth ), 4810 4800 totalThumnails = attachment.length, 4811 4801 totalRows = Math.ceil(totalThumnails/thumbnailsPerRow), 4812 4802 thisIndex = attachment.filter( ':focus' ).index(), … … 5218 5208 tabIndex: -1 5219 5209 }, 5220 5210 5221 cssTemplate: media.template('attachments-css'),5222 5223 5211 initialize: function() { 5224 5212 this.el.id = _.uniqueId('__attachments-view-'); 5225 5213 … … 5228 5216 refreshThreshold: 3, 5229 5217 AttachmentView: media.view.Attachment, 5230 5218 sortable: false, 5231 resize: true 5219 resize: true, 5220 idealColumnWidth: 160 5232 5221 }); 5233 5222 5234 5223 this._viewsByCid = {}; … … 5258 5247 5259 5248 this.initSortable(); 5260 5249 5261 _.bindAll( this, 'css' ); 5262 this.model.on( 'change:edge change:gutter', this.css, this ); 5263 this._resizeCss = _.debounce( _.bind( this.css, this ), this.refreshSensitivity ); 5250 _.bindAll( this, 'setColumns' ); 5251 5264 5252 if ( this.options.resize ) { 5265 $( window).on( 'resize.attachments', this._resizeCss );5253 $( window ).on( 'resize.attachments', this.setColumns ); 5266 5254 } 5267 5255 5268 // Call this. css() after this view has been rendered in the DOM so5256 // Call this.setColumns() after this view has been rendered in the DOM so 5269 5257 // attachments get proper width applied. 5270 _.defer( this. css, this );5258 _.defer( this.setColumns, this ); 5271 5259 }, 5272 5260 5273 5261 dispose: function() { 5274 5262 this.collection.props.off( null, null, this ); 5275 $(window).off( 'resize.attachments', this._resizeCss ); 5263 $( window ).off( 'resize.attachments', this.setColumns ); 5264 5276 5265 /** 5277 5266 * call 'dispose' directly on the parent class 5278 5267 */ … … 5279 5268 media.View.prototype.dispose.apply( this, arguments ); 5280 5269 }, 5281 5270 5282 css: function() {5283 var $css = $( '#' + this.el.id + '-css' );5271 setColumns: function() { 5272 var prev = this.columns; 5284 5273 5285 if ( $css.length ) { 5286 $css.remove(); 5287 } 5274 this.columns = Math.round( this.$el.width() / this.options.idealColumnWidth ); 5288 5275 5289 media.view.Attachments.$head().append( this.cssTemplate({ 5290 id: this.el.id, 5291 edge: this.edge(), 5292 gutter: this.model.get('gutter') 5293 }) ); 5294 }, 5295 /** 5296 * @returns {Number} 5297 */ 5298 edge: function() { 5299 var edge = this.model.get('edge'), 5300 gutter, width, columns; 5301 5302 if ( ! this.$el.is(':visible') ) { 5303 return edge; 5276 if ( prev !== this.columns ) { 5277 this.$el.attr( 'data-columns', this.columns ); 5304 5278 } 5305 5306 gutter = this.model.get('gutter') * 2;5307 width = this.$el.width() - gutter;5308 columns = Math.ceil( width / ( edge + gutter ) );5309 edge = Math.floor( ( width - ( columns * gutter ) ) / columns );5310 return edge;5311 5279 }, 5312 5280 5313 5281 initSortable: function() { … … 5453 5421 }); 5454 5422 } 5455 5423 } 5456 }, {5457 $head: (function() {5458 var $head;5459 return function() {5460 return $head = $head || $('head');5461 };5462 }())5463 5424 }); 5464 5425 5465 5426 /** … … 6003 5964 controller: this.controller, 6004 5965 collection: this.collection, 6005 5966 selection: this.collection, 6006 model: new Backbone.Model({ 6007 edge: 40, 6008 gutter: 5 6009 }) 5967 model: new Backbone.Model() 6010 5968 }); 6011 5969 6012 5970 this.views.set( '.selection-view', this.attachments ); -
src/wp-includes/media-template.php
414 414 415 415 <script type="text/html" id="tmpl-attachment"> 416 416 <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> 417 < # if ( data.uploading ) { #>418 < div class="media-progress-bar"><div></div></div>419 <# } else if ( 'image' === data.type ) { #>420 < div class="thumbnail">417 <div class="thumbnail"> 418 <# if ( data.uploading ) { #> 419 <div class="media-progress-bar"><div> 420 <# } else if ( 'image' === data.type ) { #> 421 421 <div class="centered"> 422 422 <img src="{{ data.size.url }}" draggable="false" alt="" /> 423 423 </div> 424 </div> 425 <# } else { 426 if ( data.thumb && data.thumb.src && data.thumb.src !== data.icon ) { 427 #><img src="{{ data.thumb.src }}" class="thumbnail" draggable="false" /><# 428 } else { 429 #><img src="{{ data.icon }}" class="icon" draggable="false" /><# 430 } #> 431 <div class="filename"> 432 <div>{{ data.filename }}</div> 433 </div> 434 <# } #> 424 <# } else { #> 425 <div class="centered"> 426 <# if ( data.thumb && data.thumb.src && data.thumb.src !== data.icon ) { #> 427 <img src="{{ data.thumb.src }}" class="thumbnail" draggable="false" /> 428 <# } else { #> 429 <img src="{{ data.icon }}" class="icon" draggable="false" /> 430 <# } #> 431 </div> 432 <div class="filename"> 433 <div>{{ data.filename }}</div> 434 </div> 435 <# } #> 436 </div> 435 437 <# if ( data.buttons.close ) { #> 436 438 <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a> 437 439 <# } #> … … 822 824 </div> 823 825 </script> 824 826 825 <script type="text/html" id="tmpl-attachments-css">826 <style type="text/css" id="{{ data.id }}-css">827 #{{ data.id }} {828 padding: 0 {{ data.gutter }}px;829 }830 831 #{{ data.id }} .attachment {832 margin: {{ data.gutter }}px;833 width: {{ data.edge }}px;834 }835 836 #{{ data.id }} .attachment-preview,837 #{{ data.id }} .attachment-preview .thumbnail {838 width: {{ data.edge }}px;839 height: {{ data.edge }}px;840 }841 842 #{{ data.id }} .portrait .thumbnail img {843 max-width: {{ data.edge }}px;844 height: auto;845 }846 847 #{{ data.id }} .landscape .thumbnail img {848 width: auto;849 max-height: {{ data.edge }}px;850 }851 </style>852 </script>853 854 827 <script type="text/html" id="tmpl-image-details"> 855 828 <div class="media-embed"> 856 829 <div class="embed-media-settings">