Commit 6b099d49 authored by techird's avatar techird

Merge branch 'share-edit' into dev

parents cfa6c9a3 bb63d0b3
......@@ -8,6 +8,7 @@
"white": false,
"quotmark": false,
"browser": true,
"boss": true,
"predef" : [
"module",
"require",
......
......@@ -172,9 +172,10 @@
{ path: 'ui/menu/help/feedback.js', pack: 'edit|share'},
/* UI Top Bar */
{ path: 'ui/topbar/quickvisit.js', pack: 'edit' },
{ path: 'ui/topbar/quickvisit.js', pack: 'edit|share' },
{ path: 'ui/topbar/history.js', pack: 'edit' },
{ path: 'ui/topbar/user.js', pack: 'edit' },
{ path: 'ui/topbar/feedback.js', pack: 'edit|share' },
{ path: 'ui/topbar/search.js', pack: 'edit|share' },
{ path: 'ui/topbar/switch-view.js', pack: 'm-share' },
{ path: 'ui/topbar/m-logo.js', pack: 'm-share' },
......
......@@ -54,6 +54,8 @@ KityMinder.LANG['zh-cn'] = {
'err_create_share': '分享失败',
'err_mkdir': '目录创建失败',
'err_ls': '读取目录失败',
'err_share_data': '加载分享内容出错',
'err_share_sync_fail': '分享内容同步失败',
'unknownreason': '可能是外星人篡改了代码...',
'pcs_code': {
......@@ -126,6 +128,8 @@ KityMinder.LANG['zh-cn'] = {
}
},
'ui': {
'load_share_for_edit': '正在加载分享的文件...',
'share_sync_success': '分享内容已同步',
'error_detail': '详细信息',
'copy_and_feedback': '复制并反馈',
......@@ -157,7 +161,8 @@ KityMinder.LANG['zh-cn'] = {
'new': '新建 (Ctrl + Alt + N)',
'save': '保存 (Ctrl + S)',
'share': '分享 (Ctrl + Alt + S)',
'feedback': '反馈问题(F1)'
'feedback': '反馈问题(F1)',
'editshare': '编辑'
},
'menu': {
......@@ -212,7 +217,7 @@ KityMinder.LANG['zh-cn'] = {
'email_share': '邮件邀请',
'url_share': '脑图 URL 地址:',
'sns_share': '社交网络分享:',
'sns_share_text': '“{0}” - 我用「百度脑图」制作的思维导图,快看看吧!(地址:{1})',
'sns_share_text': '“{0}” - 我用百度脑图制作的思维导图,快看看吧!(地址:{1})',
'none_share_description': '不分享当前脑图',
'public_share_description': '创建任何人可见的分享',
'share_button_text': '创建',
......
......@@ -17,45 +17,59 @@ KityMinder.registerUI('menu/default', function(minder) {
var $share = minder.getUI('menu/share/share');
var $draft = minder.getUI('menu/open/draft');
// 主菜单默认选中「打开」
$menu.$tabs.select(1);
// 打开菜单默认选中「本地文件」
$open.$tabs.select(2);
if ($draft.hasDraft()) {
// 草稿箱有草稿,默认选中「草稿箱」,并打开最近编辑的文件
$open.$tabs.select(3);
$draft.openLast();
} else {
// 没有草稿,但用户登陆了
setMenuDefaults();
loadLandingFile();
// $menu.show();
// $menu.$tabs.select(5);
function setMenuDefaults() {
// 主菜单默认选中「打开」
$menu.$tabs.select(1);
// 打开菜单默认选中「本地文件」
$open.$tabs.select(2);
// 保存菜单默认选中「导出到本地」
$save.$tabs.select(1);
// 如果用户登陆了,选中「百度云存储」
fio.user.check().then(function(user) {
if (user) {
// 有最近文件选中「最近文件」
if ($recent.hasRecent()) {
$open.$tabs.select(0);
$recent.loadLast();
}
// 否则选中网盘目录
else {
$open.$tabs.select(1);
}
$save.$tabs.select(0);
}
});
$share.$menu.$tabs.select(0); // 当前脑图
}
// 保存菜单默认选中「导出到本地」
$save.$tabs.select(1);
function loadLandingFile() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
// 如果用户登陆了,选中「百度云存储」
fio.user.check().then(function(user) {
if (user) {
$save.$tabs.select(0);
if (match) {
$share.loadShareFile();
}
});
$share.$tabs.select(0); // 当前脑图
// $menu.show();
// $menu.$tabs.select(5);
else if ($draft.hasDraft()) {
// 草稿箱有草稿,默认选中「草稿箱」,并打开最近编辑的文件
$open.$tabs.select(3);
$draft.openLast();
} else {
// 没有草稿,但用户登陆了
fio.user.check().then(function(user) {
if (user) {
// 有最近文件选中「最近文件」
if ($recent.hasRecent()) {
$open.$tabs.select(0);
$recent.loadLast();
}
// 否则选中网盘目录
else {
$open.$tabs.select(1);
}
}
});
}
}
});
});
\ No newline at end of file
......@@ -41,7 +41,7 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) {
return open(file.path);
});
function open(path) {
function open(path, errorHandler) {
$menu.hide();
......@@ -74,10 +74,10 @@ KityMinder.registerUI('menu/open/netdisk', function(minder) {
}
function error(e) {
return notice.error('err_load', e);
return errorHandler && errorHandler(e) || notice.error('err_load', e);
}
return read().then(load, error).then(function() {
return read().then(load)['catch'](error).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
......
......@@ -129,7 +129,7 @@ KityMinder.registerUI('menu/save/download', function(minder) {
netdisk.mute = true;
setTimeout(function() {
netdisk.mute = false;
});
}, 1000);
}
$form.appendTo('body').submit().remove();
......
......@@ -12,6 +12,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
var $create_menu = $($share_menu.createSub('createshare'));
var $manage_menu = $($share_menu.createSub('manageshare'));
var $doc = minder.getUI('doc');
var notice = minder.getUI('widget/notice');
var BACKEND_URL = 'http://naotu.baidu.com/share.php';
......@@ -20,7 +21,11 @@ KityMinder.registerUI('menu/share/share', function(minder) {
renderCreatePanel().then(bindCreatePanelEvent);
renderManagePanel();
var shareListLoaded = loadShareList().then(bindManageActions);
var shareListLoaded = loadShareList();
shareListLoaded.then(renderShareList);
shareListLoaded.then(bindManageActions);
minder.on('uiready', function() {
minder.getUI('topbar/user').requireLogin($manage_menu);
......@@ -52,11 +57,94 @@ KityMinder.registerUI('menu/share/share', function(minder) {
id: shared.id || shared.shareMinder.id,
record: doc.json
}
}).then(function() {
notice.info(minder.getLang('ui.share_sync_success', doc.title));
})['catch'](function(e) {
notice.error('err_share_sync_failed', e);
});
});
}
});
function loadShareFile() {
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];
$(minder.getRenderTarget()).addClass('loading');
shareListLoaded.then(function(list) {
for (var i = 0; i < list.length; i++) {
var id = list[i].id || list[i].shareMinder.id;
if (id == shareId && list[i].path) {
return loadOriginFile(list[i]);
}
}
return loadShare(shareId);
});
}
function loadOriginFile(share) {
var $netdisk = minder.getUI('menu/open/netdisk');
notice.info(minder.getLang('ui.load_share_for_edit', share.title));
return $netdisk.open(share.path, function() {
// 网盘加载失败
return loadShare(share);
});
}
function loadShare(shareId) {
function renderShareData(data) {
if (data.error) {
notice.error('err_share_data', data.error);
return;
}
var content = data.shareMinder.data;
return $doc.load({
source: 'share',
content: content,
protocol: 'json',
saved: true,
ownerId: data.uid,
ownerName: data.uname
});
}
var $container = $(minder.getRenderTarget()).addClass('loading');
return $.pajax({
url: 'http://naotu.baidu.com/share.php',
data: {
action: 'find',
id: shareId
},
dataType: 'json'
}).then(renderShareData)['catch'](function(e) {
notice.error('err_share_data', e);
}).then(function() {
$container.removeClass('loading');
});
}
function getShareByPath(path) {
if (!path || !shareList) return null;
......@@ -151,9 +239,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
return;
case $target.hasClass('edit-action'):
var $netdisk = minder.getUI('menu/open/netdisk');
$netdisk.open(share.path);
loadOriginFile(share);
return;
}
});
......@@ -316,7 +402,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
return fio.user.check().then(function(user) {
if (!user) return;
$.pajax(BACKEND_URL, {
return $.pajax(BACKEND_URL, {
type: 'GET',
......@@ -331,7 +417,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
return (shareList = result.list || []);
}).then(renderShareList);
});
});
}
......@@ -431,5 +517,8 @@ KityMinder.registerUI('menu/share/share', function(minder) {
}
}
return $share_menu;
return {
$menu: $share_menu,
loadShareFile: loadShareFile
};
});
\ No newline at end of file
......@@ -10,10 +10,25 @@ KityMinder.registerUI('menu/share/view', function (minder) {
var $menu = minder.getUI('menu/menu');
var $save = minder.getUI('menu/save/save');
var $doc = minder.getUI('doc');
var notice = minder.getUI('widget/notice');
var shareId;
$menu.$tabs.select(0);
$save.$tabs.select(0);
minder.on('uiready', function() {
var $quickvisit = minder.getUI('topbar/quickvisit');
var $edit = $quickvisit.add('editshare', 'right');
$edit.on('click', function() {
if (shareId) window.open('edit.html?shareId=' + shareId);
});
$quickvisit.$new.remove();
$quickvisit.$save.remove();
$quickvisit.$share.remove();
});
function loadShareDoc() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
......@@ -21,14 +36,12 @@ KityMinder.registerUI('menu/share/view', function (minder) {
if (!match) return Promise.resolve(null);
var shareId = match[1];
shareId = match[1];
function renderShareData(data) {
if (data.error) {
window.alert(data.error);
window.location.href = 'index.html';
return;
return notice.error('err_share_data', data.error);
}
var content = data.shareMinder.data;
......@@ -44,7 +57,7 @@ KityMinder.registerUI('menu/share/view', function (minder) {
}).then(function(doc) {
var $title = minder.getUI('topbar/title');
$title.setTitle('[分享的] ' + $title.getTitle());
$title.setTitle('[分享的] ' + $title.getTitle() + ' (只读)');
});
}
......@@ -52,7 +65,7 @@ KityMinder.registerUI('menu/share/view', function (minder) {
return $.pajax({
url: 'http://naotu.baidu.com/share.php', //'http://naotu.baidu.com/mongo.php',
url: 'http://naotu.baidu.com/share.php',
data: {
action: 'find',
......@@ -63,14 +76,14 @@ KityMinder.registerUI('menu/share/view', function (minder) {
}).then(renderShareData)['catch'](function(e) {
window.alert('请求分享文件失败,请重试!');
notice.error('err_share_data', e);
}).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
minder.disable();
minder.execCommand('hand', true);
$container.removeClass('loading');
});
}
......
......@@ -51,6 +51,16 @@
}
}
&.editshare {
margin-right: 5px;
float: right;
&:after {
top: 6.5px;
left: 7px;
background-position: 0 -1060px;
}
}
&:hover {
background-color: @tab-hover;
}
......
......@@ -55,12 +55,18 @@
height: 30px;
}
}
&.login-button .fui-icon {
width: 25px;
height: 25px;
margin-right: 3px;
vertical-align: baseline;
background: url(../images/icons.png) 0 -320px;
&.login-button {
.fui-icon {
border-radius: 100%;
width: 25px;
height: 25px;
margin-right: 3px;
vertical-align: baseline;
background: url(../images/icons.png) 0 -320px;
}
.fui-label {
display: none;
}
}
}
}
......
......@@ -1973,6 +1973,15 @@ body {
left: 7px;
background-position: 0 -970px;
}
#panel .quick-visit-button.editshare {
margin-right: 5px;
float: right;
}
#panel .quick-visit-button.editshare:after {
top: 6.5px;
left: 7px;
background-position: 0 -1060px;
}
#panel .quick-visit-button:hover {
background-color: #5a6378;
}
......@@ -2240,12 +2249,16 @@ body {
height: 30px;
}
#panel div.user-panel .fui-button.login-button .fui-icon {
border-radius: 100%;
width: 25px;
height: 25px;
margin-right: 3px;
vertical-align: baseline;
background: url(../images/icons.png) 0 -320px;
}
#panel div.user-panel .fui-button.login-button .fui-label {
display: none;
}
.login-tip {
display: none;
}
......
This diff is collapsed.
ui/theme/default/images/icons.png

