video.js
4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
* @fileOverview 视频模块
* @author:Hbomb(zhouqq@yoho.cn)
* @date:2013-05-27
*/
define('video',function(require, exports)
{
var box = require('box'); // 提示框
var $ = require("jquery");
var common = require("common");
var upload = require('admin/upload');
var form_html = $("#form_pan").html()+'';
$("#form_pan").remove();
$("#add_video").click(function()
{
box.confirm
(
form_html, submit,
{
title: '添加视频',
width: '750px',
autoClose: false
}
);
$('#create_time').click(function()
{
WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
});
//绑定上传背景按钮
upload.init(
{
button_placeholder_id:"upload_pic",
button_width : "58",
button_height : "30",
post_params: {'key':$("#pic").attr('key'), 'format':'json'},
custom_settings:
{
saveCallback:function(response,swf)
{
if (response.code == 12)
{
var thumbPath = common.getImages(response.data.file.relaPath, "0200x0150", "blogimg", "primary");
var realPath = response.data.file.relaPath;
$("#pic").val(realPath);
$("#pic").next().attr("src",thumbPath);
}
else
{
box.alert(response.message);
}
}
}
});
});
$(".del").click(function()
{
var id = $(this).attr('val');
box.confirm("确定要删除这个视频吗?",function()
{
$.ajax
({
type: "post",
url: '/admin/video/del',
data: "id="+id,
success: function(data)
{
if (data.code == 200)
{
window.location.reload();
}
else
{
box.alert(data.message);
}
}
});
});
});
//查看
$(".look").click(function()
{
box.confirm
(
form_html, submit,
{
title: '查看视频',
width: '750px',
autoClose: false
}
);
$('#create_time').click(function()
{
WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});
});
var obj = $(this).parents("tr");
var title = obj.find("td:eq(1)").text();
var pic = obj.find("td:eq(2)").attr("relaurl");
var pic_abs = obj.find("td:eq(2) img").attr("src");
var url = obj.find("td:eq(2) .video_url embed").attr("src");
var id = obj.find("td:eq(0)").text();
var create_time = obj.find("td:eq(3)").text();
$("#id").val(id);
$("#title").val(title);
$("#pic").val(pic);
$("#pic").next().attr("src",pic_abs);
$("#url").val(url);
$("#create_time").val(create_time);
});
//提交视频
function submit()
{
var title = $("#title").val();
var pic = $("#pic").val();
var url = $("#url").val();
var id = $("#id").val();
var create_time = $("#create_time").val();
if(title=="")
{
alert("标题不能为空!");
return;
}
if(pic=="")
{
alert("图片不能为空!");
return;
}
if(url=="")
{
alert("视频地址不能为空!");
return;
}
$.ajax
({
type: "post",
url: '/admin/video/submit',
data: "id=" + id+
"&title="+encodeURIComponent(title)+
"&pic="+encodeURIComponent(pic)+
"&url="+encodeURIComponent(url)+
"&create_time="+encodeURIComponent(create_time),
success: function(data)
{
if (data.code == 200)
{
window.location.reload();
}
else
{
box.alert(data.message);
}
}
});
}
$(".look_v").click(function()
{
$(this).next().toggle();
});
});