Add inline uploader UI to media modal sidebar. see #21390.
git-svn-id: http://core.svn.wordpress.org/trunk@22322 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f7c1aaf26d
commit
aa52a02dd1
|
@ -133,6 +133,7 @@
|
||||||
|
|
||||||
.media-sidebar .sidebar-content {
|
.media-sidebar .sidebar-content {
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
|
margin-bottom: 130px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.media-sidebar .search {
|
.media-sidebar .search {
|
||||||
|
@ -485,7 +486,7 @@
|
||||||
max-width: 300px;
|
max-width: 300px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
border-color: #fff;
|
border-color: #fff;
|
||||||
/*display: none;*/
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.uploader-window .media-progress-bar div {
|
.uploader-window .media-progress-bar div {
|
||||||
|
@ -496,6 +497,37 @@
|
||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.uploader-inline {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploader-inline .media-progress-bar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uploading.uploader-inline .media-progress-bar {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-sidebar .uploader-inline {
|
||||||
|
display: block;
|
||||||
|
position: absolute;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
height: 100px;
|
||||||
|
margin: 10px;
|
||||||
|
padding-top: 10px;
|
||||||
|
text-align: center;
|
||||||
|
border: 1px dashed #aaa;
|
||||||
|
}
|
||||||
|
|
||||||
|
.media-sidebar .uploader-inline h3 {
|
||||||
|
font-weight: 200;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 10px 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Selection Preview
|
* Selection Preview
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -499,17 +499,20 @@
|
||||||
var uploader;
|
var uploader;
|
||||||
|
|
||||||
this.controller = this.options.controller;
|
this.controller = this.options.controller;
|
||||||
|
this.inline = new media.view.UploaderInline({
|
||||||
|
controller: this.controller,
|
||||||
|
uploaderWindow: this
|
||||||
|
}).render();
|
||||||
|
|
||||||
|
this.inline.$el.appendTo('body');
|
||||||
|
|
||||||
uploader = this.options.uploader = _.defaults( this.options.uploader || {}, {
|
uploader = this.options.uploader = _.defaults( this.options.uploader || {}, {
|
||||||
container: this.$el,
|
container: this.inline.$el,
|
||||||
dropzone: this.$el,
|
dropzone: this.$el,
|
||||||
browser: this.$('.upload-attachments a'),
|
browser: this.inline.$('.browser'),
|
||||||
params: {}
|
params: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Track uploading attachments.
|
|
||||||
wp.Uploader.queue.on( 'add remove reset change:percent', this.renderUploadProgress, this );
|
|
||||||
|
|
||||||
if ( uploader.dropzone ) {
|
if ( uploader.dropzone ) {
|
||||||
// Ensure the dropzone is a jQuery collection.
|
// Ensure the dropzone is a jQuery collection.
|
||||||
if ( ! (uploader.dropzone instanceof $) )
|
if ( ! (uploader.dropzone instanceof $) )
|
||||||
|
@ -522,12 +525,15 @@
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
this.maybeInitUploader();
|
this.maybeInitUploader();
|
||||||
this.renderUploadProgress();
|
|
||||||
this.$el.html( this.template( this.options ) );
|
this.$el.html( this.template( this.options ) );
|
||||||
this.$bar = this.$('.upload-attachments .media-progress-bar div');
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
refresh: function() {
|
||||||
|
if ( this.uploader )
|
||||||
|
this.uploader.refresh();
|
||||||
|
},
|
||||||
|
|
||||||
maybeInitUploader: function() {
|
maybeInitUploader: function() {
|
||||||
var $id, dropzone;
|
var $id, dropzone;
|
||||||
|
|
||||||
|
@ -565,6 +571,30 @@
|
||||||
if ( '0' === $el.css('opacity') )
|
if ( '0' === $el.css('opacity') )
|
||||||
$el.hide();
|
$el.hide();
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
media.view.UploaderInline = Backbone.View.extend({
|
||||||
|
tagName: 'div',
|
||||||
|
className: 'uploader-inline',
|
||||||
|
template: media.template('uploader-inline'),
|
||||||
|
|
||||||
|
initialize: function() {
|
||||||
|
this.controller = this.options.controller;
|
||||||
|
|
||||||
|
// Track uploading attachments.
|
||||||
|
wp.Uploader.queue.on( 'add remove reset change:percent', this.renderUploadProgress, this );
|
||||||
|
},
|
||||||
|
|
||||||
|
destroy: function() {
|
||||||
|
wp.Uploader.queue.off( 'add remove reset change:percent', this.renderUploadProgress, this );
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
this.renderUploadProgress();
|
||||||
|
this.$el.html( this.template( this.options ) );
|
||||||
|
this.$bar = this.$('.media-progress-bar div');
|
||||||
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
renderUploadProgress: function() {
|
renderUploadProgress: function() {
|
||||||
|
@ -910,6 +940,11 @@
|
||||||
|
|
||||||
this.$('.sidebar-content').html( els );
|
this.$('.sidebar-content').html( els );
|
||||||
|
|
||||||
|
if ( this.controller.uploader ) {
|
||||||
|
this.$el.append( this.controller.uploader.inline.$el );
|
||||||
|
this.controller.uploader.refresh();
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -1309,6 +1309,13 @@ function wp_print_media_templates( $attachment ) {
|
||||||
</div>
|
</div>
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<script type="text/html" id="tmpl-uploader-inline">
|
||||||
|
<h3><?php _e( 'Drop files here' ); ?></h3>
|
||||||
|
<!--<span><?php _ex( 'or', 'Uploader: Drop files here - or - Select Files' ); ?></span>-->
|
||||||
|
<a href="#" class="browser button-secondary"><?php _e( 'Select Files' ); ?></a>
|
||||||
|
<div class="media-progress-bar"><div></div></div>
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/html" id="tmpl-sidebar">
|
<script type="text/html" id="tmpl-sidebar">
|
||||||
<h2 class="sidebar-title"><%- title %></h2>
|
<h2 class="sidebar-title"><%- title %></h2>
|
||||||
<div class="sidebar-content"></div>
|
<div class="sidebar-content"></div>
|
||||||
|
|
Loading…
Reference in New Issue