Commit f8dc2e4d authored by techird's avatar techird

体验优化

parent 2f0d4154
......@@ -72,7 +72,7 @@ module.exports = function (grunt) {
copy: {
dir: {
files: [{
src: ['dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**', 'index.html'],
src: ['dialogs/**', 'lang/**', 'lib/**', 'social/**', 'themes/**', 'index.html', 'download.php'],
dest: distPath
}]
},
......
( function ( utils ) {
(function(utils) {
//todo 这里先写死成中文
var content = '<div class="hyperlink-content" style="padding:20px;width:360px;">';
content += '<style>';
content += '.kmui-dialog-<%= container %> input{';
content += 'width: 75%;';
content += 'width: 74%;';
content += 'padding: 6px 12px;';
content += 'font-size: 14px;';
content += 'line-height: 1.42857143;';
......@@ -35,36 +35,51 @@
KM.registerWidget( 'hyperlink', {
KM.registerWidget('hyperlink', {
tpl: content,
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.hyperlink' ),
initContent: function(km) {
var lang = km.getLang('dialogs.hyperlink'),
html;
if ( lang ) {
html = $.parseTmpl( this.tpl, utils.extend( {
if (lang) {
html = $.parseTmpl(this.tpl, utils.extend({
'container': 'hyperlink'
}, lang ) );
}, lang));
}
this.root().html( html );
this.root().html(html);
},
initEvent: function ( km, $w ) {
$w.find( '#hyperlink_insert' ).on( 'click', function () {
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() );
initEvent: function(km, $w) {
var $btn = $w.find('#hyperlink_insert');
$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.find( '#hyperlink_href' ).on( 'keydown', function ( e ) {
if ( e.keyCode === 13 ) {
km.execCommand( 'hyperlink', $w.find( '#hyperlink_href' ).val() );
$w.kmui().hide();
});
$w.find('#hyperlink_href').on('keydown', function(e) {
if (e.keyCode === 13) {
$btn.click();
}
} );
var url = km.queryCommandValue( 'hyperlink' );
var $input = $w.find( '#hyperlink_href' );
$input.val( url || 'http://' );
setTimeout( function () {
$input.focus()
} )
});
var url = km.queryCommandValue('hyperlink');
var $input = $w.find('#hyperlink_href');
$input.val(url || 'http://');
setTimeout(function() {
$input.select();
});
},
width: 400
} );
} )( KM.Utils );
\ No newline at end of file
});
})(KM.Utils);
\ No newline at end of file
......@@ -2,7 +2,7 @@
var content = '<div class="image-content" style="padding:20px;width:360px;">';
content += '<style>';
content += '.kmui-dialog-<%= container %> input{';
content += 'width: 75%;';
content += 'width: 74%;';
content += 'padding: 6px 12px;';
content += 'font-size: 14px;';
content += 'line-height: 1.42857143;';
......@@ -49,24 +49,39 @@
this.root().html(html);
},
initEvent: function(km, $w) {
$w.find('#image_insert').on('click', function() {
km.execCommand('image', $w.find('#image_href').val());
var $btn = $w.find('#image_insert').attr('disabled', 'disabled');
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.find('#image_href').on('keydown', function(e) {
$href.on('keydown', function(e) {
if (e.keyCode === 13) {
km.execCommand('image', $w.find('#image_href').val());
$w.kmui().hide();
$btn.click();
}
}).on('input', function() {
$w.find('#image_preview').attr('src', $w.find('#image_href').val());
});
var url = km.queryCommandValue('image');
var $input = $w.find('#image_href');
$input.val(url || 'http://');
if (url) $w.find('#image_preview').attr('src', url);
setTimeout(function() {
$input.focus();
$input.select();
});
},
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 @@
<meta name="keyword" content="脑图,kity,svg,minder,百度,fex,前端,在线">
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<script src="lib/jquery-2.1.0.min.js?_=1403688582922" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1403688582922" charset="utf-8"></script>
<script src="lib/jquery-2.1.0.min.js?_=1404368123769" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1404368123769" charset="utf-8"></script>
<script type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } );
</script>
<script src="lib/kity.min.js?_=1403688582922" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1403688582922" charset="utf-8"></script>
<script src="kityminder.config.js?_=1403688582922" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1403688582922" charset="utf-8"></script>
<script src="lib/kity.min.js?_=1404368123769" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1404368123769" charset="utf-8"></script>
<script src="kityminder.config.js?_=1404368123769" 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>
zip.inflateJSPath = 'lib/inflate.js';
</script>
<script src="lib/jquery.xml2json.js?_=1403688582922" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1403688582922" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1403688582922" charset="utf-8"></script>
<script src="social/social.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?_=1404368123769" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1404368123769" charset="utf-8"></script>
<script src="social/social.js?_=1404368123769" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet">
<link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
......@@ -35,7 +34,10 @@
</head>
<body>
<div id="panel"></div>
<div id="kityminder" onselectstart="return false"></div>
<div id="share-dialog" >
<h3>URL分享:</h3>
<p>
......@@ -52,14 +54,49 @@
</p>
</div>
<p 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> |
<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>
</p>
<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>
<div id="about">
<svg id="km-cat" viewBox="0 0 1200 1200" width="32px" height="32px">
<g id="cat-face">
<path 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>
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>
<!--脑图启动代码-->
<script>
// create km instance
km = KM.getKityMinder('kityminder');
......@@ -70,32 +107,34 @@
var lastVersion = localStorage.lastKMVersion;
$('#km-version').text( 'v' + KM.version );
if( lastVersion != KM.version ) {
if (lastVersion != KM.version) {
$( '#km-version' ).addClass( 'new-version' );
localStorage.lastKMVersion = KM.version;
}
});
km.on('unziperror', function(ev){
km.on('unziperror', function(ev) {
alert('unziperror');
});
km.on('parseerror', function(ev){
km.on('parseerror', function(ev) {
alert('parseerror');
});
km.on('unknownprotocal', function(ev){
km.on('unknownprotocal', function(ev) {
alert('unknownprotocal');
});
</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-->
<script type="text/javascript">
if (document.domain == 'naotu.baidu.com') {
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"));
}
</script>
</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 @@
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
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
//readOnly: true
//设置主题
//,defaultlayoutstyle : 'default' //设置默认的主题
//,layoutstyle : [] //添加有那些主图
//,defaultTemplate : 'default' //设置默认的主题
//,defaultTheme : 'fresh-blue' //添加有那些主图
//回退相关选项
//,maxUndoCount:20 //最大可回退的次数,默认20
......
KityMinder.LANG['zh-cn'] = {
'template': {
'default': '思维导图',
'structure': '组织结构图'
},
'theme': {
'classic': '脑图经典',
'snow': '温柔冷光',
'fresh-red': '清新红',
'fresh-soil': '泥土黄',
'fresh-green': '文艺绿',
'fresh-blue': '天空蓝',
'fresh-purple': '浪漫紫',
'fresh-pink': '脑残粉'
},
'maintopic': '中心主题',
'topic': '分支主题',
'tooltips': {
......@@ -21,9 +35,11 @@ KityMinder.LANG['zh-cn'] = {
'preference': '偏好设置',
'image': '插入图片',
'hyperlink': '插入链接',
'unhyperlink': "删除链接",
'expandnode': "展开节点",
'collapsenode': "收起节点"
'unhyperlink': '删除链接',
'expandnode': '展开节点',
'collapsenode': '收起节点',
'template': '模板',
'theme': '皮肤'
},
'popupcolor': {
'clearColor': '清空颜色',
......@@ -72,11 +88,17 @@ KityMinder.LANG['zh-cn'] = {
},
'hyperlink': {
'hyperlink': '插入超链接',
'unhyperlink': "取消超链接"
'unhyperlink': '取消超链接'
},
'image': {
'image': '插入图片',
'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
* GitHub: https://github.com/fex-team/kity.git
* Copyright (c) 2014 Baidu FEX; Licensed BSD
......@@ -177,9 +177,19 @@ define("animate/animator", [ "animate/timeline", "graphic/eventhandler", "animat
var queue = this._KityAnimateQueue;
if (queue) {
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;
......@@ -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);
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() {
return [ this.x, this.y, this.width, this.height ];
},
......@@ -3541,7 +3554,7 @@ define("graphic/group", [ "graphic/shapecontainer", "graphic/container", "core/u
return require("core/class").createClass("Group", {
mixins: [ ShapeContainer ],
base: require("graphic/shape"),
constructor: function() {
constructor: function Group() {
this.callBase("g");
}
});
......@@ -4009,39 +4022,40 @@ define("graphic/matrix", [ "core/utils", "graphic/box", "core/class", "graphic/p
e: 0,
f: 0
};
var node = target.shapeNode || target.node;
refer = refer || "parent";
// 根据参照坐标系选区的不一样,返回不同的结果
switch (refer) {
case "screen":
// 以浏览器屏幕为参照坐标系
ctm = target.node.getScreenCTM();
ctm = node.getScreenCTM();
break;
case "doc":
case "paper":
// 以文档(Paper)为参照坐标系
ctm = target.node.getCTM();
ctm = node.getCTM();
break;
case "view":
case "top":
// 以顶层绘图容器(视野)为参照坐标系
if (target.getPaper()) {
ctm = target.node.getTransformToElement(target.getPaper().shapeNode);
ctm = node.getTransformToElement(target.getPaper().shapeNode);
}
break;
case "parent":
// 以父容器为参照坐标系
if (target.node.parentNode) {
ctm = target.node.getTransformToElement(target.node.parentNode);
ctm = node.getTransformToElement(target.node.parentNode);
}
break;
default:
// 其他情况,指定参照物
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();
......@@ -4292,6 +4306,9 @@ define("graphic/paper", [ "core/class", "core/utils", "graphic/svg", "graphic/co
}
return parent;
},
isAttached: function() {
return !!this.getPaper();
},
whenPaperReady: function(fn) {
var me = this;
function check() {
......@@ -4758,7 +4775,7 @@ define("graphic/rect", [ "core/utils", "graphic/point", "core/class", "graphic/b
return Math.min(minValue, radius);
}
});
return require("core/class").createClass("Rect", {
var Rect = require("core/class").createClass("Rect", {
base: require("graphic/path"),
constructor: function(width, height, x, y, radius) {
this.callBase();
......@@ -4861,6 +4878,7 @@ define("graphic/rect", [ "core/utils", "graphic/point", "core/class", "graphic/b
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) {
var Point = require("graphic/point");
......@@ -4949,7 +4967,7 @@ define("graphic/shape", [ "graphic/svg", "core/utils", "graphic/eventhandler", "
var Box = require("graphic/box");
var Shape = require("core/class").createClass("Shape", {
mixins: [ EventHandler, Styled, Data ],
constructor: function(tagName) {
constructor: function Shape(tagName) {
this.node = svg.createNode(tagName);
this.node.shape = this;
this.transform = {
......@@ -5198,6 +5216,10 @@ define("graphic/shapecontainer", [ "graphic/container", "core/class", "core/util
addShape: function(shape, index) {
return this.addItem(shape, index);
},
put: function(shape) {
this.addShape(shape);
return shape;
},
appendShape: function(shape) {
return this.addShape(shape);
},
......@@ -5347,10 +5369,12 @@ define("graphic/shapeevent", [ "graphic/matrix", "core/utils", "graphic/box", "g
return null;
}
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, // 鼠标位置在目标对象上的坐标
// 基于屏幕坐标算
point = Matrix.transformPoint(clientX, clientY, node.getScreenCTM().inverse());
return Matrix.getCTM(this.targetShape, refer || "view").transformPoint(point);
var target = this.targetShape;
var targetNode = target.shapeNode || target.node;
var pScreen = new kity.Point(eventClient && eventClient.clientX || 0, eventClient && eventClient.clientY || 0);
var pTarget = Matrix.transformPoint(pScreen, targetNode.getScreenCTM().inverse());
var pRefer = Matrix.getCTM(target, refer || "view").transformPoint(pTarget);
return pRefer;
},
stopPropagation: function() {
var evt = this.originEvent;
......@@ -5770,10 +5794,10 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", "
var TextContent = require("graphic/textcontent");
var ShapeContainer = require("graphic/shapecontainer");
var svg = require("graphic/svg");
var utils = require("core/utils");
var offsetHash = {};
function getTextBoundOffset(text) {
var style = window.getComputedStyle(text.node);
var font = [ style.fontFamily, style.fontSize, style.fontStretch, style.fontStyle, style.fontVariant, style.fontWeight ].join("-");
var font = text._cachedFontHash;
if (offsetHash[font]) {
return offsetHash[font];
}
......@@ -5796,6 +5820,22 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", "
if (content !== undefined) {
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) {
this.node.setAttribute("x", x);
......@@ -5816,7 +5856,11 @@ define("graphic/text", [ "graphic/textcontent", "graphic/shape", "core/class", "
},
setFont: function(font) {
this.callBase(font);
return this.setVerticalAlign(this.getVerticalAlign());
if (this._fontChanged(font)) {
this._buildFontHash();
this.setVerticalAlign(this.getVerticalAlign());
}
return this;
},
setTextAnchor: function(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 ) {
function init() {
drafts = localStorage.getItem( '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() {
......@@ -58,7 +37,7 @@ function DraftManager( minder ) {
function load() {
if ( current ) {
minder.importData( current.data, "json" );
minder.importData( current.data, 'json' );
}
return current;
}
......@@ -80,8 +59,9 @@ function DraftManager( minder ) {
} else {
current.path = path || current.path;
current.name = minder.getMinderTitle();
current.data = minder.exportData( "json" );
current.sync = false;
var data = minder.exportData( 'json' );
current.sync = current.sync && (data == current.data);
current.data = data;
current.update = new Date();
store();
}
......
#social{position:absolute;right:10px;top:10px;line-height:20px;text-align:right;overflow:hidden}
.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}
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}
.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;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}
.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[disabled]{background:#aaa;cursor:default}
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}
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}
button img{position:relative;top:3px;border-radius:2px;margin-right:7px}
button.user-file{position:relative;padding-right:28px}button.user-file img{border:none;outline:none}
button.user-file span.text{display:inline-block;height:24px;line-height:24px}
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-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 span.update-time{float:right;color:#ccc;margin-left:20px;padding-right:16px}
.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 li.draft-item:hover a:before{background-position:0 -48px}
.draft-menu li.draft-item{position:relative}.draft-menu li.draft-item:hover a.delete{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}
.draft-menu li.draft-item a.delete:hover{background-position:0 -20px}
.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}
.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}
button[disabled]{cursor:default;background:#ccc}
.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}
.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}
.draft-menu.kmui-dropdown-menu li.draft-item:hover a:before{background-position:0 -48px}
.draft-menu.kmui-dropdown-menu li.draft-item{position:relative}.draft-menu.kmui-dropdown-menu li.draft-item:hover a.delete{display:block}
.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}
.draft-menu.kmui-dropdown-menu li.draft-item a.delete:hover{background-position:0 -20px}
.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.kmui-dropdown-menu.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-item-label{display:block;margin-left:28px}
.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}
.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}
.file-menu.kmui-dropdown-menu.logined #save-button,.file-menu.kmui-dropdown-menu.logined #manage-file-button{display:block}
.file-menu.kmui-dropdown-menu.logined #net-hint-buttom{display:none}
.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}
#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}
#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 #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: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 @@
/**
* 百度脑图社会化功能
*
* 1. 百度账号登
* 1. 百度账号登
* 2. 百度云存储
* 3. 分享
* 4. 草稿箱同步
......@@ -11,48 +11,48 @@
*/
$.extend( $.fn, {
disabled: function ( value ) {
if ( value === undefined ) return !!this.attr( 'disabled' );
if ( value ) {
this.attr( 'disabled', 'disabled' );
$.extend($.fn, {
disabled: function(value) {
if (value === undefined) return !!this.attr('disabled');
if (value) {
this.attr('disabled', 'disabled');
} else {
this.removeAttr( 'disabled' );
this.removeAttr('disabled');
}
return this;
},
loading: function ( text ) {
if ( text ) {
this.disabled( true );
this.attr( 'origin-text', this.text() );
this.text( text );
loading: function(text) {
if (text) {
this.disabled(true);
this.attr('origin-text', this.text());
this.text(text);
} else {
this.text( this.attr( 'origin-text' ) );
this.removeAttr( 'origin-text' );
this.disabled( false );
this.text(this.attr('origin-text'));
this.removeAttr('origin-text');
this.disabled(false);
}
return this;
},
text: ( function () {
text: (function() {
var originFn = $.fn.text;
return function () {
var textSpan = this.children( 'span.text' );
if ( textSpan.length ) {
return originFn.apply( textSpan, arguments );
return function() {
var textSpan = this.children('span.text');
if (textSpan.length) {
return originFn.apply(textSpan, arguments);
} else {
return originFn.apply( this, arguments );
return originFn.apply(this, arguments);
}
};
} )()
} );
})()
});
/**
* 核心业务逻辑
*/
$( function () {
$(function() {
// 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,
// 当前文件的远端路径
......@@ -66,8 +66,8 @@ $( function () {
isPathLink,
uuid = function () {
return ( ( +new Date() * 10000 ) + ( Math.random() * 9999 ) ).toString( 36 );
uuid = function() {
return ((+new Date() * 10000) + (Math.random() * 9999)).toString(36);
},
// 当前脑图的分享ID
......@@ -84,144 +84,229 @@ $( function () {
// 当前是否要检测文档内容是否变化的开关
watchingChanges = true,
notice = ( function () {
notice = (function() {
return window.alert;
} )();
})();
start();
function start() {
initUI();
initFrontia();
if ( checkLogin() ) {
if (checkLogin()) {
return;
}
loadShare();
bindShortCuts();
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
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( {
data: [ {
label: '新建脑图',
click: newFile
}, {
label: '到网盘管理文件...',
click: function () {
window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' );
}
}, {
label: '注销',
click: logout
}, {
divider: true
} ]
} ).addClass( 'user-file-menu' ).appendTo( 'body' ).kmui();
$file_menu = $.kmuidropmenu({ data: createFileMenu() })
.addClass('file-menu')
.appendTo('body');
$file_menu.kmui().attachTo($file_btn);
$save_btn = $('#save-btn').find('a');
$share_btn = $('<button id="share-btn">分享</button>').click(share).appendTo($user);
$draft_btn = $('<button id="draft-btn">草稿箱</button>').addClass('dropdown').appendTo($menu);
$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 )
.addClass( 'baidu-cloud' );
$tool_btn = $('<button id="tool-btn" title="打开/收起工具箱">工具箱</button>').appendTo($menu);
$share_btn = $( '<button id="share-btn">分享</button>' ).click( share )
.addClass( 'share' ).appendTo( $panel );
$tool_btn.click(function() {
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' );
$draft_menu.kmui().attachTo( $draft_btn );
$draft_menu.on( 'aftershow', showDraftList );
$user_menu = $.kmuidropmenu({
data: [{
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_url = $( '#share-url' );
$copy_url_btn = $( '#copy-share-url' );
$share_dialog = $('#share-dialog');
$share_url = $('#share-url');
$copy_url_btn = $('#copy-share-url');
$share_dialog.mousedown( function ( e ) {
$share_dialog.mousedown(function(e) {
e.stopPropagation();
} );
});
var copyTrickTimer = 0;
$( 'body' ).on( 'mousedown', function ( e ) {
copyTrickTimer = setTimeout( function () {
$('body').on('mousedown', function(e) {
copyTrickTimer = setTimeout(function() {
$share_dialog.hide();
$share_btn.loading( false );
$copy_url_btn.loading( false );
}, 30 );
} );
$share_btn.loading(false);
$copy_url_btn.loading(false);
}, 30);
});
if ( window.ZeroClipboard ) {
var clip = new window.ZeroClipboard( $copy_url_btn, {
if (window.ZeroClipboard) {
var clip = new window.ZeroClipboard($copy_url_btn, {
hoverClass: 'hover',
activeClass: 'active'
} );
clip.on( 'dataRequested', function ( client, args ) {
$copy_url_btn.loading( '已复制' );
clearTimeout( copyTrickTimer );
} );
});
clip.on('dataRequested', function(client, args) {
$copy_url_btn.loading('已复制');
clearTimeout(copyTrickTimer);
});
}
}
// 初始化云平台 frontia
function initFrontia() {
var AK = 'wiE55BGOG8BkGnpPs6UNtPbb';
baidu.frontia.init( AK );
baidu.frontia.social.setLoginCallback( {
baidu.frontia.init(AK);
baidu.frontia.social.setLoginCallback({
success: setAccount,
error: function ( error ) {
notice( '登录失败!' );
error: function(error) {
notice('登录失败!');
}
} );
});
}
// 检查 URL 是否分享连接,是则加载分享内容
function loadShare() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec( window.location ) || pattern.exec( document.referrer );
if ( !match ) return;
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if (!match) return;
var shareId = match[ 1 ];
var shareId = match[1];
$.ajax( {
$.ajax({
url: 'http://naotu.baidu.com/mongo.php',
data: {
action: 'find',
id: shareId
},
dataType: 'json',
success: function ( data ) {
if ( data.error ) {
return notice( data.error );
success: function(data) {
if (data.error) {
return notice(data.error);
}
if ( draftManager ) {
var draft = draftManager.openByPath( 'share/' + shareId );
if ( draft ) {
if (draftManager) {
var draft = draftManager.openByPath('share/' + shareId);
if (draft) {
draftManager.load();
} else {
draftManager.create( 'share/' + shareId );
minder.importData( data.shareMinder.data, 'json' );
draftManager.create('share/' + shareId);
minder.importData(data.shareMinder.data, 'json');
}
} else {
minder.importData( data.shareMinder.data, 'json' );
minder.importData(data.shareMinder.data, 'json');
}
setRemotePath( null, false );
$share_btn.loading( false );
$title.loading(false);
setRemotePath(null, false);
},
error: function () {
notice( '请求分享文件失败,请重试!' );
error: function() {
notice('请求分享文件失败,请重试!');
}
} );
});
$share_btn.loading( '正在加载分享内容...' );
$title.loading('正在加载分享内容...');
isShareLink = true;
}
......@@ -230,47 +315,43 @@ $( function () {
function loadPath() {
var pattern = /path=(.+?)([&#]|$)/;
// documemt.referrer 是为了支持被嵌在 iframe 里的情况
var match = pattern.exec( window.location ) || pattern.exec( document.referrer );
if ( !match ) return;
if ( !currentAccount ) {
setTimeout( function () {
if ( !currentAccount ) return login();
setRemotePath( decodeURIComponent( match[ 1 ], true ) );
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if (!match) return;
if (!currentAccount) {
setTimeout(function() {
if (!currentAccount) return login();
setRemotePath(decodeURIComponent(match[1], true));
loadRemote();
}, 1000 );
}, 1000);
return false;
}
setRemotePath( decodeURIComponent( match[ 1 ], true ) );
setRemotePath(decodeURIComponent(match[1], true));
loadRemote();
return true;
}
function setRemotePath( path, saved ) {
function setRemotePath(path, saved) {
var filename;
remotePath = path;
if ( remotePath ) {
filename = getFileName( remotePath );
if ( !saved ) {
if (remotePath) {
filename = getFileName(remotePath);
if (!saved) {
filename = '* ' + filename;
}
$user_btn.text( filename );
} else if ( currentAccount ) {
$user_btn.text( '* ' + minder.getMinderTitle() );
}
document.title = [ filename || minder.getMinderTitle(), titleSuffix ].join( ' - ' );
if ( saved ) {
$save_btn.disabled( true ).text( '已保存' );
$title.text(filename);
} else if (currentAccount) {
$title.text('* ' + minder.getMinderTitle());
} else {
$save_btn.disabled( false ).text( '保存' );
$title.text(filename || minder.getMinderTitle());
}
document.title = [filename || minder.getMinderTitle(), titleSuffix].join(' - ');
}
// 检查是否在 Cookie 中登录过了
function checkLogin() {
var account = baidu.frontia.getCurrentAccount();
if ( account ) {
if (account) {
login();
return true;
}
......@@ -279,88 +360,83 @@ $( function () {
// 用户点击登录按钮主动登录
function login() {
baidu.frontia.social.login( {
baidu.frontia.social.login({
response_type: 'token',
media_type: 'baidu',
redirect_uri: window.location.href,
client_type: 'web'
} );
});
$login_btn.text('正在登录...').css('text-decoration', 'none');
}
function logout() {
baidu.frontia.logOutCurrentAccount();
setAccount( null );
setAccount(null);
$file_menu.removeClass('logined');
$user.removeClass('logined');
}
// 设置用户后为其初始化
function setAccount( account ) {
function setAccount(account) {
currentAccount = account;
if ( account ) {
$user_btn.prependTo( $panel );
$save_btn.appendTo( $panel );
$share_btn.appendTo( $panel );
$login_btn.detach();
if (account) {
loadAvator();
loadUserFiles();
window.location.hash = '';
} else {
$user_btn.detach();
$save_btn.detach();
$login_btn.prependTo( $panel );
$user_btn.text(account.accountName);
}
$file_menu.addClass('logined');
$user.addClass('logined');
}
// 加载用户头像
function loadAvator() {
var $img = $( '<img />' ).attr( {
'src': 'social/loading.gif',
'width': 16,
'height': 16
} ).prependTo( $user_btn );
currentAccount.getDetailInfo( {
success: function ( user ) {
$img.attr( {
'src': user.extra.tinyurl
} );
currentAccount.getDetailInfo({
success: function(user) {
$('<img />').attr({
'src': user.extra.headurl,
'width': 32,
'height': 32
}).prependTo($user_btn);
}
} );
});
}
// 加载用户最近使用的文件
function loadUserFiles() {
if ( loadUserFiles.tryCount ) {
console.warn( '加载用户最近使用的文件失败:第 ' + loadUserFiles.tryCount + '次' );
if (loadUserFiles.tryCount) {
console.warn('加载用户最近使用的文件失败:第 ' + loadUserFiles.tryCount + '次');
}
if ( loadUserFiles.tryCount > 3 ) {
notice( '加载最近脑图失败!' );
if (loadUserFiles.tryCount > 3) {
notice('加载最近脑图失败!');
loadUserFiles.tryCount = 0;
}
var sto = baidu.frontia.personalStorage;
if ( loadUserFiles.tryCount === 0 ) {
loadUserFiles.$loadingMenuItem = $user_menu.appendItem( {
if (loadUserFiles.tryCount === 0) {
loadUserFiles.$loadingMenuItem = $file_menu.kmui().appendItem({
item: {
label: '正在加载最近脑图...',
disabled: 'disabled'
}
} );
});
}
sto.listFile( 'apps/kityminder/', {
sto.listFile('apps/kityminder/', {
by: 'time',
success: function ( result ) {
if ( result.list.length ) {
success: function(result) {
if (result.list.length) {
loadUserFiles.$loadingMenuItem.remove();
addToRecentMenu( result.list.filter( function ( file ) {
return getFileFormat( file.path ) in fileLoader;
} ) );
syncPreference( result.list );
addToRecentMenu(result.list.filter(function(file) {
return getFileFormat(file.path) in fileLoader;
}));
syncPreference(result.list);
}
},
error: loadUserFiles
} );
});
loadUserFiles.tryCount++;
}
......@@ -368,7 +444,7 @@ $( function () {
loadUserFiles.tryCount = 0;
// 同步用户配置文件
function syncPreference( fileList ) {
function syncPreference(fileList) {
// frontia 接口对象引用
var sto = baidu.frontia.personalStorage;
......@@ -377,9 +453,9 @@ $( function () {
var remotePreferencesPath = '/apps/kityminder/app.preferences';
// 检查是否存在线上的配置文件
var hasRemotePreferences = ~fileList.map( function ( file ) {
var hasRemotePreferences = ~fileList.map(function(file) {
return file.path;
} ).indexOf( remotePreferencesPath );
}).indexOf(remotePreferencesPath);
// 记录远端配置的和本地配置的版本
// - 远端配置保存在 json 内容的 version 字段中
......@@ -392,15 +468,15 @@ $( function () {
// 远端有配置,下载远端配置
if ( hasRemotePreferences ) {
if (hasRemotePreferences) {
downloadPreferences();
}
// 绑定实例上配置改变的事件,配置有变需要上传
minder.on( 'preferenceschange', function () {
minder.on('preferenceschange', function() {
localStorage.preferencesVersion = ++localVersion;
uploadPreferences();
} );
});
// 下载远端配置
function downloadPreferences() {
......@@ -408,16 +484,16 @@ $( function () {
// 比较远端和本地版本
// - 远端版本较新则设置本地版本为远端版本
// - 本地版本较新则上传本地版本
function merge( remote ) {
function merge(remote) {
remoteVersion = remote.version;
remotePreferences = remote.preferences;
localPreferences = minder.getPreferences();
if ( localVersion < remoteVersion ) {
minder.resetPreferences( remotePreferences );
} else if ( localVersion > remoteVersion ) {
if (localVersion < remoteVersion) {
minder.resetPreferences(remotePreferences);
} else if (localVersion > remoteVersion) {
uploadPreferences();
}
......@@ -425,19 +501,19 @@ $( function () {
// 下载配置的过程
// 需要先获得下载的 URL 再使用 ajax 请求内容
sto.getFileUrl( remotePreferencesPath, {
success: function ( url ) {
$.ajax( {
sto.getFileUrl(remotePreferencesPath, {
success: function(url) {
$.ajax({
url: url,
cache: false,
dataType: 'json',
success: merge,
error: function () {
notice( '下载配置失败!' );
error: function() {
notice('下载配置失败!');
}
} );
});
}
} );
});
}
// 上传本地配置
......@@ -451,58 +527,58 @@ $( function () {
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,
success: function ( savedFile ) {
console && console.log( '配置已上传' );
success: function(savedFile) {
console && console.log('配置已上传');
},
error: function ( e ) {
notice( '上传配置失败' );
error: function(e) {
notice('上传配置失败');
}
} );
});
}
}
// 加载当前 remoteUrl 中制定的文件
function loadRemote() {
if ( loadRemote.tryCount ) {
console.warn( '加载用户文件失败:第 ' + loadUserFiles.tryCount + '次' );
if (loadRemote.tryCount) {
console.warn('加载用户文件失败:第 ' + loadUserFiles.tryCount + '次');
}
// 失败重试判断
if ( loadRemote.tryCount > 3 ) {
notice( '加载脑图失败!' );
if (loadRemote.tryCount > 3) {
notice('加载脑图失败!');
loadRemote.tryCount = 0;
}
var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载“' + getFileName( remotePath ) + '”...' );
$title.loading('加载“' + getFileName(remotePath) + '”...');
sto.getFileUrl( remotePath, {
success: function ( url ) {
sto.getFileUrl(remotePath, {
success: function(url) {
// the url to download the file on cloud dist
var format = getFileFormat( remotePath );
if ( format in fileLoader ) {
fileLoader[ format ]( url );
var format = getFileFormat(remotePath);
if (format in fileLoader) {
fileLoader[format](url);
}
loadRemote.tryCount = 0;
},
error: loadRemote
} );
});
loadRemote.tryCount++;
}
loadRemote.tryCount = 0;
function getFileFormat( fileUrl ) {
return fileUrl.split( '.' ).pop();
function getFileFormat(fileUrl) {
return fileUrl.split('.').pop();
}
var fileLoader = {
......@@ -513,109 +589,109 @@ $( function () {
'mm': loadFreeMind
};
function loadPlainType( url ) {
$.ajax( {
function loadPlainType(url) {
$.ajax({
cache: false,
url: url,
dataType: 'text',
success: function ( result ) {
importFile( result, 'json' );
success: function(result) {
importFile(result, 'json');
}
} );
});
}
function loadXMind( url ) {
function loadXMind(url) {
var xhr = new XMLHttpRequest();
xhr.open( "get", url, true );
xhr.open("get", url, true);
xhr.responseType = "blob";
xhr.onload = function () {
if ( this.status == 200 && this.readyState ) {
xhr.onload = function() {
if (this.status == 200 && this.readyState) {
var blob = this.response;
importFile( blob, 'xmind' );
importFile(blob, 'xmind');
}
};
xhr.send();
}
function loadMindManager( url ) {
function loadMindManager(url) {
var xhr = new XMLHttpRequest();
xhr.open( "get", url, true );
xhr.open("get", url, true);
xhr.responseType = "blob";
xhr.onload = function () {
if ( this.status == 200 && this.readyState ) {
xhr.onload = function() {
if (this.status == 200 && this.readyState) {
var blob = this.response;
importFile( blob, 'mindmanager' );
importFile(blob, 'mindmanager');
}
};
xhr.send();
}
function loadFreeMind( url ) {
$.ajax( {
function loadFreeMind(url) {
$.ajax({
cache: false,
url: url,
dataType: 'text',
success: function ( result ) {
importFile( result, 'freemind' );
success: function(result) {
importFile(result, 'freemind');
}
} );
});
}
// 见文件数据导入minder
function importFile( data, format ) {
function importFile(data, format) {
watchingChanges = false;
minder.importData( data, format );
minder.importData(data, format);
if ( draftManager ) {
if ( !draftManager.openByPath( remotePath ) ) {
if (draftManager) {
if (!draftManager.openByPath(remotePath)) {
draftManager.create();
}
draftManager.save( remotePath );
draftManager.save(remotePath);
draftManager.sync();
}
minder.execCommand( 'camera', minder.getRoot() );
$user_btn.loading( false ).text( getFileName( remotePath ) );
minder.execCommand('camera', minder.getRoot(), 300);
$title.loading(false).text(getFileName(remotePath));
watchingChanges = true;
}
// 添加文件到最近文件列表
function addToRecentMenu( list ) {
list.splice( 12 );
list.forEach( function ( file ) {
$user_menu.appendItem( {
function addToRecentMenu(list) {
list.splice(12);
list.forEach(function(file) {
$file_menu.kmui().appendItem({
item: {
label: getFileName( file.path ),
label: getFileName(file.path),
value: file.path
},
click: openFile
} );
} );
});
});
}
// 从路径中抽取文件名
function getFileName( path ) {
return path.split( '/' ).pop();
function getFileName(path) {
return path.split('/').pop();
}
// 点击文件菜单
function openFile( e ) {
var path = $( this ).data( 'value' );
function openFile(e) {
var path = $(this).data('value');
var draft = draftManager && draftManager.getCurrent();
if ( draft && draft.path == path ) {
if ( !draft.sync && window.confirm( '“' + getFileName( path ) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?' ) ) {
setRemotePath( path, true );
if (draft && draft.path == path) {
if (!draft.sync && window.confirm('“' + getFileName(path) + '”在草稿箱包含未保存的更改,确定加载网盘版本覆盖草稿箱中的版本吗?')) {
setRemotePath(path, true);
loadRemote();
}
} else if ( draftManager ) {
draft = draftManager.openByPath( path );
setRemotePath( path, !draft || draft.sync );
if ( draft ) {
} else if (draftManager) {
draft = draftManager.openByPath(path);
setRemotePath(path, !draft || draft.sync);
if (draft) {
watchingChanges = false;
draftManager.load();
watchingChanges = true;
......@@ -623,65 +699,67 @@ $( function () {
loadRemote();
}
} else {
setRemotePath( path, true );
setRemotePath(path, true);
loadRemote();
}
}
// 新建文件
function newFile() {
setRemotePath( null, true );
setRemotePath(null, true);
draftManager.create();
minder.importData( '新建脑图', 'plain' );
minder.execCommand( 'camera', minder.getRoot() );
minder.importData('新建脑图', 'plain');
minder.execCommand('camera', minder.getRoot(), 300);
}
function generateRemotePath() {
var filename = window.prompt( "请输入文件名: ", minder.getMinderTitle() ) || minder.getMinderTitle();
var filename = window.prompt("请输入文件名: ", minder.getMinderTitle()) || minder.getMinderTitle();
return '/apps/kityminder/' + filename + '.km';
}
function save() {
if ( !currentAccount || save.busy ) return;
if (!currentAccount || save.busy) return;
save.busy = true;
var data = minder.exportData( 'json' );
var data = minder.exportData('json');
var sto = baidu.frontia.personalStorage;
function error( reason ) {
notice( '保存到云盘失败,可能是网络问题导致!\n建议您将脑图以 .km 格式导出到本地!' );
$save_btn.loading( false );
clearTimeout( timeout );
function error(reason) {
notice('保存到云盘失败,可能是网络问题导致!\n建议您将脑图以 .km 格式导出到本地!');
$title.loading(false);
clearTimeout(timeout);
save.busy = false;
}
var timeout = setTimeout( function () {
error( '保存到云盘超时,可能是网络不稳定导致。' );
}, 15000 );
var timeout = setTimeout(function() {
error('保存到云盘超时,可能是网络不稳定导致。');
}, 15000);
function upload() {
if ( upload.tryCount ) {
console.warn( '保存文件失败!(第 ' + upload.tryCount + ' 次)' );
if (upload.tryCount) {
console.warn('保存文件失败!(第 ' + upload.tryCount + ' 次)');
}
if ( upload.tryCount > 3 ) {
if (upload.tryCount > 3) {
error();
upload.tryCount = 0;
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,
success: function ( savedFile ) {
if ( savedFile.path ) {
if ( !remotePath ) {
addToRecentMenu( [ savedFile ] );
success: function(savedFile) {
if (savedFile.path) {
if (!remotePath) {
addToRecentMenu([savedFile]);
}
setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath );
setRemotePath(savedFile.path, true);
if (draftManager) {
draftManager.save(remotePath);
draftManager.sync();
}
clearTimeout( timeout );
clearTimeout(timeout);
save.busy = false;
upload.tryCount = 0;
} else {
......@@ -689,62 +767,62 @@ $( function () {
}
},
error: upload
} );
});
upload.tryCount++;
}
upload.tryCount = 0;
upload();
$save_btn.loading( '正在保存...' );
}
function share() {
if ( $share_btn.disabled() ) {
if ($share_btn.disabled()) {
return;
}
var baseUrl = /^(.*?)(\?|\#|$)/.exec( window.location.href )[ 1 ];
var baseUrl = /^(.*?)(\?|\#|$)/.exec(window.location.href)[1];
var shareUrl = baseUrl + '?shareId=' + shareId,
shareData = new baidu.frontia.Data( {
shareData = new baidu.frontia.Data({
shareMinder: {
id: shareId,
data: minder.exportData( 'json' )
data: minder.exportData('json')
}
} );
});
var shareConfig = window._bd_share_config.common,
resetShare = window._bd_share_main.init;
$share_btn.loading( '正在分享...' );
$share_btn.loading('正在分享...');
$.ajax( {
$.ajax({
url: 'http://naotu.baidu.com/mongo.php',
type: 'POST',
data: {
action: 'insert',
record: JSON.stringify( {
record: JSON.stringify({
shareMinder: {
id: shareId,
data: minder.exportData( 'json' )
data: minder.exportData('json')
}
} )
})
},
success: function ( result ) {
if ( result.error ) {
notice( result.error );
success: function(result) {
if (result.error) {
notice(result.error);
} else {
$share_dialog.show();
$share_url.val( shareUrl )[ 0 ].select();
$share_url.val(shareUrl)[0].select();
}
$share_btn.loading(false);
},
error: function () {
notice( '分享失败,可能是当前的环境不支持该操作。' );
error: function() {
notice('分享失败,可能是当前的环境不支持该操作。');
$share_btn.loading(false);
}
} );
});
shareConfig.bdTitle = shareConfig.bdText = minder.getMinderTitle();
shareConfig.bdDesc = shareConfig.bdText = '“' + minder.getMinderTitle() + '” - 我用百度脑图制作的思维导图,快看看吧!(地址:' + shareUrl + ')';
......@@ -754,147 +832,151 @@ $( function () {
function bindShortCuts() {
$( document.body ).keydown( function ( e ) {
$(document.body).keydown(function(e) {
var keyCode = e.keyCode || e.which;
//添加快捷键
if ( ( e.ctrlKey || e.metaKey ) ) {
switch ( keyCode ) {
if ((e.ctrlKey || e.metaKey)) {
switch (keyCode) {
//保存
case KM.keymap.s:
if ( e.shiftKey ) {
share();
} else {
save();
}
e.preventDefault();
break;
case KM.keymap.n:
newFile();
e.preventDefault();
break;
case KM.keymap.s:
if (e.shiftKey) {
share();
} else {
save();
}
e.preventDefault();
break;
case KM.keymap.n:
newFile();
e.preventDefault();
break;
}
}
} );
});
}
function watchChanges() {
minder.on( 'contentchange', function () {
if ( !watchingChanges ) return;
var lastContent = minder.exportData('json');
minder.on('contentchange', function() {
if (!watchingChanges || lastContent == minder.exportData('json')) return;
var current = draftManager.save();
if ( currentAccount ) {
$save_btn.disabled( current.sync ).text( '保存' );
setRemotePath( remotePath, current.sync );
if (currentAccount) {
setRemotePath(remotePath, current.sync);
}
} );
lastContent = minder.exportData('json');
});
}
function showDraftList() {
var list = draftManager.list(),
draft, $draft, index;
if ( !list.length ) {
if (!list.length) {
draftManager.create();
list = draftManager.list();
}
$draft_menu.empty();
draft = list.shift();
$draft_menu.empty().append( '<li disabled="disabled" class="current-draft kmui-combobox-item kmui-combobox-item-disabled kmui-combobox-checked">' +
'<span class="kmui-combobox-icon"></span>' +
'<label class="kmui-combobox-item-label">' + draft.name +
'<span class="update-time">' + getFriendlyTimeSpan( +new Date( draft.update ), +new Date() ) + '</span>' +
'</label>' +
'</li>' );
$draft_menu.append( '<li class="kmui-divider"></li>' );
if (draftManager.getCurrent()) {
draft = list.shift();
$draft_menu.append('<li disabled="disabled" class="current-draft kmui-combobox-item kmui-combobox-item-disabled kmui-combobox-checked">' +
'<span class="kmui-combobox-icon"></span>' +
'<label class="kmui-combobox-item-label">' +
'<span class="update-time">' + getFriendlyTimeSpan(+new Date(draft.update), +new Date()) + '</span>' + draft.name +
'</label>' +
'</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 = $( '<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>' );
$draft.data( 'draft-index', index++ );
$draft.appendTo( $draft_menu );
$draft = $('<li class="draft-item">' +
'<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.appendTo($draft_menu);
}
if ( index > 1 ) {
$draft_menu.append( '<li class="kmui-divider"></li>' );
$draft_menu.append( '<li class="draft-clear"><a href="#">清空草稿箱</a></li>' );
if (index > 1) {
$draft_menu.append('<li class="kmui-divider"></li>');
$draft_menu.append('<li class="draft-clear"><a href="#">清空草稿箱</a></li>');
}
adjustDraftMenu();
//adjustDraftMenu();
}
function adjustDraftMenu() {
var pos = $draft_btn.offset();
pos.top -= $draft_menu.outerHeight() + 5;
$draft_menu.offset( pos );
$draft_menu.offset(pos);
}
function bindDraft() {
draftManager = window.draftManager;
if ( !draftManager ) {
if ( window.DraftManager ) {
draftManager = window.draftManager = new window.DraftManager( minder );
if (!draftManager) {
if (window.DraftManager) {
draftManager = window.draftManager = new window.DraftManager(minder);
}
}
$draft_menu.delegate( 'a.delete', 'click', function ( e ) {
var $li = $( this ).closest( 'li.draft-item' );
draftManager.remove( +$li.data( 'draft-index' ) );
$draft_menu.delegate('a.delete', 'click', function(e) {
var $li = $(this).closest('li.draft-item');
draftManager.remove(+$li.data('draft-index'));
$li.remove();
showDraftList();
e.stopPropagation();
} )
})
.delegate( 'li.draft-clear', 'click', function ( e ) {
if ( window.confirm( '确认清除草稿箱吗?' ) ) {
.delegate('li.draft-clear', 'click', function(e) {
if (window.confirm('确认清除草稿箱吗?')) {
draftManager.clear();
showDraftList();
}
e.stopPropagation();
} )
})
.delegate( 'li.draft-item', 'click', function ( e ) {
loadDraft( +$( this ).data( 'draft-index' ) );
} );
.delegate('li.draft-item', 'click', function(e) {
loadDraft(+$(this).data('draft-index'));
});
}
function loadDraft( index ) {
var draft = draftManager.open( index ),
function loadDraft(index) {
var draft = draftManager.open(index),
isRemote;
if ( !draft ) {
minder.initStyle();
return;
}
isRemote = draft.path.indexOf( '/apps/kityminder' ) === 0;
if ( isRemote ) {
setRemotePath( draft.path, draft.sync );
if (!draft) return;
isRemote = draft.path.indexOf('/apps/kityminder') === 0;
if (isRemote) {
setRemotePath(draft.path, draft.sync);
}
watchingChanges = false;
draftManager.load();
watchingChanges = true;
if ( !isRemote ) {
setRemotePath( null, false );
if (!isRemote) {
setRemotePath(null, false);
}
minder.execCommand('camera', null, 300);
}
function getFriendlyTimeSpan( t1_in_ms, t2_in_ms ) {
var ms = Math.abs( t1_in_ms - t2_in_ms ),
function getFriendlyTimeSpan(t1_in_ms, t2_in_ms) {
var ms = Math.abs(t1_in_ms - t2_in_ms),
s = ms / 1000,
m = s / 60,
h = m / 60,
d = h / 24;
if ( s < 60 ) return "刚刚";
if ( m < 60 ) return ( m | 0 ) + "分钟前";
if ( h < 24 ) return ( h | 0 ) + "小时前";
if ( d <= 30 ) return ( d | 0 ) + "天前";
if (s < 60) return "刚刚";
if (m < 60) return (m | 0) + "分钟前";
if (h < 24) return (h | 0) + "小时前";
if (d <= 30) return (d | 0) + "天前";
return "很久之前";
}
window.social = {
setRemotePath: setRemotePath,
watchChanges: function ( value ) {
watchChanges: function(value) {
watchingChanges = value;
}
};
} );
\ No newline at end of file
});
\ No newline at end of file
#social {
position: absolute;
right: 10px;
top: 10px;
line-height: 20px;
text-align: right;
overflow: hidden;
.niceblue {
color: white;
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 */
}
.dropdown {
padding-right: 28px;
position: relative;
&:after {
content: ' ';
display: block;
position: absolute;
right: 10px;
top: 15px;
top: 12px;
width: 0;
height: 0;
border: solid;
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 {
display: inline-block;
vertical-align: middle;
padding: 0 15px;
height: 35px;
height: 30px;
font-size: 13px;
line-height: 35px;
line-height: 30px;
text-align: center;
border-radius: 5px;
color: #ffffff;
color: #000;
text-decoration: none;
border: none;
margin-left: 5px;
cursor: pointer;
background: #0099f2; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
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 */
background: none;
border-radius: 2px;
.niceblue;
&:hover, &.hover {
background: #009fff;
}
......@@ -59,63 +59,14 @@ button {
}
&[disabled] {
background: #AAA;
cursor: default;
}
&.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;
background: #ccc;
}
}
#draft-btn {
.dropdown;
}
.draft-menu {
.draft-menu.kmui-dropdown-menu {
margin-top: 24px;
margin-left: 1px;
span.update-time {
float: right;
color: #CCC;
......@@ -184,17 +135,46 @@ button {
}
}
}
.user-file-menu {
margin-top: 20px;
.file-menu.kmui-dropdown-menu {
margin-top: 24px;
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 {
position: absolute;
padding: 20px;
border-radius: 4px;
right: 10px;
top: 65px;
left: 50%;
top: 40%;
margin-left: -175px;
margin-top: -100px;
background: white;
width: 350px;
box-shadow: 1px 2px 16px rgba(0, 0, 0, .5);
......@@ -233,22 +213,24 @@ button {
line-height: 28px;
border-radius: 2px;
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 {
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 {
position: fixed;
top: 60px;
top: 140px;
right:10px;
background-color: #ffffff;
background-color: #fff;
outline: 0;
border-radius: 5px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5);
......
.kmui-dropdown-menu {
position: absolute;
z-index: 1000;
z-index: 99999999999;
display: none;
min-width: 160px;
padding: 5px 0;
......@@ -51,7 +51,7 @@
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 */
background: #5a6378; /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white;
......
......@@ -2,13 +2,213 @@
html, body, div {
margin: 0;
padding: 0;
/* background: #FFFFFF; */
}
html, body, #kityminder, div.kmui-editor-body {
height: 100%;
width: 100%;
overflow: hidden;
-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{
width:0;
height:0;
......@@ -16,34 +216,78 @@ html, body, #kityminder, div.kmui-editor-body {
.km-minderNode{
cursor:default;
}
.kmui-container {
height: 100%;
}
.kmui-container {
.kmui-container, .kmui-editor-body {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
}
.kmui-container .kmui-toolbar{
background-color: #fafafa;
z-index: 99999;
margin-right: 400px;
background-color: #fff;
z-index: 999;
}
.kmui-container .kmui-toolbar:after {
}
.kmui-toolbar .kmui-btn-toolbar{
padding: 5px;
border-bottom: 1px solid #f0f0f0;
}
.kmui-toolbar {
position: absolute;
left: 10px;
top: 10px;
border-radius: 4px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5);
left: 0;
right: 0;
top: 0;
}
.kmui-container .kmui-editor-body {
background: rgb(50, 60, 61) url(../images/grid.png) repeat;
background: #fbfbfb;
/*line-height: 0;*/
overflow: hidden;
}
svg, body {
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: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 @@
'KITYMINDER_HOME_URL': getKMBasePath(),
//定义工具栏
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
//readOnly: true
......
......@@ -2,7 +2,7 @@
/**
* 百度脑图社会化功能
*
* 1. 百度账号登
* 1. 百度账号登
* 2. 百度云存储
* 3. 分享
* 4. 草稿箱同步
......@@ -103,6 +103,67 @@ $(function() {
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
function initUI() {
$panel = $('#panel');
......@@ -113,24 +174,9 @@ $(function() {
$file_btn = $('<button id="file-btn">文件</button>').addClass('dropdown').appendTo($menu);
$file_menu = $.kmuidropmenu({
data: [{
label: '新建 (Ctrl + N)',
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 = $.kmuidropmenu({ data: createFileMenu() })
.addClass('file-menu')
.appendTo('body');
$file_menu.kmui().attachTo($file_btn);
......@@ -142,9 +188,8 @@ $(function() {
$draft_menu = $.kmuidropmenu().addClass('draft-menu kmui-combobox-menu').appendTo('body');
$draft_menu.kmui().attachTo($draft_btn);
$draft_menu.on('aftershow', showDraftList);
$tool_btn = $('<button id="tool-btn">工具箱</button>').appendTo($menu);
$tool_btn = $('<button id="tool-btn" title="打开/收起工具箱">工具箱</button>').appendTo($menu);
$tool_btn.click(function() {
var hide = !localStorage.hide_toolbar;
......@@ -160,7 +205,7 @@ $(function() {
$login_btn = $('<button id="login-btn">登录</button>').appendTo($user).click(login);
$user_btn = $('<button id="user-btn">用户</button>').addClass('dropdown').appendTo($user);
$user_menu = $.kmuidropmenu({
data: [{
label: '个人中心',
......@@ -899,7 +944,7 @@ $(function() {
function loadDraft(index) {
var draft = draftManager.open(index),
isRemote;
if (!draft) return;
isRemote = draft.path.indexOf('/apps/kityminder') === 0;
......
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);
}
});
(function() {
//实例化
$combox = $.kmuibuttoncombobox(options).css('zIndex', me.getOptions('zIndex') + 1);
comboboxWidget = $combox.kmui();
function doProxyDownload(url, filename, type) {
function doDownload(url, filename, type) {
var content = url.split(',')[1];
var $form = $('<form></form>').attr({
'action': 'http://172.22.73.36/naotu/download.php',
'action': 'download.php',
'method': 'POST'
});
......@@ -59,38 +28,81 @@ KM.registerToolbarUI('saveto', function(name) {
$form.appendTo('body').submit().remove();
}
function doDownload(url, filename, type) {
if (!kity.Browser.chrome || ~window.location.href.indexOf('naotu.baidu.com')) {
return doProxyDownload(url, filename, type);
}
var a = document.createElement('a');
a.setAttribute('download', filename);
a.setAttribute('href', url);
a.click();
function buildDataUrl(mineType, data) {
return 'data:' + mineType + '; utf-8,' + encodeURIComponent(data);
}
comboboxWidget.on('comboboxselect', function(evt, res) {
var data = me.exportData(res.value);
var p = KityMinder.findProtocal(res.value);
var filename = me.getMinderTitle() + p.fileExtension;
function doExport(minder, type) {
var data = minder.exportData(type);
var protocal = KityMinder.findProtocal(type);
var filename = minder.getMinderTitle() + protocal.fileExtension;
var mineType = protocal.mineType || 'text/plain';
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) {
data.then(function(url) {
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() {
var minder = this;
if (kity.Browser.ie && Number(kity.Browser.version) < 10) {
alert('文件导入对IE浏览器仅支持10以上版本');
alert('文件导入对 IE 浏览器仅支持 10 以上版本');
return;
}
......@@ -30,20 +30,27 @@ KityMinder.registerModule('DropFile', function() {
if (files) {
var file = files[0];
var ext = file.type || (/(.)\w+$/).exec(file.name)[0];
console.log(ext);
if ((/xmind/g).test(ext)) { //xmind zip
importSync(minder, file, 'xmind');
} else if ((/mmap/g).test(ext)) { // mindmanager zip
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');
}
importMinderFile(minder, file);
}
}
function importMinderFile(minder, file) {
if (!file) return;
var ext = /(.)\w+$/.exec(file.name)[0];
if ((/xmind/g).test(ext)) { //xmind zip
importSync(minder, file, 'xmind');
} else if ((/mmap/g).test(ext)) { // mindmanager zip
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() {
if (!importing) return;
createDraft(this);
social.setRemotePath(null, false);
this.execCommand('camera', this.getRoot());
this.execCommand('camera', this.getRoot(), 800);
setTimeout(function() {
social.watchChanges(true);
}, 10);
......@@ -80,6 +87,13 @@ KityMinder.registerModule('DropFile', function() {
draftManager.create();
}
kity.extendClass(Minder, {
importFile: function(file) {
importMinderFile(this, file);
return this;
}
});
return {
events: {
'ready': init,
......
......@@ -12,17 +12,17 @@ html, body, #kityminder, div.kmui-editor-body {
#title, #panel {
background: #393F4F;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
-webkit-font-smoothing: antialiased;
/* -webkit-font-smoothing: antialiased; */
}
#title {
height: 40px;
line-height: 40px;
line-height: 45px;
padding: 0;
margin: 0;
padding: 0;
font-size: 14px;
color: white;
color: #DBDBDB;
text-align: center;
font-weight: 300;
font-size: 14px;
......@@ -103,7 +103,7 @@ button#tool-btn {
display: block;
position: absolute;
top: 21px;
left: 27px;
left: 40px;
width: 0;
height: 0;
border: solid;
......@@ -112,14 +112,14 @@ button#tool-btn {
}
#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;
/* 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;
/* height: 28px; */
/* margin-top: -1px; */
/* margin-left: 7px; */
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