blob: f291d30f7563cdda78b5d1dd835cccc3e2ff74c2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/**
* wp.media.view.Spinner
*
* Represents a spinner in the Media Library.
*
* @since 3.9.0
*
* @memberOf wp.media.view
*
* @class
* @augments wp.media.View
* @augments wp.Backbone.View
* @augments Backbone.View
*/
var Spinner = wp.media.View.extend(/** @lends wp.media.view.Spinner.prototype */{
tagName: 'span',
className: 'spinner',
spinnerTimeout: false,
delay: 400,
/**
* Shows the spinner. Delays the visibility by the configured amount.
*
* @since 3.9.0
*
* @return {wp.media.view.Spinner} The spinner.
*/
show: function() {
if ( ! this.spinnerTimeout ) {
this.spinnerTimeout = _.delay(function( $el ) {
$el.addClass( 'is-active' );
}, this.delay, this.$el );
}
return this;
},
/**
* Hides the spinner.
*
* @since 3.9.0
*
* @return {wp.media.view.Spinner} The spinner.
*/
hide: function() {
this.$el.removeClass( 'is-active' );
this.spinnerTimeout = clearTimeout( this.spinnerTimeout );
return this;
}
});
module.exports = Spinner;
|