Media modal/grid: remove thumbnail resizing from JS, only keep setting number of columns. Props avryl, see #27423.

Built from https://develop.svn.wordpress.org/trunk@29376


git-svn-id: http://core.svn.wordpress.org/trunk@29154 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-08-05 05:20:18 +00:00
parent e1eab74aa6
commit e6b0d0c9ee
7 changed files with 298 additions and 291 deletions

View File

@ -700,7 +700,7 @@
*/ */
.attachments { .attachments {
margin: 0; margin: 0;
padding-left: 16px; padding: 8px;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
@ -710,101 +710,74 @@
.attachment { .attachment {
position: relative; position: relative;
float: right; float: right;
padding: 0; padding: 8px;
margin: 0 10px 20px; margin: 0;
color: #464646; color: #464646;
cursor: pointer;
list-style: none; list-style: none;
text-align: center; text-align: center;
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
width: 20%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
.attachment:focus { .attachment:focus {
-webkit-box-shadow: -webkit-box-shadow:
0 0 0 1px #5b9dd9, inset 0 0 0 5px #fff,
0 0 2px 2px #5b9dd9; inset 0 0 1px 7px #5b9dd9;
box-shadow: box-shadow:
0 0 0 1px #5b9dd9, inset 0 0 0 5px #fff,
0 0 2px 2px #5b9dd9; inset 0 0 1px 7px #5b9dd9;
outline: none; outline: none;
} }
.selected.attachment { .selected.attachment {
-webkit-box-shadow: -webkit-box-shadow:
0 0 0 1px #fff, inset 0 0 0 5px #fff,
0 0 0 3px #ccc; inset 0 0 0 7px #ccc;
box-shadow: box-shadow:
0 0 0 1px #fff, inset 0 0 0 5px #fff,
0 0 0 3px #ccc; inset 0 0 0 7px #ccc;
}
.selected.attachment:focus {
-webkit-box-shadow:
0 0 0 1px #fff,
0 0 0 5px #1e8cbe;
box-shadow:
0 0 0 1px #fff,
0 0 0 5px #1e8cbe;
} }
.attachment-preview { .attachment-preview {
position: relative; position: relative;
width: 199px; }
height: 199px;
-webkit-box-shadow: .attachment-preview:before {
inset 0 0 15px rgba( 0, 0, 0, 0.1 ), content: '';
inset 0 0 0 1px rgba( 0, 0, 0, 0.05 ); display: block;
box-shadow: padding-top: 100%;
inset 0 0 15px rgba( 0, 0, 0, 0.1 ),
inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );
background: #eee;
cursor: pointer;
} }
.attachment .icon { .attachment .icon {
margin: 0 auto; margin: 0 auto;
overflow: hidden; overflow: hidden;
padding-top: 20%;
} }
.attachment .thumbnail { .attachment .thumbnail {
display: block; overflow: hidden;
position: absolute; position: absolute;
top: 0; top: 0;
left: 0;
bottom: 0;
right: 0; right: 0;
margin: 0 auto; }
overflow: hidden;
.attachment .portrait img {
max-width: 100%; max-width: 100%;
}
.attachment .landscape img {
max-height: 100%; max-height: 100%;
} }
.attachment-preview.type-audio .thumbnail, .attachment .thumbnail:after {
.attachment-preview.type-video .thumbnail {
z-index: 1;
margin: 1%;
max-width: 98%;
max-height: 98%;
}
.media-frame-content .attachment-preview.type-audio .icon,
.media-frame-content .attachment-preview.type-video .icon {
z-index: 2;
background: #f1f1f1;
position: relative;
padding: 0;
top: 15%;
right: auto;
left: auto;
}
.attachment-preview.type-audio .filename,
.attachment-preview.type-video .filename {
z-index: 3;
}
.attachment-preview .thumbnail:after {
content: ''; content: '';
display: block; display: block;
position: absolute; position: absolute;
@ -831,13 +804,13 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
-webkit-transform: translate( 50%, 50% ); -webkit-transform: translate( 50%, 50% );
-ms-transform: translate( 50%, 50% ); -ms-transform: translate(50%,50%); /* Fails with spaces?? Weird! */
transform: translate( 50%, 50% ); transform: translate( 50%, 50% );
} }
.attachment .thumbnail .centered img { .attachment .thumbnail .centered img {
-webkit-transform: translate( -50%, -50% ); -webkit-transform: translate( -50%, -50% );
-ms-transform: translate( -50%, -50% ); -ms-transform: translate(-50%,-50%);
transform: translate( -50%, -50% ); transform: translate( -50%, -50% );
} }
@ -848,7 +821,6 @@
bottom: 0; bottom: 0;
overflow: hidden; overflow: hidden;
max-height: 100%; max-height: 100%;
word-wrap: break-word; word-wrap: break-word;
text-align: center; text-align: center;
font-weight: bold; font-weight: bold;
@ -861,11 +833,6 @@
padding: 5px 10px; padding: 5px 10px;
} }
.attachment-preview .thumbnail {
width: 199px;
height: 199px;
}
.attachment .thumbnail img { .attachment .thumbnail img {
position: absolute; position: absolute;
} }
@ -907,8 +874,8 @@
width: 24px; width: 24px;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
top: -6px; top: 0;
left: -6px; left: 0;
outline: none; outline: none;
background: #eee; background: #eee;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 ); -webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 );
@ -930,21 +897,26 @@
display: block; display: block;
} }
.selected.attachment:focus,
.attachment.details, .attachment.details,
.media-frame.mode-grid .selected.attachment { .media-frame.mode-grid .selected.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, -webkit-box-shadow:
0 0 0 5px #1e8cbe; inset 0 0 0 3px #fff,
box-shadow: 0 0 0 1px #fff, inset 0 0 0 7px #1e8cbe;
0 0 0 5px #1e8cbe; box-shadow:
inset 0 0 0 3px #fff,
inset 0 0 0 7px #1e8cbe;
} }
.attachment.details .check, .attachment.details .check,
.attachment.selected .check:focus, .attachment.selected .check:focus,
.media-frame.mode-grid .attachment.selected .check { .media-frame.mode-grid .attachment.selected .check {
background-color: #1e8cbe; background-color: #1e8cbe;
-webkit-box-shadow: 0 0 0 1px #fff, -webkit-box-shadow:
0 0 0 1px #fff,
0 0 0 2px #1e8cbe; 0 0 0 2px #1e8cbe;
box-shadow: 0 0 0 1px #fff, box-shadow:
0 0 0 1px #fff,
0 0 0 2px #1e8cbe; 0 0 0 2px #1e8cbe;
} }
@ -971,7 +943,7 @@
position: relative; position: relative;
display: block; display: block;
width: 100%; width: 100%;
margin: -1px 0 0; margin: 0;
padding: 8px; padding: 8px;
font-size: 12px; font-size: 12px;
-webkit-border-radius: 0; -webkit-border-radius: 0;
@ -1218,7 +1190,7 @@
right: 0; right: 0;
left: 0; left: 0;
-webkit-transform: translateY( -50% ); -webkit-transform: translateY( -50% );
-ms-transform: translateY( -50% ); -ms-transform: translateY(-50%);
transform: translateY( -50% ); transform: translateY( -50% );
font-size: 40px; font-size: 40px;
color: #fff; color: #fff;
@ -1381,16 +1353,32 @@
.media-selection .attachments { .media-selection .attachments {
display: inline-block; display: inline-block;
height: 48px; height: 48px;
margin-top: 5px; margin: 6px;
padding: 0;
overflow: hidden; overflow: hidden;
vertical-align: top; vertical-align: top;
} }
.media-selection .attachment {
width: 48px;
padding: 0;
margin: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.media-selection .attachment .thumbnail {
top: 4px;
left: 4px;
bottom: 4px;
right: 4px;
}
.media-selection .attachment .icon { .media-selection .attachment .icon {
width: 50%; width: 50%;
} }
/*
.attachment.selection.selected { .attachment.selection.selected .thumbnail {
-webkit-box-shadow: none; -webkit-box-shadow: none;
box-shadow: none; box-shadow: none;
} }
@ -1413,8 +1401,8 @@
0 0 0 1px #fff, 0 0 0 1px #fff,
0 0 0 4px #1e8cbe; 0 0 0 4px #1e8cbe;
} }
*/
.media-selection .attachment.selection.details { .media-selection .attachment.selection.details .thumbnail {
-webkit-box-shadow: -webkit-box-shadow:
0 0 0 1px #fff, 0 0 0 1px #fff,
0 0 0 3px #1e8cbe; 0 0 0 3px #1e8cbe;
@ -2056,7 +2044,7 @@
right: 0; right: 0;
left: 0; left: 0;
-webkit-transform: translateY( -50% ); -webkit-transform: translateY( -50% );
-ms-transform: translateY( -50% ); -ms-transform: translateY(-50%);
transform: translateY( -50% ); transform: translateY( -50% );
font-size: 3em; font-size: 3em;
line-height: 1.3; line-height: 1.3;
@ -2914,3 +2902,51 @@
max-width: none !important; max-width: none !important;
} }
} }
.attachments[data-columns="1"] .attachment {
width: 100%;
}
.attachments[data-columns="2"] .attachment {
width: 50%;
}
.attachments[data-columns="3"] .attachment {
width: 33.3%;
}
.attachments[data-columns="4"] .attachment {
width: 25%;
}
.attachments[data-columns="5"] .attachment {
width: 20%;
}
.attachments[data-columns="6"] .attachment {
width: 16.6%;
}
.attachments[data-columns="7"] .attachment {
width: 14.2%;
}
.attachments[data-columns="8"] .attachment {
width: 12.5%;
}
.attachments[data-columns="9"] .attachment {
width: 11.1%;
}
.attachments[data-columns="10"] .attachment {
width: 10%;
}
.attachments[data-columns="11"] .attachment {
width: 9%;
}
.attachments[data-columns="12"] .attachment {
width: 8.3%;
}

File diff suppressed because one or more lines are too long

View File

@ -700,7 +700,7 @@
*/ */
.attachments { .attachments {
margin: 0; margin: 0;
padding-right: 16px; padding: 8px;
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
} }
@ -710,101 +710,74 @@
.attachment { .attachment {
position: relative; position: relative;
float: left; float: left;
padding: 0; padding: 8px;
margin: 0 10px 20px; margin: 0;
color: #464646; color: #464646;
cursor: pointer;
list-style: none; list-style: none;
text-align: center; text-align: center;
-webkit-user-select: none; -webkit-user-select: none;
-moz-user-select: none; -moz-user-select: none;
-ms-user-select: none; -ms-user-select: none;
user-select: none; user-select: none;
width: 20%;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
} }
.attachment:focus { .attachment:focus {
-webkit-box-shadow: -webkit-box-shadow:
0 0 0 1px #5b9dd9, inset 0 0 0 5px #fff,
0 0 2px 2px #5b9dd9; inset 0 0 1px 7px #5b9dd9;
box-shadow: box-shadow:
0 0 0 1px #5b9dd9, inset 0 0 0 5px #fff,
0 0 2px 2px #5b9dd9; inset 0 0 1px 7px #5b9dd9;
outline: none; outline: none;
} }
.selected.attachment { .selected.attachment {
-webkit-box-shadow: -webkit-box-shadow:
0 0 0 1px #fff, inset 0 0 0 5px #fff,
0 0 0 3px #ccc; inset 0 0 0 7px #ccc;
box-shadow: box-shadow:
0 0 0 1px #fff, inset 0 0 0 5px #fff,
0 0 0 3px #ccc; inset 0 0 0 7px #ccc;
}
.selected.attachment:focus {
-webkit-box-shadow:
0 0 0 1px #fff,
0 0 0 5px #1e8cbe;
box-shadow:
0 0 0 1px #fff,
0 0 0 5px #1e8cbe;
} }
.attachment-preview { .attachment-preview {
position: relative; position: relative;
width: 199px; }
height: 199px;
-webkit-box-shadow: .attachment-preview:before {
inset 0 0 15px rgba( 0, 0, 0, 0.1 ), content: '';
inset 0 0 0 1px rgba( 0, 0, 0, 0.05 ); display: block;
box-shadow: padding-top: 100%;
inset 0 0 15px rgba( 0, 0, 0, 0.1 ),
inset 0 0 0 1px rgba( 0, 0, 0, 0.05 );
background: #eee;
cursor: pointer;
} }
.attachment .icon { .attachment .icon {
margin: 0 auto; margin: 0 auto;
overflow: hidden; overflow: hidden;
padding-top: 20%;
} }
.attachment .thumbnail { .attachment .thumbnail {
display: block; overflow: hidden;
position: absolute; position: absolute;
top: 0; top: 0;
right: 0;
bottom: 0;
left: 0; left: 0;
margin: 0 auto; }
overflow: hidden;
.attachment .portrait img {
max-width: 100%; max-width: 100%;
}
.attachment .landscape img {
max-height: 100%; max-height: 100%;
} }
.attachment-preview.type-audio .thumbnail, .attachment .thumbnail:after {
.attachment-preview.type-video .thumbnail {
z-index: 1;
margin: 1%;
max-width: 98%;
max-height: 98%;
}
.media-frame-content .attachment-preview.type-audio .icon,
.media-frame-content .attachment-preview.type-video .icon {
z-index: 2;
background: #f1f1f1;
position: relative;
padding: 0;
top: 15%;
left: auto;
right: auto;
}
.attachment-preview.type-audio .filename,
.attachment-preview.type-video .filename {
z-index: 3;
}
.attachment-preview .thumbnail:after {
content: ''; content: '';
display: block; display: block;
position: absolute; position: absolute;
@ -831,13 +804,13 @@
width: 100%; width: 100%;
height: 100%; height: 100%;
-webkit-transform: translate( 50%, 50% ); -webkit-transform: translate( 50%, 50% );
-ms-transform: translate( 50%, 50% ); -ms-transform: translate(50%,50%); /* Fails with spaces?? Weird! */
transform: translate( 50%, 50% ); transform: translate( 50%, 50% );
} }
.attachment .thumbnail .centered img { .attachment .thumbnail .centered img {
-webkit-transform: translate( -50%, -50% ); -webkit-transform: translate( -50%, -50% );
-ms-transform: translate( -50%, -50% ); -ms-transform: translate(-50%,-50%);
transform: translate( -50%, -50% ); transform: translate( -50%, -50% );
} }
@ -848,7 +821,6 @@
bottom: 0; bottom: 0;
overflow: hidden; overflow: hidden;
max-height: 100%; max-height: 100%;
word-wrap: break-word; word-wrap: break-word;
text-align: center; text-align: center;
font-weight: bold; font-weight: bold;
@ -861,11 +833,6 @@
padding: 5px 10px; padding: 5px 10px;
} }
.attachment-preview .thumbnail {
width: 199px;
height: 199px;
}
.attachment .thumbnail img { .attachment .thumbnail img {
position: absolute; position: absolute;
} }
@ -907,8 +874,8 @@
width: 24px; width: 24px;
position: absolute; position: absolute;
z-index: 10; z-index: 10;
top: -6px; top: 0;
right: -6px; right: 0;
outline: none; outline: none;
background: #eee; background: #eee;
-webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 ); -webkit-box-shadow: 0 0 0 1px #fff, 0 0 0 2px rgba( 0, 0, 0, 0.15 );
@ -930,21 +897,26 @@
display: block; display: block;
} }
.selected.attachment:focus,
.attachment.details, .attachment.details,
.media-frame.mode-grid .selected.attachment { .media-frame.mode-grid .selected.attachment {
-webkit-box-shadow: 0 0 0 1px #fff, -webkit-box-shadow:
0 0 0 5px #1e8cbe; inset 0 0 0 3px #fff,
box-shadow: 0 0 0 1px #fff, inset 0 0 0 7px #1e8cbe;
0 0 0 5px #1e8cbe; box-shadow:
inset 0 0 0 3px #fff,
inset 0 0 0 7px #1e8cbe;
} }
.attachment.details .check, .attachment.details .check,
.attachment.selected .check:focus, .attachment.selected .check:focus,
.media-frame.mode-grid .attachment.selected .check { .media-frame.mode-grid .attachment.selected .check {
background-color: #1e8cbe; background-color: #1e8cbe;
-webkit-box-shadow: 0 0 0 1px #fff, -webkit-box-shadow:
0 0 0 1px #fff,
0 0 0 2px #1e8cbe; 0 0 0 2px #1e8cbe;
box-shadow: 0 0 0 1px #fff, box-shadow:
0 0 0 1px #fff,
0 0 0 2px #1e8cbe; 0 0 0 2px #1e8cbe;
} }
@ -971,7 +943,7 @@
position: relative; position: relative;
display: block; display: block;
width: 100%; width: 100%;
margin: -1px 0 0; margin: 0;
padding: 8px; padding: 8px;
font-size: 12px; font-size: 12px;
-webkit-border-radius: 0; -webkit-border-radius: 0;
@ -1218,7 +1190,7 @@
left: 0; left: 0;
right: 0; right: 0;
-webkit-transform: translateY( -50% ); -webkit-transform: translateY( -50% );
-ms-transform: translateY( -50% ); -ms-transform: translateY(-50%);
transform: translateY( -50% ); transform: translateY( -50% );
font-size: 40px; font-size: 40px;
color: #fff; color: #fff;
@ -1381,16 +1353,32 @@
.media-selection .attachments { .media-selection .attachments {
display: inline-block; display: inline-block;
height: 48px; height: 48px;
margin-top: 5px; margin: 6px;
padding: 0;
overflow: hidden; overflow: hidden;
vertical-align: top; vertical-align: top;
} }
.media-selection .attachment {
width: 48px;
padding: 0;
margin: 0;
-webkit-box-shadow: none;
box-shadow: none;
}
.media-selection .attachment .thumbnail {
top: 4px;
right: 4px;
bottom: 4px;
left: 4px;
}
.media-selection .attachment .icon { .media-selection .attachment .icon {
width: 50%; width: 50%;
} }
/*
.attachment.selection.selected { .attachment.selection.selected .thumbnail {
-webkit-box-shadow: none; -webkit-box-shadow: none;
box-shadow: none; box-shadow: none;
} }
@ -1413,8 +1401,8 @@
0 0 0 1px #fff, 0 0 0 1px #fff,
0 0 0 4px #1e8cbe; 0 0 0 4px #1e8cbe;
} }
*/
.media-selection .attachment.selection.details { .media-selection .attachment.selection.details .thumbnail {
-webkit-box-shadow: -webkit-box-shadow:
0 0 0 1px #fff, 0 0 0 1px #fff,
0 0 0 3px #1e8cbe; 0 0 0 3px #1e8cbe;
@ -2056,7 +2044,7 @@
left: 0; left: 0;
right: 0; right: 0;
-webkit-transform: translateY( -50% ); -webkit-transform: translateY( -50% );
-ms-transform: translateY( -50% ); -ms-transform: translateY(-50%);
transform: translateY( -50% ); transform: translateY( -50% );
font-size: 3em; font-size: 3em;
line-height: 1.3; line-height: 1.3;
@ -2914,3 +2902,51 @@
max-width: none !important; max-width: none !important;
} }
} }
.attachments[data-columns="1"] .attachment {
width: 100%;
}
.attachments[data-columns="2"] .attachment {
width: 50%;
}
.attachments[data-columns="3"] .attachment {
width: 33.3%;
}
.attachments[data-columns="4"] .attachment {
width: 25%;
}
.attachments[data-columns="5"] .attachment {
width: 20%;
}
.attachments[data-columns="6"] .attachment {
width: 16.6%;
}
.attachments[data-columns="7"] .attachment {
width: 14.2%;
}
.attachments[data-columns="8"] .attachment {
width: 12.5%;
}
.attachments[data-columns="9"] .attachment {
width: 11.1%;
}
.attachments[data-columns="10"] .attachment {
width: 10%;
}
.attachments[data-columns="11"] .attachment {
width: 9%;
}
.attachments[data-columns="12"] .attachment {
width: 8.3%;
}

File diff suppressed because one or more lines are too long

View File

@ -630,14 +630,6 @@
}) ); }) );
} }
if ( ! this.get('edge') ) {
this.set( 'edge', 150 );
}
if ( ! this.get('gutter') ) {
this.set( 'gutter', 8 );
}
this.resetDisplays(); this.resetDisplays();
}, },
@ -838,7 +830,7 @@
describe: true, describe: true,
displaySettings: true, displaySettings: true,
dragInfo: true, dragInfo: true,
edge: 199, idealColumnWidth: 170,
editing: false, editing: false,
priority: 60, priority: 60,
@ -991,7 +983,7 @@
describe: true, describe: true,
dragInfo: true, dragInfo: true,
edge: 199, idealColumnWidth: 170,
editing: false, editing: false,
priority: 60, priority: 60,
SettingsView: false, SettingsView: false,
@ -2178,6 +2170,7 @@
display: state.has('display') ? state.get('display') : state.get('displaySettings'), display: state.has('display') ? state.get('display') : state.get('displaySettings'),
dragInfo: state.get('dragInfo'), dragInfo: state.get('dragInfo'),
idealColumnWidth: state.get('idealColumnWidth'),
suggestedWidth: state.get('suggestedWidth'), suggestedWidth: state.get('suggestedWidth'),
suggestedHeight: state.get('suggestedHeight'), suggestedHeight: state.get('suggestedHeight'),
@ -4805,8 +4798,8 @@
arrowEvent: function( event ) { arrowEvent: function( event ) {
var attachment = $('.attachments-browser .attachment'), var attachment = $('.attachments-browser .attachment'),
attachmentsWidth = $('.attachments-browser .attachments').width(), attachmentsWidth = $('.attachments-browser .attachments').width(),
thumbnailWidth = attachment.first().innerWidth() + 16, thumbnailWidth = attachment.first().width(),
thumbnailsPerRow = Math.floor(attachmentsWidth/thumbnailWidth), thumbnailsPerRow = Math.round( attachmentsWidth / thumbnailWidth ),
totalThumnails = attachment.length, totalThumnails = attachment.length,
totalRows = Math.ceil(totalThumnails/thumbnailsPerRow), totalRows = Math.ceil(totalThumnails/thumbnailsPerRow),
thisIndex = attachment.filter( ':focus' ).index(), thisIndex = attachment.filter( ':focus' ).index(),
@ -5218,8 +5211,6 @@
tabIndex: -1 tabIndex: -1
}, },
cssTemplate: media.template('attachments-css'),
initialize: function() { initialize: function() {
this.el.id = _.uniqueId('__attachments-view-'); this.el.id = _.uniqueId('__attachments-view-');
@ -5228,7 +5219,8 @@
refreshThreshold: 3, refreshThreshold: 3,
AttachmentView: media.view.Attachment, AttachmentView: media.view.Attachment,
sortable: false, sortable: false,
resize: true resize: true,
idealColumnWidth: 150
}); });
this._viewsByCid = {}; this._viewsByCid = {};
@ -5258,56 +5250,35 @@
this.initSortable(); this.initSortable();
_.bindAll( this, 'css' ); _.bindAll( this, 'setColumns' );
this.model.on( 'change:edge change:gutter', this.css, this );
this._resizeCss = _.debounce( _.bind( this.css, this ), this.refreshSensitivity );
if ( this.options.resize ) { if ( this.options.resize ) {
$(window).on( 'resize.attachments', this._resizeCss ); $( window ).on( 'resize.attachments', this.setColumns );
} }
// Call this.css() after this view has been rendered in the DOM so // Call this.setColumns() after this view has been rendered in the DOM so
// attachments get proper width applied. // attachments get proper width applied.
_.defer( this.css, this ); _.defer( this.setColumns, this );
}, },
dispose: function() { dispose: function() {
this.collection.props.off( null, null, this ); this.collection.props.off( null, null, this );
$(window).off( 'resize.attachments', this._resizeCss ); $( window ).off( 'resize.attachments', this.setColumns );
/** /**
* call 'dispose' directly on the parent class * call 'dispose' directly on the parent class
*/ */
media.View.prototype.dispose.apply( this, arguments ); media.View.prototype.dispose.apply( this, arguments );
}, },
css: function() { setColumns: function() {
var $css = $( '#' + this.el.id + '-css' ); var prev = this.columns;
if ( $css.length ) { this.columns = Math.round( this.$el.width() / this.options.idealColumnWidth );
$css.remove();
if ( prev !== this.columns ) {
this.$el.attr( 'data-columns', this.columns );
} }
media.view.Attachments.$head().append( this.cssTemplate({
id: this.el.id,
edge: this.edge(),
gutter: this.model.get('gutter')
}) );
},
/**
* @returns {Number}
*/
edge: function() {
var edge = this.model.get('edge'),
gutter, width, columns;
if ( ! this.$el.is(':visible') ) {
return edge;
}
gutter = this.model.get('gutter') * 2;
width = this.$el.width() - gutter;
columns = Math.ceil( width / ( edge + gutter ) );
edge = Math.floor( ( width - ( columns * gutter ) ) / columns );
return edge;
}, },
initSortable: function() { initSortable: function() {
@ -5453,13 +5424,6 @@
}); });
} }
} }
}, {
$head: (function() {
var $head;
return function() {
return $head = $head || $('head');
};
}())
}); });
/** /**
@ -5895,6 +5859,7 @@
model: this.model, model: this.model,
sortable: this.options.sortable, sortable: this.options.sortable,
scrollElement: this.options.scrollElement, scrollElement: this.options.scrollElement,
idealColumnWidth: this.options.idealColumnWidth,
// The single `Attachment` view to be used in the `Attachments` view. // The single `Attachment` view to be used in the `Attachments` view.
AttachmentView: this.options.AttachmentView AttachmentView: this.options.AttachmentView
@ -6003,10 +5968,7 @@
controller: this.controller, controller: this.controller,
collection: this.collection, collection: this.collection,
selection: this.collection, selection: this.collection,
model: new Backbone.Model({ model: new Backbone.Model()
edge: 40,
gutter: 5
})
}); });
this.views.set( '.selection-view', this.attachments ); this.views.set( '.selection-view', this.attachments );

File diff suppressed because one or more lines are too long

View File

@ -414,24 +414,26 @@ function wp_print_media_templates() {
<script type="text/html" id="tmpl-attachment"> <script type="text/html" id="tmpl-attachment">
<div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}"> <div class="attachment-preview js--select-attachment type-{{ data.type }} subtype-{{ data.subtype }} {{ data.orientation }}">
<# if ( data.uploading ) { #>
<div class="media-progress-bar"><div></div></div>
<# } else if ( 'image' === data.type ) { #>
<div class="thumbnail"> <div class="thumbnail">
<# if ( data.uploading ) { #>
<div class="media-progress-bar"><div>
<# } else if ( 'image' === data.type ) { #>
<div class="centered"> <div class="centered">
<img src="{{ data.size.url }}" draggable="false" alt="" /> <img src="{{ data.size.url }}" draggable="false" alt="" />
</div> </div>
<# } else { #>
<div class="centered">
<# if ( data.thumb && data.thumb.src && data.thumb.src !== data.icon ) { #>
<img src="{{ data.thumb.src }}" class="thumbnail" draggable="false" />
<# } else { #>
<img src="{{ data.icon }}" class="icon" draggable="false" />
<# } #>
</div> </div>
<# } else {
if ( data.thumb && data.thumb.src && data.thumb.src !== data.icon ) {
#><img src="{{ data.thumb.src }}" class="thumbnail" draggable="false" /><#
} else {
#><img src="{{ data.icon }}" class="icon" draggable="false" /><#
} #>
<div class="filename"> <div class="filename">
<div>{{ data.filename }}</div> <div>{{ data.filename }}</div>
</div> </div>
<# } #> <# } #>
</div>
<# if ( data.buttons.close ) { #> <# if ( data.buttons.close ) { #>
<a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a> <a class="close media-modal-icon" href="#" title="<?php esc_attr_e('Remove'); ?>"></a>
<# } #> <# } #>
@ -822,35 +824,6 @@ function wp_print_media_templates() {
</div> </div>
</script> </script>
<script type="text/html" id="tmpl-attachments-css">
<style type="text/css" id="{{ data.id }}-css">
#{{ data.id }} {
padding: 0 {{ data.gutter }}px;
}
#{{ data.id }} .attachment {
margin: {{ data.gutter }}px;
width: {{ data.edge }}px;
}
#{{ data.id }} .attachment-preview,
#{{ data.id }} .attachment-preview .thumbnail {
width: {{ data.edge }}px;
height: {{ data.edge }}px;
}
#{{ data.id }} .portrait .thumbnail img {
max-width: {{ data.edge }}px;
height: auto;
}
#{{ data.id }} .landscape .thumbnail img {
width: auto;
max-height: {{ data.edge }}px;
}
</style>
</script>
<script type="text/html" id="tmpl-image-details"> <script type="text/html" id="tmpl-image-details">
<div class="media-embed"> <div class="media-embed">
<div class="embed-media-settings"> <div class="embed-media-settings">