PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / assets / js / media.js

media.js in Media Cloud Sync 1.4.1, at assets/js/media.js

99 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(function ($) {
2 const media = wp.media;
3 const globalData = window.wpmcs_media_object;
4 if (media) {
5 const MediaView = media.view;
6 const Button = MediaView.Button;
7 const AttachmentDetailColumn = MediaView.Attachment.Details.TwoColumn;
8
9 if (AttachmentDetailColumn) {
10 MediaView.Attachment.Details.TwoColumn =
11 AttachmentDetailColumn.extend({
12 render: function () {
13 this.fetchProviderDetails(this.model.get("id"));
14 },
15
16 fetchProviderDetails: function (id) {
17 wp.ajax
18 .send("wpmcs_get_attachment_details", {
19 data: {
20 _nonce: globalData.file_details_nonce,
21 id: id,
22 },
23 })
24 .done(_.bind(this.renderView, this));
25 },
26
27 renderView: function (response) {
28 // Render parent media.view.Attachment.Details
29 AttachmentDetailColumn.prototype.render.apply(this);
30
31 this.renderServerDetails(response);
32 },
33
34 renderServerDetails: function (response) {
35 if (response.status) {
36 var $detailsHtml = this.$el.find(".details");
37 var data = response.data;
38 var append = [];
39 if (data.provider) {
40 var $providerDiv = $("<div>", {
41 class: "wpmcs_provider",
42 });
43 $providerDiv.append(
44 $("<strong>").text(
45 window.wpmcs_media_object.strings
46 .provider
47 )
48 );
49 $providerDiv.append(
50 document.createTextNode(data.provider)
51 );
52 append.push($providerDiv);
53 }
54 if (data.region) {
55 var $regionDiv = $("<div>", {
56 class: "wpmcs_region",
57 });
58 $regionDiv.append(
59 $("<strong>").text(
60 window.wpmcs_media_object.strings
61 .region
62 )
63 );
64 $regionDiv.append(
65 document.createTextNode(data.region)
66 );
67 append.push($regionDiv);
68 }
69
70 var accessString = data.private
71 ? window.wpmcs_media_object.strings
72 .access_private
73 : window.wpmcs_media_object.strings
74 .access_public;
75 var $accessDiv = $("<div>", {
76 class: "wpmcs_access",
77 });
78 $accessDiv.append(
79 $("<strong>").text(
80 window.wpmcs_media_object.strings.access
81 )
82 );
83 $accessDiv.append(
84 document.createTextNode(accessString)
85 );
86 append.push($accessDiv);
87
88 if (append.length) {
89 append.forEach((element, key) => {
90 $detailsHtml.append(element);
91 });
92 }
93 }
94 },
95 });
96 }
97 }
98 });
99