Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持字体大小参数, 改用flex显示文字 #27

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 72 additions & 12 deletions dist/css/barrager.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,72 @@
.barrage{position: fixed;bottom:70px;right:-500px;display: inline-block;width: 500px;z-index: 99999}
.barrage_box{background-color: rgba(0,0,0,.5);padding-right: 8px; height: 40px;display: inline-block;border-radius: 25px;transition: all .3s;}
.barrage_box .portrait{ display: inline-block;margin-top: 4px; margin-left: 4px; width: 32px;height: 32px;border-radius: 50%;overflow: hidden;}
.barrage_box .portrait img{width: 100%;height: 100%;}
.barrage_box div.p a{ margin-right: 2px; font-size: 14px;color: #fff;line-height: 40px;margin-left: 18px; }
.barrage_box div.p a:hover{text-decoration: underline;}
.barrage_box .close{visibility: hidden;opacity: 0; text-align: center; width:25px;height: 25px;margin-left: 20px;border-radius: 50%;background:rgba(255,255,255,.1);margin-top:8px; background-image: url(close.png);}
.barrage_box:hover .close{visibility:visible;opacity: 1;}
.barrage_box .close a{display:block;}
.barrage_box .close .icon-close{font-size: 14px;color:rgba(255,255,255,.5);display: inline-block;margin-top: 5px; }
.barrage .z {float: left !important;}
.barrage a{text-decoration:none;}
.barrage{
position: fixed;
bottom:70px;
right:-500px;
display: inline-block;
min-width: 100px;
z-index: 99999
}
.barrage_box{
background-color: rgba(0,0,0,.5);
padding-right: 8px;
display: inline-block;
border-radius: 25px;
transition: all .3s;
display: flex;
flex-wrap: nowrap;
justify-content: flex-start;
align-items: center;
flex-grow: 0;
}
.barrage_box .portrait{
display: inline-block;
margin-left: 4px;
width: 32px;
height: 32px;
border-radius: 50%;
overflow: hidden;
}
.barrage_box .portrait img{
width: 100%;
height: 100%;
}
.barrage_box div.p a{
margin-right: 2px;
font-size: 14px;
color: #fff;
margin-left: 18px;
white-space: nowrap;
}
.barrage_box div.p a:hover{
text-decoration: underline;
}
.barrage_box .close{
visibility: hidden;
opacity: 0;
text-align: center;
width:25px;
height: 25px;
margin-left: 20px;
border-radius: 50%;
background:rgba(255,255,255,.1);
background-image: url(close.png);
}
.barrage_box:hover .close{
visibility:visible;
opacity: 1;
}
.barrage_box .close a{
display:block;
}
.barrage_box .close .icon-close{
font-size: 14px;
color:rgba(255,255,255,.5);
display: inline-block;
margin-top: 5px;
}
.barrage .z {
float: left !important;
}
.barrage a{
text-decoration:none;
}
5 changes: 4 additions & 1 deletion dist/js/jquery.barrager.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
barrage = $.extend({
close:true,
bottom: 0,
fontsize: 14,
max: 10,
speed: 8,
color: '#fff',
Expand Down Expand Up @@ -43,7 +44,7 @@
var content = $("<a title='' href='' target='_blank'></a>").appendTo(id + " .barrage_box .p");
content.attr({
'href': barrage.href,
'id': barrage.id
'id': barrage.id,
}).empty().append(barrage.info);
if(navigator.userAgent.indexOf("MSIE 6.0")>0 || navigator.userAgent.indexOf("MSIE 7.0")>0 || navigator.userAgent.indexOf("MSIE 8.0")>0 ){

Expand All @@ -54,6 +55,8 @@
content.css('color', barrage.color);

}

content.css("font-size", barrage.fontsize + "px");

var i = 0;
div_barrager.css('margin-right', 0);
Expand Down
2 changes: 1 addition & 1 deletion dist/js/jquery.barrager.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 13 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ <h2>自定义</h2>
<input class="form-control" name="info" type="text" placeholder="弹幕文字信息"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" >字体</label>
<div class="col-sm-6">
<input class="form-control" name="fontsize" type="number" placeholder="弹幕文字大小"/>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" >链接</label>
<div class="col-sm-6">
Expand Down Expand Up @@ -413,7 +419,7 @@ <h4> 讨论 </h4>
<script type="text/javascript" src="static/js/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="static/js/tinycolor-0.9.15.min.js"></script>
<script type="text/javascript" src="dist/js/jquery.barrager.min.js"></script>
<script type="text/javascript" src="dist/js/jquery.barrager.js"></script>
<script type="text/javascript" src="static/syntaxhighlighter/scripts/shCore.js"></script>
<script type="text/javascript" src="static/syntaxhighlighter/scripts/shBrushJScript.js"></script>
<script type="text/javascript" src="static/syntaxhighlighter/scripts/shBrushPhp.js"></script>
Expand Down Expand Up @@ -441,6 +447,7 @@ <h4> 讨论 </h4>
'var item={\n'+
" img:'{img}', //图片 \n"+
" info:'{info}', //文字 \n"+
" fontsize:'{fontsize}', //文字字体大小 \n"+
" href:'{href}', //链接 \n"+
" close:{close}, //显示关闭按钮 \n"+
" speed:{speed}, //延迟,单位秒,默认6 \n"+
Expand All @@ -460,13 +467,14 @@ <h4> 讨论 </h4>
'img':'static/heisenberg.png',
'info':'弹幕文字信息',
'href':'http://www.yaseng.org',
'fontsize': '32',
'close':true,
'speed':6,
'bottom':70,
'color':'#fff' ,
'old_ie_color':'#000000'
};
var item={'img':'static/img/heisenberg.png','href':'http://www.baidu.com','info':'Jquery.barrager.js 专业的网页弹幕插件'};
var item={'img':'static/img/heisenberg.png','href':'http://www.baidu.com','info':'Jquery.barrager.js 专业的网页弹幕插件', 'fontsize': 32, speed: 6,};
//item1={'href':'http://www.baidu.com','info':'这是一条很长很长的字幕','close':false};
$('#barrager-code').val(barrager_code.format(default_item));

Expand Down Expand Up @@ -516,6 +524,8 @@ <h4> 讨论 </h4>

var info=$('input[name=info]').val();
(info == '' ) ? info='请填写弹幕文字' : info=info;
var fontsize=$('input[name=fontsize]').val();
(fontsize == '') ? fontsize='32': fontsize=fontsize;
var href=$('input[name=href]').val();
var speed=parseInt($('input[name=speed]').val());
var bottom=parseInt($('input[name=bottom]').val());
Expand All @@ -540,6 +550,7 @@ <h4> 讨论 </h4>
var item={
'img':'static/img/'+img,
'info':info,
'fontsize': fontsize,
'href':href,
'close':true,
'speed':speed,
Expand Down