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;">'
;
content
+=
'<style>'
;
content
+=
'.kmui-dialog-<%= container %> input{'
;
...
...
@@ -36,39 +36,39 @@
KM
.
registerWidget
(
'image'
,
{
KM
.
registerWidget
(
'image'
,
{
tpl
:
content
,
initContent
:
function
(
km
)
{
var
lang
=
km
.
getLang
(
'dialogs.image'
),
initContent
:
function
(
km
)
{
var
lang
=
km
.
getLang
(
'dialogs.image'
),
html
;
if
(
lang
)
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
utils
.
extend
(
{
if
(
lang
)
{
html
=
$
.
parseTmpl
(
this
.
tpl
,
utils
.
extend
(
{
'container'
:
'image'
},
lang
)
);
},
lang
)
);
}
this
.
root
().
html
(
html
);
this
.
root
().
html
(
html
);
},
initEvent
:
function
(
km
,
$w
)
{
$w
.
find
(
'#image_insert'
).
on
(
'click'
,
function
()
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
initEvent
:
function
(
km
,
$w
)
{
$w
.
find
(
'#image_insert'
).
on
(
'click'
,
function
()
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
$w
.
kmui
().
hide
();
}
);
$w
.
find
(
'#image_href'
).
on
(
'keydown'
,
function
(
e
)
{
if
(
e
.
keyCode
===
13
)
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
});
$w
.
find
(
'#image_href'
).
on
(
'keydown'
,
function
(
e
)
{
if
(
e
.
keyCode
===
13
)
{
km
.
execCommand
(
'image'
,
$w
.
find
(
'#image_href'
).
val
()
);
$w
.
kmui
().
hide
();
}
}
).
on
(
'input'
,
function
()
{
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
$w
.
find
(
'#image_href'
).
val
());
}).
on
(
'input'
,
function
()
{
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
$w
.
find
(
'#image_href'
).
val
());
});
var
url
=
km
.
queryCommandValue
(
'image'
);
var
$input
=
$w
.
find
(
'#image_href'
);
$input
.
val
(
url
||
'http://'
);
if
(
url
)
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
url
);
setTimeout
(
function
()
{
var
url
=
km
.
queryCommandValue
(
'image'
);
var
$input
=
$w
.
find
(
'#image_href'
);
$input
.
val
(
url
||
'http://'
);
if
(
url
)
$w
.
find
(
'#image_preview'
).
attr
(
'src'
,
url
);
setTimeout
(
function
()
{
$input
.
focus
();
}
);
});
},
width
:
400
}
);
}
)(
KM
.
Utils
);
\ No newline at end of file
});
})(
KM
.
Utils
);
\ 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', {
}
});
kity
.
extendClass
(
MinderNode
,
{
getContentBox
:
function
()
{
return
this
.
_contentBox
;
}
});
kity
.
extendClass
(
Minder
,
{
_createRendererForNode
:
function
(
node
)
{
...
...
@@ -122,17 +116,7 @@ kity.extendClass(MinderNode, {
return
null
;
},
getContentBox
:
function
()
{
return
this
.
parent
&&
this
.
parent
.
isCollapsed
()
?
{
x
:
0
,
y
:
0
,
width
:
0
,
height
:
0
,
left
:
0
,
top
:
0
,
bottom
:
0
,
right
:
0
,
cx
:
0
,
cy
:
0
}
:
this
.
_contentBox
;
//if (!this._contentBox) this.render();
return
this
.
parent
&&
this
.
parent
.
isCollapsed
()
?
new
kity
.
Box
()
:
this
.
_contentBox
;
}
});
\ No newline at end of file
src/module/editor.js
View file @
85d41ead
...
...
@@ -179,7 +179,7 @@ KityMinder.registerModule('TextEditModule', function() {
if
(
browser
.
ipad
)
{
receiver
.
container
.
focus
();
}
}
else
{
}
else
{
//当选中节点后,输入状态准备
var
node
=
e
.
getTargetNode
();
if
(
node
)
{
...
...
src/module/font.js
View file @
85d41ead
...
...
@@ -4,7 +4,10 @@ KityMinder.registerModule("fontmodule", function() {
}
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
({
family
:
getNodeDataOrStyle
(
node
,
'font-family'
),
size
:
getNodeDataOrStyle
(
node
,
'font-size'
)
...
...
src/module/image.js
View file @
85d41ead
KityMinder
.
registerModule
(
"image"
,
function
()
{
function
loadImageSize
(
url
,
callback
)
{
var
img
=
document
.
createElement
(
'img'
);
img
.
onload
=
function
()
{
callback
(
img
.
width
,
img
.
height
);
KityMinder
.
registerModule
(
'image'
,
function
()
{
function
loadImageSize
(
url
,
callback
)
{
var
img
=
document
.
createElement
(
'img'
);
img
.
onload
=
function
()
{
callback
(
img
.
width
,
img
.
height
);
};
img
.
onerror
=
function
()
{
callback
(
null
);
img
.
onerror
=
function
()
{
callback
(
null
);
};
img
.
src
=
url
;
}
function
fitImageSize
(
width
,
height
,
maxWidth
,
maxHeight
)
{
function
fitImageSize
(
width
,
height
,
maxWidth
,
maxHeight
)
{
var
ratio
=
width
/
height
,
fitRatio
=
maxWidth
/
maxHeight
;
// 宽高比大于最大尺寸的宽高比,以宽度为标准适应
if
(
ratio
>
fitRatio
&&
width
>
maxWidth
)
{
if
(
ratio
>
fitRatio
&&
width
>
maxWidth
)
{
width
=
maxWidth
;
height
=
maxWidth
/
ratio
;
}
else
if
(
height
>
maxHeight
)
{
}
else
if
(
height
>
maxHeight
)
{
height
=
maxHeight
;
width
=
maxHeight
/
ratio
;
}
...
...
@@ -28,104 +28,110 @@ KityMinder.registerModule( "image", function () {
height
:
height
};
}
return
{
"defaultOptions"
:
{
"maxImageWidth"
:
200
,
"maxImageHeight"
:
200
var
ImageCommand
=
kity
.
createClass
(
'ImageCommand'
,
{
base
:
Command
,
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"
:
{
"image"
:
kity
.
createClass
(
"ImageCommand"
,
{
base
:
Command
,
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
);
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'
);
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
;
}
}
),
"removeimage"
:
kity
.
createClass
(
"RemoveImageCommand"
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'image'
);
km
.
updateLayout
(
n
);
}
);
},
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
nodes
.
length
==
0
)
{
return
-
1
;
}
var
image
=
false
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
if
(
n
.
getData
(
'image'
)
)
{
image
=
true
;
return
false
;
}
}
);
if
(
image
)
{
return
0
;
}
return
-
1
;
});
return
result
;
},
queryValue
:
function
(
km
)
{
var
node
=
km
.
getSelectedNode
();
return
node
.
getData
(
'image'
);
}
});
var
RemoveImageCommand
=
kity
.
createClass
(
'RemoveImageCommand'
,
{
base
:
Command
,
execute
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
n
.
setData
(
'image'
);
km
.
updateLayout
(
n
);
});
},
queryState
:
function
(
km
)
{
var
nodes
=
km
.
getSelectedNodes
();
if
(
nodes
.
length
===
0
)
{
return
-
1
;
}
var
image
=
false
;
utils
.
each
(
nodes
,
function
(
i
,
n
)
{
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"
:
{
"RenderNodeTop"
:
function
(
e
)
{
'events'
:
{
'RenderNodeTop'
:
function
(
e
)
{
var
node
=
e
.
node
,
url
=
node
.
getData
(
'image'
);
url
=
node
.
getData
(
'image'
);
var
link
,
img
,
size
,
currentBox
;
if
(
url
)
{
if
(
url
)
{
size
=
fitImageSize
(
node
.
getData
(
'imageWidth'
),
node
.
getData
(
'imageHeight'
),
this
.
getOptions
(
'maxImageWidth'
),
this
.
getOptions
(
'maxImageHeight'
)
);
node
.
getData
(
'imageWidth'
),
node
.
getData
(
'imageHeight'
),
this
.
getOptions
(
'maxImageWidth'
),
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
.
addShape
(
img
);
link
.
setTarget
(
'_blank'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
link
=
new
kity
.
HyperLink
(
url
);
link
.
addShape
(
img
);
link
.
setTarget
(
'_blank'
);
link
.
setStyle
(
'cursor'
,
'pointer'
);
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', {
'connect-radius'
:
5
,
'selected-background'
:
'rgb(254, 219, 0)'
,
'selected-color'
:
'black'
,
'drop-hint-color'
:
'yellow'
,
'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