mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-25 14:00:13 +02:00
d568679946
* Add a new folder in `wp-includes/js`, `media` * Create manifest files for `views`, `models`, `grid`, and `audio-video` * Make `browserify` an `npm` dependency * Add Grunt tasks for `browserify` and `uglify:media` on `build` and `watch` * Update the paths loaded for media files in `script-loader` * All new files were created using `svn cp` from their original location Please run `npm install`. While developing media JS, you must run `grunt watch`. See #28510. Built from https://develop.svn.wordpress.org/trunk@31373 git-svn-id: http://core.svn.wordpress.org/trunk@31354 1a063a9b-81f0-0310-95a4-ce76da25c4cd
81 lines
1.5 KiB
JavaScript
81 lines
1.5 KiB
JavaScript
/*globals _, wp, jQuery */
|
|
|
|
/**
|
|
* wp.media.view.EmbedUrl
|
|
*
|
|
* @class
|
|
* @augments wp.media.View
|
|
* @augments wp.Backbone.View
|
|
* @augments Backbone.View
|
|
*/
|
|
var View = require( '../view.js' ),
|
|
$ = jQuery,
|
|
EmbedUrl;
|
|
|
|
EmbedUrl = View.extend({
|
|
tagName: 'label',
|
|
className: 'embed-url',
|
|
|
|
events: {
|
|
'input': 'url',
|
|
'keyup': 'url',
|
|
'change': 'url'
|
|
},
|
|
|
|
initialize: function() {
|
|
var self = this;
|
|
|
|
this.$input = $('<input id="embed-url-field" type="url" />').val( this.model.get('url') );
|
|
this.input = this.$input[0];
|
|
|
|
this.spinner = $('<span class="spinner" />')[0];
|
|
this.$el.append([ this.input, this.spinner ]);
|
|
|
|
this.listenTo( this.model, 'change:url', this.render );
|
|
|
|
if ( this.model.get( 'url' ) ) {
|
|
_.delay( function () {
|
|
self.model.trigger( 'change:url' );
|
|
}, 500 );
|
|
}
|
|
},
|
|
/**
|
|
* @returns {wp.media.view.EmbedUrl} Returns itself to allow chaining
|
|
*/
|
|
render: function() {
|
|
var $input = this.$input;
|
|
|
|
if ( $input.is(':focus') ) {
|
|
return;
|
|
}
|
|
|
|
this.input.value = this.model.get('url') || 'http://';
|
|
/**
|
|
* Call `render` directly on parent class with passed arguments
|
|
*/
|
|
View.prototype.render.apply( this, arguments );
|
|
return this;
|
|
},
|
|
|
|
ready: function() {
|
|
if ( ! wp.media.isTouchDevice ) {
|
|
this.focus();
|
|
}
|
|
},
|
|
|
|
url: function( event ) {
|
|
this.model.set( 'url', event.target.value );
|
|
},
|
|
|
|
/**
|
|
* If the input is visible, focus and select its contents.
|
|
*/
|
|
focus: function() {
|
|
var $input = this.$input;
|
|
if ( $input.is(':visible') ) {
|
|
$input.focus()[0].select();
|
|
}
|
|
}
|
|
});
|
|
|
|
module.exports = EmbedUrl; |