/*
backtotop.js
by sunhw 2014-12-2
*/
;
(function() {
T.dom.ready( function() {
var dom = T.get( ‘gototopwrap‘ ), timer = 0;
var map = {
scroH : 450,
pageH : 230,
ttl : 500
};
if ( T.page.getViewHeight() < map.pageH || !dom ) {
return;
}
var scrollHandle = function() {
clearTimeout( timer );
timer = setTimeout( function() {
if ( T.page.getScrollTop() > map.scroH ) {
T.dom.setStyle( dom, "visibility", "visible" );
} else {
T.dom.setStyle( dom, "visibility", "hidden" );
}
}, map.ttl );
};
T.un( window, ‘scroll‘, scrollHandle );
T.on( window, ‘scroll‘, scrollHandle );
window.fixedIE6 && window.fixedIE6();
} );
})();
/*
backtotop.js
by sunhw 2014-10-24
*/
;(function(){
function BackTotop(option){
this.map = {
sh : 200, //getScrollTop
ttl : 500, //延迟时间
vh : 227 //getViewHeight
};
this.option = T.object.extend({
root : ‘‘
}, option || {});
this.ie6 = T.browser.ie < 7;
this.init();
}
BackTotop.prototype.init = function(){
var me = this;
if(T.page.getViewHeight() < me.map.vh) return;
me.scrollHandle = function(){
me.timer = null;
clearTimeout(me.timer);
if(me.ie6){
if(T.get(‘gototopwrap‘)){
T.hide(‘gototopwrap‘);
}
}
me.timer = setTimeout(function(){
if(T.page.getScrollTop() > me.map.sh){
me.tpl = ‘<div class="gototop" id="gototopwrap"><a class="totop-btn" id="totopBtn" href="javascript:void(window.scroll(0,0));" hidefocus></a></div>‘;
if(!T.get(‘gototopwrap‘)){
T.dom.insertHTML(T.get(me.option.root), ‘afterBegin‘, me.tpl);
}
if(me.ie6){
if(T.get(‘gototopwrap‘)){
T.get(‘gototopwrap‘).style.top = (T.page.getViewHeight()-me.map.sh)+ T.page.getScrollTop() + ‘px‘;
T.show(‘gototopwrap‘);
}
}
}else{
if(T.get(‘gototopwrap‘)){
T.dom.remove(T.get(‘gototopwrap‘));
}
}
}, me.map.ttl);
};
T.on(window, ‘scroll‘, me.scrollHandle);
}
T.dom.ready(function(){
var gototop = new BackTotop({
root : ‘footer‘
});
});
})();