19.2 KB | W: | H:

ui/theme/default/images/icons.png

19.9 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
/**
* @fileOverview
*
* 快速反馈按钮
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/feedback', function(minder) {
var $quickvisit = minder.getUI('topbar/quickvisit');
var $feedback = $quickvisit.add('feedback', 'right');
function quickFeedback() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(5);
$menu.show();
}
$feedback.click(quickFeedback);
minder.addShortcut('f1', quickFeedback);
return $feedback;
});
\ No newline at end of file
......@@ -8,24 +8,33 @@
*/
KityMinder.registerUI('topbar/quickvisit', function (minder) {
function btn(name) {
return $('<a class="quick-visit-button"></a>')
var rightDocks = [];
function btn(name, dockRight) {
var $btn = $('<a class="quick-visit-button"></a>')
.text(minder.getLang('ui.quickvisit.' + name))
.attr('title', minder.getLang('ui.quickvisit.' + name))
.addClass(name)
.appendTo('#panel');
.addClass(name);
if (dockRight) rightDocks.push($btn);
else $btn.appendTo('#panel');
return $btn;
}
var $new = btn('new'),
$save = btn('save'),
$share = btn('share'),
$feedback = btn('feedback');
$share = btn('share');
var ret = {};
var ret = {
$new: $new,
$save: $save,
$share: $share
};
minder.on('uiready', function quickVisit() {
$('#panel #search').after($feedback);
while (rightDocks.length) $('#panel #search').after(rightDocks.shift());
function quickNew() {
var $doc = minder.getUI('doc');
......@@ -52,16 +61,10 @@ KityMinder.registerUI('topbar/quickvisit', function (minder) {
$menu.show();
}
function quickFeedback() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(5);
$menu.show();
}
$new.click(quickNew);
$save.click(quickSave);
$share.click(quickShare);
$feedback.click(quickFeedback);
minder.addShortcut('ctrl+alt+n', quickNew);
minder.addShortcut('ctrl+s', quickSave);
......@@ -71,15 +74,15 @@ KityMinder.registerUI('topbar/quickvisit', function (minder) {
$menu.$tabs.select(2);
$menu.show();
});
minder.addShortcut('f1', quickFeedback);
ret.ready = true;
ret.quickNew = quickNew;
ret.quickSave = quickSave;
ret.quickShare = quickShare;
ret.quickFeedback = quickFeedback;
});
ret.add = btn;
return ret;
});
\ No newline at end of file
......@@ -101,7 +101,7 @@ KityMinder.registerUI('topbar/user', function(minder) {
fio.user.fire('login', user);
} else {
if (window.location.href.indexOf('nocheck') == -1) {
logout();
return login();
} else {
$loginButton.show();
}
......@@ -122,7 +122,7 @@ KityMinder.registerUI('topbar/user', function(minder) {
$loginButton.setLabel(minder.getLang('ui.loggingin'));
fio.user.login({
remember: 7 * 24 * 60 * 60 // remember 7 days
}).then(check);
});
}
function switchUser() {
......
......@@ -58,11 +58,11 @@
return this._ui[id];
}
});
$.ajaxSetup({ cache: false });
$.extend($, {
pajax: function(opt) {
opt.cache = false;
return Promise.resolve($.ajax(opt));
pajax: function() {
return Promise.resolve($.ajax.apply($, arguments));
}
});
......
......@@ -25,6 +25,10 @@ KityMinder.registerUI('widget/notice', function (minder) {
className: 'error-dialog'
}).appendTo(document.getElementById('content-wrapper'));
$error.on('ok cancel', function(e) {
if (error.resolve) error.resolve(e);
});
var $error_body = $($error.getBodyElement());
var isBuilded = (function() {
......@@ -136,7 +140,7 @@ KityMinder.registerUI('widget/notice', function (minder) {
if (e.getDetail) return e;
// 文件访问错误
if (e instanceof fio.FileRequestError) {
if (typeof(fio) != 'undefined' && (e instanceof fio.FileRequestError)) {
if (!e.status) {
e.description = errorMessage.err_network;
} else {
......@@ -205,6 +209,10 @@ KityMinder.registerUI('widget/notice', function (minder) {
$error.show();
$error.getElement().style.top = '180px';
return new Promise(function(resolve) {
error.resolve = resolve;
});
}
......
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