Commit e74b0527 authored by techird's avatar techird

1.2.0 preview

parent 869129ba
( function ( utils ) { (function(utils) {
//todo 这里先写死成中文 //todo 这里先写死成中文
var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">'; var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">';
content += '<style>'; content += '<style>';
...@@ -35,36 +35,51 @@ ...@@ -35,36 +35,51 @@
KM.registerWidget( 'hyperlink', { KM.registerWidget('hyperlink', {
tpl: content, tpl: content,
initContent: function ( km ) { initContent: function(km) {
var lang = km.getLang( 'dialogs.hyperlink' ), var lang = km.getLang('dialogs.hyperlink'),
html; html;
if ( lang ) { if (lang) {
html = $.parseTmpl( this.tpl, utils.extend( { html = $.parseTmpl(this.tpl, utils.extend({
'container': 'hyperlink' 'container': 'hyperlink'
}, lang ) ); }, lang));
} }
this.root().html( html ); this.root().html(html);
}, },
initEvent: function ( km, $w ) { initEvent: function(km, $w) {
$w.find( '#hyperlink_insert' ).on( 'click', function () { var $btn = $w.find('#hyperlink_insert');
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() ); $btn.attr('disabled', 'disabled');
var $href = $w.find('#hyperlink_href').on('input', function() {
var url = $href.val();
if (!/^https?\:\/\/(\w+\.)+\w+/.test(url)) {
$href.css('color', 'red');
$href.data('error', true);
$btn.attr('disabled', 'disabled');
} else {
$href.css('color', 'black');
$href.data('error', false);
$btn.removeAttr('disabled');
}
});
$btn.on('click', function() {
if ($btn.attr('disabled')) return;
var url = $w.find('#hyperlink_href').val();
km.execCommand('hyperlink', url);
$w.kmui().hide(); $w.kmui().hide();
} ); });
$w.find( '#hyperlink_href' ).on( 'keydown', function ( e ) { $w.find('#hyperlink_href').on('keydown', function(e) {
if ( e.keyCode === 13 ) { if (e.keyCode === 13) {
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() ); $btn.click();
$w.kmui().hide();
} }
} ); });
var url = km.queryCommandValue( 'hyperlink' ); var url = km.queryCommandValue('hyperlink');
var $input = $w.find( '#hyperlink_href' ); var $input = $w.find('#hyperlink_href');
$input.val( url || 'http://' ); $input.val(url || 'http://');
setTimeout( function () { setTimeout(function() {
$input.focus() $input.select();
} ) });
}, },
width: 400 width: 400
} ); });
} )( KM.Utils ); })(KM.Utils);
\ No newline at end of file \ No newline at end of file
...@@ -49,24 +49,39 @@ ...@@ -49,24 +49,39 @@
this.root().html(html); this.root().html(html);
}, },
initEvent: function(km, $w) { initEvent: function(km, $w) {
$w.find('#image_insert').on('click', function() { var $btn = $w.find('#image_insert').attr('disabled', 'disabled');
km.execCommand('image', $w.find('#image_href').val()); var $href = $w.find('#image_href').on('input', function() {
var url = $href.val();
if (!/^https?\:\/\/(\w+\.)+\w+/.test(url)) {
$href.css('color', 'red');
$href.data('error', true);
} else {
$href.css('color', 'black');
$href.data('error', false);
}
$w.find('#image_preview').attr('src', $href.val());
});
$w.find('#image_preview').on('load', function() {
$btn.removeAttr('disabled');
}).on('error', function() {
$btn.attr('disabled', 'disabled');
});
$btn.on('click', function() {
if ($btn.attr('disabled')) return;
km.execCommand('image', $href.val());
$w.kmui().hide(); $w.kmui().hide();
}); });
$w.find('#image_href').on('keydown', function(e) { $href.on('keydown', function(e) {
if (e.keyCode === 13) { if (e.keyCode === 13) {
km.execCommand('image', $w.find('#image_href').val()); $btn.click();
$w.kmui().hide();
} }
}).on('input', function() {
$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.select();
}); });
}, },
width: 400 width: 400
......
...@@ -9,8 +9,7 @@ button img{position:relative;top:3px;border-radius:2px;margin-right:7px} ...@@ -9,8 +9,7 @@ button img{position:relative;top:3px;border-radius:2px;margin-right:7px}
button.user-file{position:relative;padding-right:28px}button.user-file img{border:none;outline:none} button.user-file{position:relative;padding-right:28px}button.user-file img{border:none;outline:none}
button.user-file span.text{display:inline-block;height:24px;line-height:24px} button.user-file span.text{display:inline-block;height:24px;line-height:24px}
button.user-file:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent} button.user-file:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent}
#draft-btn{position:absolute;left:10px;bottom:10px;padding-left:35px;padding-right:28px}#draft-btn:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/draft.png) no-repeat;position:absolute;left:7px;top:5px} #draft-btn{padding-right:28px}#draft-btn:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent}
#draft-btn:after{content:' ';display:block;position:absolute;right:10px;top:15px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#fff transparent transparent transparent}
.draft-menu span.update-time{float:right;color:#ccc;margin-left:20px;padding-right:16px} .draft-menu span.update-time{float:right;color:#ccc;margin-left:20px;padding-right:16px}
.draft-menu li.draft-item a{position:relative}.draft-menu li.draft-item a:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/draft.png) no-repeat 0 -24px;position:absolute;left:4px;top:2px} .draft-menu li.draft-item a{position:relative}.draft-menu li.draft-item a:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/draft.png) no-repeat 0 -24px;position:absolute;left:4px;top:2px}
.draft-menu li.draft-item:hover a:before{background-position:0 -48px} .draft-menu li.draft-item:hover a:before{background-position:0 -48px}
......
...@@ -113,20 +113,6 @@ button { ...@@ -113,20 +113,6 @@ button {
} }
} }
#draft-btn { #draft-btn {
position: absolute;
left: 10px;
bottom: 10px;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/draft.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
padding-left: 35px;
.dropdown; .dropdown;
} }
.draft-menu { .draft-menu {
......
...@@ -31,10 +31,9 @@ ...@@ -31,10 +31,9 @@
'layout/bottom.js', 'layout/bottom.js',
'layout/filetree.js', 'layout/filetree.js',
'theme/default.js', 'theme/default.js',
'theme/bottom.js', 'theme/snow.js',
'theme/filetree.js',
'theme/fresh.js', 'theme/fresh.js',
'template/bottom.js', 'template/structure.js',
'module/node.js', 'module/node.js',
'module/text.js', 'module/text.js',
'module/expand.js', 'module/expand.js',
...@@ -58,7 +57,6 @@ ...@@ -58,7 +57,6 @@
'module/basestyle.js', 'module/basestyle.js',
'module/font.js', 'module/font.js',
'module/zoom.js', 'module/zoom.js',
'module/nodetext.js',
'module/hyperlink.js', 'module/hyperlink.js',
'module/arrange.js', 'module/arrange.js',
'ui/jquery-ui-1.10.4.custom.min.js', 'ui/jquery-ui-1.10.4.custom.min.js',
...@@ -86,7 +84,7 @@ ...@@ -86,7 +84,7 @@
'adapter/color.js', 'adapter/color.js',
'adapter/saveto.js', 'adapter/saveto.js',
'adapter/tooltips.js', 'adapter/tooltips.js',
//'adapter/layout.js', 'adapter/face.js',
'adapter/node.js', 'adapter/node.js',
'adapter/contextmenu.js', 'adapter/contextmenu.js',
'adapter/dialog.js', 'adapter/dialog.js',
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
<meta name="keyword" content="脑图,kity,svg,minder,百度,fex,前端,在线"> <meta name="keyword" content="脑图,kity,svg,minder,百度,fex,前端,在线">
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。"> <meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<script src="lib/jquery-2.1.0.min.js" charset="utf-8"></script> <script src="lib/jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js" charset="utf-8"></script> <script src="lib/ZeroClipboard.min.js" charset="utf-8"></script>
<script type="text/javascript"> <script type="text/javascript">
...@@ -36,6 +35,7 @@ ...@@ -36,6 +35,7 @@
<body> <body>
<div id="kityminder" onselectstart="return false"></div> <div id="kityminder" onselectstart="return false"></div>
<div id="share-dialog" > <div id="share-dialog" >
<h3>URL分享:</h3> <h3>URL分享:</h3>
<p> <p>
......
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ toolbars: [
'hand | zoom-in zoom zoom-out | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink image removeimage | markers resource | node | help' 'hand | zoom-in zoom zoom-out | saveto | collapsenode expandnode | undo redo | template theme | bold italic | fontfamily fontsize forecolor| hyperlink unhyperlink image removeimage | markers resource | node | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
......
KityMinder.LANG['zh-cn'] = { KityMinder.LANG['zh-cn'] = {
'template': {
'default': '思维导图',
'structure': '组织结构图'
},
'theme': {
'default': '脑图经典',
'snow': '温柔冷光',
'fresh': '文艺小清新'
},
'maintopic': '中心主题', 'maintopic': '中心主题',
'topic': '分支主题', 'topic': '分支主题',
'tooltips': { 'tooltips': {
...@@ -21,9 +30,11 @@ KityMinder.LANG['zh-cn'] = { ...@@ -21,9 +30,11 @@ KityMinder.LANG['zh-cn'] = {
'preference': '偏好设置', 'preference': '偏好设置',
'image': '插入图片', 'image': '插入图片',
'hyperlink': '插入链接', 'hyperlink': '插入链接',
'unhyperlink': "删除链接", 'unhyperlink': '删除链接',
'expandnode': "展开节点", 'expandnode': '展开节点',
'collapsenode': "收起节点" 'collapsenode': '收起节点',
'template': '模板',
'theme': '皮肤'
}, },
'popupcolor': { 'popupcolor': {
'clearColor': '清空颜色', 'clearColor': '清空颜色',
...@@ -72,11 +83,17 @@ KityMinder.LANG['zh-cn'] = { ...@@ -72,11 +83,17 @@ KityMinder.LANG['zh-cn'] = {
}, },
'hyperlink': { 'hyperlink': {
'hyperlink': '插入超链接', 'hyperlink': '插入超链接',
'unhyperlink': "取消超链接" 'unhyperlink': '取消超链接'
}, },
'image': { 'image': {
'image': '插入图片', 'image': '插入图片',
'removeimage': '删除图片' 'removeimage': '删除图片'
},
'marker': {
'marker': '设置进度/优先级'
},
'resource': {
'resource': '设置资源'
} }
}; };
\ No newline at end of file
...@@ -9,27 +9,6 @@ function DraftManager( minder ) { ...@@ -9,27 +9,6 @@ function DraftManager( minder ) {
function init() { function init() {
drafts = localStorage.getItem( 'drafts' ); drafts = localStorage.getItem( 'drafts' );
drafts = drafts ? JSON.parse( drafts ) : []; drafts = drafts ? JSON.parse( drafts ) : [];
loadDraftForOldVersion();
}
/**
* @todo 1.2 版本中删除该方法
*
* 加载老版本的草稿
*/
function loadDraftForOldVersion() {
var path = localStorage.getItem( 'draft_filename' ),
data = localStorage.getItem( 'draft_data' );
if ( path && data ) {
drafts.push( {
path: path,
data: data,
name: JSON.parse( data ).data.text,
update: new Date()
} );
localStorage.removeItem( 'draft_filename' );
localStorage.removeItem( 'draft_data' );
}
} }
function store() { function store() {
...@@ -58,7 +37,8 @@ function DraftManager( minder ) { ...@@ -58,7 +37,8 @@ function DraftManager( minder ) {
function load() { function load() {
if ( current ) { if ( current ) {
minder.importData( current.data, "json" ); minder.importData( current.data, 'json' );
minder.execCommand('camera');
} }
return current; return current;
} }
...@@ -80,8 +60,9 @@ function DraftManager( minder ) { ...@@ -80,8 +60,9 @@ function DraftManager( minder ) {
} else { } else {
current.path = path || current.path; current.path = path || current.path;
current.name = minder.getMinderTitle(); current.name = minder.getMinderTitle();
current.data = minder.exportData( "json" ); var data = minder.exportData( 'json' );
current.sync = false; current.sync = current.sync && (data == current.data);
current.data = data;
current.update = new Date(); current.update = new Date();
store(); store();
} }
......
This diff is collapsed.
This diff is collapsed.
#social { #social {
position: absolute; position: absolute;
right: 10px; height: 30px;
top: 10px; left: 0;
line-height: 20px; right: 0;
text-align: right; top: 0;
line-height: 30px;
overflow: hidden; overflow: hidden;
background: #fafafa;
border-bottom: 1px solid #fff;
box-shadow: inset 0 -1px #f0f0f0;
z-index: 1000;
h2 {
margin: 0 200px;
padding: 0;
color: #999;
text-shadow: 0 1px white;
font-size: 12px;
text-align: center;
font-weight: normal;
}
#menu {
float: left;
}
#user {
float: right;
padding-right: 10px;
a {
color: #333;
font-size: 12px;
text-decoration: underline;
padding: 0 5px;
cursor: pointer;
img {
vertical-align: text-bottom;
margin-right: 5px;
}
}
#logout-button, #user-button {
display: none;
}
&.logined {
#logout-button, #user-button {
display: inline-block;
}
#login-button {
display: none;
}
}
}
}
.niceblue {
color: white;
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
&:after {
border-color: #fff transparent transparent transparent;
}
} }
.dropdown { .dropdown {
padding-right: 28px; padding-right: 28px;
position: relative;
&:after { &:after {
content: ' '; content: ' ';
display: block; display: block;
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 15px; top: 12px;
width: 0; width: 0;
height: 0; height: 0;
border: solid; border: solid;
border-width: 4px 5px; border-width: 4px 5px;
border-color: #FFFFFF transparent transparent transparent; border-color: #333 transparent transparent transparent;
}
&:active, &.active {
&:after {
border-color: #fff transparent transparent transparent;
}
} }
} }
...@@ -29,41 +99,31 @@ button { ...@@ -29,41 +99,31 @@ button {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
padding: 0 15px; padding: 0 15px;
height: 35px; height: 30px;
font-size: 13px; font-size: 13px;
line-height: 35px; line-height: 30px;
text-align: center; text-align: center;
border-radius: 5px; color: #000;
color: #ffffff;
text-decoration: none; text-decoration: none;
border: none; border: none;
margin-left: 5px; margin-left: 5px;
cursor: pointer; background: none;
background: #0099f2; /* Old browsers */ border-radius: 2px;
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
&:hover, &.hover { &:hover, &.hover {
background: #009fff;
} }
&:active, &.active { &:active, &.active {
background: darken(#009fff, 10%); box-shadow: inset 0 1px 3px rgba(0,0,0,.2);
box-shadow: inset 0 2px 3px rgba(0,0,0, .2); background: #ccc;
color: white;
} }
&[disabled] { &[disabled] {
background: #AAA;
cursor: default; cursor: default;
} }
&.baidu-cloud { &.share {
padding-left: 35px; padding-left: 35px;
position: relative; position: relative;
&:before { &:before {
...@@ -71,65 +131,79 @@ button { ...@@ -71,65 +131,79 @@ button {
display: block; display: block;
width: 24px; width: 24px;
height: 24px; height: 24px;
background: url(../themes/default/images/baiducloud.png); background: url(../themes/default/images/share.png) no-repeat;
position: absolute; position: absolute;
left: 7px; left: 7px;
top: 5px; top: 5px;
} }
} }
img {
position: relative;
top: 3px;
border-radius: 2px;
margin-right: 7px;
}
&.file-button {
.dropdown;
.niceblue;
&.share { border-radius: 5px 5px 0 0;
padding-left: 35px; margin-left: 5px;
&:hover, &.hover {
background: #009fff;
}
&:active, &.active {
background: darken(#009fff, 10%);
box-shadow: inset 0 2px 3px rgba(0,0,0, .2);
}
}
}
#save-button {
a {
position: relative; position: relative;
&:before { &:before {
content: ' '; content: ' ';
display: block; display: block;
width: 24px; width: 24px;
height: 24px; height: 24px;
background: url(../themes/default/images/share.png) no-repeat; background: url(../themes/default/images/baiducloud.png);
position: absolute; position: absolute;
left: 7px; left: 4px;
top: 5px; top: 2px;
} }
} }
img { &:hover a:before {
position: relative; background-position: 0 -24px;
top: 3px;
border-radius: 2px;
margin-right: 7px;
} }
&.user-file { }
#share-button {
a {
position: relative; position: relative;
img { &:before {
border: none; content: ' ';
outline: none; display: block;
} width: 24px;
span.text {
display: inline-block;
height: 24px; height: 24px;
line-height: 24px; background: url(../themes/default/images/share.png);
position: absolute;
left: 4px;
top: 2px;
} }
.dropdown; }
&:hover a:before {
background-position: 0 -24px;
} }
} }
#draft-btn { #draft-btn {
position: absolute;
left: 10px;
bottom: 10px;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/draft.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
padding-left: 35px;
.dropdown; .dropdown;
border-radius: 5px 5px 0 0;
} }
.draft-menu { .draft-menu.kmui-dropdown-menu {
margin-top: 14px;
margin-left: -1px;
span.update-time { span.update-time {
float: right; float: right;
color: #CCC; color: #CCC;
...@@ -198,17 +272,30 @@ button { ...@@ -198,17 +272,30 @@ button {
} }
} }
} }
.user-file-menu { .file-menu.kmui-dropdown-menu {
margin-top: 20px; margin-top: 14px;
margin-left: 1px; margin-left: 1px;
box-shadow: 0px 1px 5px rgba(0,0,0, .3);
#save-button, #manage-file-button, #share-button + .kmui-divider {
display: none;
}
&.logined {
#save-button, #manage-file-button, #share-button + .kmui-divider {
display: block;
}
}
} }
#share-dialog { #share-dialog {
position: absolute; position: absolute;
padding: 20px; padding: 20px;
border-radius: 4px; border-radius: 4px;
right: 10px; left: 50%;
top: 65px; top: 40%;
margin-left: -175px;
margin-top: -100px;
background: white; background: white;
width: 350px; width: 350px;
box-shadow: 1px 2px 16px rgba(0, 0, 0, .5); box-shadow: 1px 2px 16px rgba(0, 0, 0, .5);
...@@ -247,22 +334,24 @@ button { ...@@ -247,22 +334,24 @@ button {
line-height: 28px; line-height: 28px;
border-radius: 2px; border-radius: 2px;
vertical-align: middle; vertical-align: middle;
color: white;
border-radius: 5px;
.niceblue;
&:hover, &.hover {
background: #009fff;
}
&:active, &.active {
background: darken(#009fff, 10%);
box-shadow: inset 0 2px 3px rgba(0,0,0, .2);
}
} }
#share-platform { #share-platform {
margin-bottom: 0; margin-bottom: 0;
} }
&:before {
position: absolute;
content: ' ';
width: 0;
height: 0;
line-height: 0;
display: block;
border: 10px solid transparent;
border-bottom-color: white;
right: 30px;
top: -20px;
}
} }
\ No newline at end of file
KM.registerToolbarUI( 'markers help preference resource', function ( name ) { KM.registerToolbarUI('markers help preference resource', function(name) {
var me = this, var me = this,
currentRange, $dialog, currentRange, $dialog,
opt = { opt = {
title: this.getLang( 'tooltips' )[ name ] || '', title: this.getLang('tooltips')[name] || '',
url: me.getOptions( 'KITYMINDER_HOME_URL' ) + 'dialogs/' + name + '/' + name + '.js', url: me.getOptions('KITYMINDER_HOME_URL') + 'dialogs/' + name + '/' + name + '.js',
}; };
var $btn = $.kmuibutton( { var $btn = $.kmuibutton({
icon: name, icon: name,
title: this.getLang( 'tooltips' )[ name ] || '' title: this.getLang('tooltips')[name] || ''
} ); });
//加载模版数据 //加载模版数据
utils.loadFile( document, { utils.loadFile(document, {
src: opt.url, src: opt.url,
tag: "script", tag: 'script',
type: "text/javascript", type: 'text/javascript',
defer: "defer" defer: 'defer'
}, function () { }, function() {
$dialog = $.kmuimodal( opt ); $dialog = $.kmuimodal(opt);
$dialog.attr( 'id', 'kmui-dialog-' + name ).addClass( 'kmui-dialog-' + name ) $dialog.attr('id', 'kmui-dialog-' + name).addClass('kmui-dialog-' + name)
.find( '.kmui-modal-body' ).addClass( 'kmui-dialog-' + name + '-body' ); .find('.kmui-modal-body').addClass('kmui-dialog-' + name + '-body');
$dialog.kmui().on( 'beforeshow', function () { $dialog.kmui().on('beforeshow', function() {
var $root = this.root(), var $root = this.root(),
win = null, win = null,
offset = null; offset = null;
if ( !$root.parent()[ 0 ] ) { if (!$root.parent()[0]) {
me.$container.find( '.kmui-dialog-container' ).append( $root ); me.$container.find('.kmui-dialog-container').append($root);
} }
KM.setWidgetBody( name, $dialog, me ); KM.setWidgetBody(name, $dialog, me);
} ).attachTo( $btn ) }).attachTo($btn);
} ); });
me.on( 'interactchange', function () { me.on('interactchange', function() {
var state = this.queryCommandState( name ); var state = this.queryCommandState(name);
$btn.kmui().disabled( state == -1 ).active( state == 1 ) $btn.kmui().disabled(state == -1).active(state == 1);
} ); });
switch (name) {
case 'markers':
me.addContextmenu([{
label: me.getLang('marker.marker'),
exec: function() {
$dialog.kmui().show();
},
cmdName: 'markers'
}]);
break;
case 'resource':
me.addContextmenu([{
label: me.getLang('resource.resource'),
exec: function() {
$dialog.kmui().show();
},
cmdName: 'resource'
}]);
}
return $btn; return $btn;
} ); });
\ No newline at end of file \ No newline at end of file
KM.registerToolbarUI('template theme', function(name) {
var values = utils.keys(name == 'template' ? KM.getTemplateList() : KM.getThemeList());
var me = this,
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
comboboxName: name,
items: values.map(function(value) {
return me.getLang(name)[value];
}),
itemStyles: [],
value: values,
autowidthitem: [],
enabledRecord: false
},
$combox = null;
//实例化
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
var 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'));
}
});
//状态反射
me.on('interactchange', function() {
var state = this.queryCommandState(name),
value = this.queryCommandValue(name);
//设置按钮状态
comboboxWidget.button().kmui().disabled(state == -1).active(state == 1);
if (value) {
comboboxWidget.selectItemByValue(value);
}
});
return comboboxWidget.button().addClass('kmui-combobox');
});
\ No newline at end of file
KM.registerToolbarUI('switchlayout', function(name) {
// var me = this,
// label = me.getLang('tooltips.' + name),
// options = {
// label: label,
// title: label,
// comboboxName: name,
// items: me.getLayoutStyleItems() || [],
// itemStyles: [],
// value: me.getLayoutStyleItems(),
// autowidthitem: [],
// enabledRecord: false
// },
// $combox = null;
// if (options.items.length == 0) {
// return null;
// }
// utils.each(options.items, function(i, item) {
// options.items[i] = me.getLang('layout')[item];
// });
// //实例化
// $combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
// var comboboxWidget = $combox.kmui();
// comboboxWidget.on('comboboxselect', function(evt, res) {
// me.execCommand(name, res.value);
// me.initStyle();
// }).on("beforeshow", function() {
// if ($combox.parent().length === 0) {
// $combox.appendTo(me.$container.find('.kmui-dialog-container'));
// }
// });
// //状态反射
// me.on('interactchange', function() {
// var state = this.queryCommandState(name),
// value = this.queryCommandValue(name);
// //设置按钮状态
// comboboxWidget.button().kmui().disabled(state == -1).active(state == 1);
// if (value) {
// //设置label
// value = value.replace(/['"]/g, '').toLowerCase().split(/['|"]?\s*,\s*[\1]?/);
// comboboxWidget.selectItemByLabel(value);
// }
// });
// // var data = [];
// // utils.each(me.getLayoutStyleItems(), function (i, v) {
// // data.push({
// // label: me.getLang('tooltips.' + name) + ' ' + v,
// // cmdName: 'switchlayout',
// // exec: function () {
// // me.execCommand('switchlayout', v);
// // }
// // });
// // });
// // data.push({
// // divider: 1
// // });
// // me.addContextmenu(data);
// return comboboxWidget.button().addClass('kmui-combobox');
});
\ No newline at end of file
KM.registerToolbarUI( 'saveto', function ( name ) { KM.registerToolbarUI('saveto', 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,
...@@ -16,92 +16,81 @@ KM.registerToolbarUI( 'saveto', function ( name ) { ...@@ -16,92 +16,81 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
$combox = null, $combox = null,
comboboxWidget = null; comboboxWidget = null;
utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) { utils.each(KityMinder.getAllRegisteredProtocals(), function(k) {
var p = KityMinder.findProtocal( k ); var p = KityMinder.findProtocal(k);
if ( p.encode ) { if (p.encode) {
var text = p.fileDescription + '(' + p.fileExtension + ')'; var text = p.fileDescription + '(' + p.fileExtension + ')';
options.value.push( k ); options.value.push(k);
options.items.push( text ); options.items.push(text);
options.autowidthitem.push( $.wordCountAdaptive( text ), true ); options.autowidthitem.push($.wordCountAdaptive(text), true);
} }
} ); });
//实例化 //实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 ); $combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
comboboxWidget = $combox.kmui(); comboboxWidget = $combox.kmui();
function doDownload( url, filename ) { function doProxyDownload(url, filename, type) {
var a = document.createElement( 'a' ); var content = url.split(',')[1];
a.setAttribute( 'download', filename ); var $form = $('<form></form>').attr({
a.setAttribute( 'href', url ); 'action': 'http://172.22.73.36/naotu/download.php',
document.body.appendChild(a); 'method': 'POST'
var evt; });
try {
evt = new MouseEvent( 'click' ); var $content = $('<input />').attr({
} catch ( error ) { name: 'content',
evt = document.createEvent( 'MouseEvents' ); type: 'hidden',
evt.initEvent( 'click', true, true ); value: decodeURIComponent(content)
} }).appendTo($form);
a.dispatchEvent( evt );
document.body.removeChild(a); var $type = $('<input />').attr({
name: 'type',
type: 'hidden',
value: type
}).appendTo($form);
var $filename = $('<input />').attr({
name: 'filename',
type: 'hidden',
value: filename
}).appendTo($form);
$form.appendTo('body').submit().remove();
} }
var ie_ver = function () { function doDownload(url, filename, type) {
var iev = 0; if (kity.Browser.ie || ~window.location.href.indexOf('naotu.baidu.com')) {
var ieold = ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) ); return doProxyDownload(url, filename, type);
var trident = !! navigator.userAgent.match( /Trident\/7.0/ ); }
var rv = navigator.userAgent.indexOf( "rv:11.0" ); var a = document.createElement('a');
if ( ieold ) iev = new Number( RegExp.$1 ); a.setAttribute('download', filename);
if ( navigator.appVersion.indexOf( "MSIE 10" ) != -1 ) iev = 10; a.setAttribute('href', url);
if ( trident && rv != -1 ) iev = 11; a.click();
return iev; }
};
var doSave = function ( urltype, d, filename ) {
var iframe = document.createElement( 'iframe' );
iframe.style.display = 'none';
document.body.appendChild( iframe );
iframe.contentDocument.open( urltype, 'replace' );
iframe.contentDocument.writeln( d );
iframe.contentDocument.execCommand( 'saveas', '', filename );
};
comboboxWidget.on( 'comboboxselect', function ( evt, res ) { comboboxWidget.on('comboboxselect', function(evt, res) {
var data = me.exportData( res.value ); var data = me.exportData(res.value);
var p = KityMinder.findProtocal( res.value ); var p = KityMinder.findProtocal(res.value);
var filename = me.getMinderTitle() + p.fileExtension; var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) { if (typeof(data) == 'string') {
var url = 'data:' + (p.mineType || 'text/plain') + '; utf-8,' + encodeURIComponent( data ); var url = 'data:' + (p.mineType || 'text/plain') + '; utf-8,' + encodeURIComponent(data);
if ( ie_ver() > 0 ) { doDownload(url, filename, 'text');
if ( p.fileExtension === '.km' ) { } else if (data && data.then) {
doSave( 'application/x-javascript', data, me.getMinderTitle() ); data.then(function(url) {
} else if ( p.fileExtension === '.svg' ) { doDownload(url, filename, 'base64');
//doSave( 'image/svg+xml', data, filename ); });
} else {
doSave( 'text/html', data, filename );
}
} else {
doDownload( url, filename );
}
} else if ( data && data.then ) {
data.then( function ( url ) {
if ( ie_ver() > 0 ) {
//doSave( 'application/base64', url.replace( 'image/octet-stream,', '' ), filename );
} else {
doDownload( url, filename );
}
} );
} }
} ).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'));
} }
} ).on( 'aftercomboboxselect', function () { }).on('aftercomboboxselect', function() {
this.setLabelWithDefaultValue(); this.setLabelWithDefaultValue();
} ); });
return comboboxWidget.button().addClass( 'kmui-combobox' ); return comboboxWidget.button().addClass('kmui-combobox');
} ); });
\ No newline at end of file \ No newline at end of file
...@@ -39,7 +39,7 @@ kity.extendClass(MinderNode, { ...@@ -39,7 +39,7 @@ kity.extendClass(MinderNode, {
}, },
getOrderHint: function(refer) { getOrderHint: function(refer) {
return this.getLayoutInstance().getOrderHint(this); return this.parent.getLayoutInstance().getOrderHint(this);
}, },
getExpandPosition: function() { getExpandPosition: function() {
...@@ -169,13 +169,22 @@ kity.extendClass(Minder, { ...@@ -169,13 +169,22 @@ kity.extendClass(Minder, {
refresh: function(duration) { refresh: function(duration) {
this.getRoot().preTraverse(function(node) { node.render(); }); this.getRoot().preTraverse(function(node) { node.render(); });
return this.layout(duration); this.layout(duration).fire('contentchange').fire('interactchange');
return this;
}, },
applyLayoutResult: function(root, duration) { applyLayoutResult: function(root, duration) {
root = root || this.getRoot(); root = root || this.getRoot();
var me = this; var me = this;
function applyMatrix(node, matrix) {
node.getRenderContainer().setMatrix(node._lastLayoutTransform = matrix);
me.fire('layoutapply', {
node: node,
matrix: matrix
});
}
function apply(node, pMatrix) { function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(pMatrix); var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node._lastLayoutTransform || new kity.Matrix(); var lastMatrix = node._lastLayoutTransform || new kity.Matrix();
...@@ -193,33 +202,23 @@ kity.extendClass(Minder, { ...@@ -193,33 +202,23 @@ kity.extendClass(Minder, {
// 如果要求以动画形式来更新,创建动画 // 如果要求以动画形式来更新,创建动画
if (duration > 0) { if (duration > 0) {
node._layoutTimeline = new kity.Animator(lastMatrix, matrix, function(node, value) { node._layoutTimeline = new kity.Animator(lastMatrix, matrix, applyMatrix)
node.getRenderContainer().setMatrix(node._lastLayoutTransform = value); .start(node, duration, 'ease')
me.fire('layoutapply', { .on('finish', function() {
node: node, // 可能性能低的时候会丢帧
matrix: value setTimeout(function() {
}); applyMatrix(node, matrix);
}).start(node, duration, 'ease').on('finish', function() { me.fire('layoutfinish', {
// 可能性能低的时候会丢帧 node: node,
me.fire('layoutapply', { matrix: matrix
node: node, });
matrix: matrix });
});
me.fire('layoutfinish', {
node: node,
matrix: matrix
}); });
});
} }
// 否则直接更新 // 否则直接更新
else { else {
node.getRenderContainer().setMatrix(matrix); applyMatrix(node, matrix);
node._lastLayoutTransform = matrix;
me.fire('layoutapply', {
node: node,
matrix: matrix
});
me.fire('layoutfinish', { me.fire('layoutfinish', {
node: node, node: node,
matrix: matrix matrix: matrix
......
...@@ -16,46 +16,30 @@ Utils.extend(KityMinder, { ...@@ -16,46 +16,30 @@ Utils.extend(KityMinder, {
} }
}); });
// 这里的 Json 是一个对象
function exportNode(node) {
var exported = {};
exported.data = node.getData();
var childNodes = node.getChildren();
if (childNodes.length) {
exported.children = [];
for (var i = 0; i < childNodes.length; i++) {
exported.children.push(exportNode(childNodes[i]));
}
}
return exported;
}
var DEFAULT_TEXT = { var DEFAULT_TEXT = {
'root': 'maintopic', 'root': 'maintopic',
'main': 'topic', 'main': 'topic',
'sub': 'topic' 'sub': 'topic'
}; };
function importNode(node, json, km) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
node.setData('text', data.text || km.getLang(DEFAULT_TEXT[node.getType()]));
var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) {
var childNode = km.createNode(null, node);
importNode(childNode, childrenTreeData[i], km);
}
return node;
}
// 导入导出 // 导入导出
kity.extendClass(Minder, { kity.extendClass(Minder, {
exportData: function(protocalName) { exportData: function(protocalName) {
// 这里的 Json 是一个对象
function exportNode(node) {
var exported = {};
exported.data = node.getData();
var childNodes = node.getChildren();
if (childNodes.length) {
exported.children = [];
for (var i = 0; i < childNodes.length; i++) {
exported.children.push(exportNode(childNodes[i]));
}
}
return exported;
}
var json, protocal; var json, protocal;
json = exportNode(this.getRoot()); json = exportNode(this.getRoot());
...@@ -67,6 +51,9 @@ kity.extendClass(Minder, { ...@@ -67,6 +51,9 @@ kity.extendClass(Minder, {
protocal: protocal protocal: protocal
}, true)) === true) return; }, true)) === true) return;
json.template = this.getTemplate();
json.theme = this.getTheme();
if (protocal) { if (protocal) {
return protocal.encode(json, this); return protocal.encode(json, this);
} else { } else {
...@@ -119,6 +106,24 @@ kity.extendClass(Minder, { ...@@ -119,6 +106,24 @@ kity.extendClass(Minder, {
}, },
_doImport: function(json, params) { _doImport: function(json, params) {
function importNode(node, json, km) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
node.setData('text', data.text || km.getLang(DEFAULT_TEXT[node.getType()]));
var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) {
var childNode = km.createNode(null, node);
importNode(childNode, childrenTreeData[i], km);
}
return node;
}
this._fire(new MinderEvent('preimport', params, false)); this._fire(new MinderEvent('preimport', params, false));
// 删除当前所有节点 // 删除当前所有节点
...@@ -126,9 +131,20 @@ kity.extendClass(Minder, { ...@@ -126,9 +131,20 @@ kity.extendClass(Minder, {
this.removeNode(this._root.getChildren()[0]); this.removeNode(this._root.getChildren()[0]);
} }
// compality for v1.1.3
var ocs = json.data.currentstyle; // old current-style
delete json.data.currentstyle;
importNode(this._root, json, this); importNode(this._root, json, this);
this.refresh(500); if (ocs == 'bottom') {
json.template = 'structure';
json.theme = 'snow';
}
this.setTemplate(json.template || null);
this.setTheme(json.theme || null);
this.refresh();
this.fire('import', params); this.fire('import', params);
......
...@@ -2,20 +2,28 @@ utils.extend(KityMinder, { ...@@ -2,20 +2,28 @@ utils.extend(KityMinder, {
_templates: {}, _templates: {},
registerTemplate: function(name, supports) { registerTemplate: function(name, supports) {
KityMinder._templates[name] = supports; KityMinder._templates[name] = supports;
},
getTemplateList: function() {
return KityMinder._templates;
} }
}); });
KityMinder.registerTemplate('default', {});
kity.extendClass(Minder, (function() { kity.extendClass(Minder, (function() {
var originGetTheme = Minder.prototype.getTheme; var originGetTheme = Minder.prototype.getTheme;
return { return {
useTemplate: function(name) { useTemplate: function(name, duration) {
this._template = name; this.setTemplate(name);
this.refresh(duration || 800);
},
this.getRoot().traverse(function(node) { getTemplate: function() {
node.render(); return this._template || null;
}); },
this.layout(300); setTemplate: function(name) {
this._template = name || null;
}, },
getTemplateSupports: function() { getTemplateSupports: function() {
...@@ -55,8 +63,8 @@ KityMinder.registerModule('TemplateModule', { ...@@ -55,8 +63,8 @@ KityMinder.registerModule('TemplateModule', {
minder.useTemplate(name); minder.useTemplate(name);
}, },
queryCommandValue: function(minder) { queryValue: function(minder) {
return minder._template; return minder.getTemplate() || 'default';
} }
}) })
} }
......
...@@ -36,6 +36,10 @@ Utils.extend(KityMinder, { ...@@ -36,6 +36,10 @@ Utils.extend(KityMinder, {
// 首个注册的主题为默认主题 // 首个注册的主题为默认主题
if (!KityMinder._defaultTheme) KityMinder._defaultTheme = name; if (!KityMinder._defaultTheme) KityMinder._defaultTheme = name;
},
getThemeList: function() {
return KityMinder._themes;
} }
}); });
...@@ -46,21 +50,16 @@ kity.extendClass(Minder, { ...@@ -46,21 +50,16 @@ kity.extendClass(Minder, {
* @param {String} name 要使用的主题的名称 * @param {String} name 要使用的主题的名称
*/ */
useTheme: function(name) { useTheme: function(name) {
if (!KityMinder._themes[name]) {
return false;
}
this._theme = name; this.setTheme(name);
this.refresh(800);
this.getRoot().traverse(function(node) { return true;
node.render(); },
});
this.getRoot().layout();
setTheme: function(name) {
this._theme = name || null;
this.getPaper().getContainer().style.background = this.getStyle('background'); this.getPaper().getContainer().style.background = this.getStyle('background');
return true;
}, },
/** /**
...@@ -68,7 +67,12 @@ kity.extendClass(Minder, { ...@@ -68,7 +67,12 @@ kity.extendClass(Minder, {
* @return {[type]} [description] * @return {[type]} [description]
*/ */
getTheme: function(node) { getTheme: function(node) {
return this._theme || KityMinder._defaultTheme; return this._theme || null;
},
getThemeItems: function(node) {
var theme = this.getTheme(node);
return KityMinder._themes[this.getTheme(node)] || KityMinder._themes[KityMinder._defaultTheme];
}, },
/** /**
...@@ -76,10 +80,10 @@ kity.extendClass(Minder, { ...@@ -76,10 +80,10 @@ kity.extendClass(Minder, {
* @param {String} item 样式名称 * @param {String} item 样式名称
*/ */
getStyle: function(item, node) { getStyle: function(item, node) {
var theme = KityMinder._themes[this.getTheme(node)]; var items = this.getThemeItems(node);
var segment, dir, selector, value, matcher; var segment, dir, selector, value, matcher;
if (item in theme) return theme[item]; if (item in items) return items[item];
// 尝试匹配 CSS 数组形式的值 // 尝试匹配 CSS 数组形式的值
// 比如 item 为 'pading-left' // 比如 item 为 'pading-left'
...@@ -90,8 +94,8 @@ kity.extendClass(Minder, { ...@@ -90,8 +94,8 @@ kity.extendClass(Minder, {
dir = segment.pop(); dir = segment.pop();
item = segment.join('-'); item = segment.join('-');
if (item in theme) { if (item in items) {
value = theme[item]; value = items[item];
if (Utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) { if (Utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) {
return matcher(value); return matcher(value);
} }
...@@ -127,7 +131,7 @@ KityMinder.registerModule('Theme', { ...@@ -127,7 +131,7 @@ KityMinder.registerModule('Theme', {
}, },
queryValue: function(km) { queryValue: function(km) {
return km.getTheme(); return km.getTheme() || 'default';
} }
}) })
} }
......
...@@ -33,12 +33,13 @@ KityMinder.registerLayout('bottom', kity.createClass({ ...@@ -33,12 +33,13 @@ KityMinder.registerLayout('bottom', kity.createClass({
return box; return box;
}); });
var nodeContentBox = node.getContentBox(); var nodeContentBox = node.getContentBox();
node.setLayoutVector(new kity.Vector(nodeContentBox.cx - 5, nodeContentBox.bottom)); node.setLayoutVector(new kity.Vector(nodeContentBox.cx, nodeContentBox.bottom));
var i, x, y, child, childTreeBox, childContentBox; var i, x, y, child, childTreeBox, childContentBox;
var transform = new kity.Matrix(); var transform = new kity.Matrix();
x = -totalTreeWidth / 2; x = -totalTreeWidth / 2;
for (var i = 0; i < children.length; i++) { for (i = 0; i < children.length; i++) {
child = children[i]; child = children[i];
childTreeBox = childTreeBoxes[i]; childTreeBox = childTreeBoxes[i];
childContentBox = child.getContentBox(); childContentBox = child.getContentBox();
...@@ -52,7 +53,47 @@ KityMinder.registerLayout('bottom', kity.createClass({ ...@@ -52,7 +53,47 @@ KityMinder.registerLayout('bottom', kity.createClass({
children[i].setLayoutTransform(new kity.Matrix().translate(x, y)); children[i].setLayoutTransform(new kity.Matrix().translate(x, y));
x += childTreeBox.width / 2 + children[i].getStyle('margin-right'); x += childTreeBox.width / 2 + children[i].getStyle('margin-right');
} }
if (node.isRoot()) {
var branchBox = this.getBranchBox(children);
var dx = branchBox.cx - nodeContentBox.cx;
children.forEach(function(child) {
child.getLayoutTransform().translate(-dx, 0);
});
}
} }
},
getOrderHint: function(node) {
var hint = [];
var box = node.getLayoutBox();
var offset = 3;
hint.push({
type: 'up',
node: node,
area: {
x: box.left - node.getStyle('margin-left') - offset,
y: box.top,
width: node.getStyle('margin-left'),
height: box.height
},
path: ['M', box.left - offset, box.top, 'L', box.left - offset, box.bottom]
});
hint.push({
type: 'down',
node: node,
area: {
x: box.right + offset,
y: box.top,
width: node.getStyle('margin-right'),
height: box.height
},
path: ['M', box.right + offset, box.top, 'L', box.right + offset, box.bottom]
});
return hint;
} }
})); }));
...@@ -64,5 +105,6 @@ KityMinder.registerConnectProvider('bottom', function(node, parent, connection) ...@@ -64,5 +105,6 @@ KityMinder.registerConnectProvider('bottom', function(node, parent, connection)
pathData.push('L', new kity.Point(pBox.cx, pBox.bottom + parent.getStyle('margin-bottom'))); pathData.push('L', new kity.Point(pBox.cx, pBox.bottom + parent.getStyle('margin-bottom')));
pathData.push('L', new kity.Point(box.cx, pBox.bottom + parent.getStyle('margin-bottom'))); pathData.push('L', new kity.Point(box.cx, pBox.bottom + parent.getStyle('margin-bottom')));
pathData.push('L', new kity.Point(box.cx, box.top)); pathData.push('L', new kity.Point(box.cx, box.top));
connection.setMarker(null);
connection.setPathData(pathData); connection.setPathData(pathData);
}); });
\ No newline at end of file
...@@ -88,19 +88,19 @@ KityMinder.registerLayout('default', kity.createClass({ ...@@ -88,19 +88,19 @@ KityMinder.registerLayout('default', kity.createClass({
x -= parent.getStyle('margin-left') + child.getStyle('margin-right'); x -= parent.getStyle('margin-left') + child.getStyle('margin-right');
} }
// 竖直方向上的布局
y += childTreeBox.height / 2;
if (i > 0) { if (i > 0) {
y += children[i].getStyle('margin-top'); y += children[i].getStyle('margin-top');
} }
// 竖直方向上的布局
y -= childTreeBox.top;
// 设置布局结果 // 设置布局结果
transform = new kity.Matrix().translate(x, y); transform = new kity.Matrix().translate(x, y);
child.setLayoutTransform(transform); child.setLayoutTransform(transform);
y += childTreeBox.height / 2 + child.getStyle('margin-bottom'); y += childTreeBox.bottom + child.getStyle('margin-bottom');
} }
if (parent.isRoot()) { if (parent.isRoot()) {
......
...@@ -21,27 +21,36 @@ KityMinder.registerLayout('filetree', kity.createClass({ ...@@ -21,27 +21,36 @@ KityMinder.registerLayout('filetree', kity.createClass({
if (!children.length) { if (!children.length) {
return false; return false;
} else { } else {
var totalTreeWidth = 0;
// 计算每个 child 的树所占的矩形区域 // 计算每个 child 的树所占的矩形区域
var childTreeBoxes = children.map(function(node, index, children) { var childTreeBoxes = children.map(function(node, index, children) {
var box = _this.getTreeBox([node]); var box = _this.getTreeBox([node]);
return box; return box;
}); });
var nodeContentBox = node.getContentBox(); var nodeContentBox = node.getContentBox();
node.setLayoutVector(new kity.Vector(nodeContentBox.left + 6, nodeContentBox.bottom)); node.setLayoutVector(new kity.Vector(0, nodeContentBox.bottom));
var i, x, y, child, childTreeBox, childContentBox; var i, x, y, child, childTreeBox, childContentBox;
var transform = new kity.Matrix(); var transform = new kity.Matrix();
y = nodeContentBox.bottom + node.getStyle('margin-bottom'); y = nodeContentBox.bottom + node.getStyle('margin-bottom');
for (var i = 0; i < children.length; i++) { for (i = 0; i < children.length; i++) {
child = children[i]; child = children[i];
childTreeBox = childTreeBoxes[i]; childTreeBox = childTreeBoxes[i];
childContentBox = child.getContentBox(); childContentBox = child.getContentBox();
x = child.getStyle('margin-left') - childContentBox.left;
if (!childContentBox.width) continue; if (!childContentBox.width) continue;
x = 10;
y += child.getStyle('margin-top'); y += child.getStyle('margin-top');
child.setLayoutTransform(new kity.Matrix().translate(x, y)); y -= childTreeBox.top;
y += childTreeBox.height + children[i].getStyle('margin-bottom');
// 设置布局结果
transform = new kity.Matrix().translate(x, y);
child.setLayoutTransform(transform);
y += childTreeBox.bottom + child.getStyle('margin-bottom');
} }
} }
}, },
...@@ -81,8 +90,8 @@ KityMinder.registerConnectProvider('filetree', function(node, parent, connection ...@@ -81,8 +90,8 @@ KityMinder.registerConnectProvider('filetree', function(node, parent, connection
var box = node.getLayoutBox(), var box = node.getLayoutBox(),
pBox = parent.getLayoutBox(); pBox = parent.getLayoutBox();
var pathData = []; var pathData = [];
var left = pBox.left + 5; var left = parent.getLayoutPoint().x;
pathData.push('M', new kity.Point(left, pBox.bottom)); pathData.push('M', new kity.Point(left, pBox.bottom + 1));
pathData.push('L', new kity.Point(left, box.cy)); pathData.push('L', new kity.Point(left, box.cy));
pathData.push('L', new kity.Point(box.left, box.cy)); pathData.push('L', new kity.Point(box.left, box.cy));
connection.setPathData(pathData); connection.setPathData(pathData);
......
...@@ -228,6 +228,7 @@ var TreeDragger = kity.createClass('TreeDragger', { ...@@ -228,6 +228,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
var sources = this._dragSources; var sources = this._dragSources;
var ancestor = MinderNode.getCommonAncestor(sources); var ancestor = MinderNode.getCommonAncestor(sources);
// 只有一个元素选中,公共祖先是其父
if (ancestor == sources[0]) ancestor = sources[0].parent; if (ancestor == sources[0]) ancestor = sources[0].parent;
if (sources.length === 0 || ancestor != sources[0].parent) { if (sources.length === 0 || ancestor != sources[0].parent) {
......
...@@ -61,7 +61,7 @@ KityMinder.registerModule('Expand', function() { ...@@ -61,7 +61,7 @@ KityMinder.registerModule('Expand', function() {
/** /**
* 策略 2:把操作进行到儿子 * 策略 2:把操作进行到儿子
*/ */
DEEP_TO_CHILD: generateDeepPolicy(1), DEEP_TO_CHILD: generateDeepPolicy(2),
/** /**
* 策略 3:把操作进行到叶子 * 策略 3:把操作进行到叶子
...@@ -118,6 +118,7 @@ KityMinder.registerModule('Expand', function() { ...@@ -118,6 +118,7 @@ KityMinder.registerModule('Expand', function() {
base: Command, base: Command,
execute: function(km) { execute: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if (!nodes.length) nodes.push(km.getRoot());
nodes.forEach(function(node) { nodes.forEach(function(node) {
node.expand(EXPAND_POLICY.DEEP_TO_LEAF); node.expand(EXPAND_POLICY.DEEP_TO_LEAF);
}); });
...@@ -129,9 +130,9 @@ KityMinder.registerModule('Expand', function() { ...@@ -129,9 +130,9 @@ KityMinder.registerModule('Expand', function() {
var CollapseNodeCommand = kity.createClass('CollapseNodeCommand', { var CollapseNodeCommand = kity.createClass('CollapseNodeCommand', {
base: Command, base: Command,
execute: function(km) { execute: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getRoot().getChildren();
nodes.forEach(function(node) { nodes.forEach(function(node) {
node.collapse(EXPAND_POLICY.DEEP_TO_LEAF); node.collapse();
}); });
}, },
queryState: function(km) { queryState: function(km) {
......
KityMinder.registerModule( "hyperlink", function () { KityMinder.registerModule("hyperlink", function() {
var linkShapePath = "M16.614,10.224h-1.278c-1.668,0-3.07-1.07-3.599-2.556h4.877c0.707,0,1.278-0.571,1.278-1.278V3.834 c0-0.707-0.571-1.278-1.278-1.278h-4.877C12.266,1.071,13.668,0,15.336,0h1.278c2.116,0,3.834,1.716,3.834,3.834V6.39 C20.448,8.508,18.73,10.224,16.614,10.224z M5.112,5.112c0-0.707,0.573-1.278,1.278-1.278h7.668c0.707,0,1.278,0.571,1.278,1.278 S14.765,6.39,14.058,6.39H6.39C5.685,6.39,5.112,5.819,5.112,5.112z M2.556,3.834V6.39c0,0.707,0.573,1.278,1.278,1.278h4.877 c-0.528,1.486-1.932,2.556-3.599,2.556H3.834C1.716,10.224,0,8.508,0,6.39V3.834C0,1.716,1.716,0,3.834,0h1.278 c1.667,0,3.071,1.071,3.599,2.556H3.834C3.129,2.556,2.556,3.127,2.556,3.834z"; var linkShapePath = "M16.614,10.224h-1.278c-1.668,0-3.07-1.07-3.599-2.556h4.877c0.707,0,1.278-0.571,1.278-1.278V3.834 c0-0.707-0.571-1.278-1.278-1.278h-4.877C12.266,1.071,13.668,0,15.336,0h1.278c2.116,0,3.834,1.716,3.834,3.834V6.39 C20.448,8.508,18.73,10.224,16.614,10.224z M5.112,5.112c0-0.707,0.573-1.278,1.278-1.278h7.668c0.707,0,1.278,0.571,1.278,1.278 S14.765,6.39,14.058,6.39H6.39C5.685,6.39,5.112,5.819,5.112,5.112z M2.556,3.834V6.39c0,0.707,0.573,1.278,1.278,1.278h4.877 c-0.528,1.486-1.932,2.556-3.599,2.556H3.834C1.716,10.224,0,8.508,0,6.39V3.834C0,1.716,1.716,0,3.834,0h1.278 c1.667,0,3.071,1.071,3.599,2.556H3.834C3.129,2.556,2.556,3.127,2.556,3.834z";
return { return {
"commands": { "commands": {
"hyperlink": kity.createClass( "hyperlink", { "hyperlink": kity.createClass("hyperlink", {
base: Command, base: Command,
execute: function ( km, url ) { execute: function(km, url) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
n.setData( 'hyperlink', url ); n.setData('hyperlink', url);
n.render(); n.render();
} ); });
km.layout(); km.layout();
}, },
queryState: function ( km ) { queryState: function(km) {
var nodes = km.getSelectedNodes(), var nodes = km.getSelectedNodes(),
result = 0; result = 0;
if ( nodes.length === 0 ) { if (nodes.length === 0) {
return -1; return -1;
} }
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
if ( n && n.getData( 'hyperlink' ) ) { if (n && n.getData('hyperlink')) {
result = 0; result = 0;
return false; return false;
} }
} ); });
return result; return result;
}, },
queryValue: function ( km ) { queryValue: function(km) {
var node = km.getSelectedNode(); var node = km.getSelectedNode();
return node.getData( 'hyperlink' ); return node.getData('hyperlink');
} }
} ), }),
"unhyperlink": kity.createClass( "hyperlink", { "unhyperlink": kity.createClass("hyperlink", {
base: Command, base: Command,
execute: function ( km ) { execute: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
n.setData( 'hyperlink' ); n.setData('hyperlink');
n.render(); n.render();
} ); });
km.layout(); km.layout();
}, },
queryState: function ( km ) { queryState: function(km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
if ( nodes.length === 0 ) { if (nodes.length === 0) {
return -1; return -1;
} }
var link = false; var link = false;
utils.each( nodes, function ( i, n ) { utils.each(nodes, function(i, n) {
if ( n.getData( 'hyperlink' ) ) { if (n.getData('hyperlink')) {
link = true; link = true;
return false; return false;
} }
} ); });
if ( link ) { if (link) {
return 0; return 0;
} }
return -1; return -1;
} }
} ) })
}, },
'renderers': { 'renderers': {
right: kity.createClass('hyperlinkrender', { right: kity.createClass('hyperlinkrender', {
...@@ -74,11 +74,11 @@ KityMinder.registerModule( "hyperlink", function () { ...@@ -74,11 +74,11 @@ KityMinder.registerModule( "hyperlink", function () {
var outline = new kity.Rect(24, 22, -2, -6, 4).fill('rgba(255, 255, 255, 0)'); var outline = new kity.Rect(24, 22, -2, -6, 4).fill('rgba(255, 255, 255, 0)');
linkshape.setPathData( linkShapePath ).fill( '#666' ); linkshape.setPathData(linkShapePath).fill('#666');
link.addShape( outline ); link.addShape(outline);
link.addShape( linkshape ); link.addShape(linkshape);
link.setTarget( '_blank' ); link.setTarget('_blank');
link.setStyle( 'cursor', 'pointer' ); link.setStyle('cursor', 'pointer');
link.on('mouseover', function() { link.on('mouseover', function() {
...@@ -91,7 +91,7 @@ KityMinder.registerModule( "hyperlink", function () { ...@@ -91,7 +91,7 @@ KityMinder.registerModule( "hyperlink", function () {
shouldRender: function(node) { shouldRender: function(node) {
return node.getData( 'hyperlink' ); return node.getData('hyperlink');
}, },
update: function(link, node, box) { update: function(link, node, box) {
...@@ -113,4 +113,4 @@ KityMinder.registerModule( "hyperlink", function () { ...@@ -113,4 +113,4 @@ KityMinder.registerModule( "hyperlink", function () {
} }
}; };
} ); });
\ No newline at end of file \ No newline at end of file
...@@ -104,7 +104,7 @@ KityMinder.registerModule('image', function() { ...@@ -104,7 +104,7 @@ KityMinder.registerModule('image', function() {
base: KityMinder.Renderer, base: KityMinder.Renderer,
create: function(node) { create: function(node) {
return new kity.Image(); return new kity.Image(node.getData('image'));
}, },
shouldRender: function(node) { shouldRender: function(node) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -57,13 +57,60 @@ var RemoveNodeCommand = kity.createClass('RemoverNodeCommand', { ...@@ -57,13 +57,60 @@ var RemoveNodeCommand = kity.createClass('RemoverNodeCommand', {
} }
}); });
var EditNodeCommand = kity.createClass('EditNodeCommand', {
base: Command,
execute: function(km) {
var selectedNode = km.getSelectedNode();
if (!selectedNode) {
return null;
}
km.select(selectedNode, true);
km.textEditNode(selectedNode);
},
queryState: function(km) {
var selectedNode = km.getSelectedNode();
if (!selectedNode) {
return -1;
} else {
return 0;
}
},
isNeedUndo: function() {
return false;
}
});
KityMinder.registerModule('NodeModule', function() { KityMinder.registerModule('NodeModule', function() {
return { return {
commands: { commands: {
'AppendChildNode': AppendChildCommand, 'AppendChildNode': AppendChildCommand,
'AppendSiblingNode': AppendSiblingCommand, 'AppendSiblingNode': AppendSiblingCommand,
'RemoveNode': RemoveNodeCommand 'RemoveNode': RemoveNodeCommand,
} 'EditNode': EditNodeCommand
},
'contextmenu': [{
label: this.getLang('node.appendsiblingnode'),
exec: function() {
this.execCommand('AppendSiblingNode', this.getLang('topic'));
},
cmdName: 'appendsiblingnode'
}, {
label: this.getLang('node.appendchildnode'),
exec: function() {
this.execCommand('AppendChildNode', this.getLang('topic'));
},
cmdName: 'appendchildnode'
}, {
label: this.getLang('node.editnode'),
exec: function() {
this.execCommand('EditNode');
},
cmdName: 'editnode'
}, {
label: this.getLang('node.removenode'),
cmdName: 'RemoveNode'
}, {
divider: 1
}]
}; };
}); });
\ No newline at end of file
KityMinder.registerModule( "NodeText", function () {
return {
events: {
'renderNodeCenter': function ( e ) {
var node = e.node;
var width = node.getContRc().getWidth();
var textShape = new kity.Text( node.getData( 'text' ) || '' );
textShape.setAttr( '_nodeTextShape', true );
node.getContRc().appendShape( textShape );
var style = this.getCurrentLayoutStyle()[ node.getType() ];
textShape.fill( style.color ).setSize( style.fontSize );
textShape.setTranslate( width + style.spaceLeft, 0 );
textShape.setVerticalAlign( 'middle' );
}
}
}
} );
\ No newline at end of file
...@@ -32,7 +32,7 @@ KityMinder.registerModule('PriorityModule', function() { ...@@ -32,7 +32,7 @@ KityMinder.registerModule('PriorityModule', function() {
.setSize(this.width, this.height); .setSize(this.width, this.height);
number = new kity.Text() number = new kity.Text()
.setX(this.width / 2 + 0.5).setY(this.height / 2 + 0.5) .setX(this.width / 2 + 0.5).setY(this.height / 2 - 0.5)
.setTextAnchor('middle') .setTextAnchor('middle')
.setVerticalAlign('middle') .setVerticalAlign('middle')
.setFontSize(12) .setFontSize(12)
...@@ -73,6 +73,10 @@ KityMinder.registerModule('PriorityModule', function() { ...@@ -73,6 +73,10 @@ KityMinder.registerModule('PriorityModule', function() {
if (val) break; if (val) break;
} }
return val; return val;
},
queryState: function(km) {
return km.getSelectedNodes().length ? 0 : -1;
} }
}); });
return { return {
......
...@@ -65,6 +65,10 @@ KityMinder.registerModule('ProgressModule', function() { ...@@ -65,6 +65,10 @@ KityMinder.registerModule('ProgressModule', function() {
if (val) break; if (val) break;
} }
return val; return val;
},
queryState: function(km) {
return km.getSelectedNodes().length ? 0 : -1;
} }
}); });
......
...@@ -100,7 +100,7 @@ KityMinder.registerModule('View', function() { ...@@ -100,7 +100,7 @@ KityMinder.registerModule('View', function() {
enableReadOnly: false enableReadOnly: false
}); });
var CameraCommand = kity.createClass("CameraCommand", { var CameraCommand = kity.createClass('CameraCommand', {
base: Command, base: Command,
execute: function(km, focusNode, noAnimate) { execute: function(km, focusNode, noAnimate) {
focusNode = focusNode || km.getRoot(); focusNode = focusNode || km.getRoot();
...@@ -112,7 +112,7 @@ KityMinder.registerModule('View', function() { ...@@ -112,7 +112,7 @@ KityMinder.registerModule('View', function() {
if (noAnimate) { if (noAnimate) {
km.getRenderContainer().translate(dx, dy); km.getRenderContainer().translate(dx, dy);
} else { } else {
km.getRenderContainer().fxTranslate(dx, dy, 1000, "easeOutQuint"); km.getRenderContainer().fxTranslate(dx, dy, 1000, 'easeOutQuint');
} }
this.setContentChanged(false); this.setContentChanged(false);
}, },
......
KityMinder.registerModule( 'Zoom', function () { KityMinder.registerModule('Zoom', function() {
var me = this; var me = this;
var timeline; var timeline;
me.setDefaultOptions( 'zoom', [ 50, 80, 100, 120, 150, 200 ] ); me.setDefaultOptions('zoom', [50, 80, 100, 120, 150, 200]);
function zoomMinder( minder, zoom ) { function zoomMinder(minder, zoom) {
var paper = minder.getPaper(); var paper = minder.getPaper();
var viewport = paper.getViewPort(); var viewport = paper.getViewPort();
if ( !zoom ) return; if (!zoom) return;
var animator = new kity.Animator( { var animator = new kity.Animator({
beginValue: viewport.zoom, beginValue: viewport.zoom,
finishValue: zoom / 100, finishValue: zoom / 100,
setter: function ( target, value ) { setter: function(target, value) {
viewport.zoom = value; viewport.zoom = value;
target.setViewPort( viewport ); target.setViewPort(viewport);
} }
} ); });
minder.zoom = zoom; minder.zoom = zoom;
if ( timeline ) { if (timeline) {
timeline.pause(); timeline.pause();
} }
timeline = animator.start( paper, 500, 'ease' ); timeline = animator.start(paper, 500, 'ease', function() {
minder.refresh(300);
});
} }
var ZoomCommand = kity.createClass( 'Zoom', { var ZoomCommand = kity.createClass('Zoom', {
base: Command, base: Command,
execute: zoomMinder, execute: zoomMinder,
queryValue: function ( minder ) { queryValue: function(minder) {
return minder.zoom; return minder.zoom;
} }
} ); });
var ZoomInCommand = kity.createClass( 'ZoomInCommand', { var ZoomInCommand = kity.createClass('ZoomInCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function(minder) {
zoomMinder( minder, this.nextValue( minder ) ); zoomMinder(minder, this.nextValue(minder));
}, },
queryState: function ( minder ) { queryState: function(minder) {
return ~this.nextValue( minder ); return (~this.nextValue(minder));
}, },
nextValue: function ( minder ) { nextValue: function(minder) {
var stack = minder.getOptions( 'zoom' ), var stack = minder.getOptions('zoom'),
i; i;
for ( i = 0; i < stack.length; i++ ) { for (i = 0; i < stack.length; i++) {
if ( stack[ i ] > minder.zoom ) return stack[ i ]; if (stack[i] > minder.zoom) return stack[i];
} }
return 0; return 0;
}, },
enableReadOnly: false enableReadOnly: false
} ); });
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', { var ZoomOutCommand = kity.createClass('ZoomOutCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function(minder) {
zoomMinder( minder, this.nextValue( minder ) ); zoomMinder(minder, this.nextValue(minder));
}, },
queryState: function ( minder ) { queryState: function(minder) {
return ~this.nextValue( minder ); return (~this.nextValue(minder));
}, },
nextValue: function ( minder ) { nextValue: function(minder) {
var stack = minder.getOptions( 'zoom' ), var stack = minder.getOptions('zoom'),
i; i;
for ( i = stack.length - 1; i >= 0; i-- ) { for (i = stack.length - 1; i >= 0; i--) {
if ( stack[ i ] < minder.zoom ) return stack[ i ]; if (stack[i] < minder.zoom) return stack[i];
} }
return 0; return 0;
}, },
enableReadOnly: false enableReadOnly: false
} ); });
return { return {
init: function () { init: function() {
this.zoom = 100; this.zoom = 100;
}, },
commands: { commands: {
...@@ -82,49 +84,49 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -82,49 +84,49 @@ KityMinder.registerModule( 'Zoom', function () {
'zoom': ZoomCommand 'zoom': ZoomCommand
}, },
events: { events: {
'normal.keydown': function ( e ) { 'normal.keydown': function(e) {
var me = this; var me = this;
var originEvent = e.originEvent; var originEvent = e.originEvent;
var keyCode = originEvent.keyCode || originEvent.which; var keyCode = originEvent.keyCode || originEvent.which;
if ( keymap[ '=' ] == keyCode ) { if (keymap['='] == keyCode) {
me.execCommand( 'zoom-in' ); me.execCommand('zoom-in');
} }
if ( keymap[ '-' ] == keyCode ) { if (keymap['-'] == keyCode) {
me.execCommand( 'zoom-out' ); me.execCommand('zoom-out');
} }
}, },
'ready': function () { 'ready': function() {
this._zoomValue = 1; this._zoomValue = 1;
}, },
'normal.mousewheel readonly.mousewheel': function ( e ) { 'normal.mousewheel readonly.mousewheel': function(e) {
if ( !e.originEvent.ctrlKey ) return; if (!e.originEvent.ctrlKey) return;
var delta = e.originEvent.wheelDelta; var delta = e.originEvent.wheelDelta;
var me = this; var me = this;
if ( !kity.Browser.mac ) { if (!kity.Browser.mac) {
delta = -delta; delta = -delta;
} }
// 稀释 // 稀释
if ( Math.abs( delta ) > 100 ) { if (Math.abs(delta) > 100) {
clearTimeout( this._wheelZoomTimeout ); clearTimeout(this._wheelZoomTimeout);
} else { } else {
return; return;
} }
this._wheelZoomTimeout = setTimeout( function () { this._wheelZoomTimeout = setTimeout(function() {
var value; var value;
var lastValue = me.getPaper()._zoom || 1; var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) { if (delta < 0) {
me.execCommand( 'zoom-in' ); me.execCommand('zoom-in');
} else if ( delta > 0 ) { } else if (delta > 0) {
me.execCommand( 'zoom-out' ); me.execCommand('zoom-out');
} }
}, 100 ); }, 100);
e.originEvent.preventDefault(); e.originEvent.preventDefault();
} }
} }
}; };
} ); });
\ No newline at end of file \ No newline at end of file
This diff is collapsed.
This diff is collapsed.
KityMinder.registerTemplate('bottom', { KityMinder.registerTemplate('structure', {
name: '组织结构图',
getLayout: function(node) { getLayout: function(node) {
...@@ -6,9 +8,5 @@ KityMinder.registerTemplate('bottom', { ...@@ -6,9 +8,5 @@ KityMinder.registerTemplate('bottom', {
if (node.isRoot()) return 'bottom'; if (node.isRoot()) return 'bottom';
return 'filetree'; return 'filetree';
},
getTheme: function(node) {
return node ? (node.isRoot() ? 'bottom' : 'filetree') : 'default';
} }
}); });
\ No newline at end of file
KityMinder.registerTheme('bottom', {
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': 'none',
'root-font-size': 24,
'root-padding': [15, 25],
'root-margin': 0,
'root-radius': 0,
'root-space': 10,
'main-color': '#333',
'main-background': '#a4c5c0',
'main-stroke': 'none',
'main-font-size': 16,
'main-padding': [6, 20],
'main-margin': [30, 0, 10, 0],
'main-radius': 5,
'main-space': 5,
'sub-color': 'white',
'sub-background': 'none',
'sub-stroke': 'white',
'sub-font-size': 12,
'sub-padding': [5, 10],
'sub-margin': [5, 15, 10, 5],
'sub-radius': 5,
'sub-space': 5,
'connect-color': 'white',
'connect-width': 2,
'connect-radius': 5,
'selected-background': 'rgb(254, 219, 0)'
});
\ No newline at end of file
KityMinder.registerTheme('default', { KityMinder.registerTheme('default', {
'background': 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowQzg5QTQ0NDhENzgxMUUzOENGREE4QTg0RDgzRTZDNyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowQzg5QTQ0NThENzgxMUUzOENGREE4QTg0RDgzRTZDNyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkMwOEQ1NDRGOEQ3NzExRTM4Q0ZEQThBODREODNFNkM3IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkMwOEQ1NDUwOEQ3NzExRTM4Q0ZEQThBODREODNFNkM3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+e9P33AAAACVJREFUeNpisXJ0YUACTAyoAMr/+eM7EGGRZ4FQ7BycEAZAgAEAHbEGtkoQm/wAAAAASUVORK5CYII=) repeat',
'name': '脑图经典',
'root-color': '#430', 'root-color': '#430',
'root-background': '#e9df98', 'root-background': '#e9df98',
'root-stroke': 'none', 'root-stroke': 'none',
'root-font-size': 24, 'root-font-size': 24,
'root-padding': [15, 25], 'root-padding': [15, 25],
'root-margin': 100, 'root-margin': [30, 100],
'root-radius': 30, 'root-radius': 30,
'root-space': 10, 'root-space': 10,
'root-shadow': 'rgba(0, 0, 0, .25)', 'root-shadow': 'rgba(0, 0, 0, .25)',
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -42,7 +42,7 @@ KM.ui.define('popup', { ...@@ -42,7 +42,7 @@ KM.ui.define('popup', {
}, },
hide: function () { hide: function () {
this.root().css('display', 'none'); this.root().css('display', 'none');
this.trigger('afterhide') this.trigger('afterhide');
}, },
attachTo: function ($obj, posObj) { attachTo: function ($obj, posObj) {
var me = this var me = this
......
This diff is collapsed.
This diff is collapsed.
themes/default/images/baiducloud.png

1.34 KB | W: | H:

themes/default/images/baiducloud.png

1.62 KB | W: | H:

themes/default/images/baiducloud.png
themes/default/images/baiducloud.png
themes/default/images/baiducloud.png
themes/default/images/baiducloud.png
  • 2-up
  • Swipe
  • Onion skin
themes/default/images/share.png

1.14 KB | W: | H:

themes/default/images/share.png

1.46 KB | W: | H:

themes/default/images/share.png
themes/default/images/share.png
themes/default/images/share.png
themes/default/images/share.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment