@@ -2,10 +2,12 @@ jQuery(function($) {
22 /**
33 * COUNTDOWN
44 */
5- if ( $ ( '.countdown' ) . length > 0 ) {
6- var countDate = new Date ( $ ( '.countdown' ) . data ( 'start' ) ) ;
7- countDate = new Date ( $ ( '.countdown' ) . data ( 'end' ) ) ;
8- $ ( '.countdown' ) . countdown ( {
5+ var countdown_el = $ ( '.countdown' ) ;
6+
7+ if ( countdown_el . length > 0 ) {
8+ var countDate = new Date ( countdown_el . data ( 'end' ) ) ;
9+
10+ countdown_el . countdown ( {
911 until : countDate ,
1012 compact : true ,
1113 layout : '<span class="day">{dn}</span> <span class="separator">:</span> <span class="hour">{hnn}</span> <span class="separator">:</span> <span class="minutes">{mnn}</span> <span class="separator">:</span> <span class="seconds">{snn}</span>'
@@ -15,30 +17,33 @@ jQuery(function($) {
1517 /**
1618 * SOCIAL LINKS
1719 */
18- if ( $ ( '.social' ) . length > 0 ) {
19- var link_target = $ ( '.social' ) . data ( 'target' ) ;
20+ var social_el = $ ( '.social' ) ;
21+
22+ if ( social_el . length > 0 ) {
23+ var link_target = social_el . data ( 'target' ) ;
2024
2125 if ( link_target == 1 ) {
22- $ ( '.social a') . attr ( 'target' , '_blank' ) ;
26+ social_el . find ( ' a') . attr ( 'target' , '_blank' ) ;
2327 }
2428 }
2529
2630 /**
2731 * SUBSCRIBE FORM
2832 */
29- if ( $ ( '.subscribe_form' ) . length > 0 ) {
33+ var subscribe_form = $ ( '.subscribe_form' ) ;
34+
35+ if ( subscribe_form . length > 0 ) {
3036 // validate form
31- $ ( '. subscribe_form' ) . validate ( {
37+ subscribe_form . validate ( {
3238 submitHandler : function ( form ) {
33- $ . post ( wpmm_vars . ajax_url , {
34- action : 'wpmm_add_subscriber' ,
35- email : $ ( '.email_input' , $ ( '.subscribe_form' ) ) . val ( )
36- } , function ( response ) {
39+ var subscribe_form_data = 'action=wpmm_add_subscriber&' + subscribe_form . serialize ( ) ;
40+
41+ $ . post ( wpmm_vars . ajax_url , subscribe_form_data , function ( response ) {
3742 if ( ! response . success ) {
3843 alert ( response . data ) ;
3944 return false ;
4045 }
41-
46+
4247 $ ( '.subscribe_wrapper' ) . html ( response . data ) ;
4348 } , 'json' ) ;
4449
@@ -61,27 +66,26 @@ jQuery(function($) {
6166 } ) ;
6267
6368 // validate form
64- $ ( '.contact_form' ) . validate ( {
69+ var contact_form = $ ( '.contact_form' ) ;
70+
71+ contact_form . validate ( {
6572 submitHandler : function ( form ) {
66- $ . post ( wpmm_vars . ajax_url , {
67- action : 'wpmm_send_contact' ,
68- name : $ ( '.name_input' , $ ( '.contact_form' ) ) . val ( ) ,
69- email : $ ( '.email_input' , $ ( '.contact_form' ) ) . val ( ) ,
70- content : $ ( '.content_textarea' , $ ( '.contact_form' ) ) . val ( )
71- } , function ( response ) {
73+ var contact_form_data = 'action=wpmm_send_contact&' + contact_form . serialize ( ) ;
74+
75+ $ . post ( wpmm_vars . ajax_url , contact_form_data , function ( response ) {
7276 if ( ! response . success ) {
7377 alert ( response . data ) ;
7478 return false ;
7579 }
7680
77- $ ( '.contact .form' ) . append ( '<div class="response">' + response . data + '</div>' ) ;
78- $ ( '.contact .form . contact_form' ) . hide ( ) ;
81+ contact_form . parent ( ) . append ( '<div class="response">' + response . data + '</div>' ) ;
82+ contact_form . hide ( ) ;
7983
8084 setTimeout ( function ( ) {
8185 $ ( '.contact' ) . hide ( ) ;
82- $ ( '.contact .form .response') . remove ( ) ;
83- $ ( '.contact .form . contact_form' ) . trigger ( 'reset' ) ;
84- $ ( '.contact .form . contact_form' ) . show ( ) ;
86+ contact_form . parent ( ) . find ( ' .response') . remove ( ) ;
87+ contact_form . trigger ( 'reset' ) ;
88+ contact_form . show ( ) ;
8589 } , 2000 ) ;
8690 } , 'json' ) ;
8791
0 commit comments