Commit c20be595 authored by techird's avatar techird

commit

parent 4dc690c8
......@@ -73,8 +73,12 @@ module.exports = function ( grunt ) {
copy: {
dir: {
files: [ {
src: [ 'dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**' ],
src: [ 'dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**', 'index.html' ],
dest: distPath
}, {
src: [ 'kity/dist/kitygraph.all.min.js' ],
dest: distPath + 'lib/',
flatten: true
} ]
}
},
......@@ -83,8 +87,8 @@ module.exports = function ( grunt ) {
src: distPath + 'index.html',
overwrite: true,
replacements: [ {
from: /1234567890/ig,
to: '1234567890'
from: /kity\/dist\/kitygraph\.all\.js/ig,
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 () {
var utils = KM.utils;
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='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>" +
......@@ -15,10 +22,10 @@
"<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>" +
"</ul>",
initContent: function ( km ) {
initContent: function ( km ,$w) {
var lang = km.getLang( 'dialogs.markers' );
if ( lang ) {
var html = $.parseTmpl( this.tpl, lang );
var html = $.parseTmpl( this.tpl, utils.extend({'container':'markers'},lang) );
}
this.root().html( html );
},
......@@ -43,23 +50,6 @@
$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
} )
......
......@@ -2,18 +2,49 @@
//todo 这里先写死成中文
var preferenceContent = '<div class="help-content" style="padding:20px;width:360px;">';
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>';
//todo 偏好设置暂时都在这里处理
//用于在reset所有偏好时,清除这个dialog下的所有偏好
var allPreferences = {};
function execExpand(km,$w){
var checked = $w.find('[name=expand]').checked();
if(checked){
function checkEverything( km, $w ) {
checkExpand( km, $w )
}
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', {
tpl: preferenceContent,
initContent: function ( km ) {
......@@ -23,13 +54,18 @@
html = $.parseTmpl( this.tpl, lang );
}
this.root().html( html );
},
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 ) {
km.fire('preferenceschange')
checkEverything( km, $w );
km.fire( 'preferencechange' )
} );
},
width: 400
......
......@@ -2,37 +2,32 @@
<html>
<head>
<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/ZeroClipboard.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 type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: '../lib/ZeroClipboard.swf' } );
ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } );
</script>
<script src="../kity/dist/kitygraph.all.min.js" charset="utf-8"></script>
<script src="../dist/kityminder.all.min.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/kitygraph.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="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>
zip.inflateJSPath = '../lib/inflate.js';
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/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" />
<link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" />
<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 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="apple-touch-icon-precomposed">
</head>
<body>
......@@ -40,7 +35,7 @@
<div id="share-dialog" >
<h3>URL分享:</h3>
<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>
</p>
<h3>社交分享:</h3>
......@@ -52,27 +47,11 @@
<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>
<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>
<script>
// create km instance
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>
</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' ] = {
'markers': '添加标签',
'switchlayout': '切换主题',
'help': '帮助',
'preference': '偏好设置'
'preference': '偏好设置',
'hyperlink':'插入链接',
'unhyperlink':"删除链接",
'expandnode':"展开节点",
'collapsenode':"闭合节点"
},
'popupcolor': {
'clearColor': '清空颜色',
......@@ -44,7 +48,8 @@ KityMinder.LANG[ 'zh-cn' ] = {
},
'help': {
}
},
hyperlink:{}
},
'node': {
'appendsiblingnode': '插入同级节点',
......
This diff is collapsed.
......@@ -79,7 +79,7 @@ $( function () {
minder = window.km,
// 草稿箱实例
draftManager = window.draftManager || ( window.draftManager = new window.DraftManager( minder ) ),
draftManager,
// 当前是否要检测文档内容是否变化的开关
watchingChanges = true,
......@@ -99,8 +99,8 @@ $( function () {
loadShare();
bindShortCuts();
bindDraft();
watchChanges();
if ( !loadPath() && !isShareLink ) loadDraft( 0 );
draftManager && watchChanges();
if ( draftManager && !loadPath() && !isShareLink ) loadDraft( 0 );
}
// 创建 UI
......@@ -159,6 +159,7 @@ $( function () {
}, 30 );
} );
if ( window.ZeroClipboard ) {
var clip = new window.ZeroClipboard( $copy_url_btn, {
hoverClass: 'hover',
activeClass: 'active'
......@@ -168,6 +169,7 @@ $( function () {
clearTimeout( copyTrickTimer );
} );
}
}
// 初始化云平台 frontia
function initFrontia() {
......@@ -207,6 +209,8 @@ $( function () {
$share_btn.loading( false );
return notice( '加载分享内容失败!请确认分享链接正确。' );
}
if ( draftManager ) {
var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) {
draftManager.load();
......@@ -214,6 +218,9 @@ $( function () {
draftManager.create( 'share/' + shareId );
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
}
} else {
minder.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
}
setRemotePath( null, false );
$share_btn.loading( false );
},
......@@ -537,11 +544,14 @@ $( function () {
minder.importData( data, format );
if ( draftManager ) {
if ( !draftManager.openByPath( remotePath ) ) {
draftManager.create();
}
draftManager.save( remotePath );
draftManager.sync();
}
minder.execCommand( 'camera', minder.getRoot() );
$user_btn.loading( false ).text( getFileName( remotePath ) );
......@@ -570,13 +580,13 @@ $( function () {
// 点击文件菜单
function openFile( e ) {
var path = $( this ).data( 'value' );
var draft = draftManager.getCurrent();
var draft = draftManager && draftManager.getCurrent();
if ( draft && draft.path == path ) {
if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) {
setRemotePath( path, true );
loadRemote();
}
} else {
} else if ( draftManager ) {
draft = draftManager.openByPath( path );
setRemotePath( path, !draft || draft.sync );
if ( draft ) {
......@@ -586,6 +596,9 @@ $( function () {
} else {
loadRemote();
}
} else {
setRemotePath( path, true );
loadRemote();
}
}
......@@ -625,8 +638,10 @@ $( function () {
addToRecentMenu( [ savedFile ] );
}
setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath );
draftManager.sync();
}
clearTimeout( timeout );
} else {
error( '保存到云盘失败,可能是网络问题导致!' );
......@@ -751,6 +766,12 @@ $( function () {
}
function bindDraft() {
if ( !draftManager ) {
if ( window.DraftManager ) {
draftManager = new window.DraftManager( minder );
}
}
$draft_menu.delegate( 'a.delete', 'click', function ( e ) {
var $li = $( this ).closest( 'li.draft-item' );
draftManager.remove( +$li.data( 'draft-index' ) );
......
......@@ -35,3 +35,16 @@
.kmui-btn-toolbar .kmui-btn .kmui-icon-preference {
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 () {
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 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 viewport = paper.getViewPort();
var animator = new kity.Animator( {
beginValue: viewbox,
finishValue: {
width: ww,
height: hh,
x: xx,
y: yy
},
beginValue: viewport.zoom,
finishValue: zoom,
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' );
minder._zoomValue = zoomValue *= rate;
}
var ZoomCommand = kity.createClass( 'Zoom', {
base: Command,
execute: zoomMinder
} );
var ZoomInCommand = kity.createClass( 'ZoomInCommand', {
base: Command,
execute: function ( minder ) {
if ( !this.queryState( minder ) ) {
zoom( minder, 1 / ZOOM_STEP );
}
zoomMinder( minder, this.nextValue() );
},
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', {
base: Command,
execute: function ( minder ) {
if ( !this.queryState( minder ) ) {
zoom( minder, ZOOM_STEP );
}
zoomMinder( minder, this.nextValue() );
},
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 {
commands: {
'zoom-in': ZoomInCommand,
'zoom-out': ZoomOutCommand
'zoom-out': ZoomOutCommand,
'zoom': ZoomCommand
},
events: {
'normal.keydown': function ( e ) {
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