Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kityminder-core
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
吴志俊
kityminder-core
Commits
69cb9cc4
Commit
69cb9cc4
authored
Feb 11, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
by zhanyi
parent
cbfcc958
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
218 additions
and
14 deletions
+218
-14
configure.js
configure.js
+7
-4
dev.html
demo/dev.html
+0
-4
zh-cn.js
lang/zh-cn/zh-cn.js
+5
-1
adapter.js
src/adapter/adapter.js
+5
-2
combobox.js
src/adapter/combobox.js
+167
-0
font.js
src/module/font.js
+28
-1
layout.js
src/module/layout.js
+6
-2
No files found.
configure.js
View file @
69cb9cc4
window
.
KITYMINDER_CONFIG
=
{
//定义工具栏
toolbars
:[
'undo redo | bold italic | forecolor'
'undo redo | bold italic | forecolor
| layoutstyle | fontfamily fontsize
'
]
//设置主题
//layoutstyle : 'default'
//,defaultlayoutstyle : 'default' //设置默认的主题
//,layoutstyle : [] //添加有那些主图
//回退相关选项
//maxUndoCount:20 //最大可回退的次数,默认20
//
,
maxUndoCount:20 //最大可回退的次数,默认20
//语言默认是zh-cn
//,lang:'zh-cn'
//设置km整体的z-index大小
//zIndex : 1000
//,zIndex : 1000
};
\ No newline at end of file
demo/dev.html
View file @
69cb9cc4
...
...
@@ -19,10 +19,6 @@
</head>
<body
>
<div
id=
"kityminder"
style=
"height:1000px;width:100%"
onselectstart=
"return false"
>
<select
id=
"StyleChange"
>
<option
value=
"default"
>
Default
</option>
<option
value=
"green"
selected
>
Green
</option>
</select>
</div>
</body>
<script>
...
...
lang/zh-cn/zh-cn.js
View file @
69cb9cc4
KityMinder
.
LANG
[
'zh-cn'
]
=
{
'tooltips'
:{
'undo'
:
'撤销'
,
'redo'
:
'重做'
,
'bold'
:
'加粗'
,
'italic'
:
'斜体'
,
'forecolor'
:
'字体颜色'
'undo'
:
'撤销'
,
'redo'
:
'重做'
,
'bold'
:
'加粗'
,
'italic'
:
'斜体'
,
'forecolor'
:
'字体颜色'
,
'fontfamily'
:
'字体'
,
'fontsize'
:
'字号'
,
'layoutstyle'
:
'选择主题'
},
'popupcolor'
:{
'clearColor'
:
'清空颜色'
,
...
...
src/adapter/adapter.js
View file @
69cb9cc4
...
...
@@ -33,8 +33,11 @@ utils.extend(KityMinder,function(){
if
(
name
==
'|'
){
$
.
kmuiseparator
&&
btns
.
push
(
$
.
kmuiseparator
());
}
else
{
var
ui
=
_kityminderUI
[
name
].
call
(
km
,
name
);
ui
&&
btns
.
push
(
ui
);
if
(
_kityminderUI
[
name
]){
var
ui
=
_kityminderUI
[
name
].
call
(
km
,
name
);
ui
&&
btns
.
push
(
ui
);
}
}
});
...
...
src/adapter/combobox.js
View file @
69cb9cc4
KM
.
registerUI
(
'layoutstyle fontfamily fontsize'
,
function
(
name
)
{
var
me
=
this
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
options
=
{
label
:
label
,
title
:
label
,
comboboxName
:
name
,
items
:
me
.
getOptions
(
name
)
||
[],
itemStyles
:
[],
value
:
[],
autowidthitem
:
[]
},
$combox
=
null
,
comboboxWidget
=
null
;
if
(
options
.
items
.
length
==
0
){
return
null
;
}
switch
(
name
)
{
case
'layoutstyle'
:
options
=
transForLayoutstyle
(
options
);
break
;
case
'fontfamily'
:
options
=
transForFontfamily
(
options
);
break
;
case
'fontsize'
:
options
=
transForFontsize
(
options
);
break
;
}
//实例化
$combox
=
$
.
kmuibuttoncombobox
(
options
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
comboboxWidget
=
$combox
.
kmui
();
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
){
me
.
execCommand
(
name
,
res
.
value
);
}).
on
(
"beforeshow"
,
function
(){
if
(
$combox
.
parent
().
length
===
0
)
{
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
)
);
}
});
//状态反射
this
.
on
(
'interactchange'
,
function
(
){
var
state
=
this
.
queryCommandState
(
name
),
value
=
this
.
queryCommandValue
(
name
);
//设置按钮状态
comboboxWidget
.
button
().
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
);
if
(
value
){
//设置label
value
=
value
.
replace
(
/
[
'"
]
/g
,
''
).
toLowerCase
().
split
(
/
[
'|"
]?\s
*,
\s
*
[\1]?
/
);
comboboxWidget
.
selectItemByLabel
(
value
);
}
});
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
/**
* 宽度自适应工具函数
* @param word 单词内容
* @param hasSuffix 是否含有后缀
*/
function
wordCountAdaptive
(
word
,
hasSuffix
)
{
var
$tmpNode
=
$
(
'<span>'
).
html
(
word
).
css
(
{
display
:
'inline'
,
position
:
'absolute'
,
top
:
-
10000000
,
left
:
-
100000
}
).
appendTo
(
document
.
body
),
width
=
$tmpNode
.
width
();
$tmpNode
.
remove
();
$tmpNode
=
null
;
if
(
width
<
50
)
{
return
word
;
}
else
{
word
=
word
.
slice
(
0
,
hasSuffix
?
-
4
:
-
1
);
if
(
!
word
.
length
)
{
return
'...'
;
}
return
wordCountAdaptive
(
word
+
'...'
,
true
);
}
}
function
transForLayoutstyle
(
options
)
{
var
tempItems
=
[];
utils
.
each
(
options
.
items
,
function
(
k
,
v
){
options
.
value
.
push
(
k
);
tempItems
.
push
(
k
);
options
.
autowidthitem
.
push
(
wordCountAdaptive
(
tempItems
[
tempItems
.
length
-
1
]
)
);
});
options
.
items
=
tempItems
;
return
options
;
}
//字体参数转换
function
transForFontfamily
(
options
)
{
var
temp
=
null
,
tempItems
=
[];
for
(
var
i
=
0
,
len
=
options
.
items
.
length
;
i
<
len
;
i
++
)
{
temp
=
options
.
items
[
i
].
val
;
tempItems
.
push
(
temp
.
split
(
/
\s
*,
\s
*/
)[
0
]
);
options
.
itemStyles
.
push
(
'font-family: '
+
temp
);
options
.
value
.
push
(
temp
);
options
.
autowidthitem
.
push
(
wordCountAdaptive
(
tempItems
[
i
]
)
);
}
options
.
items
=
tempItems
;
return
options
;
}
//字体大小参数转换
function
transForFontsize
(
options
)
{
var
temp
=
null
,
tempItems
=
[];
options
.
itemStyles
=
[];
options
.
value
=
[];
for
(
var
i
=
0
,
len
=
options
.
items
.
length
;
i
<
len
;
i
++
)
{
temp
=
options
.
items
[
i
];
tempItems
.
push
(
temp
);
options
.
itemStyles
.
push
(
'font-size: '
+
temp
+
'px'
);
}
options
.
value
=
options
.
items
;
options
.
items
=
tempItems
;
options
.
autoRecord
=
false
;
return
options
;
}
});
KM
.
registerUI
(
'forecolor'
,
function
(
name
)
{
function
getCurrentColor
()
{
return
$colorLabel
.
css
(
'background-color'
);
...
...
src/module/font.js
View file @
69cb9cc4
KityMinder
.
registerModule
(
"fontmodule"
,
function
()
{
return
{
defaultOptions
:{
'fontfamily'
:
[
{
name
:
'songti'
,
val
:
'宋体,SimSun'
},
{
name
:
'yahei'
,
val
:
'微软雅黑,Microsoft YaHei'
},
{
name
:
'kaiti'
,
val
:
'楷体,楷体_GB2312, SimKai'
},
{
name
:
'heiti'
,
val
:
'黑体, SimHei'
},
{
name
:
'lishu'
,
val
:
'隶书, SimLi'
},
{
name
:
'andaleMono'
,
val
:
'andale mono'
},
{
name
:
'arial'
,
val
:
'arial, helvetica,sans-serif'
},
{
name
:
'arialBlack'
,
val
:
'arial black,avant garde'
},
{
name
:
'comicSansMs'
,
val
:
'comic sans ms'
},
{
name
:
'impact'
,
val
:
'impact,chicago'
},
{
name
:
'timesNewRoman'
,
val
:
'times new roman'
},
{
name
:
'sans-serif'
,
val
:
'sans-serif'
}
],
'fontsize'
:
[
10
,
12
,
16
,
18
,
24
,
32
,
48
]
},
"commands"
:
{
"forecolor"
:
kity
.
createClass
(
"fontcolorCommand"
,
{
base
:
Command
,
...
...
@@ -25,6 +41,17 @@ KityMinder.registerModule( "fontmodule", function () {
n
.
getTextShape
().
setAttr
(
'font-family'
,
family
);
}
)
}
}
),
"fontsize"
:
kity
.
createClass
(
"fontsizeCommand"
,
{
base
:
Command
,
execute
:
function
(
km
,
size
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'fontsize'
,
size
);
n
.
getTextShape
().
setSize
(
size
);
}
)
}
}
)
},
...
...
src/module/layout.js
View file @
69cb9cc4
...
...
@@ -7,6 +7,9 @@ KityMinder.registerModule( "LayoutModule", function () {
getLayoutStyle
:
function
(
name
)
{
return
this
.
_layoutStyles
[
name
];
},
getLayoutStyleItems
:
function
(){
return
this
.
_layoutStyles
},
getCurrentStyle
:
function
()
{
var
_root
=
this
.
getRoot
();
return
_root
.
getData
(
"currentstyle"
);
...
...
@@ -148,11 +151,12 @@ KityMinder.registerModule( "LayoutModule", function () {
},
"events"
:
{
"ready"
:
function
()
{
switchLayout
(
this
,
this
.
getOptions
(
'layoutstyle'
)
);
this
.
setDefaultOptions
(
'layoutstyle'
,
this
.
getLayoutStyleItems
());
switchLayout
(
this
,
this
.
getOptions
(
'defaultlayoutstyle'
)
);
}
},
"defaultOptions"
:
{
"layoutstyle"
:
"default"
"
default
layoutstyle"
:
"default"
}
};
}
);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment