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
ab951fb2
Commit
ab951fb2
authored
May 28, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add background change command
parent
ed1befc0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
221 additions
and
193 deletions
+221
-193
import.js
import.js
+88
-88
color.js
src/adapter/color.js
+62
-0
combobox.js
src/adapter/combobox.js
+40
-104
font.js
src/module/font.js
+30
-0
layout.default.js
src/module/layout.default.js
+1
-1
No files found.
import.js
View file @
ab951fb2
/**
/**
* 开发版本的文件导入
* 开发版本的文件导入
*/
*/
(
function
(){
(
function
()
{
var
paths
=
new
Array
(
var
paths
=
[
'core/kityminder.js'
'core/kityminder.js'
,
,
'core/utils.js'
'core/utils.js'
,
,
'core/command.js'
'core/command.js'
,
,
'core/node.js'
'core/node.js'
,
,
'core/module.js'
'core/module.js'
,
,
'core/event.js'
'core/event.js'
,
,
'core/minder.js'
'core/minder.js'
,
,
'core/minder.data.js'
'core/minder.data.js'
,
,
'core/minder.event.js'
'core/minder.event.js'
,
,
'core/minder.module.js'
'core/minder.module.js'
,
,
'core/minder.command.js'
'core/minder.command.js'
,
,
'core/minder.node.js'
'core/minder.node.js'
,
,
'core/keymap.js'
'core/keymap.js'
,
,
'core/minder.lang.js'
'core/minder.lang.js'
,
,
'core/minder.defaultoptions.js'
'core/minder.defaultoptions.js'
,
,
'core/minder.preference.js'
'core/minder.preference.js'
,
,
'core/browser.js'
'core/browser.js'
,
,
'module/geometry.js'
'module/geometry.js'
,
,
'module/history.js'
'module/history.js'
,
,
'module/icon.js'
'module/icon.js'
,
,
'module/image.js'
'module/image.js'
,
,
'module/resource.js'
'module/resource.js'
,
,
'module/layout.js'
'module/layout.js'
,
,
'module/layout.default.js'
'module/layout.default.js'
,
,
'module/layout.bottom.js'
'module/layout.bottom.js'
,
,
'core/minder.select.js'
'core/minder.select.js'
,
,
'module/view.js'
'module/view.js'
,
,
'module/dragtree.js'
'module/dragtree.js'
,
,
'module/dropfile.js'
'module/dropfile.js'
,
,
'module/keyboard.js'
'module/keyboard.js'
,
,
'module/select.js'
'module/select.js'
,
,
'module/history.js'
'module/history.js'
,
,
'module/editor.js'
'module/editor.js'
,
,
'module/editor.range.js'
'module/editor.range.js'
,
,
'module/editor.receiver.js'
'module/editor.receiver.js'
,
,
'module/editor.selection.js'
'module/editor.selection.js'
,
,
'module/basestyle.js'
'module/basestyle.js'
,
,
'module/font.js'
'module/font.js'
,
,
'module/zoom.js'
'module/zoom.js'
,
,
'module/nodetext.js'
'module/nodetext.js'
,
,
'module/hyperlink.js'
'module/hyperlink.js'
,
,
'module/expand.js'
'module/expand.js'
,
,
'ui/jquery-ui-1.10.4.custom.min.js'
'ui/jquery-ui-1.10.4.custom.min.js'
,
,
'ui/widget.js'
'ui/widget.js'
,
,
'ui/button.js'
'ui/button.js'
,
,
'ui/toolbar.js'
'ui/toolbar.js'
,
,
'ui/menu.js'
'ui/menu.js'
,
,
'ui/dropmenu.js'
'ui/dropmenu.js'
,
,
'ui/splitbutton.js'
'ui/splitbutton.js'
,
,
'ui/colorsplitbutton.js'
'ui/colorsplitbutton.js'
,
,
'ui/popup.js'
'ui/popup.js'
,
,
'ui/scale.js'
'ui/scale.js'
,
,
'ui/colorpicker.js'
'ui/colorpicker.js'
,
,
'ui/combobox.js'
'ui/combobox.js'
,
,
'ui/buttoncombobox.js'
'ui/buttoncombobox.js'
,
,
'ui/modal.js'
'ui/modal.js'
,
,
'ui/tooltip.js'
'ui/tooltip.js'
,
,
'ui/tab.js'
'ui/tab.js'
,
,
'ui/separator.js'
'ui/separator.js'
,
,
'ui/scale.js'
'ui/scale.js'
,
,
'adapter/utils.js'
'adapter/utils.js'
,
,
'adapter/adapter.js'
'adapter/adapter.js'
,
,
'adapter/button.js'
'adapter/button.js'
,
,
'adapter/combobox.js'
'adapter/combobox.js'
,
,
'adapter/saveto.js'
'adapter/color.js'
,
,
'adapter/tooltips.js'
'adapter/saveto.js'
,
,
'adapter/layout.js'
'adapter/tooltips.js'
,
,
'adapter/node.js'
'adapter/layout.js'
,
,
'adapter/contextmenu.js'
'adapter/node.js'
,
,
'adapter/dialog.js'
'adapter/contextmenu.js'
,
,
'adapter/hyperlink.js'
'adapter/dialog.js'
,
,
'adapter/image.js'
'adapter/hyperlink.js'
,
,
'adapter/zoom.js'
'adapter/image.js'
,
,
'protocal/xmind.js'
'adapter/zoom.js'
,
,
'protocal/freemind.js'
'protocal/xmind.js'
,
,
'protocal/mindmanager.js'
'protocal/freemind.js'
,
,
'protocal/plain.js'
'protocal/mindmanager.js'
,
,
'protocal/json.js'
'protocal/plain.js'
,
,
'protocal/png.js'
'protocal/json.js'
,
,
'protocal/svg.js'
'protocal/png.js'
,
'protocal/svg.js'
)
,
]
,
baseURL
=
'src/'
;
baseURL
=
'src/'
,
doc
=
document
;
for
(
var
i
=
0
,
pi
;
pi
=
paths
[
i
++
];
)
{
while
(
paths
.
length
)
{
doc
ument
.
write
(
'<script type="text/javascript" src="'
+
baseURL
+
pi
+
'"></script>'
);
doc
.
write
(
'<script type="text/javascript" src="'
+
baseURL
+
paths
.
shift
()
+
'"></script>'
);
}
}
})();
})();
\ No newline at end of file
src/adapter/color.js
0 → 100644
View file @
ab951fb2
KM
.
registerToolbarUI
(
'forecolor'
,
function
(
name
)
{
function
getCurrentColor
()
{
return
$colorLabel
.
css
(
'background-color'
);
}
var
me
=
this
,
$colorPickerWidget
=
null
,
$colorLabel
=
null
,
$btn
=
null
;
this
.
on
(
'interactchange'
,
function
()
{
var
state
=
this
.
queryCommandState
(
name
);
$btn
.
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
);
});
$btn
=
$
.
kmuicolorsplitbutton
({
icon
:
name
,
caret
:
true
,
name
:
name
,
title
:
this
.
getLang
(
'tooltips'
)[
name
]
||
''
,
click
:
function
()
{
var
color
=
kity
.
Color
.
parse
(
getCurrentColor
()).
toHEX
();
if
(
color
!=
'#000000'
)
{
me
.
execCommand
(
name
,
color
);
}
}
});
$colorLabel
=
$btn
.
kmui
().
colorLabel
();
$colorPickerWidget
=
$
.
kmuicolorpicker
({
name
:
name
,
lang_clearColor
:
me
.
getLang
(
'popupcolor'
)[
'clearColor'
]
||
''
,
lang_themeColor
:
me
.
getLang
(
'popupcolor'
)[
'themeColor'
]
||
''
,
lang_standardColor
:
me
.
getLang
(
'popupcolor'
)[
'standardColor'
]
||
''
}).
on
(
'pickcolor'
,
function
(
evt
,
color
)
{
window
.
setTimeout
(
function
()
{
$colorLabel
.
css
(
"backgroundColor"
,
color
);
me
.
execCommand
(
name
,
color
);
},
0
);
}).
on
(
'show'
,
function
()
{
KM
.
setActiveWidget
(
$colorPickerWidget
.
kmui
().
root
());
}).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
$btn
.
kmui
().
on
(
'arrowclick'
,
function
()
{
if
(
!
$colorPickerWidget
.
parent
().
length
)
{
me
.
$container
.
find
(
'.kmui-dialog-container'
).
append
(
$colorPickerWidget
);
}
$colorPickerWidget
.
kmui
().
show
(
$btn
,
{
caretDir
:
"down"
,
offsetTop
:
-
5
,
offsetLeft
:
8
,
caretLeft
:
11
,
caretTop
:
-
8
});
}).
register
(
'click'
,
$btn
,
function
()
{
$colorPickerWidget
.
kmui
().
hide
()
});
return
$btn
;
});
\ No newline at end of file
src/adapter/combobox.js
View file @
ab951fb2
KM
.
registerToolbarUI
(
'fontfamily fontsize'
,
function
(
name
)
{
KM
.
registerToolbarUI
(
'fontfamily fontsize'
,
function
(
name
)
{
var
me
=
this
,
var
me
=
this
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
label
=
me
.
getLang
(
'tooltips.'
+
name
),
options
=
{
options
=
{
label
:
label
,
label
:
label
,
title
:
label
,
title
:
label
,
comboboxName
:
name
,
comboboxName
:
name
,
items
:
me
.
getOptions
(
name
)
||
[],
items
:
me
.
getOptions
(
name
)
||
[],
itemStyles
:
[],
itemStyles
:
[],
value
:
[],
value
:
[],
autowidthitem
:
[]
autowidthitem
:
[]
...
@@ -14,65 +14,65 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
...
@@ -14,65 +14,65 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
$combox
=
null
,
$combox
=
null
,
comboboxWidget
=
null
;
comboboxWidget
=
null
;
if
(
options
.
items
.
length
==
0
)
{
if
(
options
.
items
.
length
==
0
)
{
return
null
;
return
null
;
}
}
switch
(
name
)
{
switch
(
name
)
{
case
'fontfamily'
:
case
'fontfamily'
:
options
=
transForFontfamily
(
options
);
options
=
transForFontfamily
(
options
);
break
;
break
;
case
'fontsize'
:
case
'fontsize'
:
options
=
transForFontsize
(
options
);
options
=
transForFontsize
(
options
);
break
;
break
;
}
}
//实例化
//实例化
$combox
=
$
.
kmuibuttoncombobox
(
options
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
$combox
=
$
.
kmuibuttoncombobox
(
options
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
comboboxWidget
=
$combox
.
kmui
();
comboboxWidget
=
$combox
.
kmui
();
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
comboboxWidget
.
on
(
'comboboxselect'
,
function
(
evt
,
res
)
{
me
.
execCommand
(
name
,
res
.
value
);
me
.
execCommand
(
name
,
res
.
value
);
}
).
on
(
"beforeshow"
,
function
()
{
}
).
on
(
"beforeshow"
,
function
()
{
if
(
$combox
.
parent
().
length
===
0
)
{
if
(
$combox
.
parent
().
length
===
0
)
{
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
)
);
$combox
.
appendTo
(
me
.
$container
.
find
(
'.kmui-dialog-container'
)
);
}
}
}
);
});
//状态反射
//状态反射
this
.
on
(
'interactchange'
,
function
()
{
this
.
on
(
'interactchange'
,
function
()
{
var
state
=
this
.
queryCommandState
(
name
),
var
state
=
this
.
queryCommandState
(
name
),
value
=
this
.
queryCommandValue
(
name
);
value
=
this
.
queryCommandValue
(
name
);
//设置按钮状态
//设置按钮状态
comboboxWidget
.
button
().
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
);
comboboxWidget
.
button
().
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
);
if
(
value
)
{
if
(
value
)
{
//设置label
//设置label
value
=
value
.
replace
(
/
[
'"
]
/g
,
''
).
toLowerCase
().
split
(
/
[
'|"
]?\s
*,
\s
*
[\1]?
/
);
value
=
value
.
replace
(
/
[
'"
]
/g
,
''
).
toLowerCase
().
split
(
/
[
'|"
]?\s
*,
\s
*
[\1]?
/
);
comboboxWidget
.
selectItemByLabel
(
value
);
comboboxWidget
.
selectItemByLabel
(
value
);
}
}
}
);
});
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
//字体参数转换
//字体参数转换
function
transForFontfamily
(
options
)
{
function
transForFontfamily
(
options
)
{
var
temp
=
null
,
var
temp
=
null
,
tempItems
=
[];
tempItems
=
[];
for
(
var
i
=
0
,
len
=
options
.
items
.
length
;
i
<
len
;
i
++
)
{
for
(
var
i
=
0
,
len
=
options
.
items
.
length
;
i
<
len
;
i
++
)
{
temp
=
options
.
items
[
i
].
val
;
temp
=
options
.
items
[
i
].
val
;
tempItems
.
push
(
temp
.
split
(
/
\s
*,
\s
*/
)[
0
]
);
tempItems
.
push
(
temp
.
split
(
/
\s
*,
\s
*/
)[
0
]
);
options
.
itemStyles
.
push
(
'font-family: '
+
temp
);
options
.
itemStyles
.
push
(
'font-family: '
+
temp
);
options
.
value
.
push
(
temp
);
options
.
value
.
push
(
temp
);
options
.
autowidthitem
.
push
(
$
.
wordCountAdaptive
(
tempItems
[
i
]
)
);
options
.
autowidthitem
.
push
(
$
.
wordCountAdaptive
(
tempItems
[
i
])
);
}
}
...
@@ -83,7 +83,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
...
@@ -83,7 +83,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
}
}
//字体大小参数转换
//字体大小参数转换
function
transForFontsize
(
options
)
{
function
transForFontsize
(
options
)
{
var
temp
=
null
,
var
temp
=
null
,
tempItems
=
[];
tempItems
=
[];
...
@@ -91,11 +91,11 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
...
@@ -91,11 +91,11 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
options
.
itemStyles
=
[];
options
.
itemStyles
=
[];
options
.
value
=
[];
options
.
value
=
[];
for
(
var
i
=
0
,
len
=
options
.
items
.
length
;
i
<
len
;
i
++
)
{
for
(
var
i
=
0
,
len
=
options
.
items
.
length
;
i
<
len
;
i
++
)
{
temp
=
options
.
items
[
i
];
temp
=
options
.
items
[
i
];
tempItems
.
push
(
temp
);
tempItems
.
push
(
temp
);
options
.
itemStyles
.
push
(
'font-size: '
+
temp
+
'px; height:'
+
(
temp
+
2
)
+
'px; line-height: '
+
(
temp
+
2
)
+
'px'
);
options
.
itemStyles
.
push
(
'font-size: '
+
temp
+
'px; height:'
+
(
temp
+
2
)
+
'px; line-height: '
+
(
temp
+
2
)
+
'px'
);
}
}
options
.
value
=
options
.
items
;
options
.
value
=
options
.
items
;
...
@@ -106,68 +106,4 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
...
@@ -106,68 +106,4 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
}
}
}
);
});
\ No newline at end of file
KM
.
registerToolbarUI
(
'forecolor'
,
function
(
name
)
{
function
getCurrentColor
()
{
return
$colorLabel
.
css
(
'background-color'
);
}
var
me
=
this
,
$colorPickerWidget
=
null
,
$colorLabel
=
null
,
$btn
=
null
;
this
.
on
(
'interactchange'
,
function
()
{
var
state
=
this
.
queryCommandState
(
name
);
$btn
.
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
);
}
);
$btn
=
$
.
kmuicolorsplitbutton
(
{
icon
:
name
,
caret
:
true
,
name
:
name
,
title
:
this
.
getLang
(
'tooltips'
)[
name
]
||
''
,
click
:
function
()
{
var
color
=
kity
.
Color
.
parse
(
getCurrentColor
()).
toHEX
();
if
(
color
!=
'#000000'
){
me
.
execCommand
(
name
,
color
);
}
}
}
);
$colorLabel
=
$btn
.
kmui
().
colorLabel
();
$colorPickerWidget
=
$
.
kmuicolorpicker
(
{
name
:
name
,
lang_clearColor
:
me
.
getLang
(
'popupcolor'
)[
'clearColor'
]
||
''
,
lang_themeColor
:
me
.
getLang
(
'popupcolor'
)[
'themeColor'
]
||
''
,
lang_standardColor
:
me
.
getLang
(
'popupcolor'
)[
'standardColor'
]
||
''
}
).
on
(
'pickcolor'
,
function
(
evt
,
color
)
{
window
.
setTimeout
(
function
()
{
$colorLabel
.
css
(
"backgroundColor"
,
color
);
me
.
execCommand
(
name
,
color
);
},
0
);
}
).
on
(
'show'
,
function
()
{
KM
.
setActiveWidget
(
$colorPickerWidget
.
kmui
().
root
()
);
}
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
$btn
.
kmui
().
on
(
'arrowclick'
,
function
()
{
if
(
!
$colorPickerWidget
.
parent
().
length
)
{
me
.
$container
.
find
(
'.kmui-dialog-container'
).
append
(
$colorPickerWidget
);
}
$colorPickerWidget
.
kmui
().
show
(
$btn
,
{
caretDir
:
"down"
,
offsetTop
:
-
5
,
offsetLeft
:
8
,
caretLeft
:
11
,
caretTop
:
-
8
}
);
}
).
register
(
'click'
,
$btn
,
function
()
{
$colorPickerWidget
.
kmui
().
hide
()
}
);
return
$btn
;
}
);
\ No newline at end of file
src/module/font.js
View file @
ab951fb2
...
@@ -54,6 +54,33 @@ KityMinder.registerModule( "fontmodule", function () {
...
@@ -54,6 +54,33 @@ KityMinder.registerModule( "fontmodule", function () {
},
},
queryState
:
function
(
km
){
queryState
:
function
(
km
){
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
},
queryValue
:
function
(
km
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
return
km
.
getSelectedNodes
()[
0
].
getData
(
'fontcolor'
);
}
return
'mixed'
;
}
}
),
"backgroundcolor"
:
kity
.
createClass
(
"backgroudcolorCommand"
,
{
base
:
Command
,
execute
:
function
(
km
,
color
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'backgroundcolor'
,
color
);
n
.
getLayout
().
bgRect
.
fill
(
color
);
}
);
},
queryState
:
function
(
km
){
return
km
.
getSelectedNodes
().
length
==
0
?
-
1
:
0
},
queryValue
:
function
(
km
)
{
if
(
km
.
getSelectedNodes
().
length
==
1
)
{
return
km
.
getSelectedNodes
()[
0
].
getData
(
'backgroundcolor'
);
}
return
'mixed'
;
}
}
}
),
}
),
...
@@ -98,6 +125,9 @@ KityMinder.registerModule( "fontmodule", function () {
...
@@ -98,6 +125,9 @@ KityMinder.registerModule( "fontmodule", function () {
if
(
val
=
e
.
node
.
getData
(
'fontcolor'
)
)
{
if
(
val
=
e
.
node
.
getData
(
'fontcolor'
)
)
{
e
.
node
.
getTextShape
().
fill
(
val
);
e
.
node
.
getTextShape
().
fill
(
val
);
}
}
if
(
val
=
e
.
node
.
getData
(
'backgroundcolor'
)
)
{
e
.
node
.
getLayout
().
bgRect
.
fill
(
val
);
}
if
(
val
=
e
.
node
.
getData
(
'fontsize'
)
)
{
if
(
val
=
e
.
node
.
getData
(
'fontsize'
)
)
{
e
.
node
.
getTextShape
().
setSize
(
val
);
e
.
node
.
getTextShape
().
setSize
(
val
);
}
}
...
...
src/module/layout.default.js
View file @
ab951fb2
...
@@ -731,7 +731,7 @@ KityMinder.registerModule("LayoutDefault", function () {
...
@@ -731,7 +731,7 @@ KityMinder.registerModule("LayoutDefault", function () {
if
(
highlight
)
{
if
(
highlight
)
{
Layout
.
bgRect
.
fill
(
nodeStyle
.
highlight
);
Layout
.
bgRect
.
fill
(
nodeStyle
.
highlight
);
}
else
{
}
else
{
Layout
.
bgRect
.
fill
(
nodeStyle
.
fill
);
Layout
.
bgRect
.
fill
(
node
.
getData
(
'backgroundcolor'
)
||
node
Style
.
fill
);
}
}
break
;
break
;
case
"sub"
:
case
"sub"
:
...
...
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