1(function($){ 2 $.fn.extend( { 3 share_is_email: function( value ) { 4 return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test( this.val() ); 5 } 6 } ); 7 8 $( document ).on( 'ready post-load', function() { 9 var $more_sharing_buttons = $( '.sharing a.sharing-anchor' ); 10 11 $more_sharing_buttons.click( function() { 12 return false; 13 } ); 14 15 $( '.sharing a' ).each( function() { 16 if ( $( this ).attr( 'href' ) && $( this ).attr( 'href' ).indexOf( 'share=' ) != -1 ) 17 $( this ).attr( 'href', $( this ).attr( 'href' ) + '&nb=1' ); 18 } ); 19 20 // Show hidden buttons 21 22 // Touchscreen device: use click. 23 // Non-touchscreen device: use click if not already appearing due to a hover event 24 $more_sharing_buttons.click( function() { 25 var $more_sharing_button = $( this ), 26 $more_sharing_pane = $more_sharing_button.parents( 'div:first' ).find( '.inner' ); 27 28 if ( $more_sharing_pane.is( ':animated' ) ) { 29 // We're in the middle of some other event's animation 30 return; 31 } 32 33 if ( true === $more_sharing_pane.data( 'justSlid' ) ) { 34 // We just finished some other event's animation - don't process click event so that slow-to-react-clickers don't get confused 35 return; 36 } 37 38 $( '#sharing_email' ).slideUp( 200 ); 39 40 $more_sharing_pane.css( { 41 left: $more_sharing_button.position().left + 'px', 42 top: $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px' 43 } ).slideToggle( 200 ); 44 } ); 45 46 if ( document.ontouchstart === undefined ) { 47 // Non-touchscreen device: use hover/mouseout with delay 48 $more_sharing_buttons.hover( function() { 49 var $more_sharing_button = $( this ), 50 $more_sharing_pane = $more_sharing_button.parents( 'div:first' ).find( '.inner' ); 51 52 if ( !$more_sharing_pane.is( ':animated' ) ) { 53 // Create a timer to make the area appear if the mouse hovers for a period 54 var timer = setTimeout( function() { 55 $( '#sharing_email' ).slideUp( 200 ); 56 57 $more_sharing_pane.data( 'justSlid', true ); 58 $more_sharing_pane.css( { 59 left: $more_sharing_button.position().left + 'px', 60 top: $more_sharing_button.position().top + $more_sharing_button.height() + 3 + 'px' 61 } ).slideDown( 200, function() { 62 // Mark the item as have being appeared by the hover 63 $more_sharing_button.data( 'hasoriginal', true ).data( 'hasitem', false ); 64 65 // Remove all special handlers 66 $more_sharing_pane.mouseleave( handler_item_leave ).mouseenter( handler_item_enter ); 67 $more_sharing_button.mouseleave( handler_original_leave ).mouseenter( handler_original_enter ); 68 setTimeout( function() { 69 $more_sharing_pane.data( 'justSlid', false ); 70 }, 300 ); 71 } ); 72 73 // The following handlers take care of the mouseenter/mouseleave for the share button and the share area - if both are left then we close the share area 74 var handler_item_leave = function() { 75 $more_sharing_button.data( 'hasitem', false ); 76 77 if ( $more_sharing_button.data( 'hasoriginal' ) === false ) { 78 var timer = setTimeout( close_it, 800 ); 79 $more_sharing_button.data( 'timer2', timer ); 80 } 81 }; 82 83 var handler_item_enter = function() { 84 $more_sharing_button.data( 'hasitem', true ); 85 clearTimeout( $more_sharing_button.data( 'timer2' ) ); 86 } 87 88 var handler_original_leave = function() { 89 $more_sharing_button.data( 'hasoriginal', false ); 90 91 if ( $more_sharing_button.data( 'hasitem' ) === false ) { 92 var timer = setTimeout( close_it, 800 ); 93 $more_sharing_button.data( 'timer2', timer ); 94 } 95 }; 96 97 var handler_original_enter = function() { 98 $more_sharing_button.data( 'hasoriginal', true ); 99 clearTimeout( $more_sharing_button.data( 'timer2' ) ); 100 }; 101 102 var close_it = function() { 103 $more_sharing_pane.data( 'justSlid', true ); 104 $more_sharing_pane.slideUp( 200, function() { 105 setTimeout( function() { 106 $more_sharing_pane.data( 'justSlid', false ); 107 }, 300 ); 108 } ); 109 110 // Clear all hooks 111 $more_sharing_button.unbind( 'mouseleave', handler_original_leave ).unbind( 'mouseenter', handler_original_enter ); 112 $more_sharing_pane.unbind( 'mouseleave', handler_item_leave ).unbind( 'mouseenter', handler_item_leave ); 113 return false;
114 }; 115 }, 200 ); 116 117 // Remember the timer so we can detect it on the mouseout 118 $more_sharing_button.data( 'timer', timer ); 119 } 120 }, function() { 121 // Mouse out - remove any timer 122 $more_sharing_buttons.each( function() { 123 clearTimeout( $( this ).data( 'timer' ) ); 124 } ); 125 $more_sharing_buttons.data( 'timer', false ); 126 } ); 127 } 128 129 // Add click functionality 130 $( '.sharing ul' ).each( function( item ) { 131 printUrl = function ( uniqueId, urlToPrint ) { 132 $( 'body:first' ).append( '<iframe style="position:fixed;top:100;left:100;height:1px;width:1px;border:none;" id="printFrame-' + uniqueId + '" name="printFrame-' + uniqueId + '" src="' + urlToPrint + '" onload="frames[\'printFrame-' + uniqueId + '\'].focus();frames[\'printFrame-' + uniqueId + '\'].print();"></iframe>' ) 133 }; 134 135 // Print button 136 $( this ).find( '.share-print a' ).click( function() { 137 ref = $( this ).attr( 'href' ); 138 139 var do_print = function() { 140 if ( ref.indexOf( '#print' ) == -1 ) { 141 uid = new Date().getTime(); 142 printUrl( uid , ref ); 143 } 144 else 145 print(); 146 } 147 148 // Is the button in a dropdown? 149 if ( $( this ).parents( '.sharing-hidden' ).length > 0 ) { 150 $( this ).parents( '.inner' ).slideUp( 0, function() { 151 do_print(); 152 } ); 153 } 154 else 155 do_print(); 156 157 return false; 158 } ); 159 160 // Press This button 161 $( this ).find( '.share-press-this a' ).click( function() { 162 var s = ''; 163 164 if ( window.getSelection ) 165 s = window.getSelection(); 166 else if( document.getSelection ) 167 s = document.getSelection(); 168 else if( document.selection ) 169 s = document.selection.createRange().text; 170 171 if ( s ) 172 $( this ).attr( 'href', $( this ).attr( 'href' ) + '&sel=' + encodeURI( s ) ); 173 174 if ( !window.open( $( this ).attr( 'href' ), 't', 'toolbar=0,resizable=1,scrollbars=1,status=1,width=720,height=570' ) ) 175 document.location.href = $( this ).attr( 'href' ); 176 177 return false; 178 } ); 179 180 // Email button 181 $( this ).find( '.share-email a' ).click( function() { 182 var url = $( this ).attr( 'href' ); 183 184 if ( $( '#sharing_email' ).is( ':visible' ) ) 185 $( '#sharing_email' ).slideUp( 200 ); 186 else { 187 $( '.sharing .inner' ).slideUp(); 188 189 $( '#sharing_email .response' ).remove(); 190 $( '#sharing_email form' ).show(); 191 $( '#sharing_email form input[type=submit]' ).removeAttr( 'disabled' ); 192 $( '#sharing_email form a.sharing_cancel' ).show(); 193 194 // Show dialog 195 $( '#sharing_email' ).css( { 196 left: $( this ).offset().left + 'px', 197 top: $( this ).offset().top + $( this ).height() + 'px' 198 } ).slideDown( 200 ); 199 200 // Hook up other buttons 201 $( '#sharing_email a.sharing_cancel' ).unbind( 'click' ).click( function() { 202 $( '#sharing_email .errors' ).hide(); 203 $( '#sharing_email' ).slideUp( 200 ); 204 $( '#sharing_background' ).fadeOut(); 205 return false; 206 } ); 207 208 // Submit validation 209 $( '#sharing_email input[type=submit]' ).unbind( 'click' ).click( function() { 210 var form = $( this ).parents( 'form' ); 211 212 // Disable buttons + enable loading icon 213 $( this ).attr( 'disabled', 'disabled' ); 214 form.find( 'a.sharing_cancel' ).hide();
215 form.find( 'img.loading' ).show(); 216 217 $( '#sharing_email .errors' ).hide(); 218 $( '#sharing_email .error' ).removeClass( 'error' ); 219 220 if ( $( '#sharing_email input[name=source_email]' ).share_is_email() == false ) 221 $( '#sharing_email input[name=source_email]' ).addClass( 'error' ); 222 223 if ( $( '#sharing_email input[name=target_email]' ).share_is_email() == false ) 224 $( '#sharing_email input[name=target_email]' ).addClass( 'error' ); 225 226 if ( $( '#sharing_email .error' ).length == 0 ) { 227 // AJAX send the form 228 $.ajax( { 229 url: url, 230 type: 'POST', 231 data: form.serialize(), 232 success: function( response ) { 233 form.find( 'img.loading' ).hide(); 234 235 if ( response == '1' || response == '2' || response == '3' ) { 236 $( '#sharing_email .errors-' + response ).show(); 237 form.find( 'input[type=submit]' ).removeAttr( 'disabled' ); 238 form.find( 'a.sharing_cancel' ).show(); 239 } 240 else { 241 $( '#sharing_email form' ).hide(); 242 $( '#sharing_email' ).append( response ); 243 $( '#sharing_email a.sharing_cancel' ).click( function() { 244 $( '#sharing_email' ).slideUp( 200 ); 245 $( '#sharing_background' ).fadeOut(); 246 return false; 247 } ); 248 } 249 } 250 } ); 251 252 return false; 253 } 254
255 form.find( 'img.loading' ).hide(); 256 form.find( 'input[type=submit]' ).removeAttr( 'disabled' ); 257 form.find( 'a.sharing_cancel' ).show(); 258 $( '#sharing_email .errors-1' ).show(); 259 260 return false; 261 } ); 262 } 263 264 return false; 265 } ); 266 } ); 267 268 $( 'li.share-email, li.share-custom a.sharing-anchor' ).addClass( 'share-service-visible' ); 269 } ); 270})( 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.