Last active
August 29, 2015 14:04
-
-
Save ocean90/244470a43e4f5be77e16 to your computer and use it in GitHub Desktop.
wp.media.view.Label
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: src/wp-includes/js/media-views.js | |
=================================================================== | |
--- src/wp-includes/js/media-views.js (revision 29312) | |
+++ src/wp-includes/js/media-views.js (working copy) | |
@@ -5508,6 +5508,8 @@ | |
this.createFilters(); | |
_.extend( this.filters, this.options.filters ); | |
+ this.createLabel(); | |
+ | |
// Build `<option>` elements. | |
this.$el.html( _.chain( this.filters ).map( function( filter, value ) { | |
return { | |
@@ -5516,6 +5518,10 @@ | |
}; | |
}, this ).sortBy('priority').pluck('el').value() ); | |
+ if ( this.label ) { | |
+ this.$el.before( this.label.$el ); | |
+ } | |
+ | |
this.model.on( 'change', this.select, this ); | |
this.select(); | |
}, | |
@@ -5528,6 +5534,13 @@ | |
}, | |
/** | |
+ * @abstract | |
+ */ | |
+ createLabel: function() { | |
+ this.label = {}; | |
+ }, | |
+ | |
+ /** | |
* When the selection changes, set the Query properties | |
* accordingly for the selected filter. | |
*/ | |
@@ -5648,6 +5661,13 @@ | |
}; | |
this.filters = filters; | |
+ }, | |
+ | |
+ createLabel: function() { | |
+ this.label = new media.view.Label({ | |
+ text: l10n.select, | |
+ 'for': this.id | |
+ }); | |
} | |
}); | |
@@ -5789,8 +5809,8 @@ | |
priority: -80 | |
}).render() ); | |
- screenReaderText = $( '<label class="screen-reader-text" for="media-attachment-filters">' + l10n.select + '</label>' ); | |
- this.toolbar.get( 'filters' ).$el.before( screenReaderText ); | |
+ //screenReaderText = $( '<label class="screen-reader-text" for="media-attachment-filters">' + l10n.select + '</label>' ); | |
+ //this.toolbar.get( 'filters' ).$el.before( screenReaderText ); | |
} | |
this.toolbar.set( 'spinner', new media.view.Spinner({ | |
@@ -7057,4 +7077,26 @@ | |
return this; | |
} | |
}); | |
+ | |
+ /** | |
+ * wp.media.view.Label | |
+ * | |
+ * @constructor | |
+ * @augments wp.media.View | |
+ * @augments wp.Backbone.View | |
+ * @augments Backbone.View | |
+ */ | |
+ media.view.Label = media.View.extend({ | |
+ tagName: 'label', | |
+ className: 'screen-reader-text', | |
+ | |
+ initialize: function() { | |
+ _.defaults( this.options, { | |
+ text: '', | |
+ 'for': '' | |
+ }); | |
+ | |
+ this.$el.text( this.options.text ).attr( 'for', this.options['for'] ); | |
+ } | |
+ }); | |
}(jQuery, _)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment