Commit e74b0527 authored by techird's avatar techird

1.2.0 preview

parent 869129ba
( function ( utils ) {
(function(utils) {
//todo 这里先写死成中文
var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">';
content += '<style>';
......@@ -35,36 +35,51 @@
KM.registerWidget( 'hyperlink', {
KM.registerWidget('hyperlink', {
tpl: content,
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.hyperlink' ),
initContent: function(km) {
var lang = km.getLang('dialogs.hyperlink'),
html;
if ( lang ) {
html = $.parseTmpl( this.tpl, utils.extend( {
if (lang) {
html = $.parseTmpl(this.tpl, utils.extend({
'container': 'hyperlink'
}, lang ) );
}, lang));
}
this.root().html( html );
this.root().html(html);
},
initEvent: function ( km, $w ) {
$w.find( '#hyperlink_insert' ).on( 'click', function () {
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() );
initEvent: function(km, $w) {
var $btn = $w.find('#hyperlink_insert');
$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.find( '#hyperlink_href' ).on( 'keydown', function ( e ) {
if ( e.keyCode === 13 ) {
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() );
$w.kmui().hide();
});
$w.find('#hyperlink_href').on('keydown', function(e) {
if (e.keyCode === 13) {
$btn.click();
}
} );
var url = km.queryCommandValue( 'hyperlink' );
var $input = $w.find( '#hyperlink_href' );
$input.val( url || 'http://' );
setTimeout( function () {
$input.focus()
} )
});
var url = km.queryCommandValue('hyperlink');
var $input = $w.find('#hyperlink_href');
$input.val(url || 'http://');
setTimeout(function() {
$input.select();
});
},
width: 400
} );
} )( KM.Utils );
\ No newline at end of file
});
})(KM.Utils);
\ No newline at end of file
......@@ -49,24 +49,39 @@
this.root().html(html);
},
initEvent: function(km, $w) {
$w.find('#image_insert').on('click', function() {
km.execCommand('image', $w.find('#image_href').val());
var $btn = $w.find('#image_insert').attr('disabled', 'disabled');
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.find('#image_href').on('keydown', function(e) {
$href.on('keydown', function(e) {
if (e.keyCode === 13) {
km.execCommand('image', $w.find('#image_href').val());
$w.kmui().hide();
$btn.click();
}
}).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() {
$input.focus();
$input.select();
});
},
width: 400
......
......@@ -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 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}
#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: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{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-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:hover a:before{background-position:0 -48px}
......
......@@ -113,20 +113,6 @@ button {
}
}
#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;
}
.draft-menu {
......
......@@ -31,10 +31,9 @@
'layout/bottom.js',
'layout/filetree.js',
'theme/default.js',
'theme/bottom.js',
'theme/filetree.js',
'theme/snow.js',
'theme/fresh.js',
'template/bottom.js',
'template/structure.js',
'module/node.js',
'module/text.js',
'module/expand.js',
......@@ -58,7 +57,6 @@
'module/basestyle.js',
'module/font.js',
'module/zoom.js',
'module/nodetext.js',
'module/hyperlink.js',
'module/arrange.js',
'ui/jquery-ui-1.10.4.custom.min.js',
......@@ -86,7 +84,7 @@
'adapter/color.js',
'adapter/saveto.js',
'adapter/tooltips.js',
//'adapter/layout.js',
'adapter/face.js',
'adapter/node.js',
'adapter/contextmenu.js',
'adapter/dialog.js',
......
......@@ -6,7 +6,6 @@
<meta name="keyword" content="脑图,kity,svg,minder,百度,fex,前端,在线">
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<script src="lib/jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js" charset="utf-8"></script>
<script type="text/javascript">
......@@ -36,6 +35,7 @@
<body>
<div id="kityminder" onselectstart="return false"></div>
<div id="share-dialog" >
<h3>URL分享:</h3>
<p>
......
......@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
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
//readOnly: true
......
KityMinder.LANG['zh-cn'] = {
'template': {
'default': '思维导图',
'structure': '组织结构图'
},
'theme': {
'default': '脑图经典',
'snow': '温柔冷光',
'fresh': '文艺小清新'
},
'maintopic': '中心主题',
'topic': '分支主题',
'tooltips': {
......@@ -21,9 +30,11 @@ KityMinder.LANG['zh-cn'] = {
'preference': '偏好设置',
'image': '插入图片',
'hyperlink': '插入链接',
'unhyperlink': "删除链接",
'expandnode': "展开节点",
'collapsenode': "收起节点"
'unhyperlink': '删除链接',
'expandnode': '展开节点',
'collapsenode': '收起节点',
'template': '模板',
'theme': '皮肤'
},
'popupcolor': {
'clearColor': '清空颜色',
......@@ -72,11 +83,17 @@ KityMinder.LANG['zh-cn'] = {
},
'hyperlink': {
'hyperlink': '插入超链接',
'unhyperlink': "取消超链接"
'unhyperlink': '取消超链接'
},
'image': {
'image': '插入图片',
'removeimage': '删除图片'
},
'marker': {
'marker': '设置进度/优先级'
},
'resource': {
'resource': '设置资源'
}
};
\ No newline at end of file
......@@ -9,27 +9,6 @@ function DraftManager( minder ) {
function init() {
drafts = localStorage.getItem( '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() {
......@@ -58,7 +37,8 @@ function DraftManager( minder ) {
function load() {
if ( current ) {
minder.importData( current.data, "json" );
minder.importData( current.data, 'json' );
minder.execCommand('camera');
}
return current;
}
......@@ -80,8 +60,9 @@ function DraftManager( minder ) {
} else {
current.path = path || current.path;
current.name = minder.getMinderTitle();
current.data = minder.exportData( "json" );
current.sync = false;
var data = minder.exportData( 'json' );
current.sync = current.sync && (data == current.data);
current.data = data;
current.update = new Date();
store();
}
......
This diff is collapsed.
This diff is collapsed.
#social {
position: absolute;
right: 10px;
top: 10px;
line-height: 20px;
text-align: right;
height: 30px;
left: 0;
right: 0;
top: 0;
line-height: 30px;
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 {
padding-right: 28px;
position: relative;
&:after {
content: ' ';
display: block;
position: absolute;
right: 10px;
top: 15px;
top: 12px;
width: 0;
height: 0;
border: solid;
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 {
display: inline-block;
vertical-align: middle;
padding: 0 15px;
height: 35px;
height: 30px;
font-size: 13px;
line-height: 35px;
line-height: 30px;
text-align: center;
border-radius: 5px;
color: #ffffff;
color: #000;
text-decoration: none;
border: none;
margin-left: 5px;
cursor: pointer;
background: #0099f2; /* Old browsers */
/* 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 */
background: none;
border-radius: 2px;
&:hover, &.hover {
background: #009fff;
}
&:active, &.active {
background: darken(#009fff, 10%);
box-shadow: inset 0 2px 3px rgba(0,0,0, .2);
box-shadow: inset 0 1px 3px rgba(0,0,0,.2);
background: #ccc;
color: white;
}
&[disabled] {
background: #AAA;
cursor: default;
}
&.baidu-cloud {
&.share {
padding-left: 35px;
position: relative;
&:before {
......@@ -71,65 +131,79 @@ button {
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/baiducloud.png);
background: url(../themes/default/images/share.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
}
img {
position: relative;
top: 3px;
border-radius: 2px;
margin-right: 7px;
}
&.file-button {
.dropdown;
.niceblue;
&.share {
padding-left: 35px;
border-radius: 5px 5px 0 0;
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;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/share.png) no-repeat;
background: url(../themes/default/images/baiducloud.png);
position: absolute;
left: 7px;
top: 5px;
left: 4px;
top: 2px;
}
}
img {
position: relative;
top: 3px;
border-radius: 2px;
margin-right: 7px;
&:hover a:before {
background-position: 0 -24px;
}
&.user-file {
}
#share-button {
a {
position: relative;
img {
border: none;
outline: none;
}
span.text {
display: inline-block;
&:before {
content: ' ';
display: block;
width: 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 {
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;
border-radius: 5px 5px 0 0;
}
.draft-menu {
.draft-menu.kmui-dropdown-menu {
margin-top: 14px;
margin-left: -1px;
span.update-time {
float: right;
color: #CCC;
......@@ -198,17 +272,30 @@ button {
}
}
}
.user-file-menu {
margin-top: 20px;
.file-menu.kmui-dropdown-menu {
margin-top: 14px;
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 {
position: absolute;
padding: 20px;
border-radius: 4px;
right: 10px;
top: 65px;
left: 50%;
top: 40%;
margin-left: -175px;
margin-top: -100px;
background: white;
width: 350px;
box-shadow: 1px 2px 16px rgba(0, 0, 0, .5);
......@@ -247,22 +334,24 @@ button {
line-height: 28px;
border-radius: 2px;
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 {
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,
currentRange, $dialog,
opt = {
title: this.getLang( 'tooltips' )[ name ] || '',
url: me.getOptions( 'KITYMINDER_HOME_URL' ) + 'dialogs/' + name + '/' + name + '.js',
title: this.getLang('tooltips')[name] || '',
url: me.getOptions('KITYMINDER_HOME_URL') + 'dialogs/' + name + '/' + name + '.js',
};
var $btn = $.kmuibutton( {
var $btn = $.kmuibutton({
icon: name,
title: this.getLang( 'tooltips' )[ name ] || ''
} );
title: this.getLang('tooltips')[name] || ''
});
//加载模版数据
utils.loadFile( document, {
utils.loadFile(document, {
src: opt.url,
tag: "script",
type: "text/javascript",
defer: "defer"
}, function () {
tag: 'script',
type: 'text/javascript',
defer: 'defer'
}, function() {
$dialog = $.kmuimodal( opt );
$dialog = $.kmuimodal(opt);
$dialog.attr( 'id', 'kmui-dialog-' + name ).addClass( 'kmui-dialog-' + name )
.find( '.kmui-modal-body' ).addClass( 'kmui-dialog-' + name + '-body' );
$dialog.attr('id', 'kmui-dialog-' + name).addClass('kmui-dialog-' + name)
.find('.kmui-modal-body').addClass('kmui-dialog-' + name + '-body');
$dialog.kmui().on( 'beforeshow', function () {
$dialog.kmui().on('beforeshow', function() {
var $root = this.root(),
win = null,
offset = null;
if ( !$root.parent()[ 0 ] ) {
me.$container.find( '.kmui-dialog-container' ).append( $root );
if (!$root.parent()[0]) {
me.$container.find('.kmui-dialog-container').append($root);
}
KM.setWidgetBody( name, $dialog, me );
} ).attachTo( $btn )
} );
KM.setWidgetBody(name, $dialog, me);
}).attachTo($btn);
});
me.on( 'interactchange', function () {
var state = this.queryCommandState( name );
$btn.kmui().disabled( state == -1 ).active( state == 1 )
} );
me.on('interactchange', function() {
var state = this.queryCommandState(name);
$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;
} );
\ 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,
label = me.getLang( 'tooltips.' + name ),
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
......@@ -16,92 +16,81 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
$combox = null,
comboboxWidget = null;
utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) {
var p = KityMinder.findProtocal( k );
if ( p.encode ) {
utils.each(KityMinder.getAllRegisteredProtocals(), function(k) {
var p = KityMinder.findProtocal(k);
if (p.encode) {
var text = p.fileDescription + '(' + p.fileExtension + ')';
options.value.push( k );
options.items.push( text );
options.autowidthitem.push( $.wordCountAdaptive( text ), true );
options.value.push(k);
options.items.push(text);
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();
function doDownload( url, filename ) {
var a = document.createElement( 'a' );
a.setAttribute( 'download', filename );
a.setAttribute( 'href', url );
document.body.appendChild(a);
var evt;
try {
evt = new MouseEvent( 'click' );
} catch ( error ) {
evt = document.createEvent( 'MouseEvents' );
evt.initEvent( 'click', true, true );
}
a.dispatchEvent( evt );
document.body.removeChild(a);
function doProxyDownload(url, filename, type) {
var content = url.split(',')[1];
var $form = $('<form></form>').attr({
'action': 'http://172.22.73.36/naotu/download.php',
'method': 'POST'
});
var $content = $('<input />').attr({
name: 'content',
type: 'hidden',
value: decodeURIComponent(content)
}).appendTo($form);
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 () {
var iev = 0;
var ieold = ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) );
var trident = !! navigator.userAgent.match( /Trident\/7.0/ );
var rv = navigator.userAgent.indexOf( "rv:11.0" );
if ( ieold ) iev = new Number( RegExp.$1 );
if ( navigator.appVersion.indexOf( "MSIE 10" ) != -1 ) iev = 10;
if ( trident && rv != -1 ) iev = 11;
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 );
};
function doDownload(url, filename, type) {
if (kity.Browser.ie || ~window.location.href.indexOf('naotu.baidu.com')) {
return doProxyDownload(url, filename, type);
}
var a = document.createElement('a');
a.setAttribute('download', filename);
a.setAttribute('href', url);
a.click();
}
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
var data = me.exportData( res.value );
var p = KityMinder.findProtocal( res.value );
comboboxWidget.on('comboboxselect', function(evt, res) {
var data = me.exportData(res.value);
var p = KityMinder.findProtocal(res.value);
var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) {
var url = 'data:' + (p.mineType || 'text/plain') + '; utf-8,' + encodeURIComponent( data );
if ( ie_ver() > 0 ) {
if ( p.fileExtension === '.km' ) {
doSave( 'application/x-javascript', data, me.getMinderTitle() );
} else if ( p.fileExtension === '.svg' ) {
//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 );
}
} );
if (typeof(data) == 'string') {
var url = 'data:' + (p.mineType || 'text/plain') + '; utf-8,' + encodeURIComponent(data);
doDownload(url, filename, 'text');
} else if (data && data.then) {
data.then(function(url) {
doDownload(url, filename, 'base64');
});
}
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
}).on('beforeshow', function() {
if ($combox.parent().length === 0) {
$combox.appendTo(me.$container.find('.kmui-dialog-container'));
}
} ).on( 'aftercomboboxselect', function () {
}).on('aftercomboboxselect', function() {
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, {
},
getOrderHint: function(refer) {
return this.getLayoutInstance().getOrderHint(this);
return this.parent.getLayoutInstance().getOrderHint(this);
},
getExpandPosition: function() {
......@@ -169,13 +169,22 @@ kity.extendClass(Minder, {
refresh: function(duration) {
this.getRoot().preTraverse(function(node) { node.render(); });
return this.layout(duration);
this.layout(duration).fire('contentchange').fire('interactchange');
return this;
},
applyLayoutResult: function(root, duration) {
root = root || this.getRoot();
var me = this;
function applyMatrix(node, matrix) {
node.getRenderContainer().setMatrix(node._lastLayoutTransform = matrix);
me.fire('layoutapply', {
node: node,
matrix: matrix
});
}
function apply(node, pMatrix) {
var matrix = node.getLayoutTransform().merge(pMatrix);
var lastMatrix = node._lastLayoutTransform || new kity.Matrix();
......@@ -193,33 +202,23 @@ kity.extendClass(Minder, {
// 如果要求以动画形式来更新,创建动画
if (duration > 0) {
node._layoutTimeline = new kity.Animator(lastMatrix, matrix, function(node, value) {
node.getRenderContainer().setMatrix(node._lastLayoutTransform = value);
me.fire('layoutapply', {
node: node,
matrix: value
});
}).start(node, duration, 'ease').on('finish', function() {
// 可能性能低的时候会丢帧
me.fire('layoutapply', {
node: node,
matrix: matrix
});
me.fire('layoutfinish', {
node: node,
matrix: matrix
node._layoutTimeline = new kity.Animator(lastMatrix, matrix, applyMatrix)
.start(node, duration, 'ease')
.on('finish', function() {
// 可能性能低的时候会丢帧
setTimeout(function() {
applyMatrix(node, matrix);
me.fire('layoutfinish', {
node: node,
matrix: matrix
});
});
});
});
}
// 否则直接更新
else {
node.getRenderContainer().setMatrix(matrix);
node._lastLayoutTransform = matrix;
me.fire('layoutapply', {
node: node,
matrix: matrix
});
applyMatrix(node, matrix);
me.fire('layoutfinish', {
node: node,
matrix: matrix
......
......@@ -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 = {
'root': 'maintopic',
'main': '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, {
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;
json = exportNode(this.getRoot());
......@@ -67,6 +51,9 @@ kity.extendClass(Minder, {
protocal: protocal
}, true)) === true) return;
json.template = this.getTemplate();
json.theme = this.getTheme();
if (protocal) {
return protocal.encode(json, this);
} else {
......@@ -119,6 +106,24 @@ kity.extendClass(Minder, {
},
_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));
// 删除当前所有节点
......@@ -126,9 +131,20 @@ kity.extendClass(Minder, {
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);
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);
......
......@@ -2,20 +2,28 @@ utils.extend(KityMinder, {
_templates: {},
registerTemplate: function(name, supports) {
KityMinder._templates[name] = supports;
},
getTemplateList: function() {
return KityMinder._templates;
}
});
KityMinder.registerTemplate('default', {});
kity.extendClass(Minder, (function() {
var originGetTheme = Minder.prototype.getTheme;
return {
useTemplate: function(name) {
this._template = name;
useTemplate: function(name, duration) {
this.setTemplate(name);
this.refresh(duration || 800);
},
this.getRoot().traverse(function(node) {
node.render();
});
getTemplate: function() {
return this._template || null;
},
this.layout(300);
setTemplate: function(name) {
this._template = name || null;
},
getTemplateSupports: function() {
......@@ -55,8 +63,8 @@ KityMinder.registerModule('TemplateModule', {
minder.useTemplate(name);
},
queryCommandValue: function(minder) {
return minder._template;
queryValue: function(minder) {
return minder.getTemplate() || 'default';
}
})
}
......
......@@ -36,6 +36,10 @@ Utils.extend(KityMinder, {
// 首个注册的主题为默认主题
if (!KityMinder._defaultTheme) KityMinder._defaultTheme = name;
},
getThemeList: function() {
return KityMinder._themes;
}
});
......@@ -46,21 +50,16 @@ kity.extendClass(Minder, {
* @param {String} name 要使用的主题的名称
*/
useTheme: function(name) {
if (!KityMinder._themes[name]) {
return false;
}
this._theme = name;
this.setTheme(name);
this.refresh(800);
this.getRoot().traverse(function(node) {
node.render();
});
this.getRoot().layout();
return true;
},
setTheme: function(name) {
this._theme = name || null;
this.getPaper().getContainer().style.background = this.getStyle('background');
return true;
},
/**
......@@ -68,7 +67,12 @@ kity.extendClass(Minder, {
* @return {[type]} [description]
*/
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, {
* @param {String} item 样式名称
*/
getStyle: function(item, node) {
var theme = KityMinder._themes[this.getTheme(node)];
var items = this.getThemeItems(node);
var segment, dir, selector, value, matcher;
if (item in theme) return theme[item];
if (item in items) return items[item];
// 尝试匹配 CSS 数组形式的值
// 比如 item 为 'pading-left'
......@@ -90,8 +94,8 @@ kity.extendClass(Minder, {
dir = segment.pop();
item = segment.join('-');
if (item in theme) {
value = theme[item];
if (item in items) {
value = items[item];
if (Utils.isArray(value) && (matcher = cssLikeValueMatcher[dir])) {
return matcher(value);
}
......@@ -127,7 +131,7 @@ KityMinder.registerModule('Theme', {
},
queryValue: function(km) {
return km.getTheme();
return km.getTheme() || 'default';
}
})
}
......
......@@ -33,12 +33,13 @@ KityMinder.registerLayout('bottom', kity.createClass({
return box;
});
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 transform = new kity.Matrix();
x = -totalTreeWidth / 2;
for (var i = 0; i < children.length; i++) {
for (i = 0; i < children.length; i++) {
child = children[i];
childTreeBox = childTreeBoxes[i];
childContentBox = child.getContentBox();
......@@ -52,7 +53,47 @@ KityMinder.registerLayout('bottom', kity.createClass({
children[i].setLayoutTransform(new kity.Matrix().translate(x, y));
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)
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, box.top));
connection.setMarker(null);
connection.setPathData(pathData);
});
\ No newline at end of file
......@@ -88,19 +88,19 @@ KityMinder.registerLayout('default', kity.createClass({
x -= parent.getStyle('margin-left') + child.getStyle('margin-right');
}
// 竖直方向上的布局
y += childTreeBox.height / 2;
if (i > 0) {
y += children[i].getStyle('margin-top');
}
// 竖直方向上的布局
y -= childTreeBox.top;
// 设置布局结果
transform = new kity.Matrix().translate(x, y);
child.setLayoutTransform(transform);
y += childTreeBox.height / 2 + child.getStyle('margin-bottom');
y += childTreeBox.bottom + child.getStyle('margin-bottom');
}
if (parent.isRoot()) {
......
......@@ -21,27 +21,36 @@ KityMinder.registerLayout('filetree', kity.createClass({
if (!children.length) {
return false;
} else {
var totalTreeWidth = 0;
// 计算每个 child 的树所占的矩形区域
var childTreeBoxes = children.map(function(node, index, children) {
var box = _this.getTreeBox([node]);
return box;
});
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 transform = new kity.Matrix();
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];
childTreeBox = childTreeBoxes[i];
childContentBox = child.getContentBox();
x = child.getStyle('margin-left') - childContentBox.left;
if (!childContentBox.width) continue;
x = 10;
y += child.getStyle('margin-top');
child.setLayoutTransform(new kity.Matrix().translate(x, y));
y += childTreeBox.height + children[i].getStyle('margin-bottom');
y -= childTreeBox.top;
// 设置布局结果
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
var box = node.getLayoutBox(),
pBox = parent.getLayoutBox();
var pathData = [];
var left = pBox.left + 5;
pathData.push('M', new kity.Point(left, pBox.bottom));
var left = parent.getLayoutPoint().x;
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(box.left, box.cy));
connection.setPathData(pathData);
......
......@@ -228,6 +228,7 @@ var TreeDragger = kity.createClass('TreeDragger', {
var sources = this._dragSources;
var ancestor = MinderNode.getCommonAncestor(sources);
// 只有一个元素选中,公共祖先是其父
if (ancestor == sources[0]) ancestor = sources[0].parent;
if (sources.length === 0 || ancestor != sources[0].parent) {
......
......@@ -61,7 +61,7 @@ KityMinder.registerModule('Expand', function() {
/**
* 策略 2:把操作进行到儿子
*/
DEEP_TO_CHILD: generateDeepPolicy(1),
DEEP_TO_CHILD: generateDeepPolicy(2),
/**
* 策略 3:把操作进行到叶子
......@@ -118,6 +118,7 @@ KityMinder.registerModule('Expand', function() {
base: Command,
execute: function(km) {
var nodes = km.getSelectedNodes();
if (!nodes.length) nodes.push(km.getRoot());
nodes.forEach(function(node) {
node.expand(EXPAND_POLICY.DEEP_TO_LEAF);
});
......@@ -129,9 +130,9 @@ KityMinder.registerModule('Expand', function() {
var CollapseNodeCommand = kity.createClass('CollapseNodeCommand', {
base: Command,
execute: function(km) {
var nodes = km.getSelectedNodes();
var nodes = km.getRoot().getChildren();
nodes.forEach(function(node) {
node.collapse(EXPAND_POLICY.DEEP_TO_LEAF);
node.collapse();
});
},
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";
return {
"commands": {
"hyperlink": kity.createClass( "hyperlink", {
"hyperlink": kity.createClass("hyperlink", {
base: Command,
execute: function ( km, url ) {
execute: function(km, url) {
var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) {
n.setData( 'hyperlink', url );
utils.each(nodes, function(i, n) {
n.setData('hyperlink', url);
n.render();
} );
});
km.layout();
},
queryState: function ( km ) {
queryState: function(km) {
var nodes = km.getSelectedNodes(),
result = 0;
if ( nodes.length === 0 ) {
if (nodes.length === 0) {
return -1;
}
utils.each( nodes, function ( i, n ) {
if ( n && n.getData( 'hyperlink' ) ) {
utils.each(nodes, function(i, n) {
if (n && n.getData('hyperlink')) {
result = 0;
return false;
}
} );
});
return result;
},
queryValue: function ( km ) {
queryValue: function(km) {
var node = km.getSelectedNode();
return node.getData( 'hyperlink' );
return node.getData('hyperlink');
}
} ),
"unhyperlink": kity.createClass( "hyperlink", {
}),
"unhyperlink": kity.createClass("hyperlink", {
base: Command,
execute: function ( km ) {
execute: function(km) {
var nodes = km.getSelectedNodes();
utils.each( nodes, function ( i, n ) {
n.setData( 'hyperlink' );
utils.each(nodes, function(i, n) {
n.setData('hyperlink');
n.render();
} );
});
km.layout();
},
queryState: function ( km ) {
queryState: function(km) {
var nodes = km.getSelectedNodes();
if ( nodes.length === 0 ) {
if (nodes.length === 0) {
return -1;
}
var link = false;
utils.each( nodes, function ( i, n ) {
if ( n.getData( 'hyperlink' ) ) {
utils.each(nodes, function(i, n) {
if (n.getData('hyperlink')) {
link = true;
return false;
}
} );
if ( link ) {
});
if (link) {
return 0;
}
return -1;
}
} )
})
},
'renderers': {
right: kity.createClass('hyperlinkrender', {
......@@ -74,11 +74,11 @@ KityMinder.registerModule( "hyperlink", function () {
var outline = new kity.Rect(24, 22, -2, -6, 4).fill('rgba(255, 255, 255, 0)');
linkshape.setPathData( linkShapePath ).fill( '#666' );
link.addShape( outline );
link.addShape( linkshape );
link.setTarget( '_blank' );
link.setStyle( 'cursor', 'pointer' );
linkshape.setPathData(linkShapePath).fill('#666');
link.addShape(outline);
link.addShape(linkshape);
link.setTarget('_blank');
link.setStyle('cursor', 'pointer');
link.on('mouseover', function() {
......@@ -91,7 +91,7 @@ KityMinder.registerModule( "hyperlink", function () {
shouldRender: function(node) {
return node.getData( 'hyperlink' );
return node.getData('hyperlink');
},
update: function(link, node, box) {
......@@ -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() {
base: KityMinder.Renderer,
create: function(node) {
return new kity.Image();
return new kity.Image(node.getData('image'));
},
shouldRender: function(node) {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -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() {
return {
commands: {
'AppendChildNode': AppendChildCommand,
'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() {
.setSize(this.width, this.height);
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')
.setVerticalAlign('middle')
.setFontSize(12)
......@@ -73,6 +73,10 @@ KityMinder.registerModule('PriorityModule', function() {
if (val) break;
}
return val;
},
queryState: function(km) {
return km.getSelectedNodes().length ? 0 : -1;
}
});
return {
......
......@@ -65,6 +65,10 @@ KityMinder.registerModule('ProgressModule', function() {
if (val) break;
}
return val;
},
queryState: function(km) {
return km.getSelectedNodes().length ? 0 : -1;
}
});
......
......@@ -100,7 +100,7 @@ KityMinder.registerModule('View', function() {
enableReadOnly: false
});
var CameraCommand = kity.createClass("CameraCommand", {
var CameraCommand = kity.createClass('CameraCommand', {
base: Command,
execute: function(km, focusNode, noAnimate) {
focusNode = focusNode || km.getRoot();
......@@ -112,7 +112,7 @@ KityMinder.registerModule('View', function() {
if (noAnimate) {
km.getRenderContainer().translate(dx, dy);
} else {
km.getRenderContainer().fxTranslate(dx, dy, 1000, "easeOutQuint");
km.getRenderContainer().fxTranslate(dx, dy, 1000, 'easeOutQuint');
}
this.setContentChanged(false);
},
......
KityMinder.registerModule( 'Zoom', function () {
KityMinder.registerModule('Zoom', function() {
var me = this;
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 viewport = paper.getViewPort();
if ( !zoom ) return;
if (!zoom) return;
var animator = new kity.Animator( {
var animator = new kity.Animator({
beginValue: viewport.zoom,
finishValue: zoom / 100,
setter: function ( target, value ) {
setter: function(target, value) {
viewport.zoom = value;
target.setViewPort( viewport );
target.setViewPort(viewport);
}
} );
});
minder.zoom = zoom;
if ( timeline ) {
if (timeline) {
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,
execute: zoomMinder,
queryValue: function ( minder ) {
queryValue: function(minder) {
return minder.zoom;
}
} );
});
var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
var ZoomInCommand = kity.createClass('ZoomInCommand', {
base: Command,
execute: function ( minder ) {
zoomMinder( minder, this.nextValue( minder ) );
execute: function(minder) {
zoomMinder(minder, this.nextValue(minder));
},
queryState: function ( minder ) {
return ~this.nextValue( minder );
queryState: function(minder) {
return (~this.nextValue(minder));
},
nextValue: function ( minder ) {
var stack = minder.getOptions( 'zoom' ),
nextValue: function(minder) {
var stack = minder.getOptions('zoom'),
i;
for ( i = 0; i < stack.length; i++ ) {
if ( stack[ i ] > minder.zoom ) return stack[ i ];
for (i = 0; i < stack.length; i++) {
if (stack[i] > minder.zoom) return stack[i];
}
return 0;
},
enableReadOnly: false
} );
});
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
var ZoomOutCommand = kity.createClass('ZoomOutCommand', {
base: Command,
execute: function ( minder ) {
zoomMinder( minder, this.nextValue( minder ) );
execute: function(minder) {
zoomMinder(minder, this.nextValue(minder));
},
queryState: function ( minder ) {
return ~this.nextValue( minder );
queryState: function(minder) {
return (~this.nextValue(minder));
},
nextValue: function ( minder ) {
var stack = minder.getOptions( 'zoom' ),
nextValue: function(minder) {
var stack = minder.getOptions('zoom'),
i;
for ( i = stack.length - 1; i >= 0; i-- ) {
if ( stack[ i ] < minder.zoom ) return stack[ i ];
for (i = stack.length - 1; i >= 0; i--) {
if (stack[i] < minder.zoom) return stack[i];
}
return 0;
},
enableReadOnly: false
} );
});
return {
init: function () {
init: function() {
this.zoom = 100;
},
commands: {
......@@ -82,49 +84,49 @@ KityMinder.registerModule( 'Zoom', function () {
'zoom': ZoomCommand
},
events: {
'normal.keydown': function ( e ) {
'normal.keydown': function(e) {
var me = this;
var originEvent = e.originEvent;
var keyCode = originEvent.keyCode || originEvent.which;
if ( keymap[ '=' ] == keyCode ) {
me.execCommand( 'zoom-in' );
if (keymap['='] == keyCode) {
me.execCommand('zoom-in');
}
if ( keymap[ '-' ] == keyCode ) {
me.execCommand( 'zoom-out' );
if (keymap['-'] == keyCode) {
me.execCommand('zoom-out');
}
},
'ready': function () {
'ready': function() {
this._zoomValue = 1;
},
'normal.mousewheel readonly.mousewheel': function ( e ) {
if ( !e.originEvent.ctrlKey ) return;
'normal.mousewheel readonly.mousewheel': function(e) {
if (!e.originEvent.ctrlKey) return;
var delta = e.originEvent.wheelDelta;
var me = this;
if ( !kity.Browser.mac ) {
if (!kity.Browser.mac) {
delta = -delta;
}
// 稀释
if ( Math.abs( delta ) > 100 ) {
clearTimeout( this._wheelZoomTimeout );
if (Math.abs(delta) > 100) {
clearTimeout(this._wheelZoomTimeout);
} else {
return;
}
this._wheelZoomTimeout = setTimeout( function () {
this._wheelZoomTimeout = setTimeout(function() {
var value;
var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) {
me.execCommand( 'zoom-in' );
} else if ( delta > 0 ) {
me.execCommand( 'zoom-out' );
if (delta < 0) {
me.execCommand('zoom-in');
} else if (delta > 0) {
me.execCommand('zoom-out');
}
}, 100 );
}, 100);
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) {
......@@ -6,9 +8,5 @@ KityMinder.registerTemplate('bottom', {
if (node.isRoot()) return 'bottom';
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', {
'background': 'url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAIAAAACDbGyAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowQzg5QTQ0NDhENzgxMUUzOENGREE4QTg0RDgzRTZDNyIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowQzg5QTQ0NThENzgxMUUzOENGREE4QTg0RDgzRTZDNyI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOkMwOEQ1NDRGOEQ3NzExRTM4Q0ZEQThBODREODNFNkM3IiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOkMwOEQ1NDUwOEQ3NzExRTM4Q0ZEQThBODREODNFNkM3Ii8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+e9P33AAAACVJREFUeNpisXJ0YUACTAyoAMr/+eM7EGGRZ4FQ7BycEAZAgAEAHbEGtkoQm/wAAAAASUVORK5CYII=) repeat',
'name': '脑图经典',
'root-color': '#430',
'root-background': '#e9df98',
'root-stroke': 'none',
'root-font-size': 24,
'root-padding': [15, 25],
'root-margin': 100,
'root-margin': [30, 100],
'root-radius': 30,
'root-space': 10,
'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', {
},
hide: function () {
this.root().css('display', 'none');
this.trigger('afterhide')
this.trigger('afterhide');
},
attachTo: function ($obj, posObj) {
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