1jQuery(document).ready(function($){ 2 3 var Facebook = { 4 5 $buttonClicked: '', 6 7 init: function(){ 8 9 var tries = 0; 10 11 var runned = setInterval( function(){ 12 13 if( window.FB ){ 14 clearInterval(runned); 15 Facebook.run(); 16 } 17 18 if( tries >= 20 ){ 19 clearInterval(runned); 20 } 21 22 tries++; 23 24 }, 500 ); 25 26 27 28 }, 29 30 run: function(){ 31 32 FB.init({ 33 appId : xoo_sl_localize.facebook.app_id, 34 cookie : true, 35 xfbml : true, 36 status : true, 37 version : 'v16.0', 38 }); 39 40 FB.AppEvents.logPageView(); 41 42 Facebook.configureButton(); 43 44 45 }, 46 47 configureButton(){ 48 49 $(document.body).on( 'click', '.xoo-sl-btn-facebook', function(e){ 50 Facebook.processLoginOnClick( $(this) ); 51 }); 52 53 }, 54 55 processLoginOnClick($button){ 56 57 FB.login(function(response) { 58 59 if (response.status === 'connected') { 60 // Logged into your webpage and Facebook. 61 Processor.init( response, 'facebook', $button); 62 } 63 64 }, {scope: 'public_profile,email', auth_type: 'rerequest'}); 65 }, 66 67 68 } 69 70 if( xoo_sl_localize.facebook.enable === "yes" ){ 71 Facebook.init(); 72 } 73 74 var Apple = { 75 76 $buttonClicked: '', 77 78 init: function(){ 79 80 var tries = 0; 81 82 var runned = setInterval( function(){ 83 84 if( window.AppleID ){ 85 clearInterval(runned); 86 Apple.run(); 87 } 88 89 if( tries >= 20 ){ 90 clearInterval(runned); 91 } 92 93 tries++; 94 95 }, 500 ); 96 97 }, 98 99 run: function(){ 100 101 AppleID.auth.init(xoo_sl_localize.apple.initArgs); 102 103 if( !$('.xoo-sl-apple-login-btn > div').length ) return; 104 105 var originalButtonHTML = $('.xoo-sl-apple-login-btn > div').parent().html(); 106 107 $('.xoo-sl-apple-login-btn').each(function(index, el){ 108 var $el = $(el); 109 110 $el.html(originalButtonHTML); 111 $el.on('click', function(){ 112 Apple.$buttonClicked = $el; 113 AppleID.auth.signIn(); 114 }) 115 116 }) 117 118 $(document).on('AppleIDSignInOnSuccess', Apple.onLoginSuccess ); 119 120 }, 121 122 onLoginSuccess: function(e){ 123 console.log(e); 124 Processor.init( e.detail, 'apple', Apple.$buttonClicked ); 125 } 126 127 } 128 129 if( xoo_sl_localize.apple.enable === "yes" ){ 130 Apple.init(); 131 } 132 133 134 135 136 var Google = { 137 138 $buttonClicked: '', 139 140 141 init: function(){ 142 143 var tries = 0; 144 145 var runned = setInterval( function(){ 146 147 if( window.google ){ 148 clearInterval(runned); 149 Google.run(); 150 } 151 152 if( tries >= 20 ){ 153 clearInterval(runned); 154 } 155 156 tries++; 157 158 }, 500 ); 159 160 }, 161 162 run: function(){ 163 164 var initArgs = { 165 client_id: xoo_sl_localize.google.client_id, 166 callback: Google.callback, 167 ux_mode: xoo_sl_localize.google.ux_mode 168 } 169 170 if( initArgs.ux_mode === 'redirect' ){ 171 initArgs.login_uri = xoo_sl_localize.siteurl.slice(-1) === '/' ? xoo_sl_localize.siteurl : xoo_sl_localize.siteurl+'/' 172 } 173 174 google.accounts.id.initialize( initArgs ); 175 176 Google.renderButtons(); 177 }, 178 179 180 renderButtons: function(){ 181 182 var buttonParams = xoo_sl_localize.google.button; 183 184 $('.xoo-sl-goo-btn').each(function( index, el ){ 185 186 buttonParams.click_listener = function(){ 187 Google.$buttonClicked = $(el); 188 } 189 190 google.accounts.id.renderButton( 191 el, 192 xoo_sl_localize.google.button 193 ); 194 }) 195 }, 196 197 callback: function(response){ 198 Processor.init( response, 'google', Google.$buttonClicked ); 199 }, 200 201 202 203 } 204 205 if( xoo_sl_localize.google.enable === "yes" ){ 206 Google.init(); 207 } 208 209 var Processor = { 210 211 social: '', 212 $button: '', 213 $buttonContainer: '', 214 $easyLoginSection: '', 215 $easyLoginContainer: '', 216 $loader: '', 217 isEasyLogin: '', 218 219 220 init: function( socialData, socialType, $button ){ 221 222 Processor.$button = $button; 223 Processor.$buttonContainer = $button.parents('.xoo-sl-container'); 224 Processor.$easyLoginSection = $button.parents('.xoo-el-section'); 225 Processor.isEasyLogin = Processor.$easyLoginSection.length; 226 Processor.$easyLoginContainer = Processor.$easyLoginSection.parents('.xoo-el-form-container'); 227 Processor.$loader = Processor.$buttonContainer.find('.xoo-sl-processing'); 228 229 230 Processor.$buttonContainer.find('.xoo-sl-processing').show(); 231 232 $.ajax({
233 url: xoo_sl_localize.adminurl, 234 type: 'POST', 235 data: { 236 action: 'xoo_sl_process_social_response', 237 socialData: socialData, 238 socialType: socialType, 239 isEasyLogin: Processor.$easyLoginSection.length ? 'yes' : 'no' 240 }, 241 success: function(response){ 242 243 if( response.success === 'false' && response.message ){ 244 $('.xoo-sl-notice-container').html(response.message); 245 Processor.$loader.hide(); 246 } 247 248 if( response.success === "true" ){ 249 250 Processor.$loader.find('span').text( response.message ) 251 252 var redirectTo = xoo_sl_localize.redirect_to; 253 254 if( Processor.isEasyLogin && Processor.$easyLoginSection.find('input[name="xoo_el_redirect"]').length ){ 255 redirectTo = Processor.$easyLoginSection.find('input[name="xoo_el_redirect"]').val(); 256 } 257 258 window.location = redirectTo; 259 } 260 261 if( response.register && response.register === "yes" ){ 262 Processor.forceRegister( response.userData ); 263 } 264 265 $(document).trigger('xoo_sl_processing_userinfo',[response]); 266 } 267 }); 268 }, 269 270 271 forceRegister: function( userData ){ 272 273 Processor.$loader.hide(); 274 275 var $registrationSection = Processor.$easyLoginContainer.find('[data-section="register"]'); 276 277 if( !$registrationSection.length ){ 278 $registrationSection = $('.xoo-el-form-popup').find('[data-section="register"]'); 279 if( !$registrationSection.length ){ 280 alert('no registration form found.'); 281 return; 282 } 283 $('.xoo-el-forcereg-tgr').trigger('click'); //open popup 284 } 285 286 Processor.$easyLoginContainer.find('.xoo-el-forcereg-tgr').trigger('click'); 287 288 var $email = $('.xoo-el-form-container input[name="xoo_el_reg_email"]'), 289 $firstName = $('.xoo-el-form-container input[name="xoo_el_reg_fname"]'), 290 $lastName = $('.xoo-el-form-container input[name="xoo_el_reg_lname"]'); 291 292 if( $email.length ) $email.val(userData.email); 293 294 if( $firstName.length ) $firstName.val(userData.first_name); 295 296 if( $lastName.length ) $lastName.val(userData.last_name); 297 298 $registrationSection.find('.xoo-el-notice').html(xoo_sl_localize.fillFieldsNotice).show(); 299 } 300 301 } 302 303 $('body').on( 'mouseenter', '.xoo-sl-btns-container', function(){ 304 305 var redirectTo = xoo_sl_localize.redirect_to, 306 $easyLoginCont = $(this).closest('.xoo-el-form-container'); 307 308 if( $easyLoginCont.length && $easyLoginCont.find('input[name="xoo_el_redirect"]').length ){ 309 redirectTo = $easyLoginCont.find('input[name="xoo_el_redirect"]').val(); 310 } 311 312 document.cookie = 'xoo_sl_redirect='+redirectTo+'; path=/'; 313 314 } ); 315 316 317})
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.