PageSourceSearch

https://europe-greece.com/el/wp-content/plugins/wp-user-frontend/assets/js/subscriptions.js?ver=5.9.2

js europe-greece.com collected 2026-09-25 01:30:37 UTC 9,502 bytes, 310 lines download raw bytes

1(function($) {
2
3	var subscription = {
4
5		init: function() {
6
7			$('input#wpuf-recuring-pay').on('click', this.showSubscriptionRecurring );
8
9			$('input#wpuf-trial-status').on('click', this.showSubscriptionPack );
10
11            $('.wpuf-coupon-info-wrap').on( 'click','a.wpuf-apply-coupon', this.couponApply );
12
13            $('.wpuf-coupon-info-wrap').on( 'click','a.wpuf-copon-show', this.couponShow );
14
15            $('.wpuf-coupon-info-wrap').on( 'click','a.wpuf-copon-cancel', this.couponCancel );
16
17            $('.wpuf-assing-pack-btn').on( 'click', this.showPackDropdown );
18
19            $('.wpuf-delete-pack-btn').on( 'click', this.deletePack );
20
21            $('.wpuf-disabled-link').click( this.packAlert );
22
23            //on change enable expiration check status
24            this.changeExpirationFieldVisibility(':checkbox#wpuf-enable_post_expiration');
25
26            $('.wpuf-metabox-post_expiration').on('change',':checkbox#wpuf-enable_post_expiration',this.changeExpirationFieldVisibility);
27            //on change expiration type drop down
28            //this.setTimeExpiration('select#wpuf-expiration_time_type');
29            $('.wpuf-metabox-post_expiration').on('change','select#wpuf-expiration_time_type',this.setTimeExpiration);
30
31            // warn the user before updating the package
32            $( 'body.post-type-wpuf_subscription #post' ).submit( function( event ) {
33                if ( document.activeElement.value === 'Update' ) {
34                    event.preventDefault();
35                    Swal.fire({
36                        title: 'Are you sure to update the subscription?',
37                        text: 'The changes you made will be applied only to the new subscriptions and pending recurring payments.',
38                        icon: 'warning',
39                        showCancelButton: true,
40                        confirmButtonColor: '#3085d6',
41                        cancelButtonColor: '#d33',
42                        confirmButtonText: 'Update'
43                    }).then((result) => {
44                        if (result.isConfirmed) {
45                            $( this ).unbind('submit').submit()
46                        }
47                    })
48                }
49            } );
50
51		},
52
53        packAlert : function () {
54            alert( wpuf_subscription.pack_notice );
55        },
56
57        showPackDropdown: function(e) {
58            e.preventDefault();
59            var self = $(this),
60                wrap = self.parents('.wpuf-user-subscription'),
61                sub_dropdown = wrap.find('.wpuf-pack-dropdown'),
62                sub_details = wrap.find('.wpuf-user-sub-info'),
63                cancel_btn = wrap.find('.wpuf-cancel-pack'),
64                add_btn = wrap.find('.wpuf-add-pack');
65
66            if ( sub_dropdown.attr( 'disabled' ) === 'disabled' ) {
67                sub_dropdown.show().removeAttr('disabled');
68                sub_details.hide().attr('disabled', true );
69                cancel_btn.show();
70                add_btn.hide();
71            } else {
72                sub_details.show().removeAttr('disabled');
73                sub_dropdown.hide().attr('disabled', true );
74                cancel_btn.hide();
75                add_btn.show();
76            }
77
78        },
79
80        deletePack: function(e){
81            var self = $(this),
82                wrap = self.parents('.wpuf-user-subscription'),
83                sub_dropdown = wrap.find('.wpuf-pack-dropdown'),
84                selected_sub = wrap.find( '#wpuf_sub_pack' ),
85                userid = $(e.target).attr('data-userid'),
86                packid = $(e.target).attr('data-packid');
87
88            wrap.find('.wpuf-delete-pack-btn').attr('disabled', true);
89            wrap.css('opacity', 0.5);
90            $.post(
91                ajaxurl,
92                {
93                    'action' : 'wpuf_delete_user_package',
94                    'userid' : userid,
95                    'packid' : packid,
96                    'wpuf_subscription_delete_nonce': wpuf_subs_vars.wpuf_subscription_delete_nonce
97                },
98                function(data){
99                    if(data){
100                        wrap.css( 'opacity', 1 );
101                        $('.wpuf-user-sub-info').remove();
102                        $(e.target).remove();
103                        selected_sub.val(-1);
104                        sub_dropdown.show();
105                    }
106                }
107            );
108
109        },
110
111        couponCancel: function(e) {
112
113            e.preventDefault();
114
115            var self = $(this),
116
117                data = {
118
119                    action: 'coupon_cancel',
120
121                    _wpnonce: wpuf_frontend.nonce,
122
123                    pack_id: self.data('pack_id')
124
125                },
126
127                coupon_field = self.parents('.wpuf-coupon-info-wrap').find('input.wpuf-coupon-field');
128
129
130
131            coupon_field.addClass('wpuf-coupon-field-spinner');
132
133            $.post( wpuf_frontend.ajaxurl, data, function( res ) {
134
135                coupon_field.removeClass('wpuf-coupon-field-spinner');
136
137                if ( res.success ) {
138                    $('.wpuf-pack-inner' ).html( res.data.append_data );
139                    $('.wpuf-coupon-id-field').val('');
140
141                    var coupon_wrap = self.closest('.wpuf-copon-wrap');
142
143                    coupon_wrap.hide();
144                    coupon_wrap.siblings('.wpuf-copon-show').show();
145
146                    $('.wpuf-subscription-success').html('');
147                    $('.wpuf-subscription-error').html('');
148                }
149
150            });
151        },
152
153        couponShow: function(e) {
154
155            e.preventDefault();
156
157            var self = $(this);
158
159            self.hide();
160
161            self.parents('.wpuf-coupon-info-wrap').find('.wpuf-copon-wrap').show();
162
163        },
164
165        couponApply: function(e) {
166
167            e.preventDefault();
168
169            var self = $(this),
170
171                coupon_field = self.parents('.wpuf-coupon-info-wrap').find('input.wpuf-coupon-field'),
172
173                coupon = coupon_field.val();
174
175            if ( coupon === '' ) {
176
177                $('.wpuf-subscription-error').html( wpuf_frontend.coupon_error );
178                return;
179
180            }
181
182            var data = {
183
184                    action: 'coupon_apply',
185
186                    _wpnonce: wpuf_frontend.nonce,
187
188                    coupon: coupon,
189
190                    pack_id: self.data('pack_id')
191
192                };
193
194            if ( self.attr('disabled') === 'disabled' ) {
195
196                //return;
197
198            }
199
200            self.attr( 'disabled', true );
201
202            coupon_field.addClass('wpuf-coupon-field-spinner');
203
204            $.post( wpuf_frontend.ajaxurl, data, function( res ) {
205                coupon_field.removeClass('wpuf-coupon-field-spinner');
206
207                if ( res.success ) {
208                    $('.wpuf-pack-inner' ).html( res.data.append_data );
209                    $('.wpuf-coupon-id-field').val( res.data.coupon_id );
210
211                    if ( res.data.amount <= 0 ) {
212                        $('.wpuf-nullamount-hide').hide();
213                    }
214
215                    $('.wpuf-subscription-success').html(res.data.message);
216                    $('.wpuf-subscription-error').html('');
217                } else {
218                    $('.wpuf-subscription-success').html('');
219                    $('.wpuf-subscription-error').html(res.data.message);
220                }
221
222            });
223
224        },
225
226		showSubscriptionRecurring: function() {
227
228            var self = $(this),
229
230                wrap = self.parents('table.form-table'),
231                pack_child = wrap.find('.wpuf-recurring-child'),
232                trial_checkbox = wrap.find('input#wpuf-trial-status'),
233                trial_child = wrap.find('.wpuf-trial-child'),
234                expire_field = wrap.find('.wpuf-subcription-expire');
235
236            if ( self.is(':checked') ) {
237
238            	if ( trial_checkbox.is(':checked') ) {
239
240            		trial_child.show();
241
242            	}
243
244                pack_child.show();
245
246                expire_field.hide();
247
248            } else {
249
250            	trial_child.hide();
251
252                pack_child.hide();
253
254                expire_field.show();
255
256            }
257
258        },
259
260        showSubscriptionPack: function() {
261
262            var self = $(this),
263
264                pack_status = self.closest('table.form-table').find('.wpuf-trial-child');
265
266            if ( self.is(':checked') ) {
267
268                pack_status.show();
269
270            } else {
271
272                pack_status.hide();
273
274            }
275
276        },
277
278        setTimeExpiration: function(e){
279            var timeArray = {
280                'day' : 30,
281                'month' : 12,
282                'year': 100
283            };
284            $('#wpuf-expiration_time_value').html('');
285            var timeVal = e.target?$(e.target).val():$(e).val();
286            for(var time = 1; time <= timeArray[timeVal]; time++){
287                $('#wpuf-expiration_time_value').append('<option>'+ time +'</option>');
288            }
289        },
290
291        changeExpirationFieldVisibility : function(e){
292
293            var checkbox_obj = e.target? $(e.target) : $(e);
294
295            if ( checkbox_obj.is(':checked') ) {
296                $('.wpuf_subscription_expiration_field').show();
297            } else {
298                $('.wpuf_subscription_expiration_field').hide();
299            }
300        }
301
302	};
303
304    if ( typeof datepicker === 'function') {
305        $('.wpuf-date-picker').datepicker({ dateFormat: "yy-mm-dd" });
306    }
307
308	subscription.init();
309
310})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.