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
Hide 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
(){
var
paths
=
new
Array
(
'core/kityminder.js'
,
'core/utils.js'
,
'core/command.js'
,
'core/node.js'
,
'core/module.js'
,
'core/event.js'
,
'core/minder.js'
,
'core/minder.data.js'
,
'core/minder.event.js'
,
'core/minder.module.js'
,
'core/minder.command.js'
,
'core/minder.node.js'
,
'core/keymap.js'
,
'core/minder.lang.js'
,
'core/minder.defaultoptions.js'
,
'core/minder.preference.js'
,
'core/browser.js'
,
'module/geometry.js'
,
'module/history.js'
,
'module/icon.js'
,
'module/image.js'
,
'module/resource.js'
,
'module/layout.js'
,
'module/layout.default.js'
,
'module/layout.bottom.js'
,
'core/minder.select.js'
,
'module/view.js'
,
'module/dragtree.js'
,
'module/dropfile.js'
,
'module/keyboard.js'
,
'module/select.js'
,
'module/history.js'
,
'module/editor.js'
,
'module/editor.range.js'
,
'module/editor.receiver.js'
,
'module/editor.selection.js'
,
'module/basestyle.js'
,
'module/font.js'
,
'module/zoom.js'
,
'module/nodetext.js'
,
'module/hyperlink.js'
,
'module/expand.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/widget.js'
,
'ui/button.js'
,
'ui/toolbar.js'
,
'ui/menu.js'
,
'ui/dropmenu.js'
,
'ui/splitbutton.js'
,
'ui/colorsplitbutton.js'
,
'ui/popup.js'
,
'ui/scale.js'
,
'ui/colorpicker.js'
,
'ui/combobox.js'
,
'ui/buttoncombobox.js'
,
'ui/modal.js'
,
'ui/tooltip.js'
,
'ui/tab.js'
,
'ui/separator.js'
,
'ui/scale.js'
,
'adapter/utils.js'
,
'adapter/adapter.js'
,
'adapter/button.js'
,
'adapter/combobox.js'
,
'adapter/saveto.js'
,
'adapter/tooltips.js'
,
'adapter/layout.js'
,
'adapter/node.js'
,
'adapter/contextmenu.js'
,
'adapter/dialog.js'
,
'adapter/hyperlink.js'
,
'adapter/image.js'
,
'adapter/zoom.js'
,
'protocal/xmind.js'
,
'protocal/freemind.js'
,
'protocal/mindmanager.js'
,
'protocal/plain.js'
,
'protocal/json.js'
,
'protocal/png.js'
,
'protocal/svg.js'
)
,
baseURL
=
'src/'
;
for
(
var
i
=
0
,
pi
;
pi
=
paths
[
i
++
];
)
{
doc
ument
.
write
(
'<script type="text/javascript" src="'
+
baseURL
+
pi
+
'"></script>'
);
(
function
()
{
var
paths
=
[
'core/kityminder.js'
,
'core/utils.js'
,
'core/command.js'
,
'core/node.js'
,
'core/module.js'
,
'core/event.js'
,
'core/minder.js'
,
'core/minder.data.js'
,
'core/minder.event.js'
,
'core/minder.module.js'
,
'core/minder.command.js'
,
'core/minder.node.js'
,
'core/keymap.js'
,
'core/minder.lang.js'
,
'core/minder.defaultoptions.js'
,
'core/minder.preference.js'
,
'core/browser.js'
,
'module/geometry.js'
,
'module/history.js'
,
'module/icon.js'
,
'module/image.js'
,
'module/resource.js'
,
'module/layout.js'
,
'module/layout.default.js'
,
'module/layout.bottom.js'
,
'core/minder.select.js'
,
'module/view.js'
,
'module/dragtree.js'
,
'module/dropfile.js'
,
'module/keyboard.js'
,
'module/select.js'
,
'module/history.js'
,
'module/editor.js'
,
'module/editor.range.js'
,
'module/editor.receiver.js'
,
'module/editor.selection.js'
,
'module/basestyle.js'
,
'module/font.js'
,
'module/zoom.js'
,
'module/nodetext.js'
,
'module/hyperlink.js'
,
'module/expand.js'
,
'ui/jquery-ui-1.10.4.custom.min.js'
,
'ui/widget.js'
,
'ui/button.js'
,
'ui/toolbar.js'
,
'ui/menu.js'
,
'ui/dropmenu.js'
,
'ui/splitbutton.js'
,
'ui/colorsplitbutton.js'
,
'ui/popup.js'
,
'ui/scale.js'
,
'ui/colorpicker.js'
,
'ui/combobox.js'
,
'ui/buttoncombobox.js'
,
'ui/modal.js'
,
'ui/tooltip.js'
,
'ui/tab.js'
,
'ui/separator.js'
,
'ui/scale.js'
,
'adapter/utils.js'
,
'adapter/adapter.js'
,
'adapter/button.js'
,
'adapter/combobox.js'
,
'adapter/color.js'
,
'adapter/saveto.js'
,
'adapter/tooltips.js'
,
'adapter/layout.js'
,
'adapter/node.js'
,
'adapter/contextmenu.js'
,
'adapter/dialog.js'
,
'adapter/hyperlink.js'
,
'adapter/image.js'
,
'adapter/zoom.js'
,
'protocal/xmind.js'
,
'protocal/freemind.js'
,
'protocal/mindmanager.js'
,
'protocal/plain.js'
,
'protocal/json.js'
,
'protocal/png.js'
,
'protocal/svg.js'
]
,
baseURL
=
'src/'
,
doc
=
document
;
while
(
paths
.
length
)
{
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
,
label
=
me
.
getLang
(
'tooltips.'
+
name
),
label
=
me
.
getLang
(
'tooltips.'
+
name
),
options
=
{
label
:
label
,
title
:
label
,
comboboxName
:
name
,
items
:
me
.
getOptions
(
name
)
||
[],
items
:
me
.
getOptions
(
name
)
||
[],
itemStyles
:
[],
value
:
[],
autowidthitem
:
[]
...
...
@@ -14,65 +14,65 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
$combox
=
null
,
comboboxWidget
=
null
;
if
(
options
.
items
.
length
==
0
)
{
if
(
options
.
items
.
length
==
0
)
{
return
null
;
}
switch
(
name
)
{
switch
(
name
)
{
case
'fontfamily'
:
options
=
transForFontfamily
(
options
);
break
;
case
'fontfamily'
:
options
=
transForFontfamily
(
options
);
break
;
case
'fontsize'
:
options
=
transForFontsize
(
options
);
break
;
case
'fontsize'
:
options
=
transForFontsize
(
options
);
break
;
}
//实例化
$combox
=
$
.
kmuibuttoncombobox
(
options
).
css
(
'zIndex'
,
me
.
getOptions
(
'zIndex'
)
+
1
);
$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'
)
);
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
);
this
.
on
(
'interactchange'
,
function
()
{
var
state
=
this
.
queryCommandState
(
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
value
=
value
.
replace
(
/
[
'"
]
/g
,
''
).
toLowerCase
().
split
(
/
[
'|"
]?\s
*,
\s
*
[\1]?
/
);
comboboxWidget
.
selectItemByLabel
(
value
);
value
=
value
.
replace
(
/
[
'"
]
/g
,
''
).
toLowerCase
().
split
(
/
[
'|"
]?\s
*,
\s
*
[\1]?
/
);
comboboxWidget
.
selectItemByLabel
(
value
);
}
}
);
});
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
return
comboboxWidget
.
button
().
addClass
(
'kmui-combobox'
);
//字体参数转换
function
transForFontfamily
(
options
)
{
function
transForFontfamily
(
options
)
{
var
temp
=
null
,
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
;
tempItems
.
push
(
temp
.
split
(
/
\s
*,
\s
*/
)[
0
]
);
options
.
itemStyles
.
push
(
'font-family: '
+
temp
);
options
.
value
.
push
(
temp
);
options
.
autowidthitem
.
push
(
$
.
wordCountAdaptive
(
tempItems
[
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
])
);
}
...
...
@@ -83,7 +83,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
}
//字体大小参数转换
function
transForFontsize
(
options
)
{
function
transForFontsize
(
options
)
{
var
temp
=
null
,
tempItems
=
[];
...
...
@@ -91,11 +91,11 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
options
.
itemStyles
=
[];
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
];
tempItems
.
push
(
temp
);
options
.
itemStyles
.
push
(
'font-size: '
+
temp
+
'px; height:'
+
(
temp
+
2
)
+
'px; line-height: '
+
(
temp
+
2
)
+
'px'
);
temp
=
options
.
items
[
i
];
tempItems
.
push
(
temp
);
options
.
itemStyles
.
push
(
'font-size: '
+
temp
+
'px; height:'
+
(
temp
+
2
)
+
'px; line-height: '
+
(
temp
+
2
)
+
'px'
);
}
options
.
value
=
options
.
items
;
...
...
@@ -106,68 +106,4 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
}
}
);
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
});
\ No newline at end of file
src/module/font.js
View file @
ab951fb2
...
...
@@ -54,6 +54,33 @@ KityMinder.registerModule( "fontmodule", function () {
},
queryState
:
function
(
km
){
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 () {
if
(
val
=
e
.
node
.
getData
(
'fontcolor'
)
)
{
e
.
node
.
getTextShape
().
fill
(
val
);
}
if
(
val
=
e
.
node
.
getData
(
'backgroundcolor'
)
)
{
e
.
node
.
getLayout
().
bgRect
.
fill
(
val
);
}
if
(
val
=
e
.
node
.
getData
(
'fontsize'
)
)
{
e
.
node
.
getTextShape
().
setSize
(
val
);
}
...
...
src/module/layout.default.js
View file @
ab951fb2
...
...
@@ -731,7 +731,7 @@ KityMinder.registerModule("LayoutDefault", function () {
if
(
highlight
)
{
Layout
.
bgRect
.
fill
(
nodeStyle
.
highlight
);
}
else
{
Layout
.
bgRect
.
fill
(
nodeStyle
.
fill
);
Layout
.
bgRect
.
fill
(
node
.
getData
(
'backgroundcolor'
)
||
node
Style
.
fill
);
}
break
;
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