Commit c20be595 authored by techird's avatar techird

commit

parent 4dc690c8
...@@ -73,8 +73,12 @@ module.exports = function ( grunt ) { ...@@ -73,8 +73,12 @@ module.exports = function ( grunt ) {
copy: { copy: {
dir: { dir: {
files: [ { files: [ {
src: [ 'dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**' ], src: [ 'dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**', 'index.html' ],
dest: distPath dest: distPath
}, {
src: [ 'kity/dist/kitygraph.all.min.js' ],
dest: distPath + 'lib/',
flatten: true
} ] } ]
} }
}, },
...@@ -83,8 +87,8 @@ module.exports = function ( grunt ) { ...@@ -83,8 +87,8 @@ module.exports = function ( grunt ) {
src: distPath + 'index.html', src: distPath + 'index.html',
overwrite: true, overwrite: true,
replacements: [ { replacements: [ {
from: /1234567890/ig, from: /kity\/dist\/kitygraph\.all\.js/ig,
to: '1234567890' to: 'lib/kitygraph.all.min.js'
} ] } ]
} }
}, },
......
( function () {
//todo 这里先写死成中文
var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">';
content += '<p><label>输入链接: <input id="hyperlink_href" style="width:90%;" /></label></p>';
content += '<p style="text-align:right"><button id="hyperlink_insert">插入</button></p>';
content += '</div>';
KM.registerWidget( 'hyperlink', {
tpl: content,
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.hyperlink' ),
html;
if ( lang ) {
html = $.parseTmpl( this.tpl, lang );
}
this.root().html( html );
},
initEvent: function ( km, $w ) {
$w.find('#hyperlink_insert').on('click',function(){
km.execCommand('hyperlink',$w.find('#hyperlink_href').val());
$w.kmui().hide();
});
var url = km.queryCommandValue('hyperlink');
var $input = $w.find('#hyperlink_href');
$input.val(url || 'http://');
setTimeout(function(){
$input.focus()
})
},
width: 400
} );
} )();
\ No newline at end of file
( function () { ( function () {
var utils = KM.utils;
KM.registerWidget( 'markers', { KM.registerWidget( 'markers', {
tpl: "<ul class='icon-list priority'>" + tpl:"<style>"+
".kmui-dialog-<%= container %> .priority .icon{background:url(dialogs/markers/images/iconpriority.png) 0 0}"+
".kmui-dialog-<%= container %> .progress .icon{background:url(dialogs/markers/images/iconprogress.png) 0 0}"+
".kmui-dialog-<%= container %> .icon.p2{background-position: -20px 0}"+
".kmui-dialog-<%= container %> .icon.p3{background-position: -40px 0}"+
".kmui-dialog-<%= container %> .icon.p4{background-position: -60px 0}"+
".kmui-dialog-<%= container %> .icon.p5{background-position: -80px 0}"+
"</style>"+
"<ul class='icon-list priority'>" +
"<li value='1' type='priority'><span class='icon p1'></span><span><%= priority %>1</span></li>" + "<li value='1' type='priority'><span class='icon p1'></span><span><%= priority %>1</span></li>" +
"<li value='2' type='priority'><span class='icon p2'></span><span><%= priority %>2</span></li>" + "<li value='2' type='priority'><span class='icon p2'></span><span><%= priority %>2</span></li>" +
"<li value='3' type='priority'><span class='icon p3'></span><span><%= priority %>3</span></li>" + "<li value='3' type='priority'><span class='icon p3'></span><span><%= priority %>3</span></li>" +
...@@ -15,10 +22,10 @@ ...@@ -15,10 +22,10 @@
"<li value='4' type='progress'><span class='icon p4'></span><span><%= progress.threequartersdone %></span></li>" + "<li value='4' type='progress'><span class='icon p4'></span><span><%= progress.threequartersdone %></span></li>" +
"<li value='5' type='progress'><span class='icon p5'></span><span><%= progress.done %></span></li>" + "<li value='5' type='progress'><span class='icon p5'></span><span><%= progress.done %></span></li>" +
"</ul>", "</ul>",
initContent: function ( km ) { initContent: function ( km ,$w) {
var lang = km.getLang( 'dialogs.markers' ); var lang = km.getLang( 'dialogs.markers' );
if ( lang ) { if ( lang ) {
var html = $.parseTmpl( this.tpl, lang ); var html = $.parseTmpl( this.tpl, utils.extend({'container':'markers'},lang) );
} }
this.root().html( html ); this.root().html( html );
}, },
...@@ -43,23 +50,6 @@ ...@@ -43,23 +50,6 @@
$w.find( "li[type='progress'][value='" + valPro + "']" ).addClass( "active" ); $w.find( "li[type='progress'][value='" + valPro + "']" ).addClass( "active" );
} ); } );
}, },
buttons: {
'ok': {
exec: function ( km, $w ) {
var href = $( '#kmui-link-Jhref' ).val().replace( /^\s+|\s+$/g, '' );
if ( href ) {
km.execCommand( 'link', {
'href': href,
'target': $( "#kmui-link-Jtarget:checked" ).length ? "_blank" : '_self',
'title': $( "#kmui-link-Jtitle" ).val().replace( /^\s+|\s+$/g, '' ),
'_href': href
} );
}
}
},
'cancel': {}
},
width: 200 width: 200
} ) } )
......
...@@ -2,18 +2,49 @@ ...@@ -2,18 +2,49 @@
//todo 这里先写死成中文 //todo 这里先写死成中文
var preferenceContent = '<div class="help-content" style="padding:20px;width:360px;">'; var preferenceContent = '<div class="help-content" style="padding:20px;width:360px;">';
preferenceContent += '<h3>展开属性设置</h3>'; preferenceContent += '<h3>展开属性设置</h3>';
preferenceContent += '<p><label><input type="checkbox" name="expand" />是否全部展开</label></p>'; preferenceContent += '<p><label><input type="checkbox" name="expand" />打开时展开全部节点(刷新页面生效)</label></p>';
preferenceContent += '<p><hr/></p>';
preferenceContent += '<p><button id="reset_preference">重置</button></p>';
//preferenceContent += '<p><label><b style="color:red">有些偏好设置会在你下次刷新页面时生效</b></label></p>';
preferenceContent += '</div>'; preferenceContent += '</div>';
//todo 偏好设置暂时都在这里处理 //todo 偏好设置暂时都在这里处理
//用于在reset所有偏好时,清除这个dialog下的所有偏好
var allPreferences = {};
function execExpand(km,$w){ function checkEverything( km, $w ) {
var checked = $w.find('[name=expand]').checked(); checkExpand( km, $w )
if(checked){ }
function initEverything( km, $w ) {
initExpand( km, $w )
}
//展开
function initExpand( km, $w ) {
var expand = km.getOptions( 'defaultExpand' );
$w.find( '[name=expand]' )[ 0 ].checked = expand && expand.defaultLayer == 0;
allPreferences[ 'defaultExpand' ] = null;
}
function checkExpand( km, $w ) {
var checked = $w.find( '[name=expand]' )[ 0 ].checked;
if ( checked ) {
km.setPreferences( 'defaultExpand', {
'defaultLayer': 0,
'defaultSubShow': 0
} )
} else {
km.setPreferences( 'defaultExpand' )
}
} }
//重置偏好
function resetPreferences( km ) {
km.setPreferences( allPreferences )
} }
KM.registerWidget( 'preference', { KM.registerWidget( 'preference', {
tpl: preferenceContent, tpl: preferenceContent,
initContent: function ( km ) { initContent: function ( km ) {
...@@ -23,13 +54,18 @@ ...@@ -23,13 +54,18 @@
html = $.parseTmpl( this.tpl, lang ); html = $.parseTmpl( this.tpl, lang );
} }
this.root().html( html ); this.root().html( html );
}, },
initEvent: function ( km, $w ) { initEvent: function ( km, $w ) {
//绑定默认值
initEverything( km, $w );
$w.find( '#reset_preference' ).on( 'click', function ( e ) {
resetPreferences( km );
//重置系统默认的偏好设置
initEverything( km, $w )
} );
$w.on( 'click', '.kmui-close', function ( e ) { $w.on( 'click', '.kmui-close', function ( e ) {
checkEverything( km, $w );
km.fire('preferenceschange') km.fire( 'preferencechange' )
} ); } );
}, },
width: 400 width: 400
......
...@@ -2,37 +2,32 @@ ...@@ -2,37 +2,32 @@
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="keywords" content="思维导图,脑图,minder,mind,kity">
<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">
ZeroClipboard.setDefaults( { moviePath: '../lib/ZeroClipboard.swf' } ); ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } );
</script> </script>
<script src="../kity/dist/kitygraph.all.min.js" charset="utf-8"></script> <script src="lib/kitygraph.all.min.js" charset="utf-8"></script>
<script src="../dist/kityminder.all.min.js" charset="utf-8"></script> <script src="import.js" charset="utf-8"></script>
<script src="../kityminder.config.js" charset="utf-8"></script> <script src="kityminder.config.js" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lib/zip.js" charset="utf-8"></script> <script src="lib/zip.js" charset="utf-8"></script>
<script> <script>
zip.inflateJSPath = '../lib/inflate.js'; zip.inflateJSPath = 'lib/inflate.js';
</script> </script>
<script src="../lib/jquery.xml2json.js" charset="utf-8"></script>
<script src="../lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="../social/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script>
<link href="../social/social.css" rel="stylesheet">
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet" /> <script src="lib/jquery.xml2json.js" charset="utf-8"></script>
<link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" /> <script src="lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="social/draftmanager.js" charset="utf-8"></script>
<script src="social/social.js" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet">
<link rel="stylesheet" href="css/links.css" /> <link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon"> <link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
<link href="favicon.ico" type="image/x-icon" rel="apple-touch-icon-precomposed"> <link href="favicon.ico" type="image/x-icon" rel="apple-touch-icon-precomposed">
</head> </head>
<body> <body>
...@@ -40,7 +35,7 @@ ...@@ -40,7 +35,7 @@
<div id="share-dialog" > <div id="share-dialog" >
<h3>URL分享:</h3> <h3>URL分享:</h3>
<p> <p>
<input id="share-url" type="url" value="" /> <input id="share-url" type="url" value="http://naotu.baidu.com/?shareId=kcev3dd" />
<button id="copy-share-url" data-clipboard-target="share-url" type="button">复制</button> <button id="copy-share-url" data-clipboard-target="share-url" type="button">复制</button>
</p> </p>
<h3>社交分享:</h3> <h3>社交分享:</h3>
...@@ -52,27 +47,11 @@ ...@@ -52,27 +47,11 @@
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a> <a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p> </p>
</div> </div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script> <script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<p id="about">
KityMinder <a id="km-version" href="https://github.com/fex-team/kityminder/blob/dev/CHANGELOG.md" target="blank"></a>, Powered by f-cube, <a href="http://fex.baidu.com" target="_blank">FEX</a> |
<a href="https://github.com/fex-team/kityminder.git" target="_blank">Source</a> |
<a href="https://github.com/fex-team/kityminder/issues/new" target="_blank">Report a Bug</a> |
<a href="mailto:kity@baidu.com" target="_blank">Contact Us</a>
</p>
</body> </body>
<script> <script>
// create km instance // create km instance
window.km = KM.getKityMinder('kityminder'); window.km = KM.getKityMinder('kityminder');
$(function() {
var lastVersion = localStorage.lastKMVersion;
$('#km-version').text( 'v' + KM.version );
if( lastVersion != KM.version ) {
$( '#km-version' ).addClass( 'new-version' );
localStorage.lastKMVersion = KM.version;
}
});
</script> </script>
</html> </html>
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -18,7 +18,11 @@ KityMinder.LANG[ 'zh-cn' ] = { ...@@ -18,7 +18,11 @@ KityMinder.LANG[ 'zh-cn' ] = {
'markers': '添加标签', 'markers': '添加标签',
'switchlayout': '切换主题', 'switchlayout': '切换主题',
'help': '帮助', 'help': '帮助',
'preference': '偏好设置' 'preference': '偏好设置',
'hyperlink':'插入链接',
'unhyperlink':"删除链接",
'expandnode':"展开节点",
'collapsenode':"闭合节点"
}, },
'popupcolor': { 'popupcolor': {
'clearColor': '清空颜色', 'clearColor': '清空颜色',
...@@ -44,7 +48,8 @@ KityMinder.LANG[ 'zh-cn' ] = { ...@@ -44,7 +48,8 @@ KityMinder.LANG[ 'zh-cn' ] = {
}, },
'help': { 'help': {
} },
hyperlink:{}
}, },
'node': { 'node': {
'appendsiblingnode': '插入同级节点', 'appendsiblingnode': '插入同级节点',
......
This diff is collapsed.
...@@ -79,7 +79,7 @@ $( function () { ...@@ -79,7 +79,7 @@ $( function () {
minder = window.km, minder = window.km,
// 草稿箱实例 // 草稿箱实例
draftManager = window.draftManager || ( window.draftManager = new window.DraftManager( minder ) ), draftManager,
// 当前是否要检测文档内容是否变化的开关 // 当前是否要检测文档内容是否变化的开关
watchingChanges = true, watchingChanges = true,
...@@ -99,8 +99,8 @@ $( function () { ...@@ -99,8 +99,8 @@ $( function () {
loadShare(); loadShare();
bindShortCuts(); bindShortCuts();
bindDraft(); bindDraft();
watchChanges(); draftManager && watchChanges();
if ( !loadPath() && !isShareLink ) loadDraft( 0 ); if ( draftManager && !loadPath() && !isShareLink ) loadDraft( 0 );
} }
// 创建 UI // 创建 UI
...@@ -159,6 +159,7 @@ $( function () { ...@@ -159,6 +159,7 @@ $( function () {
}, 30 ); }, 30 );
} ); } );
if ( window.ZeroClipboard ) {
var clip = new window.ZeroClipboard( $copy_url_btn, { var clip = new window.ZeroClipboard( $copy_url_btn, {
hoverClass: 'hover', hoverClass: 'hover',
activeClass: 'active' activeClass: 'active'
...@@ -168,6 +169,7 @@ $( function () { ...@@ -168,6 +169,7 @@ $( function () {
clearTimeout( copyTrickTimer ); clearTimeout( copyTrickTimer );
} ); } );
} }
}
// 初始化云平台 frontia // 初始化云平台 frontia
function initFrontia() { function initFrontia() {
...@@ -207,6 +209,8 @@ $( function () { ...@@ -207,6 +209,8 @@ $( function () {
$share_btn.loading( false ); $share_btn.loading( false );
return notice( '加载分享内容失败!请确认分享链接正确。' ); return notice( '加载分享内容失败!请确认分享链接正确。' );
} }
if ( draftManager ) {
var draft = draftManager.openByPath( 'share/' + shareId ); var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) { if ( draft ) {
draftManager.load(); draftManager.load();
...@@ -214,6 +218,9 @@ $( function () { ...@@ -214,6 +218,9 @@ $( function () {
draftManager.create( 'share/' + shareId ); draftManager.create( 'share/' + shareId );
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' ); minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
} }
} else {
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
}
setRemotePath( null, false ); setRemotePath( null, false );
$share_btn.loading( false ); $share_btn.loading( false );
}, },
...@@ -537,11 +544,14 @@ $( function () { ...@@ -537,11 +544,14 @@ $( function () {
minder.importData( data, format ); minder.importData( data, format );
if ( draftManager ) {
if ( !draftManager.openByPath( remotePath ) ) { if ( !draftManager.openByPath( remotePath ) ) {
draftManager.create(); draftManager.create();
} }
draftManager.save( remotePath ); draftManager.save( remotePath );
draftManager.sync(); draftManager.sync();
}
minder.execCommand( 'camera', minder.getRoot() ); minder.execCommand( 'camera', minder.getRoot() );
$user_btn.loading( false ).text( getFileName( remotePath ) ); $user_btn.loading( false ).text( getFileName( remotePath ) );
...@@ -570,13 +580,13 @@ $( function () { ...@@ -570,13 +580,13 @@ $( function () {
// 点击文件菜单 // 点击文件菜单
function openFile( e ) { function openFile( e ) {
var path = $( this ).data( 'value' ); var path = $( this ).data( 'value' );
var draft = draftManager.getCurrent(); var draft = draftManager && draftManager.getCurrent();
if ( draft && draft.path == path ) { if ( draft && draft.path == path ) {
if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) { if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) {
setRemotePath( path, true ); setRemotePath( path, true );
loadRemote(); loadRemote();
} }
} else { } else if ( draftManager ) {
draft = draftManager.openByPath( path ); draft = draftManager.openByPath( path );
setRemotePath( path, !draft || draft.sync ); setRemotePath( path, !draft || draft.sync );
if ( draft ) { if ( draft ) {
...@@ -586,6 +596,9 @@ $( function () { ...@@ -586,6 +596,9 @@ $( function () {
} else { } else {
loadRemote(); loadRemote();
} }
} else {
setRemotePath( path, true );
loadRemote();
} }
} }
...@@ -625,8 +638,10 @@ $( function () { ...@@ -625,8 +638,10 @@ $( function () {
addToRecentMenu( [ savedFile ] ); addToRecentMenu( [ savedFile ] );
} }
setRemotePath( savedFile.path, true ); setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath ); draftManager.save( remotePath );
draftManager.sync(); draftManager.sync();
}
clearTimeout( timeout ); clearTimeout( timeout );
} else { } else {
error( '保存到云盘失败,可能是网络问题导致!' ); error( '保存到云盘失败,可能是网络问题导致!' );
...@@ -751,6 +766,12 @@ $( function () { ...@@ -751,6 +766,12 @@ $( function () {
} }
function bindDraft() { function bindDraft() {
if ( !draftManager ) {
if ( window.DraftManager ) {
draftManager = new window.DraftManager( minder );
}
}
$draft_menu.delegate( 'a.delete', 'click', function ( e ) { $draft_menu.delegate( 'a.delete', 'click', function ( e ) {
var $li = $( this ).closest( 'li.draft-item' ); var $li = $( this ).closest( 'li.draft-item' );
draftManager.remove( +$li.data( 'draft-index' ) ); draftManager.remove( +$li.data( 'draft-index' ) );
......
...@@ -35,3 +35,16 @@ ...@@ -35,3 +35,16 @@
.kmui-btn-toolbar .kmui-btn .kmui-icon-preference { .kmui-btn-toolbar .kmui-btn .kmui-icon-preference {
background: url(../images/setting.png) no-repeat 2px 2px; background: url(../images/setting.png) no-repeat 2px 2px;
} }
.kmui-btn-toolbar .kmui-btn .kmui-icon-expandnode {
background: url(../images/expand.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-collapsenode {
background: url(../images/contract.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-hyperlink {
background: url(../images/link.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-unhyperlink {
background: url(../images/unlink.png) no-repeat 2px 2px;
}
\ No newline at end of file
Subproject commit 84b8e320dc03c3070607d20c7a5f354168d48181 Subproject commit efa481b263c2727e90101edc7710dd9a9a393f5f
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="lib/jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="kity/dist/kitygraph.all.js" charset="utf-8"></script>
<script src="import.js" charset="utf-8"></script>
<script src="kityminder.config.js" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="lib/zip.js" charset="utf-8"></script>
<script>
zip.inflateJSPath = 'lib/inflate.js';
</script>
<script src="lib/jquery.xml2json.js" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="social/social.js" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet">
<link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
<link href="favicon.ico" type="image/x-icon" rel="apple-touch-icon-precomposed">
<style>
.kmui-toolbar, #social button#save-btn, #draft-btn, .user-file-menu li:first-child {
display: none;
}
</style>
</head>
<body>
<div id="kityminder" onselectstart="return false"></div>
<div id="share-dialog" >
<h3>URL分享:</h3>
<p>
<input id="share-url" type="url" value="http://naotu.baidu.com/?shareId=kcev3dd" />
<button id="copy-share-url" data-clipboard-target="share-url" type="button">复制</button>
</p>
<h3>社交分享:</h3>
<p id="share-platform" class="bdsharebuttonbox">
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
<a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
<a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
</body>
<script>
// create km instance
window.km = KM.getKityMinder('kityminder');
//km.setDisabled();
km.execCommand('hand');
</script>
</html>
\ No newline at end of file
KityMinder.registerModule( 'Zoom', function () { KityMinder.registerModule( 'Zoom', function () {
var MAX_ZOOM = 2,
MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) { function zoomMinder( minder, zoom ) {
var paper = minder.getPaper(); var paper = minder.getPaper();
var viewbox = paper.getViewBox(); var viewport = paper.getViewPort();
var zoomValue = minder._zoomValue;
var w = viewbox.width,
h = viewbox.height,
x = viewbox.x,
y = viewbox.y;
var ww = w * rate,
hh = h * rate,
xx = x + ( w - ww ) / 2,
yy = y + ( h - hh ) / 2;
var animator = new kity.Animator( { var animator = new kity.Animator( {
beginValue: viewbox, beginValue: viewport.zoom,
finishValue: { finishValue: zoom,
width: ww,
height: hh,
x: xx,
y: yy
},
setter: function ( target, value ) { setter: function ( target, value ) {
target.setViewBox( value.x, value.y, value.width, value.height ); viewport.zoom = value;
target.setViewPort( viewport );
} }
} ); } );
this.zoom = zoom;
animator.start( paper, 500, 'ease' ); animator.start( paper, 500, 'ease' );
minder._zoomValue = zoomValue *= rate;
} }
var ZoomCommand = kity.createClass( 'Zoom', {
base: Command,
execute: zoomMinder
} );
var ZoomInCommand = kity.createClass( 'ZoomInCommand', { var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function ( minder ) {
if ( !this.queryState( minder ) ) { zoomMinder( minder, this.nextValue() );
zoom( minder, 1 / ZOOM_STEP );
}
}, },
queryState: function ( minder ) { queryState: function ( minder ) {
return ( minder._zoomValue > 1 / MAX_ZOOM ) ? 0 : -1; return !!this.nextValue();
}, },
enableReadOnly : false nextValue: function () {
var stack = this.getOption( 'zoom' ),
i;
for ( i = 0; i < stack.length - 1; i++ ) {
if ( stack[ i ] > this.zoom ) return stack[ i ];
}
return 0;
},
enableReadOnly: falsed
} ); } );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', { var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
base: Command, base: Command,
execute: function ( minder ) { execute: function ( minder ) {
if ( !this.queryState( minder ) ) { zoomMinder( minder, this.nextValue() );
zoom( minder, ZOOM_STEP );
}
}, },
queryState: function ( minder ) { queryState: function ( minder ) {
return ( minder._zoomValue < 1 / MIN_ZOOM ) ? 0 : -1; return !!this.nextValue();
},
nextValue: function () {
var stack = this.getOption( 'zoom' ),
i;
for ( i = stack.length - 1; i >= 0l i-- ) {
if ( stack[ i ] < this.zoom ) return stack[ i ];
}
return 0;
}, },
enableReadOnly : false enableReadOnly: false
} ); } );
return { return {
commands: { commands: {
'zoom-in': ZoomInCommand, 'zoom-in': ZoomInCommand,
'zoom-out': ZoomOutCommand 'zoom-out': ZoomOutCommand,
'zoom': ZoomCommand
}, },
events: { events: {
'normal.keydown': function ( e ) { 'normal.keydown': function ( e ) {
var me = this; var me = this;
......
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