Commit cabdf85f authored by campaign's avatar campaign

merge hot-fix

parents bb1ce915 96e63d0e
# KityMinder 更新日志
##1.1.3
###功能更新
## v1.1.3.1
### Hot Fix
1. 修复某些输入法下输入英文的问题
2. 添加网盘操作(加载列表、保存文件等)失败后重试的机制
## v1.1.3
### 功能更新
1. 保存时可自定义文件名
2. 添加/删除超链接,导入第三方格式支持超链接
3. 选中节点时,按F2直接进入文字编辑状态
......@@ -11,7 +19,7 @@
7. 可指定放大缩小的百分比
##问题修复
## 问题修复
1. 修复当滚动鼠标滚轮时,光标不跟着移动的问题
2. 优化了拖拽节点操作体验
3. 修复回退操作后所选节点未回选问题
......
......@@ -7,26 +7,26 @@
<meta name="description" content="百度脑图,便捷的脑图编辑工具。让您在线上直接创建、保存并分享你的思路。">
<script src="lib/jquery-2.1.0.min.js?_=1399893922286" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1399893922286" charset="utf-8"></script>
<script src="lib/jquery-2.1.0.min.js?_=1400151442820" charset="utf-8"></script>
<script src="lib/ZeroClipboard.min.js?_=1400151442820" charset="utf-8"></script>
<script type="text/javascript">
ZeroClipboard.setDefaults( { moviePath: 'lib/ZeroClipboard.swf' } );
</script>
<script src="lib/kitygraph.all.min.js?_=1399893922286" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1399893922286" charset="utf-8"></script>
<script src="kityminder.config.js?_=1399893922286" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1399893922286" charset="utf-8"></script>
<script src="lib/kitygraph.all.min.js?_=1400151442820" charset="utf-8"></script>
<script src="kityminder.all.min.js?_=1400151442820" charset="utf-8"></script>
<script src="kityminder.config.js?_=1400151442820" charset="utf-8"></script>
<script src="lang/zh-cn/zh-cn.js?_=1400151442820" charset="utf-8"></script>
<script src="lib/zip.js?_=1399893922286" charset="utf-8"></script>
<script src="lib/zip.js?_=1400151442820" charset="utf-8"></script>
<script>
zip.inflateJSPath = 'lib/inflate.js';
</script>
<script src="lib/jquery.xml2json.js?_=1399893922286" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1399893922286" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1399893922286" charset="utf-8"></script>
<script src="social/social.js?_=1399893922286" charset="utf-8"></script>
<script src="lib/jquery.xml2json.js?_=1400151442820" charset="utf-8"></script>
<script src="lib/baidu-frontia-js-full-1.0.0.js?_=1400151442820" charset="utf-8"></script>
<script src="social/draftmanager.js?_=1400151442820" charset="utf-8"></script>
<script src="social/social.js?_=1400151442820" charset="utf-8"></script>
<link href="social/social.css" rel="stylesheet">
<link href="themes/default/css/import.css" type="text/css" rel="stylesheet" />
......@@ -53,7 +53,7 @@
</div>
<p id="about">
KityMinder <a id="km-version" href="https://github.com/fex-team/kityminder/blob/dev/CHANGELOG.md" target="blank"></a>, Powered by f-cube, <a href="http://fex.baidu.com" target="_blank">FEX</a> |
KityMinder <a id="km-version" href="https://github.com/fex-team/kityminder/blob/dev/CHANGELOG.md" target="blank"></a> under <a href="https://raw.githubusercontent.com/fex-team/kityminder/dev/LICENSE" target="_blank">BSD License</a>. Powered by f-cube, <a href="http://fex.baidu.com" target="_blank">FEX</a> |
<a href="https://github.com/fex-team/kityminder.git" target="_blank">Source</a>
<a href="https://github.com/fex-team/kityminder/issues/new" target="_blank">Bug</a> |
<a href="mailto:kity@baidu.com" target="_blank">Contact Us</a>
......
/*!
* ====================================================
* kityminder - v1.1.3 - 2014-05-12
* kityminder - v1.1.3.1 - 2014-05-15
* https://github.com/fex-team/kityminder
* GitHub: https://github.com/fex-team/kityminder.git
* Copyright (c) 2014 f-cube @ FEX; Licensed MIT
......@@ -10,9 +10,10 @@
(function(kity, window) {
var KityMinder = window.KM = window.KityMinder = function () {
var instanceMap = {}, instanceId = 0;
var instanceMap = {},
instanceId = 0;
return {
version: '1.1.3',
version: '1.1.3.1',
createMinder: function ( renderTarget, options ) {
options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
......@@ -5402,6 +5403,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
this.range && this.range.nativeSel.removeAllRanges();
this.index = 0;
this.inputLength = 0;
this.isTypeText = false;
return this;
},
setTextEditStatus: function ( status ) {
......@@ -5486,17 +5488,19 @@ Minder.Receiver = kity.createClass( 'Receiver', {
if ( me.textShape.getOpacity() == 0 ) {
me.textShape.setOpacity( 1 );
}
//#46 修复在ff下定位到文字后方空格光标不移动问题
if ( browser.gecko && /\s$/.test( text ) ) {
text += "\u200b";
}
me.textShape.setContent( text );
me.setContainerStyle();
me.minderNode.setText( text );
if ( text.length == 0 ) {
me.minderNode.setText( 'a' );
me.minderNode.setText( '|' );
}
me.setContainerStyle();
me.km.updateLayout( me.minderNode );
......@@ -5514,29 +5518,27 @@ Minder.Receiver = kity.createClass( 'Receiver', {
me.selection.setShow()
}, 500 );
}
var isTypeText = false;
var isKeypress = false;
switch ( e.type ) {
case 'keydown':
isTypeText = false;
isKeypress = false;
switch ( e.originEvent.keyCode ) {
case keys.Enter:
case keys.Tab:
this.selection.setHide();
this.clear().setTextEditStatus( false );
this.km.fire( 'contentchange' );
this.km.setStatus( 'normal' );
e.preventDefault();
return;
break;
case keymap.Shift:
case keymap.Control:
case keymap.Alt:
case keymap.Cmd:
return;
this.isTypeText = keyCode == 229 || keyCode === 0 ;
switch ( keyCode ) {
case keys.Enter:
case keys.Tab:
this.selection.setHide();
this.clear().setTextEditStatus( false );
this.km.fire( 'contentchange' );
this.km.setStatus( 'normal' );
e.preventDefault();
return;
break;
case keymap.Shift:
case keymap.Control:
case keymap.Alt:
case keymap.Cmd:
return;
}
if ( e.originEvent.ctrlKey || e.originEvent.metaKey ) {
......@@ -5550,54 +5552,53 @@ Minder.Receiver = kity.createClass( 'Receiver', {
var index = me.container.textContent.indexOf( '$$_kityminder_bookmark_$$' );
me.container.textContent = me.container.textContent.replace( '$$_kityminder_bookmark_$$', '' );
me.range.setStart( me.container.firstChild, index ).collapse( true ).select();
setTextToContainer()
setTextToContainer();
}, 100 );
}
//剪切
if ( keyCode == keymap.x ) {
setTimeout( function () {
setTextToContainer()
setTextToContainer();
}, 100 );
}
return;
}
isTypeText = true;
setTextToContainer();
break;
case 'keypress':
if ( isTypeText )
// setTextToContainer();
isKeypress = true;
setTimeout(function(){
setTextToContainer();
});
break;
case 'beforekeyup':
switch ( keyCode ) {
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus();
this.setTextEditStatus( false );
this.clear();
}
e.preventDefault();
return;
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if(keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)){
setTextToContainer();
}
if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus();
this.setTextEditStatus( false );
this.clear();
}
e.preventDefault();
return;
case keymap.Del:
case keymap.Backspace:
case keymap.Spacebar:
setTextToContainer();
return;
}
if ( !isKeypress ) {
if(this.isTypeText){
setTextToContainer();
}
if(browser.mac && browser.gecko)
setTextToContainer();
return true;
}
},
updateIndex: function () {
......@@ -5647,7 +5648,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
},
setContainerStyle: function () {
var textShapeBox = this.getBaseOffset( 'screen' );
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 5 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y + textShapeBox.height *.1 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
if ( !this.selection.isShow() ) {
var paperContainer = this.km.getPaper();
......@@ -6951,7 +6952,7 @@ KM.ui.define( 'dropmenu', {
tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' +
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%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 id="<%= ci.id%>" <%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>' +
'</li><%}}%>' +
'<%}%>' +
......@@ -7054,12 +7055,13 @@ KM.ui.define( 'dropmenu', {
},
appendItem: function ( item ) {
var itemTpl = '<%if(item.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(item.active||item.disabled){%>class="<%= item.active|| \'\' %> <%=item.disabled||\'\' %>" <%}%> data-value="<%= item.value%>" data-label="<%= item.label%>">' +
'<li id="<%= item.id%>" <%if(item.active||item.disabled){%>class="<%= item.active|| \'\' %> <%=item.disabled||\'\' %>" <%}%> data-value="<%= item.value%>" data-label="<%= item.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= item.label%></a>' +
'</li><%}%>';
var html = $.parseTmpl( itemTpl, item );
var $item = $( html ).click( item.click );
this.root().append( $item );
return $item;
},
addSubmenu: function ( label, menu, index ) {
index = index || 0;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,7 +11,7 @@ KityMinder.LANG[ 'zh-cn' ] = {
'fontsize': '字号',
'layoutstyle': '主题',
'node': '节点操作',
'saveto': '导出',
'saveto': '另存为',
'hand': '允许拖拽',
'zoom': '放大缩小',
'markers': '添加标签',
......
......@@ -99,7 +99,7 @@ $( function () {
loadShare();
bindShortCuts();
bindDraft();
draftManager && watchChanges();
if ( draftManager ) watchChanges();
if ( draftManager && !loadPath() && !isShareLink ) loadDraft( 0 );
}
......@@ -183,12 +183,6 @@ $( function () {
} );
}
function initPreferneceSync() {
if ( currentAccount ) {
}
}
// 检查 URL 是否分享连接,是则加载分享内容
function loadShare() {
......@@ -335,27 +329,45 @@ $( function () {
// 加载用户最近使用的文件
function loadUserFiles() {
if ( loadUserFiles.tryCount ) {
console.warn( '加载用户最近使用的文件失败:第 ' + loadUserFiles.tryCount + '次' );
}
if ( loadUserFiles.tryCount > 3 ) {
notice( '加载最近脑图失败!' );
loadUserFiles.tryCount = 0;
}
var sto = baidu.frontia.personalStorage;
//$user_btn.loading( '加载最近脑图...' );
if ( loadUserFiles.tryCount === 0 ) {
loadUserFiles.$loadingMenuItem = $user_menu.appendItem( {
item: {
label: '正在加载最近脑图...',
disabled: 'disabled'
}
} );
}
sto.listFile( 'apps/kityminder/', {
by: 'time',
success: function ( result ) {
if ( result.list.length ) {
//$user_btn.loading( false );
loadUserFiles.$loadingMenuItem.remove();
addToRecentMenu( result.list.filter( function ( file ) {
return getFileFormat( file.path ) in fileLoader;
} ) );
syncPreference( result.list );
}
},
error: function () {
notice( '加载最近脑图失败!' );
//$user_btn.loading( false );
}
error: loadUserFiles
} );
loadUserFiles.tryCount++;
}
loadUserFiles.tryCount = 0;
// 同步用户配置文件
function syncPreference( fileList ) {
......@@ -460,6 +472,15 @@ $( function () {
// 加载当前 remoteUrl 中制定的文件
function loadRemote() {
if ( loadRemote.tryCount ) {
console.warn( '加载用户文件失败:第 ' + loadUserFiles.tryCount + '次' );
}
// 失败重试判断
if ( loadRemote.tryCount > 3 ) {
notice( '加载脑图失败!' );
loadRemote.tryCount = 0;
}
var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载“' + getFileName( remotePath ) + '”...' );
......@@ -471,11 +492,16 @@ $( function () {
if ( format in fileLoader ) {
fileLoader[ format ]( url );
}
loadRemote.tryCount = 0;
},
error: notice
error: loadRemote
} );
loadRemote.tryCount++;
}
loadRemote.tryCount = 0;
function getFileFormat( fileUrl ) {
return fileUrl.split( '.' ).pop();
}
......@@ -617,41 +643,60 @@ $( function () {
}
function save() {
if ( !currentAccount ) return;
if ( !currentAccount || save.busy ) return;
save.busy = true;
var data = minder.exportData( 'json' );
var sto = baidu.frontia.personalStorage;
function error( reason ) {
notice( reason + '\n建议您将脑图以 .km 格式导出到本地!' );
notice( '保存到云盘失败,可能是网络问题导致!\n建议您将脑图以 .km 格式导出到本地!' );
$save_btn.loading( false );
clearTimeout( timeout );
save.busy = false;
}
var timeout = setTimeout( function () {
error( '保存到云盘超时,可能是网络不稳定导致。' );
}, 15000 );
sto.uploadTextFile( data, remotePath || generateRemotePath(), {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) {
if ( savedFile.path ) {
if ( !remotePath ) {
addToRecentMenu( [ savedFile ] );
}
setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath );
draftManager.sync();
}
clearTimeout( timeout );
} else {
error( '保存到云盘失败,可能是网络问题导致!' );
}
},
error: function ( e ) {
error( '保存到云盘失败' );
function upload() {
if ( upload.tryCount ) {
console.warn( '保存文件失败!(第 ' + upload.tryCount + ' 次)' );
}
} );
if ( upload.tryCount > 3 ) {
error();
upload.tryCount = 0;
return;
}
sto.uploadTextFile( data, remotePath || generateRemotePath(), {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) {
if ( savedFile.path ) {
if ( !remotePath ) {
addToRecentMenu( [ savedFile ] );
}
setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath );
draftManager.sync();
}
clearTimeout( timeout );
save.busy = false;
upload.tryCount = 0;
} else {
upload();
}
},
error: upload
} );
upload.tryCount++;
}
upload.tryCount = 0;
upload();
$save_btn.loading( '正在保存...' );
}
......@@ -677,7 +722,7 @@ $( function () {
$share_btn.loading( '正在分享...' );
$.ajax({
$.ajax( {
url: 'http://naotu.baidu.com/mongo.php',
type: 'POST',
data: {
......@@ -694,11 +739,11 @@ $( function () {
notice( result.error );
} else {
$share_dialog.show();
$share_url.val( shareUrl )[ 0 ].select();
$share_url.val( shareUrl )[ 0 ].select();
}
},
error: function() {
notice('分享失败,可能是当前的环境不支持该操作。');
error: function () {
notice( '分享失败,可能是当前的环境不支持该操作。' );
}
} );
......
......@@ -11,7 +11,7 @@ KityMinder.LANG[ 'zh-cn' ] = {
'fontsize': '字号',
'layoutstyle': '主题',
'node': '节点操作',
'saveto': '导出',
'saveto': '另存为',
'hand': '允许拖拽',
'zoom': '放大缩小',
'markers': '添加标签',
......
......@@ -2,7 +2,7 @@
"name": "kityminder",
"title": "kityminder",
"description": "Kity Minder",
"version": "1.1.3",
"version": "1.1.3.1",
"homepage": "https://github.com/fex-team/kityminder",
"author": {
"name": "f-cube @ FEX",
......
......@@ -99,7 +99,7 @@ $( function () {
loadShare();
bindShortCuts();
bindDraft();
draftManager && watchChanges();
if ( draftManager ) watchChanges();
if ( draftManager && !loadPath() && !isShareLink ) loadDraft( 0 );
}
......@@ -183,12 +183,6 @@ $( function () {
} );
}
function initPreferneceSync() {
if ( currentAccount ) {
}
}
// 检查 URL 是否分享连接,是则加载分享内容
function loadShare() {
......@@ -335,27 +329,45 @@ $( function () {
// 加载用户最近使用的文件
function loadUserFiles() {
if ( loadUserFiles.tryCount ) {
console.warn( '加载用户最近使用的文件失败:第 ' + loadUserFiles.tryCount + '次' );
}
if ( loadUserFiles.tryCount > 3 ) {
notice( '加载最近脑图失败!' );
loadUserFiles.tryCount = 0;
}
var sto = baidu.frontia.personalStorage;
//$user_btn.loading( '加载最近脑图...' );
if ( loadUserFiles.tryCount === 0 ) {
loadUserFiles.$loadingMenuItem = $user_menu.appendItem( {
item: {
label: '正在加载最近脑图...',
disabled: 'disabled'
}
} );
}
sto.listFile( 'apps/kityminder/', {
by: 'time',
success: function ( result ) {
if ( result.list.length ) {
//$user_btn.loading( false );
loadUserFiles.$loadingMenuItem.remove();
addToRecentMenu( result.list.filter( function ( file ) {
return getFileFormat( file.path ) in fileLoader;
} ) );
syncPreference( result.list );
}
},
error: function () {
notice( '加载最近脑图失败!' );
//$user_btn.loading( false );
}
error: loadUserFiles
} );
loadUserFiles.tryCount++;
}
loadUserFiles.tryCount = 0;
// 同步用户配置文件
function syncPreference( fileList ) {
......@@ -460,6 +472,15 @@ $( function () {
// 加载当前 remoteUrl 中制定的文件
function loadRemote() {
if ( loadRemote.tryCount ) {
console.warn( '加载用户文件失败:第 ' + loadUserFiles.tryCount + '次' );
}
// 失败重试判断
if ( loadRemote.tryCount > 3 ) {
notice( '加载脑图失败!' );
loadRemote.tryCount = 0;
}
var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载“' + getFileName( remotePath ) + '”...' );
......@@ -471,11 +492,16 @@ $( function () {
if ( format in fileLoader ) {
fileLoader[ format ]( url );
}
loadRemote.tryCount = 0;
},
error: notice
error: loadRemote
} );
loadRemote.tryCount++;
}
loadRemote.tryCount = 0;
function getFileFormat( fileUrl ) {
return fileUrl.split( '.' ).pop();
}
......@@ -617,41 +643,60 @@ $( function () {
}
function save() {
if ( !currentAccount ) return;
if ( !currentAccount || save.busy ) return;
save.busy = true;
var data = minder.exportData( 'json' );
var sto = baidu.frontia.personalStorage;
function error( reason ) {
notice( reason + '\n建议您将脑图以 .km 格式导出到本地!' );
notice( '保存到云盘失败,可能是网络问题导致!\n建议您将脑图以 .km 格式导出到本地!' );
$save_btn.loading( false );
clearTimeout( timeout );
save.busy = false;
}
var timeout = setTimeout( function () {
error( '保存到云盘超时,可能是网络不稳定导致。' );
}, 15000 );
sto.uploadTextFile( data, remotePath || generateRemotePath(), {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) {
if ( savedFile.path ) {
if ( !remotePath ) {
addToRecentMenu( [ savedFile ] );
}
setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath );
draftManager.sync();
}
clearTimeout( timeout );
} else {
error( '保存到云盘失败,可能是网络问题导致!' );
}
},
error: function ( e ) {
error( '保存到云盘失败' );
function upload() {
if ( upload.tryCount ) {
console.warn( '保存文件失败!(第 ' + upload.tryCount + ' 次)' );
}
} );
if ( upload.tryCount > 3 ) {
error();
upload.tryCount = 0;
return;
}
sto.uploadTextFile( data, remotePath || generateRemotePath(), {
ondup: remotePath ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( savedFile ) {
if ( savedFile.path ) {
if ( !remotePath ) {
addToRecentMenu( [ savedFile ] );
}
setRemotePath( savedFile.path, true );
if ( draftManager ) {
draftManager.save( remotePath );
draftManager.sync();
}
clearTimeout( timeout );
save.busy = false;
upload.tryCount = 0;
} else {
upload();
}
},
error: upload
} );
upload.tryCount++;
}
upload.tryCount = 0;
upload();
$save_btn.loading( '正在保存...' );
}
......@@ -677,7 +722,7 @@ $( function () {
$share_btn.loading( '正在分享...' );
$.ajax({
$.ajax( {
url: 'http://naotu.baidu.com/mongo.php',
type: 'POST',
data: {
......@@ -694,11 +739,11 @@ $( function () {
notice( result.error );
} else {
$share_dialog.show();
$share_url.val( shareUrl )[ 0 ].select();
$share_url.val( shareUrl )[ 0 ].select();
}
},
error: function() {
notice('分享失败,可能是当前的环境不支持该操作。');
error: function () {
notice( '分享失败,可能是当前的环境不支持该操作。' );
}
} );
......
var KityMinder = window.KM = window.KityMinder = function () {
var instanceMap = {}, instanceId = 0;
var instanceMap = {},
instanceId = 0;
return {
version: '1.1.3',
version: '1.1.3.1',
createMinder: function ( renderTarget, options ) {
options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
......
......@@ -9,7 +9,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
this.range.nativeSel.removeAllRanges();
}
this.index = 0;
this.inputLength = 0;
this.isTypeText = false;
return this;
},
setTextEditStatus: function ( status ) {
......@@ -100,11 +100,11 @@ Minder.Receiver = kity.createClass( 'Receiver', {
text += "\u200b";
}
me.setContainerStyle();
me.minderNode.setText( text );
if ( text.length === 0 ) {
me.minderNode.setText( 'a' );
}
me.setContainerStyle();
me.km.updateLayout( me.minderNode );
......@@ -126,15 +126,13 @@ Minder.Receiver = kity.createClass( 'Receiver', {
}
}
var isTypeText = false;
var isKeypress = false;
switch ( e.type ) {
case 'keydown':
isTypeText = false;
isKeypress = false;
switch ( e.originEvent.keyCode ) {
this.isTypeText = keyCode == 229 || keyCode === 0 ;
switch ( keyCode ) {
case keys.Enter:
case keys.Tab:
this.selection.setHide();
......@@ -143,8 +141,12 @@ Minder.Receiver = kity.createClass( 'Receiver', {
this.km.setStatus( 'normal' );
e.preventDefault();
return;
break;
case keymap.Shift:
case keymap.Control:
case keymap.Alt:
case keymap.Cmd:
return;
}
if ( e.originEvent.ctrlKey || e.originEvent.metaKey ) {
......@@ -169,45 +171,42 @@ Minder.Receiver = kity.createClass( 'Receiver', {
}
return;
}
isTypeText = true;
if(!orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey){
setTimeout(function(){
setTextToContainer();
}
break;
case 'keypress':
isKeypress = true;
});
break;
case 'beforekeyup':
switch ( keyCode ) {
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus();
this.setTextEditStatus( false );
this.clear();
}
e.preventDefault();
return;
case keymap.Enter:
case keymap.Tab:
case keymap.F2:
if(keymap.Enter == keyCode && (this.isTypeText || browser.mac && browser.gecko)){
setTextToContainer();
}
if ( this.keydownNode === this.minderNode ) {
this.rollbackStatus();
this.setTextEditStatus( false );
this.clear();
}
e.preventDefault();
return;
case keymap.Del:
case keymap.Backspace:
case keymap.Spacebar:
setTextToContainer();
return;
}
if ( !isKeypress && !orgEvt.ctrlKey && !orgEvt.metaKey && !orgEvt.shiftKey && !orgEvt.altKey ) {
if(this.isTypeText){
setTextToContainer();
}
if(browser.mac && browser.gecko)
setTextToContainer();
return true;
}
},
updateIndex: function () {
......@@ -257,7 +256,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
},
setContainerStyle: function () {
var textShapeBox = this.getBaseOffset( 'screen' );
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y - 5 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
this.container.style.cssText = ";left:" + textShapeBox.x + 'px;top:' + ( textShapeBox.y + textShapeBox.height *.1 ) + 'px;width:' + textShapeBox.width + 'px;height:' + textShapeBox.height + 'px;';
if ( !this.selection.isShow() ) {
var paperContainer = this.km.getPaper();
......@@ -336,7 +335,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
var me = this;
utils.each( this.textData, function ( i, v ) {
//点击开始之前
if ( i === 0 && offset.x <= v.x ) {
if ( i == 0 && offset.x <= v.x ) {
me.selection.setStartOffset( 0 );
return false;
}
......@@ -348,18 +347,18 @@ Minder.Receiver = kity.createClass( 'Receiver', {
if ( offset.x >= v.x && offset.x <= v.x + v.width ) {
if ( me.index == i ) {
if ( i === 0 ) {
me.selection.setStartOffset( i );
if ( i == 0 ) {
me.selection.setStartOffset( i )
}
if ( offset.x <= v.x + v.width / 2 ) {
me.selection.collapse();
me.selection.collapse()
} else {
me.selection.setEndOffset( i + ( ( me.selection.endOffset > i || dir == 1 ) && i != me.textData.length - 1 ? 1 : 0 ) );
me.selection.setEndOffset( i + ( ( me.selection.endOffset > i || dir == 1 ) && i != me.textData.length - 1 ? 1 : 0 ) )
}
} else if ( i > me.index ) {
me.selection.setStartOffset( me.index );
me.selection.setEndOffset( i + 1 );
me.selection.setEndOffset( i + 1 )
} else {
if ( dir == 1 ) {
me.selection.setStartOffset( i + ( offset.x >= v.x + v.width / 2 && i != me.textData.length - 1 ? 1 : 0 ) );
......@@ -367,7 +366,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
me.selection.setStartOffset( i );
}
me.selection.setEndOffset( me.index );
me.selection.setEndOffset( me.index )
}
return false;
......@@ -388,7 +387,7 @@ Minder.Receiver = kity.createClass( 'Receiver', {
var lastOffset = this.textData[ this.textData.length - 1 ];
width = lastOffset.x - startOffset.x + lastOffset.width;
} catch ( e ) {
console.log( e );
console.log( 'e' )
}
} else {
......@@ -407,11 +406,10 @@ Minder.Receiver = kity.createClass( 'Receiver', {
},
setIndex: function ( index ) {
this.index = index;
return this;
return this
},
setContainerTxt: function ( txt ) {
this.container.textContent = txt;
return this;
}
} );
\ No newline at end of file
......@@ -3,7 +3,7 @@ KM.ui.define( 'dropmenu', {
tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' +
'<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%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 id="<%= ci.id%>" <%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>' +
'</li><%}}%>' +
'<%}%>' +
......@@ -106,12 +106,13 @@ KM.ui.define( 'dropmenu', {
},
appendItem: function ( item ) {
var itemTpl = '<%if(item.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(item.active||item.disabled){%>class="<%= item.active|| \'\' %> <%=item.disabled||\'\' %>" <%}%> data-value="<%= item.value%>" data-label="<%= item.label%>">' +
'<li id="<%= item.id%>" <%if(item.active||item.disabled){%>class="<%= item.active|| \'\' %> <%=item.disabled||\'\' %>" <%}%> data-value="<%= item.value%>" data-label="<%= item.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= item.label%></a>' +
'</li><%}%>';
var html = $.parseTmpl( itemTpl, item );
var $item = $( html ).click( item.click );
this.root().append( $item );
return $item;
},
addSubmenu: function ( label, menu, index ) {
index = index || 0;
......
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