<?php

/* default/template/extension/module/xtensions/checkout/xsocial.twig */
class __TwigTemplate_0011ed7e5f81e13fe063f02c914c66be3878d962b0e128d07f6a00e90d5045c9 extends Twig_Template
{
    public function __construct(Twig_Environment $env)
    {
        parent::__construct($env);

        $this->parent = false;

        $this->blocks = array(
        );
    }

    protected function doDisplay(array $context, array $blocks = array())
    {
        // line 1
        if ((((isset($context["isFacebook"]) ? $context["isFacebook"] : null) || (isset($context["isGoogle"]) ? $context["isGoogle"] : null)) || (isset($context["isLinkedin"]) ? $context["isLinkedin"] : null))) {
            echo " 
<div class=\"login-third-party-login text-center hide_guest\">
<p class=\"login-button-info-text login-info-text\">";
            // line 3
            echo (isset($context["text_social_heading"]) ? $context["text_social_heading"] : null);
            echo "</p>
<div class=\"login-button-container\">
";
            // line 5
            if ((isset($context["isFacebook"]) ? $context["isFacebook"] : null)) {
                echo " 
<div class=\"social-container\">
<div class=\"social-container-box\" onclick=\"xfbLogin();\">
<a href=\"javascript:void(0);\" class=\"login-facebook login-button\"><span class=\"header-sprite login-fb-logo\"></span>";
                // line 8
                echo (isset($context["text_facebook"]) ? $context["text_facebook"] : null);
                echo "</a>
</div>
</div>
";
            }
            // line 11
            echo " 
";
            // line 12
            if ((isset($context["isGoogle"]) ? $context["isGoogle"] : null)) {
                echo " 
<div class=\"social-container\">
<div class=\"social-container-box\" id=\"googleLogin\">
<a href=\"javascript:void(0);\" class=\"login-google login-button\" id=\"gPlusLogin\"><span class=\"header-sprite login-gplus-logo\"></span>";
                // line 15
                echo (isset($context["text_google"]) ? $context["text_google"] : null);
                echo "</a>
</div>
</div>
";
            }
            // line 18
            echo " 
";
            // line 19
            if ((isset($context["isLinkedin"]) ? $context["isLinkedin"] : null)) {
                echo " 
<div class=\"social-container\">
<div class=\"social-container-box\" onclick=\"liLogin();\">
<a href=\"javascript:void(0);\" class=\"login-linkedin login-button\" id=\"linkedinLogin\"><span class=\"header-sprite login-linkedin-logo\"></span>";
                // line 22
                echo (isset($context["text_linkedin"]) ? $context["text_linkedin"] : null);
                echo "</a>
</div>
</div>
";
            }
            // line 25
            echo " 
</div>
</div>
<p class=\"login-info-text text-center hide_guest\">";
            // line 28
            echo (isset($context["text_using_email"]) ? $context["text_using_email"] : null);
            echo "</p>
";
            // line 29
            if ((isset($context["isFacebook"]) ? $context["isFacebook"] : null)) {
                echo " 
<script>
window.fbAsyncInit = function() {
    // FB JavaScript SDK configuration and setup
    FB.init({
      appId      : '";
                // line 34
                echo (isset($context["fb_appId"]) ? $context["fb_appId"] : null);
                echo "', // FB App ID
      cookie     : true,  // enable cookies to allow the server to access the session
      xfbml      : true,  // parse social plugins on this page
      version    : 'v2.8' // use graph api version 2.8
    });   
};
// Load the JavaScript SDK asynchronously
(function(d, s, id) {
    var js, fjs = d.getElementsByTagName(s)[0];
    if (d.getElementById(id)) return;
    js = d.createElement(s); js.id = id;
    js.src = \"//connect.facebook.net/en_US/sdk.js\";
    fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Facebook login with JavaScript SDK
function xfbLogin() {
    FB.login(function (response) {
        if (response.authResponse) {\t\t
            getFbUserData();
        } else {
        \tautherror();
        }
    }, {scope: 'email'});
}
// Fetch the user profile data from facebook
function getFbUserData(){
    FB.api('/me', {locale: 'en_US', fields: 'id,first_name,last_name,email,link,gender,locale,picture'},
    function (response) {
        if(response.email != null){
\t  \t  \tvar id= response.id;
\t  \t  \tvar email = response.email;
\t  \t  \tvar firstname = response.first_name;
\t  \t  \tvar lastname = response.last_name;
\t  \t  \tif(response.picture == null){
\t      \t\tvar pictureUrl = 'blank';
\t      \t}else{        \t
\t      \t\tvar pictureUrl = response.picture;
\t     \t}  \t  \t
\t  \t    var profileurl = response.link;
\t  \t  \tvar platform = 'facebook';
\t  \t  \tvar facebook_data = {id:id,firstname:firstname,lastname:lastname,email:email,pictureUrl:pictureUrl,profileurl:profileurl,platform:platform};
\t    \tupdate_user_data(facebook_data);
        }else{
        \tautherror();
        }
    });
}
</script>
";
            }
            // line 82
            echo " 
";
            // line 83
            if ((isset($context["isGoogle"]) ? $context["isGoogle"] : null)) {
                echo " 
<script src=\"https://apis.google.com/js/platform.js?onload=startGoogleApp\" async defer></script>
<script>
  var googleUser = {};
  var startGoogleApp = function() {
    gapi.load('auth2', function(){
      // Retrieve the singleton for the GoogleAuth library and set up the client.
      auth2 = gapi.auth2.init({
        client_id: '";
                // line 91
                echo (isset($context["google_client_id"]) ? $context["google_client_id"] : null);
                echo "',
        cookiepolicy: 'none',
        // Request scopes in addition to 'profile' and 'email'
        //scope: 'additional_scope'
      });
      attachSignin(document.getElementById('googleLogin'));
    });
  };
  function attachSignin(element) {
    auth2.attachClickHandler(element, {},
        function(googleUser) {
    \t  var profile = googleUser.getBasicProfile();
    \t  var id= profile.getId();
    \t  var email = profile.getEmail();
    \t  var firstname = profile.getGivenName();
    \t  var lastname = profile.getFamilyName();  
    \t  var pictureUrl = profile.getImageUrl();
    \t  var platform = 'google';
    \t  var google_data = {id:id,firstname:firstname,lastname:lastname,email:email,pictureUrl:pictureUrl,platform:platform};  
    \t  update_user_data(google_data); 
        }, function(error) {
            //alert(JSON.stringify(error));
        \tautherror();
        });
  }
</script>
";
            }
            // line 117
            echo " 
";
            // line 118
            if ((isset($context["isLinkedin"]) ? $context["isLinkedin"] : null)) {
                echo " 
<script type=\"text/javascript\" src=\"//platform.linkedin.com/in.js\">
    api_key: ";
                // line 120
                echo (isset($context["linkedin_api_key"]) ? $context["linkedin_api_key"] : null);
                echo " 
</script>  
<script type=\"text/javascript\">
var liLogin = function() {
    IN.UI.Authorize().params({\"scope\":[\"r_basicprofile\", \"r_emailaddress\"]}).place();
    IN.Event.on(IN, 'auth', getProfileData);
}
var getProfileData = function() { // Use the API call wrapper to request the member's basic profile data
\tIN.API.Profile(\"me\").fields(\"id,firstName,lastName,email-address,picture-url,public-profile-url,location:(name)\").result(function (me) {
        var profile = me.values[0];
        var id = profile.id;
        var firstname = profile.firstName;
        var lastname = profile.lastName;
        var email = profile.emailAddress;
        if(profile.pictureUrl == null){
        \tvar pictureUrl = 'blank';
        }else{        \t
        \tvar pictureUrl = profile.pictureUrl;
        }
        var profileUrl = profile.publicProfileUrl;
        var country = profile.location.name;
        var platform = 'linkedin';
        var linkedindata = {id:id,firstname:firstname,lastname:lastname,email:email,profileUrl:profileUrl,pictureUrl:pictureUrl,country:country,platform:platform};       
        update_user_data(linkedindata); 
    });
}
</script>
";
            }
            // line 147
            echo " 
<script>
  function autherror(){
\t  \$('#autherror').remove();
\t  \$('.login-third-party-login').before('<div id=\"autherror\" class=\"alert alert-danger alert-dismissible margintop20\"><button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-label=\"Close\"><span aria-hidden=\"true\">x</span></button>";
            // line 151
            echo (isset($context["error_auth"]) ? $context["error_auth"] : null);
            echo "</div>');
  } 
  function update_user_data(response) {
\t  \$.ajax({
\t        url: 'index.php?route=";
            // line 155
            echo (isset($context["xtensions_controller_path"]) ? $context["xtensions_controller_path"] : null);
            echo "xsocial/validateSocialUser',
\t        type: 'post',
\t        data: response,
\t        dataType: 'json',
\t        beforeSend: function() {                    
\t        \tshowLoader();
\t        },
\t        success: function(json) {        \t\t\t\t
\t            if (json.redirect) {
\t                location = json.redirect;
\t            }else if(json.additionalform){
\t\t\t\t\t";
            // line 166
            if ((isset($context["clean_login"]) ? $context["clean_login"] : null)) {
                echo " 
\t\t\t\t\t\$('#xlogin2').remove();
\t\t\t\t\t\$('#loginPage').hide();
\t\t\t\t\t\$('#xlogin').append('<div id=\"xlogin2\" class=\"login-panel-bg\">'+json.additionalform+'</div>');
\t\t\t\t\t";
            } else {
                // line 170
                echo " 
\t\t\t\t\t\$('#xlogin2').remove();
\t\t\t\t\t\$('#step_login_panel').append('<div id=\"xlogin2\" class=\"login-panel-bg\">'+json.additionalform+'</div>');
\t\t\t\t\t\$('#loginPage').hide();
\t\t\t\t\t";
            }
            // line 174
            echo " \t\t\t\t\t
\t            }  
\t            hideLoader();             
\t        },
\t        error: function(xhr, ajaxOptions, thrownError) {
\t            alert(thrownError + \"\\r\\n\" + xhr.statusText + \"\\r\\n\" + xhr.responseText);
\t        }
\t    });
  }
</script>
";
        }
    }

    public function getTemplateName()
    {
        return "default/template/extension/module/xtensions/checkout/xsocial.twig";
    }

    public function isTraitable()
    {
        return false;
    }

    public function getDebugInfo()
    {
        return array (  268 => 174,  261 => 170,  253 => 166,  239 => 155,  232 => 151,  226 => 147,  195 => 120,  190 => 118,  187 => 117,  157 => 91,  146 => 83,  143 => 82,  91 => 34,  83 => 29,  79 => 28,  74 => 25,  67 => 22,  61 => 19,  58 => 18,  51 => 15,  45 => 12,  42 => 11,  35 => 8,  29 => 5,  24 => 3,  19 => 1,);
    }
}
/* {% if isFacebook or isGoogle or isLinkedin  %} */
/* <div class="login-third-party-login text-center hide_guest">*/
/* <p class="login-button-info-text login-info-text">{{ text_social_heading }}</p>*/
/* <div class="login-button-container">*/
/* {% if isFacebook  %} */
/* <div class="social-container">*/
/* <div class="social-container-box" onclick="xfbLogin();">*/
/* <a href="javascript:void(0);" class="login-facebook login-button"><span class="header-sprite login-fb-logo"></span>{{ text_facebook }}</a>*/
/* </div>*/
/* </div>*/
/* {% endif %} */
/* {% if isGoogle  %} */
/* <div class="social-container">*/
/* <div class="social-container-box" id="googleLogin">*/
/* <a href="javascript:void(0);" class="login-google login-button" id="gPlusLogin"><span class="header-sprite login-gplus-logo"></span>{{ text_google }}</a>*/
/* </div>*/
/* </div>*/
/* {% endif %} */
/* {% if isLinkedin  %} */
/* <div class="social-container">*/
/* <div class="social-container-box" onclick="liLogin();">*/
/* <a href="javascript:void(0);" class="login-linkedin login-button" id="linkedinLogin"><span class="header-sprite login-linkedin-logo"></span>{{ text_linkedin }}</a>*/
/* </div>*/
/* </div>*/
/* {% endif %} */
/* </div>*/
/* </div>*/
/* <p class="login-info-text text-center hide_guest">{{ text_using_email }}</p>*/
/* {% if isFacebook  %} */
/* <script>*/
/* window.fbAsyncInit = function() {*/
/*     // FB JavaScript SDK configuration and setup*/
/*     FB.init({*/
/*       appId      : '{{ fb_appId }}', // FB App ID*/
/*       cookie     : true,  // enable cookies to allow the server to access the session*/
/*       xfbml      : true,  // parse social plugins on this page*/
/*       version    : 'v2.8' // use graph api version 2.8*/
/*     });   */
/* };*/
/* // Load the JavaScript SDK asynchronously*/
/* (function(d, s, id) {*/
/*     var js, fjs = d.getElementsByTagName(s)[0];*/
/*     if (d.getElementById(id)) return;*/
/*     js = d.createElement(s); js.id = id;*/
/*     js.src = "//connect.facebook.net/en_US/sdk.js";*/
/*     fjs.parentNode.insertBefore(js, fjs);*/
/* }(document, 'script', 'facebook-jssdk'));*/
/* // Facebook login with JavaScript SDK*/
/* function xfbLogin() {*/
/*     FB.login(function (response) {*/
/*         if (response.authResponse) {		*/
/*             getFbUserData();*/
/*         } else {*/
/*         	autherror();*/
/*         }*/
/*     }, {scope: 'email'});*/
/* }*/
/* // Fetch the user profile data from facebook*/
/* function getFbUserData(){*/
/*     FB.api('/me', {locale: 'en_US', fields: 'id,first_name,last_name,email,link,gender,locale,picture'},*/
/*     function (response) {*/
/*         if(response.email != null){*/
/* 	  	  	var id= response.id;*/
/* 	  	  	var email = response.email;*/
/* 	  	  	var firstname = response.first_name;*/
/* 	  	  	var lastname = response.last_name;*/
/* 	  	  	if(response.picture == null){*/
/* 	      		var pictureUrl = 'blank';*/
/* 	      	}else{        	*/
/* 	      		var pictureUrl = response.picture;*/
/* 	     	}  	  	*/
/* 	  	    var profileurl = response.link;*/
/* 	  	  	var platform = 'facebook';*/
/* 	  	  	var facebook_data = {id:id,firstname:firstname,lastname:lastname,email:email,pictureUrl:pictureUrl,profileurl:profileurl,platform:platform};*/
/* 	    	update_user_data(facebook_data);*/
/*         }else{*/
/*         	autherror();*/
/*         }*/
/*     });*/
/* }*/
/* </script>*/
/* {% endif %} */
/* {% if isGoogle  %} */
/* <script src="https://apis.google.com/js/platform.js?onload=startGoogleApp" async defer></script>*/
/* <script>*/
/*   var googleUser = {};*/
/*   var startGoogleApp = function() {*/
/*     gapi.load('auth2', function(){*/
/*       // Retrieve the singleton for the GoogleAuth library and set up the client.*/
/*       auth2 = gapi.auth2.init({*/
/*         client_id: '{{ google_client_id }}',*/
/*         cookiepolicy: 'none',*/
/*         // Request scopes in addition to 'profile' and 'email'*/
/*         //scope: 'additional_scope'*/
/*       });*/
/*       attachSignin(document.getElementById('googleLogin'));*/
/*     });*/
/*   };*/
/*   function attachSignin(element) {*/
/*     auth2.attachClickHandler(element, {},*/
/*         function(googleUser) {*/
/*     	  var profile = googleUser.getBasicProfile();*/
/*     	  var id= profile.getId();*/
/*     	  var email = profile.getEmail();*/
/*     	  var firstname = profile.getGivenName();*/
/*     	  var lastname = profile.getFamilyName();  */
/*     	  var pictureUrl = profile.getImageUrl();*/
/*     	  var platform = 'google';*/
/*     	  var google_data = {id:id,firstname:firstname,lastname:lastname,email:email,pictureUrl:pictureUrl,platform:platform};  */
/*     	  update_user_data(google_data); */
/*         }, function(error) {*/
/*             //alert(JSON.stringify(error));*/
/*         	autherror();*/
/*         });*/
/*   }*/
/* </script>*/
/* {% endif %} */
/* {% if isLinkedin  %} */
/* <script type="text/javascript" src="//platform.linkedin.com/in.js">*/
/*     api_key: {{ linkedin_api_key }} */
/* </script>  */
/* <script type="text/javascript">*/
/* var liLogin = function() {*/
/*     IN.UI.Authorize().params({"scope":["r_basicprofile", "r_emailaddress"]}).place();*/
/*     IN.Event.on(IN, 'auth', getProfileData);*/
/* }*/
/* var getProfileData = function() { // Use the API call wrapper to request the member's basic profile data*/
/* 	IN.API.Profile("me").fields("id,firstName,lastName,email-address,picture-url,public-profile-url,location:(name)").result(function (me) {*/
/*         var profile = me.values[0];*/
/*         var id = profile.id;*/
/*         var firstname = profile.firstName;*/
/*         var lastname = profile.lastName;*/
/*         var email = profile.emailAddress;*/
/*         if(profile.pictureUrl == null){*/
/*         	var pictureUrl = 'blank';*/
/*         }else{        	*/
/*         	var pictureUrl = profile.pictureUrl;*/
/*         }*/
/*         var profileUrl = profile.publicProfileUrl;*/
/*         var country = profile.location.name;*/
/*         var platform = 'linkedin';*/
/*         var linkedindata = {id:id,firstname:firstname,lastname:lastname,email:email,profileUrl:profileUrl,pictureUrl:pictureUrl,country:country,platform:platform};       */
/*         update_user_data(linkedindata); */
/*     });*/
/* }*/
/* </script>*/
/* {% endif %} */
/* <script>*/
/*   function autherror(){*/
/* 	  $('#autherror').remove();*/
/* 	  $('.login-third-party-login').before('<div id="autherror" class="alert alert-danger alert-dismissible margintop20"><button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">x</span></button>{{ error_auth }}</div>');*/
/*   } */
/*   function update_user_data(response) {*/
/* 	  $.ajax({*/
/* 	        url: 'index.php?route={{ xtensions_controller_path }}xsocial/validateSocialUser',*/
/* 	        type: 'post',*/
/* 	        data: response,*/
/* 	        dataType: 'json',*/
/* 	        beforeSend: function() {                    */
/* 	        	showLoader();*/
/* 	        },*/
/* 	        success: function(json) {        				*/
/* 	            if (json.redirect) {*/
/* 	                location = json.redirect;*/
/* 	            }else if(json.additionalform){*/
/* 					{% if clean_login  %} */
/* 					$('#xlogin2').remove();*/
/* 					$('#loginPage').hide();*/
/* 					$('#xlogin').append('<div id="xlogin2" class="login-panel-bg">'+json.additionalform+'</div>');*/
/* 					{% else %} */
/* 					$('#xlogin2').remove();*/
/* 					$('#step_login_panel').append('<div id="xlogin2" class="login-panel-bg">'+json.additionalform+'</div>');*/
/* 					$('#loginPage').hide();*/
/* 					{% endif %} 					*/
/* 	            }  */
/* 	            hideLoader();             */
/* 	        },*/
/* 	        error: function(xhr, ajaxOptions, thrownError) {*/
/* 	            alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);*/
/* 	        }*/
/* 	    });*/
/*   }*/
/* </script>*/
/* {% endif %}*/
/* */
