首页 > 代码库 > 展开收起播放列表
展开收起播放列表
//播放器关闭展开播放列表 by sunhw
(function() {
function PlayFold( option ) {
this.option = T.object.extend( {
root : ‘‘,
foldBtn : ‘‘,
playListLayout : ‘‘,
packupWrap : ‘‘
}, option || {} );
this.init();
}
PlayFold.prototype.changePlayBox = function( ags ) {
var self = this;
self.ags = ags || {};
if ( self.ags.btnClass == false ) {
self.fewer();
} else {
self.unfold();
}
/* 广播播放器列表展开收起 */
( self.ags.btnClass == false ) ? T.observer.send( F.EventCenter.PLAYLIST_COLLAPSE ) : T.observer.send( F.EventCenter.PLAYLIST_EXPAND );
};
PlayFold.prototype.fewer = function() {
var self = this;
F.tween( self.option.playListLayout, F.math.tweener.easeInExpo, 0.2, { right : -350 }, function() {
setTimeout(function() {
T.dom.addClass( self.option.root, ‘maxbox‘ );
}, 0 );
} );
T.dom.setStyles(self.option.packupWrap, { ‘width‘ : 30, ‘right‘: 0});
T.dom.addClass( self.foldBtn, ‘unfold‘ );
};
PlayFold.prototype.unfold = function() {
var self = this;
F.tween( self.option.playListLayout, F.math.tweener.easeInOutCubic, 0.2, { right : 0 }, function() {
setTimeout(function() {
T.dom.setStyles(self.option.packupWrap, {‘width‘ : 12, ‘right‘: 318 });
T.dom.removeClass( self.foldBtn, ‘unfold‘ );
T.dom.removeClass( self.option.root, ‘maxbox‘ );
}, 0 );
} );
};
PlayFold.prototype.init = function() {
var self = this;
if ( mp.visible ) { return; }
self.root = T.get( self.option.root );
self.foldBtn = T.get( self.option.foldBtn );
//点击展开收起按钮,传参当前的pageWidth,按钮是否有unfold CLASSNAME
T.on( self.foldBtn, ‘click‘, function() {
self.changePlayBox( {
btnClass : T.dom.hasClass( self.foldBtn, ‘unfold‘ )
} );
} );
T.observer.add(‘playEvent.start_play‘, function(){
self.fewer();
});
};
new PlayFold( {
root : ‘video-play-box‘,
foldBtn : ‘pack-up-btn‘,
playListLayout : ‘play-list-layout‘,
packupWrap : ‘packup-wrap‘
} );
})();
/*
onoff.js
by sunhw 重写
*/
T.dom.ready(function(){
//详情收起
(function(){
var showMoreBtn = T.query(‘.dirtext .show-morebtn‘)[0];
var contText = T.query(‘.dirtext span‘);
if(!showMoreBtn || !contText){
return;
}
var bind = function(e){
T.event.stop(T.event.get(e));
var isHasClass = T.dom.hasClass(showMoreBtn, ‘packup-morebtn‘);
if(!isHasClass){
showMoreBtn.innerHTML = ‘收起‘;
T.addClass(showMoreBtn, ‘packup-morebtn‘);
T.dom.setStyle(contText[0], ‘display‘, ‘none‘);
T.dom.setStyle(contText[1], ‘display‘, ‘inline‘);
}else{
showMoreBtn.innerHTML = ‘详情‘;
T.removeClass(showMoreBtn, ‘packup-morebtn‘);
T.dom.setStyle(contText[0], ‘display‘, ‘inline‘);
T.dom.setStyle(contText[1], ‘display‘, ‘none‘);
}
};
T.un(showMoreBtn, ‘click‘, bind);
T.on(showMoreBtn, ‘click‘, bind);
})();
//播放页分享展开收起
(function(){
var sitesMoreBtn = T.get(‘sites-more-btn‘);
var parentNode = sitesMoreBtn && sitesMoreBtn.parentNode.parentNode;
if(!sitesMoreBtn || !parentNode) {
return;
}
var bind = function(e){
T.event.stop(T.event.get(e));
( T.dom.hasClass(parentNode, ‘sites-selected‘) ) ? T.dom.removeClass(parentNode, ‘sites-selected‘) : T.dom.addClass(parentNode, ‘sites-selected‘);
};
var unbind = function(){
if(T.dom.hasClass(parentNode, ‘sites-selected‘)){
T.dom.removeClass(parentNode, ‘sites-selected‘);
}
};
T.un(sitesMoreBtn, ‘click‘, bind);
T.un(document, ‘click‘, unbind);
T.on(sitesMoreBtn, ‘click‘, bind);
T.on(document, ‘click‘, unbind);
})();
});
展开收起播放列表