PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.1
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.1
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-attribution.js

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

70 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 const StockpackAttribution = wp.media.View.extend( /** @lends wp.media.view.Toolbar.prototype */{
2 tagName: 'div',
3 className: 'stockpack-attribution',
4 template: wp.template( 'stockpack-attribution' ),
5 events: {
6 'click .notice-dismiss': 'dismiss',
7 },
8 defaults: {
9 id: 'stockpack-attribution',
10 message: '',
11 author_info: '',
12 link: '',
13 link_title: '',
14 },
15 dismissed: false,
16
17 initialize() {
18 this.model = new Backbone.Model( this.defaults );
19 // If any of the `options` have a key from `defaults`, apply its
20 // value to the `model` and remove it from the `options object.
21 _.each( this.defaults, function( def, key ) {
22 const value = this.options[ key ];
23 if ( _.isUndefined( value ) ) {
24 return;
25 }
26
27 this.model.set( key, value );
28 delete this.options[ key ];
29 }, this );
30
31 this.updateProvider( 'default' );
32
33 this.controller.on( 'update_provider', _.debounce( this.updateProvider, 150 ), this );
34 },
35
36 show() {
37 if ( ! this.dismissed ) {
38 this.$el.removeClass('hidden')
39 }
40 },
41
42 hide() {
43 this.$el.addClass('hidden')
44 },
45
46 dispose() {
47 this.$el.remove();
48 },
49
50 dismiss() {
51 this.$el.hide();
52 this.dismissed = true;
53 },
54
55 prepare() {
56 return this.model.toJSON();
57 },
58
59 updateProvider( provider ) {
60 const data = wp.media.view.l10n.stockpack.attribution[ provider ];
61 _.each( data, function( value, key ) {
62 this.model.set( key, value );
63 }, this );
64 this.render();
65 },
66
67 } );
68
69 export default StockpackAttribution;
70