PluginProbe
Powerkit – Supercharge your WordPress Site / 2.9.0
Powerkit – Supercharge your WordPress Site v2.9.0
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / extensions / connect / js / admin-powerkit-connect.js

admin-powerkit-connect.js in Powerkit – Supercharge your WordPress Site 2.9.0, at extensions/connect/js/admin-powerkit-connect.js

185 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( $ ) {
2 'use strict';
3
4 $( function() {
5
6 /*
7 * Instagram
8 */
9
10 // Add new instagram item.
11 $( document ).on('click', '.pk-instagram-manual-feed-wrap .pk-add-element', function (e) {
12 e.preventDefault();
13
14 $(this).parent().find('.pk-msg-empty').remove();
15
16 var uniqueId = Math.random().toString(36).substring(2);;
17
18 var newItem = `
19 <div class="pk-element">
20 <div class="pk-element-fields">
21 <label class="field-text">
22 Text
23 <textarea name="powerkit_connect_instagram_feed[${uniqueId}][text]" cols="30" rows="2"></textarea>
24 </label>
25 <label>
26 Instagram Link
27 <input type="text" name="powerkit_connect_instagram_feed[${uniqueId}][link]">
28 </label>
29 <label>
30 Date
31 <input type="date" name="powerkit_connect_instagram_feed[${uniqueId}][date]">
32 </label>
33 <label>
34 Image Thumbnail URL
35 <input type="text" placeholder="https://site.com/img.jpg" name="powerkit_connect_instagram_feed[${uniqueId}][image_thumbnail]">
36 </label>
37 <label>
38 Image Small URL
39 <input type="text" placeholder="https://site.com/img.jpg" name="powerkit_connect_instagram_feed[${uniqueId}][image_small]">
40 </label>
41 <label>
42 Image Large URL
43 <input type="text" placeholder="https://site.com/img.jpg" name="powerkit_connect_instagram_feed[${uniqueId}][image_large]">
44 </label>
45 <label>
46 Likes Count
47 <input type="number" name="powerkit_connect_instagram_feed[${uniqueId}][likes]">
48 </label>
49 <label>
50 Comments Count
51 <input type="number" name="powerkit_connect_instagram_feed[${uniqueId}][comments]">
52 </label>
53 </div>
54 <div class="pk-element-actions">
55 <span class="dashicons dashicons-sort"></span>
56
57 <a href="#" class="pk-remove-element">
58 Delete
59 </a>
60 </div>
61 </div>`;
62
63 $('.pk-instagram-manual-feed').append(newItem);
64 });
65
66 // Remove instagram item.
67 $( document ).on('click', '.pk-instagram-manual-feed-wrap .pk-remove-element', function (e) {
68 e.preventDefault();
69 $(this).parent().parent().remove();
70 });
71
72 // Element instagram sortable
73 $( '.pk-instagram-manual-feed' ).sortable({
74 placeholder: 'ui-state-highlight',
75 items: "> .pk-element",
76 handle: ".dashicons-sort"
77 } );
78
79 $( '.pk-instagram-manual-feed .pk-element' ).disableSelection();
80
81 /*
82 * Twitter
83 */
84
85 // Add new twitter item.
86 $( document ).on('click', '.pk-twitter-manual-feed-wrap .pk-add-element', function (e) {
87 e.preventDefault();
88
89 $(this).parent().find('.pk-msg-empty').remove();
90
91 var uniqueId = Math.random().toString(36).substring(2);;
92
93 var newItem = `
94 <div class="pk-element">
95 <div class="pk-element-fields">
96 <label class="field-text">
97 Text
98 <textarea name="powerkit_connect_twitter_feed[${uniqueId}][text]" cols="30" rows="2"></textarea>
99 </label>
100 <label>
101 Date
102 <input type="date" name="powerkit_connect_twitter_feed[${uniqueId}][date]">
103 </label>
104 <label>
105 Retweets Count
106 <input type="number" name="powerkit_connect_twitter_feed[${uniqueId}][retweets]">
107 </label>
108 <label>
109 Tweet ID
110 <input type="text" name="powerkit_connect_twitter_feed[${uniqueId}][tweet_id]">
111 </label>
112 <label>
113 <p class="description">Copy the Twitter ID from the share link, for example: https://twitter.com/codesupplyco/status/<strong>637130509961854976</strong>?s=20</p>
114 </label>
115 </div>
116 <div class="pk-element-actions">
117 <span class="dashicons dashicons-sort"></span>
118
119 <a href="#" class="pk-remove-element">
120 Delete
121 </a>
122 </div>
123 </div>`;
124
125 $('.pk-twitter-manual-feed').append(newItem);
126 });
127
128 // Remove twitter item.
129 $( document ).on('click', '.pk-twitter-manual-feed-wrap .pk-remove-element', function (e) {
130 e.preventDefault();
131 $(this).parent().parent().remove();
132 });
133
134 // Element twitter sortable
135 $( '.pk-twitter-manual-feed' ).sortable({
136 placeholder: 'ui-state-highlight',
137 items: "> .pk-element",
138 handle: ".dashicons-sort"
139 } );
140
141 $( '.pk-twitter-manual-feed .pk-element' ).disableSelection();
142
143 /*
144 * AJAX Reset cache
145 */
146 $( document ).on( 'click dblclick', 'a[href*="action=powerkit_reset_cache"]', function( e ) {
147 var $this = this;
148 $.ajax( {
149 type: 'POST',
150 url: window.pk_connect.ajax_url + '?action=powerkit_reset_cache',
151 data: {
152 page: $( $this ).attr( 'href' ).split( 'page=' ).pop().split( '&' ).shift(),
153 },
154 beforeSend: function() {
155 $( $this ).siblings( '.spinner, .status' ).remove();
156
157 $( $this ).after( '<span class="spinner is-active"></span>' );
158 },
159 success: function( data ) {
160 $( $this ).after( '<span class="status dashicons dashicons-yes"></span>' );
161 },
162 error: function() {
163 $( $this ).after( '<span class="status dashicons dashicons-no-alt"></span>' );
164 },
165 complete: function() {
166 $( $this ).siblings( '.spinner' ).remove();
167
168 setTimeout( function() {
169 $( $this ).siblings( '.status' ).fadeOut();
170 }, 2000 );
171 }
172 } );
173
174 // Refresh customizer.
175 if ( $( 'body' ).hasClass( 'wp-customizer' ) ) {
176 wp.customize.previewer.refresh();
177 }
178
179 return false;
180 } );
181
182 } );
183
184 } )( jQuery );
185