PluginProbe
Push Notifications for WP – Self Hosted Web Push Notifications / 1.12
Push Notifications for WP – Self Hosted Web Push Notifications v1.12
1.52 1.51 trunk 1.0 1.1 1.10 1.11 1.12 1.12.1 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.2 1.20 1.21 1.22 1.23 1.24 1.25 1.25.1 1.26 All 58 releases
push-notification / assets / main-admin-script.js

main-admin-script.js in Push Notifications for WP – Self Hosted Web Push Notifications 1.12, at assets/main-admin-script.js

243 lines 10.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function($){
2 /* Newletters js starts here */
3
4 if(pn_setings.do_tour){
5
6 var content = '<h3>You are awesome for using Push Notification!</h3>';
7 content += '<p>Do you want the latest on <b>Push Notification update</b> before others and some best resources on monetization in a single email? - Free just for users of Push Notification!</p>';
8 content += '<style type="text/css">';
9 content += '.wp-pointer-buttons{ padding:0; overflow: hidden; }';
10 content += '.wp-pointer-content .button-secondary{ left: -25px;background: transparent;top: 5px; border: 0;position: relative; padding: 0; box-shadow: none;margin: 0;color: #0085ba;} .wp-pointer-content .button-primary{ display:none} #pn_mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }';
11 content += '</style>';
12 content += '<div id="pn_mc_embed_signup">';
13 content += '<form id="pushnotification-subscribe-newsletter-form" method="POST">';
14 content += '<div id="pn_mc_embed_signup_scroll">';
15 content += '<div class="pn-mc-field-group" style=" margin-left: 15px; width: 195px; float: left;">';
16 content += '<input type="text" name="name" class="form-control" placeholder="Name" hidden value="'+pn_setings.current_user_name+'" style="display:none">';
17 content += '<input type="text" value="'+pn_setings.current_user_email+'" name="email" class="form-control" placeholder="Email*" style=" width: 180px; padding: 6px 5px;">';
18 content += '<input type="text" name="company" class="form-control" placeholder="Website" hidden style=" display:none; width: 168px; padding: 6px 5px;" value="'+pn_setings.get_home_url+'">';
19 content += '<input type="hidden" name="ml-submit" value="1" />';
20 content += '</div>';
21 content += '<div id="mce-responses">';
22 content += '<div class="response" id="mce-error-response" style="display:none"></div>';
23 content += '<div class="response" id="mce-success-response" style="display:none"></div>';
24 content += '</div>';
25 content += '<div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_a631df13442f19caede5a5baf_c9a71edce6" tabindex="-1" value=""></div>';
26 content += '<input type="submit" value="Subscribe" name="subscribe" class="button mc-newsletter-sent" style=" background: #0085ba; border-color: #006799; padding: 0px 16px; text-shadow: 0 -1px 1px #006799,1px 0 1px #006799,0 1px 1px #006799,-1px 0 1px #006799; height: 30px; margin-top: 1px; color: #fff; box-shadow: 0 1px 0 #006799;">';
27 content += '</div>';
28 content += '</form>';
29 content += '</div>';
30
31 var setup;
32 var wp_pointers_tour_opts = {
33 content:content,
34 position:{
35 edge:"left",
36 align:"left"
37 }
38 };
39
40 wp_pointers_tour_opts = jQuery.extend (wp_pointers_tour_opts, {
41 buttons: function (event, t) {
42 button= jQuery ('<a id="pointer-close" class="button-secondary">' + pn_setings.button1 + '</a>');
43 button_2= jQuery ('#pointer-close.button');
44 button.bind ('click.pointer', function () {
45 t.element.pointer ('close');
46 });
47 button_2.on('click', function() {
48 t.element.pointer ('close');
49 } );
50 return button;
51 },
52 close: function () {
53 jQuery.post (pn_setings.ajax_url, {
54 pointer: 'pushnotification_subscribe_pointer',
55 action: 'dismiss-wp-pointer'
56 });
57 },
58 show: function(event, t){
59 t.pointer.css({'left':'170px', 'top':'160px'});
60 }
61 });
62 setup = function () {
63 jQuery(pn_setings.displayID).pointer(wp_pointers_tour_opts).pointer('open');
64 if (pn_setings.button2) {
65 jQuery ('#pointer-close').after ('<a id="pointer-primary" class="button-primary">' + pn_setings.button2+ '</a>');
66 jQuery ('#pointer-primary').click (function () {
67 pn_setings.function_name;
68 });
69 jQuery ('#pointer-close').click (function () {
70 jQuery.post (pn_setings.ajax_url, {
71 pointer: 'pushnotification_subscribe_pointer',
72 action: 'dismiss-wp-pointer'
73 });
74 });
75 }
76 };
77 if (wp_pointers_tour_opts.position && wp_pointers_tour_opts.position.defer_loading) {
78 jQuery(window).bind('load.wp-pointers', setup);
79 }
80 else {
81 setup ();
82 }
83
84 }
85
86 /* Newletters js ends here */
87 /*Newsletter submission*/
88 jQuery("#pushnotification-subscribe-newsletter-form").on('submit',function(e){
89 e.preventDefault();
90 var form = jQuery(this);
91 var name = form.find('input[name="name"]').val();
92 var email = form.find('input[name="email"]').val();
93 var website = form.find('input[name="company"]').val();
94 jQuery.post(pn_setings.ajax_url, {action:'pn_subscribe_newsletter',name:name, email:email,website:website, nonce: pn_setings.remote_nonce},
95 function(data) {
96 jQuery.post (pn_setings.ajax_url, {
97 pointer: 'pushnotification_subscribe_pointer',
98 action: 'dismiss-wp-pointer'
99 }, function(){
100 location.reload();
101 });
102 }
103 );
104 });
105 /*Newsletter submission End*/
106
107
108
109
110 jQuery("#user_auth_vadation").click(function(){
111 var self = jQuery(this);
112 var tokenKey = jQuery("#user_auth_token_key").val().trim();
113 //console.log(tokenKey);
114 if(tokenKey==''){
115 alert("Please enter valid token");
116 return false;
117 }
118 self.addClass('button updating-message');
119 var messagediv = self.parents('fieldset').find(".resp_message")
120 messagediv.html("");
121 jQuery.ajax({
122 url: ajaxurl,
123 method: "post",
124 dataType: 'json',
125 data: { user_token: tokenKey, action: "pn_verify_user", nonce: pn_setings.remote_nonce },
126 success: function(response){
127
128 if(response.status==200){
129 messagediv.html(response.message);
130 messagediv.css({"color": "green"})
131
132 window.location.reload();
133 }else{
134 messagediv.html(response.message);
135 messagediv.css({"color": "red"})
136 }
137 self.removeClass('updating-message');
138 },
139 error:function(response){
140 var messagediv = self.parents('fieldset').find(".resp_message")
141 messagediv.html(response.responseJSON.message)
142 messagediv.css({"color": "red"})
143
144 }
145 })
146 })
147
148 jQuery("#pn-remove-apikey").click(function(){
149 var self = jQuery(this);
150 self.addClass('button updating-message');
151 jQuery.ajax({
152 url: ajaxurl,
153 method: "post",
154 dataType: 'json',
155 data: { action: "pn_revoke_keys", nonce: pn_setings.remote_nonce },
156 success: function(response){
157
158 if(response.status==200){
159 self.after("&nbsp; "+response.message);
160
161 window.location.reload();
162 }else{
163 self.after(response.message);
164 }
165 self.removeClass('updating-message');
166 },
167 error:function(response){
168 var messagediv = self.parents('fieldset').find(".resp_message")
169 messagediv.html(response.responseJSON.message)
170 messagediv.css({"color": "red"})
171
172 }
173 })
174 })
175 jQuery("#grab-subscribers-data").click(function(){
176 var self = jQuery(this);
177 self.addClass('button updating-message');
178 jQuery.ajax({
179 url: ajaxurl,
180 method: "post",
181 dataType: 'json',
182 data: { action: "pn_subscribers_data", nonce: pn_setings.remote_nonce },
183 success: function(response){
184
185 if(response.status==200){
186 self.after("&nbsp; "+response.message);
187
188 window.location.reload();
189 }else{
190 self.after(response.message);
191 }
192 self.removeClass('updating-message');
193 },
194 error:function(response){
195 var messagediv = self.parents('fieldset').find(".resp_message")
196 messagediv.html(response.responseJSON.message)
197 messagediv.css({"color": "red"})
198
199 }
200 })
201 })
202
203
204 jQuery("#pn-send-custom-notification").click(function(){
205 var self = jQuery(this);
206 var title = jQuery('#notification-title').val();
207 var link_url = jQuery('#notification-link').val();
208 var image_url = jQuery('#notification-imageurl').val();
209 var message = jQuery('#notification-message').val();
210 self.addClass('button updating-message');
211 jQuery.ajax({
212 url: ajaxurl,
213 method: "post",
214 dataType: 'json',
215 data: { action: "pn_send_notification", nonce: pn_setings.remote_nonce,
216 title: title,
217 link_url: link_url,
218 image_url: image_url,
219 message: message
220 },
221 success: function(response){
222
223 if(response.status==200){
224 jQuery(".pn-send-messageDiv").html("&nbsp; "+response.message).css({"color":"green"});
225
226 jQuery('#notification-title').val("");
227 jQuery('#notification-link').val("");
228 jQuery('#notification-imageurl').val("");
229 jQuery('#notification-message').val("");
230 }else{
231 jQuery(".pn-send-messageDiv").html("&nbsp; "+response.message).css({"color":"green"});
232 }
233 self.removeClass('updating-message');
234 },
235 error:function(response){
236 var messagediv = self.parents('fieldset').find(".resp_message")
237 messagediv.html(response.responseJSON.message)
238 messagediv.css({"color": "red"})
239
240 }
241 })
242 })
243 });