Graceful failures for TinyMCE views of video/audio playlists.

props gcorne.
fixes #27821.

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


git-svn-id: http://core.svn.wordpress.org/trunk@27975 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Nacin 2014-04-16 00:23:15 +00:00
parent dbca0c5e15
commit a8cefa836d
4 changed files with 57 additions and 39 deletions

View File

@ -602,6 +602,10 @@ window.wp = window.wp || {};
} }
}, this ); }, this );
if ( ! this.data.tracks ) {
return;
}
p = new WPPlaylistView({ p = new WPPlaylistView({
el: $( self.node ).find( '.wp-playlist' ).get(0), el: $( self.node ).find( '.wp-playlist' ).get(0),
metadata: this.data metadata: this.data
@ -623,7 +627,8 @@ window.wp = window.wp || {};
attachments, attachments,
tracks = []; tracks = [];
if ( ! this.attachments.length ) { // Don't render errors while still fetching attachments
if ( this.dfd && 'pending' === this.dfd.state() && ! this.attachments.length ) {
return; return;
} }
@ -631,8 +636,6 @@ window.wp = window.wp || {};
data[ key ] = model.coerce( data, key ); data[ key ] = model.coerce( data, key );
}); });
attachments = this.attachments.toJSON();
options = { options = {
type: data.type, type: data.type,
style: data.style, style: data.style,
@ -642,6 +645,12 @@ window.wp = window.wp || {};
artists: data.artists artists: data.artists
}; };
if ( ! this.attachments.length ) {
return this.template( options );
}
attachments = this.attachments.toJSON();
_.each( attachments, function( attachment ) { _.each( attachments, function( attachment ) {
var size = {}, resize = {}, track = { var size = {}, resize = {}, track = {
src : attachment.url, src : attachment.url,

File diff suppressed because one or more lines are too long

View File

@ -289,6 +289,30 @@ audio {
background-image: url(images/dashicon-no-alt.png); background-image: url(images/dashicon-no-alt.png);
} }
.wpview-error {
border: 1px solid #dedede;
padding: 20px 0;
margin: 0;
}
.selected .wpview-error {
border-color: transparent;
}
.wpview-error .dashicons {
display: block;
margin: 0 auto;
width: 32px;
height: 32px;
font-size: 32px;
}
.wpview-error p {
margin: 0;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
.wpview-wrap .toolbar div:hover, .wpview-wrap .toolbar div:hover,
#wp-image-toolbar div:hover { #wp-image-toolbar div:hover {
@ -350,29 +374,6 @@ audio {
margin: auto; margin: auto;
} }
.gallery-error {
border: 1px solid #dedede;
padding: 20px 0;
margin: 0;
}
.selected .gallery-error {
border-color: transparent;
}
.gallery-error .dashicons {
display: block;
margin: 0 auto;
width: 32px;
height: 32px;
font-size: 32px;
}
.gallery-error p {
margin: 0;
text-align: center;
font-family: 'Open Sans', sans-serif;
}
.gallery .gallery-item { .gallery .gallery-item {
float: left; float: left;
@ -443,6 +444,8 @@ audio {
.gallery img { .gallery img {
max-width: 100%; max-width: 100%;
height: auto; height: auto;
border: none;
padding: 0;
} }
img.wp-oembed { img.wp-oembed {

View File

@ -1001,7 +1001,7 @@ function wp_print_media_templates() {
<# } ); #> <# } ); #>
</div> </div>
<# } else { #> <# } else { #>
<div class="gallery-error"> <div class="wpview-error">
<div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p> <div class="dashicons dashicons-format-gallery"></div><p><?php _e( 'No items found.' ); ?></p>
</div> </div>
<# } #> <# } #>
@ -1032,17 +1032,23 @@ function wp_print_media_templates() {
<div class="dashicons dashicons-edit edit"></div> <div class="dashicons dashicons-edit edit"></div>
<div class="dashicons dashicons-no-alt remove"></div> <div class="dashicons dashicons-no-alt remove"></div>
</div> </div>
<div class="wp-playlist wp-{{ data.type }}-playlist wp-playlist-{{ data.style }}"> <# if ( data.tracks ) { #>
<# if ( 'audio' === data.type ){ #> <div class="wp-playlist wp-{{ data.type }}-playlist wp-playlist-{{ data.style }}">
<div class="wp-playlist-current-item"></div> <# if ( 'audio' === data.type ){ #>
<# } #> <div class="wp-playlist-current-item"></div>
<{{ data.type }} controls="controls" preload="none" <# <# } #>
if ( data.width ) { #> width="{{ data.width }}"<# } <{{ data.type }} controls="controls" preload="none" <#
#><# if ( data.height ) { #> height="{{ data.height }}"<# } #>></{{ data.type }}> if ( data.width ) { #> width="{{ data.width }}"<# }
<div class="wp-playlist-next"></div> #><# if ( data.height ) { #> height="{{ data.height }}"<# } #>></{{ data.type }}>
<div class="wp-playlist-prev"></div> <div class="wp-playlist-next"></div>
</div> <div class="wp-playlist-prev"></div>
<div class="wpview-overlay"></div> </div>
<div class="wpview-overlay"></div>
<# } else { #>
<div class="wpview-error">
<div class="dashicons dashicons-video-alt3"></div><p><?php _e( 'No items found.' ); ?></p>
</div>
<# } #>
</script> </script>
<script type="text/html" id="tmpl-crop-content"> <script type="text/html" id="tmpl-crop-content">