Commit 7053dcf0 authored by campaign's avatar campaign

Merge branch 'dev' of https://github.com/fex-team/kityminder into dev

parents ed72c683 f320920a
# KityMinder Change Log # KityMinder Change Log
## v1.2.0 ## v1.1.1
### 功能更新 ### 功能更新
1.添加快捷键,新建脑图(ctrl+n),分享脑图(ctrl+shift+s),保存脑图(ctrl+s)
1. 添加文件操作快捷键支持:
* 新建脑图(`Ctrl` + `N`
* 保存脑图到云端(`Ctrl` + `S`
* 分享脑图(`Ctrl` + `Shift` + `S`
2. 草稿功能升级为草稿箱
3. 添加了帮助菜单
## v1.1.0 ## v1.1.0
......
/*! /*!
* ==================================================== * ====================================================
* kityminder - v1.0.0 - 2014-03-19 * kityminder - v1.0.0 - 2014-03-24
* https://github.com/fex-team/kityminder * https://github.com/fex-team/kityminder
* GitHub: https://github.com/fex-team/kityminder.git * GitHub: https://github.com/fex-team/kityminder.git
* Copyright (c) 2014 f-cube @ FEX; Licensed MIT * Copyright (c) 2014 f-cube @ FEX; Licensed MIT
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
var KityMinder = window.KM = window.KityMinder = function () { var KityMinder = window.KM = window.KityMinder = function () {
var instanceMap = {}, instanceId = 0; var instanceMap = {}, instanceId = 0;
return { return {
version: '1.1.0', version: '1.1.1',
createMinder: function ( renderTarget, options ) { createMinder: function ( renderTarget, options ) {
options = options || {}; options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget; options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
...@@ -1450,7 +1450,11 @@ var keymap = KityMinder.keymap = { ...@@ -1450,7 +1450,11 @@ var keymap = KityMinder.keymap = {
'y':89, 'y':89,
//粘贴 //粘贴
'v' : 86, 'v' : 86,
'x' : 88 'x' : 88,
's' : 83,
'n' : 78
}; };
//添加多语言模块 //添加多语言模块
...@@ -5555,16 +5559,16 @@ KM.ui.define('menu',{ ...@@ -5555,16 +5559,16 @@ KM.ui.define('menu',{
}); });
//dropmenu 类 //dropmenu 类
KM.ui.define('dropmenu', { KM.ui.define( 'dropmenu', {
tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' + tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' +
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' + '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' + '<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' + '<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' + '<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
'</li><%}}%>' + '</li><%}}%>' +
'<%}%>'+ '<%}%>' +
'</ul>', '</ul>',
subTmpl:'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' + subTmpl: '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' + '<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' + '<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' + '<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
...@@ -5572,32 +5576,34 @@ KM.ui.define('dropmenu', { ...@@ -5572,32 +5576,34 @@ KM.ui.define('dropmenu', {
'<%}%>', '<%}%>',
defaultOpt: { defaultOpt: {
data: [], data: [],
click: function () { anchor: 'top',
} click: function () {}
}, },
setData:function(items){ setData: function ( items ) {
this.root().html($.parseTmpl(this.subTmpl,items)); this.root().html( $.parseTmpl( this.subTmpl, items ) );
return this; return this;
}, },
position:function(offset){ position: function ( offset ) {
this.root().css({ this.root().css( {
left:offset.x, left: offset.x,
top:offset.y top: offset.y
}); } );
return this; return this;
}, },
show:function(){ show: function () {
if(this.trigger('beforeshow') === false){ if ( this.trigger( 'beforeshow' ) === false ) {
return; return;
}else{ } else {
this.root().css({display:'block'}); this.root().css( {
this.trigger('aftershow'); display: 'block'
} );
this.trigger( 'aftershow' );
} }
return this; return this;
}, },
init: function (options) { init: function ( options ) {
var me = this; var me = this;
var eventName = { var eventName = {
click: 1, click: 1,
...@@ -5605,55 +5611,57 @@ KM.ui.define('dropmenu', { ...@@ -5605,55 +5611,57 @@ KM.ui.define('dropmenu', {
mouseout: 1 mouseout: 1
}; };
this.root($($.parseTmpl(this.tmpl, options))).on('click', 'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]',function (evt) { this.root( $( $.parseTmpl( this.tmpl, options ) ) ).on( 'click', 'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]', function ( evt ) {
$.proxy(options.click, me, evt, $(this).data('value'), $(this).data('label'),$(this))() $.proxy( options.click, me, evt, $( this ).data( 'value' ), $( this ).data( 'label' ), $( this ) )();
}).find('li').each(function (i, el) { } ).find( 'li' ).each( function ( i, el ) {
var $this = $(this); var $this = $( this );
if (!$this.hasClass("kmui-disabled kmui-divider kmui-dropdown-submenu")) { if ( !$this.hasClass( "kmui-disabled kmui-divider kmui-dropdown-submenu" ) ) {
var data = options.data[i]; var data = options.data[ i ];
$.each(eventName, function (k) { $.each( eventName, function ( k ) {
data[k] && $this[k](function (evt) { if ( data[ k ] ) {
$.proxy(data[k], el)(evt, data, me.root) $this[ k ]( function ( evt ) {
}) $.proxy( data[ k ], el )( evt, data, me.root );
}) } );
} }
}); } );
}
} );
}, },
_initEvent:function(){ _initEvent: function () {
this.root().on('mouseover','li[class="kmui-dropdown-submenu',function(e){ this.root().on( 'mouseover', 'li[class="kmui-dropdown-submenu', function ( e ) {
var $submenu = $(this).data('widget'); var $submenu = $( this ).data( 'widget' );
$submenu.kmui().show($(this),'right','position',5,2) $submenu.kmui().show( $( this ), 'right', 'position', 5, 2 );
}); } );
}, },
disabled: function (cb) { disabled: function ( cb ) {
$('li[class!=kmui-divider]', this.root()).each(function () { $( 'li[class!=kmui-divider]', this.root() ).each( function () {
var $el = $(this); var $el = $( this );
if (cb === true) { if ( cb === true ) {
$el.addClass('kmui-disabled') $el.addClass( 'kmui-disabled' );
} else if ($.isFunction(cb)) { } else if ( $.isFunction( cb ) ) {
$el.toggleClass('kmui-disabled', cb(li)) $el.toggleClass( 'kmui-disabled', cb( $el ) );
} else { } else {
$el.removeClass('kmui-disabled') $el.removeClass( 'kmui-disabled' );
} }
}); } );
}, },
val: function (val) { val: function ( val ) {
var currentVal; var currentVal;
$('li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]', this.root()).each(function () { $( 'li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]', this.root() ).each( function () {
var $el = $(this); var $el = $( this );
if (val === undefined) { if ( val === undefined ) {
if ($el.find('em.kmui-dropmenu-checked').length) { if ( $el.find( 'em.kmui-dropmenu-checked' ).length ) {
currentVal = $el.data('value'); currentVal = $el.data( 'value' );
return false return false;
} }
} else { } else {
$el.find('em').toggleClass('kmui-dropmenu-checked', $el.data('value') == val) $el.find( 'em' ).toggleClass( 'kmui-dropmenu-checked', $el.data( 'value' ) == val );
} }
}); } );
if (val === undefined) { if ( val === undefined ) {
return currentVal return currentVal;
} }
}, },
appendItem: function ( item ) { appendItem: function ( item ) {
...@@ -5665,21 +5673,21 @@ KM.ui.define('dropmenu', { ...@@ -5665,21 +5673,21 @@ KM.ui.define('dropmenu', {
var $item = $( html ).click( item.click ); var $item = $( html ).click( item.click );
this.root().append( $item ); this.root().append( $item );
}, },
addSubmenu: function (label, menu, index) { addSubmenu: function ( label, menu, index ) {
index = index || 0; index = index || 0;
var $list = $('li[class!=kmui-divider]', this.root()); var $list = $( 'li[class!=kmui-divider]', this.root() );
var $node = $('<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>').append(menu); var $node = $( '<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>' ).append( menu );
$node.data('widget',menu); $node.data( 'widget', menu );
if (index >= 0 && index < $list.length) { if ( index >= 0 && index < $list.length ) {
$node.insertBefore($list[index]); $node.insertBefore( $list[ index ] );
} else if (index < 0) { } else if ( index < 0 ) {
$node.insertBefore($list[0]); $node.insertBefore( $list[ 0 ] );
} else if (index >= $list.length) { } else if ( index >= $list.length ) {
$node.appendTo($list); $node.appendTo( $list );
} }
} }
}, 'menu'); }, 'menu' );
//splitbutton 类 //splitbutton 类
///import button ///import button
......
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -8,6 +8,27 @@ function DraftManager( minder ) { ...@@ -8,6 +8,27 @@ function DraftManager( minder ) {
function init() { function init() {
drafts = localStorage.getItem( 'drafts' ); drafts = localStorage.getItem( 'drafts' );
drafts = drafts ? JSON.parse( drafts ) : []; drafts = drafts ? JSON.parse( drafts ) : [];
loadDraftForOldVersion();
}
/**
* @todo 1.2 版本中删除该方法
*
* 加载老版本的草稿
*/
function loadDraftForOldVersion() {
var path = localStorage.getItem( 'draft_filename' ),
data = localStorage.getItem( 'draft_data' );
if ( path && data ) {
drafts.push( {
path: path,
data: data,
name: JSON.parse( data ).data.text,
update: new Date()
} );
localStorage.removeItem( 'draft_filename' );
localStorage.removeItem( 'draft_data' );
}
} }
function store() { function store() {
...@@ -49,7 +70,7 @@ function DraftManager( minder ) { ...@@ -49,7 +70,7 @@ function DraftManager( minder ) {
} }
function save( path ) { function save( path ) {
if ( current === null ) { if ( !current ) {
create(); create();
} else { } else {
current.path = path || current.path; current.path = path || current.path;
......
...@@ -338,6 +338,7 @@ $( function () { ...@@ -338,6 +338,7 @@ $( function () {
var data = minder.exportData( 'json' ); var data = minder.exportData( 'json' );
var sto = baidu.frontia.personalStorage; var sto = baidu.frontia.personalStorage;
try {
sto.uploadTextFile( data, remotePath || generateRemotePath(), { sto.uploadTextFile( data, remotePath || generateRemotePath(), {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY, ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) { success: function ( savedFile ) {
...@@ -351,10 +352,14 @@ $( function () { ...@@ -351,10 +352,14 @@ $( function () {
draftManager.save( remotePath ); draftManager.save( remotePath );
}, },
error: function ( error ) { error: function ( error ) {
window.alert( '保存到云盘失败,建议您将脑图以 .km 格式导出到本地!' ); notice( '保存到云盘失败,建议您将脑图以 .km 格式导出到本地!' );
$save_btn.loading( false ); $save_btn.loading( false );
} }
} ); } );
} catch ( e ) {
notice( '保存到云盘失败:' + e.message + '\n建议您将脑图以 .km 格式导出到本地!' );
$save_btn.loading( false );
}
$save_btn.loading( '正在保存...' ); $save_btn.loading( '正在保存...' );
} }
...@@ -457,7 +462,8 @@ $( function () { ...@@ -457,7 +462,8 @@ $( function () {
var list = draftManager.list(), var list = draftManager.list(),
draft, $draft, index; draft, $draft, index;
if ( !list.length ) { if ( !list.length ) {
return false; draftManager.create();
list = draftManager.list();
} }
draft = list.shift(); draft = list.shift();
...@@ -488,7 +494,7 @@ $( function () { ...@@ -488,7 +494,7 @@ $( function () {
function adjustDraftMenu() { function adjustDraftMenu() {
var pos = $draft_btn.offset(); var pos = $draft_btn.offset();
pos.top -= $draft_menu.outerHeight() + 15; pos.top -= $draft_menu.outerHeight() + 5;
$draft_menu.offset( pos ); $draft_menu.offset( pos );
} }
...@@ -516,10 +522,14 @@ $( function () { ...@@ -516,10 +522,14 @@ $( function () {
function loadDraft( index ) { function loadDraft( index ) {
var draft = draftManager.open( index ), var draft = draftManager.open( index ),
isRemote;
if ( !draft ) return;
isRemote = draft.path.indexOf( '/apps/kityminder' ) === 0; isRemote = draft.path.indexOf( '/apps/kityminder' ) === 0;
if ( draft && isRemote ) { if ( isRemote ) {
setRemotePath( draft.path, false ); setRemotePath( draft.path, false );
} }
draftManager.load(); draftManager.load();
if ( !isRemote ) { if ( !isRemote ) {
setRemotePath( null, false ); setRemotePath( null, false );
......
var KityMinder = window.KM = window.KityMinder = function () { var KityMinder = window.KM = window.KityMinder = function () {
var instanceMap = {}, instanceId = 0; var instanceMap = {}, instanceId = 0;
return { return {
version: '1.1.0', version: '1.1.1',
createMinder: function ( renderTarget, options ) { createMinder: function ( renderTarget, options ) {
options = options || {}; options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget; options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
......
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