orbit-basic/app/views/basic_infos/index.html.erb

61 lines
2.1 KiB
Plaintext

<%= stylesheet_link_tag "sign_up" %>
<section id="main-wrap">
<div class="sign-up have-other-sign-in facebook-form">
<div class="form">
<h3 class="login-logo">Please select a method for Basic Info</h3>
<div class="option-block">
<a href="<%= basic_infos_form_path(:user_id=>@user.id.to_s) %>" class="btn btn-info btn-large">Form</a>
<div class="or">
<div class="line left"></div>
<span>OR</span>
<div class="line right"></div>
</div>
<a href="javascript:void(0);" class="facebook"><img src="assets/facebook-logo.png" /></a>
</div>
<div class="option-block msg alert hide"><h4></h4><br /><a href="<%= basic_infos_role_page_path(:user_id => @user.id.to_s) %>" class="btn btn-primary hide">Next</a></div>
</div>
</div>
</section>
<script type="text/javascript">
(function(){
var facebookWindow = null,
timeInterval = null;
$("a.facebook").click(function(){
facebookWindow = window.open('<%= facebook_server_path(:user_id=>@user.id.to_s) %>','login_window','height=668,width=1124,titlebar=0,statusbar=0,location=0');
clearInterval(timeInterval);
timeInterval = setInterval(function(){
if( facebookWindow.closed ){
clearInterval(timeInterval);
$(".msg").removeClass('hide alert-danger').find("h4").text("Importing,please wait...");
$.ajax({
url : "/facebook/profile_import",
data : {"user_id":"<%= @user.id.to_s %>"},
type : "get",
dataType : "json",
success : function(data){
if(!data.success){
$(".msg").removeClass('hide').addClass('alert-danger').find("h4").text(data.message);
}else{
var msg = "";
if (data.user.first_name){
msg+= "Welcome " + data.user.first_name + ", your data is successfully imported!"
}else{
msg = "Import Succesfull!"
}
$(".msg").removeClass('hide').addClass('alert-success').find("h4").text(msg);
$(".msg a").removeClass('hide');
}
},
error : function(){
$(".msg").removeClass('hide').addClass('alert-danger').find("h4").text("Error connecting the server!");
}
})
}
},1000);
})
})()
</script>