PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.2
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.2
3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 3.0.0 3.0.1 All 71 releases
stockpack / assets / js / stockpack-empty.js

stockpack-empty.js in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.2, at assets/js/stockpack-empty.js

79 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import StockpackTimer from './utils/stockpack-timer';
2
3 const StockpackEmpty = wp.media.View.extend( /** @lends wp.media.view.Toolbar.prototype */{
4 tagName: 'div',
5 className: 'stockpack-empty',
6 template: wp.template( 'stockpack-empty' ),
7
8 events: {
9 'click .retry': 'retry',
10 },
11
12 defaults: {
13 message: '',
14 link: false,
15 retry: true,
16 },
17
18 timer: null,
19
20 initialize() {
21 this.model = new Backbone.Model( this.defaults );
22 // If any of the `options` have a key from `defaults`, apply its
23 // value to the `model` and remove it from the `options object.
24 _.each( this.defaults, function( def, key ) {
25 const value = this.options[ key ];
26 if ( _.isUndefined( value ) ) {
27 return;
28 }
29
30 this.model.set( key, value );
31 delete this.options[ key ];
32 }, this );
33 this.listenTo( this.model, 'change', this.render );
34
35 this.controller.on( 'start-retry', _.bind( this.retry, this ) );
36 },
37
38 render() {
39 wp.Backbone.View.prototype.render.apply( this, arguments );
40 this.afterRender();
41 return this;
42 },
43
44 afterRender() {
45 this.maybeCreateTimer();
46 },
47
48 dispose() {
49 this.$el.remove();
50 if ( this.timer ) {
51 this.timer.destroy();
52 }
53 },
54
55 prepare() {
56 return this.model.toJSON();
57 },
58
59 maybeCreateTimer() {
60 if ( this.$el.find( '.stockpack-timer' ).length ) {
61 this.timer = new StockpackTimer( this.$el.find( '.stockpack-timer' ) );
62 }
63 },
64
65 retry() {
66 this.options.browser.updateContent();
67 },
68
69 show() {
70 this.$el.removeClass( 'hidden' );
71 },
72 hide() {
73 this.$el.addClass( 'hidden' );
74 },
75
76 } );
77
78 export default StockpackEmpty;
79