Commit 5b53c051 authored by techird's avatar techird

remove ui

parent 44149c53
/**
* @fileOverview
*
*
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('contextmenu', function(minder) {
var mac = kity.Browser.mac;
function camel(word) {
return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase();
}
var $menu = $('<ul>')
.addClass('km-context-menu fui-popup-menu')
.appendTo('#content-wrapper');
var downPosition;
function distance(p1, p2) {
var dx = p1[0] - p2[0];
var dy = p1[1] - p2[1];
var ds = Math.sqrt(dx * dx + dy * dy);
return ds;
}
$menu.delegate('li', 'mousedown', function(e, info) {
var item = $(e.target).closest('li').data('menu');
if (item.command) {
minder.execCommand(item.command);
}
});
$('#content-wrapper').on('contextmenu', function(e) {
e.preventDefault();
});
$('#content-wrapper').on('mousedown', function(e) {
$menu.hide();
if (e.button == 2) {
downPosition = [e.pageX, e.pageY];
} else {
downPosition = null;
}
});
minder.on('mouseup', function(e) {
//e.preventDefault();
if (!e.isRightMB()) return;
e = e.originEvent;
var d = distance(downPosition, [e.pageX, e.pageY]);
if (isNaN(d) || d > 5) return;
$menu.empty();
var ctxmenu = minder.getContextMenu();
var lastDivider = true;
ctxmenu.forEach(function(item) {
if (item.command && minder.queryCommandState(item.command) === 0) {
var label = minder.getLang('ui.command.' + item.command);
var $li = $('<li>')
.addClass('fui-item')
.data('menu', item)
.appendTo($menu);
var shortcuts = minder.getCommandShortcutKey(item.command);
if (shortcuts) {
shortcuts.split('|').forEach(function(shortcut) {
var $shortcut = $('<span>').addClass('shortcut').appendTo($li);
shortcut.split('+').forEach(function(key) {
var parts = key.split('::');
key = parts.length > 1 ? parts[1] : parts[0];
$('<span>').addClass('shortcut-key ' + key.toLowerCase())
.text(camel(key))
.appendTo($shortcut);
});
if (mac) $shortcut.addClass('mac');
});
}
$li.append($('<div>').text(label).addClass('menu-label'));
lastDivider = false;
}
if (item.divider && !lastDivider) {
$('<li>').addClass('divider').appendTo($menu);
lastDivider = true;
}
});
if (ctxmenu.length) {
$menu.show();
var x = e.pageX,
y = e.pageY,
width = $menu.outerWidth(),
height = $menu.outerHeight(),
clientWidth = document.body.clientWidth,
clientHeight = document.body.clientHeight;
if (x + width > clientWidth) x -= width;
if (y + height > clientHeight) y -= height;
$menu.offset({
left: x,
top: y
});
}
});
});
\ No newline at end of file
/**
* @fileOverview
*
* 当前文档管理
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('doc', function(minder) {
var ret = minder.getUI('eve').setup({});
var current = { saved: true };
var loading = false;
var notice = minder.getUI('widget/notice');
var finder = minder.getUI('widget/netdiskfinder');
if (finder) finder.on('mv', trackFileMove);
function trackFileMove(from, to) {
if (current.source != 'netdisk') return;
var fromPath = from.split('/');
var toPath = to.split('/');
function preCommonLength(a, b) {
var i = 0;
while((i in a) && (i in b) && a[i] == b[i]) i++;
return (i in b) ? 0 : i;
}
var originPath = current.path.split('/');
var clen = preCommonLength(originPath, fromPath);
if (clen) {
var movedPath = toPath.concat(originPath.slice(clen));
current.path = movedPath.join('/');
current.title = movedPath.pop();
ret.fire('docchange', current);
}
}
/**
* 加载文档
*
* @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);
ret.fire('docload', doc);
ret.fire('docchange', doc);
return doc;
})['catch'](function(e) {
current = restore;
notice.error('err_doc_resolve', e);
}).then(function(doc) {
loading = false;
if (doc)
notice.info( minder.getLang('ui.load_success', doc.title ) );
return doc;
});
}
function save(doc) {
current = doc;
doc.data = minder.exportJson();
doc.json = JSON.stringify(doc.data);
doc.saved = true;
ret.fire('docsave', doc);
ret.fire('docchange', doc);
}
function getCurrent() {
return current;
}
function checkSaved(noConfirm) {
if (!fio.user.current()) return true;
if (noConfirm) return current.saved;
return current.saved || window.confirm(minder.getLang('ui.unsavedcontent', '* ' + current.title));
}
/* 绕开初始化时候的乱事件 */
setTimeout(function() {
minder.on('contentchange', function() {
if (loading) return;
if (current.source != 'netdisk') {
current.title = minder.getMinderTitle();
current.saved = false;
} else {
current.saved = current.json == JSON.stringify(minder.exportJson());
}
ret.fire('docchange', current);
});
}, 1000);
ret.load = load;
ret.save = save;
ret.current = getCurrent;
ret.checkSaved = checkSaved;
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 简版事件解耦功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('eve', function(minder) {
return {
setup: function(obj) {
var callbacks = {};
obj.on = function on(name, callback) {
var list = callbacks[name] || (callbacks[name] = []);
list.push(callback);
return this;
};
obj.off = function off(name, callback) {
var list = callbacks[name];
if (list) {
var index = list.indexOf(callback);
if (~index) {
list.splice(index, 1);
} else {
callback[name] = null;
}
}
return this;
};
obj.once = function once(name, callback) {
return this.on(name, function wrapped() {
callback.apply(obj, arguments);
obj.off(name, wrapped);
});
};
obj.fire = function fire(name) {
var list = callbacks[name];
var args = [].slice.call(arguments, 1);
if (list) list.forEach(function(callback) {
callback.apply(obj, args);
});
return this;
};
return obj;
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 拓展 fio 的能力
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
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
*
* 拓展 FUI 组件的功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
kity.extendClass(FUI.Widget, {
setEnable: function(value) {
if (value === false) this.disable();
else this.enable();
},
setActive: function(value) {
if (value === false) this.removeClass('active');
else this.addClass('active');
},
bindExecution: function(event, fn) {
var widget = this;
widget.on(event, function() {
if (widget.interactFlag) return;
fn.apply(widget, arguments);
});
},
bindCommandState: function(minder, command, valueHandle) {
var widget = this;
minder.on('interactchange', function() {
widget.interactFlag = true;
if (valueHandle) {
var value = this.queryCommandValue(command);
if (value != widget.lastHandleCommandValue) {
valueHandle.call(widget, value);
widget.lastHandleCommandValue = value;
}
}
widget.setEnable(this.queryCommandState(command) !== -1);
widget.setActive(this.queryCommandState(command) === 1);
widget.interactFlag = false;
});
}
});
\ No newline at end of file
/**
* @fileOverview
*
* UI 状态记忆
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('memory', function () {
var ls = window.localStorage;
var memory = ls.uiMemory ? JSON.parse(ls.uiMemory) : {};
return {
get: function(item) {
return memory[item] || null;
},
set: function(item, value) {
memory[item] = value;
ls.uiMemory = JSON.stringify(memory);
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 菜单默认选择项目
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/default', function(minder) {
minder.on('uiready', function() {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $recent = minder.getUI('menu/open/recent');
var $save = minder.getUI('menu/save/save');
var $share = minder.getUI('menu/share/share');
var $draft = minder.getUI('menu/open/draft');
setMenuDefaults();
// $menu.show();
// $menu.$tabs.select(1);
// $open.$tabs.select(1);
// return;
loadLandingFile();
function setMenuDefaults() {
// 主菜单默认选中「打开」
$menu.$tabs.select(1);
// 打开菜单默认选中「本地文件」
$open.$tabs.select(2);
// 保存菜单默认选中「导出到本地」
$save.$tabs.select(1);
// 如果用户登陆了,选中「百度云存储」
fio.user.check().then(function(user) {
if (user) {
$save.$tabs.select(0);
}
});
$share.$menu.$tabs.select(0); // 当前脑图
}
function loadLandingFile() {
var pattern = /(?:shareId|share_id)=(\w+)([&#]|$)/;
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if (match) {
return $share.loadShareFile();
}
// 检查登录状态
fio.user.check().then(function(user) {
var draft = $draft.last();
var recent = $recent.last();
// 登录
if (user) {
if (recent) {
if (draft) {
if (recent.time > draft.time) openRecent();
else openDraft();
} else {
openRecent();
}
} else {
if (draft) openDraft();
else $open.$tabs.select(1); // locale netdisk
}
} else {
if (draft) openDraft();
else $open.$tabs.select(2); // locale local
}
function openDraft() {
$open.$tabs.select(3);
$draft.openLast();
}
function openRecent() {
$open.$tabs.select(0);
$recent.loadLast();
}
});
}
});
});
\ No newline at end of file
/**
* @fileOverview
*
* 菜单头部
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/header', function(minder) {
var $menu = minder.getUI('menu/menu');
var $header = $('<div class="main-menu-header"></div>')
.prependTo($menu.$panel);
var $backPanel = $('<div class="main-menu-back-panel"></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', $menu.hide);
$menu.on('show', function() {
var $title = minder.getUI('topbar/title');
$titlePanel.text($title.getTitle());
});
return $header;
});
\ No newline at end of file
/**
* @fileOverview
*
* 帮助面板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/help/feedback', function (minder) {
var $menu = minder.getUI('menu/menu');
var $panel = $($menu.createSub('feedback'));
var $feedback = $('<div id="feedback-panel">')
.appendTo($panel)
.addClass('loading');
$.pajax({
url: 'static/pages/feedback.html',
dataType: 'text'
}).then(render);
function render(template) {
/* global jhtmls: true */
var renderer = jhtmls.render(template);
$feedback.html(renderer({
lang: minder.getLang('ui'),
minder: minder
}));
$feedback.on('click contextmenu keydown', function(e) {
e.stopPropagation();
});
$feedback.removeClass('loading');
$feedback.find('.km-version').text(KityMinder.version);
}
});
\ No newline at end of file
/**
* @fileOverview
*
* 帮助面板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/help/help', function (minder) {
var $menu = minder.getUI('menu/menu');
var $panel = $($menu.createSub('help'));
var $help = $('<div id="help-panel">')
.appendTo($panel)
.addClass('loading');
Promise.all([$.pajax({
url: 'static/pages/helpcontent.html',
dataType: 'text'
}), $.pajax({
url: 'static/pages/operation.' + minder.getOptions('lang') + '.txt',
dataType: 'text'
})])
.then(function(values) {
var template = values[0];
var operation = values[1];
render(template, operation);
});
function render(template, operation) {
/* global jhtmls: true */
var renderer = jhtmls.render(template);
$help.html(renderer({
lang: minder.getLang('ui'),
minder: minder
}));
$help.find('.shortcut-content').html(convert(operation));
if (kity.Browser.mac) {
$help.addClass('mac');
}
$help.removeClass('loading');
$help.find('.km-version').text(KityMinder.version);
// 彩蛋:点很多次按钮的蛋疼
/*9szjzrzdznztz6z1z28z1wzhzbz9z4z2mz23z27zcz1xz27z9z2lz38z17z0z0z0z0z0z0z0z0z0z0z0z23zfz20z8z26z27z9z2lz38z17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z1uz1uztztz1uz29z2nz3zsz5ztz2mzfz2nz2nzez7z1wzczhz2iz28zjzrzdznztz6z1z20z2lz2kz9z2lz38z17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z2cznzhz1z7zsz28z2azhzjz1zmz19z14zqz2mz2lz2pzczjz6zsziz1ez17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z2nz2eziz1ez17z0z0z0z0z0z0z0z0z0z0z0z2nz2nz1yz9zvzmz1yz2lz38z17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z1uz1uztztz1uz29z2nz3zsz5ztz2mzfz0zez7z1wzczhz2iz28zjzrzdznztz6z1z20z2lz2kz9z2lz38z17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z2cznzhz1z7zsz28z2dz2nz27zbz9zjz1ez19zbz1z11z1iz2mzozpziz1ez17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z2nz2eziz1ez17z0z0z0z0z0z0z0z0z0z0z0z2nz3ez17z0z0z0z0z0z0z0z0z0z0z0z2gznzjz2cz25zezsz2jztztzgz22z23z2z2zazrz17z17z0z0z0z0z0z0z0z0z0z0z0z2gznzjz2cz1vz1vztztz3iz6z2wz1ez17z0z0z0z0z0z0z0z0z0z0z0z2gznzjz2cz23z23ztztzgzbz1ez17z0z0z0z0z0z0z0z0z0z0z0z1vz26z2oz5z6zrz1tz23z1nz1fz1hz3kz3lz3lz25zezsz2aziz1ez17z0z0z0z0z0z0z0z0z0z0z0z2hzvz1z5z9z27z23z1nz37z0z1vz1hz3kz1zsz0ztz2fzrzaz1z3zfz7zbz1z27z9z1vz26z2oz5z6zrz1tz23z1nz1fz1hz3kz3lz3lz8z26z1xzvzvz1vz1mz1fz1xzsz33z3kzqzqz1uz1nz1fz1xzsz33z3bz0ziz1ez17z0z0z0z0z0z0z0z0z0z0z0z1wzcz1ztzsz3z9z25z1vz3z8z29z23z22ziz1ez17z0z0z0z0z0z0z0z0z0z0z0z1wzcz1ztzsz3z9z25z1vz3z8z29z24z25ziz1ez17z0z0z0z0z0z0z0z0z0z0z0z2cznzhz1z7zsz28z1xz1xzvzvz3az14z6zrz7z9z23z22zkztz2z1bz18z9zjz1ez19zbz1z25z29zhz0zszlz2bz20zrzpz0z1tzcz1vz25z9zqzqz1vz26z1wzczhz2iz28zjzrzdznztz6z1z20z26z27z9z2lz38z17z0z0z0z0z0z0z0z0z0z0z0z0z0z0z0z2cznzhz1z7zsz28z1xz24z2kzrz1pz14z6zrz7z9z29zrz6zsziz1ez17z0z0z0z0z0z0z0z0z0z0z0z2nz2ez7z1xz5z6z7z20zfz2nz2nzeziz1ez17z0z0z0z0z0z0z0z2n*/
function decrypt(a) {
a = a.split('z').map(function(s) {
return parseInt(s, 35);
});
var key = 0x131;
var b = [];
var i = 0;
b.push(a[i] ^ key);
while(a[++i] !== undefined) b.push(a[i] ^ b[i-1]);
return String.fromCharCode.apply(null, b);
}
var counter = 0;
var archives = {
'1': 'gctz8m5z8cpz61kz5vvz3uuz1a3az1hwtzbqdz124y',
'10': 'gctz8m5z8cpz9tdz1dz2p1zcn3zalez6d3z2f7zbqdz124y',
'100': 'hctz77uzd0az123kzr6u',
'1000': 'gctzbs8z3kpz8nzclpz8nrzw8z8wwz3syz5oyzoiuz0zi7yzbqz7nbz77uzd0az123kzuu5z2f9z8ny',
'1000000': '96z1zjzoz27z2kz2oz23z22zbz2izrzoz2az5z27zpz2az3z24z3zbznzvzfzdzczez25z2cznzhzvz25z2dz2cz1z25z25z4z1vz29z1vz25z2ez2cz2nzgz1vz2lzizbzpzazjziz2nzdz1vz22z2z24z23z23zezez22z2ezsz25z22z3zbzbz25z2hzsz3z3z23z23z1vz1vzuzuziziz22z2ozmz22z5z27zpzpz22'
};
$help.delegate('.shortcut-key', 'click', function() {
var msg = archives[++counter];
if (msg) {
window.alert(decrypt(msg));
if (counter > 1000000) console.log(msg);
}
});
}
function convert(markdown) {
var html = '';
var titleReg = /##\s(.+)$/;
var declareReg = /(.+?)\:\s(.+)$/;
var section = false;
markdown.split('\n').forEach(convertLine);
if (section) {
html += '</section>';
}
function convertLine(line) {
var match = titleReg.exec(line);
if (match) {
if (section) html += '</section>';
html += '<section><h3>' + match[1] + '</h3>';
section = true;
return;
}
match = declareReg.exec(line);
if (match) {
var declare = match[1];
var description = match[2];
html += '<div class="shortcut-group"><span class="shortcut">';
html += declare.replace(/\`(.+?)\`/g, function(match, key) {
return '<span class="shortcut-key ' + key.toLowerCase() + '" title="' + key + '">' + key + '</span>';
});
html += '</span>';
html += '<span class="description">' + description + '</span>';
html += '</div>';
return;
}
}
return html;
}
});
\ No newline at end of file
/**
* @fileOverview
*
* 主菜单控制
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/menu', function(minder) {
var ret = minder.getUI('eve').setup({});
var $menutab = minder.getUI('widget/menutab');
// 主菜单容器
var $panel = $('<div>')
.attr('id', 'main-menu')
.css('display', 'none')
.appendTo('#content-wrapper');
// 主菜单按钮
var $button = new FUI.Button({
id: 'main-menu-btn',
label: minder.getLang('ui.menu.mainmenutext')
}).appendTo(document.getElementById('panel'));
// 一级菜单选项卡
var $tabs = new FUI.Tabs({
className: 'main-menu-level1'
}).appendTo($panel[0]);
var timer;
function show() {
$panel.css('display', 'block');
clearTimeout(timer);
timer = setTimeout(function() {
$panel.addClass('show');
ret.fire('show');
});
}
function hide() {
ret.fire('hide');
$panel.removeClass('show');
minder.getRenderTarget().focus();
timer = setTimeout(function() {
$panel.css('display', 'none');
});
}
function isVisible() {
return $panel.hasClass('show');
}
function toggle() {
if ($('#content-wrapper').hasClass('fullscreen')) return;
(isVisible() ? 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);
minder.addShortcut('esc', toggle);
// expose
ret.show = show;
ret.hide = hide;
ret.toggle = toggle;
ret.isVisible = isVisible;
ret.createSub = createSub;
ret.createSubMenu = createSubMenu;
ret.$panel = $panel;
ret.$button = $button;
ret.$tabs = $tabs;
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 新建文件菜单
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/new/new', function(minder) {
var $menu = minder.getUI('menu/menu');
var $doc = minder.getUI('doc');
var ret = minder.getUI('eve').setup({});
var $panel = $menu.createSub('new');
// 模板列表容器
var $ul = $('<ul></ul>')
.addClass('new-file-template-select')
.appendTo($panel);
// 模板容器
var $li;
var templates = KityMinder.getTemplateList();
for (var name in templates) {
$li = $('<li></li>')
.addClass('template-item')
.addClass(name)
.data('template', name)
.append('<a>' + minder.getLang('template')[name] + '</a>')
.appendTo($ul);
}
$ul.delegate('.template-item', 'click', function(e) {
if (!$doc.checkSaved()) return;
var template = $(e.target).data('template');
$doc.load({
content: {
template: template,
version: KityMinder.version,
data: {
text: minder.getLang('template')[template]
}
},
protocol: null,
saved: true
});
$menu.hide();
});
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 草稿箱功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/open/draft', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $loader = minder.getUI('widget/fileloader');
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.draftheader'))
.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) {
if (!$doc.checkSaved()) return;
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.saved) return;
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();
}
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);
});
}
return {
hasDraft: function() {
return draftList.length;
},
openLast: function() {
$ul.find('.draft-list-item').eq(0).click();
},
last: function() {
return draftList.get(0) || null;
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 支持从本地打开文件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/open/local', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $doc = minder.getUI('doc');
var notice = minder.getUI('widget/notice');
/* extension => protocol */
var supports = {};
var accepts = [];
minder.getSupportedProtocols().forEach(function(protocol) {
if (protocol.decode) {
supports[protocol.fileExtension] = protocol;
accepts.push(protocol.fileExtension);
}
});
/* 网盘面板 */
var $panel = $($open.createSub('local')).addClass('local-file-open-panel');
/* 标题 */
$('<h2>本地文件</h2>')
.appendTo($panel);
/* 选择文件 */
var $pick = $('<div class="pick-file"></div>')
.appendTo($panel);
var $pickButton = $('<a></a>')
.text(minder.getLang('ui.pickfile'))
.appendTo($pick);
$('<span></span>')
.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() {
if (!$doc.checkSaved()) return;
$('<input type="file" />')
.attr('accept', accepts.join())
.on('change', function(e) {
read(this.files[0]);
$menu.hide();
}).click();
});
var cwrapper = $('#content-wrapper')[0];
cwrapper.addEventListener('dragover', function(e) {
e.preventDefault();
e.stopPropagation();
}, false);
cwrapper.addEventListener('drop', function(e) {
if (e.dataTransfer.files.length) {
e.preventDefault();
if (!$doc.checkSaved()) return;
read(e.dataTransfer.files[0]);
$menu.hide();
}
}, false);
function read(domfile) {
if (!domfile) return;
var info = new fio.file.anlysisPath(domfile.name);
var protocol = supports[info.extension];
if (!protocol || !protocol.decode) {
notice.warn(minder.getLang('ui.unsupportedfile'));
return Promise.reject();
}
function loadFile(file, protocol) {
return 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');
}
});
}
function loadFileError() {
var notice = minder.getUI('widget/notice');
notice.error('err_localfile_read');
}
function loadDoc(data) {
var doc = {
content: data.content,
protocol: protocol.name,
title: info.filename,
source: 'local'
};
return $doc.load(doc);
}
$(minder.getRenderTarget()).addClass('loading');
return loadFile(domfile, protocol).then(loadDoc, loadFileError).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
});
}
return {
read: read
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 支持从百度网盘打开文件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/open/netdisk', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $netdiskfinder = minder.getUI('widget/netdiskfinder');
var $eve = minder.getUI('eve');
var $doc = minder.getUI('doc');
var ret = $eve.setup({});
var notice = minder.getUI('widget/notice');
/* 网盘面板 */
var $panel = $($open.createSub('netdisk')).addClass('netdisk-open-panel');
/* 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 supports[file.extension];
});
$finder.on('fileclick', function(file) {
if (!$doc.checkSaved()) return;
return open(file.path);
});
function open(path, errorHandler) {
$menu.hide();
$(minder.getRenderTarget()).addClass('loading');
var info = fio.file.anlysisPath(path);
var protocol = supports[info.extension];
function read() {
return fio.file.read({
path: path,
dataType: protocol.dataType
});
}
function load(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);
}
function error(e) {
return errorHandler && errorHandler(e) || notice.error('err_load', e);
}
return read().then(load)['catch'](error).then(function() {
$(minder.getRenderTarget()).removeClass('loading');
});
}
ret.open = open;
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 打开菜单(二级菜单)
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/open/open', function(minder) {
return minder.getUI('menu/menu').createSubMenu('open', true);
});
\ No newline at end of file
/**
* @fileOverview
*
* 最近文件功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/open/recent', function(minder) {
var $menu = minder.getUI('menu/menu');
var $open = minder.getUI('menu/open/open');
var $loader = minder.getUI('widget/fileloader');
var frdTime = minder.getUI('widget/friendlytimespan');
var doc = minder.getUI('doc');
var recentList = minder.getUI('widget/locallist').use('recent');
var finder = minder.getUI('widget/netdiskfinder');
/* 网盘面板 */
var $panel = $($open.createSub('recent')).addClass('recent-file-panel');
minder.on('uiready', function() {
minder.getUI('topbar/user').requireLogin($panel);
});
/* 标题 */
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);
/* 最近文件列表容器 */
var $ul = $('<ul></ul>')
.addClass('recent-file-list')
.appendTo($panel);
$ul.delegate('.recent-file-item', 'click', function(e) {
if (!doc.checkSaved()) return;
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);
finder.on('mv', trackFileMove);
renderList();
function trackFileMove(from, to) {
var fromPath = from.split('/');
var toPath = to.split('/');
function preCommonLength(a, b) {
var i = 0;
while((i in a) && (i in b) && a[i] == b[i]) i++;
return (i in b) ? 0 : i;
}
recentList.forEach(function(item) {
var originPath = item.path.split('/');
var clen = preCommonLength(originPath, fromPath);
if (clen) {
var movedPath = toPath.concat(originPath.slice(clen));
item.path = movedPath.join('/');
item.filename = toPath.pop();
}
});
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>')
.addClass('recent-file-item')
.data('path', item.path)
.appendTo($ul);
$('<h4></h4>')
.addClass('file-name')
.text(item.filename)
.appendTo($li);
$('<p></p>')
.addClass('file-title')
.text(item.title)
.appendTo($li);
$('<span></span>')
.addClass('file-time')
.displayFriendlyTime(item.time)
.appendTo($li);
});
}
return {
hasRecent: function() {
return recentList.length;
},
loadLast: function() {
$ul.find('.recent-file-item').eq(0).click();
},
last: function() {
return recentList.get(0) || null;
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 配置面板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ui/menu/preference/preference', function (minder) {
var $menu = minder.getUI('menu/menu');
var ret = minder.getUI('eve').setup({});
var $panel = $menu.createSub('preference');
// 同步用户配置文件
function syncPreference() {
// 配置文件在网盘的路径
var remotePreferencesPath = '/apps/kityminder/app.preferences';
// 记录远端配置的和本地配置的版本
// - 远端配置保存在 json 内容的 version 字段中
// - 本地配置用 localStorage 来记录
var remoteVersion = 0,
localVersion = localStorage.preferencesVersion || 0;
// 远端配置和本地配置的内容
var remotePreferences, localPreferences;
downloadPreferences();
// 绑定实例上配置改变的事件,配置有变需要上传
minder.on('preferenceschange', function() {
localStorage.preferencesVersion = ++localVersion;
uploadPreferences();
});
// 下载远端配置
function downloadPreferences() {
// 比较远端和本地版本
// - 远端版本较新则设置本地版本为远端版本
// - 本地版本较新则上传本地版本
function merge(remote) {
if (!remote) return;
remote = JSON.parse(remote.data.content);
remoteVersion = remote.version;
remotePreferences = remote.preferences;
localPreferences = minder.getPreferences();
if (localVersion < remoteVersion) {
minder.resetPreferences(remotePreferences);
} else if (localVersion > remoteVersion) {
uploadPreferences();
}
}
// 下载配置的过程
// 需要先获得下载的 URL 再使用 ajax 请求内容
fio.file.read({
path: remotePreferencesPath,
dataType: 'text'
}).then(merge);
}
// 上传本地配置
function uploadPreferences() {
localPreferences = minder.getPreferences();
// 上传的数据需要附带版本信息
var data = {
version: localVersion,
preferences: localPreferences
};
fio.file.write({
path: remotePreferencesPath,
content: JSON.stringify(data),
ondup: fio.file.DUP_OVERWRITE
});
}
}
});
\ 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.downloadheader'))
.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');
if (!$panel.hasClass('loading')) doExport(protocol);
});
function doExport(protocol) {
var filename = minder.getMinderTitle() + protocol.fileExtension;
var mineType = protocol.mineType || 'text/plain';
$panel.addClass('loading');
var options = {
download: true,
filename: filename
};
minder.exportData(protocol.name, options).then(function(data) {
if (protocol.name == 'freemind') return;
switch (protocol.dataType) {
case 'text':
return doDownload(buildDataUrl(mineType, data), filename, 'text');
case 'base64':
return doDownload(data, filename, 'base64');
case 'blob':
return null;
}
return null;
})['catch'](function exportError(e) {
var notice = minder.getUI('widget/notice');
return notice.error('err_download', e);
})
.then(function done(tick) {
$panel.removeClass('loading');
});
}
function doDownload(url, filename, type) {
var stamp = +new Date() * 1e5 + Math.floor(Math.random() * (1e5 - 1));
stamp = stamp.toString(36);
var ret = new Promise(function(resolve, reject) {
var ticker = 0;
var MAX_TICK = 30;
var interval = 1000;
function check() {
if (document.cookie.indexOf(stamp + '=1') != -1) return resolve([stamp, ticker]);
if (++ticker > MAX_TICK) {
resolve([stamp, ticker]);
}
setTimeout(check, interval);
}
setTimeout(check, interval);
});
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);
if (kity.Browser.ie) {
$('<input name="iehack" value="1" />').appendTo($form);
}
$('<input name="stamp" />').val(stamp).appendTo($form);
var netdisk = minder.getUI('menu/save/netdisk');
if (netdisk) {
netdisk.mute = true;
setTimeout(function() {
netdisk.mute = false;
}, 1000);
}
$form.appendTo('body').submit().remove();
return ret;
}
function buildDataUrl(mineType, data) {
return 'data:' + mineType + '; utf-8,' + encodeURIComponent(data);
}
});
\ No newline at end of file
/**
* @fileOverview
*
* 保存文件到网盘的功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/save/netdisk', function(minder) {
var $menu = minder.getUI('menu/menu');
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 notice = minder.getUI('widget/notice');
/* extension => protocol */
var supports = {};
minder.getSupportedProtocols().forEach(function(protocol) {
if (protocol.encode && protocol.decode) {
supports[protocol.fileExtension] = protocol;
}
});
/* 网盘面板 */
var $panel = $($save.createSub('netdisk', true)).addClass('netdisk-save-panel');
var $finder = $netdiskfinder.generate($panel, function(file) {
return supports[file.extension];
});
var $selects = $('<div class="netdisk-save-select"></div>')
.appendTo($panel);
$('<label>')
.text(minder.getLang('ui.saveas'))
.appendTo($selects);
/* 文件名 */
var $filename = $('<input>')
.addClass('fui-widget fui-selectable')
.attr('type', 'text')
.attr('placeholder', minder.getLang('ui.filename'))
.attr('title', minder.getLang('ui.filename'))
.on('keydown', function(e) {
if (e.keyCode == 27) $menu.toggle();
if (e.keyCode == 13) save();
})
.appendTo($selects);
/* 文件格式 */
var $format = $('<select>')
.attr('title', minder.getLang('ui.fileformat'))
.appendTo($selects);
for (var ext in supports) {
var protocol = supports[ext];
if (!protocol.encode) return;
$('<option>')
.text(protocol.fileDescription + '(' + protocol.fileExtension + ')')
.val(ext)
.appendTo($format);
}
$format.val('.km');
$format.on('change', normalizeFilename);
/* 保存按钮 */
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);
});
ret.quickSave = quickSave;
window.onbeforeunload = function() {
var noask = ret.mute || window.location.href.indexOf('noask') > 0;
if (!$doc.checkSaved(true) && !noask)
return minder.getLang('ui.unsavedcontent', '* ' + $doc.current().title);
};
var autoSaveDuration = minder.getOptions('autoSave');
if (autoSaveDuration !== false) {
autoSaveDuration = isNaN(autoSaveDuration) ? 3000 : (autoSaveDuration * 1000);
autoSave();
}
var autoSaveTimer = 0;
function autoSave() {
function lazySave(doc) {
if (doc.saved) return;
clearTimeout(autoSaveTimer);
autoSaveTimer = setTimeout(saveCurrent, autoSaveDuration);
}
$doc.on('docchange', lazySave);
}
// 快速保存
function quickSave() {
var doc = $doc.current();
if (doc.source != 'netdisk' && !$menu.isVisible()) {
$menu.$tabs.select(2);
$save.$tabs.select(0);
return $menu.show();
} else {
saveCurrent();
}
}
function saveCurrent() {
var doc = $doc.current();
if (doc.source != 'netdisk') return Promise.resolve();
var $title = minder.getUI('topbar/title').$title;
$filename.val(doc.title);
return doSave(doc.path, doc.protocol, doc, $title, 'leaveTheMenu');
}
function normalizeFilename() {
var filename = $filename.val();
var info = fio.file.anlysisPath(filename);
var ext = info.extension;
if (ext != $format.val()) {
if (ext in supports) {
$filename.val(info.name + $format.val());
} else {
$filename.val(filename + $format.val());
}
$filename[0].select();
}
return $filename.val();
}
function getSaveContext() {
var filename = normalizeFilename();
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;
return {
filename: filename,
path: path,
doc: doc,
protocol: protocol,
exist: exist,
match: match,
duplicated: duplicated
};
}
function save() {
var ctx = getSaveContext();
if (ctx.match || !ctx.exist || ctx.duplicated && window.confirm(minder.getLang('ui.overrideconfirm', ctx.filename))) {
doSave(ctx.path, ctx.protocol.name, ctx.doc, $panel);
}
}
var saving = 0;
function doSave(path, protocol, doc, $mask, leaveTheMenu, msg) {
if (saving) return;
saving = true;
if ($mask) $mask.addClass('loading');
function upload(data) {
return fio.file.write({
path: path,
content: data,
ondup: fio.file.DUP_OVERWRITE
});
}
function finish(file) {
if (!file.modifyTime) throw new Error('File Save Error');
if (!leaveTheMenu) {
$menu.hide();
}
doc.path = file.path;
doc.title = file.filename;
doc.source = 'netdisk';
doc.protocol = protocol;
$doc.save(doc);
notice.info(msg || minder.getLang('ui.save_success', doc.title, file.modifyTime.toLocaleTimeString()));
setTimeout(function() {
$finder.list($finder.pwd(), true);
}, 1499);
}
function error(e) {
notice.error('err_save', e);
}
return minder.exportData(protocol).then(upload).then(finish, error).then(function() {
if ($mask) $mask.removeClass('loading');
saving = false;
});
}
function setFilename() {
var doc = $doc.current();
switch (doc.source) {
case 'netdisk':
setFilenameForNetDiskSource(doc);
break;
default:
setFilenameForOtherSource(doc);
break;
}
$filename[0].select();
}
function setFilenameInputValue(filename) {
$filename.val(filename);
normalizeFilename(filename);
}
function setFilenameForNetDiskSource(doc) {
if (!fio.user.current()) return;
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);
}
setFilenameInputValue(pathInfo.filename);
}
function setFilenameForOtherSource(doc) {
setFilenameInputValue(doc.title);
$finder.select(null);
}
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 保存菜单(二级菜单)
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/save/save', function(minder) {
return minder.getUI('menu/menu').createSubMenu('save');
});
\ No newline at end of file
/**
* @fileOverview
*
* 查看分享文件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('menu/share/m-share', function (minder) {
var $doc = minder.getUI('doc');
function loadShareDoc() {
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) {
window.alert(data.error);
window.location.href = 'index.html';
return;
}
var content = data.shareMinder.data;
return $doc.load({
source: 'share',
content: content,
protocol: 'json',
saved: true,
ownerId: data.uid,
ownerName: data.uname
}).then(function(doc) {
var $title = minder.getUI('topbar/title');
$title.setTitle('[分享的] ' + $title.getTitle());
});
}
$('#kityminder').addClass('loading');
return $.pajax({
url: 'http://naotu.baidu.com/share.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');
minder.execCommand('hand');
$('#kityminder').removeClass('loading');
});
}
minder.on('dblclick', function() {
minder.execCommand('camera', minder.getRoot(), 500);
});
return {
ready: loadShareDoc()
};
});
\ 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');
var $create_menu = $($share_menu.createSub('createshare'));
var $manage_menu = $($share_menu.createSub('manageshare'));
var $share_list = $('<ul>')
.attr('id', 'manage-share-list')
.appendTo($manage_menu);
var $doc = minder.getUI('doc');
var notice = minder.getUI('widget/notice');
var finder = minder.getUI('widget/netdiskfinder');
var BACKEND_URL = 'http://naotu.baidu.com/share.php';
var currentShare = null;
var shareList = [];
renderCreatePanel().then(bindCreatePanelEvent);
renderManagePanel();
var shareListLoaded = loadShareList();
shareListLoaded.then(renderShareList);
shareListLoaded.then(bindManageActions);
minder.on('uiready', function() {
minder.getUI('topbar/user').requireLogin($manage_menu);
});
$doc.on('docload', function(doc) {
if (doc.source != 'netdisk') {
currentShare = null;
$('#public-share .share-body', $create_menu).hide();
setShareType('none');
}
var shared = getShareByPath(doc.path);
if (shared) {
setCurrentShare(shared);
}
});
$doc.on('docsave', function(doc) {
if (doc.source != 'netdisk') return;
var shared = getShareByPath(doc.path);
if (shared) {
fio.user.check().then(function(user) {
$.pajax({
url: BACKEND_URL,
type: 'POST',
data: {
action: 'update',
ak: user.access_token,
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);
});
});
}
});
finder.on('mv', trackFileMove);
function trackFileMove(from, to) {
var fromPath = from.split('/');
var toPath = to.split('/');
function preCommonLength(a, b) {
var i = 0;
while((i in a) && (i in b) && a[i] == b[i]) i++;
return (i in b) ? 0 : i;
}
shareListLoaded.then(function(list) {
var userChecked = fio.user.check();
list.forEach(function(item) {
var originPath = item.path.split('/');
var clen = preCommonLength(originPath, fromPath);
if (clen) {
var movedPath = toPath.concat(originPath.slice(clen));
userChecked.then(function(user) {
$.pajax({
url: BACKEND_URL,
type: 'POST',
data: {
action: 'move',
ak: user.access_token,
id: item.id || item.shareMinder.id,
path: movedPath.join('/')
}
}).then(function() {
notice.info(minder.getLang('ui.share_sync_success', item.title));
})['catch'](function(e) {
notice.error('err_share_sync_failed', e);
});
});
item.path = movedPath.join('/');
}
});
renderShareList(list);
});
}
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;
var i = shareList.length;
while (i--) {
if (shareList[i].path == path) return shareList[i];
}
return null;
}
function setCurrentShare(share) {
currentShare = share;
renderPublicShare(share);
}
function renderCreatePanel() {
// render template
return $.pajax({ url: 'static/pages/createshare.html' }).then(function(html) {
/* global jhtmls: true */
var render = jhtmls.render(html);
$create_menu.html(render({
lang: minder.getLang('ui'),
minder: minder
}));
setTimeout(zeroCopy, 10);
return $create_menu;
});
}
function renderManagePanel() {
$manage_menu.append($('<h2>')
.text(minder.getLang('ui.manage_share'))
.attr('id', 'manage-share-header'));
}
function bindCreatePanelEvent($panel) {
$panel.delegate('input[name=sharetype]', 'click', function(e) {
var actions = {
'none': removeCurrentShare,
'public': createPublicShare
};
actions[e.target.value]();
});
$panel.delegate('input#share-url', 'dblclick', function() {
this.select();
});
$panel.delegate('#copy-share-url', 'click', function() {
if (kity.Browser.safari && kity.Browser.safari < 8) {
var input = $('#share-url');
input.focus();
input.select();
window.alert(minder.getLang('ui.clipboardunsupported'));
}
});
}
function bindManageActions() {
$manage_menu.delegate('.share-item a', 'click', function(e) {
var $target = $(e.target);
var $li = $target.closest('.share-item');
var share = $li.data('share');
switch (true) {
case $target.hasClass('view-action'):
window.open(buildShareUrl(share.id || share.shareMinder.id), '_blank');
return;
case $target.hasClass('remove-action'):
$li.addClass('loading');
removeShare(share).then(function(result) {
if (result && result.deleted) {
shareList.splice(shareList.indexOf(share), 1);
$li.slideUp(function() {
$li.remove();
});
if (share == currentShare) {
removeCurrentShareSelect();
}
}
}).then(function() {
$li.removeClass('loading');
});
return;
case $target.hasClass('edit-action'):
loadOriginFile(share);
return;
}
});
}
function removeShare(share) {
return fio.user.check().then(function(user) {
return $.pajax(BACKEND_URL, {
type: 'POST',
data: {
action: 'remove',
ak: user && user.access_token,
id: share.id || share.shareMinder.id
},
dataType: 'json'
})['catch'](function(e) {
var notice = minder.getUI('widget/notice');
notice.error('err_remove_share', e);
});
});
}
function removeCurrentShare() {
if (!currentShare) return;
$create_menu.addClass('loading');
return removeShare(currentShare).then(function(result) {
if (result && result.deleted) {
removeCurrentShareSelect();
}
$create_menu.removeClass('loading');
});
}
function removeCurrentShareSelect() {
var $sbody = $('#public-share .share-body', $create_menu);
$sbody.hide();
if (currentShare.$listItem) {
currentShare.$listItem.remove();
}
currentShare = null;
setShareType('none');
}
function uuid() {
// 最多使用 1e7,否则 IE toString() 会出来指数表示法
var timeLead = 1e6;
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) {
var notice = minder.getUI('widget/notice');
notice.error('err_create_share', e);
});
})
.then(function(shared) {
if (shared) {
setCurrentShare(shared);
shareListLoaded.then(function() {
shareList.unshift(shared);
$('#manage-share-list').prepend(currentShare.$listItem = buildShareItem(shared));
});
}
$create_menu.removeClass('loading');
});
}
function buildShareUrl(id) {
var baseUrl = /^(.*?)(\?|\#|$)/.exec(window.location.href)[1];
baseUrl = baseUrl.split('edit.html')[0];
return baseUrl + 'viewshare.html?shareId=' + id;
}
function setShareType(value) {
$('#share-select input[name=sharetype][value=' + value + ']', $create_menu)
.prop('checked', true);
}
function renderPublicShare(shared) {
var $sbody = $('#public-share .share-body', $create_menu);
var shareUrl = buildShareUrl(shared.id || shared.shareMinder.id);
$('#share-url', $sbody).val(shareUrl)[0].select();
// qr code
var $qrcontainer = $sbody.find('.share-qr-code').empty();
new window.QRCode($qrcontainer[0], {
text: shareUrl,
width: 128,
height: 128,
correctLevel : window.QRCode.CorrectLevel.M
});
var shareConfig = window._bd_share_config && window._bd_share_config.common,
resetShare = window._bd_share_main && 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();
}
setShareType('public');
$sbody.show();
}
function loadShareList() {
return fio.user.check().then(function(user) {
if (!user) return;
return $.pajax(BACKEND_URL, {
type: 'GET',
data: {
action: 'list',
ak: user && user.access_token
},
dataType: 'json'
}).then(function(result) {
return (shareList = result.list || []);
});
});
}
function renderShareList(list) {
var frdTime = minder.getUI('widget/friendlytimespan');
if (!list) return;
$share_list.empty();
list.forEach(function(share) {
$share_list.append(buildShareItem(share));
});
}
function buildShareItem(share) {
var $li = $('<li>')
.addClass('share-item')
.data('share', share);
$('<span>')
.addClass('title')
.text(share.title)
.appendTo($li);
$('<span>')
.addClass('url')
.text(share.path ?
share.path.replace('/apps/kityminder', minder.getLang('ui.mydocument')) :
buildShareUrl(share.id || share.shareMinder.id))
.appendTo($li);
if (share.ctime) {
$('<span>')
.addClass('ctime')
.displayFriendlyTime(+share.ctime)
.appendTo($li);
}
$('<a>')
.addClass('remove-action')
.text(minder.getLang('ui.share_remove_action'))
.attr('title', minder.getLang('ui.share_remove_action'))
.appendTo($li);
$('<a>')
.addClass('view-action')
.text(minder.getLang('ui.share_view_action'))
.attr('title', minder.getLang('ui.share_view_action'))
.appendTo($li);
if (share.path)
$('<a>')
.addClass('edit-action')
.text(minder.getLang('ui.share_edit_action'))
.attr('title', minder.getLang('ui.share_edit_action'))
.appendTo($li);
return $li;
}
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 */
var $copy_url_btn = $('#copy-share-url', $create_menu);
if (window.ZeroClipboard) {
ZeroClipboard.config({
swfPath: 'lib/ZeroClipboard.swf',
hoverClass: 'hover',
activeClass: 'active'
});
var clip = new window.ZeroClipboard($copy_url_btn);
clip.on('ready', function () {
clip.on('aftercopy', function() {
$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 {
$menu: $share_menu,
loadShareFile: loadShareFile
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 查看分享文件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
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+)([&#]|$)/;
var match = pattern.exec(window.location) || pattern.exec(document.referrer);
if (!match) return Promise.resolve(null);
shareId = match[1];
function renderShareData(data) {
if (data.error) {
return notice.error('err_share_data', data.error);
}
var content = data.shareMinder.data;
var title = data.path ? data.path.split('/').pop() : data.title;
title = title || JSON.parse(content).data.text;
title = minder.getLang('ui.shared_file_title', title);
return $doc.load({
title: title,
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() {
minder.disable();
minder.execCommand('hand', true);
$container.removeClass('loading');
});
}
return {
ready: loadShareDoc()
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 脑图缩略图导航功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('nav', function(minder) {
var memory = minder.getUI('memory');
var $navBar = $('<div>').addClass('nav-bar').appendTo('#content-wrapper');
var $commandbutton = minder.getUI('widget/commandbutton');
var $zoomIn = $commandbutton.generate('zoom-in').appendTo($navBar[0]);
var $zoomPan = createZoomPan($navBar);
var $zoomOut = $commandbutton.generate('zoom-out').appendTo($navBar[0]);
var $previewNavigator = createViewNavigator();
var $hand = $commandbutton.generate('hand').appendTo($navBar[0]);
var $root = $commandbutton.generate('camera', function() {
minder.execCommand('camera', minder.getRoot(), 600);
}).appendTo($navBar[0]);
var $previewTrigger = createPreviewTrigger($previewNavigator).appendTo($navBar);
function createZoomPan($parent) {
var $pan = $('<div>').addClass('zoom-pan').appendTo($parent);
var zoomStack = minder.getOptions('zoom');
var minValue = zoomStack[0];
var maxValue = zoomStack[zoomStack.length - 1];
var valueRange = maxValue - minValue;
var totalHeight = $pan.height();
function getHeight(value) {
return (1 - (value - minValue) / valueRange) * totalHeight;
}
var $origin = $('<div>')
.addClass('origin')
.appendTo($pan)
.css('y', getHeight(100));
var $indicator = $('<div>')
.addClass('indicator')
.appendTo($pan)
.css('y', getHeight(100));
function indicate(value) {
$indicator.animate({
'y': getHeight(value)
}, 200);
}
minder.on('zoom', function(e) {
indicate(e.zoom);
});
$origin.click(function() {
minder.execCommand('zoom', 100);
});
return $pan;
}
/**
* 创建导航器的 DOM 元素以及交互的逻辑代码
*/
function createViewNavigator() {
var $previewNavigator = $('<div>')
.addClass('preview-navigator')
.appendTo('#content-wrapper');
// 画布,渲染缩略图
var paper = new kity.Paper($previewNavigator[0]);
// 用两个路径来挥之节点和连线的缩略图
var nodeThumb = paper.put(new kity.Path());
var connectionThumb = paper.put(new kity.Path());
// 表示可视区域的矩形
var visibleRect = paper.put(new kity.Rect(100, 100).stroke('red', '1%'));
var contentView = new kity.Box(), visibleView = new kity.Box();
navigate();
$previewNavigator.show = function() {
$.fn.show.call(this);
bind();
updateContentView();
updateVisibleView();
};
$previewNavigator.hide = function() {
$.fn.hide.call(this);
unbind();
};
function bind() {
minder.on('layout layoutallfinish', updateContentView);
minder.on('viewchange', updateVisibleView);
}
function unbind() {
minder.off('layout layoutallfinish', updateContentView);
minder.off('viewchange', updateVisibleView);
}
window.u = updateContentView;
function navigate() {
function moveView(center, duration) {
var box = visibleView;
center.x = -center.x;
center.y = -center.y;
var viewMatrix = minder.getPaper().getViewPortMatrix();
box = viewMatrix.transformBox(box);
var targetPosition = center.offset(box.width / 2, box.height / 2);
minder.getViewDragger().moveTo(targetPosition, duration);
}
var dragging = false;
paper.on('mousedown', function(e) {
dragging = true;
moveView(e.getPosition('top'), 200);
$previewNavigator.addClass('grab');
});
paper.on('mousemove', function(e) {
if (dragging) {
moveView(e.getPosition('top'));
}
});
$(window).on('mouseup', function() {
dragging = false;
$previewNavigator.removeClass('grab');
});
}
function updateContentView() {
var view = minder.getRenderContainer().getBoundaryBox();
contentView = view;
var padding = 30;
paper.setViewBox(
view.x - padding - 0.5,
view.y - padding - 0.5,
view.width + padding * 2 + 1,
view.height + padding * 2 + 1);
var nodePathData = [];
var connectionThumbData = [];
minder.getRoot().traverse(function(node) {
var box = node.getLayoutBox();
nodePathData.push('M', box.x, box.y,
'h', box.width, 'v', box.height,
'h', -box.width, 'z');
if (node.getConnection() && node.parent && node.parent.isExpanded()) {
connectionThumbData.push(node.getConnection().getPathData());
}
});
paper.setStyle('background', minder.getStyle('background'));
if (nodePathData.length) {
nodeThumb
.fill(minder.getStyle('root-background'))
.setPathData(nodePathData);
} else {
nodeThumb.setPathData(null);
}
if (connectionThumbData.length) {
connectionThumb
.stroke(minder.getStyle('connect-color'), '0.5%')
.setPathData(connectionThumbData);
} else {
connectionThumb.setPathData(null);
}
updateVisibleView();
}
function updateVisibleView() {
visibleView = minder.getViewDragger().getView();
visibleRect.setBox(visibleView.intersect(contentView));
}
return $previewNavigator;
}
function createPreviewTrigger($previewNavigator) {
var $trigger = $('<div>').addClass('command-button nav-trigger');
$trigger.append('<div class="fui-icon">');
$trigger.click(toggle);
$trigger.attr('title', minder.getLang('ui.navigator'));
function toggle() {
if ($trigger.toggleClass('active').hasClass('active')) {
$previewNavigator.show();
memory.set('navigator-hidden', false);
} else {
$previewNavigator.hide();
memory.set('navigator-hidden', true);
}
}
if (memory.get('navigator-hidden')) toggle();
toggle();
return $trigger;
}
});
\ No newline at end of file
/**
* @fileOverview
*
* 节点颜色设置(包括和背景)
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/appearence/color', function(minder) {
function generateSerisColor() {
return ['#e75d66', '#fac75b', '#99ca6a', '#00c5ad', '#3bbce0', '#c9ced1', '#425b71', 'white'];
}
var $commandbuttonset = minder.getUI('widget/commandbuttonset');
var $tabs = minder.getUI('ribbon/tabs');
var $colorPanel = new FUI.LabelPanel({
label: minder.getLang('panels.color')
}).appendTo($tabs.appearence);
var $backgroundPanel = new FUI.LabelPanel({
label: minder.getLang('panels.background')
}).appendTo($tabs.appearence);
var foreColorList = generateSerisColor();
$colorPanel.appendWidget($commandbuttonset.generate('forecolor', foreColorList.map(function(color) {
return {
icon: {
style: {
background: color
}
},
label: color,
text: color,
value: color
};
})).addClass('color-picker'));
$backgroundPanel.appendWidget($commandbuttonset.generate('background', foreColorList.map(function(color) {
return {
icon: {
style: {
background: color
}
},
label: color,
text: color,
value: color
};
})).addClass('color-picker'));
return {
color: $colorPanel,
background: $backgroundPanel
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 字体设置(字体字号加粗斜体)
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/appearence/font', function(minder) {
var $tabs = minder.getUI('ribbon/tabs');
var commandinputmenu = minder.getUI('widget/commandinputmenu');
var commandbutton = minder.getUI('widget/commandbutton');
var $fontPanel = new FUI.LabelPanel({
label: minder.getLang('panels.font'),
id: 'font-panel'
});
var $leftPanel = new FUI.Panel({
column: true
});
var $rightPanel = new FUI.Panel({
column: true
});
var $fontFamilyMenu = commandinputmenu.generate('fontfamily', minder.getOptions('fontfamily').map(function(ff) {
return {
label: {
text: ff.name,
style: {
fontFamily: ff.val
}
},
text: ff.name,
value: ff.val
};
}));
var $fontSizeMenu = commandinputmenu.generate('fontsize', minder.getOptions('fontsize').map(function(fs) {
return {
label: {
text: fs,
style: {
fontSize: fs
}
},
text: fs,
value: fs
};
}));
$leftPanel.appendWidgets([$fontFamilyMenu, $fontSizeMenu]);
var $boldButton = commandbutton.generate('bold');
var $italicButton = commandbutton.generate('italic');
$rightPanel.appendWidgets([$boldButton, $italicButton]);
$fontPanel.appendWidgets([$leftPanel, $rightPanel]);
$tabs.appearence.appendWidget($fontPanel);
});
\ No newline at end of file
/**
* @fileOverview
*
* 布局面板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/appearence/layout', function(minder) {
var $tabs = minder.getUI('ribbon/tabs');
var $commandbuttonset = minder.getUI('widget/commandbuttonset');
var $commandbutton = minder.getUI('widget/commandbutton');
var $layoutPanel = new FUI.LabelPanel({
id: 'layout-panel',
label: minder.getLang('panels.layout')
}).appendTo($tabs.appearence);
// var $layoutSelect = new FUI.DropPanel({
// id: 'layout-select'
// }).appendTo($layoutPanel);
// var layoutList = KityMinder.Utils.keys(KityMinder.getLayoutList());
// $layoutSelect.appendWidget($commandbuttonset.generate('layout', layoutList));
$commandbutton.generate('resetlayout').appendTo($layoutPanel).addClass('large');
return $layoutPanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 样式控制
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/appearence/style', function(minder) {
var $tabs = minder.getUI('ribbon/tabs');
var $commandbutton = minder.getUI('widget/commandbutton');
var $stylePanel = new FUI.LabelPanel({
label: minder.getLang('panels.style')
}).appendTo($tabs.appearence);
$commandbutton.generate('clearstyle').addClass('large').appendTo($stylePanel);
var $styleClipPanel = new FUI.Panel({
column: true
}).appendTo($stylePanel);
$commandbutton.generate('copystyle').appendTo($styleClipPanel);
$commandbutton.generate('pastestyle').appendTo($styleClipPanel);
return $stylePanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 模板选择
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/appearence/template', function(minder) {
var $commandselectmenu = minder.getUI('widget/commandselectmenu');
var $tabs = minder.getUI('ribbon/tabs');
var $templatePanel = new FUI.LabelPanel({
id: 'template-panel',
label: minder.getLang('panels.template')
});
var templateList = KityMinder.Utils.keys(KityMinder.getTemplateList());
var $templateSelect = $commandselectmenu.generate('template', templateList, 2);
$tabs.appearence.appendWidget($templatePanel);
$templatePanel.appendWidget($templateSelect);
return $templatePanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 皮肤选择
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/appearence/theme', function(minder) {
var $commandselectmenu = minder.getUI('widget/commandselectmenu');
var $tabs = minder.getUI('ribbon/tabs');
var $themePanel = new FUI.LabelPanel({
id: 'theme-panel',
label: minder.getLang('panels.theme')
});
var themeList = KityMinder.Utils.keys(KityMinder.getThemeList());
var $themeSelect = $commandselectmenu.generate('theme', themeList.map(function(theme) {
var style = KityMinder._themes[theme];
return {
clazz: 'Button',
label: {
text: minder.getLang('theme.' + theme),
style: {
background: style['root-background'],
color: style['root-color'],
borderRadius: style['root-radius'] / 2
}
},
text: minder.getLang('theme.' + theme),
value: theme,
className: ['theme', theme].join(' ')
};
}));
$tabs.appearence.appendWidget($themePanel);
$themePanel.appendWidget($themeSelect);
minder.on('themechange', function(e) {
$('#content-wrapper').css('background', minder.getStyle('background'));
});
return $themePanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 排列节点的两个命令按钮
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/arrange', function(minder) {
var $tabs = minder.getUI('ribbon/tabs');
var $commandbutton = minder.getUI('widget/commandbutton');
var $arrangePanel = new FUI.LabelPanel({
label: minder.getLang('panels.arrange'),
column: true
});
$commandbutton.generate('arrangeup').appendTo($arrangePanel);
$commandbutton.generate('arrangedown').appendTo($arrangePanel);
$tabs.idea.appendWidget($arrangePanel);
return $arrangePanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 附件面板
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/attachment', function(minder) {
var $tabs = minder.getUI('ribbon/tabs');
var $attachmentPanel = new FUI.LabelPanel({
label: minder.getLang('panels.attachment'),
coloum: true
}).appendTo($tabs.idea);
return $attachmentPanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 插入和管理图片
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('image', function(minder) {
var $attachment = minder.getUI('ribbon/idea/attachment');
var $imageButtonMenu = new FUI.ButtonMenu({
id: 'image-button-menu',
text: minder.getLang('ui.image'),
layout: 'bottom',
buttons: [{}, {
label: minder.getLang('ui.image')
}],
menu: {
items: [minder.getLang('ui.removeimage')]
}
}).appendTo($attachment);
$imageButtonMenu.bindCommandState(minder, 'image');
var $imageDialog = new FUI.Dialog({
width: 600,
height: 600,
prompt: true,
className: 'image-dialog',
caption: minder.getLang('ui.image')
}).appendTo(document.getElementById('content-wrapper'));
var $dialogBody = $($imageDialog.getBodyElement());
// writed by yangxiaohu 2014-10-20
var tabs = new FUI.Tabs( {
buttons: [ "图片搜索", "插入图片" ]
} );
$dialogBody.html([
'<div id="img_buttons"></div>',
'<div id="img_panels"></div>'
].join(''));
tabs.appendButtonTo( document.getElementById( 'img_buttons') );
tabs.appendPanelTo( document.getElementById( 'img_panels'));
tabs.getPanel(0).getContentElement().innerHTML = ['<div class="searchBar"><label>关键字:</label><input id="img_searchTxt" type="text" placeholder="请输入搜索关键词">',
'<button id="img_searchBtn">百度一下</button></div>',
'<div id="img_searchList"><ul id="img_searchListUl"></ul></div>'
].join('');
tabs.getPanel(1).getContentElement().innerHTML = ['<p><label>图片地址:</label><input type="url" class="image-url fui-widget fui-selectable" /></p>',
'<p><label>提示文本:</label><input type="text" class="image-title fui-widget fui-selectable" /></p>',
'<img class="image-preview" src="" style="max-height: 200px;" />'].join('');
//the content below is from xujinquan's ueditor
/*搜索图片 */
$G = function ( id ) {
return document.getElementById( id )
};
function SearchImage() {
this.init();
}
SearchImage.prototype = {
lang: {
searchRemind : '请输入搜索关键词',
searchLoading : '图片加载中,请稍后……',
searchRetry : '抱歉,没有找到图片!请重试一次!',
},
data: {
imgUrl: '',
imgTitle: '',
},
init: function () {
this.initEvents();
},
initEvents: function(){
var _this = this;
/* 点击搜索按钮 */
$('#img_searchBtn').on('click', function(){
var key = $G('img_searchTxt').value;
if(key && key != _this.lang.searchRemind) {
_this.getImageData();
}
});
/* 搜索框聚焦 */
$('#img_searchTxt').on('focus', function(){
var key = $G('img_searchTxt').value;
if(key && key == _this.lang.searchRemind) {
$G('img_searchTxt').value = '';
}
});
/* 搜索框回车键搜索 */
$('#img_searchTxt').on('keydown', function(e){
var keyCode = e.keyCode || e.which;
if (keyCode == 13) {
$G('img_searchBtn').click();
return false;
}
});
/* 选中图片 */
$('#img_searchList').on('click', function(e){
var target = e.target || e.srcElement,
$li = $(target).closest('li');
_this.data.imgUrl = $li.find('img').attr('src');
_this.data.imgTitle = $li.find('span').attr('title');
$li.siblings('.selected').removeClass('selected');
$li.addClass('selected');
});
},
/* 改变图片大小 */
scale: function (img, w, h) {
var ow = img.width,
oh = img.height;
if (ow >= oh) {
img.width = w * ow / oh;
img.height = h;
img.style.marginLeft = '-' + parseInt((img.width - w) / 2) + 'px';
} else {
img.width = w;
img.height = h * oh / ow;
img.style.marginTop = '-' + parseInt((img.height - h) / 2) + 'px';
}
},
getImageData: function(){
var _this = this,
key = $G('img_searchTxt').value,
keepOriginName = '1';
url = "http://image.baidu.com/i?ct=201326592&cl=2&lm=-1&st=-1&tn=baiduimagejson&istype=2&rn=3200&fm=index&pv=&word=" + key + "&ie=utf-8&oe=utf-8&keeporiginname=" + keepOriginName + "&" + +new Date;
$G('img_searchListUl').innerHTML = _this.lang.searchLoading;
$.ajax({url : url,
dataType: 'jsonp',
scriptCharset: 'GB18030',
success:function(json){
var list = [];
if(json && json.data) {
for(var i = 0; i < json.data.length; i++) {
if(json.data[i].objURL) {
list.push({
title: json.data[i].fromPageTitleEnc,
src: json.data[i].objURL,
url: json.data[i].fromURL
});
}
}
}
_this.setList(list);
},
error:function(){
$G('img_searchListUl').innerHTML = _this.lang.searchRetry;
}
});
},
/* 添加图片到列表界面上 */
setList: function (list) {
var i, item, p, img, title, _this = this,
listUl = $G('img_searchListUl');
listUl.innerHTML = '';
if(list.length) {
for (i = 0; i < list.length; i++) {
item = document.createElement('li');
img = document.createElement('img');
title = document.createElement('span');
img.setAttribute('src', list[i].src);
title.innerHTML = list[i].title;
item.appendChild(img);
item.appendChild(title);
listUl.appendChild(item);
img.onerror = function() {
$(this).closest('li').remove();
};
}
} else {
listUl.innerHTML = _this.lang.searchRetry;
}
},
getInsertList: function () {
var child,
src,
align = getAlign(),
list = [],
items = $G('img_searchListUl').children;
for(var i = 0; i < items.length; i++) {
child = items[i].firstChild && items[i].firstChild.firstChild;
if(child.tagName && child.tagName.toLowerCase() == 'img' && $(items[i]).hasClass('selected')) {
src = child.src;
list.push({
src: src,
_src: src,
alt: src.substr(src.lastIndexOf('/') + 1),
floatStyle: align
});
}
}
return list;
}
};
var searchImage = new SearchImage();
// the end content writed by yangxiaohu
var $url = $dialogBody.find('.image-url');
var $title = $dialogBody.find('.image-title');
var $preview = $dialogBody.find('.image-preview');
var $errorMsg = $('<span class="validate-error"></span>');
$imageDialog.on('ok', function() {
var index = tabs.getSelectedIndex();
switch(index) {
case 1:
minder.execCommand('image', $url.val(), $title.val());
break;
case 0:
minder.execCommand('image', searchImage.data.imgUrl, searchImage.data.imgTitle);
break;
}
});
$imageDialog.on('open', function() {
var image = minder.queryCommandValue('image');
$url.val(image.url);
$title.val(image.title);
$preview.attr('src', image.url || '');
error(false);
});
function error(value) {
if (value) {
$url.addClass('validate-error');
$errorMsg.text('图片无法加载');
// $ok.disable();
} else {
$url.removeClass('validate-error');
$errorMsg.text('');
// $imageDialog.enable();
}
return value;
}
$url.after($errorMsg);
$url.on('input', function() {
var url = $url.val();
if (/^https?\:\/\/(\w+\.)+\w+/.test(url)) {
$preview.attr('src', url);
error(false);
// $imageDialog.disable();
$preview.addClass('loading');
} else {
error(true);
}
});
$preview.on('load', function() {
error(false);
$preview.removeClass('loading');
}).on('error', function() {
if ($preview.attr('src')) error(true);
$preview.removeClass('loading');
});
$imageButtonMenu.on('buttonclick', function() {
$imageDialog.open();
$url[0].focus();
});
$imageButtonMenu.on('select', function() {
minder.execCommand('removeimage');
});
return $imageButtonMenu;
});
\ No newline at end of file
/**
* @fileOverview
*
* 插入节点
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/insert', function(minder) {
var $commandbutton = minder.getUI('widget/commandbutton');
var $tabs = minder.getUI('ribbon/tabs');
var $insertNodePanel = new FUI.LabelPanel({
label: minder.getLang('panels.insert'),
column: true
});
$commandbutton.generate('appendchildnode').appendTo($insertNodePanel);
$commandbutton.generate('appendsiblingnode').appendTo($insertNodePanel);
$tabs.idea.appendWidget($insertNodePanel);
return $insertNodePanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 插入和管理超链接
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/link', function(minder) {
var R_URL = /(http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&amp;:/~\+#]*[\w\-\@?^=%&amp;/~\+#])?/;
var $attachment = minder.getUI('ribbon/idea/attachment');
var $linkButtonMenu = new FUI.ButtonMenu({
id: 'link-button-menu',
text: minder.getLang('ui.link'),
layout: 'bottom',
buttons: [{}, {
label: minder.getLang('ui.link')
}],
menu: {
items: [minder.getLang('ui.removelink')]
}
}).appendTo($attachment);
$linkButtonMenu.bindCommandState(minder, 'hyperlink');
var $linkDialog = new FUI.Dialog({
width: 600,
height: 200,
prompt: true,
caption: minder.getLang('ui.link')
}).appendTo(document.getElementById('content-wrapper'));
var $dialogBody = $($linkDialog.getBodyElement());
$dialogBody.html([
'<p><label>连接地址:</label><input type="url" class="link-href fui-widget fui-selectable" /></p>',
'<p><label>提示文本:</label><input type="text" class="link-title fui-widget fui-selectable" /></p>'
].join(''));
var $href = $dialogBody.find('.link-href');
var $title = $dialogBody.find('.link-title');
var $ok = $linkDialog.getButton(0);
var $errorMsg = $('<span class="validate-error"></span>');
function error(value) {
if (value) {
$href.addClass('validate-error');
$errorMsg.text('地址格式错误');
$ok.disable();
} else {
$href.removeClass('validate-error');
$errorMsg.text('');
$ok.enable();
}
}
$href.after($errorMsg);
$href.on('input', function() {
var url = $href.val();
error(!R_URL.test(url));
});
$linkButtonMenu.on('buttonclick', function() {
$linkDialog.open();
$href[0].focus();
});
$linkButtonMenu.on('select', function() {
minder.execCommand('unhyperlink');
});
$linkDialog.on('ok', function() {
minder.execCommand('hyperlink', $href.val(), $title.val() || '');
});
$linkDialog.on('open', function() {
var value = minder.queryCommandValue('hyperlink');
$href.val(value.url);
$title.val(value.title);
error(false);
});
$(minder.getPaper().getNode()).delegate('a', 'click', function(e) {
var $a = $(e.target).closest('a');
var href = $a.prop('href').baseVal;
if (window.confirm(minder.getLang('ui.redirect', href))) {
window.open(href, '_blank');
}
e.preventDefault();
});
return $linkButtonMenu;
});
\ No newline at end of file
/**
* @fileOverview
*
* 节点操作(编辑和删除)
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/operation', function(minder) {
var $commandbutton = minder.getUI('widget/commandbutton');
var $tabs = minder.getUI('ribbon/tabs');
var $opPanel = new FUI.LabelPanel({
label: minder.getLang('panels.nodeop'),
column: true
}).appendTo($tabs.idea);
['editnode', 'removenode'].forEach(function(cmd) {
$commandbutton.generate(cmd).appendTo($opPanel);
});
});
\ No newline at end of file
/**
* @fileOverview
*
* 添加和修改优先级标签
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/priority', function(minder) {
var $commandbuttonset = minder.getUI('widget/commandbuttonset');
var $tabs = minder.getUI('ribbon/tabs');
var $priorityPanel = new FUI.LabelPanel({
label: minder.getLang('panels.priority')
}).appendTo($tabs.idea);
$commandbuttonset.generate('priority', [1, 2, 3, 4, 5, 6, 7, 8, 9, 0].map(function(p) {
return {
label: p,
text: minder.getLang('ui.priority') + p,
value: p,
className: ['priority', p].join('-')
};
})).appendTo($priorityPanel);
return $priorityPanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 添加和修改进度标签
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/progress', function(minder) {
var $commandbuttonset = minder.getUI('widget/commandbuttonset');
var $tabs = minder.getUI('ribbon/tabs');
var $progressPanel = new FUI.LabelPanel({
label: minder.getLang('panels.progress')
}).appendTo($tabs.idea);
$commandbuttonset.generate('progress', [1, 2, 3, 4, 5, 6, 7, 8, 9, 0].map(function(p) {
return {
label: p,
text: minder.getLang('ui.progress.p' + p),
value: p,
className: ['progress', p].join('-')
};
})).appendTo($progressPanel);
return $progressPanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* 添加和管理资源标签
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/idea/resource', function(minder) {
var $commandbuttonset = minder.getUI('widget/commandbuttonset');
var $tabs = minder.getUI('ribbon/tabs');
var $resourcePanel = new FUI.LabelPanel({
label: minder.getLang('panels.resource'),
id: 'resource-panel'
}).appendTo($tabs.idea);
var $addInput = new FUI.Input().appendTo($resourcePanel);
$addInput.getElement().type = 'text';
var $addButton = new FUI.Button({
label: '添加'
}).appendTo($resourcePanel);
var $resourceDrop = new FUI.DropPanel().appendTo($resourcePanel);
var $dropContainer = $($resourceDrop.getPanelElement());
var $ul = $('<ul></ul>').addClass('resource-list').appendTo($dropContainer);
var $list = [];
function addResource() {
var resource = $addInput.getValue();
var origin = minder.queryCommandValue('resource');
if (/\S/.test(resource)) {
if (!~origin.indexOf(resource)) origin.push(resource);
origin.sort();
minder.execCommand('resource', origin);
}
$addInput.setValue(null);
update();
$addInput.focus();
}
$addInput.on('inputcomplete', function(e) {
addResource();
});
$addButton.on('click', addResource);
$dropContainer.delegate('input[type=checkbox]', 'change', function() {
minder.execCommand('resource', $dropContainer.find('input[type=checkbox]:checked').map(function(index, chk) {
return $(chk).data('resource');
}).toArray());
update();
});
function hash(resource, used) {
return [resource.join(','), used.join(',')].join(';');
}
function changed(resource, used) {
var currentHash = hash(resource, used);
if (currentHash == changed.lastHash) return false;
changed.lastHash = currentHash;
return true;
}
function update() {
var resource = minder.queryCommandValue('resource');
var used = minder.getUsedResource();
used.sort();
switch (minder.queryCommandState('resource')) {
case 0:
$addInput.enable();
$addButton.enable();
$resourceDrop.enable();
$ul.find('input[type=checkbox]').removeAttr('disabled');
break;
case -1:
$addInput.disable();
$addButton.disable();
$resourceDrop.disable();
$ul.find('input[type=checkbox]').attr('disabled', true);
break;
}
if (!changed(resource, used)) return;
var delta = used.length - $ul.children().length;
while (delta--) $ul.append('<li><label><input type="checkbox" /><span></span></label></li>');
while (++delta) $ul.children().first().remove();
used.forEach(function(name, index) {
var $li = $ul.children().eq(index);
var $label = $li.find('label');
var $chk = $label.find('input');
var $span = $label.find('span');
$chk.data('resource', name);
$chk.prop('checked', ~resource.indexOf(name));
$span.text(name);
var color = minder.getResourceColor(name);
$li.css({
color: color.dec('l', 60).toString(),
backgroundColor: ~resource.indexOf(name) ? color : color.dec('a', 0.85).toRGBA()
});
});
}
minder.on('interactchange', update);
return $resourcePanel;
});
\ No newline at end of file
/**
* @fileOverview
*
* Ribbon 选项卡
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/tabs', function(minder) {
var memory = minder.getUI('memory');
var $tab = new FUI.Tabs({
buttons: ['idea', 'appearence', 'view'].map(function(key) {
return minder.getLang('ui.tabs.' + key);
})
});
var $title = minder.getUI('topbar/title').$title;
var $header = $('<div id="tab-select"></div>');
var $container = $('<div id="tab-container"></div>');
$title.before($header);
$('#panel').after($container);
$tab.appendButtonTo($header[0]);
$tab.appendPanelTo($container[0]);
// 隐藏效果
var lastIndex = 0;
var muteRemember = false;
$tab.on('tabsselect', function(e, info) {
if (info.index == lastIndex) {
$container.toggleClass('collapsed');
$header.toggleClass('collapsed');
} else {
$container.removeClass('collapsed');
$header.removeClass('collapsed');
}
if (!muteRemember) {
memory.set('ribbon-tab-collapsed', $container.hasClass('collapsed'));
memory.set('ribbon-tab-index', info.index);
}
lastIndex = info.index;
});
$tab.idea = $tab.getPanel(0);
$tab.appearence = $tab.getPanel(1);
$tab.view = $tab.getPanel(2);
var rememberIndex = memory.get('ribbon-tab-index');
var rememberCollapse = memory.get('ribbon-tab-collapsed');
muteRemember = true;
$tab.select(rememberIndex || 0);
muteRemember = false;
if (rememberCollapse) {
$container.addClass('collapsed');
$header.addClass('collapsed');
} else {
$container.removeClass('collapsed');
$header.removeClass('collapsed');
}
return $tab;
});
\ No newline at end of file
/**
* @fileOverview
*
* 全屏无打扰模式
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/view/fullscreen', function(minder) {
var $commandbutton = minder.getUI('widget/commandbutton');
var $tabs = minder.getUI('ribbon/tabs');
var notice = minder.getUI('widget/notice');
var $fullscreenPanel = new FUI.LabelPanel({
label: minder.getLang('panels.level'),
column: true
}).appendTo($tabs.view);
var $fullscreenButton = $commandbutton
.generate('fullscreen', fullscreen)
.addClass('large')
.appendTo($fullscreenPanel);
function fullscreen() {
if ($('#content-wrapper').toggleClass('fullscreen').hasClass('fullscreen')) {
notice.info(minder.getLang('ui.fullscreen_exit_hint'), false, 4000);
}
}
minder.addShortcut('F11', fullscreen);
minder.addShortcut('Esc', function () {
if ($('#content-wrapper').hasClass('fullscreen')) {
$('#content-wrapper').removeClass('fullscreen');
}
});
return $fullscreenButton;
});
/**
* @fileOverview
*
* 切换展开层次
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('ribbon/view/level', function(minder) {
var $commandbutton = minder.getUI('widget/commandbutton');
var $tabs = minder.getUI('ribbon/tabs');
var $levelPanel = new FUI.LabelPanel({
label: minder.getLang('panels.level'),
column: true
}).appendTo($tabs.view);
['expandtoleaf', 'collapsetolevel1'].forEach(function(cmd) {
$commandbutton.generate(cmd).appendTo($levelPanel);
});
});
/**
* 页面下方 “关于” 面板的样式
*/
.fullscreen #about #km-cat {
transform: translate(0, 0);
transition: transform 0.7s 0.2s ease;
}
#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;
overflow: visible;
transition: all ease .3s 0.3s;
transform: translate(100%);
a {
color: #eee;
}
#km-cat {
position: absolute;
left: 15px;
top: 5px;
transition: all ease 1.3s 0.3s;
transform: translate(-60px, 0);
cursor: pointer;
}
#cat-face {
fill: #393F4F;
}
&:hover, &:hover #km-cat {
transform: translate(0);
}
#km-version.new-version{
position: relative;
padding-right: 30px;
&: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);
transform: scale(.6);
}
}
}
.command-buttonset.color-picker {
width: 100px;
.fui-toggle-button {
margin: 3px 3px 0 0 !important;
padding: 2px !important;
border-radius: 100%;
border: 1px solid #efefef;
background: transparent;
&.fui-button-pressed {
border: 1px solid @button-active;
background: #fafcff;
}
&:hover {
border: 1px solid #ccd0d3;
background: #fff;
}
.fui-label {
display: none;
}
.fui-icon {
width: 16px;
height: 16px;
border-radius: 100%;
}
}
}
\ 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
#font-panel {
.command-button {
padding: 0;
width: 20px;
height: 20px;
border: 1px solid transparent;
background: transparent;
&.active {
border: 1px solid #ccd0d3;
background: #fafcff;
}
&:hover {
border: 1px solid #ccd0d3;
background: #fff;
}
&:active {
background: darken(#fafcff, 5%);
}
border-radius: 11px;
margin-left: 5px;
margin-top: 2px;
margin-bottom: 2px !important;
.fui-label {
display: none;
}
}
}
\ No newline at end of file
#help-panel, #feedback-panel {
.dock(50px, 0, 0, 0);
overflow-y: auto;
h2 {
font-weight: normal;
color: @theme-color;
margin: 10px 0;
}
.shortcut-content {
font-family: 'Microsoft Yahei';
margin-left: 50px;
section {
min-width: 300px;
margin: 0 20px 20px 0;
float: left;
h3 {
border-bottom: 1px solid #EEE;
}
div.shortcut-group {
margin: 5px auto;
span.shortcut {
display: inline-block;
width: 220px;
text-align: right;
margin-right: 10px;
}
}
}
}
.contact-content {
list-style: none;
padding-left: 0;
li {
display: block;
float: left;
padding: 0;
width: 150px;
height: 150px;
margin: 20px;
text-align: center;
position: relative;
a {
-webkit-user-select: initial;
cursor: text;
color: @theme-color;
&[href] {
cursor: pointer;
}
}
&:before {
transition: all .3s ease;
opacity: 0.6;
content: ' ';
display: block;
width: 150px;
height: 150px;
background: white url(../images/feedback.png) no-repeat;
}
&:hover:before {
transform: translate3d(0, -5px, 0);
opacity: 1;
}
&.email:before {
background-position: -150px 0;
}
&.github:before {
background-position: -300px 0;
}
&.tieba:before {
background-position: -450px 0;
}
}
}
}
\ No newline at end of file
.command-button {
&.undo, &.redo {
float: left;
border: none;
width: @panel-height;
height: @panel-height;
line-height: @panel-height;
padding: 0;
margin: 0;
.fui-label {
display: none;
}
.fui-icon {
display: block;
width: @panel-height;
height: @panel-height;
background: url(../images/history.png) no-repeat;
}
&:hover {
background: @tab-hover;
.fui-icon {
background-position-y: -40px;
}
}
&:active {
background: @tab-active;
}
&.fui-disabled {
&:hover, &:active {
background: none;
}
.fui-icon {
background-position-y: 0;
}
}
}
&.undo {
}
&.redo {
.fui-icon {
background-position-x: -40px;
}
}
}
\ No newline at end of file
@iconsize: 20px;
.sprite(@index, @size:@iconsize) {
background-position: 0 (-@index * @iconsize);
}
.command-button .fui-icon {
background: url(../images/icons.png) no-repeat;
.sprite(-1);
.appendchildnode& { .sprite(0); }
.appendsiblingnode& { .sprite(1); }
.editnode& { .sprite(3); }
.removenode& { .sprite(4); }
.resetlayout& { background-position: 0 -150px; }
.clearstyle& { background-position: 0 -175px; }
.copystyle& { .sprite(10); }
.pastestyle& { .sprite(11); }
.bold& { .sprite(12); }
.italic& { .sprite(13); }
.arrangeup& { .sprite(14); }
.arrangedown& { .sprite(15); }
.expandtoleaf& { background-position: 0 -995px; }
.collapsetolevel1& { background-position: 0 -1015px;}
.fullscreen& { background-position: 0 -1035px;}
}
\ No newline at end of file
#img_panels {
margin: 0 auto;
border: 1px solid #EEE;
height: 400px;
position: relative;
clear: both;
z-index: 60;
padding: 20px 15px;
background: white;
}
#img_panels .fui-container {
display: block;
}
#img_panels .searchBar {
width: 100%;
height: 30px;
margin-bottom: 5px;
padding: 0px;
label {
vertical-align: middle;
display: inline-block;
height: 30px;
line-height: 30px;
}
}
#img_searchTxt {
width: 370px;
}
#img_searchBtn {
margin-left: 10px;
float: right;
}
#img_buttons {
height: 35px;
position: relative;
z-index: 70;
background: #fcfcfc;
overflow: visible;
}
#img_buttons .fui-button {
box-sizing: border-box;
height: 35px;
line-height: 35px;
padding: 0 15px;
border: 1px solid transparent;
text-align: center;
.fui-icon {display: none;}
.fui-label {
display: block;
height: 35px;
line-height: 35px;
}
&:hover {
background: none;
text-decoration: underline;
}
}
#img_buttons .fui-button.fui-selected {
background: #fff;
border-color: #eee #eee white #eee;
height: 36px;
&:hover {
text-decoration: none;
}
}
#img_searchList {
height: 370px;
overflow: hidden;
clear: both;
}
#img_searchListUl {
margin: 0;
padding: 0;
list-style: none;
clear: both;
height: 100%;
overflow-x: hidden;
overflow-y: auto;
zoom: 1;
position: relative;
}
#img_searchListUl li {
list-style: none;
float: left;
display: block;
width: 115px;
height: 115px;
line-height: 115px;
margin: 6px;
padding: 0;
font-size: 12px;
position: relative;
vertical-align: top;
text-align: center;
overflow: hidden;
cursor: pointer;
border: 2px solid #fcfcfc;
img {
max-width: 111px;
max-height: 115px;
vertical-align: middle;
}
span {
display: block;
position: absolute;
bottom: 0;
height: 20px;
background: rgba(0, 0, 0, .5);
left: 0;
right: 0;
color: white;
line-height: 20px;
overflow: hidden;
text-overflow: ellipsis;
word-break: break-all;
white-space: nowrap;
opacity: 0;
transform: translate(0, 20px);
transition: all .2s ease;
}
&:hover span {
opacity: 1;
transform: translate(0, 0);
}
}
#img_searchListUl li.selected {
border: 2px solid @theme-color;
}
#img_searchListUl li p{
background-color: #eee;
margin: 0;
padding: 0;
position: relative;
width: 100%;
height: 115px;
overflow: hidden;
}
#img_searchListUl li a {
color: #999;
border-top: 1px solid #F2F2F2;
background: #FAFAFA;
text-align: center;
display: block;
padding: 0 5px;
width: 105px;
height: 32px;
line-height: 32px;
white-space: nowrap;
text-overflow: ellipsis;
text-decoration: none;
overflow: hidden;
word-break: break-all;
}
/**
* 基本页面样式
*/
html, body, div {
margin: 0;
padding: 0;
overflow: hidden;
}
body, svg {
font-family: "Microsoft Yahei", "Heiti SC", Arial, sans-serif;
}
html, body {
height: 100%;
}
#content-wrapper {
overflow: hidden;
.dock;
position: fixed;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
-webkit-user-drag: none;
cursor: default;
}
#kityminder {
.dock(100px, 0, 0, 0);
&.maximize {
top: 40px;
}
&:focus {
/* box-shadow: inset 0 0 10px fadeOut(black, 0.5); */
}
-moz-user-select: none;
}
#tab-container.collapsed + #kityminder,
#panel + #kityminder{
top: 40px;
}
.fullscreen #panel {
transform: translate(0, -101px);
}
.fullscreen #kityminder {
top: 0 !important;
}
#panel {
background: @ui-color;
font-family: 'Hiragino Sans GB', 'Arial', 'Microsoft Yahei';
height: @panel-height;
overflow: hidden;
-webkit-backface-visibility: hidden;
position: relative;
transition: transform .7s ease;
z-index: 11;
h1 {
font-size: 14px;
height: @panel-height;
line-height: @panel-height;
margin: 0;
text-align: center;
font-weight: normal;
color: @ui-fore;
vertical-align: middle;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
span {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
input {
outline: none;
font-size: 14px;
border: none;
border-radius: 2px;
box-shadow: 0 0 3px black;
padding: 3px 2px 3px 5px;
background: white;
}
&.rename-enabled{
cursor: text;
&:after {
content: ' ';
width: 20px;
height: 20px;
display: inline-block;
background: url(../images/icons.png) 1px -1110px;
vertical-align: middle;
position: relative;
top: -1px;
margin-left: 5px;
opacity: 0;
transition: opacity ease .3s;
}
}
&.rename-enabled:hover:after {
opacity: 0.6;
}
&.loading {
&:before {
position: relative;
display: inline-block;
.loading-circle(12px, 3px);
left: -6px;
top: 3px;
box-shadow: none;
}
&:after {
display: none;
}
}
}
}
.fui-widget {
-webkit-font-smoothing: auto;
}
\ No newline at end of file
.local-file-open-panel {
position: relative;
& > h2 {
&:before {
content: ' ';
display: block;
width: 25px;
height: 25px;
position: absolute;
left: 0;
background: url(../images/icons.png) no-repeat 0 -495px;
}
}
.pick-file {
padding: 10px 0;
a {
.button;
margin: 0 10px 10px 0;
}
span {
line-height: 30px;
}
}
.drop-file {
border: 2px dashed #eee;
border-radius: 4px;
height: 100px;
width: 100px;
text-align: center;
font-size: 16px;
color: #CCC;
margin: 150px auto;
transition: all .1s ease;
span {
display: block;
margin-top: 25px;
padding: 0 15px;
}
&.accept {
border-color: lighten(@tab-active, 40%);
transform: scale(1.2);
}
&.deny {
border-color: #eee;
color: #eee;
}
}
}
\ No newline at end of file
#main-menu-btn {
display: block;
float: left;
height: @panel-height;
line-height: @panel-height;
padding: 0 30px 0 15px;
z-index: 11;
background-color: @main-menu-theme-color;
&:hover {
background-color: lighten(@main-menu-theme-color, 5%) !important;
}
&:active {
background-color: darken(@main-menu-theme-color, 5%) !important;
}
.fui-label {
height: @panel-height;
line-height: @panel-height;
font-size: 14px;
color: white;
}
&:after {
content: ' ';
display: block;
position: absolute;
width: 0;
height: 0;
line-height: 0;
font-size: 0;
border: 6px solid;
border-color: white transparent transparent transparent;
right: 12px;
top: @panel-height / 2 - 4;
}
}
#main-menu {
@left-width: 150px;
background: white;
.dock;
overflow: hidden;
transform: translate3d(0, -100%, 0);
transform-origin: 0 0;
opacity: 0;
-webkit-transition: opacity .2s ease, -webkit-transform .2s ease;
transition: opacity .2s ease, transform .2s ease;
z-index: 100;
&.show {
opacity: 1;
transform: translate3d(0, 0, 0);
}
.slide-in() {
transform: translateX(-(@left-width)) translateZ(0);
-webkit-transition: -webkit-transform .7s ease, opacity .5s ease;
transition: transform .7s ease, opacity .5s ease;
.show& {
transform: translateX(0) translateZ(0);
-webkit-transition: -webkit-transform .7s ease, opacity .5s ease;
transition: transform .7s ease, opacity .5s ease;
}
}
&:before {
content: ' ';
display: block;
position: absolute;
top: 0;
left: @left-width;
right: -1000px;
bottom: 10px;
box-shadow: 0 -3px 8px rgba(0,0,0,.15);
z-index: 1;
.slide-in;
}
.main-menu- {
&header {
background: white;
height: @panel-height;
}
&back-panel {
background-color: @main-menu-theme-color;
float: left;
width: @left-width;
height: @panel-height;
.main-menu-back-button {
.fui-label {
display: inline-block;
color: white;
margin-left: 10px;
font-size: 14px;
display: none;
}
.fui-icon {
display: inline-block;
width: 25px;
height: 25px;
line-height: 25px;
border-radius: 100%;
border: 2px solid white;
background: url(../images/icons.png) -1px -370px;
vertical-align: middle;
}
width: @left-width - 10px;
height: @panel-height - 10px;
padding: 5px;
&:hover {
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: darken(@main-menu-theme-color, 10%);
}
}
}
&title {
margin-left: @left-width;
height: @panel-height;
display: block;
background: white;
z-index: 2;
text-align: center;
font-size: 12px;
font-weight: normal;
line-height: @panel-height;
color: #999;
.slide-in;
}
&level1 {
position: absolute;
left: 0;
right: 0;
bottom: 0;
top: @panel-height;
& > .fui-tabs- {
&button-wrap {
.dock(0, auto, 0, 0);
width: @left-width;
position: absolute;
background-color: @main-menu-theme-color;
.fui-button {
display: block;
text-align: right;
height: 50px;
.fui-label {
height: 50px;
line-height: 50px;
color: white;
padding-right: 20px;
font-size: 16px;
}
&:hover {
background: darken(@main-menu-theme-color, 5%);
}
&:active {
background: darken(@main-menu-theme-color, 10%);
}
&.fui-selected {
background: lighten(@main-menu-theme-color, 10%);
}
}
}
/* 二级菜单区域 */
&panel-wrap {
.dock(0, 0, 0, @left-width);
background-color: white;
z-index: 2;
.slide-in;
/* 每个二级菜单的面板 */
& > .fui-panel {
.dock(0, @panel-height);
/* 面板内容 */
& > .fui-panel-content {
.dock;
/* 二级菜单大标题 */
& > h2 {
font-size: 24px;
font-weight: normal;
margin-top: 0;
margin-bottom: 20px;
color: @main-menu-fore-color;
}
/* 二级菜单导航 */
& > .fui-tabs {
.dock;
/* 二级导航菜单区域 */
& > .fui-tabs-button-wrap {
.dock(60px, auto, 30px, 0);
display: block;
width: 180px;
border-right: 1px solid lighten(@tab-active, 50%);
& > .fui-button {
display: block;
height: 50px;
line-height: 50px;
text-align: right;
padding-right: 20px;
& > .fui-label {
font-size: 14px;
line-height: 50px;
color: @main-menu-fore-color;
}
&:hover {
background-color: lighten(@tab-hover, 40%);
& > .fui-label {
}
}
&.fui-selected {
background-color: lighten(@tab-active, 20%);
& > .fui-label {
color: white;
}
}
}
}
/* 二级菜单内容区域 */
& > .fui-tabs-panel-wrap {
.dock(60px, 0, 30px, 200px);
& > .fui-panel {
display: block;
.dock;
& > .fui-panel-content {
.dock;
display: block;
h2 {
padding-bottom: 10px;
height: 30px;
line-height: 30px;
border-bottom: 1px solid hsl(0, 0%, 93%);
font-size: 18px;
font-weight: normal;
margin: 0;
padding-left: 38px;
}
}
}
}
}
}
animation: slideRight 0.3s ease;
animation-fill-mode: backward;
animation-direction: reverse;
&.fui-hide {
animation-fill-mode: forward;
animation-direction: normal;
}
}
}
}
}
}
}
@keyframes slideLeft {
}
@keyframes slideRight {
0% {
transform: translate(0, 0);
opacity: 1;
display: block !important;
}
100% {
transform: translate(50px, 0);
opacity: 0;
display: none !important;
}
}
\ No newline at end of file
.new-file-template-select {
margin: 0;
padding: 0;
list-style: none;
li {
display: inline-block;
position: relative;
width: 120px;
height: 120px;
margin-right: 20px;
margin-bottom: 20px;
cursor: pointer;
a {
display: block;
text-align: center;
position: absolute;
bottom: 0;
left: 0;
right: 0;
}
&:before {
content: ' ';
display: block;
position: absolute;
.dock(0, 0, 24px, 0);
border: 1px solid #ddd;
}
&:after {
content: ' ';
display: block;
position: absolute;
width: 100px;
height: 80px;
left: 50%;
top: 10px;
margin-left: -50px;
background: url(../images/template_large.png) no-repeat;
}
&.default:after {
background-position: 0 0;
}
&.structure:after {
background-position: -100px 0;
}
&.filetree:after {
background-position: -200px 0;
}
&.right:after {
background-position: -300px 0;
}
&.fish-bone:after {
background-position: -400px 0;
}
&:hover {
a {
color: @main-menu-theme-color;
}
&:before {
border: 1px solid @main-menu-theme-color;
}
}
&:active:before {
background-color: lighten(@main-menu-theme-color, 20%);
}
}
}
\ No newline at end of file
.fullscreen .preview-navigator {
transform: translate(-45px, 30px);
}
.preview-navigator {
background: white;
width: 140px;
height: 120px;
position: absolute;
left: 45px;
bottom: 30px;
box-shadow: 0 0 8px rgba(0, 0, 0, .2);
border-radius: 0 2px 2px 0;
padding: 1px;
z-index: 9;
cursor: crosshair;
transition: transform .7s 0.1s ease;
&.grab {
cursor: move;
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
cursor: grabbing;
}
}
.fullscreen .nav-bar {
transform: translate(-60px, 0);
}
.nav-bar {
position: absolute;
width: 35px;
height: 240px;
padding: 5px 0;
left: 10px;
bottom: 10px;
background: @theme-color;
border-radius: 4px;
z-index: 10;
box-shadow: 3px 3px 10px rgba(0, 0, 0, .2);
transition: transform .7s 0.1s ease;
.command-button {
width: 35px;
height: 24px;
text-align: center;
line-height: 30px;
.fui-label {
display: none;
}
.fui-icon {
background: url(../images/icons.png);
width: 20px;
height: 20px;
margin: 2px auto;
display: block;
}
&:hover {
background: lighten(@theme-color, 10%);
}
&:active {
background: darken(@theme-color, 3%);
}
&.active {
background: #5A6378;
}
&.hand, &.nav-trigger, &.camera {
height: 25px;
margin: 3px 0;
.fui-icon {
margin: 0 auto;
width: 25px;
height: 25px;
}
}
&.zoom-in .fui-icon {
background-position: 0 -730px;
}
&.zoom-out .fui-icon {
background-position: 0 -750px;
}
&.hand {
margin-top: 10px;
.fui-icon {
background-position: 0 -770px;
}
&.active .fui-icon {
background-position: 0 -795px;
}
}
&.nav-trigger {
.fui-icon {
background-position: 0 -820px;
}
&.active .fui-icon {
background-position: 0 -845px;
}
}
&.camera {
.fui-icon {
background-position: 0 -870px;
}
margin-bottom: 0;
}
}
.zoom-pan {
width: 2px;
height: 70px;
box-shadow: 0 1px #E50000;
position: relative;
background: white;
margin: 3px auto;
overflow: visible;
.origin {
position: absolute;
width: 20px;
height: 8px;
left: -9px;
margin-top: -4px;
background: transparent;
&:after {
content: ' ';
display: block;
width: 6px;
height: 2px;
background: white;
left: 7px;
top: 3px;
position: absolute;
}
&:hover:after {
box-shadow: 0 0 5px rgba(255, 255, 255, 1);
}
}
.indicator {
position: absolute;
width: 8px;
height: 8px;
left: -3px;
background: white;
border-radius: 100%;
margin-top: -4px;
}
}
}
\ No newline at end of file
@keyframes shake {
0% { transform: translate(0, 0); }
15% { transform: translate(-2px, -2px); }
35% { transform: translate(2px, -2px);}
65% { transform: translate(-2px, 2px); }
85% { transform: translate(2px, 2px); }
100% { transform: translate(0, 0); }
}
@keyframes shake-left-right {
0% { transform: translate(0, 0); }
25% { transform: translate(-3px, 0); }
75% { transform: translate(3px, 0); }
100% { transform: translate(0, 0); }
}
.netdisk-finder {
.dir.drag-enter {
border: 1px dashed #717B94 !important;
background: #F9F9F9;
}
&.drop-mode {
.dir {
animation: shake .3s ease;
}
.recycle {
animation: shake .3s ease;
}
}
&.recycle-bin {
.head .control {
.button.mkdir {
display: none;
}
.button.recycle {
display: none;
}
.button.recycle-clear {
display: block;
}
}
.file-list .file-list-item.dir:after {
display: none;
}
}
.head {
padding-bottom: 10px;
height: 30px;
border-bottom: 1px solid #eee;
.control {
float: right;
.button {
vertical-align: middle;
font-size: 0;
background: url(../images/finder.svg) no-repeat;
width: 30px;
height: 30px;
border-radius: 2px;
box-sizing: border-box;
border: 1px solid transparent;
&:hover {
border: 1px solid lighten(#717B94, 30%);
}
&:active {
box-shadow: inset 0 1px 3px fadeOut(#717B94, 80%);
}
&.recycle {
background-position: -30px 0;
&.drag-enter {
background-position: -60px 0 !important;
}
}
&.recycle-clear {
display: none;
background-position: -90px 0;
}
}
}
.nav {
font-size: 18px;
span, a {
display: inline-block;
height: 20px;
line-height: 20px;
padding: 5px 10px;
margin: 0 3px 0 0;
cursor: default;
vertical-align: middle;
}
span.my-document {
width: 25px;
height: 25px;
padding: 0;
text-indent: -1000px;
position: relative;
top: -2px;
background: url(../images/icons.png) 0 -470px;
}
a.dir-back {
border-radius: 100%;
width: 23px;
height: 23px;
padding: 0;
border: 1px solid @ui-color;
text-indent: -1000px;
position: relative;
top: -1px;
background: url(../images/icons.png) -2px -396px no-repeat;
}
span.spliter {
.triangle-left(black,4px,8px);
display: inline-block;
margin-left: 4px;
}
a {
border: 1px solid transparent;
&:hover {
background-color: lighten(@tab-hover, 55%);
}
&:active {
background-color: lighten(@tab-active, 55%)
}
}
}
}
.file-list {
.dock(41px, 0, 0, 0);
margin: 0;
padding: 0;
list-style: none;
overflow: auto;
overflow-x: hidden;
.empty {
height: 50px;
line-height: 50px;
text-align: center;
font-size: 18px;
color: #ccc;
}
.file-list-item {
font-size: 14px;
height: 20px;
line-height: 20px;
padding: 10px 20px 10px 40px;
cursor: default;
-webkit-user-drag: element;
-khtml-user-drag: element;
border: 1px solid transparent;
.rename-button {
display: inline-block;
width: 20px;
height: 20px;
margin-left: 10px;
vertical-align: middle;
border-radius: 2px;
box-sizing: border-box;
border: 1px solid transparent;
opacity: 0;
transition: transform,opacity ease .2s;
transform: scale(0);
font-size: 0;
&:hover {
border: 1px solid lighten(#717B94, 30%);
}
&:active {
box-shadow: inset 0 1px 3px fadeOut(#717B94, 80%);
}
}
.filename {
height: 20px;
line-height: 20px;
vertical-align: middle;
}
input {
margin: 0;
outline: none;
width: 61.80%;
-moz-user-select: default;
}
&:hover {
.rename-button {
transition: transform,opacity ease .2s .5s;
transform: scale(1);
opacity: 1;
background: url(../images/icons.png) 1px -1130px;
}
}
&.selected {
&:hover .rename-button {
background: url(../images/icons.png) 1px -1110px;
}
background-color: lighten(@tab-active, 20%);
color: white;
&.dir .icon {
background: lighten(@tab-active, 20%) url(../images/icons.png) 0 -1085px;
}
&.dir:after {
border-left-color: white;
}
&.file .icon {
background: lighten(@tab-active, 20%) url(../images/icons.png) 0 -545px;
}
}
&.dragging {
border: 1px solid #717B94;
}
&.file {
position: relative;
.icon {
display: block;
position: absolute;
width: 25px;
height: 25px;
left: 5px;
top: 7px;
background: url(../images/icons.png) 0 -445px no-repeat;
}
}
&.renaming {
input.invalid-name {
animation: shake-left-right .3s ease;
}
.rename-button {
display: none !important;
}
}
&.dir {
position: relative;
.icon {
display: block;
position: absolute;
width: 25px;
height: 25px;
left: 5px;
top: 7px;
background: url(../images/icons.png) 0 -420px no-repeat;
}
&:after {
.triangle-left(black,4px,8px);
position: absolute;
right: 5px;
top: 20px;
margin-top: -4px;
}
}
}
}
}
.netdisk-open-panel .netdisk-finder {
.dock;
}
.netdisk-save-panel .netdisk-finder {
.dock(0, 0, 50px, 0);
}
// for save
.netdisk-save-panel .netdisk-file-list {
bottom: 50px;
}
.netdisk-save-select {
.dock(auto, 0, 0, 0);
height: auto;
padding: 10px;
border-top: 1px solid #EEE;
background: #fcfcfc;
label {
display: inline-block;
padding: 0 10px 0 0;
vertical-align: middle;
margin-top: 5px;
}
& > input {
width: 50%;
margin: 0;
margin-top: 5px;
margin-right: 10px;
vertical-align: middle;
}
& > select {
margin: 5px 0 0 0;
outline: none;
vertical-align: middle;
}
& > .save-button {
float: right;
width: 80px;
vertical-align: middle;
}
}
\ No newline at end of file
.notice-widget {
position: absolute;
right: 20px;
top: 20px;
padding: 5px 15px;
border-radius: 4px;
background: fadeOut(lighten(@tab-hover, 20%), 20%);
transition: all ease .2s;
opacity: 0;
color: white;
z-index: 101;
transform: translate3d(0, -50px, 0);
p {
margin: 5px 0;
font-size: 12px;
}
&.show {
transform: translate3d(0, 0, 0);
opacity: 1;
}
&.warn {
background: white url(../images/kmcat_warn.png) 8px 10px no-repeat;
color: rgb(255, 146, 0);
box-shadow: none;
padding-left: 35px;
border: 1px solid #FFB200;
}
}
#content-wrapper .error-dialog {
border-radius: 4px;
.fui-dialog-head {
background: #DC0000;
height: 40px;
line-height: 40px;
padding: 0 15px;
.fui-close-button {
top: 10px;
}
}
.fui-dialog-body {
.error-content {
background: url(../images/kmcat_sad.png) no-repeat;
padding-left: 80px;
h3 {
font-size: 16px;
font-weight: normal;
margin: 0;
}
p {
margin: 10px 0;
height: auto;
}
min-height: 80px;
}
.error-detail {
position: relative;
a.expander {
display: block;
&:before {
.triangle-left(#333, 5px, 10px);
display: inline-block;
margin-right: 3px;
}
margin: 8px 0;
cursor: pointer;
&:hover {
text-decoration: underline;
}
}
&.expanded {
.error-detail-wrapper {
display: block;
}
a.expander:before {
.triangle-top(#333, 10px, 5px);
margin-right: 3px;
top: 3px;
position: relative;
display: inline-block;
}
}
&:before {
display: block;
content: '反馈详细信息有助于开发人员定位问题';
position: absolute;
top: 8px;
right: 0;
font-size: 12px;
color: #AAA;
}
.error-detail-wrapper {
display: none;
textarea {
box-sizing: border-box;
width: 100%;
height: 200px;
border: 1px solid #EEE;
background: #fcfcfc;
outline: none;
padding: 6px;
color: #666;
}
.copy-and-feedback {
float: right;
margin-top: 10px;
}
}
}
}
.fui-dialog-foot {
position: static;
padding: 5px 20px;
.fui-button.fui-xdialog-ok-btn {
background: #dc0000;
margin: 10px 0;
&:hover {
background: #FF7F7F;
}
}
.fui-button.fui-xdialog-cancel-btn {
display: none;
}
}
}
\ No newline at end of file
.priority-sprite(@count) when (@count >= 0) {
.priority-sprite(@count - 1);
&.priority-@{count} .fui-icon {
background-position: 0 (-20px * (@count - 1));
}
}
#tab-container .command-buttonset.priority {
width: 130px;
.fui-button {
width: 20px;
height: 20px;
margin: 1px;
.fui-label {
display: none;
}
.fui-icon {
display: block;
height: 20px;
width: 20px;
background: url(../images/iconpriority.png) repeat-y;
background-color: transparent;
}
padding: 2px;
border-radius: 4px;
.priority-sprite(9);
&.fui-button-pressed {
background-color: @button-active;
}
}
}
\ No newline at end of file
.progress-sprite(@count) when (@count >= 0) {
.progress-sprite(@count - 1);
&.progress-@{count} .fui-icon {
background-position: 0 (-20px * (@count - 1));
}
}
#tab-container .command-buttonset.progress {
width: 130px;
.fui-button {
width: 20px;
height: 20px;
margin: 1px;
.fui-label {
display: none;
}
.fui-icon {
display: block;
height: 20px;
width: 20px;
background: url(../images/iconprogress.png) repeat-y;
background-color: transparent;
}
padding: 2px;
border-radius: 4px;
.progress-sprite(9);
&.fui-button-pressed {
background-color: @button-active;
}
}
}
\ No newline at end of file
.animation(@value) {
-webkit-animation: @value;
-moz-animation: @value;
-ms-animation: @value;
-o-animation: @value;
animation: @value;
}
.blur {
filter: url(../images/blur.svg#blur);
-webkit-filter: blur(5px);
-moz-filter: blur(5px);
-mz-filter: blur(5px);
-o-filter: blur(5px);
filter: blur(5px);
}
.dock(@top: 0, @right: @top, @bottom: @top, @left: @right) {
position: absolute;
top: @top;
right: @right;
bottom: @bottom;
left: @left;
}
.validate-error {
color: red;
border-color: red !important;
vertical-align: middle;
}
span.validate-error {
margin-left: 5px;
}
.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;
box-sizing: content-box;
}
input[type=text],
input[type=url] {
padding: 2px 5px;
height: 16px;
line-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-circle(@size: 40px, @border-size: 4px) {
width: @size;
height: @size;
border: @border-size solid;
border-color: @border-color transparent transparent;
box-shadow: 0 0 (@size - 5px) white;
z-index: 10;
border-radius: 100%;
.animation(rotate 1.33s ease infinite);
filter: none;
-webkit-filter: none;
}
.loading(@color: rgb(128, 130, 140), @border-color: #fff) {
.loading-target {
.blur;
}
&:after {
content: ' ';
display: block;
.dock;
background: fadeOut(@color, 25%);
.animation(fadeIn 3s ease);
}
&:before {
content: ' ';
.loading-circle;
position: absolute;
left: 50%;
top: 50%;
margin-left: -24px;
margin-top: -24px;
}
}
.loading {
.loading();
}
@-webkit-keyframes rotate {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
@keyframes rotate {
from {
transform: rotate(0);
}
to {
transform: rotate(360deg);
}
}
@-webkit-keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
@-webkit-keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; }
}
@keyframes fadeOut {
from { opacity: 1; }
to { opacity: 0; }
}
.shortcut-key {
display: inline-block;
padding: 3px 8px 5px;
font-size: 12px;
font-weight: normal;
line-height: 14px;
color: hsl(0, 0%, 43%);
/* text-shadow: 0px -1px 0px rgba(0, 0, 0, 0.25); */
white-space: nowrap;
vertical-align: middle;
background-color: hsl(0, 0%, 99%);
border-radius: 3px;
border: 1px solid hsl(0, 0%, 80%);
text-transform: capitalize;
box-shadow: inset 0 -2px hsl(0, 0%, 92%), inset 0 -3px hsl(0, 100%, 100%), 0 1px 2px rgba(255, 255, 255, 0.3);
&:active {
padding-top: 4px;
padding-bottom: 4px;
box-shadow: inset 0 -1px hsl(0, 0%, 92%), inset 0 -2px hsl(0, 100%, 100%), 0 1px 1px rgba(255, 255, 255, 0.3);
&:after {
transform: translate(0, 1px);
}
}
.mac &.ctrl,
.mac &.shift,
.mac &.alt,
&.up,
&.down,
&.left,
&.right {
text-indent: 99999px;
position: relative;
width: 9px;
&:after {
display: block;
position: absolute;
text-align: center;
left: 5px;
top: 4px;
width: 16px;
height: 16px;
text-indent: 0;
}
}
.mac &.ctrl:after {
content: '⌘';
}
.mac &.shift:after {
content: '⇧';
}
.mac &.alt:after {
content: '⌥';
}
&.up:after {
content: '↑';
top: 2px;
}
&.down:after {
content: '↓';
top: 2px;
}
&.left:after {
content: '←';
top: 2px;
}
&.right:after {
content: '→';
top: 2px;
}
}
#panel .quick-visit-button {
float: left;
border: none;
width: 40px;
height: 40px;
line-height: 40px;
padding: 0;
margin: 0;
display: block;
position: relative;
&:after {
content: ' ';
position: absolute;
display: block;
width: 25px;
height: 25px;
left: 7.5px;
top: 5.5px;
background: url(../images/icons.png) no-repeat;
}
text-indent: -10000px;
&.new {
&:after {
background-position: 0 -895px;
}
}
&.save {
&:after {
background-position: 0 -920px;
}
}
&.share {
&:after {
background-position: 0 -945px;
}
}
&.feedback {
float: right;
margin-right: 5px;
&:after {
top: 6.5px;
left: 7px;
background-position: 0 -970px;
}
}
&.editshare {
margin-right: 5px;
float: right;
&:after {
top: 6.5px;
left: 7px;
background-position: 0 -1060px;
}
}
&:hover {
background-color: @tab-hover;
}
&:active {
background-color: @tab-active;
}
&:first-child {
margin-left: 5px;
}
}
\ No newline at end of file
.km_receiver{
width:0;
height:0;
}
\ No newline at end of file
.recent-file-panel {
h2 {
&:before {
content: ' ';
display: block;
width: 25px;
height: 25px;
position: absolute;
left: 0;
top: 2px;
background: url(../images/icons.png) no-repeat 0 -520px;
}
}
& > .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;
padding: 10px 20px 10px 40px;
cursor: default;
position: relative;
&:hover {
background-color: lighten(@tab-hover, 55%);
}
&:active {
background-color: lighten(@tab-hover, 50%);
}
.file-name {
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-title {
margin: 0;
margin-top: 5px;
font-size: 12px;
color: #999;
}
.file-time {
position: absolute;
right: 5px;
top: 10px;
font-size: 12px;
color: #999;
}
}
}
}
\ No newline at end of file
#resource-panel > .fui-panel-content > .fui-label-panel-content {
position: relative;
& > .fui-input {
width: 140px;
margin: 2px 0 0;
vertical-align: middle;
box-sizing: content-box;
}
& > .fui-button {
left: auto;
right: 6px;
top: 8px;
padding: 1px 3px;
vertical-align: middle;
position: absolute;
}
& > .fui-drop-panel {
display: block;
height: 25px;
margin-top: -1px;
width: 140px;
}
}
#image-button-menu .fui-button:first-child {
background-image: url(../images/icons.png);
background-position: center -125px;
background-repeat: no-repeat;
}
#link-button-menu .fui-button:first-child {
background-image: url(../images/icons.png);
background-position: center -100px;
background-repeat: no-repeat;
}
ul.resource-list {
margin: 0;
padding: 0;
list-style: none;
width: 150px;
li {
display: inline-block;
padding: 1px 2px;
border-radius: 4px;
margin: 3px;
}
}
\ No newline at end of file
#search {
float: right;
position: relative;
&:after {
content: ' ';
display: block;
position: absolute;
width: 24px;
height: 24px;
left: 5px;
top: 7px;
background: url(../images/icons.png) no-repeat 0 -345px;
}
input[type=search] {
background: @tab-hover;
border: none;
height: 20px;
line-height: 1em;
border-radius: 15px;
outline: none;
color: @ui-fore;
padding: 5px 10px 5px 30px;
box-sizing: content-box;
margin-top: 5px;
margin-right: 3px;
width: 30px;
-webkit-appearance: none;
transition: width .5s ease;
transform: translateZ(0);
&:focus {
width: 150px;
}
}
}
\ No newline at end of file
#current-share-header {
&:before {
content: ' ';
display: block;
width: 25px;
height: 25px;
position: absolute;
left: 0;
top: 1px;
background: url(../images/icons.png) no-repeat 0 -645px;
}
}
#manage-share-header {
&:before {
content: ' ';
display: block;
width: 25px;
height: 25px;
position: absolute;
left: 0;
top: 1px;
background: url(../images/icons.png) no-repeat 0 -620px;
}
}
#manage-share-list {
margin: 0;
padding: 0;
list-style: none;
.dock(40px, 0, 0, 0);
overflow: auto;
overflow-x: hidden;
overflow-y: auto;
padding-right: 10px;
&:empty:after {
content: '没有分享';
display: block;
text-align: center;
font-size: 18px;
height: 50px;
line-height: 50px;
color: #CCC;
}
.share-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%);
}
.title {
display: block;
margin: 0;
font-weight: normal;
height: 20px;
line-height: 20px;
overflow: ellipse;
&:after {
content: ' ';
display: block;
position: absolute;
width: 25px;
height: 25px;
background: url(../images/icons.png) no-repeat 0 -445px;
left: 5px;
top: 10px;
}
}
.url {
display: block;
margin: 0;
margin-top: 5px;
font-size: 12px;
color: #999;
}
.ctime {
position: absolute;
right: 5px;
top: 10px;
font-size: 12px;
color: #999;
}
.view-action, .remove-action, .edit-action {
display: none;
float: right;
width: 18px;
height: 18px;
background: url(../images/icons.png) no-repeat;
position: relative;
margin-left: 5px;
left: 15px;
top: -20px;
border: 1px solid transparent;
border-radius: 2px;
text-indent: -99999px;
&:hover {
border: 1px solid #888;
box-shadow: inset 0 8px 1px rgba(255,255,255,0.3),
inset 0 0 3px rgba(0, 0, 0, 0.2);
}
&:active {
box-shadow: inset 0 7px 3px rgba(0,0,0,0.05),
inset 0 0 4px rgba(0, 0, 0, 0.3);
}
}
.view-action {
background-position: -1px -670px;
}
.remove-action {
background-position: 0 -690px;
}
.edit-action {
background-position: 0 -710px;
}
&:hover {
.view-action, .remove-action, .edit-action {
display: block;
}
}
}
}
#share-select {
margin-top: 10px;
fieldset {
border: 1px solid #f0f0f0;
margin: 0;
margin-bottom: 10px;
padding: 10px;
border-radius: 2px;
legend {
font-size: 14px;
}
&:disabled {
opacity: 0.5;
}
.share-description {
}
.share-body {
margin-top: 10px;
.share-qr-code img {
margin: 20px 0;
}
}
}
}
#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;
}
}
.shared-content {
& > .left, & > .right {
float: left;
}
.m-logo {
float: left;
margin-top: 4px;
margin-left: 8px;
}
.switch-view {
float: right;
font-size: 14px;
height: 40px;
line-height: 40px;
margin-right: 8px;
text-align: center;
font-weight: normal;
color: #ffffff;
}
.cur-list, .cur-root {
position: relative;
margin: 0;
padding: 0;
}
.cur-list {
list-style-type: none;
overflow-y: scroll;
}
.cur-list li, .cur-root {
line-height: 50px;
height: 50px;
padding-left: 25px;
border-bottom: 1px solid #ddd;
}
.cur-root {
background-color: #fc8383;
font-size: 16px;
padding-left: 15px;
border-bottom: none;
.dock;
}
.priority {
height: 20px;
width: 20px;
background: url(../images/iconpriority.png) repeat-x;
float: left;
margin: 15px 15px auto 0;
}
.priority-1 {
background-position: 0 0;
}
.priority-2 {
background-position: -20px 0;
}
.priority-3 {
background-position: -40px 0;
}
.priority-4 {
background-position: -60px 0;
}
.priority-5 {
background-position: -80px 0;
}
.priority-6 {
background-position: -100px 0;
}
.priority-7 {
background-position: -120px 0;
}
.priority-8 {
background-position: -140px 0;
}
.priority-9 {
background-position: -160px 0;
}
.priority-0 {
background-position: -180px 0;
}
.progress {
height: 20px;
width: 20px;
background: url(../images/iconprogress.png) repeat-x;
float: left;
margin: 15px 15px auto 0;
}
.progress-1 {
background-position: 0 0;
}
.progress-2 {
background-position: -20px 0;
}
.progress-3 {
background-position: -40px 0;
}
.progress-4 {
background-position: -60px 0;
}
.progress-5 {
background-position: -80px 0;
}
.progress-6 {
background-position: -100px 0;
}
.progress-7 {
background-position: -120px 0;
}
.progress-8 {
background-position: -140px 0;
}
.progress-9 {
background-position: -160px 0;
}
.progress-0 {
background-position: -180px 0;
}
.resource {
padding: 3px 5px;
border-radius: 2px;
font-size: 12px;
line-height: 16px;
color: rgb(77, 65, 0);
vertical-align: middle;
margin: 14px 8px;
float: right;
}
.hyperlink {
display: block;
float: right;
width: 30px;
height: 20px;
margin: 15px;
padding: 0;
background: url(../images/icons.png) no-repeat 0 -80px;
background-size: 20px;
vertical-align: middle;
}
.next-level {
width: 32px;
height: 50px;
margin-right: 16px;
float: right;
background: url(../images/next-level.png) no-repeat center center;
}
#km-list-view {
.dock(40px, 0, 0, 0);
overflow: visible;
}
.cur-list {
.dock(50px, 0, 0, 0);
}
.back {
width: 32px;
height: 32px;
background: url(../images/prev-level.png) no-repeat center center;
display: none;
}
.clickable:hover {
background-color: #eee;
}
.clickable:active {
background-color: #eee;
}
#km-list-view > div {
.dock;
}
.text {
display: block;
white-space: nowrap;
text-overflow: ellipsis;
-o-text-overflow: ellipsis;
overflow: hidden;
vertical-align: middle;
}
.cur-root .text {
color: white;
}
}
\ No newline at end of file
#tab-select {
height: @panel-height;
line-height: @panel-height;
min-width: 200px;
margin-left: 10px;
float: left;
.fui-button {
width: 60px;
height: @panel-height;
line-height: @panel-height;
text-align: 50px;
display: inline-block;
&:hover {
background: @tab-hover !important;
}
&:active {
background: @tab-active !important;
}
.fui-icon {
display: none;
}
.fui-label {
height: @panel-height;
line-height: @panel-height;
text-align: center;
display: block;
color: hsl(224, 6%, 80%);
font-size: 14px;
&:hover {
background: @tab-hover;
}
&:active {
background: darken(@tab-active, 10%);
}
}
&.fui-selected {
.fui-label {
color: white;
}
&:after {
content: ' ';
height: 0;
line-height: 0;
font-size: 0;
display: block;
position: absolute;
border: 6px solid;
border-color: transparent transparent white transparent;
bottom: 0;
left: 50%;
margin-left: -3px;
z-index: 11;
}
}
}
&.collapsed .fui-button.fui-selected {
.fui-label {
color: hsl(224, 6%, 80%);
}
&:after {
display: none;
}
}
}
.fullscreen #tab-container {
transform: translate(0, -101px) !important;
}
#tab-container {
position: absolute;
top: @panel-height;
height: 60px;
left: 0;
right: 0;
background: white;
z-index: 10;
border-bottom: 1px solid #dbdbdb;
box-shadow: 0 -3px 3px rgba(0, 0, 0, .05);
overflow: visible;
/* 每一个 Tab 面板 */
& > .fui-panel {
display: block;
height: 100%;
/* 每一个小节 */
& > .fui-panel-content > .fui-panel {
height: 100%;
padding: 0 5px;
border-right: 1px dashed #eee;
& > .fui-panel-content > .fui-label {
text-align: center;
display: block;
width: 100%;
padding: 1px 0;
position: absolute;
bottom: 0;
top: auto;
display: none;
}
& > .fui-panel-content > .fui-label-panel-content {
padding: 5px;
}
}
}
transition: transform 0.7s ease,
opacity,height .5s ease;
&.collapsed {
opacity: 0;
height: 0;
}
}
\ No newline at end of file
#template-panel {
& > .fui-panel-content
> .fui-label-panel-content
> .fui-drop-panel {
width: 65px;
height: 50px;
}
}
#theme-panel {
& > .fui-panel-content
> .fui-label-panel-content
> .fui-drop-panel {
width: 90px;
height: 50px;
}
}
#layout-panel {
& > .fui-panel-content
> .fui-label-panel-content
> .fui-drop-panel {
width: 65px;
height: 50px;
margin-right: 10px;
}
}
.fui-button.template {
width: 50px;
height: 40px;
padding: 0 2px !important;
margin: 5px !important;
.fui-label {
display: none;
}
.fui-icon {
display: block;
width: 50px;
height: 40px;
background-image: url(../images/template.png);
background-repeat: no-repeat;
}
&.default .fui-icon {
background-position: 0 0;
}
&.structure .fui-icon {
background-position: -50px 0;
}
&.filetree .fui-icon {
background-position: -100px 0;
}
&.right .fui-icon {
background-position: -150px 0;
}
&.fish-bone .fui-icon {
background-position: -200px 0;
}
}
.fui-button.theme {
padding: 5px !important;
margin: 5px !important;
.fui-label {
width: 60px;
height: 30px;
line-height: 30px;
text-align: center;
padding: 0 5px;
}
}
.fui-button.layout {
width: 50px;
height: 40px;
padding: 0 2px !important;
margin: 5px 0 0 5px !important;
.fui-label {
display: none;
}
.fui-icon {
display: block;
width: 50px;
height: 40px;
background-image: url(../images/layout.png);
background-repeat: no-repeat;
}
&.default .fui-icon {
background-position: 0 0;
}
&.bottom .fui-icon {
background-position: -100px 0;
}
&.filetree .fui-icon {
background-position: -200px 0;
}
}
\ No newline at end of file
.triangle {
content: ' ';
display: block;
width: 0;
height: 0;
padding: 0 !important;
line-height: 0;
font-size: 0;
border-style: solid;
border-color: transparent;
}
.triangle-top(@color, @width: 10px, @height: @width) {
.triangle;
border-width: @height (@width/2);
border-top-color: @color;
}
.triangle-bottom(@color, @width: 10px, @height: @width) {
.triangle;
border-width: @height (@width/2);
border-bottom-color: @color;
}
.triangle-left(@color, @width: 10px, @height: @width) {
.triangle;
border-width: (@height/2) @width;
border-left-color: @color;
}
.triangle-right(@color, @width: 10px, @height: @width) {
.triangle;
border-width: (@height/2) @width;
border-right-color: @color;
}
#panel div.user-panel {
float: right;
height: @panel-height;
line-height: @panel-height;
font-size: 14px;
color: @ui-fore;
vertical-align: baseline;
.loading-tip {
text-indent: 100000px;
display: inline-block;
width: 50px;
height: @panel-height;
line-height: @panel-height;
position: relative;
&:before {
content: ' ';
display: block;
position: absolute;
left: 9px;
top: 7px;
.loading-circle(16px);
box-shadow: none;
}
}
.fui-button {
padding: 5px 10px;
height: @panel-height - 10px;
line-height: @panel-height - 10px;
&:hover {
background-color: @tab-hover;
}
&:active {
background-color: @tab-active;
}
.fui-label {
font-size: 14px;
color: @ui-fore;
vertical-align: baseline;
}
&.user-button .fui-label {
display: none;
}
.fui-icon {
vertical-align: baseline;
border-radius: 100%;
img {
width: 30px;
height: 30px;
}
}
&.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;
}
}
}
}
.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
@panel-height: 40px;
@theme-color: hsl(0, 95%, 75%);
@main-menu-theme-color: @theme-color;
@main-menu-fore-color: #465468;
@tab-hover: #5a6378;
@tab-active: darken(@tab-hover, 10%);
@button-border: #c9ced1;
@button-text: #5a6378;
@button-hover: hsl(222, 55%, 96%);
@button-active: hsl(222, 55%, 85%);
@button-pressed: hsl(222, 55%, 90%);
@border-color: #c9ced1;
@ui-color: #393f4f;
@ui-fore: white;
\ No newline at end of file
.fui-button, li {
transition: background-color .2s ease;
}
.fui-disabled,
.fui-disabled .fui-widget {
&:hover, &:active {
background-color: transparent;
}
}
.fui-widget {
input[type=text],
textarea {
user-select: text;
}
}
input::-ms-clear {
display: none;
}
input[type=search]::-ms-clear {
display: inline-block;
}
#tab-container .fui-button {
display: inline-block;
padding: 2px 5px 2px 3px;
.fui-label {
color: @button-text;
font-size: 12px;
vertical-align: middle;
}
&.command-button {
margin-bottom: 3px;
.fui-icon {
width: 20px;
height: 20px;
margin-right: 3px;
display: inline-block;
vertical-align: middle;
}
&.large {
width: 50px;
height: 50px;
padding: 0;
.fui-icon {
width: 25px;
height: 25px;
margin-left: 12px;
margin-bottom: 3px;
margin-top: 4px;
}
.fui-label {
display: block;
text-align: center;
}
}
}
&:hover {
background-color: @button-hover;
}
&:active {
background-color: @button-active;
}
&.fui-disabled:hover,
&.fui-disabled:active {
background-color: transparent;
}
&.active {
background-color: @button-pressed;
}
}
.command-buttonset {
.fui-toggle-button {
&:hover {
background-color: @button-hover;
.fui-disabled& {
background-color: transparent;
}
}
&:active {
transform: scale(0.9);
&:hover {
background-color: @button-active;
.fui-disabled& {
background-color: transparent;
}
}
}
&.fui-button-pressed {
background-color: @button-pressed;
}
}
}
.command-inputmenu, .fui-input-menu {
& > .fui-input-button {
position: relative;
.fui-input {
width: 100px;
}
border-color: @border-color;
margin: 2px 0;
& > .fui-button {
position: absolute;
left: auto;
right: 0;
top: 0;
bottom: 0;
width: 20px;
border-left: 1px solid @border-color;
padding: 0 !important;
.fui-icon {
position: absolute;
left: auto;
right: 6px;
top: 50%;
margin-top: -2px;
.triangle-top(@button-text, 8px, 4px);
}
}
}
}
#tab-container .fui-drop-panel {
padding-right: 10px;
border-color: @border-color;
& > .fui-button {
position: absolute;
display: block;
right: 1px;
left: auto;
top: 1px;
bottom: 1px;
width: 10px;
padding: 0;
&:hover {
background: @button-hover;
}
&:active {
background: @button-active;
}
& > .fui-icon {
position: absolute;
.triangle-top(@button-text, 6px, 4px);
top: auto;
bottom: 2px;
left: 2px;
}
}
}
.fui-drop-panel-popup {
background: white;
box-shadow: 0 0 3px rgba(0,0,0,.3);
padding-right: 5px;
padding-bottom: 5px;
max-width: 300px;
}
#tab-container .fui-button-menu {
border: 1px solid transparent;
width: 40px;
height: 50px;
display: inline-block;
margin-top: 2px;
&:hover {
border-color: @button-hover;
}
&.fui-disabled:hover {
border-color: transparent;
}
.fui-button:first-child {
display: block;
width: 40px;
height: 25px;
padding: 0;
}
.fui-button:last-child {
display: block;
width: 40px;
height: 25px;
padding: 0;
.fui-label {
font-size: 12px;
}
.fui-icon {
.triangle-top(@button-text, 6px, 4px);
display: block;
position: absolute;
top: auto;
bottom: -2px;
left: 50%;
margin-left: -3px;
}
}
}
.fui-dialog {
& > .fui-panel-content {
padding: 0;
}
box-shadow: 0 0 5px rgba(0,0,0, .15);
border: none;
.fui-dialog-head {
background-color: @ui-color;
color: white;
h1 {
font-size: 14px;
font-weight: normal;
}
padding: 5px;
.fui-close-button {
.fui-close-button-icon {
display: none;
background: none;
}
position: absolute;
right: 6px;
top: 7px;
left: auto;
display: block;
width: 20px;
height: 20px;
cursor: pointer;
border-radius: 100%;
&:hover {
background-color: hsl(0, 73%, 64%);
}
&:active {
background-color: hsl(0, 73%, 60%);
}
&:after {
content: 'x';
display: block;
width: 16px;
height: 16px;
font-family: inherit;
color: white;
font-size: 14px;
position: absolute;
left: 2px;
top: 1px;
line-height: 16px;
text-align: center;
}
}
}
.fui-dialog-body {
padding: 20px;
p {
margin: 0;
height: 40px;
}
input[type=text],
input[type=url] {
border: 1px solid @border-color;
outline: none;
height: 20px;
padding: 2px 4px;
width: 300px;
vertical-align: middle;
}
}
.fui-dialog-foot {
position: absolute;
bottom: 0;
left: 0;
right: 0;
top: auto;
height: 50px;
border-top: 1px solid @border-color;
text-align: right;
.fui-button {
width: 80px;
height: 30px;
line-height: 30px;
text-align: center;
&:hover {
background: lighten(@ui-color, 70%);
}
&:active {
background: lighten(@ui-color, 55%);
}
&.fui-xdialog-ok-btn {
background: @ui-color;
&:hover {
background: lighten(@ui-color, 10%);
}
&:active {
background: darken(@ui-color, 3%);
}
border-color: transparent;
.fui-label {
color: white;
}
}
border: 1px solid @border-color;
border-radius: 4px;
margin: 8px 8px 0 0;
.fui-label {
font-size: 14px;
line-height: 30px;
height: 30px;
}
}
}
}
#tab-container .fui-select-menu.command-selectmenu > .fui-panel-content {
padding-right: 10px;
border: 1px solid transparent;
width: auto;
&:hover {
border-color: @border-color;
}
& > .fui-button {
position: absolute;
display: block;
.dock;
padding: 0;
&:hover {
background: fadeOut(@button-hover, 90%);
}
&:active {
background: fadeOut(@button-active, 50%);
}
& > .fui-icon {
position: absolute;
.triangle-top(@button-text, 6px, 4px);
top: auto;
bottom: 2px;
right: 2px;
left: auto;
}
}
& > .fui-select-menu-container {
border: 1px solid #ccc;
box-shadow: 3px 3px 6px rgba(0, 0, 0, .3);
}
}
.fui-popup-menu, .fui-menu.fui-ppanel-position {
position: absolute;
z-index: 100000;
min-width: 160px;
padding: 5px 0;
font-size: 12px;
list-style: none;
background-color: #ffffff;
border-radius: 0;
box-shadow: 0 1px 15px rgba(0, 0, 0, 0.3);
background-clip: padding-box;
font-family: Arial, "Heiti SC", "Microsoft Yahei";
overflow: hidden;
&:empty {
display: none !important;
}
.fui-panel-content, .fui-menu {
border: none;
display: block;
}
.fui-item {
.fui-label, .fui-icon {
height: 25px;
line-height: 25px;
}
display: block;
padding: 2px 15px 2px 30px;
height: 25px;
line-height: 25px;
clear: both;
font-weight: normal;
color: #333333;
white-space: nowrap;
text-decoration: none;
font-size: 12px;
overflow: hidden;
transition: none;
&:hover, :focus {
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: hsl(222, 14%, 41%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white;
.fui-label {
color: white;
}
}
.menu-label {
display: inline-block;
}
.shortcut {
float: right;
margin-left: 20px;
.shortcut-key {
font-size: 12px;
border: 1px solid #CCC;
height: 10px;
line-height: 10px;
margin-left: 3px;
}
+ .shortcut:after {
content: 'or';
position: relative;
left: 10px;
}
}
}
.divider, .fui-spliter {
height: 1px;
margin: 5px 0;
overflow: hidden;
background-color: #e5e5e5;
padding: 0;
&:first-child, &:last-child {
display: none;
}
}
}
\ No newline at end of file
@import (less) "../../../../lib/fui/theme/default/fui.all.css";
@import "_vars";
@import "_public";
@import "_triangle";
@import "_widgets";
@import "_notice";
@import "_kityminder";
@import "_mainmenu";
@import "_mainmenu.new.less";
@import "_quickvisit.less";
@import "_history";
@import "_tab";
@import "_search";
@import "_user";
@import "_recent";
@import "_netdisk";
@import "_localfile";
@import "_draft";
@import "_download";
@import "_help";
@import "_priority_panel";
@import "_progress_panel";
@import "_resource_panel";
@import "_attachment_panel";
@import "_image_dialog";
@import "_themepanel";
@import "_fontpanel";
@import "_colorpanel";
@import "_about";
@import "_receiver";
@import "_help";
@import "_share";
@import "_icons";
@import "_nav";
\ No newline at end of file
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="25px"
height="25px" viewBox="0 0 25 25" style="enable-background:new 0 0 25 25;" xml:space="preserve">
<g id="&#x56FE;&#x5C42;_2">
<path style="fill:#3A4859;" d="M6.196,24c1.062,0,6.493-3,12.605,0h5.94C24.853,24,25,24.359,25,24.247V2.112
C25,2,24.853,2,24.741,2h-7.869L5.981,24H6.196z"/>
</g>
<g id="&#x56FE;&#x5C42;_1">
<path style="fill:#474D54;" d="M18.905,24L8.038,2H0.169C0.057,2,0,2,0,2.112v22.135C0,24.359,0.057,24,0.169,24h6.027
c1.062,0,6.493-3,12.605,0H18.905z"/>
</g>
<g id="&#x56FE;&#x5C42;_2_x5F_&#x590D;&#x5236;">
</g>
<g id="&#x56FE;&#x5C42;_1_x5F_&#x590D;&#x5236;">
<path style="fill:#2C363F;" d="M5.981,24h0.215c1.062,0,6.493-3,12.605,0h0.103L12.45,10.611L5.981,24z"/>
</g>
<g id="&#x56FE;&#x5C42;_3" style="display:none;">
<image style="display:inline;overflow:visible;" width="512" height="512" xlink:href="754EB0E7B73A025C.png" transform="matrix(0.9999 0 0 0.9999 -243 -243)">
</image>
</g>
</svg>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<filter id="blur">
<feGaussianBlur stdDeviation="5" />
</filter>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 17.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="图层_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="300px" height="55px" viewBox="0.5 0.5 300 55" enable-background="new 0.5 0.5 300 55" xml:space="preserve">
<g id="参考线">
</g>
<g id="create">
<path id="add-folder-2-icon" fill="#717B94" d="M25.5,19.5h-2v-2h-2v2h-2v2h2v2h2v-2h2V19.5z M17.5,23.5h-12v-17h6.696l1.645,1.638
C14.296,8.591,14.912,8.5,15.555,8.5H25.5v6h-2v-4h-7.945c-1.183,0-2.296-0.108-3.134-0.943L11.365,8.5H7.5v13h10V23.5z"/>
</g>
<g id="recycle">
<polygon fill="#717B94" points="51.5,22.5 39.5,22.5 39.5,10.5 37.5,10.5 37.5,24.5 53.5,24.5 53.5,10.5 51.5,10.5 "/>
<path fill="#717B94" d="M48.5,6.5c-0.823,0-2-1.222-2-2h-2c0,0.778-1.177,2-2,2h-5v2h16v-2H48.5z"/>
<path fill="#717B94" d="M44.5,19.5c0,0.552-0.448,1-1,1l0,0c-0.552,0-1-0.448-1-1v-7c0-0.552,0.448-1,1-1l0,0c0.552,0,1,0.448,1,1
V19.5z"/>
<path fill="#717B94" d="M48.5,19.5c0,0.552-0.448,1-1,1l0,0c-0.552,0-1-0.448-1-1v-7c0-0.552,0.448-1,1-1l0,0c0.552,0,1,0.448,1,1
V19.5z"/>
<polygon fill="#717B94" points="81.5,22.5 69.5,22.5 69.5,10.5 67.5,10.5 67.5,24.5 83.5,24.5 83.5,10.5 81.5,10.5 "/>
<path fill="#717B94" d="M78.907,5.478c-0.794-0.217-1.606-1.707-1.4-2.457l-1.929-0.529c-0.206,0.75-1.664,1.618-2.457,1.4
l-4.822-1.321L67.769,4.5L83.2,8.729L83.729,6.8L78.907,5.478z"/>
<path fill="#717B94" d="M74.5,19.5c0,0.552-0.448,1-1,1l0,0c-0.552,0-1-0.448-1-1v-7c0-0.552,0.448-1,1-1l0,0c0.552,0,1,0.448,1,1
V19.5z"/>
<path fill="#717B94" d="M78.5,19.5c0,0.552-0.448,1-1,1l0,0c-0.552,0-1-0.448-1-1v-7c0-0.552,0.448-1,1-1l0,0c0.552,0,1,0.448,1,1
V19.5z"/>
</g>
<path fill="#767E9C" d="M9.543,53.5c1.014,0,6.2-3,12.037,0h5.672H27.5V32.61c0-0.107-0.14-0.11-0.247-0.11h-7.515l-10.4,21H9.543z"
/>
<path fill="#767E9C" d="M21.679,53.5l-10.377-21H3.788c-0.107,0-0.288,0.003-0.288,0.11V53.5h0.288h5.755c1.014,0,6.2-3,12.037,0
H21.679z"/>
<path fill="#60687C" d="M9.338,53.5h0.205c1.014,0,6.2-3,12.037,0h0.099l-6.164-12.786L9.338,53.5z"/>
<g>
<path fill="#76809B" d="M54.836,38.828l1.056-5.778l-5.798,1.034c-1.391-0.687-2.957-1.074-4.614-1.074
c-1.651,0-3.212,0.384-4.599,1.067l-5.788-1.007l1.017,5.788l0,0c-0.677,1.382-1.057,2.936-1.057,4.579
c0,5.759,4.669,10.428,10.428,10.428s10.428-4.669,10.428-10.428C55.908,41.783,55.522,40.218,54.836,38.828z"/>
<path fill="#FFFFFF" d="M51.901,38.878c-2.514,0-4.552,2.038-4.552,4.552c0,2.514,2.038,4.552,4.552,4.552
c2.514,0,4.552-2.038,4.552-4.552C56.453,40.916,54.415,38.878,51.901,38.878z M51.896,46.389c-1.604,0-2.904-1.3-2.904-2.904
s1.3-2.904,2.904-2.904s2.904,1.3,2.904,2.904S53.5,46.389,51.896,46.389z"/>
<path fill="#FFFFFF" d="M39.003,38.878c-2.514,0-4.552,2.038-4.552,4.552c0,2.514,2.038,4.552,4.552,4.552
c2.514,0,4.552-2.038,4.552-4.552C43.555,40.916,41.517,38.878,39.003,38.878z M38.998,46.369c-1.604,0-2.904-1.3-2.904-2.904
s1.3-2.904,2.904-2.904s2.904,1.3,2.904,2.904S40.602,46.369,38.998,46.369z"/>
</g>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#76809B" d="M86.888,31.842c0,0-2.398,0.852-7.73,0.852
c-2.871,0-7.383,0-7.383,0s-5.806-0.631-5.995,4.828c-0.189,5.459,0,11.043,0,11.864s0.126,3.818-0.41,4.354
c-0.536,0.536,1.988-0.82,5.837-0.757c3.849,0.063,10.98-0.095,10.98-0.095s3.926,0.273,4.354-4.922
C86.983,42.602,85.91,35.786,86.888,31.842z"/>
<path fill-rule="evenodd" clip-rule="evenodd" fill="#FFFFFF" d="M82.393,44.851c-0.244-0.239-0.424-0.414-0.556-0.543
c-0.036-0.017-0.066-0.039-0.091-0.067c-4.761-2.931-1.457-1.898,0.413-2.666c1.871-0.769,1.237-3.208,1.237-3.208
s-4.913-0.201-4.779,0.167c0.134,0.368,0.602,3.108-2.473,2.506c-3.075-0.602-3.409-4.612-3.409-4.612l-5.648-0.167
c0,0-0.501,2.874,3.509,4.913c3.564,1.812,0.714,1.749-0.55,1.948c-0.01,0.004-0.019,0.009-0.029,0.012
c-0.051,0.015-0.105,0.021-0.158,0.022c-0.031,0.007-0.061,0.014-0.088,0.021c-0.029,0.015-0.061,0.025-0.097,0.031
c-0.004,0.002-0.009,0.003-0.013,0.005c-0.835,0.334-3.175,0.602-3.542,3.442l4.411-0.067c0,0,0.568-2.707,2.339-2.974
c1.771-0.267,5.38,1.003,5.815,4.979l5.481,0.134C84.164,48.728,83.897,46.321,82.393,44.851z"/>
<path fill="#707995" d="M108.368,13.764c-1.853-1.464-4.868,0.027-4.868,2.736c0,0,0.091-0.001,0.091,0h0.896l-1.987,2l-2-2h2
c0,0-1,0-1,0C101.5,13.124,106.093,11.165,108.368,13.764z"/>
<path fill="#707995" d="M102.632,18.961c1.853,1.464,4.868,0.247,4.868-2.461c0-0.001-0.021,0-0.021,0H106.5l2-2l2,2h-1c0,0,0,0,0,0
C109.5,19.875,104.907,21.56,102.632,18.961z"/>
<polygon fill="#717B94" points="111.5,22.5 99.5,22.5 99.5,10.5 97.5,10.5 97.5,24.5 113.5,24.5 113.5,10.5 111.5,10.5 "/>
<path fill="#717B94" d="M108.5,6.5c-0.823,0-2-1.222-2-2h-2c0,0.778-1.177,2-2,2h-5v2h16v-2H108.5z"/>
</svg>
<svg xmlns="http://www.w3.org/2000/svg" id="km-cat" viewBox="0 0 1200 1200" width="500" height="500">
<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>
\ No newline at end of file
/**
* @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
/**
* @fileOverview
*
* 历史控制按钮
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/history', function(minder) {
var ret = {};
var commandbutton = minder.getUI('widget/commandbutton');
['undo', 'redo'].forEach(function(command) {
ret[command] = commandbutton.generate(command).appendTo(document.getElementById('panel'));
});
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 移动端分享页面加载 logo 功能
*
* @author: zhangbobell
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/m-logo', function(minder) {
var $logoSvg = $('<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.999c-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.641c0,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.255s227.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-145s145,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.255s227.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-145s145,64.919,145,145S356.081,745,276,745z"/></g></svg>');
var $mLogo = $logoSvg.appendTo('#m-logo');
return $mLogo;
});
\ No newline at end of file
/**
* @fileOverview
*
* 快速访问区域
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/quickvisit', function (minder) {
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);
if (dockRight) rightDocks.push($btn);
else $btn.appendTo('#panel');
return $btn;
}
var $new = btn('new'),
$save = btn('save'),
$share = btn('share');
var ret = {
$new: $new,
$save: $save,
$share: $share
};
minder.on('uiready', function quickVisit() {
while (rightDocks.length) $('#panel #search').after(rightDocks.shift());
function quickNew() {
var $doc = minder.getUI('doc');
if (!$doc.checkSaved()) return;
$doc.load({
content: {
template: 'default',
version: KityMinder.version,
data: {
text: minder.getLang('maintopic')
}
},
saved: true
});
}
function quickSave() {
minder.getUI('menu/save/netdisk').quickSave();
}
function quickShare() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(3);
$menu.show();
}
$new.click(quickNew);
$save.click(quickSave);
$share.click(quickShare);
minder.addShortcut('ctrl+alt+n', quickNew);
minder.addShortcut('ctrl+s', quickSave);
minder.addShortcut('ctrl+alt+s', quickShare);
minder.addShortcut('ctrl+shift+s', function() {
var $menu = minder.getUI('menu/menu');
$menu.$tabs.select(2);
$menu.show();
});
ret.ready = true;
ret.quickNew = quickNew;
ret.quickSave = quickSave;
ret.quickShare = quickShare;
});
ret.add = btn;
return ret;
});
\ No newline at end of file
/**
* @fileOverview
*
* 搜索节点功能
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/search', function(minder) {
var $search = $('<div id="search"><input type="search" /></div>').appendTo('#panel');
var $input = $search.find('input');
minder.addShortcut('ctrl+f', function() {
$input[0].focus();
$input[0].select();
});
$input.on('keydown', function(e) {
if (e.keyCode == 13) {
doSearch($input.val());
}
if (e.keyCode == 27) {
$input[0].blur();
}
});
var nodeSequence;
minder.on('contentchange', makeNodeSequence);
function makeNodeSequence() {
nodeSequence = [];
minder.getRoot().traverse(function(node) {
nodeSequence.push(node);
});
}
function doSearch(keyword) {
if (!/\S/.exec(keyword)) {
$input[0].focus();
$input[0].select();
return;
}
keyword = keyword.toLowerCase();
var newSearch = doSearch.lastKeyword != keyword;
doSearch.lastKeyword = keyword;
var startIndex = newSearch ? 0 : doSearch.lastIndex + 1 || 0;
var endIndex = startIndex + nodeSequence.length - 1;
for (var i = startIndex; i <= endIndex; i++) {
var node = nodeSequence[i % nodeSequence.length];
var text = node.getText().toLowerCase();
if (text.indexOf(keyword) != -1) {
setSearchResult(node);
doSearch.lastIndex = i;
break;
}
}
function setSearchResult(node) {
minder.execCommand('camera', node, 50);
setTimeout(function() {
minder.select(node, true);
}, 60);
}
}
return $search;
});
\ No newline at end of file
/**
* @fileOverview
*
* 移动端分享页面转换视图按钮
*
* @author: zhangbobell
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/switch-view', function(minder) {
var $switch = $('<span class="switch-view" id="switch-view">转换</span>').appendTo('#panel');
$('<div class="back"></div>').appendTo('#m-logo');
var treeData;
var $curView=$('<div id="curView">');
var $preView=$('<div id="preView">');
minder.on('uiready', function() {
var shareView = minder.getUI('menu/share/m-share');
shareView.ready.then(function(){
treeData = addParentPointer(minder);
renderNodeData(treeData, minder, $curView);
renderNodeData(treeData, minder, $preView);
$('#km-list-view').append($curView);
$('#km-list-view').append($preView);
$preView.css('x', '100%');
$('#km-list-view').css('display', 'none');
});
});
var isListView = false; // mutex : 当前是否是列表视图
$switch.on('click', function(){
if (!isListView ){
$('#kityminder').css('display', 'none');
$('#km-list-view').css('display', 'block');
isListView = true;
} else {
$('#km-list-view').css('display', 'none');
$('#kityminder').css('display', 'block');
isListView = false;
}
});
$('#km-list-view').delegate('li', 'click', function(){
var preViewData = $(this).data();
if (preViewData.children) {
renderNodeData(preViewData, minder, $preView);
// $curView.css('x');
// console.log($preView.css('x'));
$preView.css('x', parseInt($curView.css('x')) + 100 + '%');
// console.log($preView.css('x'));
// $('#km-list-view').css('x', '0');
$('#km-list-view').transition({
x: parseInt($('#km-list-view').css('x')) - 100 + '%',
duration: 200,
easing: 'ease',
complete: function(){
var $temp = $curView;
$curView = $preView;
$preView = $temp;
}
});
if (preViewData.parent){
$('.back').css('display', 'block');
$('#km-cat').css('display', 'none');
}
}
});
$('.back').on('click', function(){
var parentViewData = $('.cur-root', $curView).data();
renderNodeData(parentViewData, minder, $preView);
$preView.css('x', parseInt($curView.css('x')) - 100 + '%');
// $curView.css('x');
// $('#km-list-view').css('x', '-100%');
$('#km-list-view').transition({
x: parseInt($('#km-list-view').css('x')) + 100 + '%',
duration: 200,
easing: 'ease',
complete: function(){
var $temp = $curView;
$curView = $preView;
$preView = $temp;
}
});
if (!parentViewData.parent){
$('.back').css('display', 'none');
$('#km-cat').css('display', 'block');
}
})
return $switch;
});
/**
* addParentPointer - 给 minder 的 json 数据增加 parent 指针
* @param minder - kityminder 实例
* @returns {*} - 增加了 parent 指针之后的 json 结构
*/
function addParentPointer(minder){
var root = minder.exportJson();
return AddParent(root);
}
/**
* AddParent - 递归的增加 parent 指针
* @param root - 传入的根节点
* @returns {*}
*/
function AddParent(root){
if (root.children){
$.each(root.children, function(idx, ele){
ele.parent = root;
AddParent(ele);
});
}
return root;
}
/**
* creadNodeData - 根据 json 结构创建好视图的 jQuery 对象
* @param node
* @param minder
* @returns {*} - 创建好的 jQuery 对象
*/
function renderNodeData(node, minder, $target){
var $curRoot = createRootNode(node, minder);
var $curList = $('<ul class="cur-list">');
if (node.children){
$.each(node.children, function(idx, ele){
var $listNode = createListNode(ele, minder);
$curList.append($listNode);
});
}
// debugger;
return $target.html($curRoot.add($curList));
}
/**
* createRootNode - 创建当前根节点对应的 jQuery 对象
* @param node 节点的 jQuery 对象
* @param minder kityminder 实例
* @returns {*|jQuery|HTMLElement} 当前根节点的 jQuery 对象
*/
function createRootNode(node, minder){
var $root = $('<h1 class="cur-root">');
$root.append(getNodeHtml(node, minder));
if (node.parent){
$root.data(node.parent);
}
return $root;
}
/**
* createListNode - 创建子节点对应的 jQuery 对象
* @param node 节点的 json 对象
* @param minder kityminder 实例
* @returns {*|jQuery|HTMLElement} 子节点的 jQuery 对象
*/
function createListNode(node, minder){
var $list = $('<li>');
$list.append(getNodeHtml(node, minder));
// 处理子节点
if (node.children){
$list.addClass('clickable');
$list.children().first().before('<span class="next-level"></span>');
$list.data(node);
}
return $list;
}
/**
* getNodeHtml - 根据传入节点的 json 对象创建该节点的 html 数据
* @param node 节点的 json 对象
* @param minder kityminder 实例
* @returns {string} 返回的 html 字符串
*/
function getNodeHtml (node, minder){
var data = node.data;
var html = '';
// 处理优先级
if (data.priority){
html += '<div class="priority priority-' + data.priority + '"></div>'
}
// 处理进度
if (data.progress){
html += '<div class="progress progress-' + data.progress + '"></div>'
}
// 处理超链接
if (data.hyperlink) {
html +='<a class="hyperlink" href="'+ data.hyperlink +'" target="_blank"></a>';
}
// 处理资源
if (data.resource){
$.each(data.resource, function(idx, ele){
html += '<span class="resource" style="background-color: '+ minder.getResourceColor(ele).toRGB() +'">' + ele + '</span>' + ' ';
});
}
// 处理文字
if (data.text) {
html += '<span class="text">' + (data.text || '') + '</span>';
}
return html;
}
/**
* @fileOverview
*
* 显示并更新脑图文件的标题
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/title', function(minder) {
var $title = $('<h1>').appendTo('#panel');
var $doc = minder.getUI('doc');
var finder = minder.getUI('widget/netdiskfinder');
var notice = minder.getUI('widget/notice');
var renameEnabled = false;
var renameMode = false;
$doc.on('docchange', update);
$title.on('click', rename);
function rename() {
if (!renameEnabled || renameMode) return;
var doc = $doc.current();
var $input = $('<input>').width($title.find('.title-content').width());
var oldFilename = doc.title;
var oldPath = doc.path;
$input.val(oldFilename);
setTimeout(function() {
$input[0].select();
});
$title.addClass('rename-mode');
$title.empty();
$title.append($input);
renameMode = true;
$input.on('keydown', function(e) {
if (e.keyCode == 13) confirm();
else if (e.keyCode == 27) {
cancel();
e.stopPropagation();
}
}).on('blur', cancel);
function exit() {
setTimeout(function() {
renameMode = false;
});
}
function cancel() {
update();
exit();
}
function confirm() {
var newFilename = $input.val();
var oldFilenameInfo = fio.file.anlysisPath(oldFilename);
var newFilenameInfo = fio.file.anlysisPath(newFilename);
if (!newFilenameInfo.name.length) return cancel();
newFilename = newFilenameInfo.name + oldFilenameInfo.extension;
var newPath = fio.file.anlysisPath(oldPath).parentPath + newFilename;
if (newPath == oldPath) return cancel();
$title.addClass('loading');
fio.file.move({
path: oldPath,
newPath: newPath
}).then(function() {
doc.path = newPath;
doc.title = newFilename;
finder.fire('mv', oldPath, newPath);
notice.info(minder.getLang('ui.rename_success', newFilename));
})['catch'](function(e) {
notice.error('err_rename', e);
}).then(function() {
$title.removeClass('loading');
update();
exit();
});
}
}
function enableRename(enabled) {
renameEnabled = enabled;
if (enabled) $title.addClass('rename-enabled');
else $title.removeClass('rename-enabled');
}
function update() {
var doc = $doc.current();
function setTitle(title) {
title = title || minder.getLang('ui.untitleddoc');
$title.html('<span class="title-content">' + title + '</span>');
document.title = title ? title + ' - 百度脑图' : '百度脑图';
}
if (doc.saved) {
setTitle(doc.title);
} else {
setTitle('* ' + doc.title);
}
enableRename(doc.source == 'netdisk' && doc.saved);
}
update();
return {
$title: $title,
getTitle: function() {
return $doc.current().title;
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 用户登录控制
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('topbar/user', function(minder) {
var eve = minder.getUI('eve');
var currentUser;
var $userPanel = $('<div class="user-panel"></div>').appendTo('#panel');
var $tip = $('<span class="loading-tip"></span>')
.text(minder.getLang('ui.checklogin'))
.appendTo($userPanel);
/* 登录按钮 */
var $loginButton = new FUI.Button({
label: minder.getLang('ui.login'),
text: minder.getLang('ui.login'),
className: 'login-button'
}).appendTo($userPanel[0]).hide();
/* 用户按钮 */
var $userButton = new FUI.Button({
icon: {
// 1px 透明图
img: 'data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs='
},
className: 'user-button'
}).appendTo($userPanel[0]).hide();
/* 用户菜单 */
var $userMenu = new FUI.PopupMenu({
id: 'user-menu'
}).appendTo(document.getElementById('content-wrapper')).positionTo($userButton);
var menu = $userMenu.getMenuWidget().show();
['userinfo', 'gotonetdisk', 'fui-spliter', 'switchuser', 'logout'].forEach(function(name) {
menu.appendItem(new FUI.Item({
label: minder.getLang('ui.' + name),
className: name,
value: name
}));
});
$userButton.on('click', function() {
$userMenu.open();
var $dom = $($userMenu.getElement());
var $button = $($userButton.getElement());
$dom.offset({
left: $button.offset().left - $dom.outerWidth() + $button.outerWidth() - 10,
top: $button.offset().top + $button.outerHeight()
});
});
menu.on('select', function(e, info) {
switch (info.value) {
case 'userinfo':
window.open('http://i.baidu.com');
break;
case 'gotonetdisk':
window.open('http://pan.baidu.com/disk/home#path=/apps/kityminder');
break;
case 'switchuser':
switchUser();
break;
case 'logout':
logout();
break;
}
menu.clearSelect();
$userMenu.hide();
});
minder.on('uiready', function() {
fio.user.check().then(check)['catch'](function(error) {
$loginButton.show();
$userButton.hide();
$tip.hide();
});
});
$loginButton.on('click', login);
$('#content-wrapper').delegate('.login-button', 'click', login);
function check(user) {
if (user) {
$userButton.setLabel(user.username);
$userButton.getIconWidget().setImage(user.smallImage);
$userButton.show();
$loginButton.hide();
fio.user.fire('login', user);
} else {
if (window.location.href.indexOf('nocheck') == -1) {
return login();
} else {
$loginButton.show();
}
}
$tip.hide();
currentUser = user;
}
function logout() {
fio.user.logout();
$loginButton.show();
$userButton.hide();
fio.user.fire('logout');
window.location.href = window.location.href.split('edit.html')[0] + 'index.html'; // refresh
}
function login() {
$loginButton.setLabel(minder.getLang('ui.loggingin'));
fio.user.login({
remember: 7 * 24 * 60 * 60 // remember 7 days
});
}
function switchUser() {
fio.user.login({
remember: 7 * 24 * 60 * 60, // remember 7 days
force: true
});
}
function requireLogin($element) {
var $login_tip = $('<p class="login-tip"></p>')
.html(minder.getLang('ui.requirelogin'));
$element.append($login_tip);
fio.user.on('login', function() {
$element.removeClass('login-required');
});
fio.user.on('logout', function() {
$element.addClass('login-required');
});
}
return {
getCurrent: function() {
return currentUser;
},
loginLink: function() {
return $('<a></a>').click(login);
},
requireLogin: requireLogin
};
});
\ No newline at end of file
/**
* @fileOverview
*
* KityMinder UI 注册及加载机制
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
(function() {
var uiQueue = [];
/* 注册一个新的 UI 交互 */
KityMinder.registerUI = function(id, deps, ui) {
if (typeof(deps) == 'function') {
ui = deps;
deps = null;
}
uiQueue.push({
id: id,
ui: ui,
deps: deps
});
};
kity.extendClass(Minder, {
/* 为实例注册 UI 交互 */
initUI: function() {
var ui = this._ui = {};
var minder = this;
uiQueue.forEach(function(uiDeal) {
var deps = uiDeal.deps;
if (deps) deps = deps.map(function(dep) {
return minder.getUI(dep);
});
ui[uiDeal.id] = uiDeal.ui.apply(null, [minder].concat(deps || []));
});
// 阻止非脑图事件冒泡
$('#content-wrapper').delegate('#panel, #tab-container, .fui-dialog, #main-menu', 'keydown keyup', function(e) {
e.stopPropagation();
});
// 阻止非脑图事件冒泡
$('#content-wrapper').delegate('input', 'mousedown mousemove mouseup contextmenu', function(e) {
e.stopPropagation();
});
minder.getPaper().addClass('loading-target');
this.fire('interactchange');
this.fire('uiready');
},
/* 获得实例的 UI 实例 */
getUI: function(id) {
return this._ui[id];
}
});
$.ajaxSetup({ cache: false });
$.extend($, {
pajax: function() {
return Promise.resolve($.ajax.apply($, arguments));
}
});
// preload css images
$(function() {
var list = ["kmcat_warn.png", "kmcat_sad.png", "icons.png", "template_large.png", "history.png", "feedback.png", "iconpriority.png", "iconprogress.png", "template.png", "layout.png", "next-level.png", "prev-level.png"];
list.forEach(function(item) {
(new Image()).src = 'ui/theme/default/images/' + item;
});
});
})();
\ No newline at end of file
/**
* @fileOverview
*
* 生成绑定到某个命令的按钮
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/commandbutton', function(minder) {
return {
generate: function(command, onclick) {
var $button = new FUI.Button({
label: minder.getLang('ui.command.' + command) || minder.getLang('ui.' + command),
text: minder.getLang('ui.command.' + command) || minder.getLang('ui.' + command),
className: ['command-widget', 'command-button', command]
});
$button.bindExecution('click', onclick || function() {
minder.execCommand(command);
});
$button.bindCommandState(minder, command);
return $button;
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* commandbuttonset.js 生成与指定命令绑定的按钮
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/commandbuttonset', function(minder) {
function mapValueItem(command, valueList) {
return valueList.map(function(value) {
var text = minder.getLang([command, value].join('.')) || value;
return {
label: text,
text: text,
value: value,
className: [command, value].join(' ')
};
});
}
function generate(command, valueList) {
var $buttonset = new FUI.Buttonset({
id: 'template-set',
buttons: typeof(valueList[0]) == 'object' ? valueList : mapValueItem(command, valueList),
className: ['command-widget', 'command-buttonset', command].join(' ')
});
$buttonset.bindExecution('change', function() {
minder.execCommand(command, $buttonset.getValue());
});
$buttonset.bindCommandState(minder, command, function(value) {
this.selectByValue(value);
});
return $buttonset;
}
return {
generate: generate
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 绑定到某个命令的下拉选框
*
*/
KityMinder.registerUI('widget/commandinputmenu', function(minder) {
function generate(command, menuList) {
var $menu = new FUI.InputMenu({
menu: {
items: menuList
},
input: {
placeholder: minder.getLang('ui.' + command),
},
className: ['command-widget', 'command-inputmenu', command]
});
$menu.bindCommandState(minder, command, function(value) {
if (!$menu.selectByValue(value)) {
$menu.clearSelect();
}
});
var lastIndex = -1;
$menu.bindExecution('select', function(e, info) {
if (~info.index) {
minder.execCommand(command, info.value);
} else {
$menu.select(lastIndex);
}
lastIndex = info.index;
});
return $menu;
}
return {
generate: generate
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 生成与指定命令绑定的下拉选框
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/commandselectmenu', function(minder) {
function mapValueWidget(command, valueList) {
return valueList.map(function(value) {
var text = minder.getLang([command, value].join('.')) || value;
return {
clazz: 'Button',
label: text,
text: text,
value: value,
className: [command, value].join(' ')
};
});
}
function generate(command, valueList, column) {
var $selectMenu = new FUI.SelectMenu({
widgets: typeof(valueList[0]) == 'object' ? valueList : mapValueWidget(command, valueList),
className: ['command-widget', 'command-selectmenu', command].join(' '),
column: column || 3
});
$selectMenu.bindExecution('change', function() {
minder.execCommand(command, $selectMenu.getValue());
});
$selectMenu.bindCommandState(minder, command, function(value) {
if (value !== undefined) this.selectByValue(value);
});
return $selectMenu;
}
return {
generate: generate
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 完成加载一个脑图文件的流程
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/fileloader', function(minder) {
var doc = minder.getUI('doc');
var $container = $(minder.getRenderTarget());
var supports = minder.getSupportedProtocols();
function getProtocolByExtension(extension) {
for (var protocol in supports) {
if (supports[protocol].fileExtension == extension) return supports[protocol];
}
return false;
}
function load(file) {
var protocol = getProtocolByExtension(file.extension);
return doc.load({
source: file.source,
title: file.filename,
content: file.data.content,
protocol: protocol.name
}).then(function(json) {
$container.removeClass('loading');
return {
file: file,
json: json
};
});
}
function error(err) {
var notice = minder.getUI('widget/notice');
notice.error('err_localfile_read', err);
$container.removeClass('loading');
}
return {
load: function(filePromise, source) {
$container.addClass('loading');
return Promise.resolve(filePromise).then(load)['catch'](error);
},
support: function(file) {
return getProtocolByExtension(file.extension);
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 渲染当前时间离指定时间的时长
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/friendlytimespan', function(minder) {
$.extend($.fn, {
displayFriendlyTime: function(time) {
return this.each(function() {
display($(this)
.addClass('friendly-time')
.data('time', time));
});
}
});
function getTimeText(timeInMs) {
var ms = Math.abs(timeInMs - new Date()),
s = ms / 1000,
m = s / 60,
h = m / 60,
d = h / 24;
if (s < 60) return minder.getLang('ui.justnow', s | 0);
if (m < 60) return minder.getLang('ui.minutesago', m | 0);
if (h < 24) return minder.getLang('ui.hoursago', h | 0);
if (d < 2) return minder.getLang('ui.yesterday');
if (d <= 30) return minder.getLang('ui.daysago', d | 0);
return minder.getLang("ui.longago");
}
function display($element) {
$element.text(getTimeText($element.data('time')));
}
function update() {
$('.friendly-time').each(function() {
display($(this));
});
}
setInterval(update, 60000);
});
\ No newline at end of file
/**
* @fileOverview
*
* 提供存储在 LocalStorage 中的列表
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/locallist', function() {
function LocalList(name, maxCount) {
var list;
maxCount = maxCount || 10;
function load() {
list = localStorage.getItem(name);
if (list) {
list = JSON.parse(list);
} else {
list = [];
}
this.length = list.length;
}
function save() {
while (list.length > maxCount) list.pop();
localStorage.setItem(name, JSON.stringify(list));
this.length = list.length;
}
function get(index) {
return list[index];
}
function remove(index) {
list.splice(index, 1);
save();
}
function clear() {
list = [];
save();
}
function unshift(item) {
list.unshift(item);
save();
}
function createKeyMatcher(key) {
return function(item, value) {
return item[key] == value;
};
}
function findIndex(matcher, value) {
if (typeof(matcher) == 'string') {
matcher = createKeyMatcher(matcher);
}
for (var i = 0; i < list.length; i++) {
if (matcher(list[i], value)) return i;
}
return -1;
}
function find(matcher, value) {
return get(findIndex(matcher, value));
}
function forEach(callback) {
list.forEach(callback);
save();
}
load.call(this);
this.get = get;
this.remove = remove;
this.findIndex = findIndex;
this.find = find;
this.forEach = forEach;
this.unshift = unshift;
this.clear = clear;
}
return {
use: function(name) {
return new LocalList(name);
}
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 用 FUI.Tabs 实现的多级的创建
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KM.registerUI('widget/menutab', function(minder) {
function generate(parent, name, asDefault) {
var index = parent.getButtons().length;
var tab = parent.appendTab({
buttons: [{
label: minder.getLang('ui.menu.' + name + 'tab'),
className: 'tab-' + name
}]
});
if (asDefault) {
parent.select(index);
}
return tab[0].panel.getContentElement();
}
return {
generate: generate
};
});
\ No newline at end of file
/**
* @fileOverview
*
* 网盘的目录访问组件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/netdiskfinder', function(minder) {
var eve = minder.getUI('eve');
var notice = minder.getUI('widget/notice');
var recycleReady = null;
var base = '/apps/kityminder';
var recyclePath = base + '/.recycle';
var moveConfirm = true;
var instances = [];
var Finder = eve.setup({});
Finder.BASE_PATH = base + '/';
Finder.RECYCLE_PATH = recyclePath + '/';
Finder.on('mv', function(from, to, source) {
instances.forEach(function(instance) {
if (source != instance) instance.refresh();
});
});
/**
* 生成一个网盘的目录访问组件
*
* @param {JQueryObject} $container 容器
* @param {function} listFilter 一个函数,检查一个文件是否应该被列出
*/
function generate($container, listFilter) {
var finder = eve.setup({});
instances.push(finder);
var currentPath = base;
var $finder = $('<div class="netdisk-finder"></div>').appendTo($container);
/* 顶部工具栏 */
var $headbar = $('<div class="head"></div>').appendTo($finder);
/* 控制按钮 */
var $control = $('<div class="control"></div>').appendTo($headbar);
var $mkdir = $('<a></a>')
.text(minder.getLang('ui.mkdir'))
.attr('title', minder.getLang('ui.mkdir'))
.addClass('button mkdir')
.appendTo($control)
.click(mkdir);
var $recycle = $('<a></a>')
.text(minder.getLang('ui.recycle'))
.attr('title', minder.getLang('ui.recycle'))
.addClass('button recycle dir')
.data('file', {
path: recyclePath,
filename: minder.getLang('ui.recycle')
})
.appendTo($control)
.click(recycle);
var $recycleClear = $('<a></a>')
.text(minder.getLang('ui.recycle_clear'))
.attr('title', minder.getLang('ui.recycle_clear'))
.addClass('button recycle-clear')
.appendTo($control)
.click(clearRecycle);
/* 路径导航 */
var $nav = $('<div class="nav"></div>').appendTo($headbar);
/* 显示当前目录文件列表 */
var $list = $('<ul class="file-list"></ul>')
.appendTo($finder);
var selected = null;
minder.on('uiready', function() {
var $user = minder.getUI('topbar/user');
$user.requireLogin($container);
fio.user.on('login', function() {
list();
});
});
handleClick();
handleDrag();
handleNav();
handleRename();
function handleRename() {
$list.delegate('.file-list-item a.rename-button', 'click', function(e) {
var $li = $(e.target).closest('li');
$li.find('span.filename').remove();
rename($li);
$li.addClass('renaming');
e.stopPropagation();
});
function rename($li) {
rename.onprogress = true;
var file = $li.data('file');
var $input = $('<input>')
.attr('type', 'text')
.addClass('new-dir-name fui-widget fui-selectable')
.val(file.filename)
.appendTo($li);
$li.removeAttr('draggable');
$input.on('keydown', function (e) {
if (e.keyCode == 13) return confirm();
if (e.keyCode == 27) {
e.stopPropagation();
return cancel();
}
}).on('blur', cancel);
$input.on('dragstart mousedown mouseup click dblclick', function(e) {
e.stopPropagation();
});
setTimeout(function() {
$input[0].select();
});
function reset(filename) {
$input.remove();
$li.find('.icon').after('<span class="filename">' + filename + '</span>');
$li.removeClass('renaming');
$li.attr('draggable', true);
}
function cancel() {
reset(file.filename);
}
function confirm() {
var newFilename = $input.val();
var newPath = file.parentPath + newFilename;
if (file.filename == newFilename) return cancel();
if (fio.file.anlysisPath(newFilename).extension != file.extension) {
$input.addClass('invalid-name');
setTimeout(function () {
$input.removeClass('invalid-name');
}, 500);
return $input.select();
}
$container.addClass('loading');
mv(file.path, newPath).then(function () {
var oldPath = file.path;
file.filename = newFilename;
file.path = newPath;
reset(newFilename);
Finder.fire('mv', oldPath, newPath, finder);
notice.info(minder.getLang('ui.rename_success', newFilename));
})['catch'](function(e) {
notice.error('err_rename', e);
cancel();
}).then(function() {
$container.removeClass('loading');
});
}
}
}
function handleClick() {
/* 点击目录中的项目时打开项目 */
$list.delegate('.file-list-item', 'dblclick', function(e) {
if (currentPath == recyclePath + '/') return;
if (mkdir.onprogress) return mkdir.onprogress.select();
var $file = $(e.target).closest('li'),
file = $file.data('file');
if (file) open(file);
});
$list.delegate('.file-list-item', 'mousedown', function(e) {
if (mkdir.onprogress) return mkdir.onprogress.select();
var $file = $(e.target).closest('li'),
file = $file.data('file');
if (!file) return;
select(file && file.path);
});
}
function handleNav() {
/* 点击导航处,切换路径 */
$nav.delegate('a', 'click', function(e) {
if (mkdir.onprogress) return mkdir.onprogress.select();
if ($(e.target).hasClass('dir-back')) {
var parts = currentPath.split('/');
parts.pop(); // 有一个无效部分
parts.pop();
return list(parts.join('/'));
}
list($(e.target).data('path'));
});
}
function handleDrag() {
var fileItemSelector = '.file-list-item';
var dirSelector = '.dir';
var $dragging = null;
$list.delegate(fileItemSelector, 'dragstart', itemDragStart)
.delegate(fileItemSelector, 'dragend', itemDragEnd)
.delegate(dirSelector, 'dragover', dragOver)
.delegate(dirSelector, 'dragenter', dirDragEnter)
.delegate(dirSelector, 'dragleave', dirDragLeave)
.delegate(dirSelector, 'drop', dirDrop);
$headbar.delegate(dirSelector, 'dragover', dragOver)
.delegate(dirSelector, 'dragenter', dirDragEnter)
.delegate(dirSelector, 'dragleave', dirDragLeave)
.delegate(dirSelector, 'drop', dirDrop);
$list.delegate(fileItemSelector + ' input', 'dragstart', function(e) {
e.stopPropagation();
e.preventDefault();
});
function itemDragStart(e) {
var $target = $(e.target);
if (!$target.hasClass('file-list-item')) {
return;
}
// e.originalEvent.dataTransfer.effectAllowed = "move";
// e.originalEvent.dataTransfer.dropEffect = 'move';
try {
var dataType = kity.Browser.ie && kity.Browser.version == 10 ? 'text' : 'text/plain';
e.originalEvent.dataTransfer.setData(dataType, 'FEX');
e.originalEvent.dataTransfer.setDragImage($target.find('.icon').get(0), 12, 12);
} catch (ignore) {}
$dragging = $target.addClass('dragging');
$finder.addClass('drop-mode');
}
function itemDragEnd(e) {
$(e.target).removeClass('dragging');
e.originalEvent.dataTransfer.dropEffect = 'move';
e.preventDefault();
$finder.removeClass('drop-mode');
}
function dragOver(e) {
if ($(e.target).hasClass('filename')) e.preventDefault();
}
function dirDragEnter(e) {
var $target = $(e.target).closest('.dir');
$target.addClass('drag-enter');
if (e.target != $target[0]) $target.addClass('enter-child');
}
function dirDragLeave(e) {
if ($(e.target).hasClass('dir')) {
if ($(e.target).hasClass('enter-child')) {
return $(e.target).removeClass('enter-child');
}
$(e.target).removeClass('drag-enter');
}
}
function dirDrop(e) {
e.preventDefault();
var $target = $(e.target).closest('.dir').removeClass('drag-enter');
if (!$target.hasClass('dir')) return;
var source = $dragging.data('file');
var destination = $target.data('file');
var destinationPath = destination.path + '/' + source.filename;
var sourcePath = source.path;
if (destinationPath.indexOf(sourcePath) === 0) return;
if (!moveConfirm || window.confirm(minder.getLang('ui.move_file_confirm', source.filename, destination.filename))) {
$container.addClass('loading');
recycleReady.then(doMove);
moveConfirm = false;
}
function doMove() {
mv(sourcePath, destinationPath).then(function() {
$dragging.remove();
Finder.fire('mv', sourcePath, destinationPath, finder);
notice.info(minder.getLang('ui.move_success', source.filename, destination.filename));
})['catch'](function(e) {
notice.error('err_move_file', e);
}).then(function() {
$container.removeClass('loading');
});
}
}
}
function recycle() {
list(recyclePath);
}
function createRecycleBin() {
return fio.file.mkdir({
path: recyclePath
});
}
function clearRecycle() {
if (!window.confirm(minder.getLang('ui.recycle_clear_confirm'))) return;
$container.addClass('loading');
fio.file['delete']({
path: recyclePath
}).then(function() {
return recycleReady = createRecycleBin();
}).then(function() {
renderList([]);
$container.removeClass('loading');
});
}
function mv(source, destination) {
return fio.file.move({
path: source,
newPath: destination,
ondup: destination.indexOf(recyclePath) === 0 ? fio.file.DUP_RENAME : fio.file.DUP_FAIL
});
}
function mkdir() {
if (mkdir.onprogress) {
return mkdir.onprogress.select();
}
var $li = $('<li>').addClass('file-list-item dir').prependTo($list);
$li.append('<span class="icon"></span>');
var $input = $('<input>')
.attr('type', 'text')
.addClass('new-dir-name fui-widget fui-selectable')
.val(minder.getLang('ui.newdir'))
.appendTo($li);
mkdir.onprogress = $input[0];
$input[0].select();
$input.on('keydown', function(e) {
if (e.keyCode == 13) confirm();
if (e.keyCode == 27) {
cancel();
e.stopPropagation();
}
}).on('blur', confirm);
function cancel() {
$li.remove();
mkdir.onprogress = false;
}
function confirm() {
var name = $input.val();
if (name) {
$container.addClass('loading');
fio.file.mkdir({
path: currentPath + name
}).then(function() {
return new Promise(function(resolve) {
setTimeout(function() {
resolve(refresh());
}, 200);
});
}, function(e) {
if (e.detail && e.detail.error_code == 31061) {
e.message = '已存在同名目录';
}
var notice = minder.getUI('widget/notice');
notice.error('err_mkdir', e);
$li.remove();
}).then(function() {
$container.removeClass('loading');
mkdir.onprogress = false;
});
}
}
}
/**
* 返回数值的符号:
* 正数 => 1
* 0 => 0
* 负数 => -1
*/
function sign(num) {
return num > 0 ? 1 : (num < 0 ? -1 : 0);
}
/**
* 打开选中的文件或目录
*
* @param {fio.file.File} file
*/
function open(file) {
if (file.isDir) return list(file.path);
finder.fire('fileclick', file);
}
function fadeOutList(x) {
return new Promise(function(resolve, reject) {
$list.transit({
x: x,
opacity: 0
}, 100, resolve);
});
}
function fadeInList() {
return new Promise(function(resolve) {
$list.css({
x: -parseInt($list.css('x'))
}).stop().transit({
x: 0,
opacity: 1
}, 100, resolve);
});
}
function refresh() {
return list(currentPath, true);
}
/**
* 列出指定目录的文件
*/
function list(path, noAnimate) {
path = path || base;
var listPromise = fio.file.list({
path: path
});
var transitPromise = noAnimate ? Promise.resolve() : fadeOutList(-100 * sign(path.length - currentPath.length));
currentPath = path.charAt(path.length - 1) == '/' ? path : path + '/';
updateNav();
function checkRecycleBin(files) {
if (!recycleReady && path == base) {
for (var i = 0; i < files.length; i++) {
if (files[i].path == recyclePath) {
recycleReady = Promise.resolve(true);
}
break;
}
recycleReady = recycleReady || createRecycleBin();
}
}
return Promise.all([listPromise, transitPromise]).then(function(values) {
var files = values[0];
checkRecycleBin(files);
return renderList(files);
}, function(error) {
var notice = minder.getUI('widget/notice');
notice.error('err_ls', error);
});
}
function renderFileList(files) {
$list.empty();
if (!files.length) {
$list.append('<li class="empty" disabled="disabled">' + minder.getLang('ui.emptydir') + '</li>');
} else {
files.forEach(function(file) {
if (!file.isDir && (!listFilter || !listFilter(file))) return;
if (file.path == recyclePath) return;
$('<li></li>')
.append('<span class="icon"></span>')
.append('<span class="filename">' + file.filename + '</span>')
.append('<a class="rename-button" title="' + minder.getLang('ui.rename') + '">"' + minder.getLang('ui.rename') + '"</a>')
.addClass('file-list-item')
.addClass(file.isDir ? 'dir' : 'file')
.data('file', file)
.attr('draggable', true)
.appendTo($list);
});
}
}
finder._renderFileList = renderFileList;
function renderList(files) {
files.sort(function(a, b) {
if (a.isDir > b.isDir) {
return -1;
} else if (a.isDir == b.isDir) {
return a.createTime > b.createTime ? -1 : 1;
} else return 1;
});
renderFileList(files);
// 通知其他 finder 更新
instances.forEach(function(instance) {
if (instance == finder) return;
if (instance.pwd() == currentPath)
instance._renderFileList(files);
});
fadeInList();
checkSelect();
finder.fire('cd', currentPath);
}
function updateNav() {
$nav.empty();
if (currentPath != base && currentPath != base + '/') {
$nav.append('<a class="dir-back">Back</a>');
} else {
$nav.append('<span class="my-document"></span>');
}
var path = currentPath.substr(base.length);
var parts = path.split('/');
var processPath = '';
function pathButton(part) {
processPath += part + '/';
var $a = $('<a></a>').addClass('dir');
if (part == base) {
$a.text(minder.getLang('ui.mydocument'));
} else if (part == '.recycle') {
$a.text(minder.getLang('ui.recycle'));
$finder.addClass('recycle-bin');
} else {
$a.text(part);
}
return $a.data('path', processPath).data('file', {
path: processPath.substr(0, processPath.length - 1),
filename: part == base ? minder.getLang('ui.mydocument') : part
});
}
$finder.removeClass('recycle-bin');
$nav.append(pathButton(base));
parts.forEach(function(part) {
if (!part) return;
$nav.append('<span class="spliter"></span>');
$nav.append(pathButton(part));
});
}
function select(path) {
selected = path;
return checkSelect();
}
function checkSelect() {
var hasSelect = false;
$list.find('.file-list-item').removeClass('selected').each(function() {
var file = $(this).data('file');
if (file && file.path == selected) {
$(this).addClass('selected');
hasSelect = true;
$list[0].focus();
finder.fire('select', file, this);
}
});
if (!hasSelect) selected = false;
return hasSelect;
}
function pwd() {
return currentPath;
}
finder.list = list;
finder.select = select;
finder.pwd = pwd;
finder.refresh = refresh;
return finder;
}
Finder.generate = generate;
return Finder;
});
\ No newline at end of file
/**
* @fileOverview
*
* 通知小组件
*
* @author: techird
* @copyright: Baidu FEX, 2014
*/
KityMinder.registerUI('widget/notice', function (minder) {
var errorMessage = minder.getLang('error_message');
var memory = minder.getUI('memory');
var $notice = $('<div>')
.addClass('notice-widget')
.appendTo('#content-wrapper');
var $mask = $('<div>')
.addClass('error-mask');
var $error = new FUI.Dialog({
width: 500,
height: 'auto',
prompt: true,
caption: errorMessage.title,
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() {
var scripts = [].slice.apply(document.getElementsByTagName('script'));
var s, m;
while( (s = scripts.pop()) ) {
if ( (m = /kityminder.*\.min\.js/.exec(s.src))) return m[0];
}
return false;
})();
// concatMap: sperate files -> join file
// minMap: join file -> min file
var concatMap, minMap;
function fixSourceSymbol($ta, $mask) {
function fix() {
var text = $ta.text();
var pattern = new RegExp('at.+' + isBuilded + '.+\\:(\\d+)\\:(\\d+)\\)?', 'g');
var match;
$ta.text(text.replace(pattern, function(match, $1, $2) {
var lookup = {line: +$1, column: +$2};
var info = minMap.originalPositionFor(lookup);
var name = info.name;
lookup = {line: info.line, column: info.column};
info = concatMap.originalPositionFor(lookup);
name = name || '<Anonymous>';
var replaced = 'at ' + name + ' (' +
info.source.replace('../', '') + ':' + info.line + ':' + info.column + ')';
if (replaced.indexOf('promise') != -1) {
replaced = 'at <async> Promise.' + name;
}
return replaced;
}));
}
if (isBuilded) {
if (concatMap) return fix();
$mask.addClass('loading');
setTimeout(function() {
$mask.removeClass('loading');
}, 5000);
var script = document.createElement('script');
script.onload = function() {
Promise.all([
$.pajax({
url: isBuilded.replace('min.js', 'js.map'),
dataType: 'json'
}),
$.pajax({
url: isBuilded.replace('.js', '.map'),
dataType: 'json'
})
]).then(function(files) {
concatMap = new window.sourceMap.SourceMapConsumer(files[0]);
minMap = new window.sourceMap.SourceMapConsumer(files[1]);
fix();
$mask.removeClass('loading');
});
};
script.src = 'lib/source-map.min.js';
document.head.appendChild(script);
}
}
$error_body.delegate('.error-detail a.expander', 'click', function(e) {
var $detail = $(e.target).closest('.error-detail').toggleClass('expanded');
var showDetail = $detail.hasClass('expanded');
memory.set('show-error-detail', showDetail);
});
function info(msg, warn, time) {
if (!$notice.hasClass('show')) $notice.empty();
clearTimeout(info.ttl2);
if (warn) $notice.addClass('warn');
else $notice.removeClass('warn');
$notice.css({
top: minder.getUI('menu/menu').isVisible() ? $('#main-menu .main-menu-level1').offset().top : $('#kityminder').offset().top + 20
});
$notice.append('<p>' + msg + '</p>');
$notice.addClass('show');
clearTimeout(info.ttl);
time = time || (warn ? 5000 : 3000);
info.ttl = setTimeout(function() {
$notice.removeClass('show');
info.ttl2 = setTimeout(function() {
$notice.empty();
}, 1000);
}, time);
}
function warn(msg) {
info(msg, warn);
}
function descriptReason(e) {
e = e || new Error();
if (typeof(e) == 'string') {
e = new Error(e);
}
if (e.getDetail) return e;
// 文件访问错误
if (typeof(fio) != 'undefined' && (e instanceof fio.FileRequestError)) {
if (!e.status) {
e.description = errorMessage.err_network;
} else {
e.description = errorMessage.pcs_code[e.detail.error_code];
}
e.getDetail = function() {
return JSON.stringify(e, null, 4);
};
} else if (e instanceof Error) {
e.getDetail = function() {
return e.stack;
};
}
return e;
}
function error(name, e) {
if (arguments.length == 1) {
e = name;
name = 'unknown';
}
$error_body.empty();
e = descriptReason(e);
var $content = $('<div>')
.addClass('error-content')
.appendTo($error_body);
var $msg = $('<h3>')
.text(errorMessage[name] || errorMessage.err_unknown)
.appendTo($content);
var $reason = $('<p>')
.text(e.message || e.description || errorMessage.unknownreason)
.appendTo($content);
if (e.getDetail) {
var $detail = $('<div>')
.addClass('error-detail')
.append($('<a class="expander"></a>').text(minder.getLang('ui.error_detail')))
.appendTo($error_body);
var $detailContent = $('<div>')
.addClass('error-detail-wrapper')
.appendTo($detail);
var $textarea = $('<textarea>')
.attr('id', 'error-detail-content')
.text(e.getDetail() + '\n\n浏览器信息:' + navigator.userAgent)
.appendTo($detailContent);
fixSourceSymbol($textarea, $detailContent);
var $copy = $('<button>')
.addClass('copy-and-feedback')
.text(minder.getLang('ui.copy_and_feedback'))
.appendTo($detailContent);
$copy.attr('data-clipboard-target', 'error-detail-content');
zeroCopy($copy);
if (memory.get('show-error-detail')) $detail.addClass('expanded');
}
$error.show();
$error.getElement().style.top = '180px';
return new Promise(function(resolve) {
error.resolve = resolve;
});
}
function zeroCopy($target) {
/* global ZeroClipboard:true */
if (window.ZeroClipboard) {
ZeroClipboard.config({
swfPath: 'lib/ZeroClipboard.swf',
hoverClass: 'hover',
activeClass: 'active'
});
var clip = new window.ZeroClipboard($target);
clip.on('ready', function () {
clip.on('aftercopy', function() {
$error.hide();
minder.getUI('topbar/feedback').click();
});
});
} else {
$target.remove();
}
}
return {
info: info,
error: error,
warn: warn
};
});
\ No newline at end of file
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