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
85d41ead
Commit
85d41ead
authored
Jun 18, 2014
by
techird
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix select color issue
parent
1be05c9b
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
139 deletions
+133
-139
image.js
dialogs/image/image.js
+25
-25
kity
kity
+1
-1
render.js
src/core/render.js
+2
-18
editor.js
src/module/editor.js
+1
-1
font.js
src/module/font.js
+4
-1
image.js
src/module/image.js
+99
-93
default.js
src/theme/default.js
+1
-0
No files found.
dialogs/image/image.js
View file @
85d41ead
(
function
(
utils
)
{
(
function
(
utils
)
{
var
content
=
'<div class="image-content" style="padding:20px;width:360px;">'
;
var
content
=
'<div class="image-content" style="padding:20px;width:360px;">'
;
content
+=
'<style>'
;
content
+=
'<style>'
;
content
+=
'.kmui-dialog-<%= container %> input{'
;
content
+=
'.kmui-dialog-<%= container %> input{'
;
...
@@ -36,39 +36,39 @@
...
@@ -36,39 +36,39 @@
KM
.
registerWidget
(
'image'
,
{
KM
.
registerWidget
(
'image'
,
{
tpl
:
content
,
tpl
:
content
,
initContent
:
function
(
km
)
{
initContent
:
function
(
km
)
{
var
lang
=
km
.
getLang
(
'dialogs.image'
),
var
lang
=
km
.
getLang
(
'dialogs.image'
),
html
;
html
;
if
(
lang
)
{
if
(
lang
)
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
utils
.
extend
(
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
utils
.
extend
(
{
'container'
:
'image'
'container'
:
'image'
},
lang
)
);
},
lang
)
);
}
}
this
.
root
().
html
(
html
);
this
.
root
().
html
(
html
);
},
},
initEvent
:
function
(
km
,
$w
)
{
initEvent
:
function
(
km
,
$w
)
{
$w
.
find
(
'#image_insert'
).
on
(
'click'
,
function
()
{
$w
.
find
(
'#image_insert'
).
on
(
'click'
,
function
()
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
$w
.
kmui
().
hide
();
$w
.
kmui
().
hide
();
}
);
});
$w
.
find
(
'#image_href'
).
on
(
'keydown'
,
function
(
e
)
{
$w
.
find
(
'#image_href'
).
on
(
'keydown'
,
function
(
e
)
{
if
(
e
.
keyCode
===
13
)
{
if
(
e
.
keyCode
===
13
)
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
$w
.
kmui
().
hide
();
$w
.
kmui
().
hide
();
}
}
}
).
on
(
'input'
,
function
()
{
}).
on
(
'input'
,
function
()
{
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
$w
.
find
(
'#image_href'
).
val
());
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
$w
.
find
(
'#image_href'
).
val
());
});
});
var
url
=
km
.
queryCommandValue
(
'image'
);
var
url
=
km
.
queryCommandValue
(
'image'
);
var
$input
=
$w
.
find
(
'#image_href'
);
var
$input
=
$w
.
find
(
'#image_href'
);
$input
.
val
(
url
||
'http://'
);
$input
.
val
(
url
||
'http://'
);
if
(
url
)
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
url
);
if
(
url
)
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
url
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
$input
.
focus
();
$input
.
focus
();
}
);
});
},
},
width
:
400
width
:
400
}
);
});
}
)(
KM
.
Utils
);
})(
KM
.
Utils
);
\ No newline at end of file
\ No newline at end of file
kity
@
9e420efd
Subproject commit
0d9f7dcd784436d13e45b4570ce690e186f3c686
Subproject commit
9e420efd89ba672f5389e21069eb0009e52ad7b1
src/core/render.js
View file @
85d41ead
...
@@ -24,12 +24,6 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
...
@@ -24,12 +24,6 @@ var Renderer = KityMinder.Renderer = kity.createClass('Renderer', {
}
}
});
});
kity
.
extendClass
(
MinderNode
,
{
getContentBox
:
function
()
{
return
this
.
_contentBox
;
}
});
kity
.
extendClass
(
Minder
,
{
kity
.
extendClass
(
Minder
,
{
_createRendererForNode
:
function
(
node
)
{
_createRendererForNode
:
function
(
node
)
{
...
@@ -122,17 +116,7 @@ kity.extendClass(MinderNode, {
...
@@ -122,17 +116,7 @@ kity.extendClass(MinderNode, {
return
null
;
return
null
;
},
},
getContentBox
:
function
()
{
getContentBox
:
function
()
{
return
this
.
parent
&&
this
.
parent
.
isCollapsed
()
?
{
//if (!this._contentBox) this.render();
x
:
0
,
return
this
.
parent
&&
this
.
parent
.
isCollapsed
()
?
new
kity
.
Box
()
:
this
.
_contentBox
;
y
:
0
,
width
:
0
,
height
:
0
,
left
:
0
,
top
:
0
,
bottom
:
0
,
right
:
0
,
cx
:
0
,
cy
:
0
}
:
this
.
_contentBox
;
}
}
});
});
\ No newline at end of file
src/module/editor.js
View file @
85d41ead
...
@@ -179,7 +179,7 @@ KityMinder.registerModule('TextEditModule', function() {
...
@@ -179,7 +179,7 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
browser
.
ipad
)
{
if
(
browser
.
ipad
)
{
receiver
.
container
.
focus
();
receiver
.
container
.
focus
();
}
}
}
else
{
}
else
{
//当选中节点后,输入状态准备
//当选中节点后,输入状态准备
var
node
=
e
.
getTargetNode
();
var
node
=
e
.
getTargetNode
();
if
(
node
)
{
if
(
node
)
{
...
...
src/module/font.js
View file @
85d41ead
...
@@ -4,7 +4,10 @@ KityMinder.registerModule("fontmodule", function() {
...
@@ -4,7 +4,10 @@ KityMinder.registerModule("fontmodule", function() {
}
}
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
)
{
KityMinder
.
TextRenderer
.
registerStyleHook
(
function
(
node
,
text
)
{
text
.
fill
(
getNodeDataOrStyle
(
node
,
'color'
));
var
dataColor
=
node
.
getData
(
'color'
);
var
selectedColor
=
node
.
getStyle
(
'selected-color'
);
var
styleColor
=
node
.
getStyle
(
'color'
);
text
.
fill
(
dataColor
||
(
node
.
isSelected
()
?
selectedColor
:
styleColor
));
text
.
setFont
({
text
.
setFont
({
family
:
getNodeDataOrStyle
(
node
,
'font-family'
),
family
:
getNodeDataOrStyle
(
node
,
'font-family'
),
size
:
getNodeDataOrStyle
(
node
,
'font-size'
)
size
:
getNodeDataOrStyle
(
node
,
'font-size'
)
...
...
src/module/image.js
View file @
85d41ead
KityMinder
.
registerModule
(
"image"
,
function
()
{
KityMinder
.
registerModule
(
'image'
,
function
()
{
function
loadImageSize
(
url
,
callback
)
{
function
loadImageSize
(
url
,
callback
)
{
var
img
=
document
.
createElement
(
'img'
);
var
img
=
document
.
createElement
(
'img'
);
img
.
onload
=
function
()
{
img
.
onload
=
function
()
{
callback
(
img
.
width
,
img
.
height
);
callback
(
img
.
width
,
img
.
height
);
};
};
img
.
onerror
=
function
()
{
img
.
onerror
=
function
()
{
callback
(
null
);
callback
(
null
);
};
};
img
.
src
=
url
;
img
.
src
=
url
;
}
}
function
fitImageSize
(
width
,
height
,
maxWidth
,
maxHeight
)
{
function
fitImageSize
(
width
,
height
,
maxWidth
,
maxHeight
)
{
var
ratio
=
width
/
height
,
var
ratio
=
width
/
height
,
fitRatio
=
maxWidth
/
maxHeight
;
fitRatio
=
maxWidth
/
maxHeight
;
// 宽高比大于最大尺寸的宽高比,以宽度为标准适应
// 宽高比大于最大尺寸的宽高比,以宽度为标准适应
if
(
ratio
>
fitRatio
&&
width
>
maxWidth
)
{
if
(
ratio
>
fitRatio
&&
width
>
maxWidth
)
{
width
=
maxWidth
;
width
=
maxWidth
;
height
=
maxWidth
/
ratio
;
height
=
maxWidth
/
ratio
;
}
else
if
(
height
>
maxHeight
)
{
}
else
if
(
height
>
maxHeight
)
{
height
=
maxHeight
;
height
=
maxHeight
;
width
=
maxHeight
/
ratio
;
width
=
maxHeight
/
ratio
;
}
}
...
@@ -28,104 +28,110 @@ KityMinder.registerModule( "image", function () {
...
@@ -28,104 +28,110 @@ KityMinder.registerModule( "image", function () {
height
:
height
height
:
height
};
};
}
}
return
{
"defaultOptions"
:
{
var
ImageCommand
=
kity
.
createClass
(
'ImageCommand'
,
{
"maxImageWidth"
:
200
,
base
:
Command
,
"maxImageHeight"
:
200
execute
:
function
(
km
,
url
)
{
var
nodes
=
km
.
getSelectedNodes
();
loadImageSize
(
url
,
function
(
width
,
height
)
{
if
(
!
width
)
return
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'image'
,
url
);
n
.
setData
(
'imageWidth'
,
width
);
n
.
setData
(
'imageHeight'
,
height
);
n
.
render
();
});
km
.
layout
();
});
},
},
"commands"
:
{
queryState
:
function
(
km
)
{
"image"
:
kity
.
createClass
(
"ImageCommand"
,
{
var
nodes
=
km
.
getSelectedNodes
(),
base
:
Command
,
result
=
0
;
if
(
nodes
.
length
===
0
)
{
execute
:
function
(
km
,
url
)
{
return
-
1
;
var
nodes
=
km
.
getSelectedNodes
();
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
loadImageSize
(
url
,
function
(
width
,
height
)
{
if
(
n
&&
n
.
getData
(
'image'
))
{
if
(
!
width
)
return
;
result
=
0
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
return
false
;
n
.
setData
(
'image'
,
url
);
n
.
setData
(
'imageWidth'
,
width
);
n
.
setData
(
'imageHeight'
,
height
);
km
.
updateLayout
(
n
);
}
);
}
);
},
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
(),
result
=
0
;
if
(
nodes
.
length
===
0
)
{
return
-
1
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
&&
n
.
getData
(
'image'
)
)
{
result
=
0
;
return
false
;
}
}
);
return
result
;
},
queryValue
:
function
(
km
)
{
var
node
=
km
.
getSelectedNode
();
return
node
.
getData
(
'image'
);
}
}
}
),
});
"removeimage"
:
kity
.
createClass
(
"RemoveImageCommand"
,
{
return
result
;
base
:
Command
,
},
queryValue
:
function
(
km
)
{
execute
:
function
(
km
)
{
var
node
=
km
.
getSelectedNode
();
var
nodes
=
km
.
getSelectedNodes
();
return
node
.
getData
(
'image'
);
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
}
n
.
setData
(
'image'
);
});
km
.
updateLayout
(
n
);
}
);
var
RemoveImageCommand
=
kity
.
createClass
(
'RemoveImageCommand'
,
{
},
base
:
Command
,
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
nodes
.
length
==
0
)
{
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
return
-
1
;
n
.
setData
(
'image'
);
}
km
.
updateLayout
(
n
);
var
image
=
false
;
});
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
},
if
(
n
.
getData
(
'image'
)
)
{
queryState
:
function
(
km
)
{
image
=
true
;
var
nodes
=
km
.
getSelectedNodes
();
return
false
;
}
if
(
nodes
.
length
===
0
)
{
}
);
return
-
1
;
if
(
image
)
{
}
return
0
;
var
image
=
false
;
}
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
return
-
1
;
if
(
n
.
getData
(
'image'
))
{
image
=
true
;
return
false
;
}
}
}
)
});
if
(
image
)
{
return
0
;
}
return
-
1
;
}
});
return
{
'defaultOptions'
:
{
'maxImageWidth'
:
200
,
'maxImageHeight'
:
200
},
'commands'
:
{
'image'
:
ImageCommand
,
'removeimage'
:
RemoveImageCommand
},
},
"events"
:
{
'events'
:
{
"RenderNodeTop"
:
function
(
e
)
{
'RenderNodeTop'
:
function
(
e
)
{
var
node
=
e
.
node
,
var
node
=
e
.
node
,
url
=
node
.
getData
(
'image'
);
url
=
node
.
getData
(
'image'
);
var
link
,
img
,
size
,
currentBox
;
var
link
,
img
,
size
,
currentBox
;
if
(
url
)
{
if
(
url
)
{
size
=
fitImageSize
(
size
=
fitImageSize
(
node
.
getData
(
'imageWidth'
),
node
.
getData
(
'imageWidth'
),
node
.
getData
(
'imageHeight'
),
node
.
getData
(
'imageHeight'
),
this
.
getOptions
(
'maxImageWidth'
),
this
.
getOptions
(
'maxImageWidth'
),
this
.
getOptions
(
'maxImageHeight'
)
);
this
.
getOptions
(
'maxImageHeight'
)
);
img
=
new
kity
.
Image
(
url
,
size
.
width
,
size
.
height
);
img
=
new
kity
.
Image
(
url
,
size
.
width
,
size
.
height
);
link
=
new
kity
.
HyperLink
(
url
);
link
=
new
kity
.
HyperLink
(
url
);
link
.
addShape
(
img
);
link
.
addShape
(
img
);
link
.
setTarget
(
'_blank'
);
link
.
setTarget
(
'_blank'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
currentBox
=
node
.
getContRc
().
getBoundaryBox
();
currentBox
=
node
.
getContRc
().
getBoundaryBox
();
node
.
getContRc
().
addShape
(
link
.
setTranslate
(
0
,
currentBox
.
y
-
size
.
height
)
);
node
.
getContRc
().
addShape
(
link
.
setTranslate
(
0
,
currentBox
.
y
-
size
.
height
)
);
}
}
}
}
}
}
};
};
}
);
});
\ No newline at end of file
\ No newline at end of file
src/theme/default.js
View file @
85d41ead
...
@@ -32,6 +32,7 @@ KityMinder.registerTheme('default', {
...
@@ -32,6 +32,7 @@ KityMinder.registerTheme('default', {
'connect-radius'
:
5
,
'connect-radius'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
,
'selected-background'
:
'rgb(254, 219, 0)'
,
'selected-color'
:
'black'
,
'drop-hint-color'
:
'yellow'
,
'drop-hint-color'
:
'yellow'
,
'sub-drop-hint-width'
:
2
,
'sub-drop-hint-width'
:
2
,
...
...
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