Commit 4540940b authored by Ronny's avatar Ronny

Merge remote-tracking branch 'origin/dev' into dev

parents 96fdebdb dc9d662f
# KityMinder 更新日志
## v1.2.0
## v1.1.2
### 功能更新
1. 支持本地格式文件导入
* 支持文件拖拽和网盘文件导入
* 格式支持xmind/freemind/mindmanager,其他格式不支持
* 支持标签,包括优先级和任务进度
* 格式支持 xmind/freemind/mindmanager,其他格式不支持
2. 新增节点移动到视野中
3. 当前文件名加到 Title 中
4. 分享链接直接到粘贴板(针对已经支持的浏览器)
5. 分享到社交网络
6. 用户登出功能
7. 添加只读模式,配置项 readOnly,添加动态调用接口setEnabled,setDisabled
8. 优化当下拉菜单不可执行时,下拉菜单按钮会自动变灰
9. 新图标
### 问题修复
1. 导出 png 和 svg 图片时,文本中如果包含 ` ` 字符会报错的问题
2. 删除中心节点导致页面卡住
3. 文件在IE下无法导出(.txt,.svg,.km)
4. 拖入文件导入之后,草稿箱和社会化文件名不同步
5. 仅有根节点时,将其删除,再添加节点报错
6. 本地部署,127.0.0.1退出后不能登录
7. 去掉了“导出”菜单上的打勾
## v1.1.1
......
The MIT License (MIT)
Copyright (c) 2014, FEX,Baidu.
All rights reserved.
Copyright (c) 2013 KityMinder
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* Neither the name of the {organization} nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\ No newline at end of file
......@@ -13,14 +13,14 @@
<script src="../dev/import.php" charset="utf-8"></script>
<script src="../kityminder.config.js" charset="utf-8"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lib/zip.js" charset="utf-8"></script>
<script src="../lib/jquery.xml2json.js" charset="utf-8"></script>
<script src="../lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="../social/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script>
<link href="../social/social.css" rel="stylesheet">
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet" />
<link href="../dialogs/dialogs.css" rel="stylesheet" type="text/css" />
<link href="favicon.ico" type="image/x-icon" rel="shortcut icon">
......@@ -44,7 +44,8 @@
<a href="#" class="bds_weixin" data-cmd="weixin" title="分享到微信"></a>
</p>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdMini":"2","bdMiniList":[],"bdPic":"","bdStyle":"1","bdSize":"32"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
</body>
<script>
// create km instance
......
......@@ -2,14 +2,20 @@
<html>
<head>
<meta charset="utf-8">
<script src="../lib/jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="../lib/ZeroClipboard.min.js" charset="utf-8"></script>
<script type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: '../lib/ZeroClipboard.swf' } );
</script>
<script src="../kity/dist/kitygraph.all.min.js" charset="utf-8"></script>
<script src="../dist/kityminder.all.min.js" charset="utf-8"></script>
<script src="../kityminder.config.js" charset="utf-8"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<script src="../lib/zip.js" charset="utf-8"></script>
<script src="../lib/jquery.xml2json.js" charset="utf-8"></script>
<script src="../lib/baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="../social/draftmanager.js" charset="utf-8"></script>
<script src="../social/social.js" charset="utf-8"></script>
......@@ -30,7 +36,7 @@
<h3>URL分享:</h3>
<p>
<input id="share-url" type="url" value="" />
<button id="copy-share-url" type="button">复制</button>
<button id="copy-share-url" data-clipboard-target="share-url" type="button">复制</button>
</p>
<h3>社交分享:</h3>
<p id="share-platform" class="bdsharebuttonbox">
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -62,11 +62,12 @@
window.KITYMINDER_CONFIG = {
'KITYMINDER_HOME_URL': getKMBasePath()
//定义工具栏
,toolbars: [
,
toolbars: [
'hand zoom-in zoom-out | undo redo | bold italic | fontfamily fontsize forecolor | saveto | markers | node | switchlayout | help'
]
],
//只读模式,默认是false
//readOnly : false
//readOnly: true
//设置主题
//,defaultlayoutstyle : 'default' //设置默认的主题
......@@ -81,4 +82,4 @@
//设置km整体的z-index大小
//,zIndex : 1000
};
} )()
\ No newline at end of file
} )();
\ No newline at end of file
......@@ -77,7 +77,7 @@ $( function () {
// 脑图实例
minder = window.km,
// 草稿箱
draftManager = window.draftManager || new window.DraftManager( minder ),
draftManager = window.draftManager || ( window.draftManager = new window.DraftManager( minder ) ),
// 当前是否要检测文档内容是否变化的开关
watchingChanges = true,
......@@ -681,4 +681,10 @@ $( function () {
return "很久之前";
}
window.social = {
setRemotePath: setRemotePath,
watchChanges: function ( value ) {
watchingChanges = value;
}
};
} );
\ No newline at end of file
/**
* Created by dongyancen on 14-3-26.
*/
var fs = require('fs');
var browsers = ['Chrome', 'Firefox', 'PhantomJS', 'IE'];
var result_forBrowser = {};
var jsonFileBasePath = './spec/coverage/json_files/';
var jsonFiles = fs.readdirSync(jsonFileBasePath);
var finalJsonFile = 'defaultFileName';
var curPath = '/spec';
var resultPath = 'spec/coverage';
//找出所有的json文件
for (var i = 0; i < jsonFiles.length; i++) {
// json文件名必须是有8位的日期和6位的时间戳如:-20140326_161249
if (!isJsonFiles(jsonFiles[i])) {
jsonFiles.splice(i, 1);
i--;
}
}
//没有找到合适的文件
if(jsonFiles.length==0)return;
//先排序 按时间从小到大 及从旧到新
jsonFiles.sort(function (f1, f2) {
var t1 = getFileTime(f1);//形如['-20140326_161249','20140326','161249']
var t2 = getFileTime(f2);
var dateDiff = parseInt(t1[1]) - parseInt(t2[1]);
if (dateDiff != 0)return dateDiff;
else return parseInt(t1[2]) - parseInt(t2[2]);
});
//以时间命名新的文件
finalJsonFile = getFileTime(jsonFiles[jsonFiles.length-1])[0].substring(1);
//如:20140326_161249
//取最新的
// 按浏览器类型分类 result_forBrowser属性形如:{'Crome':'filename1','Firefox':'filename2'}
for (i = 0; i < jsonFiles.length; i++) {
for (var j = 0; j < browsers.length; j++) {
if (eval('/' + browsers[j] + '/.test("' + jsonFiles[i] + '");')) {
eval('result_forBrowser.' + browsers[j] + '="' + jsonFiles[i] + '";');
}
}
}
//以上得到所有要合计的json文件
//读取,合计数字,需要合计的属性: 's' 'b' 'f' 'l'
//修正路径
var jsonToWrite = null;
for (var a in result_forBrowser) {
var r = fs.readFileSync(jsonFileBasePath + result_forBrowser[a]);
if (!jsonToWrite) {
jsonToWrite = JSON.parse(r);
continue;
} else {
jsonToWrite = mergeResult(jsonToWrite, JSON.parse(r));
}
}
//写文件
fs.writeFileSync(jsonFileBasePath+finalJsonFile+'.json',JSON.stringify(jsonToWrite));
function isJsonFiles(fileName) {
var e = fileName.substring(fileName.lastIndexOf(".") + 1);
// json文件名必须是有8位的日期和6位的时间戳如:-20140326_161249
//否则无法判断文件生成时间,也就无法合并同一次运行产生的结果
return e == 'json' && getFileTime(fileName);
}
function getFileTime(fileName) {
// json文件名必须是有8位的日期和6位的时间戳如:-20140326_161249
return fileName.match(/-(\d{8})_(\d{6})/);
}
function mergeResult(allR, addR) {
var resultR = {};
for (var allRKey in allR) {
if (addR[allRKey]) {
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 's', 1);
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 'f', 1);
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 'l', 1);
allR[allRKey] = mergeDetail(allR[allRKey], addR[allRKey], 'b', 2);
}
//修正路径
resultR[fixPath(allRKey)] = allR[allRKey]
}
return resultR;
}
//type = 1 合并 s f l ,如:{"1":1,"2":1,"3":1}
//type = 2 合并 b ,如:{"1":[0,0],"2":[0,0]}
function mergeDetail(allEle, addEle, attrName, type) {
if (allEle[attrName] && addEle[attrName]) {
if (type == 1) {
for (var k in allEle[attrName]) {
//todo 现在没有考虑两个文件中同一项覆盖率的统计行数不一致的问题
if ( parseInt(allEle[attrName][k])==0 && parseInt(addEle[attrName][k]) ==1) {
allEle[attrName][k] = 1;
}
}
}
else if (type == 2) {
for (var k in allEle[attrName]) {
//todo 现在没有考虑两个文件中同一项覆盖率的统计行数不一致的问题
if (addEle[attrName][k]) {
if (parseInt(allEle[attrName][k][0])==0 &&parseInt(addEle[attrName][k][0])==1 ) {
allEle[attrName][k][0] = 1;
}
if (parseInt(allEle[attrName][k][1])==0 &&parseInt(addEle[attrName][k][1])==1 ) {
allEle[attrName][k][1] = 1;
}
}
}
}
}
return allEle;
}
//修正路径
function fixPath(oldPath){
//例如把 "D:/workspace/ufinder/_src/core/finder.js" 修正为
// spec/coverage/_src/core/finder.js 注意这里一定要用相对路径(相对于_spec/coverage)
var s = __dirname.replace(/\\/g,'/');
if(s.lastIndexOf(curPath)){
s = s.substring(0,s.lastIndexOf(curPath) );
}
oldPath = oldPath.replace(s,resultPath);
return oldPath;
}
console.log(finalJsonFile);
\ No newline at end of file
setlocal EnableDelayedExpansion
del /q /s .\spec\coverage\json_files\*.json
rd /s /q .\coverage
for /f %%j in ('karma start ./spec/karma.conf.js') do set karmaRe=%%j
for /f %%i in ('node ./spec/mergeCoverageForIstanbul.js') do set re=%%i
for /f %%i in ('node ./spec/_mergeCoverageForIstanbul.js') do set re=%%i
istanbul report html spec/coverage/json_files/%re%.json
\ No newline at end of file
......@@ -4,7 +4,7 @@
var fs = require('fs');
var browsers = ['Chrome', 'Firefox', 'PhantomJS', 'IE'];
var result_forBrowser = {};
var jsonFileBasePath = './spec/coverage/json_files/';
var jsonFileBasePath = './coverage/json_files/';
var jsonFiles = fs.readdirSync(jsonFileBasePath);
var finalJsonFile = 'defaultFileName';
var curPath = '/spec';
......
......@@ -3,4 +3,3 @@ del /q /s .\coverage\json_files\*.json
for /f %%j in ('karma start ./karma.conf.js') do set karmaRe=%%j
for /f %%i in ('node ./mergeCoverageForIstanbul.js') do set re=%%i
istanbul report html coverage/json_files/%re%.json
pause
......@@ -55,8 +55,11 @@ utils.extend( KityMinder, function () {
} );
btns.length && $toolbar.kmui().appendToBtnmenu( btns );
} );
$toolbar.append( $( '<div class="kmui-dialog-container"></div>' ) );
}else{
$toolbar.hide()
}
$toolbar.append( $( '<div class="kmui-dialog-container"></div>' ) );
},
_createStatusbar: function ( $statusbar, km ) {
......
......@@ -22,7 +22,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
});
//实例化
$combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui();
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( name, res.value );
......@@ -37,6 +37,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
var state = this.queryCommandState( name ),
value = this.queryCommandValue( name );
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
if ( value ) {
......@@ -44,6 +45,7 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
value = value.replace( /['"]/g, '' ).toLowerCase().split( /['|"]?\s*,\s*[\1]?/ );
comboboxWidget.selectItemByLabel( value );
}
} );
var data = [];
......
......@@ -25,7 +25,7 @@ KM.registerToolbarUI( 'node', function ( name ) {
//实例化
$combox = $.kmuibuttoncombobox( transForInserttopic( options ) ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui();
var comboboxWidget = $combox.kmui();
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
me.execCommand( res.value, new MinderNode( me.getLang().topic ), true );
......@@ -43,7 +43,20 @@ KM.registerToolbarUI( 'node', function ( name ) {
}
} )
} );
//状态反射
me.on( 'interactchange', function () {
var state = 0;
utils.each( shortcutKeys, function ( k ) {
state = me.queryCommandState( k );
if ( state != -1 ) {
return false;
}
} );
//设置按钮状态
comboboxWidget.button().kmui().disabled( state == -1 ).active( state == 1 );
} );
//comboboxWidget.button().kmui().disabled(-1);
return comboboxWidget.button().addClass( 'kmui-combobox' );
......
......@@ -10,14 +10,15 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
itemStyles: [],
value: [],
autowidthitem: [],
enabledRecord: false
enabledRecord: false,
enabledSelected:false
},
$combox = null,
comboboxWidget = null;
utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) {
var p = KityMinder.findProtocal( k );
if( p.encode ){
if ( p.encode ) {
var text = p.fileDescription + '(' + p.fileExtension + ')';
options.value.push( k );
options.items.push( text );
......@@ -34,20 +35,58 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var a = document.createElement( 'a' );
a.setAttribute( 'download', filename );
a.setAttribute( 'href', url );
a.dispatchEvent( new MouseEvent( 'click' ) );
var evt;
try {
evt = new MouseEvent( 'click' );
} catch ( error ) {
evt = document.createEvent( 'MouseEvents' );
evt.initEvent( 'click', true, true );
}
a.dispatchEvent( evt );
}
var ie_ver = function () {
var iev = 0;
var ieold = ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) );
var trident = !! navigator.userAgent.match( /Trident\/7.0/ );
var rv = navigator.userAgent.indexOf( "rv:11.0" );
if ( ieold ) iev = new Number( RegExp.$1 );
if ( navigator.appVersion.indexOf( "MSIE 10" ) != -1 ) iev = 10;
if ( trident && rv != -1 ) iev = 11;
return iev;
};
var doSave = function ( urltype, d, filename ) {
var iframe = document.createElement( 'iframe' );
iframe.style.display = 'none';
document.body.appendChild( iframe );
iframe.contentDocument.open( urltype, 'replace' );
iframe.contentDocument.writeln( d );
iframe.contentDocument.execCommand( 'saveas', '', filename );
};
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
var data = me.exportData( res.value );
var p = KityMinder.findProtocal( res.value );
var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) {
var url = 'data:text/plain; utf-8,' + encodeURI( data );
doDownload( url, filename );
var url = 'data:text/plain; utf-8,' + encodeURIComponent( data );
if ( ie_ver() > 0 ) {
if ( p.fileExtension === '.km' ) {
console.log( "KM" );
doSave( 'application/x-javascript', data, me.getMinderTitle() );
} else {
doSave( 'text/html', data, filename );
}
} else {
doDownload( url, filename );
}
} else if ( data && data.then ) {
data.then( function ( url ) {
doDownload( url, filename );
console.log( url );
if ( ie_ver() > 0 ) {
//doSave( 'application/base64', url.replace( 'image/octet-stream,', '' ), filename );
} else {
doDownload( url, filename );
}
} );
}
} ).on( "beforeshow", function () {
......
......@@ -10,7 +10,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._initContextmenu();
this._initModules();
if(this.getOptions('readOnly') === true){
if ( this.getOptions( 'readOnly' ) === true ) {
this.setDisabled();
}
this.fire( 'ready' );
......@@ -41,6 +41,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._root.setType( "root" );
if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo );
//this._paper.setStyle( 'font-family', 'Arial,"Microsoft YaHei",sans-serif' );
}
},
_addRenderContainer: function () {
......@@ -170,45 +171,45 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
getStatus: function () {
return this._status;
},
setDisabled : function(){
setDisabled: function () {
var me = this;
//禁用命令
me.bkqueryCommandState = me.queryCommandState;
me.bkqueryCommandValue = me.queryCommandValue;
me.queryCommandState = function (type) {
var cmd = this._getCommand(type);
if(cmd && cmd.enableReadOnly === false){
return me.bkqueryCommandState.apply(me, arguments);
me.queryCommandState = function ( type ) {
var cmd = this._getCommand( type );
if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandState.apply( me, arguments );
}
return -1;
};
me.queryCommandValue = function (type) {
var cmd = this._getCommand(type);
if(cmd && cmd.enableReadOnly === false){
return me.bkqueryCommandValue.apply(me, arguments);
me.queryCommandValue = function ( type ) {
var cmd = this._getCommand( type );
if ( cmd && cmd.enableReadOnly === false ) {
return me.bkqueryCommandValue.apply( me, arguments );
}
return null;
};
this.setStatus('readonly');
this.setStatus( 'readonly' );
me.fire('interactchange');
me.fire( 'interactchange' );
},
setEnabled : function(){
setEnabled: function () {
var me = this;
if (me.bkqueryCommandState) {
if ( me.bkqueryCommandState ) {
me.queryCommandState = me.bkqueryCommandState;
delete me.bkqueryCommandState;
}
if (me.bkqueryCommandValue) {
if ( me.bkqueryCommandValue ) {
me.queryCommandValue = me.bkqueryCommandValue;
delete me.bkqueryCommandValue;
}
this.rollbackStatus();
me.fire('interactchange');
me.fire( 'interactchange' );
}
} );
......
KityMinder.registerModule( "basestylemodule", function () {
var km = this;
return {
"commands": {
"bold": kity.createClass( "boldCommand", {
base: Command,
execute: function ( ) {
execute: function () {
var nodes = km.getSelectedNodes();
if(this.queryState('bold') == 1){
utils.each(nodes,function(i,n){
n.setData('bold');
n.getTextShape().setAttr('font-weight');
km.updateLayout(n)
})
}else{
utils.each(nodes,function(i,n){
n.setData('bold',true);
n.getTextShape().setAttr('font-weight','bold');
km.updateLayout(n)
})
if ( this.queryState( 'bold' ) == 1 ) {
utils.each( nodes, function ( i, n ) {
n.setData( 'bold' );
n.getTextShape().setAttr( 'font-weight' );
km.updateLayout( n )
} )
} else {
utils.each( nodes, function ( i, n ) {
n.setData( 'bold', true );
n.getTextShape().setAttr( 'font-weight', 'bold' );
km.updateLayout( n )
} )
}
},
queryState: function ( ) {
queryState: function () {
var nodes = km.getSelectedNodes(),
result = 0;
if(nodes.length == 0){
if ( nodes.length == 0 ) {
return -1;
}
utils.each(nodes,function(i,n){
if( n && n.getData('bold') ){
utils.each( nodes, function ( i, n ) {
if ( n && n.getData( 'bold' ) ) {
result = 1;
return false;
}
});
} );
return result;
}
} ),
"italic": kity.createClass( "italicCommand", {
base: Command,
execute: function ( ) {
execute: function () {
var nodes = km.getSelectedNodes();
if(this.queryState('italic') == 1){
utils.each(nodes,function(i,n){
n.setData('italic');
n.getTextShape().setAttr('font-style');
km.updateLayout(n)
})
}else{
utils.each(nodes,function(i,n){
n.setData('italic',true);
n.getTextShape().setAttr('font-style','italic');
km.updateLayout(n)
})
if ( this.queryState( 'italic' ) == 1 ) {
utils.each( nodes, function ( i, n ) {
n.setData( 'italic' );
n.getTextShape().setAttr( 'font-style' );
km.updateLayout( n )
} )
} else {
utils.each( nodes, function ( i, n ) {
n.setData( 'italic', true );
n.getTextShape().setAttr( 'font-style', 'italic' );
km.updateLayout( n )
} )
}
},
queryState: function ( ) {
queryState: function () {
var nodes = km.getSelectedNodes(),
result = 0;
if(nodes.length == 0){
if ( nodes.length == 0 ) {
return -1;
}
utils.each(nodes,function(i,n){
if( n && n.getData('italic') ){
utils.each( nodes, function ( i, n ) {
if ( n && n.getData( 'italic' ) ) {
result = 1;
return false;
}
});
} );
return result;
}
} )
......@@ -81,12 +80,12 @@ KityMinder.registerModule( "basestylemodule", function () {
"events": {
"beforeRenderNode": function ( e ) {
//加粗
if(e.node.getData('bold')){
e.node.getTextShape().setAttr('font-weight','bold');
if ( e.node.getData( 'bold' ) ) {
e.node.getTextShape().setAttr( 'font-weight', 'bold' );
}
if(e.node.getData('italic')){
e.node.getTextShape().setAttr('font-style','italic');
if ( e.node.getData( 'italic' ) ) {
e.node.getTextShape().setAttr( 'font-style', 'italic' );
}
}
}
......
KityMinder.registerModule( "DropFile", function () {
var social,
draftManager,
importing = false;
function init() {
var container = this.getPaper().getContainer();
container.addEventListener( 'dragover', onDragOver );
......@@ -25,51 +29,58 @@ KityMinder.registerModule( "DropFile", function () {
var files = e.dataTransfer.files;
if ( files ) {
var file = files[0];
var ext = file.type || (/(.)\w+$/).exec(file.name)[0];
var file = files[ 0 ];
var ext = file.type || ( /(.)\w+$/ ).exec( file.name )[ 0 ];
if( (/xmind/g).test(ext) ){ //xmind zip
if ( ( /xmind/g ).test( ext ) ) { //xmind zip
importSync( minder, file, 'xmind' );
}else if( (/mmap/g).test(ext) ){ // mindmanager zip
} else if ( ( /mmap/g ).test( ext ) ) { // mindmanager zip
importSync( minder, file, 'mindmanager' );
}else if( (/mm/g).test(ext) ){ //freemind xml
} else if ( ( /mm/g ).test( ext ) ) { //freemind xml
importAsync( minder, file, 'freemind' );
}else{// txt json
} else { // txt json
importAsync( minder, file );
}
}
}
function afterImport() {
if ( !importing ) return;
createDraft( this );
social.setRemotePath( null, false );
this.execCommand( 'camera', this.getRoot() );
setTimeout(function() {
social.watchChanges( true );
}, 10);
importing = false;
}
// 同步加载文件
function importSync( minder, file, protocal ){
minder.importData( file, protocal );//zip文件的import是同步的
manageDraft( minder );
minder.execCommand( 'camera', minder.getRoot() );
function importSync( minder, file, protocal ) {
social = social || window.social;
social.watchChanges( false );
importing = true;
minder.importData( file, protocal ); //zip文件的import是同步的
}
// 异步加载文件
function importAsync( minder, file, protocal ){
function importAsync( minder, file, protocal ) {
var reader = new FileReader();
reader.onload = function ( e ) {
minder.importData( e.target.result, protocal );//纯文本文件的import是同步的
manageDraft( minder );
minder.execCommand( 'camera', minder.getRoot() );
importSync( minder, e.target.result, protocal );
};
reader.readAsText( file );
}
function manageDraft( minder ){
if( !window.draftManager ){
window.draftManager = new window.DraftManager( minder );
}
window.draftManager.create();
function createDraft( minder ) {
draftManager = window.draftManager;
draftManager.create();
}
return {
events: {
ready: init
'ready': init,
'import': afterImport
}
};
} );
\ No newline at end of file
......@@ -143,8 +143,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
break;
case keys.Backspace:
case keys.Del:
this.execCommand( 'removenode' );
e.preventDefault();
if ( this.queryCommandState( 'removenode' ) !== -1 ) this.execCommand( 'removenode' );
break;
case keys.Left:
......
......@@ -411,7 +411,7 @@ KityMinder.registerModule( "LayoutBottom", function () {
this.appendChildNode( _cleanbuffer[ j ].getLayout().parent, _cleanbuffer[ j ] );
}
},
appendChildNode: function ( parent, node, sibling ) {
appendChildNode: function ( parent, node, focus, sibling ) {
node.clearLayout();
var parentLayout = parent.getLayout();
var expand = parent.getData( "expand" );
......
......@@ -10,97 +10,96 @@ KityMinder.registerProtocal( 'mindmanager', function () {
// 标签 map
var markerMap = {
'urn:mindjet:Prio1' : ['PriorityIcon', 1]
,'urn:mindjet:Prio2' : ['PriorityIcon', 2]
,'urn:mindjet:Prio3' : ['PriorityIcon', 3]
,'urn:mindjet:Prio4' : ['PriorityIcon', 4]
,'urn:mindjet:Prio5' : ['PriorityIcon', 5]
,'0' : ['ProgressIcon', 1]
,'25' : ['ProgressIcon', 2]
,'50' : ['ProgressIcon', 3]
,'75' : ['ProgressIcon', 4]
,'100' : ['ProgressIcon', 5]
'urn:mindjet:Prio1': [ 'PriorityIcon', 1 ],
'urn:mindjet:Prio2': [ 'PriorityIcon', 2 ],
'urn:mindjet:Prio3': [ 'PriorityIcon', 3 ],
'urn:mindjet:Prio4': [ 'PriorityIcon', 4 ],
'urn:mindjet:Prio5': [ 'PriorityIcon', 5 ],
'0': [ 'ProgressIcon', 1 ],
'25': [ 'ProgressIcon', 2 ],
'50': [ 'ProgressIcon', 3 ],
'75': [ 'ProgressIcon', 4 ],
'100': [ 'ProgressIcon', 5 ]
};
function processTopic(topic, obj){
function processTopic( topic, obj ) {
//处理文本
obj.data = { text : topic.Text && topic.Text.PlainText || '' }; // 节点默认的文本,没有Text属性
obj.data = {
text: topic.Text && topic.Text.PlainText || ''
}; // 节点默认的文本,没有Text属性
// 处理标签
if(topic.Task){
if ( topic.Task ) {
var type;
if(topic.Task.TaskPriority){
if ( topic.Task.TaskPriority ) {
type = markerMap[ topic.Task.TaskPriority ];
type && (obj.data[ type[0] ] = type[1]);
type && ( obj.data[ type[ 0 ] ] = type[ 1 ] );
}
if(topic.Task.TaskPercentage){
if ( topic.Task.TaskPercentage ) {
type = markerMap[ topic.Task.TaskPercentage ];
type && (obj.data[ type[0] ] = type[1]);
type && ( obj.data[ type[ 0 ] ] = type[ 1 ] );
}
}
//处理子节点
if( topic.SubTopics && topic.SubTopics.Topic ){
if ( topic.SubTopics && topic.SubTopics.Topic ) {
var tmp = topic.SubTopics.Topic;
if( tmp.length && tmp.length > 0 ){ //多个子节点
if ( tmp.length && tmp.length > 0 ) { //多个子节点
obj.children = [];
for(var i in tmp){
obj.children.push({});
processTopic(tmp[i], obj.children[i]);
for ( var i in tmp ) {
obj.children.push( {} );
processTopic( tmp[ i ], obj.children[ i ] );
}
}else{ //一个子节点
obj.children = [{}];
processTopic(tmp, obj.children[0]);
} else { //一个子节点
obj.children = [ {} ];
processTopic( tmp, obj.children[ 0 ] );
}
}
}
function xml2km(xml){
var json = $.xml2json(xml);
function xml2km( xml ) {
var json = $.xml2json( xml );
var result = {};
processTopic(json.OneTopic.Topic, result);
processTopic( json.OneTopic.Topic, result );
return result;
}
function getEntries(file, onend) {
zip.createReader(new zip.BlobReader(file), function(zipReader) {
zipReader.getEntries(onend);
}, onerror);
function getEntries( file, onend ) {
zip.createReader( new zip.BlobReader( file ), function ( zipReader ) {
zipReader.getEntries( onend );
}, onerror );
}
return {
fileDescription: 'mindmanager格式文件',
fileExtension: '.mmap',
decode: function ( local ) {
return {
then : function(local, callback){
getEntries( local, function( entries ) {
entries.forEach(function( entry ) {
if(entry.filename == 'Document.xml'){
entry.getData(new zip.TextWriter(), function(text) {
var km = xml2km($.parseXML(text));
callback && callback( km );
});
}
});
});
}
};
},
// recognize: recognize,
recognizePriority: -1
};
} );
return {
fileDescription: 'mindmanager格式文件',
fileExtension: '.mmap',
decode: function ( local ) {
return {
then: function ( local, callback ) {
getEntries( local, function ( entries ) {
entries.forEach( function ( entry ) {
if ( entry.filename == 'Document.xml' ) {
entry.getData( new zip.TextWriter(), function ( text ) {
var km = xml2km( $.parseXML( text ) );
callback && callback( km );
} );
}
} );
} );
}
};
},
// recognize: recognize,
recognizePriority: -1
};
} );
\ No newline at end of file
......@@ -6,7 +6,7 @@ KityMinder.registerProtocal( "png", function () {
}
return {
fileDescription: 'PNG 图片',
fileDescription: 'PNG 图片(暂不支持IE)',
fileExtension: '.png',
encode: function ( json, km ) {
var domContainer = km.getPaper().container,
......@@ -38,14 +38,14 @@ KityMinder.registerProtocal( "png", function () {
$svg.attr( {
width: renderBox.width,
height: renderBox.height,
style: 'font-family: Arial, "Heiti SC", "Microsoft Yahei";'
style: 'font-family: Arial, "Microsoft Yahei","Heiti SC";'
} );
// need a xml with width and height
svgXml = $( '<div></div' ).append( $svg ).html();
svgXml = $( '<div></div>' ).append( $svg ).html();
// svg 含有 &nbsp; 符号导出报错 Entity 'nbsp' not defined
svgXml = svgXml.replace(/&nbsp;/g, '&#xa0;');
svgXml = svgXml.replace( /&nbsp;/g, '&#xa0;' );
blob = new Blob( [ svgXml ], {
type: "image/svg+xml;charset=utf-8"
......
......@@ -31,7 +31,7 @@
"<%}%>" +
"<%}%>" +
"<%for( var i=0, label; label = items[i]; i++ ) {%>" +
"<li class=\"<%=itemClassName%><%if( selected == i ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%><%if( disabled[ i ] === true ) {%> kmui-combobox-item-disabled<%}%>\" data-item-index=\"<%=i%>\" unselectable=\"on\" onmousedown=\"return false\">" +
"<li class=\"<%=itemClassName%><%if( selected == i && enabledSelected ) {%> kmui-combobox-checked<%}%> kmui-combobox-item-<%=i%><%if( disabled[ i ] === true ) {%> kmui-combobox-item-disabled<%}%>\" data-item-index=\"<%=i%>\" unselectable=\"on\" onmousedown=\"return false\">" +
"<span class=\"kmui-combobox-icon\" unselectable=\"on\" onmousedown=\"return false\"></span>" +
"<label class=\"<%=labelClassName%>\" style=\"<%=itemStyles[ i ]%>\" unselectable=\"on\" onmousedown=\"return false\"><%=label%></label>" +
"</li>" +
......@@ -52,7 +52,8 @@
autoRecord: true,
//最多记录条数
recordCount: 5,
enabledRecord:true
enabledRecord:true,
enabledSelected:true
},
init: function( options ){
......@@ -332,7 +333,7 @@
var options = this.data("options"),
newStack = [];
debugger
if(this.data('options').enabledRecord){
$.each( options.recordStack, function( i, item ){
......
......@@ -42,5 +42,5 @@ html, body, #kityminder, div.kmui-editor-body {
overflow: hidden;
}
svg {
font-family: Arial, "Heiti SC", "Microsoft Yahei";
font-family: Arial, "Microsoft Yahei","Heiti SC",sans-serif;
}
\ 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