https://shop.dementiauk.org/wp-content/plugins/donationsystem/assets/js/frontend/frontend.js?ver=3.4
1/* global fp_donation_frontend_params, fp_donation_flybox_params */ 2jQuery( function ( $ ) { 3 'use strict' ; 4 if ( typeof fp_donation_frontend_params === 'undefined' || typeof fp_donation_flybox_params === 'undefined' ) { 5 return false ; 6 } 7 8 function fp_donation_setCookie( key , value ) { 9 var expires = new Date( ) ; 10 11 expires.setTime( expires.getTime( ) + ( fp_donation_flybox_params.expired_value * 24 * 60 * 60 * 1000 ) ) ; 12 document.cookie = key + '=' + value + ';expires=' + expires.toUTCString( ) ; 13 } 14 15 function fp_donation_getCookie( key ) { 16 var keyValue = document.cookie.match( '(^|;) ?' + key + '=([^;]*)(;|$)' ) ; 17 return keyValue ? keyValue[2] : null ; 18 } 19 20 var FP_Donation_Frontend = { 21 init : function ( ) { 22 // Trigger donation reason type. 23 $( document ).on( 'change' , '.fp_donation_reason_type' , this.trigger_donation_reason_type ) ; 24 // Trigger predefined list box. 25 $( document ).on( 'change' , '.fp_input_predefined_listbox' , this.trigger_predefined_listbox ) ; 26 // Toggle predefined buttons. 27 $( document ).on( 'click' , '.fp_input_predefined_buttons' , this.toggle_predefined_buttons ) ; 28 // Handle donation anonymous. 29 $( document ).on( 'change' , '.donation_anonymous_enable' , this.handle_donation_anonymous ) ; 30 // Display the fly box. 31 $( window ).on( 'scroll' , this.display_flybox ) ; 32 // Close the fly box. 33 $( document ).on( 'click' , '.fpdonationflyboxclose' , this.close_flybox ) ; 34 // Add Donation rewards. 35 $( document ).on( 'click' , '.sumo_donation_manual_free_product' , this.manually_add_donation_rewards ) ; 36 37 $(document).on('keyup mouseup change blur keydown' , '.fp_donation_amount' , this.validate_donation_amout); 38 39 this.trigger_on_page_load( ) ; 40 } , trigger_on_page_load : function ( ) { 41 // Trigger donation reason type. 42 FP_Donation_Frontend.donation_reason_type( ".fp_donation_reason_type" ) ; 43 // Trigger predefined list box. 44 FP_Donation_Frontend.predefined_listbox( ".fp_input_predefined_listbox" ) ; 45 46 FP_Donation_Frontend.initialize_footable( ) ; 47 FP_Donation_Frontend.initialize_flybox( ) ; 48 } , 49 50 validate_donation_amout(e){ 51 let $msg_field = $(this).closest('td').find('.fp_donation_inp_field_msg'); 52 let $submit_btn = $(this).closest('table').find('#fp_donation_submit'); 53 let $min_donation = parseFloat($(this).attr('min')); 54 let $max_donation = parseFloat($(this).attr('max')); 55 let $val = parseFloat($(this).val()); 56 57 if( $min_donation !== '' && $min_donation > $val){ 58 $msg_field.html(fp_donation_frontend_params.min_donation_msg); 59 $msg_field.removeClass('fp_donation_hide'); 60 $submit_btn.attr('disabled', true); 61 } else if( $max_donation !== '' && $max_donation < $val){ 62 $msg_field.html(fp_donation_frontend_params.max_donation_msg); 63 $msg_field.removeClass('fp_donation_hide'); 64 $submit_btn.attr('disabled', true); 65 } else { 66 if(!$msg_field.hasClass('fp_donation_hide')){ 67 $msg_field.addClass('fp_donation_hide'); 68 } 69 70 $submit_btn.attr('disabled', false); 71 } 72 }, 73 74 initialize_footable : function ( ) { 75 if ( !$( '.donationtable' ).length ) { 76 return ; 77 } 78 79 $( '.donationtable' ).footable( ) ; 80 $( '#pagination_size' ).val( 5 ) ; 81 $( '#pagination_size' ).on( 'change' , function ( ) { 82 $( '.donationtable' ).data( 'page-size' , this.value ) ; 83 $( '.donationtable' ).trigger( 'footable_initialized' ) ; 84 } ) ; 85 } , initialize_flybox : function () { 86 if ( fp_donation_getCookie( 'fpdonationflybox' ) !== '1' ) { 87 var get_current_width = $( '.fp_donation_flybox' ).outerWidth( ) ; 88 89 if ( fp_donation_flybox_params.position == '1' ) { 90 $( '.fp_donation_flybox' ).css( 'left' , '-' + get_current_width + 'px' ) ; 91 } else { 92 $( '.fp_donation_flybox' ).css( 'right' , '-' + get_current_width + 'px' ) ; 93 } 94 95 $( '.fp_donation_flybox' ).css( 'visibility' , 'visible' ) ; 96 } else { 97 $( '.fp_donation_flybox' ).css( 'display' , 'none' ) ; 98 } 99 } , display_flybox : function ( e ) { 100 $( '.fp_donation_flybox' ).css( 'visibility' , 'visible' ) ; 101 var currY = $( this ).scrollTop( ) , 102 postHeight = $( this ).height( ) , 103 scrollHeight = $( document ).height( ) , 104 scrollPercent = ( currY / ( scrollHeight - postHeight ) ) * 100 ; 105 106 if ( fp_donation_flybox_params.position == '2' ) { 107 if ( fp_donation_getCookie( 'fpdonationflybox' ) !== '1' ) { 108 if ( scrollPercent >= fp_donation_flybox_params.scroll_percentage ) { 109 $( '.fp_donation_flybox' ).stop( ).animate( { right : "40px" , bottom : "30px" } , 600 ) ; 110 } else { 111 var width = $( '.fp_donation_flybox' ).outerWidth( ) ; 112 $( '.fp_donation_flybox' ).stop( ).animate( { right : '-' + width , easing : "swing" } , 600 ) ; 113 } 114 } 115 } else { 116 if ( fp_donation_getCookie( 'fpdonationflybox' ) !== '1' ) { 117 if ( scrollPercent >= fp_donation_flybox_params.scroll_percentage ) { 118 $( '.fp_donation_flybox' ).stop( ).animate( { left : "40px" , bottom : "30px" } , 600 ) ; 119 } else { 120 var width = $( '.fp_donation_flybox' ).outerWidth( ) ; 121 $( '.fp_donation_flybox' ).stop( ).animate( { left : '-' + width , easing : "swing" } , 600 ) ; 122 } 123 } 124 } 125 } , trigger_donation_reason_type : function ( event ) { 126 event.preventDefault( ) ; 127 var $this = $( event.currentTarget ) ; 128 FP_Donation_Frontend.donation_reason_type( $this ) ; 129 } , trigger_predefined_listbox : function ( event ) { 130 event.preventDefault( ) ; 131 var $this = $( event.currentTarget ) ; 132 FP_Donation_Frontend.predefined_listbox( $this ) ; 133 } , donation_reason_type : function ( $this ) { 134 135 switch ( $( $this ).val( ) ) { 136 case '2': 137 $( $this ).closest( '.fp_donation_reason_table' ).find( '.fp_reason_for_fields' ).show( ) ; 138 break ; 139 default: 140 $( $this ).closest( '.fp_donation_reason_table' ).find( '.fp_reason_for_fields' ).hide( ) ; 141 break ; 142 } 143 144 } , predefined_listbox : function ( $this ) { 145 $( '.fp_donation_amount_predefined_listbox' ).val( $( $this ).val( ) ) ; 146 } , toggle_predefined_buttons : function ( event ) { 147 event.preventDefault( ) ; 148 var $this = $( event.currentTarget ) ,
149 dataprice = $( $this ).attr( 'data-price' ) ; 150 $( '.fp_input_predefined_buttons' ).removeClass( 'fp_input_predefined_buttons_selected' ) ; 151 $( $this ).addClass( 'fp_input_predefined_buttons_selected' ) ; 152 $( '.fp_donation_amount_predefined_buttons' ).val( dataprice ) ; 153 } , handle_donation_anonymous : function ( event ) { 154 event.preventDefault( ) ; 155 var $this = $( event.currentTarget ) , 156 anonymous = 'no' ; 157 FP_Donation_Frontend.block( $this ) ; 158 if ( $( $this ).is( ":checked" ) ) { 159 anonymous = 'yes' ; 160 } 161 162 var data = ( { 163 action : 'fp_donation_handle_anonymous' , 164 anonymous : anonymous , 165 fp_donation_security : fp_donation_frontend_params.anonymous_nonce , 166 } ) ; 167 $.post( fp_donation_frontend_params.ajax_url , data , function ( res ) { 168 if ( true !== res.success ) { 169 alert( res.data.error ) ; 170 } 171 172 FP_Donation_Frontend.unblock( $this ) ; 173 } ) ; 174 } , close_flybox : function ( event ) { 175 event.preventDefault( ) ; 176 var $this = $( event.currentTarget ) , 177 getwidth = $( '.fp_donation_flybox' ).outerWidth() ; 178 179 if ( fp_donation_flybox_params.position == '1' ) { 180 $( '.fp_donation_flybox' ).stop().animate( { left : '-' + getwidth , easing : "swing" } , 600 ) ; 181 } else { 182 $( '.fp_donation_flybox' ).stop().animate( { right : '-' + getwidth , easing : "swing" } , 600 ) ; 183 } 184 185 if ( fp_donation_flybox_params.enable_cookies == 'yes' ) { 186 fp_donation_setCookie( 'fpdonationflybox' , '1' ) ; 187 } 188 189 } , manually_add_donation_rewards : function ( event ) { 190 event.preventDefault( ) ; 191 var $this = $( event.currentTarget ) ; 192 var data = { 193 action : 'fp_donation_reward_product' , 194 product_id : $( $this ).data( 'product_id' ) , 195 donation_security : fp_donation_frontend_params.reward_nonce , 196 } ; 197 $.ajax( { 198 type : 'POST' , 199 url : fp_donation_frontend_params.ajax_url , 200 data : data 201 } ).done( function ( response ) { 202 if ( true === response.success ) { 203 window.location.reload( ) ; 204 } 205 } ) ; 206 } , block : function ( id ) { 207 if ( !FP_Donation_Frontend.is_blocked( id ) ) { 208 $( id ).addClass( 'processing' ).block( { 209 message : null , 210 overlayCSS : { 211 background : '#fff' , 212 opacity : 0.7 213 } 214 } ) ; 215 } 216 } , unblock : function ( id ) { 217 $( id ).removeClass( 'processing' ).unblock( ) ; 218 } , is_blocked : function ( id ) { 219 return $( id ).is( '.processing' ) || $( id ).parents( '.processing' ).length ; 220 } 221 } ; 222 FP_Donation_Frontend.init( ) ; 223} ) ;
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.