Commit f8d19797 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents 28708a23 ab649310
...@@ -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>
<link rel="stylesheet" href="css/links.css" /> <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="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>
<p id="about"> <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>
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,14 +159,16 @@ $( function () { ...@@ -159,14 +159,16 @@ $( function () {
}, 30 ); }, 30 );
} ); } );
var clip = new window.ZeroClipboard( $copy_url_btn, { if ( window.ZeroClipboard ) {
hoverClass: 'hover', var clip = new window.ZeroClipboard( $copy_url_btn, {
activeClass: 'active' hoverClass: 'hover',
} ); activeClass: 'active'
clip.on( 'dataRequested', function ( client, args ) { } );
$copy_url_btn.loading( '已复制' ); clip.on( 'dataRequested', function ( client, args ) {
clearTimeout( copyTrickTimer ); $copy_url_btn.loading( '已复制' );
} ); clearTimeout( copyTrickTimer );
} );
}
} }
// 初始化云平台 frontia // 初始化云平台 frontia
...@@ -207,11 +209,16 @@ $( function () { ...@@ -207,11 +209,16 @@ $( function () {
$share_btn.loading( false ); $share_btn.loading( false );
return notice( '加载分享内容失败!请确认分享链接正确。' ); return notice( '加载分享内容失败!请确认分享链接正确。' );
} }
var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) { if ( draftManager ) {
draftManager.load(); var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) {
draftManager.load();
} else {
draftManager.create( 'share/' + shareId );
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
}
} else { } else {
draftManager.create( 'share/' + shareId );
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' ); minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
} }
setRemotePath( null, false ); setRemotePath( null, false );
...@@ -537,11 +544,14 @@ $( function () { ...@@ -537,11 +544,14 @@ $( function () {
minder.importData( data, format ); minder.importData( data, format );
if ( !draftManager.openByPath( remotePath ) ) { if ( draftManager ) {
draftManager.create(); if ( !draftManager.openByPath( remotePath ) ) {
draftManager.create();
}
draftManager.save( remotePath );
draftManager.sync();
} }
draftManager.save( remotePath );
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 );
draftManager.save( remotePath ); if ( draftManager ) {
draftManager.sync(); draftManager.save( remotePath );
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' ) );
......
...@@ -34,4 +34,17 @@ ...@@ -34,4 +34,17 @@
} }
.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 afbb101c5b3d7518080bac3886f16043a482b7c9 Subproject commit efa481b263c2727e90101edc7710dd9a9a393f5f
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ toolbars: [
'hand zoom | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | help' 'hand | zoom-in zoom zoom-out | collapsenode expandnode | undo redo | bold italic | fontfamily fontsize forecolor | saveto | hyperlink unhyperlink | markers | node | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
......
...@@ -59,6 +59,10 @@ KityMinder.LANG[ 'zh-cn' ] = { ...@@ -59,6 +59,10 @@ KityMinder.LANG[ 'zh-cn' ] = {
'layout': { 'layout': {
'default': '左右展开', 'default': '左右展开',
'bottom': '向下展开' 'bottom': '向下展开'
},
'hyperlink':{
'hyperlink':'插入超链接',
'unhyperlink':"取消超链接"
} }
}; };
\ No newline at end of file
<!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
...@@ -38,6 +38,22 @@ KM.registerToolbarUI( 'hyperlink', function ( name ) { ...@@ -38,6 +38,22 @@ KM.registerToolbarUI( 'hyperlink', function ( name ) {
} ); } );
me.addContextmenu( [ {
label: me.getLang( 'hyperlink.hyperlink' ),
exec: function (url) {
$dialog.kmui().show();
this.execCommand( 'hyperlink', url )
},
cmdName: 'hyperlink'
},{
label: me.getLang( 'hyperlink.unhyperlink' ),
exec: function (url) {
this.execCommand( 'unhyperlink' )
},
cmdName: 'hyperlink'
}
]);
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 )
......
...@@ -10,8 +10,8 @@ KM.registerToolbarUI( 'zoom', function ( name ) { ...@@ -10,8 +10,8 @@ KM.registerToolbarUI( 'zoom', function ( name ) {
itemStyles: [], itemStyles: [],
value: me.getOptions( name ), value: me.getOptions( name ),
autowidthitem: [], autowidthitem: [],
enabledRecord: false, enabledRecord: false
enabledSelected: false
}, },
$combox = null; $combox = null;
if ( options.items.length == 0 ) { if ( options.items.length == 0 ) {
...@@ -31,9 +31,15 @@ KM.registerToolbarUI( 'zoom', function ( name ) { ...@@ -31,9 +31,15 @@ KM.registerToolbarUI( 'zoom', function ( name ) {
} ); } );
//状态反射 //状态反射
me.on( 'interactchange', function () { me.on( 'interactchange', function () {
var state = 0;
var state = this.queryCommandState( name ),
value = this.queryCommandValue( name );
//设置按钮状态 //设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 ); comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
if ( value ) {
//设置label
comboboxWidget.selectItemByLabel( value + '%' );
}
} ); } );
//comboboxWidget.button().kmui().disabled(-1); //comboboxWidget.button().kmui().disabled(-1);
......
...@@ -97,7 +97,7 @@ KityMinder.registerModule( 'View', function () { ...@@ -97,7 +97,7 @@ KityMinder.registerModule( 'View', function () {
queryState: function ( minder ) { queryState: function ( minder ) {
return minder._viewDragger.isEnabled() ? 1 : 0; return minder._viewDragger.isEnabled() ? 1 : 0;
}, },
enableReadOnly : false enableReadOnly: false
} ); } );
var CameraCommand = kity.createClass( "CameraCommand", { var CameraCommand = kity.createClass( "CameraCommand", {
...@@ -110,7 +110,7 @@ KityMinder.registerModule( 'View', function () { ...@@ -110,7 +110,7 @@ KityMinder.registerModule( 'View', function () {
km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" ); km.getRenderContainer().fxTranslate( dx, dy, 1000, "easeOutQuint" );
this.setContentChanged( false ); this.setContentChanged( false );
}, },
enableReadOnly : false enableReadOnly: false
} ); } );
return { return {
...@@ -153,8 +153,9 @@ KityMinder.registerModule( 'View', function () { ...@@ -153,8 +153,9 @@ KityMinder.registerModule( 'View', function () {
e.preventDefault(); e.preventDefault();
}, },
'normal.dblclick readonly.dblclick': function ( e ) { 'normal.dblclick readonly.dblclick': function ( e ) {
if ( e.getTargetNode() ) return; if ( e.kityEvent.targetShape instanceof kity.Paper ) {
this.execCommand( 'camera', this.getRoot() ); this.execCommand( 'camera', this.getRoot() );
}
} }
} }
}; };
......
KityMinder.registerModule( 'Zoom', function () { KityMinder.registerModule( 'Zoom', function () {
var me = this; var me = this;
me.setOptions('zoom',[50,80,100,120,150,200]);
var MAX_ZOOM = 2, var timeline;
MIN_ZOOM = kity.Browser.chrome ? 1 : 0.5,
ZOOM_STEP = Math.sqrt( 2 );
function zoom( minder, rate ) { me.setOptions( 'zoom', [ 50, 80, 100, 120, 150, 200 ] );
var paper = minder.getPaper();
var viewbox = paper.getViewBox();
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( {
beginValue: viewbox,
finishValue: {
width: ww,
height: hh,
x: xx,
y: yy
},
setter: function ( target, value ) {
target.setViewBox( value.x, value.y, value.width, value.height );
}
} );
animator.start( paper, 500, 'ease' ); function zoomMinder( minder, zoom ) {
minder._zoomValue = zoomValue *= rate; var paper = minder.getPaper();
} var viewport = paper.getViewPort();
var ZoomInCommand = kity.createClass( 'ZoomInCommand', { if ( !zoom ) return;
base: Command,
execute: function ( minder ) {
if ( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP );
}
},
queryState: function ( minder ) {
return ( minder._zoomValue > 1 / MAX_ZOOM ) ? 0 : -1;
},
enableReadOnly : false
} );
var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', { var animator = new kity.Animator( {
base: Command, beginValue: viewport.zoom,
execute: function ( minder ) { finishValue: zoom / 100,
if ( !this.queryState( minder ) ) { setter: function ( target, value ) {
zoom( minder, ZOOM_STEP ); viewport.zoom = value;
} target.setViewPort( viewport );
}, }
queryState: function ( minder ) { } );
return ( minder._zoomValue < 1 / MIN_ZOOM ) ? 0 : -1; minder.zoom = zoom;
}, if ( timeline ) {
enableReadOnly : false timeline.pause();
} ); }
timeline = animator.start( paper, 500, 'ease' );
}
return { var ZoomCommand = kity.createClass( 'Zoom', {
commands: { base: Command,
'zoom-in': ZoomInCommand, execute: zoomMinder,
'zoom-out': ZoomOutCommand queryValue: function ( minder ) {
}, return minder.zoom;
}
} );
var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command,
execute: function ( minder ) {
zoomMinder( minder, this.nextValue( minder ) );
},
queryState: function ( minder ) {
return ~this.nextValue( minder );
},
nextValue: function ( minder ) {
var stack = minder.getOptions( 'zoom' ),
i;
for ( i = 0; i < stack.length; i++ ) {
if ( stack[ i ] > minder.zoom ) return stack[ i ];
}
return 0;
},
enableReadOnly: false
} );
events: { var ZoomOutCommand = kity.createClass( 'ZoomOutCommand', {
'normal.keydown': function ( e ) { base: Command,
var me = this; execute: function ( minder ) {
var originEvent = e.originEvent; zoomMinder( minder, this.nextValue( minder ) );
var keyCode = originEvent.keyCode || originEvent.which; },
if ( keymap[ '=' ] == keyCode ) { queryState: function ( minder ) {
me.execCommand( 'zoom-in' ); return ~this.nextValue( minder );
} },
if ( keymap[ '-' ] == keyCode ) { nextValue: function ( minder ) {
me.execCommand( 'zoom-out' ); var stack = minder.getOptions( 'zoom' ),
i;
for ( i = stack.length - 1; i >= 0; i-- ) {
if ( stack[ i ] < minder.zoom ) return stack[ i ];
}
return 0;
},
enableReadOnly: false
} );
} return {
}, init: function () {
'ready': function () { this.zoom = 100;
this._zoomValue = 1; },
}, commands: {
'normal.mousewheel readonly.mousewheel': function ( e ) { 'zoom-in': ZoomInCommand,
if ( !e.originEvent.ctrlKey ) return; 'zoom-out': ZoomOutCommand,
var delta = e.originEvent.wheelDelta; 'zoom': ZoomCommand
var me = this; },
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' );
if ( !kity.Browser.mac ) { }
delta = -delta; },
} 'ready': function () {
this._zoomValue = 1;
},
'normal.mousewheel readonly.mousewheel': function ( e ) {
if ( !e.originEvent.ctrlKey ) return;
var delta = e.originEvent.wheelDelta;
var me = this;
// 稀释 if ( !kity.Browser.mac ) {
if ( Math.abs( delta ) > 100 ) { delta = -delta;
clearTimeout( this._wheelZoomTimeout ); }
} else {
return;
}
this._wheelZoomTimeout = setTimeout( function () { // 稀释
var value; if ( Math.abs( delta ) > 100 ) {
var lastValue = me.getPaper()._zoom || 1; clearTimeout( this._wheelZoomTimeout );
if ( delta < 0 ) { } else {
me.execCommand( 'zoom-in' ); return;
} else if ( delta > 0 ) { }
me.execCommand( 'zoom-out' );
}
}, 100 );
e.originEvent.preventDefault(); 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' );
}
}, 100 );
e.originEvent.preventDefault();
}
}
};
} ); } );
\ No newline at end of file
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