提交 | 用户 | 时间
|
8286c6
|
1 |
window.onload = function () { |
懒 |
2 |
editor.setOpt({ |
|
3 |
emotionLocalization:false |
|
4 |
}); |
|
5 |
|
|
6 |
emotion.SmileyPath = editor.options.emotionLocalization === true ? 'images/' : "http://img.baidu.com/hi/"; |
|
7 |
emotion.SmileyBox = createTabList( emotion.tabNum ); |
|
8 |
emotion.tabExist = createArr( emotion.tabNum ); |
|
9 |
|
|
10 |
initImgName(); |
|
11 |
initEvtHandler( "tabHeads" ); |
|
12 |
}; |
|
13 |
|
|
14 |
function initImgName() { |
|
15 |
for ( var pro in emotion.SmilmgName ) { |
|
16 |
var tempName = emotion.SmilmgName[pro], |
|
17 |
tempBox = emotion.SmileyBox[pro], |
|
18 |
tempStr = ""; |
|
19 |
|
|
20 |
if ( tempBox.length ) return; |
|
21 |
for ( var i = 1; i <= tempName[1]; i++ ) { |
|
22 |
tempStr = tempName[0]; |
|
23 |
if ( i < 10 ) tempStr = tempStr + '0'; |
|
24 |
tempStr = tempStr + i + '.gif'; |
|
25 |
tempBox.push( tempStr ); |
|
26 |
} |
|
27 |
} |
|
28 |
} |
|
29 |
|
|
30 |
function initEvtHandler( conId ) { |
|
31 |
var tabHeads = $G( conId ); |
|
32 |
for ( var i = 0, j = 0; i < tabHeads.childNodes.length; i++ ) { |
|
33 |
var tabObj = tabHeads.childNodes[i]; |
|
34 |
if ( tabObj.nodeType == 1 ) { |
|
35 |
domUtils.on( tabObj, "click", (function ( index ) { |
|
36 |
return function () { |
|
37 |
switchTab( index ); |
|
38 |
}; |
|
39 |
})( j ) ); |
|
40 |
j++; |
|
41 |
} |
|
42 |
} |
|
43 |
switchTab( 0 ); |
|
44 |
$G( "tabIconReview" ).style.display = 'none'; |
|
45 |
} |
|
46 |
|
|
47 |
function InsertSmiley( url, evt ) { |
|
48 |
var obj = { |
|
49 |
src:editor.options.emotionLocalization ? editor.options.UEDITOR_HOME_URL + "dialogs/emotion/" + url : url |
|
50 |
}; |
|
51 |
obj._src = obj.src; |
|
52 |
editor.execCommand( 'insertimage', obj ); |
|
53 |
if ( !evt.ctrlKey ) { |
|
54 |
dialog.popup.hide(); |
|
55 |
} |
|
56 |
} |
|
57 |
|
|
58 |
function switchTab( index ) { |
|
59 |
|
|
60 |
autoHeight( index ); |
|
61 |
if ( emotion.tabExist[index] == 0 ) { |
|
62 |
emotion.tabExist[index] = 1; |
|
63 |
createTab( 'tab' + index ); |
|
64 |
} |
|
65 |
//获取呈现元素句柄数组 |
|
66 |
var tabHeads = $G( "tabHeads" ).getElementsByTagName( "span" ), |
|
67 |
tabBodys = $G( "tabBodys" ).getElementsByTagName( "div" ), |
|
68 |
i = 0, L = tabHeads.length; |
|
69 |
//隐藏所有呈现元素 |
|
70 |
for ( ; i < L; i++ ) { |
|
71 |
tabHeads[i].className = ""; |
|
72 |
tabBodys[i].style.display = "none"; |
|
73 |
} |
|
74 |
//显示对应呈现元素 |
|
75 |
tabHeads[index].className = "focus"; |
|
76 |
tabBodys[index].style.display = "block"; |
|
77 |
} |
|
78 |
|
|
79 |
function autoHeight( index ) { |
|
80 |
var iframe = dialog.getDom( "iframe" ), |
|
81 |
parent = iframe.parentNode.parentNode; |
|
82 |
switch ( index ) { |
|
83 |
case 0: |
|
84 |
iframe.style.height = "380px"; |
|
85 |
parent.style.height = "392px"; |
|
86 |
break; |
|
87 |
case 1: |
|
88 |
iframe.style.height = "220px"; |
|
89 |
parent.style.height = "232px"; |
|
90 |
break; |
|
91 |
case 2: |
|
92 |
iframe.style.height = "260px"; |
|
93 |
parent.style.height = "272px"; |
|
94 |
break; |
|
95 |
case 3: |
|
96 |
iframe.style.height = "300px"; |
|
97 |
parent.style.height = "312px"; |
|
98 |
break; |
|
99 |
case 4: |
|
100 |
iframe.style.height = "140px"; |
|
101 |
parent.style.height = "152px"; |
|
102 |
break; |
|
103 |
case 5: |
|
104 |
iframe.style.height = "260px"; |
|
105 |
parent.style.height = "272px"; |
|
106 |
break; |
|
107 |
case 6: |
|
108 |
iframe.style.height = "230px"; |
|
109 |
parent.style.height = "242px"; |
|
110 |
break; |
|
111 |
default: |
|
112 |
|
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
|
|
117 |
function createTab( tabName ) { |
|
118 |
var faceVersion = "?v=1.1", //版本号 |
|
119 |
tab = $G( tabName ), //获取将要生成的Div句柄 |
|
120 |
imagePath = emotion.SmileyPath + emotion.imageFolders[tabName], //获取显示表情和预览表情的路径 |
|
121 |
positionLine = 11 / 2, //中间数 |
|
122 |
iWidth = iHeight = 35, //图片长宽 |
|
123 |
iColWidth = 3, //表格剩余空间的显示比例 |
|
124 |
tableCss = emotion.imageCss[tabName], |
|
125 |
cssOffset = emotion.imageCssOffset[tabName], |
|
126 |
textHTML = ['<table class="smileytable">'], |
|
127 |
i = 0, imgNum = emotion.SmileyBox[tabName].length, imgColNum = 11, faceImage, |
|
128 |
sUrl, realUrl, posflag, offset, infor; |
|
129 |
|
|
130 |
for ( ; i < imgNum; ) { |
|
131 |
textHTML.push( '<tr>' ); |
|
132 |
for ( var j = 0; j < imgColNum; j++, i++ ) { |
|
133 |
faceImage = emotion.SmileyBox[tabName][i]; |
|
134 |
if ( faceImage ) { |
|
135 |
sUrl = imagePath + faceImage + faceVersion; |
|
136 |
realUrl = imagePath + faceImage; |
|
137 |
posflag = j < positionLine ? 0 : 1; |
|
138 |
offset = cssOffset * i * (-1) - 1; |
|
139 |
infor = emotion.SmileyInfor[tabName][i]; |
|
140 |
|
|
141 |
textHTML.push( '<td class="' + tableCss + '" border="1" width="' + iColWidth + '%" style="border-collapse:collapse;" align="center" bgcolor="transparent" onclick="InsertSmiley(\'' + realUrl.replace( /'/g, "\\'" ) + '\',event)" onmouseover="over(this,\'' + sUrl + '\',\'' + posflag + '\')" onmouseout="out(this)">' ); |
|
142 |
textHTML.push( '<span>' ); |
|
143 |
textHTML.push( '<img style="background-position:left ' + offset + 'px;" title="' + infor + '" src="' + emotion.SmileyPath + (editor.options.emotionLocalization ? '0.gif" width="' : 'default/0.gif" width="') + iWidth + '" height="' + iHeight + '"></img>' ); |
|
144 |
textHTML.push( '</span>' ); |
|
145 |
} else { |
|
146 |
textHTML.push( '<td width="' + iColWidth + '%" bgcolor="#FFFFFF">' ); |
|
147 |
} |
|
148 |
textHTML.push( '</td>' ); |
|
149 |
} |
|
150 |
textHTML.push( '</tr>' ); |
|
151 |
} |
|
152 |
textHTML.push( '</table>' ); |
|
153 |
textHTML = textHTML.join( "" ); |
|
154 |
tab.innerHTML = textHTML; |
|
155 |
} |
|
156 |
|
|
157 |
function over( td, srcPath, posFlag ) { |
|
158 |
td.style.backgroundColor = "#ACCD3C"; |
|
159 |
$G( 'faceReview' ).style.backgroundImage = "url(" + srcPath + ")"; |
|
160 |
if ( posFlag == 1 ) $G( "tabIconReview" ).className = "show"; |
|
161 |
$G( "tabIconReview" ).style.display = 'block'; |
|
162 |
} |
|
163 |
|
|
164 |
function out( td ) { |
|
165 |
td.style.backgroundColor = "transparent"; |
|
166 |
var tabIconRevew = $G( "tabIconReview" ); |
|
167 |
tabIconRevew.className = ""; |
|
168 |
tabIconRevew.style.display = 'none'; |
|
169 |
} |
|
170 |
|
|
171 |
function createTabList( tabNum ) { |
|
172 |
var obj = {}; |
|
173 |
for ( var i = 0; i < tabNum; i++ ) { |
|
174 |
obj["tab" + i] = []; |
|
175 |
} |
|
176 |
return obj; |
|
177 |
} |
|
178 |
|
|
179 |
function createArr( tabNum ) { |
|
180 |
var arr = []; |
|
181 |
for ( var i = 0; i < tabNum; i++ ) { |
|
182 |
arr[i] = 0; |
|
183 |
} |
|
184 |
return arr; |
|
185 |
} |
|
186 |
|