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
6c6eede3
Commit
6c6eede3
authored
May 06, 2014
by
campaign
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加hyperlink
parent
72fcba5d
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
206 additions
and
30 deletions
+206
-30
hyperlink.js
dialogs/hyperlink/hyperlink.js
+32
-0
import.js
import.js
+84
-9
kityminder.config.js
kityminder.config.js
+1
-1
button.js
src/adapter/button.js
+1
-1
hyperlink.js
src/adapter/hyperlink.js
+46
-0
editor.js
src/module/editor.js
+4
-2
hyperlink.js
src/module/hyperlink.js
+31
-17
buttonicon.css
themes/default/css/buttonicon.css
+7
-0
No files found.
dialogs/hyperlink/hyperlink.js
0 → 100644
View file @
6c6eede3
(
function
()
{
//todo 这里先写死成中文
var
content
=
'<div class="hyperlink-content" style="padding:20px;width:360px;">'
;
content
+=
'<p><label>输入链接: <input id="hyperlink_href" style="width:90%;" /></label></p>'
;
content
+=
'<p style="text-align:right"><button id="hyperlink_insert">插入</button></p>'
;
content
+=
'</div>'
;
KM
.
registerWidget
(
'hyperlink'
,
{
tpl
:
content
,
initContent
:
function
(
km
)
{
var
lang
=
km
.
getLang
(
'dialogs.hyperlink'
),
html
;
if
(
lang
)
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
lang
);
}
this
.
root
().
html
(
html
);
},
initEvent
:
function
(
km
,
$w
)
{
$w
.
find
(
'#hyperlink_insert'
).
on
(
'click'
,
function
(){
km
.
execCommand
(
'hyperlink'
,
$w
.
find
(
'#hyperlink_href'
).
val
());
$w
.
kmui
().
hide
();
});
var
url
=
km
.
queryCommandValue
(
'hyperlink'
);
$w
.
find
(
'#hyperlink_href'
).
val
(
url
||
''
)
},
width
:
400
}
);
}
)();
\ No newline at end of file
import.js
View file @
6c6eede3
/**
* 开发版本的文件导入
*/
(
function
()
{
(
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/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'
,
'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/view.js'
,
'adapter/tooltips.js'
,
'adapter/layout.js'
,
'adapter/node.js'
,
'adapter/contextmenu.js'
,
'adapter/dialog.js'
,
'protocal/xmind.js'
,
'protocal/freemind.js'
,
'protocal/mindmanager.js'
,
'protocal/plain.js'
,
'protocal/json.js'
,
'protocal/png.js'
,
'protocal/svg.js'
'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/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'
,
'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/view.js'
,
'adapter/tooltips.js'
,
'adapter/layout.js'
,
'adapter/node.js'
,
'adapter/contextmenu.js'
,
'adapter/dialog.js'
,
'adapter/hyperlink.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
++
];
)
{
document
.
write
(
'<script type="text/javascript" src="'
+
baseURL
+
pi
+
'"></script>'
);
for
(
var
i
=
0
,
pi
;
pi
=
paths
[
i
++
];
)
{
document
.
write
(
'<script type="text/javascript" src="'
+
baseURL
+
pi
+
'"></script>'
);
}
}
)();
\ No newline at end of file
})();
kityminder.config.js
View file @
6c6eede3
...
...
@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL'
:
getKMBasePath
(),
//定义工具栏
toolbars
:
[
'hand zoom-in zoom-out expand contract | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | preference | help'
'hand zoom-in zoom-out expand contract | undo redo | bold italic | fontfamily fontsize forecolor | saveto |
hyperlink unhyperlink |
markers | node | preference | help'
]
//只读模式,默认是false
//readOnly: true
...
...
src/adapter/button.js
View file @
6c6eede3
KM
.
registerToolbarUI
(
'bold italic redo undo'
,
KM
.
registerToolbarUI
(
'bold italic redo undo
unhyperlink
'
,
function
(
name
)
{
var
me
=
this
;
var
$btn
=
$
.
kmuibutton
(
{
...
...
src/adapter/hyperlink.js
0 → 100644
View file @
6c6eede3
KM
.
registerToolbarUI
(
'hyperlink'
,
function
(
name
)
{
var
me
=
this
,
currentRange
,
$dialog
,
opt
=
{
title
:
this
.
getLang
(
'tooltips'
)[
name
]
||
''
,
url
:
me
.
getOptions
(
'KITYMINDER_HOME_URL'
)
+
'dialogs/'
+
name
+
'/'
+
name
+
'.js'
};
var
$btn
=
$
.
kmuibutton
(
{
icon
:
name
,
title
:
this
.
getLang
(
'tooltips'
)[
name
]
||
''
}
);
//加载模版数据
utils
.
loadFile
(
document
,
{
src
:
opt
.
url
,
tag
:
"script"
,
type
:
"text/javascript"
,
defer
:
"defer"
},
function
()
{
$dialog
=
$
.
kmuimodal
(
opt
);
$dialog
.
attr
(
'id'
,
'kmui-dialog-'
+
name
).
addClass
(
'kmui-dialog-'
+
name
)
.
find
(
'.kmui-modal-body'
).
addClass
(
'kmui-dialog-'
+
name
+
'-body'
);
$dialog
.
kmui
().
on
(
'beforeshow'
,
function
()
{
var
$root
=
this
.
root
(),
win
=
null
,
offset
=
null
;
if
(
!
$root
.
parent
()[
0
]
)
{
me
.
$container
.
find
(
'.kmui-dialog-container'
).
append
(
$root
);
}
KM
.
setWidgetBody
(
name
,
$dialog
,
me
);
}
).
attachTo
(
$btn
);
}
);
me
.
on
(
'interactchange'
,
function
()
{
var
state
=
this
.
queryCommandState
(
name
);
$btn
.
kmui
().
disabled
(
state
==
-
1
).
active
(
state
==
1
)
}
);
return
$btn
;
}
);
src/module/editor.js
View file @
6c6eede3
...
...
@@ -82,7 +82,9 @@ KityMinder.registerModule( "TextEditModule", function () {
if
(
node
){
if
(
this
.
isSingleSelect
()
&&
node
.
isSelected
())
{
var
keyCode
=
e
.
originEvent
.
keyCode
;
if
(
!
keymap
.
notContentInput
[
keyCode
]){
if
(
!
keymap
.
notContentInput
[
keyCode
]
&&
range
.
nativeSel
.
rangeCount
!=
0
){
var
nativeRange
=
range
.
nativeSel
.
getRangeAt
(
0
);
if
(
nativeRange
&&
(
nativeRange
.
startContainer
===
receiver
.
container
||
receiver
.
container
.
contains
(
nativeRange
.
startContainer
)))
km
.
setStatus
(
'textedit'
)
}
}
...
...
src/module/hyperlink.js
View file @
6c6eede3
...
...
@@ -2,24 +2,18 @@ KityMinder.registerModule( "hyperlink", function () {
return
{
"commands"
:
{
"
create
link"
:
kity
.
createClass
(
"hyperlink"
,
{
"
hyper
link"
:
kity
.
createClass
(
"hyperlink"
,
{
base
:
Command
,
execute
:
function
(
url
)
{
execute
:
function
(
km
,
url
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
this
.
queryState
(
'hyperlink'
)
==
1
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
);
}
)
}
else
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
,
url
);
km
.
updateLayout
(
n
)
}
)
}
},
queryState
:
function
()
{
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
(),
result
=
0
;
if
(
nodes
.
length
==
0
)
{
...
...
@@ -32,19 +26,39 @@ KityMinder.registerModule( "hyperlink", function () {
}
}
);
return
result
;
},
queryValue
:
function
(
km
)
{
if
(
km
.
queryCommandState
(
'hyperlink'
)
==
1
)
{
var
node
=
km
.
getSelectedNode
();
return
node
.
getData
(
'hyperlink'
);
}
}
}
),
"unhyperlink"
:
kity
.
createClass
(
"hyperlink"
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'hyperlink'
);
km
.
updateLayout
(
n
)
}
)
}
}
)
},
"events"
:
{
"RenderNodeRight"
:
function
(
e
)
{
var
node
=
e
.
node
,
url
;
if
(
url
=
node
.
getData
(
'h'
)){
if
(
url
=
node
.
getData
(
'h
yperlink
'
)){
var
link
=
new
kity
.
HyperLink
(
url
);
var
rect
=
new
kity
.
Rect
();
var
box
=
node
.
getContRc
().
getBoundaryBox
();
rect
.
setWidth
(
10
).
setHeight
(
10
).
fill
(
'#ccc'
).
setPosition
(
box
.
x
+
box
.
width
+
2
,
rect
.
getHeight
()
/-
2
);
link
.
appendChild
(
rect
);
node
.
getContRc
().
appendChild
(
link
);
var
style
=
this
.
getCurrentLayoutStyle
()[
node
.
getType
()
];
rect
.
setWidth
(
10
).
setHeight
(
10
).
fill
(
'#ccc'
).
setPosition
(
box
.
x
+
box
.
width
+
style
.
spaceLeft
,
rect
.
getHeight
()
/-
2
);
link
.
addShape
(
rect
);
link
.
setTarget
(
'_blank'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
node
.
getContRc
().
addShape
(
link
);
}
}
...
...
themes/default/css/buttonicon.css
View file @
6c6eede3
...
...
@@ -41,3 +41,10 @@
.kmui-btn-toolbar
.kmui-btn
.kmui-icon-contract
{
background
:
url(../images/contract.png)
no-repeat
2px
2px
;
}
.kmui-btn-toolbar
.kmui-btn
.kmui-icon-hyperlink
{
background
:
url(../images/contract.png)
no-repeat
2px
2px
;
}
.kmui-btn-toolbar
.kmui-btn
.kmui-icon-unhyperlink
{
background
:
url(../images/contract.png)
no-repeat
2px
2px
;
}
\ 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