1jQuery( document ).ready( function( $ ) { 2 'use strict'; 3 4 // display required asteriscs 5 $( '.dk-speakup-widget-popup-wrap label.required' ).append('<span> *</span>'); 6 7 // run only if widget is on the page 8 if( $( '.dk-speakup-widget-wrap' ).length ) { 9 $( '.dk-speakup-widget-button' ).click( function( e ) { 10 var petition_form = '#' + $( this ).attr( 'rel' ), 11 screenHeight = $( document ).height(), 12 screenWidth = $( window ).width(), 13 windowHeight = $( window ).height(), 14 windowWidth = $( window ).width(); 15 16 $( '#dk-speakup-widget-windowshade' ).css( { 17 'width' : screenWidth, 18 'height' : screenHeight 19 }); 20 $( '#dk-speakup-widget-windowshade' ).fadeTo( 500, 0.8 ); 21 22 // center the pop-up window 23 $( petition_form ).css( 'top', ( ( windowHeight / 2 ) - ( $( petition_form ).height() / 2 ) ) ); 24 $( petition_form ).css( 'left', ( windowWidth / 2 ) - ( $( petition_form ).width() / 2 ) ); 25 26 // display the form 27 $( petition_form ).fadeIn( 500 ); 28 }); 29 30 /* Close the pop-up petition form */ 31 // by clicking windowshade area 32 $( '#dk-speakup-widget-windowshade' ).click( function () { 33 $( this ).fadeOut( 'slow' ); 34 $( '.dk-speakup-widget-popup-wrap' ).hide(); 35 }); 36 // or by clicking the close button 37 $( '.dk-speakup-widget-close' ).click( function() { 38 $( '#dk-speakup-widget-windowshade' ).fadeOut( 'slow' ); 39 $( '.dk-speakup-widget-popup-wrap' ).hide(); 40 }); 41 // or by pressing ESC 42 $( document ).keyup( function( e ) { 43 if ( e.keyCode === 27 ) { 44 $( '#dk-speakup-widget-windowshade' ).fadeOut( 'slow' ); 45 $( '.dk-speakup-widget-popup-wrap' ).hide(); 46 } 47 }); 48 49 // process petition form submissions 50 $( '.dk-speakup-widget-submit' ).click( function( e ) { 51 e.preventDefault(); 52 53 var id = $( this ).attr( 'name' ), 54 current_url = document.URL, 55 share_url = $( '#dk-speakup-widget-shareurl-' + id ).val(), 56 posttitle = $( '#dk-speakup-widget-posttitle-' + id ).val(), 57 tweet = $( '#dk-speakup-widget-tweet-' + id ).val(), 58 lang = $( '#dk-speakup-widget-lang-' + id ).val(), 59 firstname = $( '#dk-speakup-widget-first-name-' + id ).val(), 60 lastname = $( '#dk-speakup-widget-last-name-' + id ).val(), 61 email = $( '#dk-speakup-widget-email-' + id ).val(), 62 email_confirm = $( '#dk-speakup-widget-email-confirm-' + id ).val(), 63 street = $( '#dk-speakup-widget-street-' + id ).val(), 64 city = $( '#dk-speakup-widget-city-' + id ).val(), 65 state = $( '#dk-speakup-widget-state-' + id ).val(), 66 postcode = $( '#dk-speakup-widget-postcode-' + id ).val(), 67 country = $( '#dk-speakup-widget-country-' + id ).val(), 68 custom_field = $( '#dk-speakup-widget-custom-field-' + id ).val(), 69 custom_message = $( 'textarea#dk-speakup-widget-message-' + id ).val(), 70 optin = '', 71 amount = $( '#dk-speakup-amount' ).val(), 72 ajaxloader = $( '#dk-speakup-widget-ajaxloader-' + id ); 73 74 if ( share_url === '' ) { 75 share_url = current_url.split('#')[0]; 76 } 77 78 if ( $( '#dk-speakup-widget-optin-' + id ).attr( 'checked' ) ) { 79 optin = 'on'; 80 } 81 82 // make sure error notices are turned off before checking for new errors 83 $( '#dk-speakup-widget-popup-wrap-' + id + ' input' ).removeClass( 'dk-speakup-widget-error' ); 84 85 // validate form values 86 var errors = 0, 87 emailRegEx = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; 88 89 if ( email_confirm !== undefined && email_confirm !== email ) { 90 if ( email_confirm !== email ) { 91 $( '#dk-speakup-widget-email-' + id ).addClass( 'dk-speakup-widget-error' ); 92 $( '#dk-speakup-widget-email-confirm-' + id ).addClass( 'dk-speakup-widget-error' ); 93 errors ++; 94 } 95 } 96 if ( email === '' || !emailRegEx.test( email ) ) { 97 $( '#dk-speakup-widget-email-' + id ).addClass( 'dk-speakup-widget-error' ); 98 errors ++; 99 } 100 if ( firstname === '' ) { 101 $( '#dk-speakup-widget-first-name-' + id ).addClass( 'dk-speakup-widget-error' ); 102 errors ++; 103 } 104 if ( lastname === '' ) {
105 $( '#dk-speakup-widget-last-name-' + id ).addClass( 'dk-speakup-widget-error' ); 106 errors ++; 107 } 108 109 if ( street === '' ) { 110 $( '#dk-speakup-street-' + id ).addClass( 'dk-speakup-error' ); 111 errors ++; 112 } 113 114 if ( city === '' ) { 115 $( '#dk-speakup-city-' + id ).addClass( 'dk-speakup-error' ); 116 errors ++; 117 } 118 119 120 if ( state === '' ) { 121 $( '#dk-speakup-state-' + id ).addClass( 'dk-speakup-error' ); 122 errors ++; 123 } 124 125 if ( postcode === '' ) { 126 $( '#dk-speakup-postcode-' + id ).addClass( 'dk-speakup-error' ); 127 errors ++; 128 } 129 if ( country === '' ) { 130 $( '#dk-speakup-country-' + id ).addClass( 'dk-speakup-error' ); 131 errors ++; 132 133 } 134 135 136 137 // if no errors found, submit the data via ajax 138 if ( errors === 0 && $( this ).attr( 'rel' ) !== 'disabled' ) { 139 140 // set rel to disabled as flag to block double clicks 141 $( this ).attr( 'rel', 'disabled' ); 142 143 var data = { 144 action: 'dk_speakup_sendmail', 145 id: id, 146 first_name: firstname, 147 last_name: lastname, 148 email: email, 149 street: street, 150 city: city, 151 state: state, 152 postcode: postcode, 153 country: country, 154 custom_field: custom_field, 155 custom_message: custom_message, 156 optin: optin, 157 lang: lang 158 }; 159 160 // display AJAX loading animation 161 ajaxloader.css({ 'visibility' : 'visible'}); 162 163 // submit form data and handle ajax response 164 $.post( dk_speakup_widget_js.ajaxurl, data, 165 function( response ) { 166 var response_class = 'dk-speakup-widget-response-success'; 167 if ( response.status === 'error' ) { 168 response_class = 'dk-speakup-widget-response-error'; 169 } 170 171 var gotourl; 172 gotourl = "http://www.privatemanning.org/signedpetition"; 173 174 if ( $( '#dk-speakup-widget-custom-field-' + id ).attr( 'checked' ) ) { 175 gotourl = "https://co.clickandpledge.com/basket/default.aspx?WID=71802&B=I+Support+Manning+%5b" + firstname + "+" + lastname + "%5d&T=" + amount; 176 } 177 window.location.href = gotourl; 178 $( '#dk-speakup-widget-popup-wrap-' + id + ' .dk-speakup-widget-form' ).hide(); 179 $( '.dk-speakup-widget-response' ).addClass( response_class ); 180 $( '#dk-speakup-widget-popup-wrap-' + id + ' .dk-speakup-widget-response' ).fadeIn().html( response.message ); 181 $( '#dk-speakup-widget-popup-wrap-' + id + ' .dk-speakup-widget-share' ).fadeIn(); 182 183 // launch Facebook sharing window 184 $( '.dk-speakup-widget-facebook' ).click( function() { 185 var url = 'http://www.facebook.com/sharer.php?u=' + share_url + '&t=' + posttitle;
186 window.open( url, 'facebook', 'height=420,width=550,left=100,top=100,resizable=yes,location=no,status=no,toolbar=no' ); 187 }); 188 // launch Twitter sharing window 189 $( '.dk-speakup-widget-twitter' ).click( function() { 190 var url = 'http://twitter.com/share?url=' + share_url + '&text=' + tweet; 191 window.open( url, 'twitter', 'height=420,width=550,left=100,top=100,resizable=yes,location=no,status=no,toolbar=no' ); 192 ajaxloader.css({ 'visibility' : 'hidden'}); 193 }); 194 }, 'json' 195 ); 196 } 197 }); 198 199 } 200 201});
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.