Commit f0a86d7d authored by techird's avatar techird

stash

parent 9e89a241
......@@ -9,9 +9,9 @@
<title>百度脑图 - 便捷的思维导图工具</title>
<script src="kityminder.all.min.js?_=1409099802809" charset="utf-8"></script>
<script src="kityminder.config.js?_=1409099802809" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1409099802809" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1409280817067" charset="utf-8"></script>
<script src="kityminder.config.js?_=1409280817067" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1409280817067" charset="utf-8"></script>
<link href="ui/theme/default/css/default.all.css" type="text/css" rel="stylesheet" />
......
This diff is collapsed.
This diff is collapsed.
......@@ -67,7 +67,10 @@ KityMinder.LANG['zh-cn'] = {
'save': {
'header': '保存到',
'netdisk': '百度网盘',
'local': '导出到本地'
'download': '导出到本地'
},
'share': {
'header': '分享我的脑图'
}
},
......@@ -78,6 +81,16 @@ KityMinder.LANG['zh-cn'] = {
'dropfile': '或将文件拖至此处',
'unsupportedfile': '不支持的文件格式',
'untitleddoc': '未命名文档',
'errorloading': '加载失败:{0}',
'unknownreason': '可能是外星人篡改了代码...',
'overrideconfirm': '{0} 已存在,确认覆盖吗?',
'checklogin': '检查登录状态中...',
'loggingin': '正在登录...',
'recent': '最近打开',
'clearrecent': '清空',
'clearrecentconfirm': '确认清空最近文档列表?',
'cleardraft': '清空',
'cleardraftconfirm': '确认清空草稿箱?',
'login': '登录',
'logout': '注销',
......
This diff is collapsed.
......@@ -14,8 +14,10 @@
'lib/ZeroClipboard.min.js',
'lib/fui/dev-lib/jhtmls.min.js',
'lib/fui/dist/fui.all.js',
'lib/fio/dist/fio.js',
'lib/fio/src/fio.js',
'lib/fio/provider/netdisk/oauth.js',
'lib/fio/provider/netdisk/netdisk.js',
'lib/fio/provider/mongoshare/mongoshare.js',
/* Kity 依赖库 */
'lib/kity/dist/kity.js',
......@@ -102,6 +104,7 @@
'ui/eve.js',
'ui/fuix.js',
'ui/fiox.js',
'ui/doc.js',
/* UI 组件 */
'ui/widget/commandbutton.js',
......@@ -109,22 +112,21 @@
'ui/widget/commandinputmenu.js',
'ui/widget/friendlytimespan.js',
'ui/widget/locallist.js',
'ui/widget/fileloader.js',
'ui/widget/netdiskfinder.js',
'ui/widget/menutab',
/* UI 菜单 */
'ui/menu/menu.js',
'ui/menu/header.js',
'ui/menu/level1.js',
/* UI 菜单 - 新建 */
'ui/menu/new/new.js',
/* UI 菜单 - 打开 */
'ui/menu/open/open.js',
'ui/menu/open/local.js',
'ui/menu/open/netdisk.js',
'ui/menu/open/recent.js',
'ui/menu/open/netdisk.js',
'ui/menu/open/local.js',
'ui/menu/open/draft.js',
/* UI 菜单 - 保存 */
......
/**
* 开发版本的文件导入
*/
(function() {
var paths = [
/* 依赖库 */
'lib/jquery-2.1.1.js',
'lib/jquery.transit.min.js',
'lib/promise-1.0.0.js',
'lib/fui/dev-lib/jhtmls.min.js',
'lib/fui/dist/fui.all.js',
/* Kity 依赖库 */
'lib/kity/dist/kity.js',
/* 核心代码 */
'src/core/kityminder.js',
'src/core/utils.js',
'src/core/command.js',
'src/core/node.js',
'src/core/module.js',
'src/core/event.js',
'src/core/minder.js',
'src/core/minder.data.compatibility.js',
'src/core/minder.data.js',
'src/core/minder.event.js',
'src/core/minder.module.js',
'src/core/minder.command.js',
'src/core/minder.node.js',
'src/core/minder.select.js',
'src/core/keymap.js',
'src/core/minder.lang.js',
'src/core/minder.defaultoptions.js',
'src/core/minder.preference.js',
'src/core/browser.js',
'src/core/layout.js',
'src/core/connect.js',
'src/core/render.js',
'src/core/theme.js',
'src/core/template.js',
/* 布局 */
'src/layout/default.js',
'src/layout/default.connect.js',
'src/layout/bottom.js',
'src/layout/filetree.js',
/* 皮肤 */
'src/theme/default.js',
'src/theme/snow.js',
'src/theme/fresh.js',
/* 模板 */
'src/template/structure.js',
/* 模块 */
'src/module/node.js',
'src/module/text.js',
'src/module/expand.js',
'src/module/outline.js',
'src/module/geometry.js',
'src/module/history.js',
'src/module/progress.js',
'src/module/priority.js',
'src/module/image.js',
'src/module/resource.js',
'src/module/view.js',
'src/module/dragtree.js',
'src/module/keyboard.js',
'src/module/select.js',
'src/module/history.js',
'src/module/basestyle.js',
'src/module/font.js',
'src/module/zoom.js',
'src/module/hyperlink.js',
'src/module/arrange.js',
'src/module/paste.js',
'src/module/style.js',
/* 格式支持 */
'src/protocol/plain.js',
'src/protocol/json.js',
'src/protocol/png.js',
'src/protocol/svg.js',
/* UI 基础 */
'ui/ui.js',
'ui/eve.js',
'ui/fuix.js',
// 'ui/fiox.js',
'ui/doc.js',
/* UI 组件 */
// 'ui/widget/commandbutton.js',
// 'ui/widget/commandbuttonset.js',
// 'ui/widget/commandinputmenu.js',
// 'ui/widget/friendlytimespan.js',
// 'ui/widget/locallist.js',
// 'ui/widget/netdiskfinder.js',
'ui/widget/menutab',
/* UI 菜单 */
'ui/menu/menu.js',
'ui/menu/header.js',
/* UI 菜单 - 新建 */
// 'ui/menu/new/new.js',
/* UI 菜单 - 打开 */
// 'ui/menu/open/open.js',
// 'ui/menu/open/recent.js',
// 'ui/menu/open/netdisk.js',
// 'ui/menu/open/local.js',
// 'ui/menu/open/draft.js',
/* UI 菜单 - 保存 */
'ui/menu/save/save.js',
// 'ui/menu/save/netdisk.js',
'ui/menu/save/download.js',
/* UI 菜单 - 分享 */
// 'ui/menu/share/share.js',
/* UI Top Bar */
// 'ui/topbar/history.js',
// 'ui/topbar/user.js',
'ui/topbar/search.js',
'ui/topbar/title.js',
/* UI Ribbon */
// 'ui/ribbon/tabs.js',
/* UI Ribbon「思路」面板 */
// 'ui/ribbon/idea/insert.js',
// 'ui/ribbon/idea/arrange.js',
// 'ui/ribbon/idea/operation.js',
// 'ui/ribbon/idea/attachment.js',
// 'ui/ribbon/idea/link.js',
// 'ui/ribbon/idea/image.js',
// 'ui/ribbon/idea/priority.js',
// 'ui/ribbon/idea/progress.js',
// 'ui/ribbon/idea/resource.js',
/* UI Ribbon「展示」面板 */
// 'ui/ribbon/appearence/template.js',
// 'ui/ribbon/appearence/theme.js',
// 'ui/ribbon/appearence/layout.js',
// 'ui/ribbon/appearence/style.js',
// 'ui/ribbon/appearence/font.js',
// 'ui/ribbon/appearence/color.js',
/* UI Ribbon「视图」面板 */
// 'ui/ribbon/view/level.js'
];
if (typeof(module) === 'object' && module.exports) {
module.exports = paths;
} else if (document) {
while (paths.length) {
/* jshint browser:true */
window.document.write('<script type="text/javascript" src="' + paths.shift() + '"></script>');
}
}
})();
\ No newline at end of file
......@@ -27,22 +27,6 @@
</div>
<div id="share-dialog">
<h3>URL分享:</h3>
<p>
<input id="share-url" type="url" value="http://naotu.baidu.com/?shareId=kcev3dd" />
<button id="copy-share-url" data-clipboard-target="share-url" type="button">复制</button>
</p>
<h3>社交分享:</h3>
<p id="share-platform" class="bdsharebuttonbox">
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
<a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
<a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p>
</div>
<div id="about">
<svg id="km-cat" viewBox="0 0 1200 1200" width="32px" height="32px">
<g id="cat-face">
......@@ -100,7 +84,6 @@
$(function() {
/* 依赖库初始化 */
ZeroClipboard.setDefaults({ moviePath: 'lib/ZeroClipboard.swf' });
zip.inflateJSPath = 'lib/inflate.js';
});
......
......@@ -46,29 +46,27 @@ KityMinder.LANG['zh-cn'] = {
},
'menu': {
'level1': {
'new': '新建',
'open': '打开',
'save': '保存',
'share': '分享',
'help': '帮助',
'setting': '设置'
},
'new': {
'header': '新建脑图'
},
'open': {
'header': '打开',
'recent': '最近使用',
'netdisk': '百度云盘',
'local': '本地文件',
'draft': '草稿箱'
},
'save': {
'header': '保存到',
'netdisk': '百度网盘',
'local': '导出到本地'
}
'mainmenutext': '百度脑图', // 主菜单按钮文本
'newtab': '新建',
'opentab': '打开',
'savetab': '保存',
'sharetab': '分享',
'helptab': '帮助',
'settingtab': '设置',
'recenttab': '最近使用',
'netdisktab': '百度云存储',
'localtab': '本地文件',
'drafttab': '草稿箱',
'downloadtab': '导出到本地',
'createsharetab': '当前脑图',
'managesharetab': '已分享',
'newheader': '新建脑图',
'openheader': '打开',
'saveheader': '保存到',
'shareheader': '分享我的脑图'
},
'mydocument': '我的文档',
......@@ -78,6 +76,34 @@ KityMinder.LANG['zh-cn'] = {
'dropfile': '或将文件拖至此处',
'unsupportedfile': '不支持的文件格式',
'untitleddoc': '未命名文档',
'errorloading': '加载失败:{0}',
'unknownreason': '可能是外星人篡改了代码...',
'overrideconfirm': '{0} 已存在,确认覆盖吗?',
'checklogin': '检查登录状态中...',
'loggingin': '正在登录...',
'recent': '最近打开',
'clearrecent': '清空',
'clearrecentconfirm': '确认清空最近文档列表?',
'cleardraft': '清空',
'cleardraftconfirm': '确认清空草稿箱?',
'none_share': '不分享',
'public_share': '公开分享',
'password_share': '私密分享',
'email_share': '邮件邀请',
'url_share': '脑图 URL 地址:',
'sns_share': '社交网络分享:',
'sns_share_text': '“{0}” - 我用「百度脑图」制作的思维导图,快看看吧!(地址:{1})',
'none_share_description': '不分享当前脑图',
'public_share_description': '创建任何人可见的分享',
'share_button_text': '创建',
'password_share_description': '创建需要密码才可见的分享',
'email_share_description': '创建指定人可见的分享,您还可以允许他们编辑',
'ondev': '敬请期待!',
'create_share_failed': '分享失败:{0}',
'copy': '复制',
'copied': '已复制',
'shared_tip': '当前脑图被 {0} 分享,你可以修改之后保存到自己的网盘上或再次分享',
'login': '登录',
'logout': '注销',
......
Subproject commit b5a61278a057db00d81d54718514df9492007d1e
Subproject commit f56bdb0c9bd079b42ea07f683dc79c5796174ea9
Subproject commit bdca414351274d350a1cc87c2f3d17536b715903
Subproject commit 7198d3af584d6cf2b4b6335045a57d0b07d5c292
......@@ -269,7 +269,7 @@ define("promise/polyfill",
return isFunction(resolve);
}());
if (!es6PromiseSupport) {
if (!es6PromiseSupport || ~window.location.href.indexOf('rsvpromise')) {
local.Promise = RSVPPromise;
}
}
......
......@@ -35,8 +35,7 @@ kity.extendClass(Minder, {
});
},
exportData: function(protocolName) {
exportJson: function() {
/* 导出 node 上整棵树的数据为 JSON */
function exportNode(node) {
var exported = {};
......@@ -51,14 +50,67 @@ kity.extendClass(Minder, {
return exported;
}
var json, protocol;
json = exportNode(this.getRoot());
var json = exportNode(this.getRoot());
json.template = this.getTemplate();
json.theme = this.getTheme();
json.version = KityMinder.version;
return json;
},
importJson: function(json, params) {
function importNode(node, json, km) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
node.setData('text', data.text || km.getLang(DEFAULT_TEXT[node.getType()]));
var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) {
var childNode = km.createNode(null, node);
importNode(childNode, childrenTreeData[i], km);
}
return node;
}
if (!json) return;
this._fire(new MinderEvent('preimport', params, false));
// 删除当前所有节点
while (this._root.getChildren().length) {
this.removeNode(this._root.getChildren()[0]);
}
json = KityMinder.compatibility(json);
importNode(this._root, json, this);
this.setTemplate(json.template || null);
this.setTheme(json.theme || null);
this.refresh();
this.fire('import', params);
this._firePharse({
type: 'contentchange'
});
this._firePharse({
type: 'interactchange'
});
},
exportData: function(protocolName) {
var json, protocol;
json = this.exportJson();
// 指定了协议进行导出,需要检测协议是否支持
if (protocolName) {
protocol = this.getProtocol(protocolName);
......@@ -112,57 +164,11 @@ kity.extendClass(Minder, {
}).then(function(json) {
minder._doImport(json, params);
minder.importJson(json, params);
return json;
});
},
_doImport: function(json, params) {
function importNode(node, json, km) {
var data = json.data;
node.data = {};
for (var field in data) {
node.setData(field, data[field]);
}
node.setData('text', data.text || km.getLang(DEFAULT_TEXT[node.getType()]));
var childrenTreeData = json.children || [];
for (var i = 0; i < childrenTreeData.length; i++) {
var childNode = km.createNode(null, node);
importNode(childNode, childrenTreeData[i], km);
}
return node;
}
if (!json) return;
this._fire(new MinderEvent('preimport', params, false));
// 删除当前所有节点
while (this._root.getChildren().length) {
this.removeNode(this._root.getChildren()[0]);
}
json = KityMinder.compatibility(json);
importNode(this._root, json, this);
this.setTemplate(json.template || null);
this.setTheme(json.theme || null);
this.refresh();
this.fire('import', params);
this._firePharse({
type: 'contentchange'
});
this._firePharse({
type: 'interactchange'
});
}
});
\ No newline at end of file
......@@ -368,7 +368,6 @@ KityMinder.registerModule('DragTree', function() {
dragger.dragEnd();
//e.stopPropagation();
e.preventDefault();
this.fire('contentchange');
},
'statuschange': function(e) {
if (e.lastStatus == 'textedit' && e.currentStatus == 'normal') {
......
......@@ -219,9 +219,9 @@ Minder.Receiver = kity.createClass('Receiver', {
this.km.setStatus('inputready');
clearTimeout(me.inputTextTimer);
e.preventDefault();
this.km.fire('contentchange');
}else{
this.km.setStatus('normal');
this.km.fire('contentchange');
}
restoreTextContent();
return;
......@@ -303,7 +303,6 @@ Minder.Receiver = kity.createClass('Receiver', {
e.preventDefault();
}else{
this.km.setStatus('normal');
this.km.fire('contentchange');
}
restoreTextContent();
return;
......
......@@ -74,7 +74,7 @@ KityMinder.registerProtocol('freemind', function(minder) {
}
return {
fileDescription: 'freemind格式文件',
fileDescription: 'Freemind 格式',
fileExtension: '.mm',
dataType: 'text',
......
KityMinder.registerProtocol('json', function(minder) {
return {
fileDescription: 'KityMinder',
fileDescription: 'KityMinder 格式',
fileExtension: '.km',
dataType: 'text',
mineType: 'application/json',
......
......@@ -113,7 +113,7 @@ KityMinder.registerProtocol('mindmanager', function(minder) {
}
return {
fileDescription: 'mindmanager格式文件',
fileDescription: 'MindManager 格式',
fileExtension: '.mmap',
dataType: 'blob',
......
......@@ -138,6 +138,7 @@ if (!kity.Browser.ie) {
fileDescription: 'PNG 图片',
fileExtension: '.png',
mineType: 'image/png',
dataType: 'base64',
encode: encode,
recognizePriority: -1
};
......
......@@ -6,6 +6,7 @@ if (!kity.Browser.ie) {
fileDescription: 'SVG 矢量图',
fileExtension: '.svg',
mineType: 'image/svg+xml',
dataType: 'text',
encode: function(json) {
......
......@@ -32,7 +32,7 @@ KityMinder.registerProtocol('xmind', function(minder) {
};
return {
fileDescription: 'xmind格式文件',
fileDescription: 'XMind 格式',
fileExtension: '.xmind',
dataType: 'blob',
......
/**
* @fileOverview
*
* 当前文档管理
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('doc', function(minder) {
var ret = minder.getUI('eve').setup({});
var current = {};
var loading = false;
/**
* 加载文档
*
* @param {Object} doc 文档的属性,可包括:
* doc.content {string} [Required] 文档内容
* doc.protocol {string} [Required] 内容所使用的编码协议
* doc.title {string} 文档的标题
* doc.source {string} 文档的来源
* doc.path {string} 文档的路径
* doc.saved {bool} 文档的保存状态
*
* @event docload(doc)
* doc - 文档解析之后的文档对象
*
* @return {Promise<doc>} 返回解析完之后的文档对象,解析的结果为 doc.data
*/
function load(doc) {
var restore = doc;
current = doc;
loading = true;
return minder.importData(doc.content, doc.protocol).then(function(data) {
doc.title = doc.title || minder.getMinderTitle();
minder.execCommand('camera', minder.getRoot(), 300);
doc.data = data;
doc.json = JSON.stringify(data);
minder.getUI('topbar/title').setTitle(doc.title, doc.saved);
ret.fire('docload', doc);
return doc;
})['catch'](function(e) {
current = restore;
throw e;
}).then(function(doc) {
loading = false;
return doc;
});
}
function save(doc) {
current = doc;
minder.getUI('topbar/title').setTitle(doc.title, true);
ret.fire('docsave', doc);
}
function getCurrent() {
return current;
}
/* 绕开初始化时候的乱事件 */
setTimeout(function() {
minder.on('contentchange', function() {
if (loading) return;
var $title = minder.getUI('topbar/title');
if (current.source != 'netdisk') {
current.title = minder.getMinderTitle();
$title.setTitle(current.title, false);
ret.fire('docchange', current);
} else {
if (current.json != JSON.stringify(minder.exportJson())) {
$title.setSaved(false);
ret.fire('docchange', current);
} else {
$title.setSaved(true);
}
}
});
}, 1000);
ret.load = load;
ret.save = save;
ret.current = getCurrent;
return ret;
});
\ No newline at end of file
......@@ -10,4 +10,9 @@
KityMinder.registerUI('fiox', function(minder) {
var eve = minder.getUI('eve');
eve.setup(fio.user);
/* 初始化网盘使用的 APP 身份 */
fio.user.init({
apiKey: 'wiE55BGOG8BkGnpPs6UNtPbb'
});
});
\ No newline at end of file
/**
* @fileOverview
*
* 菜单默认选择项目
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/default', function (minder) {
});
\ No newline at end of file
......@@ -7,21 +7,29 @@
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/header', function (minder) {
KityMinder.registerUI('menu/header', function(minder) {
var $menu = minder.getUI('menu/menu');
var $header = $('<div class="main-menu-header"></div>').appendTo($menu);
var $header = $('<div class="main-menu-header"></div>')
.prependTo($menu.$panel);
var $backPanel = $('<div class="main-menu-back-panel"></div>').appendTo($header);
var $backPanel = $('<div class="main-menu-back-panel"></div>')
.appendTo($header);
var $titlePanel = $('<div class="main-menu-title">百度脑图</div>').appendTo($header);
var $titlePanel = $('<div class="main-menu-title">百度脑图</div>')
.appendTo($header);
var $backButton = new FUI.Button({
className: 'main-menu-back-button',
label: minder.getLang('ui.back')
}).appendTo($backPanel[0]).on('click', function() {
$menu.removeClass('show');
}).appendTo($backPanel[0]).on('click', $menu.hide);
$menu.on('show', function() {
var $title = minder.getUI('topbar/title');
$titlePanel.text($title.getTitle());
});
return $header;
......
/**
* @fileOverview
*
* 一级菜单
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/level1', function(minder) {
var $menu = minder.getUI('menu/menu');
var tabs = ['new', 'open', 'save', 'share', 'help'];
var $l1_tabs = new FUI.Tabs({
buttons: tabs.map(function(key) {
return {
label: minder.getLang('ui.menu.level1.' + key),
className: key
};
}),
className: 'main-menu-level-1'
});
$l1_tabs.appendTo($menu[0]);
$l1_tabs.select(2);
var ret = {};
tabs.forEach(function(key, index) {
ret[key] = $l1_tabs.getPanel(index);
});
return ret;
});
\ No newline at end of file
......@@ -9,27 +9,79 @@
KityMinder.registerUI('menu/menu', function(minder) {
var $mainMenuButton = new FUI.Button({
id: 'main-menu-btn'
});
var ret = minder.getUI('eve').setup({});
var $menutab = minder.getUI('widget/menutab');
// 主菜单容器
var $panel = $('<div>')
.attr('id', 'main-menu')
.appendTo('#content-wrapper');
// 主菜单按钮
var $button = new FUI.Button({
id: 'main-menu-btn',
label: minder.getLang('ui.menu.mainmenutext')
}).appendTo(document.getElementById('panel'));
var $panel;
// 一级菜单选项卡
var $tabs = new FUI.Tabs({
className: 'main-menu-level1'
}).appendTo($panel[0]);
$mainMenuButton.setLabel('百度脑图');
$mainMenuButton.appendTo(document.getElementById('panel'));
$mainMenuButton.on('click', function(e) {
function show() {
$panel.addClass('show');
});
ret.fire('show');
}
$panel = $('<div id="main-menu"></div>').appendTo('#content-wrapper');
function hide() {
$panel.removeClass('show');
ret.fire('hide');
}
function toggle() {
($panel.hasClass('show') ? hide : show)();
}
function createSub(name, asDefault) {
var $sub = $menutab.generate($tabs, name, asDefault);
var $h2 = $('<h2></h2>')
.text(minder.getLang('ui.menu.' + name + 'header'))
.appendTo($sub);
return $sub;
}
function createSubMenu(name, asDefault) {
var $sub = createSub(name, asDefault);
var $subtabs = new FUI.Tabs().appendTo($sub);
return {
$tabs: $subtabs,
createSub: function(subname, asDefault) {
return $menutab.generate($subtabs, subname, asDefault);
}
};
}
$button.on('click', toggle);
$(window).keydown(function(e) {
// ESC Pressed
if (e.keyCode == 27) {
$panel.toggleClass('show');
}
if (e.keyCode == 27) toggle();
});
return $panel.addClass('show');
// expose
ret.show = show;
ret.hide = hide;
ret.toggle = toggle;
ret.createSub = createSub;
ret.createSubMenu = createSubMenu;
ret.$panel = $panel;
ret.$button = $button;
ret.$tabs = $tabs;
show();
return ret;
});
\ No newline at end of file
......@@ -10,14 +10,10 @@
KityMinder.registerUI('menu/new/new', function(minder) {
var $menu = minder.getUI('menu/menu');
var $level1 = minder.getUI('menu/level1');
var eve = minder.getUI('eve');
var $doc = minder.getUI('doc');
var ret = minder.getUI('eve').setup({});
var $panel = $level1['new'].getContentElement();
var $h2 = $('<h2></h2>')
.text(minder.getLang('ui.menu.new.header'))
.appendTo($panel);
var $panel = $menu.createSub('new');
// 模板列表容器
var $ul = $('<ul></ul>')
......@@ -40,20 +36,18 @@ KityMinder.registerUI('menu/new/new', function(minder) {
$ul.delegate('.template-item', 'click', function(e) {
var template = $(e.target).data('template');
minder.importData({
$doc.load({
content: {
template: template,
version: KityMinder.version,
data: {
text: minder.getLang('template')[template]
}
},
protocol: null
});
minder.execCommand('camera', minder.getRoot());
$menu.removeClass('show');
$menu.hide();
});
var ret = {};
eve.setup(ret);
return ret;
});
\ No newline at end of file
......@@ -8,9 +8,137 @@
*/
KityMinder.registerUI('menu/open/draft', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $panel = $($open.draft.getContentElement()).addClass('draft-file-list');
var drafts = minder.getUI('widget/locallist').use('draft');
var $loader = minder.getUI('widget/fileloader');
$panel.append('<h2>草稿箱</h2>');
var frdTime = minder.getUI('widget/friendlytimespan');
var $doc = minder.getUI('doc');
// 旧数据迁移
if (localStorage.drafts) {
var oldDrafts = JSON.parse(localStorage.drafts);
var list = oldDrafts.map(function(draft) {
var ret = {};
ret.json = draft.data;
ret.time = +new Date(draft.update);
ret.title = JSON.parse(draft.data).data.text;
return ret;
});
delete localStorage.drafts;
localStorage.draft = JSON.stringify(list);
}
var draftList = minder.getUI('widget/locallist').use('draft');
/* 网盘面板 */
var $panel = $($open.createSub('draft')).addClass('draft-panel');
/* 标题 */
var $title = $('<h2></h2>')
.text(minder.getLang('ui.menu.open.draft'))
.appendTo($panel);
var $clear = $('<button></button>')
.addClass('clear-draft')
.text(minder.getLang('ui.cleardraft'))
.appendTo($panel);
/* 最近文件列表容器 */
var $ul = $('<ul></ul>')
.addClass('draft-list')
.appendTo($panel);
var current = null,
lastDoc = null;
$ul.delegate('.draft-list-item', 'click', function(e) {
var item = $(e.target).closest('.draft-list-item').data('item');
var index = draftList.findIndex(function(finding) {
return finding == item;
});
if (index > -1) {
current = item;
draftList.remove(index);
draftList.unshift(current);
lastDoc = {
title: current.title,
protocol: 'json',
content: current.json,
path: current.path,
source: current.source,
saved: false
};
$doc.load(lastDoc);
}
$menu.hide();
});
$clear.on('click', function() {
if (!window.confirm(minder.getLang('ui.cleardraftconfirm'))) return;
draftList.clear();
current = null;
renderList();
});
$doc.on('docsave', popDraft);
$doc.on('docchange', pushDraft);
renderList();
function pushDraft(doc) {
if (doc == lastDoc) {
if (current) {
draftList.remove(0);
}
} else {
current = null;
}
lastDoc = doc;
current = current || {};
current.json = JSON.stringify(minder.exportJson());
current.title = doc.title;
current.time = +new Date();
current.path = doc.path;
current.source = doc.source;
draftList.unshift(current);
renderList();
}
function popDraft() {
if (current) {
draftList.remove(0);
current = null;
}
renderList();
console.log('pop draft');
}
function renderList() {
$ul.empty();
draftList.forEach(function(item) {
var $li = $('<li></li>')
.addClass('draft-list-item')
.data('item', item)
.appendTo($ul);
$('<h4></h4>')
.addClass('draft-title')
.text(item.title)
.appendTo($li);
$('<span></span>')
.addClass('file-time')
.displayFriendlyTime(item.time)
.appendTo($li);
});
}
});
\ No newline at end of file
......@@ -11,51 +11,27 @@ KityMinder.registerUI('menu/open/local', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $loader = minder.getUI('widget/fileloader');
var $doc = minder.getUI('doc');
// 支持的文件类型
var supportedExtensions = [];
/* extension => protocol */
var supports = {};
var accepts = [];
Utils.each(minder.getSupportedProtocols(), function(name, protocol) {
if (protocol && protocol.decode) {
supportedExtensions.push(protocol.fileExtension);
minder.getSupportedProtocols().forEach(function(protocol) {
if (protocol.decode) {
supports[protocol.fileExtension] = protocol;
accepts.push(protocol.fileExtension);
}
});
supportedExtensions = supportedExtensions.join(', ');
function readFile(domfile) {
return new Promise(function(resolve, reject) {
var file = new fio.file.File(domfile.name);
var protocol = minder.getProtocol($loader.support(file));
var reader;
if (protocol.dataType == 'blob') {
file.data = new fio.file.Data(domfile);
resolve(file);
} else {
reader = new FileReader();
reader.onload = function() {
file.data = new fio.file.Data(this.result);
resolve(file);
};
reader.readAsText(domfile, 'utf-8');
}
});
}
/* 网盘面板 */
var $panel = $($open.local.getContentElement()).addClass('local-file-open-panel');
var $panel = $($open.createSub('local')).addClass('local-file-open-panel');
/* 路径导航 */
var $nav = $('<h2>本地文件</h2>')
/* 标题 */
$('<h2>本地文件</h2>')
.appendTo($panel);
/* 选择文件 */
var $pick = $('<div class="pick-file"></div>')
.appendTo($panel);
......@@ -64,19 +40,26 @@ KityMinder.registerUI('menu/open/local', function(minder) {
.appendTo($pick);
$('<span></span>')
.text(minder.getLang('ui.acceptfile', supportedExtensions))
.appendTo($pick);
.text(minder.getLang('ui.acceptfile', accepts.map(function(ext) {
var protocol = supports[ext];
return protocol.fileDescription + '(' + ext + ')';
}).join(', '))).appendTo($pick);
/* 拖放提示 */
var $drop = $('<div class="drop-file"></div>')
.append($('<span></span>').html(minder.getLang('ui.dropfile')))
.appendTo($panel);
/* 交互事件 */
$pickButton.click(function() {
var $file = $('<input type="file" />')
.attr('accept', supportedExtensions)
$('<input type="file" />')
.attr('accept', accepts.join())
.on('change', function(e) {
readFile(this.files[0]).then($loader.load);
$menu.removeClass('show');
read(this.files[0]);
$menu.hide();
}).click();
});
......@@ -85,9 +68,62 @@ KityMinder.registerUI('menu/open/local', function(minder) {
e.stopPropagation();
}).on('drop', function(e) {
e = e.originalEvent;
var file = e.dataTransfer.files[0];
readFile(file).then($loader.load);
$menu.removeClass('show');
read(e.dataTransfer.files[0]);
$menu.hide();
e.preventDefault();
});
function read(domfile) {
if (!domfile) return;
var info = new fio.file.anlysisPath(domfile.name);
var protocol = supports[info.extension];
var dataPromise = new Promise(function(resolve, reject) {
var reader;
if (protocol.dataType == 'blob') {
resolve(new fio.file.Data(domfile));
} else {
reader = new FileReader();
reader.onload = function() {
resolve(new fio.file.Data(this.result));
};
reader.onerror = reject;
reader.readAsText(domfile, 'utf-8');
}
});
$(minder.getRenderTarget()).addClass('loading');
return dataPromise.then(function(data) {
var doc = {
content: data.content,
protocol: protocol.name,
title: info.filename,
source: 'local'
};
return $doc.load(doc);
})['catch'](function(error) {
window.alert(minder.getLang('ui.errorloading', error.message || minder.getLang('ui.unknownreason')));
}).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
});
}
return {
read: read
};
});
\ No newline at end of file
......@@ -11,38 +11,73 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $loader = minder.getUI('widget/fileloader');
var $netdiskfinder = minder.getUI('widget/netdiskfinder');
var $eve = minder.getUI('eve');
var $doc = minder.getUI('doc');
var ret = $eve.setup({});
/* 网盘面板 */
var $panel = $($open.netdisk.getContentElement());
var $panel = $($open.createSub('netdisk'));
/* extension => protocol */
var supports = {};
minder.getSupportedProtocols().forEach(function(protocol) {
if (protocol.decode) {
supports[protocol.fileExtension] = protocol;
}
});
/* Finder */
var $finder = $netdiskfinder.generate($panel, function(file) {
return $loader.support(file);
return supports[file.extension];
});
$finder.on('fileclick', openFile);
$finder.on('fileclick', function(file) {
return open(file.path);
});
function openFile(file) {
var protocol = $loader.support(file);
function open(path) {
$menu.removeClass('show');
$menu.hide();
$(minder.getRenderTarget()).addClass('loading');
return $loader.load(fio.file.read({
path: file.path,
var info = fio.file.anlysisPath(path);
var protocol = supports[info.extension];
return fio.file.read({
path: path,
dataType: protocol.dataType
})).then(function(readed) {
if (readed) ret.fire('fileload', readed);
}).then(function(file) {
var doc = {
protocol: supports[file.extension].name,
content: file.data.content,
title: file.filename,
source: 'netdisk',
path: file.path,
saved: true
};
return $doc.load(doc);
})['catch'](function(error) {
window.alert(minder.getLang('ui.errorloading', error.message || minder.getLang('unknownreason')));
}).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
});
}
ret.loadFileByPath = function(path) {
var file = new fio.file.File(path);
return openFile(file);
};
ret.open = open;
return ret;
});
\ No newline at end of file
......@@ -6,46 +6,6 @@
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/open/open', function(minder) {
var $level1 = minder.getUI('menu/level1');
var eve = minder.getUI('eve');
var $h2 = $('<h2></h2>')
.text(minder.getLang('ui.menu.open.header'))
.appendTo($level1.open.getContentElement());
var source = ['recent', 'netdisk', 'local', 'draft'];
var $tabs = new FUI.Tabs({
buttons: source.map(function(key) {
return {
label: minder.getLang('ui.menu.open.' + key),
className: key
};
})
}).appendTo($level1.open);
// 暴露
var ret = {};
// 暴露每个面板
source.forEach(function(key, index) {
ret[key] = $tabs.getPanel(index);
});
// 支持事件
eve.setup(ret);
// 暴露打开菜单(选项卡)选择事件
$tabs.on('tabsselect', function(e, info) {
ret.fire('select', info);
});
// 暴露选择事件
ret.select = $tabs.select.bind($tabs);
return ret;
return minder.getUI('menu/menu').createSubMenu('open', true);
});
\ No newline at end of file
......@@ -13,14 +13,24 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
var $open = minder.getUI('menu/open/open');
var $loader = minder.getUI('widget/fileloader');
var frdTime = minder.getUI('widget/friendlytimespan');
var netdisk = minder.getUI('menu/open/netdisk');
var doc = minder.getUI('doc');
var recentList = minder.getUI('widget/locallist').use('recent');
/* 网盘面板 */
var $panel = $($open.recent.getContentElement()).addClass('recent-file-panel');
var $panel = $($open.createSub('recent', true)).addClass('recent-file-panel');
minder.on('uiready', function() {
minder.getUI('topbar/user').requireLogin($panel);
});
/* 路径导航 */
var $nav = $('<h2>最近使用</h2>')
/* 标题 */
var $title = $('<h2></h2>')
.text(minder.getLang('ui.recent'))
.appendTo($panel);
var $clear = $('<button></button>')
.addClass('clear-recent-list')
.text(minder.getLang('ui.clearrecent'))
.appendTo($panel);
/* 最近文件列表容器 */
......@@ -28,10 +38,50 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
.addClass('recent-file-list')
.appendTo($panel);
$ul.delegate('.recent-file-item', 'click', function(e) {
var netdisk = minder.getUI('menu/open/netdisk');
var path = $(e.target)
.closest('.recent-file-item')
.data('path');
netdisk.open(path);
});
$clear.on('click', function() {
if (!window.confirm(minder.getLang('ui.clearrecentconfirm'))) return;
recentList.clear();
renderList();
});
doc.on('docload', addToList);
doc.on('docsave', addToList);
renderList();
function addToList(doc) {
if (doc.source != 'netdisk') return;
var exist = recentList.findIndex('path', doc.path);
if (~exist) {
recentList.remove(exist);
}
recentList.unshift({
path: doc.path,
filename: fio.file.anlysisPath(doc.path).filename,
title: minder.getMinderTitle(),
time: +new Date()
});
renderList();
}
function renderList() {
$ul.empty();
recentList.forEach(function(item) {
var $li = $('<li></li>')
......@@ -51,39 +101,9 @@ KityMinder.registerUI('menu/open/recent', function(minder) {
$('<span></span>')
.addClass('file-time')
.data('time', item.time)
.text(frdTime.display(item.time))
.displayFriendlyTime(item.time)
.appendTo($li);
});
}
$ul.delegate('.recent-file-item', 'click', function(e) {
var path = $(e.target)
.closest('.recent-file-item')
.data('path');
netdisk.loadFileByPath(path);
});
netdisk.on('fileload', function(loaded) {
var exist = recentList.findIndex('path', loaded.file.path);
if (~exist) {
recentList.remove(exist);
}
recentList.unshift({
path: loaded.file.path,
filename: loaded.file.filename,
title: loaded.json.data.text || minder.getLang('untitleddoc'),
time: +new Date()
});
renderList();
});
function updateTime() {
$ul.find('.file-time').each(function(index, element) {
$(element).text(frdTime.display($(element).data('time')));
});
}
setInterval(updateTime, 60000);
});
\ No newline at end of file
/**
* @fileOverview
*
*
* 导出数据到本地
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/save/download', function(minder) {
var $menu = minder.getUI('menu/menu');
var $save = minder.getUI('menu/save/save');
/* 导出面板 */
var $panel = $($save.createSub('download')).addClass('download-panel');
/* 标题 */
var $title = $('<h2></h2>')
.text(minder.getLang('ui.menu.save.download'))
.appendTo($panel);
var $list = $('<ul>')
.addClass('download-list')
.appendTo($panel);
var supports = [];
minder.getSupportedProtocols().forEach(function(protocol) {
if (protocol.encode) {
supports.push(protocol);
}
});
supports.forEach(function(protocol) {
$('<li>')
.addClass(protocol.name)
.text(protocol.fileDescription + ' (' + protocol.fileExtension + ')')
.data('protocol', protocol)
.appendTo($list);
});
$list.delegate('li', 'click', function(e) {
var protocol = $(e.target).data('protocol');
doExport(protocol);
});
function doExport(protocol) {
var filename = minder.getMinderTitle() + protocol.fileExtension;
var mineType = protocol.mineType || 'text/plain';
$panel.addClass('loading');
minder.exportData(protocol.name).then(function(data) {
if (typeof(data) != 'string') return;
switch (protocol.dataType) {
case 'text':
return doDownload(buildDataUrl(mineType), filename, 'text');
case 'base64':
return doDownload(data, filename, 'base64');
}
return null;
}).then(function() {
$panel.removeClass('loading');
$menu.hide();
});
}
function doDownload(url, filename, type) {
var content = url.split(',')[1];
var $form = $('<form></form>').attr({
'action': 'download.php',
'method': 'POST',
'accept-charset': 'utf-8'
});
var $content = $('<input />').attr({
name: 'content',
type: 'hidden',
value: decodeURIComponent(content)
}).appendTo($form);
var $type = $('<input />').attr({
name: 'type',
type: 'hidden',
value: type
}).appendTo($form);
var $filename = $('<input />').attr({
name: 'filename',
type: 'hidden',
value: filename
}).appendTo($form);
$('<input name="iehack" value="&#9760;" />').appendTo($form);
$form.appendTo('body').submit().remove();
}
function buildDataUrl(mineType, data) {
return 'data:' + mineType + '; utf-8,' + encodeURIComponent(data);
}
});
\ No newline at end of file
......@@ -11,19 +11,23 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
var $save = minder.getUI('menu/save/save');
var $netdiskfinder = minder.getUI('widget/netdiskfinder');
var $eve = minder.getUI('eve');
var $doc = minder.getUI('doc');
var ret = $eve.setup({});
var protocols = minder.getSupportedProtocols().filter(function(protocol) {
return protocol.encode;
/* extension => protocol */
var supports = {};
minder.getSupportedProtocols().forEach(function(protocol) {
if (protocol.encode && protocol.decode) {
supports[protocol.fileExtension] = protocol;
}
});
/* 网盘面板 */
var $panel = $($save.netdisk.getContentElement()).addClass('netdisk-save-panel');
var $panel = $($save.createSub('netdisk', true)).addClass('netdisk-save-panel');
var $finder = $netdiskfinder.generate($panel, function(file) {
return protocols.some(function(protocol) {
return protocol.fileExtension == file.extension;
}, false);
return supports[file.extension];
});
var $selects = $('<div class="netdisk-save-select"></div>')
......@@ -33,28 +37,133 @@ KityMinder.registerUI('menu/save/netdisk', function(minder) {
.text(minder.getLang('ui.saveas'))
.appendTo($selects);
/* 文件名 */
var $filename = $('<input>')
.attr('type', 'text')
.attr('placeholder', minder.getLang('ui.filename'))
.attr('title', minder.getLang('ui.filename'))
.on('keydown', function(e) {
if (e.keyCode == 27) $menu.toggleClass('show');
})
.appendTo($selects);
/* 文件格式 */
var $format = $('<select>')
.attr('title', minder.getLang('ui.fileformat'))
.appendTo($selects);
protocols.forEach(function(protocol) {
for (var ext in supports) {
var protocol = supports[ext];
if (!protocol.encode) return;
$('<option>')
.text(protocol.fileDescription + '(' + protocol.fileExtension + ')')
.val(protocol.name)
.val(ext)
.appendTo($format);
});
}
$format.val('json');
$format.val('.km');
/* 保存按钮 */
var $saveBtn = $('<button></button>')
.addClass('save-button')
.text(minder.getLang('ui.save'))
.click(save)
.appendTo($selects);
$menu.on('show', setFileName);
$finder.on('fileclick', function(file) {
$finder.select(file.path);
$filename.val(file.filename);
});
function save() {
var filename = $filename.val();
if (fio.file.anlysisPath(filename).extension != $format.val()) {
$filename.val(filename += $format.val())[0].select();
}
var path = $finder.pwd() + filename;
var doc = $doc.current();
var protocol = supports[$format.val()];
var exist = $finder.select(path); // 目标路径存在
var match = doc.path == path; // 目标路径正是当前文档
var duplicated = exist && !match;
if (!exist || match || duplicated && window.confirm(minder.getLang('ui.overrideconfirm', filename))) {
doSave(path, protocol, doc);
}
}
function doSave(path, protocol, doc) {
$panel.addClass('loading');
return minder.exportData(protocol.name).then(function(data) {
return fio.file.write({
path: path,
content: data,
ondup: fio.file.DUP_OVERWRITE
});
}).then(function() {
$panel.removeClass('loading');
$menu.hide();
doc.path = path;
doc.title = $filename.val();
doc.source = 'netdisk';
$doc.save(doc);
setTimeout($finder.list, 500);
})['catch'](function(e) {
window.alert('保存文件失败:' + (e.message || minder.getLang('ui.unknownreason')));
});
}
function setFileName() {
var doc = $doc.current();
switch (doc.source) {
case 'netdisk':
setFileNameForNetDiskSource(doc);
break;
default:
setFileNameForOtherSource(doc);
break;
}
$filename[0].select();
}
function setFileNameForNetDiskSource(doc) {
var path = doc.path;
var pathInfo = fio.file.anlysisPath(path);
// 选中当前文件
if ($finder.pwd() != pathInfo.parentPath) {
$finder.list(pathInfo.parentPath).then(function() {
$finder.select(path);
});
} else {
$finder.select(path);
}
$filename.val(pathInfo.filename);
}
function setFileNameForOtherSource(doc) {
$filename.val(doc.title);
$finder.select(null);
}
return ret;
});
\ No newline at end of file
......@@ -8,41 +8,5 @@
*/
KityMinder.registerUI('menu/save/save', function(minder) {
var $level1 = minder.getUI('menu/level1');
var eve = minder.getUI('eve');
var $h2 = $('<h2></h2>')
.text(minder.getLang('ui.menu.save.header'))
.appendTo($level1.save.getContentElement());
var source = ['netdisk', 'local'];
var $tabs = new FUI.Tabs({
buttons: source.map(function(key) {
return {
label: minder.getLang('ui.menu.save.' + key),
className: key
};
})
}).appendTo($level1.save);
// 暴露
var ret = eve.setup({});
// 暴露每个面板
source.forEach(function(key, index) {
ret[key] = $tabs.getPanel(index);
});
// 暴露保存菜单(选项卡)选择事件
$tabs.on('tabsselect', function(e, info) {
ret.fire('select', info);
});
// 暴露选择事件
ret.select = $tabs.select.bind($tabs);
return ret;
return minder.getUI('menu/menu').createSubMenu('save');
});
\ No newline at end of file
<form id="share-select">
<div id="shared-tip"></div>
<fieldset id="no-share">
<legend>
<label>
<input name="sharetype" type="radio" value="none" checked />
$lang.none_share
</label>
</legend>
<div class="share-description">
$lang.none_share_description
</div>
</fieldset>
<fieldset id="public-share">
<legend>
<label>
<input name="sharetype" type="radio" value="public"/>
$lang.public_share
</label>
</legend>
<div class="share-description">$lang.public_share_description</div>
<div class="share-body">
<h3>$lang.url_share</h3>
<p>
<input id="share-url" type="url" value="http://naotu.baidu.com/?shareId=kcev3dd" />
<button id="copy-share-url" data-clipboard-target="share-url" type="button">$lang.copy</button>
</p>
<h3>$lang.sns_share</h3>
<p id="share-platform" class="bdsharebuttonbox">
<a href="#" class="bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
<a href="#" class="bds_qzone" data-cmd="qzone" title="分享到QQ空间"></a>
<a href="#" class="bds_tqq" data-cmd="tqq" title="分享到腾讯微博"></a>
<a href="#" class="bds_renren" data-cmd="renren" title="分享到人人网"></a>
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p>
</div>
</fieldset>
<fieldset id="password-share" disabled>
<legend>
<label>
<input name="sharetype" type="radio" value="password" disabled />
$lang.password_share
</label>
</legend>
<div class="share-description">$lang.password_share_description</div>
<div class="share-body">$lang.ondev</div>
</fieldset>
<fieldset id="email-share" disabled>
<legend>
<label>
<input name="sharetype" type="radio" value="email" disabled />
$lang.email_share
</label>
</legend>
<div class="share-description">$lang.email_share_description</div>
<div class="share-body">$lang.ondev</div>
</fieldset>
</form>
\ No newline at end of file
/**
* @fileOverview
*
*
* 分享功能交互
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/share/share', function(minder) {
var $share_menu = minder.getUI('menu/menu').createSubMenu('share', true);
var $create_menu = $($share_menu.createSub('createshare', true));
var $manage_menu = $($share_menu.createSub('manageshare'));
var $doc = minder.getUI('doc');
var BACKEND_URL = 'http://127.0.0.1/naotu/mongo.php';
var currentShare = null;
var shareList = [];
var panelReady = renderCreatePanel();
panelReady.then(bindCreatePanelEvent);
fio.user.on('login', loadShareList);
fio.user.on('logout', clearShareList);
function renderCreatePanel() {
// render template
return $.pajax('ui/menu/share/create.html').then(function(html) {
/* global jhtmls: true */
var render = jhtmls.render(html);
$create_menu.html(render({
lang: minder.getLang('ui'),
minder: minder
}));
zeroCopy();
return $create_menu;
});
}
function bindCreatePanelEvent($panel) {
$panel.delegate('input[name=sharetype]', 'click', function(e) {
var actions = {
'none': removeShare,
'public': createPublicShare
};
actions[e.target.value]();
});
}
function removeShare() {
if (!currentShare) return;
if (currentShare) {
return $.pajax({
});
}
}
function uuid() {
var timeLead = 1e9;
return ((+new Date() * timeLead) + (Math.random() * --timeLead)).toString(36);
}
function createPublicShare(user) {
if (currentShare) return;
$create_menu.addClass('loading');
return fio.user.check().then(function(user) {
var record = {
shareMinder: {
id: uuid(),
data: JSON.stringify(minder.exportJson())
}
};
var currentDoc = $doc.current();
if (currentDoc.source == 'netdisk') {
record.path = currentDoc.path;
}
return $.pajax(BACKEND_URL, {
type: 'POST',
data: {
action: 'insert',
record: JSON.stringify(record),
ak: user && user.access_token
},
dataType: 'json'
}).then(function(result) {
if (result.error) {
throw new Error(result.error);
}
return result;
})['catch'](function(e) {
window.alert(minder.getLang('create_share_failed', e.message));
});
})
.then(function(shared) {
if (shared) {
currentShare = shared;
renderPublicShare(shared);
}
$create_menu.removeClass('loading');
});
}
function renderPublicShare(shared) {
var $sbody = $('#public-share .share-body', $create_menu);
var baseUrl = /^(.*?)(\?|\#|$)/.exec(window.location.href)[1];
var shareUrl = baseUrl + '?shareId=' + shared.shareMinder.id;
$('#share-url', $sbody).val(shareUrl)[0].select();
var shareConfig = window._bd_share_config.common,
resetShare = window._bd_share_main.init;
if (shareConfig && resetShare) {
shareConfig.bdTitle = shareConfig.bdText = minder.getMinderTitle();
shareConfig.bdDesc = shareConfig.bdText = minder.getLang('ui.sns_share_text', minder.getMinderTitle(), shareUrl);
shareConfig.bdUrl = shareUrl;
resetShare();
}
$sbody.show();
}
function loadShareList() {
var user = fio.user.current();
return $.pajax(BACKEND_URL, {
});
}
function clearShareList() {
shareList = [];
}
function shareRedirect() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if (match) {
window.location.href = 'viewshare.html?shareId=' + match[1];
}
}
function zeroCopy() {
/* global ZeroClipboard:true */
ZeroClipboard.setDefaults({ moviePath: 'lib/ZeroClipboard.swf' });
var $copy_url_btn = $('#copy-share-url', $create_menu);
if (window.ZeroClipboard) {
var clip = new window.ZeroClipboard($copy_url_btn, {
hoverClass: 'hover',
activeClass: 'active'
});
clip.on('dataRequested', function(client, args) {
$copy_url_btn.text(minder.getLang('ui.copied')).attr('disabled', 'disabled');
setTimeout(function() {
$copy_url_btn
.text(minder.getLang('ui.copy'))
.removeAttr('disabled');
}, 3000);
});
}
}
return $share_menu;
});
\ No newline at end of file
/**
* @fileOverview
*
* 查看分享文件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/share/view', function (minder) {
var $doc = minder.getUI('doc');
var $save = minder.getUI('menu/save');
var $download = minder.getUI('download');
function loadShareDoc(results) {
var user = results[0],
$panel = results[1];
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if (!match) return Promise.resolve(null);
var shareId = match[1];
function renderShareData(data) {
if (data.error) {
return window.alert(data.error);
}
var content = data.shareMinder.data;
return $doc.load({
source: 'share',
content: content,
protocol: 'json',
saved: false,
ownerId: data.uid,
ownerName: data.uname
}).then(function(doc) {
if (user) {
if (doc.ownerId == user.id) {
}
}
// 分享着不是当前用户
if (doc.ownerId && doc.ownerId != (user && user.id)) {
$('#shared-tip', $panel).text(minder.getLang('ui.shared_tip', doc.ownerName));
}
});
}
return $.pajax({
url: 'http://127.0.0.1/naotu/mongo.php', //'http://naotu.baidu.com/mongo.php',
data: {
action: 'find',
id: shareId
},
dataType: 'json'
}).then(renderShareData)['catch'](function(e) {
window.alert('请求分享文件失败,请重试!');
}).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
});
}
});
\ No newline at end of file
.download-panel {
h2 {
&:before {
content: ' ';
display: block;
width: 25px;
height: 25px;
position: absolute;
left: 0;
background: url(../images/icons.png) no-repeat 0 -595px;
}
}
& > .download-list {
margin: 0;
padding: 0;
list-style: none;
li {
font-size: 14px;
line-height: 20px;
padding: 10px 20px 10px 40px;
cursor: default;
position: relative;
margin: 0;
font-weight: normal;
height: 20px;
line-height: 20px;
&:hover {
background-color: lighten(@tab-hover, 55%);
}
&:active {
background-color: lighten(@tab-hover, 50%);
}
}
}
}
\ No newline at end of file
.draft-panel {
h2 {
&:before {
content: ' ';
display: block;
width: 25px;
height: 25px;
position: absolute;
left: 0;
background: url(../images/icons.png) no-repeat 0 -570px;
}
}
& > .clear-draft {
position: absolute;
right: 0;
top: 0;
}
& > .draft-list {
margin: 0;
padding: 0;
list-style: none;
&:empty:after {
content: '这是个空虚寂寞的草稿箱!';
display: block;
text-align: center;
font-size: 18px;
height: 50px;
line-height: 50px;
color: #CCC;
}
.draft-list-item {
font-size: 14px;
line-height: 20px;
padding: 10px 20px 10px 40px;
cursor: default;
position: relative;
&:hover {
background-color: lighten(@tab-hover, 55%);
}
&:active {
background-color: lighten(@tab-hover, 50%);
}
.draft-title {
margin: 0;
font-weight: normal;
height: 20px;
line-height: 20px;
&:after {
content: ' ';
display: block;
position: absolute;
width: 25px;
height: 25px;
background: url(../images/icons.png) no-repeat 0 -445px;
left: 5px;
top: 10px;
}
}
.file-time {
position: absolute;
right: 5px;
top: 10px;
font-size: 12px;
color: #999;
}
}
}
}
\ No newline at end of file
......@@ -25,53 +25,6 @@ html, body {
#kityminder {
.dock(@panel-height, 0, 0, 0);
-moz-user-select: none;
&.loading {
svg {
.blur;
}
&:after {
content: ' ';
display: block;
.dock;
background: rgba(128, 130, 140, .75);
}
&:before {
content: ' ';
width: 40px;
height: 40px;
border: 4px solid;
border-color: #fff transparent transparent;
box-shadow: 0 0 35px white;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
z-index: 10;
border-radius: 100%;
-webkit-animation: rotate 1.33s ease infinite;
}
}
}
@-webkit-keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@-moz-keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@-ms-keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
#panel {
......
......@@ -18,6 +18,9 @@
.button;
margin: 0 10px 10px 0;
}
span {
line-height: 30px;
}
}
.drop-file {
border: 2px dashed #eee;
......
......@@ -38,27 +38,28 @@
#main-menu {
@left-width: 200px;
background: white;
.dock;
overflow: hidden;
transform: scale(0);
transform: translate3d(0, -100%, 0);
transform-origin: 0 0;
opacity: 0;
transition: opacity .25s ease, transform .25s ease;
transition: opacity .2s ease, transform .2s ease;
z-index: 100;
&.show {
opacity: 1;
transform: scale(1);
transform: translate3d(0, 0, 0);
}
.slide-in() {
transform: translateX(-(@left-width)) translateZ(0);
transition: transform .5s ease;
transition: transform .7s ease, opacity .5s ease;
.show& {
transform: translateX(0) translateZ(0);
transition: transform .5s ease;
transition: transform .7s ease, opacity .5s ease;
}
}
......@@ -89,26 +90,36 @@
.main-menu-back-button {
.fui-label {
display: inline-block;
color: white;
margin-left: 10px;
font-size: 14px;
display: none;
}
.fui-icon {
display: block;
width: 25px;
height: 25px;
background: url(../images/icons.png) -1px -370px;
}
display: inline-block;
width: 25px;
height: 25px;
line-height: 25px;
border-radius: 100%;
border: 2px solid white;
left: 5px;
top: 5px;
cursor: pointer;
background: url(../images/icons.png) -1px -370px;
vertical-align: middle;
}
width: @left-width - 10px;
height: @panel-height - 10px;
padding: 5px;
&:hover {
background-color: rgba(255,255,255,.3);
background: -moz-linear-gradient(left, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, right top, color-stop(0%,rgba(255,255,255,0.3)), color-stop(100%,rgba(255,255,255,0))); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(left, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(left, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(left, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* IE10+ */
background: linear-gradient(to right, rgba(255,255,255,0.3) 0%,rgba(255,255,255,0) 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#4dffffff', endColorstr='#00ffffff',GradientType=1 ); /* IE6-9 */
}
&:active {
background-color: rgba(0,0,0,.05);
background: darken(@main-menu-theme-color, 10%);
}
}
}
......@@ -125,7 +136,7 @@
color: #999;
.slide-in;
}
&level-1 {
&level1 {
position: absolute;
left: 0;
right: 0;
......
......@@ -80,6 +80,13 @@
&:active {
background-color: lighten(@tab-hover, 50%);
}
&.selected {
background-color: lighten(@tab-active, 20%);
color: white;
&.file:before {
background-position: 0 -545px;
}
}
&.file {
position: relative;
&:before {
......@@ -127,41 +134,15 @@
top: 0;
}
.login-tip {
display: none;
text-align: center;
font-size: 16px;
color: #999;
margin-top: 30px;
a {
text-decoration: underline;
color: @main-menu-theme-color;
cursor: pointer;
&:hover {
color: lighten(@main-menu-theme-color, 10%);
}
}
}
&.require-login {
.login-tip {
display: block;
}
.netdisk-nav, .netdisk-file-list {
display: none;
}
}
}
// for save
.netdisk-save-panel .netdisk-file-list {
bottom: 60px;
bottom: 50px;
}
.netdisk-save-select {
.dock(auto, 0, 0, 0);
height: 30px;
height: auto;
padding: 10px;
border-top: 1px solid #EEE;
background: #fcfcfc;
......@@ -174,29 +155,22 @@
}
& > input {
width: 50%;
padding: 2px 5px;
height: 16px;
outline: none;
border: 1px solid lighten(@tab-hover, 30%);
margin: 0;
margin-top: 5px;
margin-right: 10px;
&:focus {
border-color: lighten(@tab-active, 40%);
}
vertical-align: middle;
}
& > select {
margin: 5px 0 0 10px;
margin: 5px 0 0 0;
outline: none;
vertical-align: middle;
}
& > .save-button {
position: absolute;
right: 10px;
top: 10px;
float: right;
width: 80px;
vertical-align: middle;
}
}
\ No newline at end of file
......@@ -30,3 +30,102 @@
bottom: @bottom;
left: @left;
}
.validate-error {
color: red;
border-color: red !important;
}
.button, button {
display: inline-block;
height: 30px;
padding: 0 15px;
line-height: 30px;
text-align: center;
outline: none;
background: lighten(@tab-active, 20%);
&:hover, &.hover {
background: lighten(@tab-hover, 20%);
}
&:active, &.active {
background: lighten(@tab-active, 15%);
}
&:disabled {
background: #CCC;
&:hover, &.hover,
&:active, &.active {
background: #CCC;
}
}
cursor: default;
color: @ui-fore;
border: none;
}
input[type=text],
input[type=url] {
padding: 2px 5px;
height: 16px;
outline: none;
border: 1px solid lighten(@tab-hover, 50%);
box-shadow: inset 0 1px 3px rgba(0,0,0,.05);
border-radius: 2px;
&:focus {
border-color: hsl(223, 38%, 55%);
}
}
.loading(@color: rgb(128, 130, 140), @border-color: #fff) {
.loading-target {
.blur;
}
&:after {
content: ' ';
display: block;
.dock;
background: fadeOut(@color, 25%);
}
&:before {
content: ' ';
width: 40px;
height: 40px;
border: 4px solid;
border-color: @border-color transparent transparent;
box-shadow: 0 0 35px white;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
z-index: 10;
border-radius: 100%;
-webkit-animation: rotate 1.33s ease infinite;
filter: none;
-webkit-filter: none;
}
}
.loading {
.loading();
}
@-webkit-keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@-moz-keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@-ms-keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
@keyframes rotate {
from { transform: rotate(0); }
to { transform: rotate(360deg); }
}
\ No newline at end of file
......@@ -12,11 +12,27 @@
}
}
& > .clear-recent-list {
position: absolute;
right: 0;
top: 0;
}
& > .recent-file-list {
margin: 0;
padding: 0;
list-style: none;
&:empty:after {
content: '没有最近打开文件!';
display: block;
text-align: center;
font-size: 18px;
height: 50px;
line-height: 50px;
color: #CCC;
}
.recent-file-item {
font-size: 14px;
line-height: 20px;
......
#share-dialog {
#share-select {
fieldset {
border: 1px solid #f0f0f0;
margin: 0;
margin-bottom: 10px;
padding: 10px;
legend {
font-size: 14px;
}
&:disabled {
opacity: 0.5;
}
.share-description {
}
.share-body {
margin-top: 10px;
}
}
}
#public-share {
p {
position: relative;
max-width: 500px;
input {
width: 100%;
box-sizing: border-box;
height: 24px;
margin: 0;
}
#copy-share-url {
position: absolute;
right: 0;
top: 0;
margin: 0;
height: 24px;
line-height: 24px;
border-radius: 2px;
}
}
.share-body {
display: none;
}
}
\ No newline at end of file
......@@ -2,6 +2,9 @@
float: right;
height: @panel-height;
line-height: @panel-height;
font-size: 14px;
color: @ui-fore;
vertical-align: baseline;
.fui-button {
......@@ -42,3 +45,28 @@
}
}
}
.login-tip {
display: none;
}
.login-required {
& > * {
display: none;
}
& > .login-tip {
display: block;
text-align: center;
font-size: 16px;
color: #999;
margin-top: 30px;
a {
text-decoration: underline;
color: @main-menu-theme-color;
cursor: pointer;
&:hover {
color: lighten(@main-menu-theme-color, 10%);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -15,6 +15,8 @@
@import "_recent";
@import "_netdisk";
@import "_localfile";
@import "_draft";
@import "_download";
@import "_priority_panel";
@import "_progress_panel";
......
ui/theme/default/images/icons.png

8.9 KB | W: | H:

ui/theme/default/images/icons.png

9.82 KB | W: | H:

ui/theme/default/images/icons.png
ui/theme/default/images/icons.png
ui/theme/default/images/icons.png
ui/theme/default/images/icons.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -44,9 +44,7 @@ KityMinder.registerUI('topbar/title', function(minder) {
setSaved: function(saved) {
if (saved !== false) {
_saved = true;
}
_saved = saved !== false;
update();
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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