Commit ca6e9e0c authored by campaign's avatar campaign

Merge remote-tracking branch 'origin/dev' into dev

Conflicts:
	README.md
parents cae8aeff fba52c76
......@@ -14,10 +14,29 @@ KM是基于SVG技术实现,使用JavaScript+html实现。支持绝大多数的
3. Safari
4. IE9+
## 线上版本
[http://fex.baidu.com/kityminder/dist](http://fex.baidu.com/kityminder/dist)
## 项目链接
[官网链接http://naotu.baidu.com](http://naotu.baidu.com)
注意:由于历史原因,有两个发布过的公开地址:
1. [~~http://fex-team.baidu.com/kityminder/dist~~](http://fex-team.baidu.com/kityminder/dist)
2. [~~http://kitygraph.github.io/kityminder/dist~~](http://kitygraph.github.io/kityminder/dist)
第一个地址已经失效,第二个地址不再维护更新,不便之处,请原谅。新地址已经稳定,请大家放心使用。
## 依赖说明
KityMinder 依赖 Kity 库。刚下载的压缩包或者刚从 github 拉下来的代码会有一个空的 kity 目录。要运行调试,必须加载 Kity 的依赖:
1. 如果你下载的是 KityMinder 的压缩包,那么需要手动下载 [Kity](http://kitygraph.github.io/kityminder/kity/dist/kitygraph.all.js) 库到 kity/dist/kitygraph.all.js
2. 如果你是从 github 上拉源代码下来的,那么可以更新一下子模块:
```bash
cd YOUR_KITYMINDER_PATH
git submodule init
git submodule update
```
## 联系我们
邮件: kity@baidu.com
......
......@@ -23,7 +23,7 @@ $dependency = Array(
,'src/module/layout.default.js'
,'src/module/layout.bottom.js'
,'src/core/minder.select.js'
,'src/module/hand.js'
,'src/module/view.js'
,'src/module/dragtree.js'
,'src/module/dropfile.js'
,'src/module/keyboard.js'
......
......@@ -27,6 +27,6 @@
<body>
<div id="kityminder" onselectstart="return false"></div>
<body>
</body>
</html>
\ No newline at end of file
......@@ -27,6 +27,6 @@
<body>
<div id="kityminder" onselectstart="return false"></div>
<body>
</body>
</html>
\ No newline at end of file
/*!
* ====================================================
* kityminder - v1.0.0 - 2014-03-07
* kityminder - v1.0.0 - 2014-03-10
* https://github.com/fex-team/kityminder
* GitHub: https://github.com/fex-team/kityminder.git
* Copyright (c) 2014 f-cube @ FEX; Licensed MIT
......@@ -3555,6 +3555,7 @@ KityMinder.registerModule( 'Hand', function () {
mousewheel: function ( e ) {
var dx, dy;
e = e.originEvent;
if(e.ctrlKey || e.shiftKey) return;
if ( 'wheelDeltaX' in e ) {
......@@ -3575,7 +3576,7 @@ KityMinder.registerModule( 'Hand', function () {
e.preventDefault();
},
dblclick: function ( e ) {
'normal.dblclick': function ( e ) {
if ( e.getTargetNode() ) return;
var viewport = this.getPaper().getViewPort();
......@@ -5027,7 +5028,7 @@ KityMinder.registerModule( "fontmodule", function () {
KityMinder.registerModule( 'Zoom', function () {
var MAX_ZOOM = 2,
MIN_ZOOM = 0.5,
MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) {
......@@ -5055,31 +5056,31 @@ KityMinder.registerModule( 'Zoom', function () {
}
} );
animator.start( paper, 100, 'ease' );
animator.start( paper, 500, 'ease' );
minder._zoomValue = zoomValue *= rate;
}
var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command,
execute: function ( minder ) {
if( !this.queryState( minder ) ) {
if ( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP );
}
},
queryState: function ( minder ) {
return (minder._zoomValue > MIN_ZOOM) ? 0 : -1;
return ( minder._zoomValue > 1 / MAX_ZOOM ) ? 0 : -1;
}
} );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
base: Command,
execute: function ( minder ) {
if( !this.queryState( minder ) ) {
if ( !this.queryState( minder ) ) {
zoom( minder, ZOOM_STEP );
}
},
queryState: function ( minder ) {
return (minder._zoomValue < MAX_ZOOM) ? 0 : -1;
return ( minder._zoomValue < 1 / MIN_ZOOM ) ? 0 : -1;
}
} );
......@@ -5091,26 +5092,30 @@ KityMinder.registerModule( 'Zoom', function () {
events: {
'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-out');
'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-out' );
}
},
}
},
'ready': function () {
this._zoomValue = 1;
},
// disable mouse wheel
'mousewheel_': function ( e ) {
'normal.mousewheel': function ( e ) {
if ( !e.originEvent.ctrlKey ) return;
var delta = e.originEvent.wheelDelta;
var me = this;
if ( !kity.Browser.mac ) {
delta = -delta;
}
// 稀释
if ( Math.abs( delta ) > 100 ) {
clearTimeout( this._wheelZoomTimeout );
......@@ -5122,9 +5127,9 @@ KityMinder.registerModule( 'Zoom', function () {
var value;
var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) {
me.execCommand('zoom-in');
me.execCommand( 'zoom-in' );
} else if ( delta > 0 ) {
me.execCommand('zoom-out');
me.execCommand( 'zoom-out' );
}
}, 100 );
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -189,6 +189,7 @@ $( function () {
function newFile() {
thisMapFilename = null;
window.km.importData( '新建脑图', 'plain' );
window.km.execCommand( 'camera', window.km.getRoot() );
$user_btn.text( '<新建脑图>' );
}
......@@ -237,7 +238,8 @@ $( function () {
var data = window.km.exportData( 'json' );
$share_btn.loading( '正在分享...' );
var shareUrl = baseUrl + 'index.html?share_id=' + share_id;
var currentUrl = window.location.origin + window.location.pathname;
var shareUrl = currentUrl + '?share_id=' + share_id;
share( data, share_id, function ( success ) {
if ( success ) {
var $popup = $( '<div></div>' ).addClass( 'popup' ).appendTo( 'body' );
......
......@@ -13,7 +13,7 @@ kity.extendClass( Minder, {
},
// TODO: mousemove lazy bind
_bindPaperEvents: function () {
this._paper.on( 'click dblclick mousedown contextmenu mouseup mousemove mousewheel touchstart touchmove touchend', this._firePharse.bind( this ) );
this._paper.on( 'click dblclick mousedown contextmenu mouseup mousemove mousewheel DOMMouseScroll touchstart touchmove touchend', this._firePharse.bind( this ) );
if ( window ) {
window.addEventListener( 'resize', this._firePharse.bind( this ) );
}
......@@ -27,6 +27,10 @@ kity.extendClass( Minder, {
_firePharse: function ( e ) {
var beforeEvent, preEvent, executeEvent;
if ( e.type == 'DOMMouseScroll' ) {
e.type = 'mousewheel';
e.wheelDelta = e.originEvent.wheelDelta = e.originEvent.detail * 120;
}
beforeEvent = new MinderEvent( 'before' + e.type, e, true );
if ( this._fire( beforeEvent ) ) {
......@@ -67,17 +71,17 @@ kity.extendClass( Minder, {
var callbacks = this._eventCallbacks[ e.type.toLowerCase() ] || [];
if(status){
if ( status ) {
callbacks = callbacks.concat(this._eventCallbacks[ status + '.' + e.type.toLowerCase() ] || []);
callbacks = callbacks.concat( this._eventCallbacks[ status + '.' + e.type.toLowerCase() ] || [] );
}
if(callbacks.length == 0){
if ( callbacks.length === 0 ) {
return;
}
var lastStatus = this.getStatus();
var lastStatus = this.getStatus();
for ( var i = 0; i < callbacks.length; i++ ) {
......@@ -92,18 +96,18 @@ kity.extendClass( Minder, {
},
on: function ( name, callback ) {
var km = this;
utils.each(name.split(/\s+/),function(i,n){
utils.each( name.split( /\s+/ ), function ( i, n ) {
km._listen( n.toLowerCase(), callback );
});
} );
return this;
},
off: function ( name, callback ) {
var types = name.split( /\s+/);
var types = name.split( /\s+/ );
var i, j, callbacks, removeIndex;
for ( i = 0; i < types.length; i++ ) {
callbacks = this._eventCallbacks[ types[ i ].toLowerCase() ];
callbacks = this._eventCallbacks[ types[ i ].toLowerCase() ];
if ( callbacks ) {
removeIndex = null;
for ( j = 0; j < callbacks.length; j++ ) {
......
......@@ -39,9 +39,9 @@ var ViewDragger = kity.createClass( "ViewDragger", {
me.setStatus( 'hand' );
}, 1 );
}
} );
} )
this._minder.on( 'hand.beforemousedown', function ( e ) {
.on( 'hand.beforemousedown', function ( e ) {
// 已经被用户打开拖放模式
if ( dragger.isEnabled() ) {
lastPosition = e.getPosition();
......@@ -75,7 +75,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
}
} );
KityMinder.registerModule( 'Hand', function () {
KityMinder.registerModule( 'View', function () {
var km = this;
......@@ -96,12 +96,24 @@ KityMinder.registerModule( 'Hand', function () {
}
} );
var CameraCommand = kity.createClass( "CameraCommand", {
base: Command,
execute: function ( km, focusNode ) {
var viewport = km.getPaper().getViewPort();
var offset = focusNode.getRenderContainer().getRenderBox( km.getRenderContainer() );
var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y;
km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
}
} );
return {
init: function () {
this._viewDragger = new ViewDragger( this );
},
commands: {
'hand': ToggleHandCommand
'hand': ToggleHandCommand,
'camera': CameraCommand
},
events: {
keyup: function ( e ) {
......@@ -113,6 +125,7 @@ KityMinder.registerModule( 'Hand', function () {
mousewheel: function ( e ) {
var dx, dy;
e = e.originEvent;
if ( e.ctrlKey || e.shiftKey ) return;
if ( 'wheelDeltaX' in e ) {
......@@ -133,14 +146,9 @@ KityMinder.registerModule( 'Hand', function () {
e.preventDefault();
},
dblclick: function ( e ) {
'normal.dblclick': function ( e ) {
if ( e.getTargetNode() ) return;
var viewport = this.getPaper().getViewPort();
var offset = this.getRoot().getRenderContainer().getRenderBox( this.getRenderContainer() );
var dx = viewport.center.x - offset.x - offset.width / 2,
dy = viewport.center.y - offset.y;
this.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
this.execCommand( 'camera', this.getRoot() );
}
}
};
......
KityMinder.registerModule( 'Zoom', function () {
var MAX_ZOOM = 2,
MIN_ZOOM = 0.5,
MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) {
......@@ -28,31 +28,31 @@ KityMinder.registerModule( 'Zoom', function () {
}
} );
animator.start( paper, 100, 'ease' );
animator.start( paper, 500, 'ease' );
minder._zoomValue = zoomValue *= rate;
}
var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command,
execute: function ( minder ) {
if( !this.queryState( minder ) ) {
if ( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP );
}
},
queryState: function ( minder ) {
return (minder._zoomValue > MIN_ZOOM) ? 0 : -1;
return ( minder._zoomValue > 1 / MAX_ZOOM ) ? 0 : -1;
}
} );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
base: Command,
execute: function ( minder ) {
if( !this.queryState( minder ) ) {
if ( !this.queryState( minder ) ) {
zoom( minder, ZOOM_STEP );
}
},
queryState: function ( minder ) {
return (minder._zoomValue < MAX_ZOOM) ? 0 : -1;
return ( minder._zoomValue < 1 / MIN_ZOOM ) ? 0 : -1;
}
} );
......@@ -64,26 +64,30 @@ KityMinder.registerModule( 'Zoom', function () {
events: {
'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-out');
'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-out' );
}
},
}
},
'ready': function () {
this._zoomValue = 1;
},
// disable mouse wheel
'mousewheel_': function ( e ) {
'normal.mousewheel': function ( e ) {
if ( !e.originEvent.ctrlKey ) return;
var delta = e.originEvent.wheelDelta;
var me = this;
if ( !kity.Browser.mac ) {
delta = -delta;
}
// 稀释
if ( Math.abs( delta ) > 100 ) {
clearTimeout( this._wheelZoomTimeout );
......@@ -95,9 +99,9 @@ KityMinder.registerModule( 'Zoom', function () {
var value;
var lastValue = me.getPaper()._zoom || 1;
if ( delta < 0 ) {
me.execCommand('zoom-in');
me.execCommand( 'zoom-in' );
} else if ( delta > 0 ) {
me.execCommand('zoom-out');
me.execCommand( 'zoom-out' );
}
}, 100 );
......
......@@ -3,9 +3,9 @@ html, body, div {
margin: 0;
padding: 0;
}
html, body, #kity-minder, div.kmui-editor-body {
html, body, #kityminder, div.kmui-editor-body {
height: 100%;
width: 100%
width: 100%;
overflow: hidden;
-moz-user-select: none;
}
......
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