ueditor-rails 1.2.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +49 -0
- data/Rakefile +1 -0
- data/app/assets/javascripts/ueditor.js +3 -0
- data/lib/tasks/ueditor.rake +12 -0
- data/lib/ueditor-rails.rb +1 -0
- data/lib/ueditor/rails.rb +9 -0
- data/lib/ueditor/rails/engine.rb +20 -0
- data/lib/ueditor/rails/version.rb +6 -0
- data/ueditor-rails.gemspec +20 -0
- data/vendor/assets/javascripts/ueditor/.DS_Store +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/.DS_Store +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.css +43 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.html +54 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/emotion.js +186 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/0.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/bface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/cface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/fface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/jxface2.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/tface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/wface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/emotion/images/yface.gif +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/image.css +69 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/image.html +204 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/image.js +712 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/imageUploader.swf +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/images/center_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/images/left_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/images/none_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/image/images/right_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/internal.js +79 -0
- data/vendor/assets/javascripts/ueditor/dialogs/tangram.js +1238 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/center_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/left_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/none_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/images/right_focus.jpg +0 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.css +59 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.html +67 -0
- data/vendor/assets/javascripts/ueditor/dialogs/video/video.js +402 -0
- data/vendor/assets/javascripts/ueditor/editor_all.js +12437 -0
- data/vendor/assets/javascripts/ueditor/editor_all_min.js +1 -0
- data/vendor/assets/javascripts/ueditor/editor_config.js +209 -0
- data/vendor/assets/javascripts/ueditor/index.html +146 -0
- data/vendor/assets/javascripts/ueditor/lang/en/en.js +528 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/addimage.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/alldeletebtnhoverskin.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/alldeletebtnupskin.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/background.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/button.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/copy.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/deletedisable.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/deleteenable.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/imglabel.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/listbackground.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/localimage.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/music.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/rotateleftdisable.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/rotateleftenable.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/rotaterightdisable.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/rotaterightenable.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/en/images/upload.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/copy.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/imglabel.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/localimage.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/music.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/images/upload.png +0 -0
- data/vendor/assets/javascripts/ueditor/lang/zh-cn/zh-cn.js +492 -0
- data/vendor/assets/javascripts/ueditor/php/.DS_Store +0 -0
- data/vendor/assets/javascripts/ueditor/php/Uploader.class.php +198 -0
- data/vendor/assets/javascripts/ueditor/php/fileUp.php +43 -0
- data/vendor/assets/javascripts/ueditor/php/getContent.php +21 -0
- data/vendor/assets/javascripts/ueditor/php/getMovie.php +13 -0
- data/vendor/assets/javascripts/ueditor/php/getRemoteImage.php +100 -0
- data/vendor/assets/javascripts/ueditor/php/imageManager.php +56 -0
- data/vendor/assets/javascripts/ueditor/php/imageUp.php +48 -0
- data/vendor/assets/javascripts/ueditor/php/scrawlUp.php +60 -0
- data/vendor/assets/javascripts/ueditor/themes/.DS_Store +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/.DS_Store +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/css/ueditor.css +1582 -0
- data/vendor/assets/javascripts/ueditor/themes/default/dialogbase.css +100 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/.DS_Store +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/anchor.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/arrow.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/button-bg.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/cancelbutton.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_h.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_h.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_v.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/cursor_v.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/dialog-title-bg.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/filescan.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/highlighted.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/icons-all.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/icons.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/icons.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/lock.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/neweditor-tab-bg.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/pagebreak.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/scale.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/spacer.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/sparator_v.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/toolbar_bg.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/unhighlighted.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/upload.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/videologo.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/word.gif +0 -0
- data/vendor/assets/javascripts/ueditor/themes/default/images/wordpaste.png +0 -0
- data/vendor/assets/javascripts/ueditor/themes/iframe.css +1 -0
- data/vendor/assets/javascripts/ueditor/uparse.js +358 -0
- metadata +159 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
@charset "utf-8";
|
2
|
+
.wrapper{ width: 570px;_width:575px;margin: 10px auto; zoom:1;position: relative}
|
3
|
+
.tabbody{height:335px;}
|
4
|
+
.panel { position: absolute;width:100%; height:100%;background: #fff;}
|
5
|
+
.panel table td{vertical-align: middle;}
|
6
|
+
#videoUrl {
|
7
|
+
width: 490px;
|
8
|
+
height: 21px;
|
9
|
+
line-height: 21px;
|
10
|
+
margin: 8px 5px;
|
11
|
+
background: #FFF;
|
12
|
+
border: 1px solid #d7d7d7;
|
13
|
+
}
|
14
|
+
#videoSearchTxt{margin-left:15px;background: #FFF;width:200px;height:21px;line-height:21px;border: 1px solid #d7d7d7;}
|
15
|
+
#searchList{width: 570px;overflow: auto;zoom:1;height: 270px;}
|
16
|
+
#searchList div{float: left;width: 120px;height: 135px;margin: 5px 15px;}
|
17
|
+
#searchList img{margin: 2px 8px;cursor: pointer;border: 2px solid #fff} /*不用缩略图*/
|
18
|
+
#searchList p{margin-left: 10px;}
|
19
|
+
#videoType{
|
20
|
+
width: 65px;
|
21
|
+
height: 23px;
|
22
|
+
line-height: 22px;
|
23
|
+
border: 1px solid #d7d7d7;
|
24
|
+
}
|
25
|
+
#videoSearchBtn,#videoSearchReset{
|
26
|
+
/*width: 80px;*/
|
27
|
+
height: 25px;
|
28
|
+
line-height: 25px;
|
29
|
+
background: #eee;
|
30
|
+
border: 1px solid #d7d7d7;
|
31
|
+
cursor: pointer;
|
32
|
+
padding: 0 5px;
|
33
|
+
}
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
#preview{width: 420px; margin-left: 10px; _margin-left:5px; height: 280px;background-color: #ddd;float: left}
|
38
|
+
#videoInfo {width: 120px;float: left;margin-left: 10px;_margin-left:7px;}
|
39
|
+
fieldset{
|
40
|
+
border: 1px solid #ddd;
|
41
|
+
padding-left: 5px;
|
42
|
+
margin-bottom: 20px;
|
43
|
+
padding-bottom: 5px;
|
44
|
+
width: 115px;
|
45
|
+
}
|
46
|
+
fieldset legend{font-weight: bold;}
|
47
|
+
fieldset p{line-height: 30px;}
|
48
|
+
fieldset input.txt{
|
49
|
+
width: 65px;
|
50
|
+
height: 21px;
|
51
|
+
line-height: 21px;
|
52
|
+
margin: 8px 5px;
|
53
|
+
background: #FFF;
|
54
|
+
border: 1px solid #d7d7d7;
|
55
|
+
}
|
56
|
+
label.url{font-weight: bold;margin-left: 5px;color: #06c;}
|
57
|
+
#videoFloat div{cursor:pointer;opacity: 0.5;filter: alpha(opacity = 50);margin:9px;_margin:5px;width:38px;height:36px;float:left;}
|
58
|
+
#videoFloat .focus{opacity: 1;filter: alpha(opacity = 100)}
|
59
|
+
span.view{display: inline-block;width: 30px;float: right;cursor: pointer;color: blue}
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title></title>
|
6
|
+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
|
7
|
+
<script type="text/javascript" src="../internal.js"></script>
|
8
|
+
<link rel="stylesheet" type="text/css" href="video.css" />
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div class="wrapper">
|
12
|
+
<div id="videoTab">
|
13
|
+
<div id="tabHeads" class="tabhead">
|
14
|
+
<span tabSrc="video" class="focus"><var id="lang_tab_insertV"></var></span>
|
15
|
+
<span tabSrc="videoSearch"><var id="lang_tab_searchV"></var></span>
|
16
|
+
</div>
|
17
|
+
<div id="tabBodys" class="tabbody">
|
18
|
+
<div id="video" class="panel">
|
19
|
+
<table><tr><td><label for="videoUrl" class="url"><var id="lang_video_url"></var></label></td><td><input id="videoUrl" type="text"></td></tr></table>
|
20
|
+
<div id="preview"></div>
|
21
|
+
<div id="videoInfo">
|
22
|
+
<fieldset>
|
23
|
+
<legend><var id="lang_video_size"></var></legend>
|
24
|
+
<table>
|
25
|
+
<tr><td><label for="videoWidth"><var id="lang_videoW"></var></label></td><td><input class="txt" id="videoWidth" type="text"/></td></tr>
|
26
|
+
<tr><td><label for="videoHeight"><var id="lang_videoH"></var></label></td><td><input class="txt" id="videoHeight" type="text"/></td></tr>
|
27
|
+
</table>
|
28
|
+
</fieldset>
|
29
|
+
<fieldset>
|
30
|
+
<legend><var id="lang_alignment"></var></legend>
|
31
|
+
<div id="videoFloat"></div>
|
32
|
+
</fieldset>
|
33
|
+
</div>
|
34
|
+
</div>
|
35
|
+
<div id="videoSearch" class="panel" style="display: none">
|
36
|
+
<table style="margin-top: 5px;">
|
37
|
+
<tr>
|
38
|
+
<td><input id="videoSearchTxt" type="text" /></td>
|
39
|
+
<td>
|
40
|
+
<select id="videoType">
|
41
|
+
<option value="0"></option>
|
42
|
+
<option value="29"></option>
|
43
|
+
<option value="1"></option>
|
44
|
+
<option value="5"></option>
|
45
|
+
<option value="15"></option>
|
46
|
+
<option value="21"></option>
|
47
|
+
<option value="31"></option>
|
48
|
+
</select>
|
49
|
+
</td>
|
50
|
+
<td><input id="videoSearchBtn" type="button"/></td>
|
51
|
+
<td><input id="videoSearchReset" type="button" /></td>
|
52
|
+
</tr>
|
53
|
+
</table>
|
54
|
+
<div id="searchList"></div>
|
55
|
+
</div>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
</div>
|
59
|
+
<script type="text/javascript" src="video.js"></script>
|
60
|
+
<script type="text/javascript">
|
61
|
+
window.onload = function(){
|
62
|
+
video.init();
|
63
|
+
$focus($G("videoUrl"));
|
64
|
+
};
|
65
|
+
</script>
|
66
|
+
</body>
|
67
|
+
</html>
|
@@ -0,0 +1,402 @@
|
|
1
|
+
/**
|
2
|
+
* Created by JetBrains PhpStorm.
|
3
|
+
* User: taoqili
|
4
|
+
* Date: 12-2-20
|
5
|
+
* Time: 上午11:19
|
6
|
+
* To change this template use File | Settings | File Templates.
|
7
|
+
*/
|
8
|
+
var video = {};
|
9
|
+
|
10
|
+
(function(){
|
11
|
+
video.init = function(){
|
12
|
+
switchTab("videoTab");
|
13
|
+
createAlignButton( ["videoFloat"] );
|
14
|
+
addUrlChangeListener($G("videoUrl"));
|
15
|
+
addOkListener();
|
16
|
+
addSearchListener();
|
17
|
+
|
18
|
+
//编辑视频时初始化相关信息
|
19
|
+
(function(){
|
20
|
+
var img = editor.selection.getRange().getClosedNode(),url;
|
21
|
+
if(img && img.className == "edui-faked-video"){
|
22
|
+
$G("videoUrl").value = url = img.getAttribute("_url");
|
23
|
+
$G("videoWidth").value = img.width;
|
24
|
+
$G("videoHeight").value = img.height;
|
25
|
+
var align = domUtils.getComputedStyle(img,"float"),
|
26
|
+
parentAlign = domUtils.getComputedStyle(img.parentNode,"text-align");
|
27
|
+
updateAlignButton(parentAlign==="center"?"center":align);
|
28
|
+
}
|
29
|
+
createPreviewVideo(url);
|
30
|
+
})();
|
31
|
+
};
|
32
|
+
/**
|
33
|
+
* 监听确认和取消两个按钮事件,用户执行插入或者清空正在播放的视频实例操作
|
34
|
+
*/
|
35
|
+
function addOkListener(){
|
36
|
+
dialog.onok = function(){
|
37
|
+
$G("preview").innerHTML = "";
|
38
|
+
var currentTab = findFocus("tabHeads","tabSrc");
|
39
|
+
switch(currentTab){
|
40
|
+
case "video":
|
41
|
+
return insertSingle();
|
42
|
+
break;
|
43
|
+
case "videoSearch":
|
44
|
+
return insertSearch("searchList");
|
45
|
+
break;
|
46
|
+
}
|
47
|
+
};
|
48
|
+
dialog.oncancel = function(){
|
49
|
+
$G("preview").innerHTML = "";
|
50
|
+
};
|
51
|
+
}
|
52
|
+
|
53
|
+
function selectTxt(node){
|
54
|
+
if(node.select){
|
55
|
+
node.select();
|
56
|
+
}else{
|
57
|
+
var r = node.createTextRange && node.createTextRange();
|
58
|
+
r.select();
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* 依据传入的align值更新按钮信息
|
64
|
+
* @param align
|
65
|
+
*/
|
66
|
+
function updateAlignButton( align ) {
|
67
|
+
var aligns = $G( "videoFloat" ).children;
|
68
|
+
for ( var i = 0, ci; ci = aligns[i++]; ) {
|
69
|
+
if ( ci.getAttribute( "name" ) == align ) {
|
70
|
+
if ( ci.className !="focus" ) {
|
71
|
+
ci.className = "focus";
|
72
|
+
}
|
73
|
+
} else {
|
74
|
+
if ( ci.className =="focus" ) {
|
75
|
+
ci.className = "";
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
|
81
|
+
/**
|
82
|
+
* 将单个视频信息插入编辑器中
|
83
|
+
*/
|
84
|
+
function insertSingle(){
|
85
|
+
var width = $G("videoWidth"),
|
86
|
+
height = $G("videoHeight"),
|
87
|
+
url=$G('videoUrl').value,
|
88
|
+
align = findFocus("videoFloat","name");
|
89
|
+
if(!url) return false;
|
90
|
+
if ( !checkNum( [width, height] ) ) return false;
|
91
|
+
editor.execCommand('insertvideo', {
|
92
|
+
url: convert_url(url),
|
93
|
+
width: width.value,
|
94
|
+
height: height.value,
|
95
|
+
align: align
|
96
|
+
});
|
97
|
+
}
|
98
|
+
|
99
|
+
/**
|
100
|
+
* 将元素id下的所有代表视频的图片插入编辑器中
|
101
|
+
* @param id
|
102
|
+
*/
|
103
|
+
function insertSearch(id){
|
104
|
+
var imgs = domUtils.getElementsByTagName($G(id),"img"),
|
105
|
+
videoObjs=[];
|
106
|
+
for(var i=0,img; img=imgs[i++];){
|
107
|
+
if(img.getAttribute("selected")){
|
108
|
+
videoObjs.push({
|
109
|
+
url:img.getAttribute("ue_video_url"),
|
110
|
+
width:420,
|
111
|
+
height:280,
|
112
|
+
align:"none"
|
113
|
+
});
|
114
|
+
}
|
115
|
+
}
|
116
|
+
editor.execCommand('insertvideo',videoObjs);
|
117
|
+
}
|
118
|
+
|
119
|
+
/**
|
120
|
+
* 找到id下具有focus类的节点并返回该节点下的某个属性
|
121
|
+
* @param id
|
122
|
+
* @param returnProperty
|
123
|
+
*/
|
124
|
+
function findFocus( id, returnProperty ) {
|
125
|
+
var tabs = $G( id ).children,
|
126
|
+
property;
|
127
|
+
for ( var i = 0, ci; ci = tabs[i++]; ) {
|
128
|
+
if ( ci.className=="focus" ) {
|
129
|
+
property = ci.getAttribute( returnProperty );
|
130
|
+
break;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
return property;
|
134
|
+
}
|
135
|
+
function convert_url(s){
|
136
|
+
return s.replace(/http:\/\/www\.tudou\.com\/programs\/view\/([\w\-]+)\/?/i,"http://www.tudou.com/v/$1")
|
137
|
+
.replace(/http:\/\/www\.youtube\.com\/watch\?v=([\w\-]+)/i,"http://www.youtube.com/v/$1")
|
138
|
+
.replace(/http:\/\/v\.youku\.com\/v_show\/id_([\w\-=]+)\.html/i,"http://player.youku.com/player.php/sid/$1")
|
139
|
+
.replace(/http:\/\/www\.56\.com\/u\d+\/v_([\w\-]+)\.html/i, "http://player.56.com/v_$1.swf")
|
140
|
+
.replace(/http:\/\/www.56.com\/w\d+\/play_album\-aid\-\d+_vid\-([^.]+)\.html/i, "http://player.56.com/v_$1.swf")
|
141
|
+
.replace(/http:\/\/v\.ku6\.com\/.+\/([^.]+)\.html/i, "http://player.ku6.com/refer/$1/v.swf");
|
142
|
+
}
|
143
|
+
|
144
|
+
/**
|
145
|
+
* 检测传入的所有input框中输入的长宽是否是正数
|
146
|
+
* @param nodes input框集合,
|
147
|
+
*/
|
148
|
+
function checkNum( nodes ) {
|
149
|
+
for ( var i = 0, ci; ci = nodes[i++]; ) {
|
150
|
+
var value = ci.value;
|
151
|
+
if ( !isNumber( value ) && value) {
|
152
|
+
alert( lang.numError );
|
153
|
+
ci.value = "";
|
154
|
+
ci.focus();
|
155
|
+
return false;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
return true;
|
159
|
+
}
|
160
|
+
|
161
|
+
/**
|
162
|
+
* 数字判断
|
163
|
+
* @param value
|
164
|
+
*/
|
165
|
+
function isNumber( value ) {
|
166
|
+
return /(0|^[1-9]\d*$)/.test( value );
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* tab切换
|
171
|
+
* @param tabParentId
|
172
|
+
* @param keepFocus 当此值为真时,切换按钮上会保留focus的样式
|
173
|
+
*/
|
174
|
+
function switchTab( tabParentId,keepFocus ) {
|
175
|
+
var tabElements = $G( tabParentId ).children,
|
176
|
+
tabHeads = tabElements[0].children,
|
177
|
+
tabBodys = tabElements[1].children;
|
178
|
+
for ( var i = 0, length = tabHeads.length; i < length; i++ ) {
|
179
|
+
var head = tabHeads[i];
|
180
|
+
domUtils.on( head, "click", function () {
|
181
|
+
//head样式更改
|
182
|
+
for ( var k = 0, len = tabHeads.length; k < len; k++ ) {
|
183
|
+
if(!keepFocus)tabHeads[k].className = "";
|
184
|
+
}
|
185
|
+
this.className = "focus";
|
186
|
+
//body显隐
|
187
|
+
var tabSrc = this.getAttribute( "tabSrc" );
|
188
|
+
for ( var j = 0, length = tabBodys.length; j < length; j++ ) {
|
189
|
+
var body = tabBodys[j],
|
190
|
+
id = body.getAttribute( "id" );
|
191
|
+
|
192
|
+
if ( id == tabSrc ) {
|
193
|
+
body.style.display = "";
|
194
|
+
if(id=="videoSearch"){
|
195
|
+
selectTxt($G("videoSearchTxt"));
|
196
|
+
}
|
197
|
+
if(id=="video"){
|
198
|
+
selectTxt($G("videoUrl"));
|
199
|
+
}
|
200
|
+
|
201
|
+
} else {
|
202
|
+
body.style.display = "none";
|
203
|
+
}
|
204
|
+
}
|
205
|
+
} );
|
206
|
+
}
|
207
|
+
}
|
208
|
+
/**
|
209
|
+
* 创建图片浮动选择按钮
|
210
|
+
* @param ids
|
211
|
+
*/
|
212
|
+
function createAlignButton( ids ) {
|
213
|
+
for ( var i = 0, ci; ci = ids[i++]; ) {
|
214
|
+
var floatContainer = $G( ci ),
|
215
|
+
nameMaps = {"none":lang['default'], "left":lang.floatLeft, "right":lang.floatRight, "center":lang.block};
|
216
|
+
for ( var j in nameMaps ) {
|
217
|
+
var div = document.createElement( "div" );
|
218
|
+
div.setAttribute( "name", j );
|
219
|
+
if ( j == "none" ) div.className="focus";
|
220
|
+
div.style.cssText = "background:url(images/" + j + "_focus.jpg);";
|
221
|
+
div.setAttribute( "title", nameMaps[j] );
|
222
|
+
floatContainer.appendChild( div );
|
223
|
+
}
|
224
|
+
switchSelect( ci );
|
225
|
+
}
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* 选择切换
|
230
|
+
* @param selectParentId
|
231
|
+
*/
|
232
|
+
function switchSelect( selectParentId ) {
|
233
|
+
var selects = $G( selectParentId ).children;
|
234
|
+
for ( var i = 0, ci; ci = selects[i++]; ) {
|
235
|
+
domUtils.on( ci, "click", function () {
|
236
|
+
for ( var j = 0, cj; cj = selects[j++]; ) {
|
237
|
+
cj.className = "";
|
238
|
+
cj.removeAttribute && cj.removeAttribute( "class" );
|
239
|
+
}
|
240
|
+
this.className = "focus";
|
241
|
+
} )
|
242
|
+
}
|
243
|
+
}
|
244
|
+
|
245
|
+
/**
|
246
|
+
* 监听url改变事件
|
247
|
+
* @param url
|
248
|
+
*/
|
249
|
+
function addUrlChangeListener(url){
|
250
|
+
if (browser.ie) {
|
251
|
+
url.onpropertychange = function () {
|
252
|
+
createPreviewVideo( this.value );
|
253
|
+
}
|
254
|
+
} else {
|
255
|
+
url.addEventListener( "input", function () {
|
256
|
+
createPreviewVideo( this.value );
|
257
|
+
}, false );
|
258
|
+
}
|
259
|
+
}
|
260
|
+
|
261
|
+
/**
|
262
|
+
* 根据url生成视频预览
|
263
|
+
* @param url
|
264
|
+
*/
|
265
|
+
function createPreviewVideo(url){
|
266
|
+
|
267
|
+
if ( !url )return;
|
268
|
+
var matches = url.match(/youtu.be\/(\w+)$/) || url.match(/youtube\.com\/watch\?v=(\w+)/) || url.match(/youtube.com\/v\/(\w+)/),
|
269
|
+
youku = url.match(/youku\.com\/v_show\/id_(\w+)/),
|
270
|
+
youkuPlay = /player\.youku\.com/ig.test(url);
|
271
|
+
if(!youkuPlay){
|
272
|
+
if (matches){
|
273
|
+
url = "https://www.youtube.com/v/" + matches[1] + "?version=3&feature=player_embedded";
|
274
|
+
}else if(youku){
|
275
|
+
url = "http://player.youku.com/player.php/sid/"+youku[1]+"/v.swf"
|
276
|
+
}else if(!endWith(url,[".swf",".flv",".wmv"])){
|
277
|
+
$G("preview").innerHTML = lang.urlError;
|
278
|
+
return;
|
279
|
+
}
|
280
|
+
}else{
|
281
|
+
url = url.replace(/\?f=.*/,"");
|
282
|
+
}
|
283
|
+
$G("preview").innerHTML = '<embed type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"' +
|
284
|
+
' src="' + url + '"' +
|
285
|
+
' width="' + 420 + '"' +
|
286
|
+
' height="' + 280 + '"' +
|
287
|
+
' wmode="transparent" play="true" loop="false" menu="false" allowscriptaccess="never" allowfullscreen="true" ></embed>';
|
288
|
+
}
|
289
|
+
|
290
|
+
/**
|
291
|
+
* 末尾字符检测
|
292
|
+
* @param str
|
293
|
+
* @param endStrArr
|
294
|
+
*/
|
295
|
+
function endWith(str,endStrArr){
|
296
|
+
for(var i=0,len = endStrArr.length;i<len;i++){
|
297
|
+
var tmp = endStrArr[i];
|
298
|
+
if(str.length - tmp.length<0) return false;
|
299
|
+
|
300
|
+
if(str.substring(str.length-tmp.length)==tmp){
|
301
|
+
return true;
|
302
|
+
}
|
303
|
+
}
|
304
|
+
return false;
|
305
|
+
}
|
306
|
+
|
307
|
+
/**
|
308
|
+
* ajax获取视频信息
|
309
|
+
*/
|
310
|
+
function getMovie(){
|
311
|
+
var keywordInput = $G("videoSearchTxt");
|
312
|
+
if(!keywordInput.getAttribute("hasClick") ||!keywordInput.value){
|
313
|
+
selectTxt(keywordInput);
|
314
|
+
return;
|
315
|
+
}
|
316
|
+
$G( "searchList" ).innerHTML = lang.loading;
|
317
|
+
var keyword = keywordInput.value,
|
318
|
+
type = $G("videoType").value,
|
319
|
+
str="";
|
320
|
+
ajax.request(editor.options.getMovieUrl,{
|
321
|
+
searchKey:keyword,
|
322
|
+
videoType:type,
|
323
|
+
onsuccess:function(xhr){
|
324
|
+
try{
|
325
|
+
var info = eval("("+xhr.responseText+")");
|
326
|
+
}catch(e){
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
|
330
|
+
var videos = info.multiPageResult.results;
|
331
|
+
var html=["<table width='530'>"];
|
332
|
+
for(var i=0,ci;ci = videos[i++];){
|
333
|
+
html.push(
|
334
|
+
"<tr>" +
|
335
|
+
"<td><img title='"+lang.clickToSelect+"' ue_video_url='"+ci.outerPlayerUrl+"' alt='"+ci.tags+"' width='106' height='80' src='"+ci.picUrl+"' /> </td>" +
|
336
|
+
"<td>" +
|
337
|
+
"<p><a target='_blank' title='"+lang.goToSource+"' href='"+ci.itemUrl+"'>"+ci.title.substr(0,30)+"</a></p>" +
|
338
|
+
"<p style='height: 62px;line-height: 20px' title='"+ci.description+"'> "+ ci.description.substr(0,95) +" </p>" +
|
339
|
+
"</td>" +
|
340
|
+
"</tr>"
|
341
|
+
);
|
342
|
+
}
|
343
|
+
html.push("</table>");
|
344
|
+
$G("searchList").innerHTML = str = html.length ==2 ?lang.noVideo : html.join("");
|
345
|
+
var imgs = domUtils.getElementsByTagName($G("searchList"),"img");
|
346
|
+
if(!imgs)return;
|
347
|
+
for(var i=0,img;img = imgs[i++];){
|
348
|
+
domUtils.on(img,"click",function(){
|
349
|
+
changeSelected(this);
|
350
|
+
})
|
351
|
+
}
|
352
|
+
}
|
353
|
+
});
|
354
|
+
}
|
355
|
+
|
356
|
+
/**
|
357
|
+
* 改变对象o的选中状态
|
358
|
+
* @param o
|
359
|
+
*/
|
360
|
+
function changeSelected(o){
|
361
|
+
if ( o.getAttribute( "selected" ) ) {
|
362
|
+
o.removeAttribute( "selected" );
|
363
|
+
o.style.cssText = "filter:alpha(Opacity=100);-moz-opacity:1;opacity: 1;border: 2px solid #fff";
|
364
|
+
} else {
|
365
|
+
o.setAttribute( "selected", "true" );
|
366
|
+
o.style.cssText = "filter:alpha(Opacity=50);-moz-opacity:0.5;opacity: 0.5;border:2px solid blue;";
|
367
|
+
}
|
368
|
+
}
|
369
|
+
|
370
|
+
/**
|
371
|
+
* 视频搜索相关注册事件
|
372
|
+
*/
|
373
|
+
function addSearchListener(){
|
374
|
+
domUtils.on($G("videoSearchBtn"),"click",getMovie);
|
375
|
+
domUtils.on($G( "videoSearchTxt" ),"click",function () {
|
376
|
+
if ( this.value == lang.static.videoSearchTxt.value ) {
|
377
|
+
this.value = "";
|
378
|
+
}
|
379
|
+
this.setAttribute("hasClick","true");
|
380
|
+
selectTxt(this);
|
381
|
+
});
|
382
|
+
$G( "videoSearchTxt" ).onkeyup = function(){
|
383
|
+
this.setAttribute("hasClick","true");
|
384
|
+
this.onkeyup = null;
|
385
|
+
};
|
386
|
+
domUtils.on($G( "videoSearchReset" ),"click",function () {
|
387
|
+
var txt = $G( "videoSearchTxt" );
|
388
|
+
txt.value = "";
|
389
|
+
selectTxt(txt);
|
390
|
+
$G( "searchList" ).innerHTML = "";
|
391
|
+
});
|
392
|
+
domUtils.on($G( "videoType" ),"change", getMovie);
|
393
|
+
domUtils.on($G( "videoSearchTxt" ), "keyup", function ( evt ) {
|
394
|
+
if ( evt.keyCode == 13 ) {
|
395
|
+
getMovie();
|
396
|
+
}
|
397
|
+
} )
|
398
|
+
}
|
399
|
+
|
400
|
+
|
401
|
+
|
402
|
+
})();
|