2017.2.21

左侧和头部的导航滑动栏

$(function () {
if (navigator.platform.indexOf('Win32') != -1) {
var btop = parseInt($('#myTab').offset().top);
var statich = parseInt($('#myTab').css('height'));
var daytabtop = parseInt($('#daytab').offset().top);
var daytabhidelength = parseInt($('#myTabContent').css('height'));
var number = $('#daytab').children('li').length;
var alllength = 0;
var clonemyTab = $('#myTab').clone();
clonemyTab.attr("id", "myTabClone");

$('#daytab').children('li').each(function () {
var divindex = parseInt($(this).index() + 1);
if ($("#day" + divindex).length) {
if (!isNaN(parseInt($("#day" + divindex).css('height')))) {
alllength += parseInt($("#day" + divindex).css('height'));
}
}
})

$(window).scroll(function () {
var hidelength = parseInt($('#myTabContent').css('height'));
var isIE = !-[1, ];
var isIE6 = isIE && !window.XMLHttpRequest;
if (isIE6) { return false; }
if (document.documentElement && document.documentElement.scrollTop) {
var newtop = document.documentElement.scrollTop;
} else {
var newtop = document.body.scrollTop;
}
if (newtop >= btop) {
if (!$("#myTabClone").length) {
$('#myTab').parent().prepend(clonemyTab);
}
$('#myTab').css('position', 'fixed'); $('#myTab').css('top', '0px');
} else {
if ($("#myTabClone").length) {
$('#myTabClone').remove();
}
$('#myTab').css('position', 'static');
}
if (newtop >= daytabtop && newtop <= (daytabtop + alllength - statich)) {
$('#daytab').css('position', 'fixed'); $('#daytab').css('top', '0px'); $('#daytab').children("li").css('float', 'none');
} else {
$('#daytab').css('position', 'static');
}

$("[data-tourl]").each(function () {
var urlat = $(this).attr("data-tourl");
var toprourl = parseInt($(this).offset().top);

if (newtop >= (toprourl - statich-1)) {
$('#myTab').children('li').removeClass("active");
$("[data-url='" + urlat + "']").parent().addClass("active");
}
})


$('#daytab').children('li').each(function () {
var divindex = parseInt($(this).index() + 1);
var divtop;
if ($("#day" + divindex).length) {
divtop = parseInt($("#day" + divindex).offset().top);
}

if (newtop >= (divtop - statich)) {
$('#daytab').children('li').removeClass("active");
$(this).addClass("active");
}
})
});

/*点击头部导航跳转*/
$('#myTab li a').click(function () {
var tourl = $(this).attr("data-url");
if ($("[data-tourl='" + tourl + "']").length) {
var htop = parseInt($("[data-tourl='" + tourl + "']").offset().top);
}
$('#daytab').children('li').removeClass("active");
$('#daytab').children('li:eq(0)').addClass("active");


$('#myTab').css('position', 'fixed'); $('#myTab').css('top', '0px');
$("html,body").animate({ scrollTop: (htop - statich) }, 0);
})

/*点击左侧导航跳转*/
$('#daytab').children('li').click(function () {
var divindex = parseInt($(this).index() + 1);
var divtop;
if ($("#day" + divindex).length) {
divtop = parseInt($("#day" + divindex).offset().top);
}

$('#myTab').css('position', 'fixed'); $('#myTab').css('top', '0px');
$("html,body").animate({ scrollTop: (divtop - statich) }, 0);
})
}
})

 

facebook联合登录

function statusChangeCallback(response) {

if (response.status === 'connected') {
var accessToken = response.authResponse.accessToken;
console.log(accessToken);
FB.api('/me?fields=name,first_name,last_name,email', function(response) {
console.log(response);
if(accessToken&&response.email){

}else {
alert("Longin failed!Please retry again1.");
}
});
}
}


facebookLogin=function(){
FB.login(function(response){
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
},{scope:'email'});
}

window.fbAsyncInit = function() {
FB.init({
appId : 'youid',
cookie : true,
xfbml : true,
version : 'v2.8'
});
};

// Load the 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'));

posted on 2017-02-21 18:03  月下华光  阅读(135)  评论(0编辑  收藏  举报

导航