Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_14980201
ueditor
提交
779f9f15
U
ueditor
项目概览
qq_14980201
/
ueditor
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
ueditor
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
779f9f15
编写于
2月 25, 2013
作者:
Z
zhuwenxuan
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev-1.2.5' of
https://github.com/campaign/ueditor
into dev-1.2.5
上级
c3099891
7671d13c
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
349 addition
and
60 deletion
+349
-60
_src/plugins/contextmenu.js
_src/plugins/contextmenu.js
+85
-0
_src/plugins/table.action.js
_src/plugins/table.action.js
+8
-2
_src/plugins/table.cmds.js
_src/plugins/table.cmds.js
+92
-18
_src/plugins/table.core.js
_src/plugins/table.core.js
+70
-17
_src/plugins/wordimage.js
_src/plugins/wordimage.js
+1
-1
_test/core/node.js
_test/core/node.js
+70
-12
_test/plugins/table.core.js
_test/plugins/table.core.js
+21
-8
dialogs/internal.js
dialogs/internal.js
+2
-2
未找到文件。
_src/plugins/contextmenu.js
浏览文件 @
779f9f15
...
...
@@ -70,6 +70,41 @@ UE.plugins['contextmenu'] = function () {
label
:
lang
.
inserttable
,
cmdName
:
'
inserttable
'
},
{
label
:
"
清除表格背景
"
,
cmdName
:
"
cleartablebackground
"
,
exec
:
function
(){
this
.
execCommand
(
"
cleartablebackground
"
);
}
},
{
label
:
"
整个表格隔行变色
"
,
cmdName
:
"
settablebackground
"
,
exec
:
function
(){
this
.
execCommand
(
"
settablebackground
"
,{
repeat
:
true
,
colorList
:[
"
#bbb
"
,
"
#ccc
"
]},
true
);
}
},
{
label
:
"
三色渐变
"
,
cmdName
:
"
settablebackground
"
,
exec
:
function
(){
this
.
execCommand
(
"
settablebackground
"
,{
repeat
:
true
,
colorList
:[
"
#aaa
"
,
"
#bbb
"
,
"
#ccc
"
]});
}
},
{
label
:
"
隔行变色
"
,
cmdName
:
"
settablebackground
"
,
exec
:
function
(){
this
.
execCommand
(
"
settablebackground
"
,{
repeat
:
true
,
colorList
:[
"
#bbb
"
,
"
#ccc
"
]});
}
},
{
label
:
"
红蓝相间
"
,
cmdName
:
"
settablebackground
"
,
exec
:
function
(){
this
.
execCommand
(
"
settablebackground
"
,{
repeat
:
true
,
colorList
:[
"
red
"
,
"
blue
"
]});
}
},
{
label
:
lang
.
deletetable
,
cmdName
:
'
deletetable
'
...
...
@@ -174,6 +209,54 @@ UE.plugins['contextmenu'] = function () {
}
]
},
{
group
:
"
表格排序
"
,
icon
:
'
tablesort
'
,
subMenu
:[
{
label
:
"
逆序当前
"
,
cmdName
:
'
sorttable
'
,
value
:
1
},
{
label
:
"
按ASCII字符升序
"
,
cmdName
:
'
sorttable
'
},
{
label
:
"
按ASCII字符降序
"
,
cmdName
:
'
sorttable
'
,
exec
:
function
(){
this
.
execCommand
(
"
sorttable
"
,
function
(
td1
,
td2
){
var
value1
=
td1
.
innerHTML
,
value2
=
td2
.
innerHTML
;
return
value2
.
localeCompare
(
value1
);
});
}
},
{
label
:
"
按数值大小升序
"
,
cmdName
:
'
sorttable
'
,
exec
:
function
(){
this
.
execCommand
(
"
sorttable
"
,
function
(
td1
,
td2
){
var
value1
=
parseInt
(
td1
.
innerHTML
,
10
),
value2
=
parseInt
(
td2
.
innerHTML
,
10
);
return
(
value1
||
0
)
-
(
value2
||
0
);
});
}
},
{
label
:
"
按数值大小降序
"
,
cmdName
:
'
sorttable
'
,
exec
:
function
(){
this
.
execCommand
(
"
sorttable
"
,
function
(
td1
,
td2
){
var
value1
=
parseInt
(
td1
.
innerHTML
,
10
),
value2
=
parseInt
(
td2
.
innerHTML
,
10
);
return
(
value2
||
0
)
-
(
value1
||
0
);
});
}
}
]
},
{
group
:
lang
.
aligntd
,
icon
:
'
aligntd
'
,
...
...
@@ -330,6 +413,8 @@ UE.plugins['contextmenu'] = function () {
return
me
.
getLang
(
"
contextMenu.aligntd
"
);
case
"
aligntable
"
:
return
me
.
getLang
(
"
contextMenu.aligntable
"
);
case
"
tablesort
"
:
return
"
表格排序
"
;
default
:
return
''
;
}
...
...
_src/plugins/table.action.js
浏览文件 @
779f9f15
...
...
@@ -47,7 +47,8 @@ UE.plugins['table'] = function () {
'
defaultRows
'
:
5
,
'
tdvalign
'
:
'
top
'
,
'
cursorpath
'
:
me
.
options
.
UEDITOR_HOME_URL
+
"
themes/default/images/cursor_
"
,
'
tableDragable
'
:
false
'
tableDragable
'
:
false
,
'
classList
'
:[
"
.back1
"
,
"
.back2
"
]
});
me
.
getUETable
=
getUETable
;
var
commands
=
{
...
...
@@ -84,7 +85,7 @@ UE.plugins['table'] = function () {
'
table.noBorderTable td,table.noBorderTable th,table.noBorderTable caption{border:1px dashed #ddd !important}
'
+
//插入的表格的默认样式
'
table{margin-bottom:10px;border-collapse:collapse;display:table;}
'
+
'
td,th{
background:white;
padding: 5px 10px;border: 1px solid #DDD;}
'
+
'
td,th{padding: 5px 10px;border: 1px solid #DDD;}
'
+
'
caption{border:1px dashed #DDD;border-bottom:0;padding:3px;text-align:center;}
'
+
'
th{border-top:2px solid #BBB;background:#F7F7F7;}
'
+
'
td p{margin:0;padding:0;}
'
,
me
.
document
);
...
...
@@ -513,6 +514,11 @@ UE.plugins['table'] = function () {
toggleDraggableState
(
me
,
false
,
""
,
null
);
}
});
me
.
addListener
(
"
interlacetable
"
,
function
(
type
,
table
){
var
rows
=
table
.
rows
,
len
;
});
me
.
addListener
(
"
mousedown
"
,
mouseDownEvent
);
...
...
_src/plugins/table.cmds.js
浏览文件 @
779f9f15
...
...
@@ -5,18 +5,19 @@
* Time: 下午6:25
* To change this template use File | Settings | File Templates.
*/
;(
function
(){
;
(
function
()
{
var
UT
=
UE
.
UETable
,
getTableItemsByRange
=
function
(
editor
)
{
getTableItemsByRange
=
function
(
editor
)
{
return
UT
.
getTableItemsByRange
(
editor
);
},
getUETableBySelected
=
function
(
editor
)
{
getUETableBySelected
=
function
(
editor
)
{
return
UT
.
getUETableBySelected
(
editor
)
},
getDefaultValue
=
function
(
editor
,
table
)
{
return
UT
.
getDefaultValue
(
editor
,
table
);
getDefaultValue
=
function
(
editor
,
table
)
{
return
UT
.
getDefaultValue
(
editor
,
table
);
},
getUETable
=
function
(
tdOrTable
)
{
getUETable
=
function
(
tdOrTable
)
{
return
UT
.
getUETable
(
tdOrTable
);
};
...
...
@@ -526,10 +527,10 @@
table
=
tableItems
.
table
;
if
(
table
)
{
if
(
cmd
==
'
adaptbywindow
'
)
{
resetTdWidth
(
table
,
this
);
resetTdWidth
(
table
,
this
);
}
else
{
var
cells
=
domUtils
.
getElementsByTagName
(
table
,
"
td th
"
);
utils
.
each
(
cells
,
function
(
cell
)
{
var
cells
=
domUtils
.
getElementsByTagName
(
table
,
"
td th
"
);
utils
.
each
(
cells
,
function
(
cell
)
{
cell
.
removeAttribute
(
"
width
"
);
});
table
.
removeAttribute
(
"
width
"
);
...
...
@@ -696,7 +697,6 @@
if
(
table
)
{
var
obj
=
{};
obj
[
data
[
0
]]
=
data
[
1
];
table
.
style
[
utils
.
cssStyleToDomStyle
(
"
float
"
)]
=
""
;
table
.
style
.
margin
=
""
;
domUtils
.
setStyles
(
table
,
obj
);
...
...
@@ -745,25 +745,99 @@
}
}
};
UE
.
commands
[
'
sorttable
'
]
=
{
queryCommandState
:
function
()
{
var
me
=
this
,
tableItems
=
getTableItemsByRange
(
me
);
if
(
!
tableItems
.
cell
)
return
-
1
;
var
table
=
tableItems
.
table
,
cells
=
table
.
getElementsByTagName
(
"
td
"
);
for
(
var
i
=
0
,
cell
;
cell
=
cells
[
i
++
];)
{
if
(
cell
.
rowSpan
!=
1
||
cell
.
colSpan
!=
1
)
return
-
1
;
}
return
0
;
},
execCommand
:
function
(
cmd
,
fn
)
{
var
me
=
this
,
range
=
me
.
selection
.
getRange
(),
bk
=
range
.
createBookmark
(
true
),
tableItems
=
getTableItemsByRange
(
me
),
cell
=
tableItems
.
cell
,
ut
=
getUETable
(
tableItems
.
table
),
cellIndex
=
ut
.
getCellInfo
(
cell
).
cellIndex
,
cells
=
ut
.
getSameEndPosCells
(
cell
,
"
x
"
);
if
(
cells
.
length
<
ut
.
rowsNum
)
{
this
.
fireEvent
(
"
tableForbidSort
"
);
return
;
}
ut
.
sortTable
(
cellIndex
,
fn
);
range
.
moveToBookmark
(
bk
).
select
();
}
};
function
resetTdWidth
(
table
,
editor
){
UE
.
commands
[
"
enablesort
"
]
=
UE
.
commands
[
"
disablesort
"
]
=
{
queryCommandState
:
function
()
{
return
getTableItemsByRange
(
this
).
table
?
0
:
-
1
;
},
execCommand
:
function
(
cmd
)
{
var
table
=
getTableItemsByRange
(
this
).
table
;
table
.
setAttribute
(
"
data-sort
"
,
cmd
==
"
enablesort
"
?
"
sortEnabled
"
:
"
sortDisabled
"
);
}
};
UE
.
commands
[
"
settablebackground
"
]
=
{
queryCommandState
:
function
()
{
return
getTableItemsByRange
(
this
).
table
?
0
:
-
1
;
},
execCommand
:
function
(
cmd
,
value
,
allCells
)
{
var
table
,
cells
,
ut
;
if
(
allCells
)
{
table
=
getTableItemsByRange
(
this
).
table
;
cells
=
table
.
getElementsByTagName
(
"
td
"
);
}
else
{
cells
=
getSelectedArr
(
this
);
}
ut
=
getUETable
(
cells
[
0
]);
ut
.
setBackground
(
cells
,
value
);
}
};
UE
.
commands
[
"
cleartablebackground
"
]
=
{
execCommand
:
function
()
{
var
cells
=
getSelectedArr
(
this
),
ut
=
getUETable
(
cells
[
0
]);
ut
.
removeBackground
(
cells
);
}
};
UE
.
commands
[
"
interlacedtable
"
]
=
UE
.
commands
[
"
uninterlacedtable
"
]
=
{
execCommand
:
function
(
cmd
)
{
var
table
=
getTableItemsByRange
(
this
).
table
;
table
.
setAttribute
(
"
interlaced
"
,
cmd
==
"
interlacedtable
"
?
"
enabled
"
:
"
disabled
"
);
this
.
fireEvent
(
"
interlacetable
"
,
table
);
}
};
function
resetTdWidth
(
table
,
editor
)
{
var
tds
=
table
.
getElementsByTagName
(
"
td
"
);
utils
.
each
(
tds
,
function
(
td
)
{
td
.
removeAttribute
(
"
width
"
);
});
table
.
setAttribute
(
'
width
'
,
getTableWidth
(
editor
,
true
,
getDefaultValue
(
editor
,
table
)));
setTimeout
(
function
()
{
utils
.
each
(
tds
,
function
(
td
)
{
(
td
.
colSpan
==
1
)
&&
td
.
setAttribute
(
"
width
"
,
td
.
offsetWidth
+
""
);
table
.
setAttribute
(
'
width
'
,
getTableWidth
(
editor
,
true
,
getDefaultValue
(
editor
,
table
)));
setTimeout
(
function
()
{
utils
.
each
(
tds
,
function
(
td
)
{
(
td
.
colSpan
==
1
)
&&
td
.
setAttribute
(
"
width
"
,
td
.
offsetWidth
+
""
);
})
},
0
);
},
0
);
}
function
getTableWidth
(
editor
,
needIEHack
,
defaultValue
)
{
var
body
=
editor
.
body
;
return
body
.
offsetWidth
-
(
needIEHack
?
parseInt
(
domUtils
.
getComputedStyle
(
body
,
'
margin-left
'
),
10
)
*
2
:
0
)
-
defaultValue
.
tableBorder
*
2
-
(
editor
.
options
.
offsetWidth
||
0
);
}
function
getSelectedArr
(
editor
)
{
var
ut
=
getTableItemsByRange
(
editor
).
cell
||
getUETableBySelected
(
editor
);
return
ut
?
(
ut
.
nodeType
?
[
ut
]
:
ut
.
selectedTds
)
:
[];
var
cell
=
getTableItemsByRange
(
editor
).
cell
,
ut
=
getUETable
(
cell
);
return
ut
.
selectedTds
.
length
?
ut
.
selectedTds
:
[
cell
];
}
})();
\ No newline at end of file
_src/plugins/table.core.js
浏览文件 @
779f9f15
...
...
@@ -11,7 +11,7 @@
* @constructor
*/
(
function
()
{
var
UETable
=
UE
.
UETable
=
function
(
table
)
{
var
UETable
=
UE
.
UETable
=
function
(
table
)
{
this
.
table
=
table
;
this
.
indexTable
=
[];
this
.
selectedTds
=
[];
...
...
@@ -20,29 +20,29 @@
};
//===以下为静态工具方法===
UETable
.
removeSelectedClass
=
function
(
cells
)
{
UETable
.
removeSelectedClass
=
function
(
cells
)
{
utils
.
each
(
cells
,
function
(
cell
)
{
domUtils
.
removeClasses
(
cell
,
"
selectTdClass
"
);
})
};
UETable
.
addSelectedClass
=
function
(
cells
)
{
UETable
.
addSelectedClass
=
function
(
cells
)
{
utils
.
each
(
cells
,
function
(
cell
)
{
domUtils
.
addClass
(
cell
,
"
selectTdClass
"
);
})
};
UETable
.
isEmptyBlock
=
function
(
node
)
{
UETable
.
isEmptyBlock
=
function
(
node
)
{
var
reg
=
new
RegExp
(
domUtils
.
fillChar
,
'
g
'
);
if
(
node
[
browser
.
ie
?
'
innerText
'
:
'
textContent
'
].
replace
(
/^
\s
*$/
,
''
).
replace
(
reg
,
''
).
length
>
0
)
{
return
0
;
}
for
(
var
i
in
dtd
.
$isNotEmpty
)
if
(
dtd
.
$isNotEmpty
.
hasOwnProperty
(
i
))
{
for
(
var
i
in
dtd
.
$isNotEmpty
)
if
(
dtd
.
$isNotEmpty
.
hasOwnProperty
(
i
))
{
if
(
node
.
getElementsByTagName
(
i
).
length
)
{
return
0
;
}
}
return
1
;
};
UETable
.
getWidth
=
function
(
cell
)
{
UETable
.
getWidth
=
function
(
cell
)
{
if
(
!
cell
)
return
0
;
return
parseInt
(
domUtils
.
getComputedStyle
(
cell
,
"
width
"
),
10
);
};
...
...
@@ -51,7 +51,7 @@
* 根据当前选区获取相关的table信息
* @return {Object}
*/
UETable
.
getTableItemsByRange
=
function
(
editor
)
{
UETable
.
getTableItemsByRange
=
function
(
editor
)
{
var
start
=
editor
.
selection
.
getStart
(),
//在table或者td边缘有可能存在选中tr的情况
cell
=
start
&&
domUtils
.
findParentByTagName
(
start
,
[
"
td
"
,
"
th
"
],
true
),
...
...
@@ -66,7 +66,7 @@
caption
:
caption
}
};
UETable
.
getUETableBySelected
=
function
(
editor
)
{
UETable
.
getUETableBySelected
=
function
(
editor
)
{
var
table
=
UETable
.
getTableItemsByRange
(
editor
).
table
;
if
(
table
&&
table
.
ueTable
&&
table
.
ueTable
.
selectedTds
.
length
)
{
return
table
.
ueTable
;
...
...
@@ -74,7 +74,7 @@
return
null
;
};
UETable
.
getDefaultValue
=
function
(
editor
,
table
)
{
UETable
.
getDefaultValue
=
function
(
editor
,
table
)
{
var
borderMap
=
{
thin
:
'
0px
'
,
medium
:
'
1px
'
,
...
...
@@ -117,7 +117,7 @@
* 根据当前点击的td或者table获取索引对象
* @param tdOrTable
*/
UETable
.
getUETable
=
function
(
tdOrTable
)
{
UETable
.
getUETable
=
function
(
tdOrTable
)
{
var
tag
=
tdOrTable
.
tagName
.
toLowerCase
();
tdOrTable
=
(
tag
==
"
td
"
||
tag
==
"
th
"
||
tag
==
'
caption
'
)
?
domUtils
.
findParentByTagName
(
tdOrTable
,
"
table
"
,
true
)
:
tdOrTable
;
if
(
!
tdOrTable
.
ueTable
)
{
...
...
@@ -261,14 +261,14 @@
setCellContent
:
function
(
cell
,
content
)
{
cell
.
innerHTML
=
content
||
(
browser
.
ie
?
domUtils
.
fillChar
:
"
<br />
"
);
},
cloneCell
:
function
(
cell
,
ignoreMerge
)
{
if
(
!
cell
||
utils
.
isString
(
cell
))
{
cloneCell
:
function
(
cell
,
ignoreMerge
)
{
if
(
!
cell
||
utils
.
isString
(
cell
))
{
return
this
.
table
.
ownerDocument
.
createElement
(
cell
||
'
td
'
);
}
var
flag
=
domUtils
.
hasClass
(
cell
,
"
selectTdClass
"
);
flag
&&
domUtils
.
removeClasses
(
cell
,
"
selectTdClass
"
);
var
tmpCell
=
cell
.
cloneNode
(
true
);
if
(
ignoreMerge
)
{
if
(
ignoreMerge
)
{
tmpCell
.
rowSpan
=
tmpCell
.
colSpan
=
1
;
}
tmpCell
.
style
.
borderLeftStyle
=
""
;
...
...
@@ -312,10 +312,12 @@
this
.
cellsRange
=
{};
this
.
indexTable
=
[];
var
rows
=
this
.
table
.
rows
,
//暂时采用rows Length,对残缺表格可能存在问题,
//todo 可以考虑取最大值
rowsNum
=
rows
.
length
,
rowsNum
=
this
.
getMaxRows
(),
dNum
=
rowsNum
-
rows
.
length
,
colsNum
=
this
.
getMaxCols
();
while
(
dNum
--
)
{
this
.
table
.
insertRow
(
rows
.
length
);
}
this
.
rowsNum
=
rowsNum
;
this
.
colsNum
=
colsNum
;
for
(
var
i
=
0
,
len
=
rows
.
length
;
i
<
len
;
i
++
)
{
...
...
@@ -1009,7 +1011,58 @@
var
tds
=
this
.
table
.
getElementsByTagName
(
"
td
"
),
range
=
this
.
getCellsRange
(
tds
[
0
],
tds
[
tds
.
length
-
1
]);
this
.
setSelected
(
range
);
},
sortTable
:
function
(
sortByCellIndex
,
compareFn
){
var
table
=
this
.
table
,
rows
=
table
.
rows
,
trArray
=
[],
flag
=
rows
[
0
].
cells
[
0
].
tagName
===
"
TH
"
;
for
(
var
i
=
0
,
len
=
rows
.
length
;
i
<
len
;
i
++
)
{
trArray
[
i
]
=
rows
[
i
];
}
//th不参与排序
flag
&&
trArray
.
splice
(
0
,
1
);
trArray
.
sort
(
function
(
tr1
,
tr2
)
{
return
compareFn
?
(
typeof
compareFn
===
"
number
"
?
compareFn
:
compareFn
.
call
(
this
,
tr1
.
cells
[
sortByCellIndex
],
tr2
.
cells
[
sortByCellIndex
]))
:
function
()
{
var
value1
=
tr1
.
cells
[
sortByCellIndex
].
innerHTML
,
value2
=
tr2
.
cells
[
sortByCellIndex
].
innerHTML
;
return
value1
.
localeCompare
(
value2
);
}();
});
var
fragment
=
table
.
ownerDocument
.
createDocumentFragment
();
for
(
var
j
=
0
,
len
=
trArray
.
length
;
j
<
len
;
j
++
)
{
fragment
.
appendChild
(
trArray
[
j
]);
}
table
.
getElementsByTagName
(
"
tbody
"
)[
0
].
appendChild
(
fragment
);
},
setBackground
:
function
(
cells
,
value
){
if
(
typeof
value
===
"
string
"
){
utils
.
each
(
cells
,
function
(
cell
){
cell
.
style
.
backgroundColor
=
value
;
})
}
else
if
(
typeof
value
===
"
object
"
){
value
=
utils
.
extend
({
repeat
:
true
,
colorList
:[
"
#ddd
"
,
"
#fff
"
]
},
value
);
var
rowIndex
=
this
.
getCellInfo
(
cells
[
0
]).
rowIndex
,
count
=
0
,
colors
=
value
.
colorList
,
getColor
=
function
(
list
,
index
,
repeat
){
return
list
[
index
]
?
list
[
index
]
:
repeat
?
list
[
index
%
list
.
length
]:
""
;
};
for
(
var
i
=
0
,
cell
;
cell
=
cells
[
i
++
];){
var
cellInfo
=
this
.
getCellInfo
(
cell
);
cell
.
style
.
backgroundColor
=
getColor
(
colors
,((
rowIndex
+
count
)
==
cellInfo
.
rowIndex
)
?
count
:
++
count
,
value
.
repeat
);
}
}
},
removeBackground
:
function
(
cells
){
utils
.
each
(
cells
,
function
(
cell
){
cell
.
style
.
backgroundColor
=
""
;
})
}
};
function
showError
(
e
)
{}
function
showError
(
e
)
{
}
})();
\ No newline at end of file
_src/plugins/wordimage.js
浏览文件 @
779f9f15
...
...
@@ -14,7 +14,7 @@ UE.plugins["wordimage"] = function () {
flag
=
parseInt
(
attrs
.
width
)
<
128
||
parseInt
(
attrs
.
height
)
<
43
,
opt
=
me
.
options
,
src
=
opt
.
UEDITOR_HOME_URL
+
'
themes/default/images/spacer.gif
'
;
if
(
attrs
[
'
_src
'
].
indexOf
(
"
file:///
"
)
!==-
1
)
{
if
(
attrs
[
'
_src
'
]
&&
attrs
[
'
_src
'
]
.
indexOf
(
"
file:///
"
)
!==-
1
)
{
img
.
setAttr
({
width
:
attrs
.
width
,
height
:
attrs
.
height
,
...
...
_test/core/node.js
浏览文件 @
779f9f15
...
...
@@ -2,22 +2,55 @@ module( 'core.node' );
test
(
''
,
function
()
{
var
uNode
=
UE
.
uNode
;
//createElement
var
node
=
uNode
.
createElement
(
'
div
'
);
equals
(
node
.
tagName
,
'
div
'
);
equals
(
node
.
type
,
'
element
'
);
node
=
uNode
.
createElement
(
'
<div id="aa">sdfadf</div>
'
);
equals
(
node
.
tagName
,
'
div
'
);
equals
(
node
.
children
[
0
].
data
,
'
sdfadf
'
);
//getNodeById
node
=
uNode
.
createElement
(
'
<div id="aa"><div id="bb"></div>sdfadf</div>
'
);
node
=
node
.
getNodeById
(
'
bb
'
);
equals
(
node
.
getAttr
(
'
id
'
),
'
bb
'
);
node
=
uNode
.
createElement
(
'
<div id="aa"><div id="bb"><div id="cc"></div> </div>sdfadf</div>
'
);
node
=
node
.
getNodeById
(
'
cc
'
);
equals
(
node
.
getAttr
(
'
id
'
),
'
cc
'
);
//getNodesByTagName
node
=
uNode
.
createElement
(
'
<div id="aa"><div id="bb"><div id="cc"></div> </div>sdfadf</div>
'
);
var
nodelist
=
node
.
getNodesByTagName
(
'
div
'
);
equals
(
nodelist
.
length
,
2
);
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<div id="bb"><div id="cc"></div> </div>sdfadf
'
);
//innerHTML
node
.
innerHTML
(
'
<div><div><div></div></div></div>
'
);
nodelist
=
node
.
getNodesByTagName
(
'
div
'
);
equals
(
nodelist
.
length
,
3
);
for
(
var
i
=
0
,
ci
;
ci
=
nodelist
[
i
++
];){
ci
.
tagName
=
'
p
'
;
}
equals
(
node
.
innerHTML
(),
'
<p><p><p></p></p></p>
'
);
//innerText
var
tmp
=
new
UE
.
uNode
.
createElement
(
'
area
'
);
tmp
.
innerHTML
(
''
);
equals
(
tmp
.
innerText
(),
tmp
);
var
tmp
=
new
UE
.
uNode
.
createText
(
''
);
tmp
.
innerHTML
(
''
);
equals
(
tmp
.
innerText
(),
tmp
);
node
.
innerHTML
(
'
<p>dfsdfsdf<b>eee</b>sdf</p>
'
);
equals
(
node
.
innerText
(),
'
dfsdfsdfeeesdf
'
);
//getData
var
tmp
=
new
UE
.
uNode
.
createElement
(
'
div
'
);
equals
(
tmp
.
getData
(),
''
);
var
tmp
=
new
UE
.
uNode
.
createText
(
'
askdj
'
);
equals
(
tmp
.
getData
(),
"
askdj
"
);
//appendChild && insertBefore
node
.
innerHTML
(
'
<p><td></td></p>
'
);
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p>
'
);
var
tmp
=
uNode
.
createElement
(
'
div
'
);
...
...
@@ -27,27 +60,52 @@ test( '', function() {
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<div></div><p><table><tbody><tr><td></td></tr></tbody></table></p>
'
);
node
.
appendChild
(
tmp
);
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p><div></div>
'
);
//replaceChild && setAttr
tmp
=
uNode
.
createElement
(
'
p
'
);
tmp
.
setAttr
({
'
class
'
:
'
test
'
,
'
id
'
:
'
aa
'
});
node
.
insertBefore
(
tmp
,
node
.
lastChild
());
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p><p class="test" id="aa"></p><div></div>
'
);
node
.
replaceChild
(
uNode
.
createElement
(
'
div
'
),
tmp
);
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p><div></div><div></div>
'
);
node
.
innerHTML
(
'
<p>dfsdfsdf<b>eee</b>sdf</p>
'
);
equals
(
node
.
innerText
(),
'
dfsdfsdfeeesdf
'
);
node
.
innerHTML
(
'
<div><div><div></div></div></div>
'
);
nodelist
=
node
.
getNodesByTagName
(
'
div
'
);
equals
(
nodelist
.
length
,
3
);
for
(
var
i
=
0
,
ci
;
ci
=
nodelist
[
i
++
];){
ci
.
tagName
=
'
p
'
;
}
equals
(
node
.
innerHTML
(),
'
<p><p><p></p></p></p>
'
);
//insertAfter
node
.
innerHTML
(
'
<p><td></td></p>
'
);
var
tmp
=
uNode
.
createElement
(
'
div
'
);
node
.
appendChild
(
tmp
);
node
.
insertAfter
(
tmp
,
node
.
firstChild
());
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p><div></div>
'
);
node
.
appendChild
(
tmp
);
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p><div></div>
'
);
//setAttr
tmp
=
uNode
.
createElement
(
'
p
'
);
tmp
.
setAttr
();
node
.
insertAfter
(
tmp
,
node
.
lastChild
());
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p><div></div><p></p>
'
);
//replaceChild
node
.
innerHTML
(
'
<p><td></td></p>
'
);
var
tmp
=
uNode
.
createElement
(
'
div
'
);
node
.
appendChild
(
tmp
);
node
.
replaceChild
(
node
.
firstChild
(),
tmp
);
equals
(
node
.
innerHTML
().
replace
(
/
[
]
+>/g
,
'
>
'
),
'
<p><table><tbody><tr><td></td></tr></tbody></table></p>
'
);
//getStyle
node
.
innerHTML
(
'
<div style=""><div>
'
);
node
=
node
.
firstChild
();
equals
(
node
.
getStyle
(
''
),
''
);
node
.
innerHTML
(
'
<div style="border:1px solid #ccc"><div>
'
);
node
=
node
.
firstChild
();
equals
(
node
.
getStyle
(
'
border
'
),
'
1px solid #ccc
'
);
node
.
innerHTML
(
'
<div style="border:1px solid #ccc"><div>
'
);
node
=
node
.
firstChild
();
equals
(
node
.
getStyle
(
'
color
'
),
''
);
node
.
innerHTML
(
'
<div style="border:1px solid #ccc;color:#ccc"><div>
'
);
node
=
node
.
firstChild
();
equals
(
node
.
getStyle
(
'
border
'
),
'
1px solid #ccc
'
);
//setStyle
node
.
setStyle
(
'
border
'
,
'
2px solid #ccc
'
);
equals
(
node
.
getAttr
(
'
style
'
),
'
border:2px solid #ccc;color:#ccc
'
);
node
.
setStyle
({
...
...
@@ -63,14 +121,14 @@ test( '', function() {
});
equals
(
node
.
getAttr
(
'
style
'
),
undefined
);
node
.
setStyle
(
'
border
'
,
'
<script>alert("")</script>
'
);
equals
(
node
.
getAttr
(
'
style
'
),
"
border:<script>alert("")</script>;
"
);
equals
(
node
.
toHtml
(),
'
<div style=
\
"border:<script>alert("")</script>;
\
" ><div></div></div>
'
)
node
.
innerHTML
(
'
<div>asdfasdf<b>sdf</b></div>
'
)
node
.
removeChild
(
node
.
firstChild
(),
true
);
equals
(
node
.
toHtml
(),
'
<div style=
\
"border:<script>alert("")</script>;
\
" >asdfasdf<b>sdf</b></div>
'
)
//getIndex
var
tmp
=
new
UE
.
uNode
.
createElement
(
'
div
'
);
node
.
appendChild
(
tmp
);
equals
(
tmp
.
getIndex
(),
2
)
equals
(
tmp
.
getIndex
(),
2
)
;
});
\ No newline at end of file
_test/plugins/table.core.js
浏览文件 @
779f9f15
...
...
@@ -12,26 +12,39 @@ function getTable(str) {
div
.
id
=
"
testTable
"
;
document
.
body
.
appendChild
(
div
);
}
div
.
innerHTML
=
"
<table>
"
+
str
+
"
</table>
"
;
div
.
innerHTML
=
"
<table
border='1'
>
"
+
str
+
"
</table>
"
;
return
div
.
firstChild
;
}
UT
=
UE
.
UETable
;
test
(
"
create UETable
"
,
function
(){
var
table
=
getTable
(
"
<tr><td>ddd</td></tr>
"
),
ut
=
new
U
E
.
UETable
(
table
);
ut
=
new
U
T
(
table
);
ok
(
ut
.
table
===
table
,
"
UT对象创建成功
"
);
equal
(
ut
.
colsNum
,
1
,
"
单元格列数为1
"
);
equal
(
ut
.
rowsNum
,
1
,
"
单元格行数为1
"
);
ok
(
ut
.
colsNum
==
1
&&
ut
.
rowsNum
==
1
,
"
单元格行、列数为1
"
);
});
test
(
"
getMaxRows
"
,
function
(){
var
table
=
getTable
(
"
<tr><td>1</td><td>2</td><td>3</td></tr>
"
+
"
<tr><td>1</td><td>2</td><td>3</td></tr>
"
),
ut
=
new
U
E
.
UETable
(
table
);
ut
=
new
U
T
(
table
);
var
maxRows
=
ut
.
getMaxRows
();
equal
(
maxRows
,
2
,
"
最大行数为2
"
);
table
=
getTable
(
"
<tr><td rowspan='2'>1</td><td>2</td><td rowspan='2'>3</td></tr>
"
+
table
=
getTable
(
"
<tr><td rowspan='3'>1</td><td>2</td><td rowspan='2'>3</td></tr>
"
+
"
<tr><td>2</td></tr>
"
);
ut
=
new
UT
(
table
);
maxRows
=
ut
.
getMaxRows
();
equal
(
maxRows
,
3
,
"
最大行数为3
"
);
});
test
(
"
getMaxCols
"
,
function
(){
var
table
=
getTable
(
"
<tr><td>1</td><td>2</td><td>3</td></tr>
"
+
"
<tr><td>1</td><td>2</td><td>3</td></tr>
"
),
ut
=
new
UT
(
table
);
var
maxCols
=
ut
.
getMaxCols
();
equal
(
maxCols
,
3
,
"
最大列数为3
"
);
table
=
getTable
(
"
<tr><td rowspan='3'>1</td><td>2</td><td rowspan='2'>3</td></tr>
"
+
"
<tr><td>2</td><td colspan='3'></td></tr>
"
);
ut
=
new
UT
(
table
);
maxCols
=
ut
.
getMaxCols
();
equal
(
maxCols
,
6
,
"
最大列数为6
"
);
});
\ No newline at end of file
dialogs/internal.js
浏览文件 @
779f9f15
...
...
@@ -42,11 +42,11 @@
var
langImgPath
=
editor
.
options
.
langPath
+
editor
.
options
.
lang
+
"
/images/
"
;
//针对静态资源
for
(
var
i
in
lang
.
static
)
{
for
(
var
i
in
lang
[
"
static
"
]
)
{
var
dom
=
$G
(
i
);
if
(
!
dom
)
continue
;
var
tagName
=
dom
.
tagName
,
content
=
lang
.
static
[
i
];
content
=
lang
[
"
static
"
]
[
i
];
if
(
content
.
src
){
//clone
content
=
utils
.
extend
({},
content
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录