Commit f8dc2e4d authored by techird's avatar techird

体验优化

parent 2f0d4154
...@@ -72,7 +72,7 @@ module.exports = function (grunt) { ...@@ -72,7 +72,7 @@ module.exports = function (grunt) {
copy: { copy: {
dir: { dir: {
files: [{ files: [{
src: ['dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**', 'index.html'], src: ['dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**', 'index.html', 'download.php'],
dest: distPath dest: distPath
}] }]
}, },
......
( function ( utils ) { (function(utils) {
//todo 这里先写死成中文 //todo 这里先写死成中文
var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">'; var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">';
content += '<style>'; content += '<style>';
content += '.kmui-dialog-<%= container %> input{'; content += '.kmui-dialog-<%= container %> input{';
content += 'width: 75%;'; content += 'width: 74%;';
content += 'padding: 6px 12px;'; content += 'padding: 6px 12px;';
content += 'font-size: 14px;'; content += 'font-size: 14px;';
content += 'line-height: 1.42857143;'; content += 'line-height: 1.42857143;';
...@@ -35,36 +35,51 @@ ...@@ -35,36 +35,51 @@
KM.registerWidget( 'hyperlink', { KM.registerWidget('hyperlink', {
tpl: content, tpl: content,
initContent: function ( km ) { initContent: function(km) {
var lang = km.getLang( 'dialogs.hyperlink' ), var lang = km.getLang('dialogs.hyperlink'),
html; html;
if ( lang ) { if (lang) {
html = $.parseTmpl( this.tpl, utils.extend( { html = $.parseTmpl(this.tpl, utils.extend({
'container': 'hyperlink' 'container': 'hyperlink'
}, lang ) ); }, lang));
} }
this.root().html( html ); this.root().html(html);
}, },
initEvent: function ( km, $w ) { initEvent: function(km, $w) {
$w.find( '#hyperlink_insert' ).on( 'click', function () { var $btn = $w.find('#hyperlink_insert');
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() ); $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.kmui().hide();
} ); });
$w.find( '#hyperlink_href' ).on( 'keydown', function ( e ) { $w.find('#hyperlink_href').on('keydown', function(e) {
if ( e.keyCode === 13 ) { if (e.keyCode === 13) {
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() ); $btn.click();
$w.kmui().hide();
} }
} ); });
var url = km.queryCommandValue( 'hyperlink' ); var url = km.queryCommandValue('hyperlink');
var $input = $w.find( '#hyperlink_href' ); var $input = $w.find('#hyperlink_href');
$input.val( url || 'http://' ); $input.val(url || 'http://');
setTimeout( function () { setTimeout(function() {
$input.focus() $input.select();
} ) });
}, },
width: 400 width: 400
} ); });
} )( KM.Utils ); })(KM.Utils);
\ No newline at end of file \ No newline at end of file
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
var content = '<div class="image-content" style="padding:20px;width:360px;">'; var content = '<div class="image-content" style="padding:20px;width:360px;">';
content += '<style>'; content += '<style>';
content += '.kmui-dialog-<%= container %> input{'; content += '.kmui-dialog-<%= container %> input{';
content += 'width: 75%;'; content += 'width: 74%;';
content += 'padding: 6px 12px;'; content += 'padding: 6px 12px;';
content += 'font-size: 14px;'; content += 'font-size: 14px;';
content += 'line-height: 1.42857143;'; content += 'line-height: 1.42857143;';
...@@ -49,24 +49,39 @@ ...@@ -49,24 +49,39 @@
this.root().html(html); this.root().html(html);
}, },
initEvent: function(km, $w) { initEvent: function(km, $w) {
$w.find('#image_insert').on('click', function() { var $btn = $w.find('#image_insert').attr('disabled', 'disabled');
km.execCommand('image', $w.find('#image_href').val()); 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.kmui().hide();
}); });
$w.find('#image_href').on('keydown', function(e) { $href.on('keydown', function(e) {
if (e.keyCode === 13) { if (e.keyCode === 13) {
km.execCommand('image', $w.find('#image_href').val()); $btn.click();
$w.kmui().hide();
} }
}).on('input', function() {
$w.find('#image_preview').attr('src', $w.find('#image_href').val());
}); });
var url = km.queryCommandValue('image'); var url = km.queryCommandValue('image');
var $input = $w.find('#image_href'); var $input = $w.find('#image_href');
$input.val(url || 'http://'); $input.val(url || 'http://');
if (url) $w.find('#image_preview').attr('src', url); if (url) $w.find('#image_preview').attr('src', url);
setTimeout(function() { setTimeout(function() {
$input.focus(); $input.select();
}); });
}, },
width: 400 width: 400
......
<?php
/**
* 导出文件代理
*
* @author Jinqn, techird
*/
$type = $_REQUEST['type'];
if (isset($_REQUEST['content'])) {
$content = $_REQUEST['content'];
if ($type == 'base64') {
$content = base64_decode($content);
}
$filename = htmlspecialchars($_REQUEST["filename"]);
if (!$filename) {
$filename = "kikyminder";
}
header("Content-type: application/octet-stream; charset=utf-8; name=".$filename);
header("Accept-Length: ".strlen($content));
header("Content-Length: ".strlen($content));
header("Content-Disposition: attachment; filename=".$filename);
header('Content-Description: File Transfer');
echo $content;
} else {
echo 'Empty Content!';
}
?>
\ No newline at end of file
...@@ -6,27 +6,26 @@ ...@@ -6,27 +6,26 @@
<meta name="keyword" content="脑图,kity,svg,minder,百度,fex,前端,在线"> <meta name="keyword" content="脑图,kity,svg,minder,百度,fex,前端,在线">
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。"> <meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<script src="lib/jquery-2.1.0.min.js?_=1404368123769" charset="utf-8"></script>
<script src="lib/jquery-2.1.0.min.js?_=1403688582922" charset="utf-8"></script> <script src="lib/ZeroClipboard.min.js?_=1404368123769" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1403688582922" 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="lib/kity.min.js?_=1403688582922" charset="utf-8"></script> <script src="lib/kity.min.js?_=1404368123769" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1403688582922" charset="utf-8"></script> <script src="kityminder.all.min.js?_=1404368123769" charset="utf-8"></script>
<script src="kityminder.config.js?_=1403688582922" charset="utf-8"></script> <script src="kityminder.config.js?_=1404368123769" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1403688582922" charset="utf-8"></script> <script src="lang/zh-cn/zh-cn.js?_=1404368123769" charset="utf-8"></script>
<script src="lib/zip.js?_=1403688582922" charset="utf-8"></script> <script src="lib/zip.js?_=1404368123769" charset="utf-8"></script>
<script> <script>
zip.inflateJSPath = 'lib/inflate.js'; zip.inflateJSPath = 'lib/inflate.js';
</script> </script>
<script src="lib/jquery.xml2json.js?_=1403688582922" charset="utf-8"></script> <script src="lib/jquery.xml2json.js?_=1404368123769" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1403688582922" charset="utf-8"></script> <script src="lib/baidu-frontia-js-full-1.0.0.js?_=1404368123769" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1403688582922" charset="utf-8"></script> <script src="social/draftmanager.js?_=1404368123769" charset="utf-8"></script>
<script src="social/social.js?_=1403688582922" charset="utf-8"></script> <script src="social/social.js?_=1404368123769" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet"> <link href="social/social.css" rel="stylesheet">
<link href="themes/default/css/import.css" type="text/css" rel="stylesheet" /> <link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
...@@ -35,7 +34,10 @@ ...@@ -35,7 +34,10 @@
</head> </head>
<body> <body>
<div id="panel"></div>
<div id="kityminder" onselectstart="return false"></div> <div id="kityminder" onselectstart="return false"></div>
<div id="share-dialog" > <div id="share-dialog" >
<h3>URL分享:</h3> <h3>URL分享:</h3>
<p> <p>
...@@ -52,14 +54,49 @@ ...@@ -52,14 +54,49 @@
</p> </p>
</div> </div>
<p id="about"> <div id="about">
KityMinder <a id="km-version" href="https://github.com/fex-team/kityminder/blob/dev/CHANGELOG.md" target="blank"></a> under <a href="https://raw.githubusercontent.com/fex-team/kityminder/dev/LICENSE" target="_blank">BSD License</a>. Powered by f-cube, <a href="http://fex.baidu.com" target="_blank">FEX</a> | <svg id="km-cat" viewBox="0 0 1200 1200" width="32px" height="32px">
<a href="https://github.com/fex-team/kityminder.git" target="_blank">Source</a> <g id="cat-face">
<a href="https://github.com/fex-team/kityminder/issues/new" target="_blank">Bug</a> | <path d="M1066.769,368.482L1119.5,80L830,131.611C760.552,97.29,682.35,77.999,599.641,77.999
<a href="mailto:kity@baidu.com" target="_blank">Contact Us</a> c-82.424,0-160.371,19.161-229.641,53.26L81,81l50.769,289l0,0c-33.792,69.019-52.77,146.612-52.77,228.641
</p> c0,287.542,233.099,520.642,520.642,520.642s520.642-233.099,520.642-520.642C1120.282,516.011,1101.028,437.88,1066.769,368.482z"
<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> />
</g>
<g id="cat-eye">
<path style="fill:#FFFFFF;" d="M920.255,371C794.746,371,693,472.746,693,598.255s101.746,227.255,227.255,227.255
s227.255-101.746,227.255-227.255S1045.765,371,920.255,371z M920,746c-80.081,0-145-64.919-145-145s64.919-145,145-145
s145,64.919,145,145S1000.081,746,920,746z"/>
<path style="fill:#FFFFFF;" d="M276.255,371C150.746,371,49,472.746,49,598.255s101.746,227.255,227.255,227.255
s227.255-101.746,227.255-227.255S401.765,371,276.255,371z M276,745c-80.081,0-145-64.919-145-145s64.919-145,145-145
s145,64.919,145,145S356.081,745,276,745z"/>
</g>
</svg>
KityMinder
<a id="km-version"
href="https://github.com/fex-team/kityminder/blob/dev/CHANGELOG.md"
target="blank">
</a>
under
<a href="https://raw.githubusercontent.com/fex-team/kityminder/dev/LICENSE"
target="_blank">BSD License
</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">Bug
</a> |
<a href="mailto:kity@baidu.com"
target="_blank">Contact Us
</a>
</div>
</body> </body>
<!--脑图启动代码-->
<script> <script>
// create km instance // create km instance
km = KM.getKityMinder('kityminder'); km = KM.getKityMinder('kityminder');
...@@ -70,32 +107,34 @@ ...@@ -70,32 +107,34 @@
var lastVersion = localStorage.lastKMVersion; var lastVersion = localStorage.lastKMVersion;
$('#km-version').text( 'v' + KM.version ); $('#km-version').text( 'v' + KM.version );
if( lastVersion != KM.version ) { if (lastVersion != KM.version) {
$( '#km-version' ).addClass( 'new-version' ); $( '#km-version' ).addClass( 'new-version' );
localStorage.lastKMVersion = KM.version; localStorage.lastKMVersion = KM.version;
} }
}); });
km.on('unziperror', function(ev){ km.on('unziperror', function(ev) {
alert('unziperror'); alert('unziperror');
}); });
km.on('parseerror', function(ev){ km.on('parseerror', function(ev) {
alert('parseerror'); alert('parseerror');
}); });
km.on('unknownprotocal', function(ev){ km.on('unknownprotocal', function(ev) {
alert('unknownprotocal'); alert('unknownprotocal');
}); });
</script> </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>
<!--Baidu Tongji Code--> <!--Baidu Tongji Code-->
<script type="text/javascript"> <script type="text/javascript">
if (document.domain == 'naotu.baidu.com') { if (document.domain == 'naotu.baidu.com') {
var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://"); var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F0703917f224067c887f3664479a03887' type='text/javascript'%3E%3C/script%3E")); document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F0703917f224067c887f3664479a03887' type='text/javascript'%3E%3C/script%3E"));
} }
</script> </script>
</html> </html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -63,14 +63,14 @@ ...@@ -63,14 +63,14 @@
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ 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' 'undo redo | template theme | fontfamily fontsize bold italic forecolor | node hyperlink unhyperlink image removeimage markers resource | collapsenode expandnode | hand zoom-in zoom zoom-out | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
//设置主题 //设置主题
//,defaultlayoutstyle : 'default' //设置默认的主题 //,defaultTemplate : 'default' //设置默认的主题
//,layoutstyle : [] //添加有那些主图 //,defaultTheme : 'fresh-blue' //添加有那些主图
//回退相关选项 //回退相关选项
//,maxUndoCount:20 //最大可回退的次数,默认20 //,maxUndoCount:20 //最大可回退的次数,默认20
......
KityMinder.LANG['zh-cn'] = { KityMinder.LANG['zh-cn'] = {
'template': {
'default': '思维导图',
'structure': '组织结构图'
},
'theme': {
'classic': '脑图经典',
'snow': '温柔冷光',
'fresh-red': '清新红',
'fresh-soil': '泥土黄',
'fresh-green': '文艺绿',
'fresh-blue': '天空蓝',
'fresh-purple': '浪漫紫',
'fresh-pink': '脑残粉'
},
'maintopic': '中心主题', 'maintopic': '中心主题',
'topic': '分支主题', 'topic': '分支主题',
'tooltips': { 'tooltips': {
...@@ -21,9 +35,11 @@ KityMinder.LANG['zh-cn'] = { ...@@ -21,9 +35,11 @@ KityMinder.LANG['zh-cn'] = {
'preference': '偏好设置', 'preference': '偏好设置',
'image': '插入图片', 'image': '插入图片',
'hyperlink': '插入链接', 'hyperlink': '插入链接',
'unhyperlink': "删除链接", 'unhyperlink': '删除链接',
'expandnode': "展开节点", 'expandnode': '展开节点',
'collapsenode': "收起节点" 'collapsenode': '收起节点',
'template': '模板',
'theme': '皮肤'
}, },
'popupcolor': { 'popupcolor': {
'clearColor': '清空颜色', 'clearColor': '清空颜色',
...@@ -72,11 +88,17 @@ KityMinder.LANG['zh-cn'] = { ...@@ -72,11 +88,17 @@ KityMinder.LANG['zh-cn'] = {
}, },
'hyperlink': { 'hyperlink': {
'hyperlink': '插入超链接', 'hyperlink': '插入超链接',
'unhyperlink': "取消超链接" 'unhyperlink': '取消超链接'
}, },
'image': { 'image': {
'image': '插入图片', 'image': '插入图片',
'removeimage': '删除图片' 'removeimage': '删除图片'
},
'marker': {
'marker': '设置进度/优先级'
},
'resource': {
'resource': '设置资源'
} }
}; };
\ No newline at end of file
/*! /*!
* ==================================================== * ====================================================
* kity - v2.0.0 - 2014-06-23 * kity - v2.0.0 - 2014-07-01
* https://github.com/fex-team/kity * https://github.com/fex-team/kity
* GitHub: https://github.com/fex-team/kity.git * GitHub: https://github.com/fex-team/kity.git
* Copyright (c) 2014 Baidu FEX; Licensed BSD * Copyright (c) 2014 Baidu FEX; Licensed BSD
...@@ -177,9 +177,19 @@ define("animate/animator", [ "animate/timeline", "graphic/eventhandler", "animat ...@@ -177,9 +177,19 @@ define("animate/animator", [ "animate/timeline", "graphic/eventhandler", "animat
var queue = this._KityAnimateQueue; var queue = this._KityAnimateQueue;
if (queue) { if (queue) {
while (queue.length) { while (queue.length) {
queue.shift().stop(); queue.shift().t.stop();
} }
} }
return this;
},
pause: function() {
var queue = this._KityAnimateQueue;
if (queue) {
while (queue.length) {
queue.shift().t.pause();
}
}
return this;
} }
}); });
return Animator; return Animator;
...@@ -1668,6 +1678,9 @@ define("graphic/box", [ "core/class" ], function(require, exports, module) { ...@@ -1668,6 +1678,9 @@ define("graphic/box", [ "core/class" ], function(require, exports, module) {
var xMin = Math.min(this.x, another.x), xMax = Math.max(this.right, another.right), yMin = Math.min(this.y, another.y), yMax = Math.max(this.bottom, another.bottom); var xMin = Math.min(this.x, another.x), xMax = Math.max(this.right, another.right), yMin = Math.min(this.y, another.y), yMax = Math.max(this.bottom, another.bottom);
return new Box(xMin, yMin, xMax - xMin, yMax - yMin); return new Box(xMin, yMin, xMax - xMin, yMax - yMin);
}, },
expand: function(ex, ey, ew, eh) {
return new Box(this.x + ex, this.y + ey, this.width - ex + ew, this.height - ey + eh);
},
valueOf: function() { valueOf: function() {
return [ this.x, this.y, this.width, this.height ]; return [ this.x, this.y, this.width, this.height ];
}, },
...@@ -3541,7 +3554,7 @@ define("graphic/group", [ "graphic/shapecontainer", "graphic/container", "core/u ...@@ -3541,7 +3554,7 @@ define("graphic/group", [ "graphic/shapecontainer", "graphic/container", "core/u
return require("core/class").createClass("Group", { return require("core/class").createClass("Group", {
mixins: [ ShapeContainer ], mixins: [ ShapeContainer ],
base: require("graphic/shape"), base: require("graphic/shape"),
constructor: function() { constructor: function Group() {
this.callBase("g"); this.callBase("g");
} }
}); });
...@@ -4009,39 +4022,40 @@ define("graphic/matrix", [ "core/utils", "graphic/box", "core/class", "graphic/p ...@@ -4009,39 +4022,40 @@ define("graphic/matrix", [ "core/utils", "graphic/box", "core/class", "graphic/p
e: 0, e: 0,
f: 0 f: 0
}; };
var node = target.shapeNode || target.node;
refer = refer || "parent"; refer = refer || "parent";
// 根据参照坐标系选区的不一样,返回不同的结果 // 根据参照坐标系选区的不一样,返回不同的结果
switch (refer) { switch (refer) {
case "screen": case "screen":
// 以浏览器屏幕为参照坐标系 // 以浏览器屏幕为参照坐标系
ctm = target.node.getScreenCTM(); ctm = node.getScreenCTM();
break; break;
case "doc": case "doc":
case "paper": case "paper":
// 以文档(Paper)为参照坐标系 // 以文档(Paper)为参照坐标系
ctm = target.node.getCTM(); ctm = node.getCTM();
break; break;
case "view": case "view":
case "top": case "top":
// 以顶层绘图容器(视野)为参照坐标系 // 以顶层绘图容器(视野)为参照坐标系
if (target.getPaper()) { if (target.getPaper()) {
ctm = target.node.getTransformToElement(target.getPaper().shapeNode); ctm = node.getTransformToElement(target.getPaper().shapeNode);
} }
break; break;
case "parent": case "parent":
// 以父容器为参照坐标系 // 以父容器为参照坐标系
if (target.node.parentNode) { if (target.node.parentNode) {
ctm = target.node.getTransformToElement(target.node.parentNode); ctm = node.getTransformToElement(target.node.parentNode);
} }
break; break;
default: default:
// 其他情况,指定参照物 // 其他情况,指定参照物
if (refer.node) { if (refer.node) {
ctm = target.node.getTransformToElement(refer.shapeNode || refer.node); ctm = node.getTransformToElement(refer.shapeNode || refer.node);
} }
} }
return ctm ? new Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f) : new Matrix(); return ctm ? new Matrix(ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f) : new Matrix();
...@@ -4292,6 +4306,9 @@ define("graphic/paper", [ "core/class", "core/utils", "graphic/svg", "graphic/co ...@@ -4292,6 +4306,9 @@ define("graphic/paper", [ "core/class", "core/utils", "graphic/svg", "graphic/co
} }
return parent; return parent;
}, },
isAttached: function() {
return !!this.getPaper();
},
whenPaperReady: function(fn) { whenPaperReady: function(fn) {
var me = this; var me = this;
function check() { function check() {
...@@ -4758,7 +4775,7 @@ define("graphic/rect", [ "core/utils", "graphic/point", "core/class", "graphic/b ...@@ -4758,7 +4775,7 @@ define("graphic/rect", [ "core/utils", "graphic/point", "core/class", "graphic/b
return Math.min(minValue, radius); return Math.min(minValue, radius);
} }
}); });
return require("core/class").createClass("Rect", { var Rect = require("core/class").createClass("Rect", {
base: require("graphic/path"), base: require("graphic/path"),
constructor: function(width, height, x, y, radius) { constructor: function(width, height, x, y, radius) {
this.callBase(); this.callBase();
...@@ -4861,6 +4878,7 @@ define("graphic/rect", [ "core/utils", "graphic/point", "core/class", "graphic/b ...@@ -4861,6 +4878,7 @@ define("graphic/rect", [ "core/utils", "graphic/point", "core/class", "graphic/b
return this.update(); return this.update();
} }
}); });
return Rect;
}); });
define("graphic/regularpolygon", [ "graphic/point", "core/class", "graphic/path", "core/utils", "graphic/shape", "graphic/svg", "graphic/geometry" ], function(require, exports, module) { define("graphic/regularpolygon", [ "graphic/point", "core/class", "graphic/path", "core/utils", "graphic/shape", "graphic/svg", "graphic/geometry" ], function(require, exports, module) {
var Point = require("graphic/point"); var Point = require("graphic/point");
...@@ -4949,7 +4967,7 @@ define("graphic/shape", [ "graphic/svg", "core/utils", "graphic/eventhandler", " ...@@ -4949,7 +4967,7 @@ define("graphic/shape", [ "graphic/svg", "core/utils", "graphic/eventhandler", "
var Box = require("graphic/box"); var Box = require("graphic/box");
var Shape = require("core/class").createClass("Shape", { var Shape = require("core/class").createClass("Shape", {
mixins: [ EventHandler, Styled, Data ], mixins: [ EventHandler, Styled, Data ],
constructor: function(tagName) { constructor: function Shape(tagName) {
this.node = svg.createNode(tagName); this.node = svg.createNode(tagName);
this.node.shape = this; this.node.shape = this;
this.transform = { this.transform = {
...@@ -5198,6 +5216,10 @@ define("graphic/shapecontainer", [ "graphic/container", "core/class", "core/util ...@@ -5198,6 +5216,10 @@ define("graphic/shapecontainer", [ "graphic/container", "core/class", "core/util
addShape: function(shape, index) { addShape: function(shape, index) {
return this.addItem(shape, index); return this.addItem(shape, index);
}, },
put: function(shape) {
this.addShape(shape);
return shape;
},
appendShape: function(shape) { appendShape: function(shape) {
return this.addShape(shape); return this.addShape(shape);
}, },
...@@ -5347,10 +5369,12 @@ define("graphic/shapeevent", [ "graphic/matrix", "core/utils", "graphic/box", "g ...@@ -5347,10 +5369,12 @@ define("graphic/shapeevent", [ "graphic/matrix", "core/utils", "graphic/box", "g
return null; return null;
} }
var eventClient = this.originEvent.touches ? this.originEvent.touches[touchIndex || 0] : this.originEvent; var eventClient = this.originEvent.touches ? this.originEvent.touches[touchIndex || 0] : this.originEvent;
var clientX = eventClient && eventClient.clientX || 0, clientY = eventClient && eventClient.clientY || 0, node = this.targetShape.shapeNode || this.targetShape.node, // 鼠标位置在目标对象上的坐标 var target = this.targetShape;
// 基于屏幕坐标算 var targetNode = target.shapeNode || target.node;
point = Matrix.transformPoint(clientX, clientY, node.getScreenCTM().inverse()); var pScreen = new kity.Point(eventClient && eventClient.clientX || 0, eventClient && eventClient.clientY || 0);
return Matrix.getCTM(this.targetShape, refer || "view").transformPoint(point); var pTarget = Matrix.transformPoint(pScreen, targetNode.getScreenCTM().inverse());
var pRefer = Matrix.getCTM(target, refer || "view").transformPoint(pTarget);
return pRefer;
}, },
stopPropagation: function() { stopPropagation: function() {
var evt = this.originEvent; var evt = this.originEvent;
...@@ -5770,10 +5794,10 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", " ...@@ -5770,10 +5794,10 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", "
var TextContent = require("graphic/textcontent"); var TextContent = require("graphic/textcontent");
var ShapeContainer = require("graphic/shapecontainer"); var ShapeContainer = require("graphic/shapecontainer");
var svg = require("graphic/svg"); var svg = require("graphic/svg");
var utils = require("core/utils");
var offsetHash = {}; var offsetHash = {};
function getTextBoundOffset(text) { function getTextBoundOffset(text) {
var style = window.getComputedStyle(text.node); var font = text._cachedFontHash;
var font = [ style.fontFamily, style.fontSize, style.fontStretch, style.fontStyle, style.fontVariant, style.fontWeight ].join("-");
if (offsetHash[font]) { if (offsetHash[font]) {
return offsetHash[font]; return offsetHash[font];
} }
...@@ -5796,6 +5820,22 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", " ...@@ -5796,6 +5820,22 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", "
if (content !== undefined) { if (content !== undefined) {
this.setContent(content); this.setContent(content);
} }
this._buildFontHash();
},
_buildFontHash: function() {
var style = window.getComputedStyle(this.node);
this._cachedFontHash = [ style.fontFamily, style.fontSize, style.fontStretch, style.fontStyle, style.fontVariant, style.fontWeight ].join("-");
},
_fontChanged: function(font) {
var last = this._lastFont;
var current = utils.extend({}, last, font);
if (!last) {
last = font;
return true;
}
var changed = last.family != current.family || last.size != current.size || last.style != current.style || last.weight != current.weight;
last = current;
return changed;
}, },
setX: function(x) { setX: function(x) {
this.node.setAttribute("x", x); this.node.setAttribute("x", x);
...@@ -5816,7 +5856,11 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", " ...@@ -5816,7 +5856,11 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", "
}, },
setFont: function(font) { setFont: function(font) {
this.callBase(font); this.callBase(font);
return this.setVerticalAlign(this.getVerticalAlign()); if (this._fontChanged(font)) {
this._buildFontHash();
this.setVerticalAlign(this.getVerticalAlign());
}
return this;
}, },
setTextAnchor: function(anchor) { setTextAnchor: function(anchor) {
this.node.setAttribute("text-anchor", anchor); this.node.setAttribute("text-anchor", anchor);
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -9,27 +9,6 @@ function DraftManager( minder ) { ...@@ -9,27 +9,6 @@ function DraftManager( minder ) {
function init() { function init() {
drafts = localStorage.getItem( 'drafts' ); drafts = localStorage.getItem( 'drafts' );
drafts = drafts ? JSON.parse( 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() { function store() {
...@@ -58,7 +37,7 @@ function DraftManager( minder ) { ...@@ -58,7 +37,7 @@ function DraftManager( minder ) {
function load() { function load() {
if ( current ) { if ( current ) {
minder.importData( current.data, "json" ); minder.importData( current.data, 'json' );
} }
return current; return current;
} }
...@@ -80,8 +59,9 @@ function DraftManager( minder ) { ...@@ -80,8 +59,9 @@ function DraftManager( minder ) {
} else { } else {
current.path = path || current.path; current.path = path || current.path;
current.name = minder.getMinderTitle(); current.name = minder.getMinderTitle();
current.data = minder.exportData( "json" ); var data = minder.exportData( 'json' );
current.sync = false; current.sync = current.sync && (data == current.data);
current.data = data;
current.update = new Date(); current.update = new Date();
store(); store();
} }
......
#social{position:absolute;right:10px;top:10px;line-height:20px;text-align:right;overflow:hidden} .niceblue{color:#fff;background:-moz-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #0099f2), color-stop(0, #4096ee), color-stop(100%, #0076dd));background:-webkit-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-o-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-ms-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:linear-gradient(to bottom, #0099f2 0, #4096ee 0, #0076dd 100%);}
.dropdown{padding-right:28px}.dropdown: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} .dropdown{padding-right:28px;position:relative}.dropdown:after{content:' ';display:block;position:absolute;right:10px;top:12px;width:0;height:0;border:solid;border-width:4px 5px;border-color:#333 transparent transparent transparent}
button{font-family:Arial,"Heiti SC","Microsoft Yahei";outline:none;display:inline-block;vertical-align:middle;padding:0 15px;height:35px;font-size:13px;line-height:35px;text-align:center;border-radius:5px;color:#fff;text-decoration:none;border:none;margin-left:5px;cursor:pointer;background:#0099f2;background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);background:-moz-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #0099f2), color-stop(0, #4096ee), color-stop(100%, #0076dd));background:-webkit-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-o-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-ms-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:linear-gradient(to bottom, #0099f2 0, #4096ee 0, #0076dd 100%);}button:hover,button.hover{background:#009fff} .dropdown:active:after,.dropdown.active:after{border-color:#fff transparent transparent transparent}
button{font-family:Arial,"Heiti SC","Microsoft Yahei";outline:none;display:inline-block;vertical-align:middle;/* font-size: 12px; */padding:0 15px;height:30px;font-size: 12px;line-height:30px;text-align:center;color:#000;text-decoration:none;border:none;margin-left:5px;background:none;border-radius: 0px;color:#fff;background:-moz-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #0099f2), color-stop(0, #4096ee), color-stop(100%, #0076dd));background:-webkit-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-o-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-ms-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:linear-gradient(to bottom, #0099f2 0, #4096ee 0, #0076dd 100%);}button:hover,button.hover{background:#009fff}
button:active,button.active{background:#007fcc;box-shadow:inset 0 2px 3px rgba(0,0,0,0.2)} button:active,button.active{background:#007fcc;box-shadow:inset 0 2px 3px rgba(0,0,0,0.2)}
button[disabled]{background:#aaa;cursor:default} button[disabled]{cursor:default;background:#ccc}
button.baidu-cloud{padding-left:35px;position:relative}button.baidu-cloud:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/baiducloud.png);position:absolute;left:7px;top:5px} .draft-menu.kmui-dropdown-menu{margin-top:24px;margin-left:1px}.draft-menu.kmui-dropdown-menu span.update-time{float:right;color:#ccc;margin-left:20px;padding-right:16px}
button.share{padding-left:35px;position:relative}button.share:before{content:' ';display:block;width:24px;height:24px;background:url(../themes/default/images/share.png) no-repeat;position:absolute;left:7px;top:5px} .draft-menu.kmui-dropdown-menu li.draft-item a{position:relative}.draft-menu.kmui-dropdown-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}
button img{position:relative;top:3px;border-radius:2px;margin-right:7px} .draft-menu.kmui-dropdown-menu li.draft-item:hover a:before{background-position:0 -48px}
button.user-file{position:relative;padding-right:28px}button.user-file img{border:none;outline:none} .draft-menu.kmui-dropdown-menu li.draft-item{position:relative}.draft-menu.kmui-dropdown-menu li.draft-item:hover a.delete{display:block}
button.user-file span.text{display:inline-block;height:24px;line-height:24px} .draft-menu.kmui-dropdown-menu li.draft-item a.delete{display:none;cursor:pointer;position:absolute;width:20px;height:20px;right:4px;top:4px;padding:0;background:url(../themes/default/images/close-button.png) no-repeat 0 0}.draft-menu.kmui-dropdown-menu li.draft-item a.delete:before{display:none}
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-menu.kmui-dropdown-menu li.draft-item a.delete:hover{background-position:0 -20px}
#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.kmui-dropdown-menu.kmui-combobox-menu .kmui-combobox-checked{overflow:hidden;opacity:1;color:#ccc}.draft-menu.kmui-dropdown-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon{float:left;margin:5px 0;width:28px;background-position:center 0;opacity:.3}
.draft-menu span.update-time{float:right;color:#ccc;margin-left:20px;padding-right:16px} .draft-menu.kmui-dropdown-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-item-label{display:block;margin-left:28px}
.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.kmui-dropdown-menu.kmui-combobox-menu .kmui-combobox-checked:hover{color:#ccc}.draft-menu.kmui-dropdown-menu.kmui-combobox-menu .kmui-combobox-checked:hover .kmui-combobox-icon{background-position:center 0}
.draft-menu li.draft-item:hover a:before{background-position:0 -48px} .file-menu.kmui-dropdown-menu{margin-top:24px;margin-left:1px;border-radius:4px;box-shadow:0 1px 5px rgba(0,0,0,0.3)}.file-menu.kmui-dropdown-menu #save-button,.file-menu.kmui-dropdown-menu #manage-file-button{display:none}
.draft-menu li.draft-item{position:relative}.draft-menu li.draft-item:hover a.delete{display:block} .file-menu.kmui-dropdown-menu.logined #save-button,.file-menu.kmui-dropdown-menu.logined #manage-file-button{display:block}
.draft-menu li.draft-item a.delete{display:none;cursor:pointer;position:absolute;width:20px;height:20px;right:4px;top:4px;padding:0;background:url(../themes/default/images/close-button.png) no-repeat 0 0}.draft-menu li.draft-item a.delete:before{display:none} .file-menu.kmui-dropdown-menu.logined #net-hint-buttom{display:none}
.draft-menu li.draft-item a.delete:hover{background-position:0 -20px} .user-menu.kmui-dropdown-menu{margin-top:24px;margin-left:-25px;min-width:130px;border-radius:4px;box-shadow:0 1px 5px rgba(0,0,0,0.3)}.user-menu.kmui-dropdown-menu li a{padding-left:40px}
.draft-menu.kmui-combobox-menu .kmui-combobox-checked{overflow:hidden;opacity:1;color:#ccc}.draft-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon{float:left;margin:5px 0;width:28px;background-position:center 0;opacity:.3} #share-dialog{position:absolute;padding:20px;border-radius:4px;left:50%;top:40%;margin-left:-175px;margin-top:-100px;background:#fff;width:350px;box-shadow:1px 2px 16px rgba(0,0,0,0.5);display:none}#share-dialog h3{margin:0;font-size:16px;color:#666}
.draft-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-item-label{display:block;margin-left:28px}
.draft-menu.kmui-combobox-menu .kmui-combobox-checked:hover{color:#ccc}.draft-menu.kmui-combobox-menu .kmui-combobox-checked:hover .kmui-combobox-icon{background-position:center 0}
.user-file-menu{margin-top:20px;margin-left:1px}
#share-dialog{position:absolute;padding:20px;border-radius:4px;right:10px;top:65px;background:#fff;width:350px;box-shadow:1px 2px 16px rgba(0,0,0,0.5);display:none}#share-dialog h3{margin:0;font-size:16px;color:#666}
#share-dialog input{width:260px;height:22px;line-height:22px;padding:4px 4px 0;border:1px solid #999;vertical-align:middle;margin-right:3px;background:#eee}#share-dialog input:focus{border:1px solid #99f;outline:none} #share-dialog input{width:260px;height:22px;line-height:22px;padding:4px 4px 0;border:1px solid #999;vertical-align:middle;margin-right:3px;background:#eee}#share-dialog input:focus{border:1px solid #99f;outline:none}
#share-dialog p,#share-dialog #share-platform{margin:20px 0 30px} #share-dialog p,#share-dialog #share-platform{margin:20px 0 30px}
#share-dialog #copy-share-url{display:inline-block;margin:0;width:70px;height:28px;line-height:28px;border-radius:2px;vertical-align:middle} #share-dialog #copy-share-url{display:inline-block;margin:0;width:70px;height:28px;line-height:28px;border-radius:2px;vertical-align:middle;border-radius:5px;color:#fff;background:-moz-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #0099f2), color-stop(0, #4096ee), color-stop(100%, #0076dd));background:-webkit-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-o-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-ms-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:linear-gradient(to bottom, #0099f2 0, #4096ee 0, #0076dd 100%);}#share-dialog #copy-share-url:hover,#share-dialog #copy-share-url.hover{background:#009fff}
#share-dialog #copy-share-url:active,#share-dialog #copy-share-url.active{background:#007fcc;box-shadow:inset 0 2px 3px rgba(0,0,0,0.2)}
#share-dialog #share-platform{margin-bottom:0} #share-dialog #share-platform{margin-bottom:0}
#share-dialog:before{position:absolute;content:' ';width:0;height:0;line-height:0;display:block;border:10px solid transparent;border-bottom-color:#fff;right:30px;top:-20px}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 百度脑图社会化功能 * 百度脑图社会化功能
* *
* 1. 百度账号登 * 1. 百度账号登
* 2. 百度云存储 * 2. 百度云存储
* 3. 分享 * 3. 分享
* 4. 草稿箱同步 * 4. 草稿箱同步
...@@ -11,48 +11,48 @@ ...@@ -11,48 +11,48 @@
*/ */
$.extend( $.fn, { $.extend($.fn, {
disabled: function ( value ) { disabled: function(value) {
if ( value === undefined ) return !!this.attr( 'disabled' ); if (value === undefined) return !!this.attr('disabled');
if ( value ) { if (value) {
this.attr( 'disabled', 'disabled' ); this.attr('disabled', 'disabled');
} else { } else {
this.removeAttr( 'disabled' ); this.removeAttr('disabled');
} }
return this; return this;
}, },
loading: function ( text ) { loading: function(text) {
if ( text ) { if (text) {
this.disabled( true ); this.disabled(true);
this.attr( 'origin-text', this.text() ); this.attr('origin-text', this.text());
this.text( text ); this.text(text);
} else { } else {
this.text( this.attr( 'origin-text' ) ); this.text(this.attr('origin-text'));
this.removeAttr( 'origin-text' ); this.removeAttr('origin-text');
this.disabled( false ); this.disabled(false);
} }
return this; return this;
}, },
text: ( function () { text: (function() {
var originFn = $.fn.text; var originFn = $.fn.text;
return function () { return function() {
var textSpan = this.children( 'span.text' ); var textSpan = this.children('span.text');
if ( textSpan.length ) { if (textSpan.length) {
return originFn.apply( textSpan, arguments ); return originFn.apply(textSpan, arguments);
} else { } else {
return originFn.apply( this, arguments ); return originFn.apply(this, arguments);
} }
}; };
} )() })()
} ); });
/** /**
* 核心业务逻辑 * 核心业务逻辑
*/ */
$( function () { $(function() {
// UI 元素 // UI 元素
var $panel, $login_btn, $save_btn, $share_btn, $user_btn, $user_menu, var $panel, $title, $menu, $user, $share_btn, $save_btn, $file_btn, $tool_btn, $file_menu, $login_btn, $user_btn, $user_menu,
$draft_btn, $draft_menu, $share_dialog, $share_url, $copy_url_btn, $draft_btn, $draft_menu, $share_dialog, $share_url, $copy_url_btn,
// 当前文件的远端路径 // 当前文件的远端路径
...@@ -66,8 +66,8 @@ $( function () { ...@@ -66,8 +66,8 @@ $( function () {
isPathLink, isPathLink,
uuid = function () { uuid = function() {
return ( ( +new Date() * 10000 ) + ( Math.random() * 9999 ) ).toString( 36 ); return ((+new Date() * 10000) + (Math.random() * 9999)).toString(36);
}, },
// 当前脑图的分享ID // 当前脑图的分享ID
...@@ -84,144 +84,229 @@ $( function () { ...@@ -84,144 +84,229 @@ $( function () {
// 当前是否要检测文档内容是否变化的开关 // 当前是否要检测文档内容是否变化的开关
watchingChanges = true, watchingChanges = true,
notice = ( function () { notice = (function() {
return window.alert; return window.alert;
} )(); })();
start(); start();
function start() { function start() {
initUI(); initUI();
initFrontia(); initFrontia();
if ( checkLogin() ) { if (checkLogin()) {
return; return;
} }
loadShare(); loadShare();
bindShortCuts(); bindShortCuts();
bindDraft(); bindDraft();
if ( draftManager ) watchChanges(); if (draftManager) watchChanges();
if (draftManager && !loadPath() && !isShareLink) loadDraft(0);
}
function createFileMenu() {
var menus = [{
label: '新建 (Ctrl + N)',
click: newFile
}, {
divider: true
}];
// 导入菜单组
var acceptFiles = [];
KityMinder.getSupportedProtocals().forEach(function(name) {
var p = KityMinder.findProtocal(name);
if (p.decode) {
acceptFiles.push(p.fileExtension);
}
});
menus = menus.concat([{
label: '导入本地文件',
click: function() {
$('<input type="file" />')
.attr('accept', acceptFiles.join(','))
.on('change', function(e) {
e = e.originalEvent;
minder.importFile(e.target.files[0]);
}).click();
}
}, {
divider: true
}]);
// 导出菜单组
KityMinder.getSupportedProtocals().forEach(function(name) {
var p = KityMinder.findProtocal(name);
if (p.encode) {
var text = p.fileDescription + '(' + p.fileExtension + ')';
menus.push({
label: '导出 ' + text,
click: function() {
minder.exportFile(name);
}
});
}
});
menus = menus.concat([{
divider: true,
}, {
label: '登陆',
click: login,
id: 'net-hint-buttom'
}, {
label: '保存到百度云 (Ctrl + S)',
click: save,
id: 'save-button'
}, {
divider: true
}]);
return menus;
} }
// 创建 UI // 创建 UI
function initUI() { function initUI() {
$panel = $( '<div id="social"></div>' ).appendTo( 'body' ); $panel = $('#panel');
$login_btn = $( '<button>登录</button>' ).addClass( 'login' ).click( login ).appendTo( $panel ); $menu = $('<div id="menu"></div>').appendTo($panel);
$user = $('<div id="user"></div>').appendTo($panel);
$title = $('<h1 id="title"></h1>').appendTo($panel);
$user_btn = $( '<button><span class="text"></span></button>' ).addClass( 'user-file' ); $file_btn = $('<button id="file-btn">文件</button>').addClass('dropdown').appendTo($menu);
$user_menu = $.kmuidropmenu( { $file_menu = $.kmuidropmenu({ data: createFileMenu() })
data: [ { .addClass('file-menu')
label: '新建脑图', .appendTo('body');
click: newFile
}, { $file_menu.kmui().attachTo($file_btn);
label: '到网盘管理文件...',
click: function () { $save_btn = $('#save-btn').find('a');
window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' ); $share_btn = $('<button id="share-btn">分享</button>').click(share).appendTo($user);
}
}, { $draft_btn = $('<button id="draft-btn">草稿箱</button>').addClass('dropdown').appendTo($menu);
label: '注销',
click: logout
}, {
divider: true
} ]
} ).addClass( 'user-file-menu' ).appendTo( 'body' ).kmui();
$user_menu.attachTo( $user_btn ); $draft_menu = $.kmuidropmenu().addClass('draft-menu kmui-combobox-menu').appendTo('body');
$draft_menu.kmui().attachTo($draft_btn);
$draft_menu.on('aftershow', showDraftList);
$save_btn = $( '<button id="save-btn">保存</button>' ).click( save ) $tool_btn = $('<button id="tool-btn" title="打开/收起工具箱">工具箱</button>').appendTo($menu);
.addClass( 'baidu-cloud' );
$share_btn = $( '<button id="share-btn">分享</button>' ).click( share ) $tool_btn.click(function() {
.addClass( 'share' ).appendTo( $panel ); var hide = !localStorage.hide_toolbar;
$('#kityminder div.kmui-btn-toolbar').css('display', hide ? 'none' : 'block');
if (hide) {
$tool_btn.removeClass('active');
localStorage.hide_toolbar = true;
} else {
$tool_btn.addClass('active');
delete localStorage.hide_toolbar;
}
}).click().click();
$draft_btn = $( '<button id="draft-btn">草稿箱</button>' ).appendTo( 'body' ); $login_btn = $('<button id="login-btn">登录</button>').appendTo($user).click(login);
$user_btn = $('<button id="user-btn">用户</button>').addClass('dropdown').appendTo($user);
$draft_menu = $.kmuidropmenu().addClass( 'draft-menu kmui-combobox-menu' ).appendTo( 'body' ); $user_menu = $.kmuidropmenu({
$draft_menu.kmui().attachTo( $draft_btn ); data: [{
$draft_menu.on( 'aftershow', showDraftList ); label: '个人中心',
click: function() {
window.open('http://i.baidu.com/', '_blank');
}
}, {
label: '管理云文件',
click: function() {
window.open('http://pan.baidu.com/disk/home#dir/path=/apps/kityminder');
},
id: 'manage-file-button'
}, {
divider: true,
}, {
label: '注销',
click: logout
}]
}).addClass('user-menu').appendTo('body').kmui().attachTo($user_btn);
$share_dialog = $( '#share-dialog' ); $share_dialog = $('#share-dialog');
$share_url = $( '#share-url' ); $share_url = $('#share-url');
$copy_url_btn = $( '#copy-share-url' ); $copy_url_btn = $('#copy-share-url');
$share_dialog.mousedown( function ( e ) { $share_dialog.mousedown(function(e) {
e.stopPropagation(); e.stopPropagation();
} ); });
var copyTrickTimer = 0; var copyTrickTimer = 0;
$( 'body' ).on( 'mousedown', function ( e ) { $('body').on('mousedown', function(e) {
copyTrickTimer = setTimeout( function () { copyTrickTimer = setTimeout(function() {
$share_dialog.hide(); $share_dialog.hide();
$share_btn.loading( false ); $share_btn.loading(false);
$copy_url_btn.loading( false ); $copy_url_btn.loading(false);
}, 30 ); }, 30);
} ); });
if ( window.ZeroClipboard ) { 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'
} ); });
clip.on( 'dataRequested', function ( client, args ) { clip.on('dataRequested', function(client, args) {
$copy_url_btn.loading( '已复制' ); $copy_url_btn.loading('已复制');
clearTimeout( copyTrickTimer ); clearTimeout(copyTrickTimer);
} ); });
} }
} }
// 初始化云平台 frontia // 初始化云平台 frontia
function initFrontia() { function initFrontia() {
var AK = 'wiE55BGOG8BkGnpPs6UNtPbb'; var AK = 'wiE55BGOG8BkGnpPs6UNtPbb';
baidu.frontia.init( AK ); baidu.frontia.init(AK);
baidu.frontia.social.setLoginCallback( { baidu.frontia.social.setLoginCallback({
success: setAccount, success: setAccount,
error: function ( error ) { error: function(error) {
notice( '登录失败!' ); notice('登录失败!');
} }
} ); });
} }
// 检查 URL 是否分享连接,是则加载分享内容 // 检查 URL 是否分享连接,是则加载分享内容
function loadShare() { function loadShare() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/; var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec( window.location ) || pattern.exec( document.referrer ); var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if ( !match ) return; if (!match) return;
var shareId = match[ 1 ]; var shareId = match[1];
$.ajax( { $.ajax({
url: 'http://naotu.baidu.com/mongo.php', url: 'http://naotu.baidu.com/mongo.php',
data: { data: {
action: 'find', action: 'find',
id: shareId id: shareId
}, },
dataType: 'json', dataType: 'json',
success: function ( data ) { success: function(data) {
if ( data.error ) { if (data.error) {
return notice( data.error ); return notice(data.error);
} }
if ( draftManager ) { if (draftManager) {
var draft = draftManager.openByPath( 'share/' + shareId ); var draft = draftManager.openByPath('share/' + shareId);
if ( draft ) { if (draft) {
draftManager.load(); draftManager.load();
} else { } else {
draftManager.create( 'share/' + shareId ); draftManager.create('share/' + shareId);
minder.importData( data.shareMinder.data, 'json' ); minder.importData(data.shareMinder.data, 'json');
} }
} else { } else {
minder.importData( data.shareMinder.data, 'json' ); minder.importData(data.shareMinder.data, 'json');
} }
setRemotePath( null, false ); $title.loading(false);
$share_btn.loading( false ); setRemotePath(null, false);
}, },
error: function () { error: function() {
notice( '请求分享文件失败,请重试!' ); notice('请求分享文件失败,请重试!');
} }
} ); });
$share_btn.loading( '正在加载分享内容...' ); $title.loading('正在加载分享内容...');
isShareLink = true; isShareLink = true;
} }
...@@ -230,47 +315,43 @@ $( function () { ...@@ -230,47 +315,43 @@ $( function () {
function loadPath() { function loadPath() {
var pattern = /path=(.+?)([&#]|$)/; var pattern = /path=(.+?)([&#]|$)/;
// documemt.referrer 是为了支持被嵌在 iframe 里的情况 // documemt.referrer 是为了支持被嵌在 iframe 里的情况
var match = pattern.exec( window.location ) || pattern.exec( document.referrer ); var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if ( !match ) return; if (!match) return;
if ( !currentAccount ) { if (!currentAccount) {
setTimeout( function () { setTimeout(function() {
if ( !currentAccount ) return login(); if (!currentAccount) return login();
setRemotePath( decodeURIComponent( match[ 1 ], true ) ); setRemotePath(decodeURIComponent(match[1], true));
loadRemote(); loadRemote();
}, 1000 ); }, 1000);
return false; return false;
} }
setRemotePath( decodeURIComponent( match[ 1 ], true ) ); setRemotePath(decodeURIComponent(match[1], true));
loadRemote(); loadRemote();
return true; return true;
} }
function setRemotePath( path, saved ) { function setRemotePath(path, saved) {
var filename; var filename;
remotePath = path; remotePath = path;
if ( remotePath ) { if (remotePath) {
filename = getFileName( remotePath ); filename = getFileName(remotePath);
if ( !saved ) { if (!saved) {
filename = '* ' + filename; filename = '* ' + filename;
} }
$user_btn.text( filename ); $title.text(filename);
} else if ( currentAccount ) { } else if (currentAccount) {
$user_btn.text( '* ' + minder.getMinderTitle() ); $title.text('* ' + minder.getMinderTitle());
}
document.title = [ filename || minder.getMinderTitle(), titleSuffix ].join( ' - ' );
if ( saved ) {
$save_btn.disabled( true ).text( '已保存' );
} else { } else {
$save_btn.disabled( false ).text( '保存' ); $title.text(filename || minder.getMinderTitle());
} }
document.title = [filename || minder.getMinderTitle(), titleSuffix].join(' - ');
} }
// 检查是否在 Cookie 中登录过了 // 检查是否在 Cookie 中登录过了
function checkLogin() { function checkLogin() {
var account = baidu.frontia.getCurrentAccount(); var account = baidu.frontia.getCurrentAccount();
if ( account ) { if (account) {
login(); login();
return true; return true;
} }
...@@ -279,88 +360,83 @@ $( function () { ...@@ -279,88 +360,83 @@ $( function () {
// 用户点击登录按钮主动登录 // 用户点击登录按钮主动登录
function login() { function login() {
baidu.frontia.social.login( { baidu.frontia.social.login({
response_type: 'token', response_type: 'token',
media_type: 'baidu', media_type: 'baidu',
redirect_uri: window.location.href, redirect_uri: window.location.href,
client_type: 'web' client_type: 'web'
} ); });
$login_btn.text('正在登录...').css('text-decoration', 'none');
} }
function logout() { function logout() {
baidu.frontia.logOutCurrentAccount(); baidu.frontia.logOutCurrentAccount();
setAccount( null ); setAccount(null);
$file_menu.removeClass('logined');
$user.removeClass('logined');
} }
// 设置用户后为其初始化 // 设置用户后为其初始化
function setAccount( account ) { function setAccount(account) {
currentAccount = account; currentAccount = account;
if ( account ) { if (account) {
$user_btn.prependTo( $panel );
$save_btn.appendTo( $panel );
$share_btn.appendTo( $panel );
$login_btn.detach();
loadAvator(); loadAvator();
loadUserFiles(); loadUserFiles();
window.location.hash = ''; window.location.hash = '';
} else { $user_btn.text(account.accountName);
$user_btn.detach();
$save_btn.detach();
$login_btn.prependTo( $panel );
} }
$file_menu.addClass('logined');
$user.addClass('logined');
} }
// 加载用户头像 // 加载用户头像
function loadAvator() { function loadAvator() {
var $img = $( '<img />' ).attr( { currentAccount.getDetailInfo({
'src': 'social/loading.gif', success: function(user) {
'width': 16, $('<img />').attr({
'height': 16 'src': user.extra.headurl,
} ).prependTo( $user_btn ); 'width': 32,
currentAccount.getDetailInfo( { 'height': 32
success: function ( user ) { }).prependTo($user_btn);
$img.attr( {
'src': user.extra.tinyurl
} );
} }
} ); });
} }
// 加载用户最近使用的文件 // 加载用户最近使用的文件
function loadUserFiles() { function loadUserFiles() {
if ( loadUserFiles.tryCount ) { if (loadUserFiles.tryCount) {
console.warn( '加载用户最近使用的文件失败:第 ' + loadUserFiles.tryCount + '次' ); console.warn('加载用户最近使用的文件失败:第 ' + loadUserFiles.tryCount + '次');
} }
if ( loadUserFiles.tryCount > 3 ) { if (loadUserFiles.tryCount > 3) {
notice( '加载最近脑图失败!' ); notice('加载最近脑图失败!');
loadUserFiles.tryCount = 0; loadUserFiles.tryCount = 0;
} }
var sto = baidu.frontia.personalStorage; var sto = baidu.frontia.personalStorage;
if ( loadUserFiles.tryCount === 0 ) { if (loadUserFiles.tryCount === 0) {
loadUserFiles.$loadingMenuItem = $user_menu.appendItem( { loadUserFiles.$loadingMenuItem = $file_menu.kmui().appendItem({
item: { item: {
label: '正在加载最近脑图...', label: '正在加载最近脑图...',
disabled: 'disabled' disabled: 'disabled'
} }
} ); });
} }
sto.listFile( 'apps/kityminder/', { sto.listFile('apps/kityminder/', {
by: 'time', by: 'time',
success: function ( result ) { success: function(result) {
if ( result.list.length ) { if (result.list.length) {
loadUserFiles.$loadingMenuItem.remove(); loadUserFiles.$loadingMenuItem.remove();
addToRecentMenu( result.list.filter( function ( file ) { addToRecentMenu(result.list.filter(function(file) {
return getFileFormat( file.path ) in fileLoader; return getFileFormat(file.path) in fileLoader;
} ) ); }));
syncPreference( result.list ); syncPreference(result.list);
} }
}, },
error: loadUserFiles error: loadUserFiles
} ); });
loadUserFiles.tryCount++; loadUserFiles.tryCount++;
} }
...@@ -368,7 +444,7 @@ $( function () { ...@@ -368,7 +444,7 @@ $( function () {
loadUserFiles.tryCount = 0; loadUserFiles.tryCount = 0;
// 同步用户配置文件 // 同步用户配置文件
function syncPreference( fileList ) { function syncPreference(fileList) {
// frontia 接口对象引用 // frontia 接口对象引用
var sto = baidu.frontia.personalStorage; var sto = baidu.frontia.personalStorage;
...@@ -377,9 +453,9 @@ $( function () { ...@@ -377,9 +453,9 @@ $( function () {
var remotePreferencesPath = '/apps/kityminder/app.preferences'; var remotePreferencesPath = '/apps/kityminder/app.preferences';
// 检查是否存在线上的配置文件 // 检查是否存在线上的配置文件
var hasRemotePreferences = ~fileList.map( function ( file ) { var hasRemotePreferences = ~fileList.map(function(file) {
return file.path; return file.path;
} ).indexOf( remotePreferencesPath ); }).indexOf(remotePreferencesPath);
// 记录远端配置的和本地配置的版本 // 记录远端配置的和本地配置的版本
// - 远端配置保存在 json 内容的 version 字段中 // - 远端配置保存在 json 内容的 version 字段中
...@@ -392,15 +468,15 @@ $( function () { ...@@ -392,15 +468,15 @@ $( function () {
// 远端有配置,下载远端配置 // 远端有配置,下载远端配置
if ( hasRemotePreferences ) { if (hasRemotePreferences) {
downloadPreferences(); downloadPreferences();
} }
// 绑定实例上配置改变的事件,配置有变需要上传 // 绑定实例上配置改变的事件,配置有变需要上传
minder.on( 'preferenceschange', function () { minder.on('preferenceschange', function() {
localStorage.preferencesVersion = ++localVersion; localStorage.preferencesVersion = ++localVersion;
uploadPreferences(); uploadPreferences();
} ); });
// 下载远端配置 // 下载远端配置
function downloadPreferences() { function downloadPreferences() {
...@@ -408,16 +484,16 @@ $( function () { ...@@ -408,16 +484,16 @@ $( function () {
// 比较远端和本地版本 // 比较远端和本地版本
// - 远端版本较新则设置本地版本为远端版本 // - 远端版本较新则设置本地版本为远端版本
// - 本地版本较新则上传本地版本 // - 本地版本较新则上传本地版本
function merge( remote ) { function merge(remote) {
remoteVersion = remote.version; remoteVersion = remote.version;
remotePreferences = remote.preferences; remotePreferences = remote.preferences;
localPreferences = minder.getPreferences(); localPreferences = minder.getPreferences();
if ( localVersion < remoteVersion ) { if (localVersion < remoteVersion) {
minder.resetPreferences( remotePreferences ); minder.resetPreferences(remotePreferences);
} else if ( localVersion > remoteVersion ) { } else if (localVersion > remoteVersion) {
uploadPreferences(); uploadPreferences();
} }
...@@ -425,19 +501,19 @@ $( function () { ...@@ -425,19 +501,19 @@ $( function () {
// 下载配置的过程 // 下载配置的过程
// 需要先获得下载的 URL 再使用 ajax 请求内容 // 需要先获得下载的 URL 再使用 ajax 请求内容
sto.getFileUrl( remotePreferencesPath, { sto.getFileUrl(remotePreferencesPath, {
success: function ( url ) { success: function(url) {
$.ajax( { $.ajax({
url: url, url: url,
cache: false, cache: false,
dataType: 'json', dataType: 'json',
success: merge, success: merge,
error: function () { error: function() {
notice( '下载配置失败!' ); notice('下载配置失败!');
} }
} ); });
} }
} ); });
} }
// 上传本地配置 // 上传本地配置
...@@ -451,58 +527,58 @@ $( function () { ...@@ -451,58 +527,58 @@ $( function () {
preferences: localPreferences preferences: localPreferences
}; };
var text = JSON.stringify( data ); var text = JSON.stringify(data);
sto.uploadTextFile( text, remotePreferencesPath, { sto.uploadTextFile(text, remotePreferencesPath, {
// 文件重复选择覆盖 // 文件重复选择覆盖
ondup: sto.constant.ONDUP_OVERWRITE, ondup: sto.constant.ONDUP_OVERWRITE,
success: function ( savedFile ) { success: function(savedFile) {
console && console.log( '配置已上传' ); console && console.log('配置已上传');
}, },
error: function ( e ) { error: function(e) {
notice( '上传配置失败' ); notice('上传配置失败');
} }
} ); });
} }
} }
// 加载当前 remoteUrl 中制定的文件 // 加载当前 remoteUrl 中制定的文件
function loadRemote() { function loadRemote() {
if ( loadRemote.tryCount ) { if (loadRemote.tryCount) {
console.warn( '加载用户文件失败:第 ' + loadUserFiles.tryCount + '次' ); console.warn('加载用户文件失败:第 ' + loadUserFiles.tryCount + '次');
} }
// 失败重试判断 // 失败重试判断
if ( loadRemote.tryCount > 3 ) { if (loadRemote.tryCount > 3) {
notice( '加载脑图失败!' ); notice('加载脑图失败!');
loadRemote.tryCount = 0; loadRemote.tryCount = 0;
} }
var sto = baidu.frontia.personalStorage; var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载“' + getFileName( remotePath ) + '”...' ); $title.loading('加载“' + getFileName(remotePath) + '”...');
sto.getFileUrl( remotePath, { sto.getFileUrl(remotePath, {
success: function ( url ) { success: function(url) {
// the url to download the file on cloud dist // the url to download the file on cloud dist
var format = getFileFormat( remotePath ); var format = getFileFormat(remotePath);
if ( format in fileLoader ) { if (format in fileLoader) {
fileLoader[ format ]( url ); fileLoader[format](url);
} }
loadRemote.tryCount = 0; loadRemote.tryCount = 0;
}, },
error: loadRemote error: loadRemote
} ); });
loadRemote.tryCount++; loadRemote.tryCount++;
} }
loadRemote.tryCount = 0; loadRemote.tryCount = 0;
function getFileFormat( fileUrl ) { function getFileFormat(fileUrl) {
return fileUrl.split( '.' ).pop(); return fileUrl.split('.').pop();
} }
var fileLoader = { var fileLoader = {
...@@ -513,109 +589,109 @@ $( function () { ...@@ -513,109 +589,109 @@ $( function () {
'mm': loadFreeMind 'mm': loadFreeMind
}; };
function loadPlainType( url ) { function loadPlainType(url) {
$.ajax( { $.ajax({
cache: false, cache: false,
url: url, url: url,
dataType: 'text', dataType: 'text',
success: function ( result ) { success: function(result) {
importFile( result, 'json' ); importFile(result, 'json');
} }
} ); });
} }
function loadXMind( url ) { function loadXMind(url) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open( "get", url, true ); xhr.open("get", url, true);
xhr.responseType = "blob"; xhr.responseType = "blob";
xhr.onload = function () { xhr.onload = function() {
if ( this.status == 200 && this.readyState ) { if (this.status == 200 && this.readyState) {
var blob = this.response; var blob = this.response;
importFile( blob, 'xmind' ); importFile(blob, 'xmind');
} }
}; };
xhr.send(); xhr.send();
} }
function loadMindManager( url ) { function loadMindManager(url) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open( "get", url, true ); xhr.open("get", url, true);
xhr.responseType = "blob"; xhr.responseType = "blob";
xhr.onload = function () { xhr.onload = function() {
if ( this.status == 200 && this.readyState ) { if (this.status == 200 && this.readyState) {
var blob = this.response; var blob = this.response;
importFile( blob, 'mindmanager' ); importFile(blob, 'mindmanager');
} }
}; };
xhr.send(); xhr.send();
} }
function loadFreeMind( url ) { function loadFreeMind(url) {
$.ajax( { $.ajax({
cache: false, cache: false,
url: url, url: url,
dataType: 'text', dataType: 'text',
success: function ( result ) { success: function(result) {
importFile( result, 'freemind' ); importFile(result, 'freemind');
} }
} ); });
} }
// 见文件数据导入minder // 见文件数据导入minder
function importFile( data, format ) { function importFile(data, format) {
watchingChanges = false; watchingChanges = false;
minder.importData( data, format ); minder.importData(data, format);
if ( draftManager ) { 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(), 300);
$user_btn.loading( false ).text( getFileName( remotePath ) ); $title.loading(false).text(getFileName(remotePath));
watchingChanges = true; watchingChanges = true;
} }
// 添加文件到最近文件列表 // 添加文件到最近文件列表
function addToRecentMenu( list ) { function addToRecentMenu(list) {
list.splice( 12 ); list.splice(12);
list.forEach( function ( file ) { list.forEach(function(file) {
$user_menu.appendItem( { $file_menu.kmui().appendItem({
item: { item: {
label: getFileName( file.path ), label: getFileName(file.path),
value: file.path value: file.path
}, },
click: openFile click: openFile
} ); });
} ); });
} }
// 从路径中抽取文件名 // 从路径中抽取文件名
function getFileName( path ) { function getFileName(path) {
return path.split( '/' ).pop(); return path.split('/').pop();
} }
// 点击文件菜单 // 点击文件菜单
function openFile( e ) { function openFile(e) {
var path = $( this ).data( 'value' ); var path = $(this).data('value');
var draft = draftManager && 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 if ( draftManager ) { } 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) {
watchingChanges = false; watchingChanges = false;
draftManager.load(); draftManager.load();
watchingChanges = true; watchingChanges = true;
...@@ -623,65 +699,67 @@ $( function () { ...@@ -623,65 +699,67 @@ $( function () {
loadRemote(); loadRemote();
} }
} else { } else {
setRemotePath( path, true ); setRemotePath(path, true);
loadRemote(); loadRemote();
} }
} }
// 新建文件 // 新建文件
function newFile() { function newFile() {
setRemotePath( null, true ); setRemotePath(null, true);
draftManager.create(); draftManager.create();
minder.importData( '新建脑图', 'plain' ); minder.importData('新建脑图', 'plain');
minder.execCommand( 'camera', minder.getRoot() ); minder.execCommand('camera', minder.getRoot(), 300);
} }
function generateRemotePath() { function generateRemotePath() {
var filename = window.prompt( "请输入文件名: ", minder.getMinderTitle() ) || minder.getMinderTitle(); var filename = window.prompt("请输入文件名: ", minder.getMinderTitle()) || minder.getMinderTitle();
return '/apps/kityminder/' + filename + '.km'; return '/apps/kityminder/' + filename + '.km';
} }
function save() { function save() {
if ( !currentAccount || save.busy ) return; if (!currentAccount || save.busy) return;
save.busy = true; save.busy = true;
var data = minder.exportData( 'json' ); var data = minder.exportData('json');
var sto = baidu.frontia.personalStorage; var sto = baidu.frontia.personalStorage;
function error( reason ) { function error(reason) {
notice( '保存到云盘失败,可能是网络问题导致!\n建议您将脑图以 .km 格式导出到本地!' ); notice('保存到云盘失败,可能是网络问题导致!\n建议您将脑图以 .km 格式导出到本地!');
$save_btn.loading( false ); $title.loading(false);
clearTimeout( timeout ); clearTimeout(timeout);
save.busy = false; save.busy = false;
} }
var timeout = setTimeout( function () { var timeout = setTimeout(function() {
error( '保存到云盘超时,可能是网络不稳定导致。' ); error('保存到云盘超时,可能是网络不稳定导致。');
}, 15000 ); }, 15000);
function upload() { function upload() {
if ( upload.tryCount ) { if (upload.tryCount) {
console.warn( '保存文件失败!(第 ' + upload.tryCount + ' 次)' ); console.warn('保存文件失败!(第 ' + upload.tryCount + ' 次)');
} }
if ( upload.tryCount > 3 ) { if (upload.tryCount > 3) {
error(); error();
upload.tryCount = 0; upload.tryCount = 0;
return; return;
} }
sto.uploadTextFile( data, remotePath || generateRemotePath(), { var uploadPath = remotePath || generateRemotePath();
$title.loading('正在保存 “' + getFileName(uploadPath) + '” ...');
sto.uploadTextFile(data, uploadPath, {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY, ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) { success: function(savedFile) {
if ( savedFile.path ) { if (savedFile.path) {
if ( !remotePath ) { if (!remotePath) {
addToRecentMenu( [ savedFile ] ); addToRecentMenu([savedFile]);
} }
setRemotePath( savedFile.path, true ); setRemotePath(savedFile.path, true);
if ( draftManager ) { if (draftManager) {
draftManager.save( remotePath ); draftManager.save(remotePath);
draftManager.sync(); draftManager.sync();
} }
clearTimeout( timeout ); clearTimeout(timeout);
save.busy = false; save.busy = false;
upload.tryCount = 0; upload.tryCount = 0;
} else { } else {
...@@ -689,62 +767,62 @@ $( function () { ...@@ -689,62 +767,62 @@ $( function () {
} }
}, },
error: upload error: upload
} ); });
upload.tryCount++; upload.tryCount++;
} }
upload.tryCount = 0; upload.tryCount = 0;
upload(); upload();
$save_btn.loading( '正在保存...' );
} }
function share() { function share() {
if ( $share_btn.disabled() ) { if ($share_btn.disabled()) {
return; return;
} }
var baseUrl = /^(.*?)(\?|\#|$)/.exec( window.location.href )[ 1 ]; var baseUrl = /^(.*?)(\?|\#|$)/.exec(window.location.href)[1];
var shareUrl = baseUrl + '?shareId=' + shareId, var shareUrl = baseUrl + '?shareId=' + shareId,
shareData = new baidu.frontia.Data( { shareData = new baidu.frontia.Data({
shareMinder: { shareMinder: {
id: shareId, id: shareId,
data: minder.exportData( 'json' ) data: minder.exportData('json')
} }
} ); });
var shareConfig = window._bd_share_config.common, var shareConfig = window._bd_share_config.common,
resetShare = window._bd_share_main.init; resetShare = window._bd_share_main.init;
$share_btn.loading( '正在分享...' ); $share_btn.loading('正在分享...');
$.ajax( { $.ajax({
url: 'http://naotu.baidu.com/mongo.php', url: 'http://naotu.baidu.com/mongo.php',
type: 'POST', type: 'POST',
data: { data: {
action: 'insert', action: 'insert',
record: JSON.stringify( { record: JSON.stringify({
shareMinder: { shareMinder: {
id: shareId, id: shareId,
data: minder.exportData( 'json' ) data: minder.exportData('json')
} }
} ) })
}, },
success: function ( result ) { success: function(result) {
if ( result.error ) { if (result.error) {
notice( result.error ); notice(result.error);
} else { } else {
$share_dialog.show(); $share_dialog.show();
$share_url.val( shareUrl )[ 0 ].select(); $share_url.val(shareUrl)[0].select();
} }
$share_btn.loading(false);
}, },
error: function () { error: function() {
notice( '分享失败,可能是当前的环境不支持该操作。' ); notice('分享失败,可能是当前的环境不支持该操作。');
$share_btn.loading(false);
} }
} ); });
shareConfig.bdTitle = shareConfig.bdText = minder.getMinderTitle(); shareConfig.bdTitle = shareConfig.bdText = minder.getMinderTitle();
shareConfig.bdDesc = shareConfig.bdText = '“' + minder.getMinderTitle() + '” - 我用百度脑图制作的思维导图,快看看吧!(地址:' + shareUrl + ')'; shareConfig.bdDesc = shareConfig.bdText = '“' + minder.getMinderTitle() + '” - 我用百度脑图制作的思维导图,快看看吧!(地址:' + shareUrl + ')';
...@@ -754,147 +832,151 @@ $( function () { ...@@ -754,147 +832,151 @@ $( function () {
function bindShortCuts() { function bindShortCuts() {
$( document.body ).keydown( function ( e ) { $(document.body).keydown(function(e) {
var keyCode = e.keyCode || e.which; var keyCode = e.keyCode || e.which;
//添加快捷键 //添加快捷键
if ( ( e.ctrlKey || e.metaKey ) ) { if ((e.ctrlKey || e.metaKey)) {
switch ( keyCode ) { switch (keyCode) {
//保存 //保存
case KM.keymap.s: case KM.keymap.s:
if ( e.shiftKey ) { if (e.shiftKey) {
share(); share();
} else { } else {
save(); save();
} }
e.preventDefault(); e.preventDefault();
break; break;
case KM.keymap.n: case KM.keymap.n:
newFile(); newFile();
e.preventDefault(); e.preventDefault();
break; break;
} }
} }
} ); });
} }
function watchChanges() { function watchChanges() {
minder.on( 'contentchange', function () { var lastContent = minder.exportData('json');
if ( !watchingChanges ) return; minder.on('contentchange', function() {
if (!watchingChanges || lastContent == minder.exportData('json')) return;
var current = draftManager.save(); var current = draftManager.save();
if ( currentAccount ) { if (currentAccount) {
$save_btn.disabled( current.sync ).text( '保存' ); setRemotePath(remotePath, current.sync);
setRemotePath( remotePath, current.sync );
} }
} ); lastContent = minder.exportData('json');
});
} }
function showDraftList() { function showDraftList() {
var list = draftManager.list(), var list = draftManager.list(),
draft, $draft, index; draft, $draft, index;
if ( !list.length ) { if (!list.length) {
draftManager.create(); draftManager.create();
list = draftManager.list(); list = draftManager.list();
} }
$draft_menu.empty();
draft = list.shift(); if (draftManager.getCurrent()) {
$draft_menu.empty().append( '<li disabled="disabled" class="current-draft kmui-combobox-item kmui-combobox-item-disabled kmui-combobox-checked">' + draft = list.shift();
'<span class="kmui-combobox-icon"></span>' + $draft_menu.append('<li disabled="disabled" class="current-draft kmui-combobox-item kmui-combobox-item-disabled kmui-combobox-checked">' +
'<label class="kmui-combobox-item-label">' + draft.name + '<span class="kmui-combobox-icon"></span>' +
'<span class="update-time">' + getFriendlyTimeSpan( +new Date( draft.update ), +new Date() ) + '</span>' + '<label class="kmui-combobox-item-label">' +
'</label>' + '<span class="update-time">' + getFriendlyTimeSpan(+new Date(draft.update), +new Date()) + '</span>' + draft.name +
'</li>' ); '</label>' +
'</li>');
$draft_menu.append( '<li class="kmui-divider"></li>' ); $draft_menu.append('<li class="kmui-divider"></li>');
index = 1;
} else {
index = 0;
}
index = 1; while (list.length) {
while ( list.length ) {
draft = list.shift(); draft = list.shift();
$draft = $( '<li class="draft-item">' + $draft = $('<li class="draft-item">' +
'<a href="#">' + draft.name + '<span class="update-time">' + getFriendlyTimeSpan( +new Date( draft.update ), +new Date() ) + '</span></a><a class="delete" title="删除该草稿"></a></li>' ); '<a href="#">' + '<span class="update-time">' + getFriendlyTimeSpan(+new Date(draft.update), +new Date()) + '</span>' + draft.name + '</a><a class="delete" title="删除该草稿"></a></li>');
$draft.data( 'draft-index', index++ ); $draft.data('draft-index', index++);
$draft.appendTo( $draft_menu ); $draft.appendTo($draft_menu);
} }
if ( index > 1 ) { if (index > 1) {
$draft_menu.append( '<li class="kmui-divider"></li>' ); $draft_menu.append('<li class="kmui-divider"></li>');
$draft_menu.append( '<li class="draft-clear"><a href="#">清空草稿箱</a></li>' ); $draft_menu.append('<li class="draft-clear"><a href="#">清空草稿箱</a></li>');
} }
adjustDraftMenu(); //adjustDraftMenu();
} }
function adjustDraftMenu() { function adjustDraftMenu() {
var pos = $draft_btn.offset(); var pos = $draft_btn.offset();
pos.top -= $draft_menu.outerHeight() + 5; pos.top -= $draft_menu.outerHeight() + 5;
$draft_menu.offset( pos ); $draft_menu.offset(pos);
} }
function bindDraft() { function bindDraft() {
draftManager = window.draftManager; draftManager = window.draftManager;
if ( !draftManager ) { if (!draftManager) {
if ( window.DraftManager ) { if (window.DraftManager) {
draftManager = window.draftManager = new window.DraftManager( minder ); draftManager = window.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'));
$li.remove(); $li.remove();
showDraftList(); showDraftList();
e.stopPropagation(); e.stopPropagation();
} ) })
.delegate( 'li.draft-clear', 'click', function ( e ) { .delegate('li.draft-clear', 'click', function(e) {
if ( window.confirm( '确认清除草稿箱吗?' ) ) { if (window.confirm('确认清除草稿箱吗?')) {
draftManager.clear(); draftManager.clear();
showDraftList(); showDraftList();
} }
e.stopPropagation(); e.stopPropagation();
} ) })
.delegate( 'li.draft-item', 'click', function ( e ) { .delegate('li.draft-item', 'click', function(e) {
loadDraft( +$( this ).data( 'draft-index' ) ); loadDraft(+$(this).data('draft-index'));
} ); });
} }
function loadDraft( index ) { function loadDraft(index) {
var draft = draftManager.open( index ), var draft = draftManager.open(index),
isRemote; isRemote;
if ( !draft ) {
minder.initStyle();
return;
}
isRemote = draft.path.indexOf( '/apps/kityminder' ) === 0; if (!draft) return;
if ( isRemote ) {
setRemotePath( draft.path, draft.sync ); isRemote = draft.path.indexOf('/apps/kityminder') === 0;
if (isRemote) {
setRemotePath(draft.path, draft.sync);
} }
watchingChanges = false; watchingChanges = false;
draftManager.load(); draftManager.load();
watchingChanges = true; watchingChanges = true;
if ( !isRemote ) { if (!isRemote) {
setRemotePath( null, false ); setRemotePath(null, false);
} }
minder.execCommand('camera', null, 300);
} }
function getFriendlyTimeSpan( t1_in_ms, t2_in_ms ) { function getFriendlyTimeSpan(t1_in_ms, t2_in_ms) {
var ms = Math.abs( t1_in_ms - t2_in_ms ), var ms = Math.abs(t1_in_ms - t2_in_ms),
s = ms / 1000, s = ms / 1000,
m = s / 60, m = s / 60,
h = m / 60, h = m / 60,
d = h / 24; d = h / 24;
if ( s < 60 ) return "刚刚"; if (s < 60) return "刚刚";
if ( m < 60 ) return ( m | 0 ) + "分钟前"; if (m < 60) return (m | 0) + "分钟前";
if ( h < 24 ) return ( h | 0 ) + "小时前"; if (h < 24) return (h | 0) + "小时前";
if ( d <= 30 ) return ( d | 0 ) + "天前"; if (d <= 30) return (d | 0) + "天前";
return "很久之前"; return "很久之前";
} }
window.social = { window.social = {
setRemotePath: setRemotePath, setRemotePath: setRemotePath,
watchChanges: function ( value ) { watchChanges: function(value) {
watchingChanges = value; watchingChanges = value;
} }
}; };
} ); });
\ No newline at end of file \ No newline at end of file
#social { .niceblue {
position: absolute; color: white;
right: 10px; background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
top: 10px; background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
line-height: 20px; background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
text-align: right; background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
overflow: hidden; background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
} }
.dropdown { .dropdown {
padding-right: 28px; padding-right: 28px;
position: relative;
&:after { &:after {
content: ' '; content: ' ';
display: block; display: block;
position: absolute; position: absolute;
right: 10px; right: 10px;
top: 15px; top: 12px;
width: 0; width: 0;
height: 0; height: 0;
border: solid; border: solid;
border-width: 4px 5px; 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,26 +36,19 @@ button { ...@@ -29,26 +36,19 @@ button {
display: inline-block; display: inline-block;
vertical-align: middle; vertical-align: middle;
padding: 0 15px; padding: 0 15px;
height: 35px; height: 30px;
font-size: 13px; font-size: 13px;
line-height: 35px; line-height: 30px;
text-align: center; text-align: center;
border-radius: 5px; color: #000;
color: #ffffff;
text-decoration: none; text-decoration: none;
border: none; border: none;
margin-left: 5px; margin-left: 5px;
cursor: pointer; background: none;
background: #0099f2; /* Old browsers */ border-radius: 2px;
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=); .niceblue;
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 */
&:hover, &.hover { &:hover, &.hover {
background: #009fff; background: #009fff;
} }
...@@ -59,63 +59,14 @@ button { ...@@ -59,63 +59,14 @@ button {
} }
&[disabled] { &[disabled] {
background: #AAA;
cursor: default; cursor: default;
} background: #ccc;
&.baidu-cloud {
padding-left: 35px;
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/baiducloud.png);
position: absolute;
left: 7px;
top: 5px;
}
}
&.share {
padding-left: 35px;
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
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;
}
&.user-file {
position: relative;
img {
border: none;
outline: none;
}
span.text {
display: inline-block;
height: 24px;
line-height: 24px;
}
.dropdown;
} }
} }
#draft-btn {
.dropdown; .draft-menu.kmui-dropdown-menu {
} margin-top: 24px;
.draft-menu { margin-left: 1px;
span.update-time { span.update-time {
float: right; float: right;
color: #CCC; color: #CCC;
...@@ -184,17 +135,46 @@ button { ...@@ -184,17 +135,46 @@ button {
} }
} }
} }
.user-file-menu {
margin-top: 20px; .file-menu.kmui-dropdown-menu {
margin-top: 24px;
margin-left: 1px; margin-left: 1px;
border-radius: 4px;
box-shadow: 0px 1px 5px rgba(0,0,0, .3);
#save-button, #manage-file-button {
display: none;
}
&.logined {
#save-button, #manage-file-button{
display: block;
}
#net-hint-buttom {
display: none;
}
}
}
.user-menu.kmui-dropdown-menu {
margin-top: 24px;
margin-left: -25px;
min-width: 130px;
border-radius: 4px;
box-shadow: 0px 1px 5px rgba(0,0,0, .3);
li a {
padding-left: 40px;
}
} }
#share-dialog { #share-dialog {
position: absolute; position: absolute;
padding: 20px; padding: 20px;
border-radius: 4px; border-radius: 4px;
right: 10px; left: 50%;
top: 65px; top: 40%;
margin-left: -175px;
margin-top: -100px;
background: white; background: white;
width: 350px; width: 350px;
box-shadow: 1px 2px 16px rgba(0, 0, 0, .5); box-shadow: 1px 2px 16px rgba(0, 0, 0, .5);
...@@ -233,22 +213,24 @@ button { ...@@ -233,22 +213,24 @@ button {
line-height: 28px; line-height: 28px;
border-radius: 2px; border-radius: 2px;
vertical-align: middle; 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 { #share-platform {
margin-bottom: 0; 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
.kmui-modal { .kmui-modal {
position: fixed; position: fixed;
top: 60px; top: 140px;
right:10px; right:10px;
background-color: #ffffff; background-color: #fff;
outline: 0; outline: 0;
border-radius: 5px; border-radius: 5px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5); box-shadow: 3px 3px 8px rgba(0,0,0, .5);
......
.kmui-dropdown-menu { .kmui-dropdown-menu {
position: absolute; position: absolute;
z-index: 1000; z-index: 99999999999;
display: none; display: none;
min-width: 160px; min-width: 160px;
padding: 5px 0; padding: 5px 0;
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */ 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: -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: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */ background: #5a6378; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white; color: white;
......
...@@ -2,13 +2,213 @@ ...@@ -2,13 +2,213 @@
html, body, div { html, body, div {
margin: 0; margin: 0;
padding: 0; padding: 0;
/* background: #FFFFFF; */
} }
html, body, #kityminder, div.kmui-editor-body { html, body, #kityminder, div.kmui-editor-body {
height: 100%;
width: 100%;
overflow: hidden; overflow: hidden;
-moz-user-select: none; -moz-user-select: none;
} }
#title, #panel {
background: #393F4F;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
/* -webkit-font-smoothing: antialiased; */
}
#title {
height: 40px;
line-height: 45px;
padding: 0;
margin: 0;
padding: 0;
font-size: 14px;
color: #DBDBDB;
text-align: center;
font-weight: 300;
font-size: 14px;
}
#panel {
height: 40px;
overflow: visible;
padding: 0 15px;
position: relative;
border-bottom: 8px solid #5A6378;
}
#panel button {
font-size: 14px;
height: 24px;
line-height: 28px;
padding-right: 7px;
padding-left: 30px;
cursor: pointer;
color: #a3a6ae;
margin: 0 8px;
background: url(../images/menu-icons.png) no-repeat;
vertical-align: middle;
margin-top: -3px;
}
#menu, #user {
height: 40px;
line-height: 40px;
}
#menu {
float: left;
flo
}
#panel button:hover, #panel button.active {
color: white;
box-shadow: none;
}
button.dropdown {
padding-right: 28px !important;
position: relative;
}
button.dropdown:after {
content: ' ';
display: block;
position: absolute;
right: 10px;
top: 12px;
width: 0;
height: 0;
border: solid;
border-width: 4px 5px;
border-color: #a3a6ae transparent transparent transparent;
}
button.dropdown:hover:after, button.dropdown.active:after {
border-color: #fff transparent transparent transparent;
}
#file-btn:hover, #file-btn.active {
background-position: 0 -24px;
}
button#tool-btn {
background-position: 0 -48px;
}
#tool-btn:hover, #tool-btn.active {
background-position: 0 -72px;
}
#tool-btn.active:after {
content: ' ';
display: block;
position: absolute;
top: 21px;
left: 40px;
width: 0;
height: 0;
border: solid;
border-width: 11px 11px;
border-color: rgba(0, 0, 0, 0) rgba(0, 0, 0, 0) #FFF rgba(0, 0, 0, 0);
}
#panel button#tool-btn.active {
/* box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 -1px 2px rgba(255, 255, 255, .1); */
/* background-color: #677085; */
/* border: 1px solid #2E2E2E; */
/* padding-top: 10px; */
/* padding-bottom: 10px; */
/* height: 28px; */
/* margin-top: -1px; */
/* margin-left: 7px; */
position: relative;
}
#user {
/* position: absolute; */
/* top: 0; */
/* right: 10px; */
float: right;
}
#user-btn, #logout-btn, #user.logined #login-btn {
display: none;
}
#user.logined #user-btn, #user.logined #logout-btn {
display: inline-block;
}
button#user-btn {
position: relative;
margin-right: 0;
}
button#user-btn, button#login-btn {
background-position: 0 -96px;
}
button#user-btn:hover, button#login-btn:hover,
button#user-btn.active, button#login-btn.active {
background-position: 0 -120px;
}
#user-btn img {
position: absolute;
left: 4px;
top: 4px;
width: 18px;
height: 18px;
/* display: none; */
}
button#logout-btn {
background: none;
margin: none;
padding-left: 0;
}
button#draft-btn {
background-position: 0 -144px;
}
button#draft-btn:hover,
button#draft-btn.active {
background-position: 0 -168px;
}
li#manage-file-button {
position: relative;
}
li#manage-file-button:before {
content: ' ';
display: block;
position: absolute;
width: 24px;
height: 24px;
left: 5px;
background: url(../images/baiducloud.png) no-repeat 3px 0;
}
li#manage-file-button:hover:before {
background-position: 3px -24px;
}
button#share-btn {
background-position: 0 -192px;
}
button#share-btn:hover {
background-position: 0 -216px;
}
#kityminder {
position: absolute;
left: 0;
top: 48px;
right: 0;
bottom: 0;
}
.km_receiver{ .km_receiver{
width:0; width:0;
height:0; height:0;
...@@ -16,34 +216,78 @@ html, body, #kityminder, div.kmui-editor-body { ...@@ -16,34 +216,78 @@ html, body, #kityminder, div.kmui-editor-body {
.km-minderNode{ .km-minderNode{
cursor:default; cursor:default;
} }
.kmui-container { .kmui-container, .kmui-editor-body {
height: 100%; position: absolute;
} left: 0;
.kmui-container { top: 0;
right: 0;
bottom: 0;
} }
.kmui-container .kmui-toolbar{ .kmui-container .kmui-toolbar{
background-color: #fafafa; background-color: #fff;
z-index: 99999; z-index: 999;
margin-right: 400px; }
.kmui-container .kmui-toolbar:after {
} }
.kmui-toolbar .kmui-btn-toolbar{ .kmui-toolbar .kmui-btn-toolbar{
padding: 5px; padding: 5px;
border-bottom: 1px solid #f0f0f0;
} }
.kmui-toolbar { .kmui-toolbar {
position: absolute; position: absolute;
left: 10px; left: 0;
top: 10px; right: 0;
border-radius: 4px; top: 0;
box-shadow: 3px 3px 8px rgba(0,0,0, .5);
} }
.kmui-container .kmui-editor-body { .kmui-container .kmui-editor-body {
background: rgb(50, 60, 61) url(../images/grid.png) repeat; background: #fbfbfb;
/*line-height: 0;*/ /*line-height: 0;*/
overflow: hidden; overflow: hidden;
} }
svg, body { svg, body {
font-family: Arial, "Microsoft Yahei", "Heiti SC", sans-serif; font-family: Arial, "Microsoft Yahei", "Heiti SC", sans-serif;
} }
#about{position:absolute;bottom:10px;right:10px;height:24px;line-height:24px;color:#888;font-family:Arial;font-size:13px;font-weight:normal;margin:0;text-shadow:0 1px 1px #000}#about a{color:#888}#about a:hover{color:#fff} #about {
position:absolute;
bottom: 0;
right: 0;
height: 40px;
line-height: 40px;
background: #5d697a;
color: #eee;
font-family:Arial;
font-size:13px;
font-weight:normal;
margin:0;
text-align: right;
padding: 0 15px 0 60px;
border-bottom: 5px solid #393F4F;
-webkit-font-smoothing: antialiased;
position: absolute;
transition: all ease .3s 0.3s;
-webkit-transform: translate(100%);
}
#about:hover {
-webkit-transform: translate(0);
}
#about a {
color: #eee;
}
#about #km-cat {
position: absolute;
left: 15px;
top: 5px;
transition: all ease 1.3s 0.3s;
-webkit-transform: translate(-60px, 0);
cursor: pointer;
}
#about:hover #km-cat {
-webkit-transform: translate(0);
}
#about #cat-face {
fill: #393F4F;
}
#km-version.new-version{position:relative;padding-right:30px} #km-version.new-version{position:relative;padding-right:30px}
#km-version.new-version:after{content:'NEW';color:#ff0;position:absolute;top:-10px;right:-5px;display:block;background:#f00;padding:0 5px;border-radius:4px;text-shadow:none;box-shadow:-1px 1px 3px rgba(0,0,0,0.3);-webkit-transform:scale(.6);-moz-transform:scale(.6);-ms-transform:scale(.6);transform:scale(.6)} #km-version.new-version:after{content:'NEW';color:#ff0;position:absolute;top:-10px;right:-5px;display:block;background:#f00;padding:0 5px;border-radius:4px;text-shadow:none;box-shadow:-1px 1px 3px rgba(0,0,0,0.3);-webkit-transform:scale(.6);-moz-transform:scale(.6);-ms-transform:scale(.6);transform:scale(.6)}
<svg viewBox="0 0 1200 1200" width="32px" height="32px">
<g id="cat-face">
<path style="fill:#272B2D;" d="M1066.769,368.482L1119.5,80L830,131.611C760.552,97.29,682.35,77.999,599.641,77.999
c-82.424,0-160.371,19.161-229.641,53.26L81,81l50.769,289l0,0c-33.792,69.019-52.77,146.612-52.77,228.641
c0,287.542,233.099,520.642,520.642,520.642s520.642-233.099,520.642-520.642C1120.282,516.011,1101.028,437.88,1066.769,368.482z"
/>
</g>
<g id="cat-eye">
<path style="fill:#FFFFFF;" d="M920.255,371C794.746,371,693,472.746,693,598.255s101.746,227.255,227.255,227.255
s227.255-101.746,227.255-227.255S1045.765,371,920.255,371z M920,746c-80.081,0-145-64.919-145-145s64.919-145,145-145
s145,64.919,145,145S1000.081,746,920,746z"/>
<path style="fill:#FFFFFF;" d="M276.255,371C150.746,371,49,472.746,49,598.255s101.746,227.255,227.255,227.255
s227.255-101.746,227.255-227.255S401.765,371,276.255,371z M276,745c-80.081,0-145-64.919-145-145s64.919-145,145-145
s145,64.919,145,145S356.081,745,276,745z"/>
</g>
</svg>
dist/themes/default/images/share.png

1.14 KB | W: | H:

dist/themes/default/images/share.png

1.46 KB | W: | H:

dist/themes/default/images/share.png
dist/themes/default/images/share.png
dist/themes/default/images/share.png
dist/themes/default/images/share.png
  • 2-up
  • Swipe
  • Onion skin
<?php
/**
* 导出文件代理
*
* @author Jinqn, techird
*/
$type = $_REQUEST['type'];
if (isset($_REQUEST['content'])) {
$content = $_REQUEST['content'];
if ($type == 'base64') {
$content = base64_decode($content);
}
$filename = htmlspecialchars($_REQUEST["filename"]);
if (!$filename) {
$filename = "kikyminder";
}
header("Content-type: application/octet-stream; charset=utf-8; name=".$filename);
header("Accept-Length: ".strlen($content));
header("Content-Length: ".strlen($content));
header("Content-Disposition: attachment; filename=".$filename);
header('Content-Description: File Transfer');
echo $content;
} else {
echo 'Empty Content!';
}
?>
\ No newline at end of file
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
'KITYMINDER_HOME_URL': getKMBasePath(), 'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏 //定义工具栏
toolbars: [ toolbars: [
'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' 'undo redo | template theme | fontfamily fontsize bold italic forecolor | node hyperlink unhyperlink image removeimage markers resource | collapsenode expandnode | hand zoom-in zoom zoom-out | help'
] ]
//只读模式,默认是false //只读模式,默认是false
//readOnly: true //readOnly: true
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* 百度脑图社会化功能 * 百度脑图社会化功能
* *
* 1. 百度账号登 * 1. 百度账号登
* 2. 百度云存储 * 2. 百度云存储
* 3. 分享 * 3. 分享
* 4. 草稿箱同步 * 4. 草稿箱同步
...@@ -103,6 +103,67 @@ $(function() { ...@@ -103,6 +103,67 @@ $(function() {
if (draftManager && !loadPath() && !isShareLink) loadDraft(0); if (draftManager && !loadPath() && !isShareLink) loadDraft(0);
} }
function createFileMenu() {
var menus = [{
label: '新建 (Ctrl + N)',
click: newFile
}, {
divider: true
}];
// 导入菜单组
var acceptFiles = [];
KityMinder.getSupportedProtocals().forEach(function(name) {
var p = KityMinder.findProtocal(name);
if (p.decode) {
acceptFiles.push(p.fileExtension);
}
});
menus = menus.concat([{
label: '导入本地文件',
click: function() {
$('<input type="file" />')
.attr('accept', acceptFiles.join(','))
.on('change', function(e) {
e = e.originalEvent;
minder.importFile(e.target.files[0]);
}).click();
}
}, {
divider: true
}]);
// 导出菜单组
KityMinder.getSupportedProtocals().forEach(function(name) {
var p = KityMinder.findProtocal(name);
if (p.encode) {
var text = p.fileDescription + '(' + p.fileExtension + ')';
menus.push({
label: '导出 ' + text,
click: function() {
minder.exportFile(name);
}
});
}
});
menus = menus.concat([{
divider: true,
}, {
label: '登陆',
click: login,
id: 'net-hint-buttom'
}, {
label: '保存到百度云 (Ctrl + S)',
click: save,
id: 'save-button'
}, {
divider: true
}]);
return menus;
}
// 创建 UI // 创建 UI
function initUI() { function initUI() {
$panel = $('#panel'); $panel = $('#panel');
...@@ -113,24 +174,9 @@ $(function() { ...@@ -113,24 +174,9 @@ $(function() {
$file_btn = $('<button id="file-btn">文件</button>').addClass('dropdown').appendTo($menu); $file_btn = $('<button id="file-btn">文件</button>').addClass('dropdown').appendTo($menu);
$file_menu = $.kmuidropmenu({ $file_menu = $.kmuidropmenu({ data: createFileMenu() })
data: [{ .addClass('file-menu')
label: '新建 (Ctrl + N)', .appendTo('body');
click: newFile
}, {
divider: true,
}, {
label: '登陆',
click: login,
id: 'net-hint-buttom'
}, {
label: '保存到百度云 (Ctrl + S)',
click: save,
id: 'save-button'
}, {
divider: true
}]
}).addClass('file-menu').appendTo('body');
$file_menu.kmui().attachTo($file_btn); $file_menu.kmui().attachTo($file_btn);
...@@ -142,9 +188,8 @@ $(function() { ...@@ -142,9 +188,8 @@ $(function() {
$draft_menu = $.kmuidropmenu().addClass('draft-menu kmui-combobox-menu').appendTo('body'); $draft_menu = $.kmuidropmenu().addClass('draft-menu kmui-combobox-menu').appendTo('body');
$draft_menu.kmui().attachTo($draft_btn); $draft_menu.kmui().attachTo($draft_btn);
$draft_menu.on('aftershow', showDraftList); $draft_menu.on('aftershow', showDraftList);
$tool_btn = $('<button id="tool-btn" title="打开/收起工具箱">工具箱</button>').appendTo($menu);
$tool_btn = $('<button id="tool-btn">工具箱</button>').appendTo($menu);
$tool_btn.click(function() { $tool_btn.click(function() {
var hide = !localStorage.hide_toolbar; var hide = !localStorage.hide_toolbar;
...@@ -160,7 +205,7 @@ $(function() { ...@@ -160,7 +205,7 @@ $(function() {
$login_btn = $('<button id="login-btn">登录</button>').appendTo($user).click(login); $login_btn = $('<button id="login-btn">登录</button>').appendTo($user).click(login);
$user_btn = $('<button id="user-btn">用户</button>').addClass('dropdown').appendTo($user); $user_btn = $('<button id="user-btn">用户</button>').addClass('dropdown').appendTo($user);
$user_menu = $.kmuidropmenu({ $user_menu = $.kmuidropmenu({
data: [{ data: [{
label: '个人中心', label: '个人中心',
...@@ -899,7 +944,7 @@ $(function() { ...@@ -899,7 +944,7 @@ $(function() {
function loadDraft(index) { function loadDraft(index) {
var draft = draftManager.open(index), var draft = draftManager.open(index),
isRemote; isRemote;
if (!draft) return; if (!draft) return;
isRemote = draft.path.indexOf('/apps/kityminder') === 0; isRemote = draft.path.indexOf('/apps/kityminder') === 0;
......
KM.registerToolbarUI('saveto', function(name) { (function() {
var me = this,
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
comboboxName: name,
items: [],
itemStyles: [],
value: [],
autowidthitem: [],
enabledRecord: false,
enabledSelected: false
},
$combox = null,
comboboxWidget = null;
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);
}
});
//实例化 function doDownload(url, filename, type) {
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
comboboxWidget = $combox.kmui();
function doProxyDownload(url, filename, type) {
var content = url.split(',')[1]; var content = url.split(',')[1];
var $form = $('<form></form>').attr({ var $form = $('<form></form>').attr({
'action': 'http://172.22.73.36/naotu/download.php', 'action': 'download.php',
'method': 'POST' 'method': 'POST'
}); });
...@@ -59,38 +28,81 @@ KM.registerToolbarUI('saveto', function(name) { ...@@ -59,38 +28,81 @@ KM.registerToolbarUI('saveto', function(name) {
$form.appendTo('body').submit().remove(); $form.appendTo('body').submit().remove();
} }
function doDownload(url, filename, type) { function buildDataUrl(mineType, data) {
if (!kity.Browser.chrome || ~window.location.href.indexOf('naotu.baidu.com')) { return 'data:' + mineType + '; utf-8,' + encodeURIComponent(data);
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) { function doExport(minder, type) {
var data = me.exportData(res.value); var data = minder.exportData(type);
var p = KityMinder.findProtocal(res.value); var protocal = KityMinder.findProtocal(type);
var filename = me.getMinderTitle() + p.fileExtension; var filename = minder.getMinderTitle() + protocal.fileExtension;
var mineType = protocal.mineType || 'text/plain';
if (typeof(data) == 'string') { if (typeof(data) == 'string') {
var url = 'data:' + (p.mineType || 'text/plain') + '; utf-8,' + encodeURIComponent(data);
doDownload(url, filename, 'text'); doDownload(buildDataUrl(mineType, data), filename, 'text');
} else if (data && data.then) { } else if (data && data.then) {
data.then(function(url) { data.then(function(url) {
doDownload(url, filename, 'base64'); doDownload(url, filename, 'base64');
}); });
} }
}).on('beforeshow', function() { }
if ($combox.parent().length === 0) {
$combox.appendTo(me.$container.find('.kmui-dialog-container')); kity.extendClass(Minder, {
exportFile: function(type) {
doExport(this, type);
return this;
} }
}).on('aftercomboboxselect', function() {
this.setLabelWithDefaultValue();
}); });
KM.registerToolbarUI('saveto', function(name) {
var me = this,
label = me.getLang('tooltips.' + name),
options = {
label: label,
title: label,
comboboxName: name,
items: [],
itemStyles: [],
value: [],
autowidthitem: [],
enabledRecord: false,
enabledSelected: false
},
$combox = null,
comboboxWidget = null;
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);
}
});
return comboboxWidget.button().addClass('kmui-combobox'); //实例化
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
comboboxWidget = $combox.kmui();
comboboxWidget.on('comboboxselect', function(evt, res) {
doExport(me, res.value);
}).on('beforeshow', function() {
if ($combox.parent().length === 0) {
$combox.appendTo(me.$container.find('.kmui-dialog-container'));
}
}).on('aftercomboboxselect', function() {
this.setLabelWithDefaultValue();
});
return comboboxWidget.button().addClass('kmui-combobox');
});
}); })();
\ No newline at end of file \ No newline at end of file
...@@ -22,7 +22,7 @@ KityMinder.registerModule('DropFile', function() { ...@@ -22,7 +22,7 @@ KityMinder.registerModule('DropFile', function() {
var minder = this; var minder = this;
if (kity.Browser.ie && Number(kity.Browser.version) < 10) { if (kity.Browser.ie && Number(kity.Browser.version) < 10) {
alert('文件导入对IE浏览器仅支持10以上版本'); alert('文件导入对 IE 浏览器仅支持 10 以上版本');
return; return;
} }
...@@ -30,20 +30,27 @@ KityMinder.registerModule('DropFile', function() { ...@@ -30,20 +30,27 @@ KityMinder.registerModule('DropFile', function() {
if (files) { if (files) {
var file = files[0]; var file = files[0];
var ext = file.type || (/(.)\w+$/).exec(file.name)[0]; importMinderFile(minder, file);
console.log(ext); }
}
if ((/xmind/g).test(ext)) { //xmind zip
importSync(minder, file, 'xmind'); function importMinderFile(minder, file) {
} else if ((/mmap/g).test(ext)) { // mindmanager zip if (!file) return;
importSync(minder, file, 'mindmanager');
} else if ((/mm/g).test(ext)) { //freemind xml var ext = /(.)\w+$/.exec(file.name)[0];
importAsync(minder, file, 'freemind');
} else if (/km/.test(ext)) { // txt json if ((/xmind/g).test(ext)) { //xmind zip
importAsync(minder, file, 'json'); importSync(minder, file, 'xmind');
} else if (/txt/.test(ext)) { } else if ((/mmap/g).test(ext)) { // mindmanager zip
importAsync(minder, file, 'plain'); importSync(minder, file, 'mindmanager');
} } else if ((/mm/g).test(ext)) { //freemind xml
importAsync(minder, file, 'freemind');
} else if (/km/.test(ext)) { // txt json
importAsync(minder, file, 'json');
} else if (/txt/.test(ext)) {
importAsync(minder, file, 'plain');
} else {
alert('不支持该文件!');
} }
} }
...@@ -51,7 +58,7 @@ KityMinder.registerModule('DropFile', function() { ...@@ -51,7 +58,7 @@ KityMinder.registerModule('DropFile', function() {
if (!importing) return; if (!importing) return;
createDraft(this); createDraft(this);
social.setRemotePath(null, false); social.setRemotePath(null, false);
this.execCommand('camera', this.getRoot()); this.execCommand('camera', this.getRoot(), 800);
setTimeout(function() { setTimeout(function() {
social.watchChanges(true); social.watchChanges(true);
}, 10); }, 10);
...@@ -80,6 +87,13 @@ KityMinder.registerModule('DropFile', function() { ...@@ -80,6 +87,13 @@ KityMinder.registerModule('DropFile', function() {
draftManager.create(); draftManager.create();
} }
kity.extendClass(Minder, {
importFile: function(file) {
importMinderFile(this, file);
return this;
}
});
return { return {
events: { events: {
'ready': init, 'ready': init,
......
...@@ -12,17 +12,17 @@ html, body, #kityminder, div.kmui-editor-body { ...@@ -12,17 +12,17 @@ html, body, #kityminder, div.kmui-editor-body {
#title, #panel { #title, #panel {
background: #393F4F; background: #393F4F;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei'; font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
-webkit-font-smoothing: antialiased; /* -webkit-font-smoothing: antialiased; */
} }
#title { #title {
height: 40px; height: 40px;
line-height: 40px; line-height: 45px;
padding: 0; padding: 0;
margin: 0; margin: 0;
padding: 0; padding: 0;
font-size: 14px; font-size: 14px;
color: white; color: #DBDBDB;
text-align: center; text-align: center;
font-weight: 300; font-weight: 300;
font-size: 14px; font-size: 14px;
...@@ -103,7 +103,7 @@ button#tool-btn { ...@@ -103,7 +103,7 @@ button#tool-btn {
display: block; display: block;
position: absolute; position: absolute;
top: 21px; top: 21px;
left: 27px; left: 40px;
width: 0; width: 0;
height: 0; height: 0;
border: solid; border: solid;
...@@ -112,14 +112,14 @@ button#tool-btn { ...@@ -112,14 +112,14 @@ button#tool-btn {
} }
#panel button#tool-btn.active { #panel button#tool-btn.active {
box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 -1px 2px rgba(255, 255, 255, .1); /* box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 -1px 2px rgba(255, 255, 255, .1); */
background-color: #677085; /* background-color: #677085; */
border: 1px solid #2E2E2E; /* border: 1px solid #2E2E2E; */
/* padding-top: 10px; */ /* padding-top: 10px; */
/* padding-bottom: 10px; */ /* padding-bottom: 10px; */
height: 28px; /* height: 28px; */
margin-top: -1px; /* margin-top: -1px; */
margin-left: 7px; /* margin-left: 7px; */
position: relative; position: relative;
} }
......
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