AD 对联

/*
对联广告 首页、检索页、搜索、媒体页
by sunhw 2014-12-16
*/
;(function() {
if( F.config.isWangjs ){
return;
}
function Couplet( option ) {
this.option = T.object.extend( {
root : '',
position : '',
zindex : '',
top : '',
right : '',
left : ''
}, option || {} );
this.init();
}
Couplet.prototype.resize = function() {
var me = this;
var maxWidth = ( F.config.isFsHost == false && F.config.isFsDomain == true ) ? 0 : 1400,
pageWidth = T.page.getViewWidth();
if ( pageWidth >= maxWidth ) {
if ( T.get( 'coupletad' ) ) {
T.show( T.get( 'coupletad' ) );
}
} else {
if ( T.get( 'coupletad' ) ) {
T.hide( T.get( 'coupletad' ) );
}
}
};
Couplet.prototype.init = function() {
var me = this;
if ( T.get( 'coupletad' ) ) {
return;
}
var fck = F.cookie.get('fck'),
uid = F.user.userid,
url = window.location.href,
match = [],
mid = '',
timer = 0,
ttl = 2000,
refer = document.referrer;
if( url ){
match = url.match(/\d+/g);
}
if( match ){
mid = String(match[0]);
}
var requestURL = "http://pub.funshion.com/interface/deliver?ap=w_a_couplet&fck=" + fck + "&uid=" + uid + "&url=" + url + "&refer=" + refer + "&mid=" + mid;
F.http.jsonp( requestURL, function( json ) {
if ( !json ) {
return;
}
var data = json[ 0 ].ad_list[ 0 ];
if ( !data ) {
return;
}
var reportURL = data.monitor,
width = data.width ,
height = data.height,
closeSrc = data.close || 'http://adm.funshion.com/mat/20140704162826-10271647.png',
leftURl = data.LeftMaterial,
rightURl = data.RightMaterial;
var wrapHTML = '<div id="coupletad"></div>';
var leftHTML = '<iframe width="' + width + 'px" height="' + height + 'px" frameborder="0" scrolling="no" allowtransparency="true" hspace="0" vspace="0" marginwidth="0" marginheight="0" src="' + leftURl + '"></iframe><a href="javascript:;" class="close-bnt" style="display:none;background:url(' + closeSrc + ') no-repeat 0 0;position:absolute;top:0;left:0;width:18px;height:18px;"></a>';
var rightHTML = '<iframe width="' + width + 'px" height="' + height + 'px" frameborder="0" scrolling="no" allowtransparency="true" hspace="0" vspace="0" marginwidth="0" marginheight="0" src="' + rightURl + '"></iframe><a href="javascript:;" class="close-bnt" style="display:none;background:url(' + closeSrc + ') no-repeat 0 0;position:absolute;top:0;right:0;width:18px;height:18px;"></a>';
var layoutHTML = '<div class="fixedIe6" id="coup_ad_left" style="width:'+width+'px;height:'+height+'px;position:'+me.option.position+';left:'+me.option.left+';top:'+me.option.top+'px;z-index:'+me.option.zindex+';">' + leftHTML + '</div><div class="fixedIe6" id="coup_ad_right" style="width:'+width+'px;height:'+height+'px;position:'+me.option.position+';right:'+me.option.right+';top:'+me.option.top+'px;z-index:'+me.option.zindex+';">' + rightHTML + '</div>';
T.dom.insertHTML( T.query( 'body' )[ 0 ], 'beforeEnd', wrapHTML );
T.get( 'coupletad' ).innerHTML = layoutHTML;
clearTimeout( timer );
timer = setTimeout( function() {
T.each( T.query( '.close-bnt' ), function( item ) {
T.dom.setStyle( item, 'display', 'block' );
T.on( item, 'click', function( e ) {
T.event.stop( T.event.get( e ) );
if ( T.get( 'coupletad' ) ) {
T.dom.remove( T.get( 'coupletad' ) );
}
} );
} );;
}, ttl );
(new Image).src = reportURL;
} );
T.un( window, 'resize', me.resize );
T.on( window, 'resize', me.resize );
};
T.dom.ready( function() {
var maxWidth = ( F.config.isFsHost == false && F.config.isFsDomain == true ) ? 0 : 1400, mask = false;
var couplet = null;
function _init() {
if ( mask == false && T.page.getViewWidth() >= maxWidth && T.array.indexOf( [ 'index_', 'list_', 'search_media', 'subject_' ], F.config.ctrlname ) > -1 ) {
mask = true;
couplet = new Couplet( {
root : 'body',
position : 'fixed',
zindex : 9,
top : 240,
right : 0,
left : 0
} );
}
}
_init();
T.un( window, 'resize', _init );
T.on( window, 'resize', _init );
} );
})();

posted @ 2014-12-28 17:04  sunhw360  阅读(160)  评论(0编辑  收藏  举报