79 lines
2.1 KiB
JavaScript
79 lines
2.1 KiB
JavaScript
var Video = function(){};
|
|
var a = new Video();
|
|
a.ex = function(obj){
|
|
var config = {
|
|
Width:"800",
|
|
Height:"400",
|
|
Src:"",
|
|
Type:"flv",
|
|
unit:'px'
|
|
};
|
|
a.d = obj? $.extend(config,obj):config;
|
|
};
|
|
|
|
a.genereteHtml = function(){
|
|
var d = a.d;
|
|
var type = a.d.Type;
|
|
var width = d.Width+d.unit,height = d.Height+d.unit;
|
|
console.log(width,height);
|
|
if(type == 'mp4'){
|
|
var html = '<div class="Alert-cover"></div><div id="AlertVideo" class="AlertVideo">';
|
|
html += '<div class="AlertVideo-main">';
|
|
html += '<video style="width:'+width+';height:'+height+';" src="'+d.Src+'" autoplay controls>';
|
|
html += '</div><div class="AlertVideo-Closed"><a href="javascript:a.closedVideo()"></a></div>';
|
|
}else{
|
|
var html = '<div class="Alert-cover"></div><div id="AlertVideo" class="AlertVideo">';
|
|
html += '<div class="AlertVideo-main">';
|
|
html += '<embed type="application/x-shockwave-flash"';
|
|
html += 'wmode="transparent"';
|
|
html += 'src="http://s2.qhimg.com/static/8dccccc36ce33293.swf"';
|
|
html += 'width="'+ d.Width+'" height="'+d.Height+'"';
|
|
html += 'quality="high" allowfullscreen="true"';
|
|
html += 'flashvars="file='+ d.Src+'&width=800&height=450">';
|
|
html += '</div><div class="AlertVideo-Closed"><a href="javascript:a.closedVideo()"></a></div>';
|
|
}
|
|
return html;
|
|
};
|
|
|
|
a.countCss = function(){
|
|
var d = a.d;
|
|
var css = {
|
|
width: d.Width+d.unit,
|
|
height: d.Height+d.unit
|
|
};
|
|
var mar = '-'+ (d.Height/2)+d.unit+' 0 0 -'+(d.Width/2)+d.unit;
|
|
$(".AlertVideo-main").css(css)
|
|
$(".AlertVideo").css("margin",mar)
|
|
};
|
|
|
|
|
|
|
|
a.closedVideo = function(){
|
|
$(".Alert-cover").remove();
|
|
$("#AlertVideo").remove();
|
|
a.isShow = false;
|
|
};
|
|
|
|
a.isShow = false;
|
|
|
|
a.showVideo = function(){
|
|
if(a.isShow){return false}
|
|
var html = a.genereteHtml();
|
|
$("body").append(html);
|
|
a.countCss();
|
|
a.isShow = true;
|
|
};
|
|
|
|
a.Init = function(obj){
|
|
a.ex(obj);
|
|
a.showVideo();
|
|
};
|
|
|
|
$.fn.extend({
|
|
insertVideo:function(obj){
|
|
$(this).click(function(){
|
|
a.Init(obj)
|
|
})
|
|
}
|
|
})
|