Commit f90cd952 authored by techird's avatar techird

bug fix

parent 3bdfe00c
......@@ -214,7 +214,9 @@ KityMinder.LANG['zh-cn'] = {
'shortcuts': '快捷键',
'contact': '联系我们',
'email': '邮件组',
'qq_group': 'QQ 群'
'qq_group': 'QQ 群',
'clipboardunsupported': '您的浏览器不支持剪贴板,请使用快捷键复制'
},
'popupcolor': {
'clearColor': '清空颜色',
......
This diff is collapsed.
No preview for this file type
Subproject commit 2100743a23276853658906608e093d1227739084
Subproject commit 5abfcd8d5ece0bcece486dec435288ec7bcd281d
......@@ -32,6 +32,7 @@ var keymap = KityMinder.keymap = (function(origin) {
'End': 35,
'Home': 36,
'Insert': 45,
'Left': 37,
'Up': 38,
......@@ -44,7 +45,6 @@ var keymap = KityMinder.keymap = (function(origin) {
39: 1,
40: 1
},
'Insert': 45,
'Del': 46,
......
......@@ -330,14 +330,14 @@ kity.extendClass(Minder, {
.start(node, duration, 'ease')
.on('finish', function() {
//可能性能低的时候会丢帧,手动添加一帧
kity.Timeline.requestFrame(function() {
setTimeout(function() {
applyMatrix(node, matrix);
me.fire('layoutfinish', {
node: node,
matrix: matrix
});
consume();
});
}, 150);
});
}
......
......@@ -17,7 +17,7 @@ kity.extendClass(Minder, (function() {
},
getTemplate: function() {
return this._template || null;
return this._template || 'default';
},
setTemplate: function(name) {
......@@ -25,7 +25,7 @@ kity.extendClass(Minder, (function() {
},
getTemplateSupport: function(method) {
var supports = KityMinder._templates[this._template];
var supports = KityMinder._templates[this.getTemplate()];
return supports && supports[method];
},
......
......@@ -140,6 +140,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
return false;
};
case keymap.Tab:
case keymap.Insert:
if(this.selection.isShow()){
this.re.clear();
this.km.setStatus('inputready');
......@@ -159,6 +160,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
case keymap.Del:
case keymap['/']:
case keymap.F2:
case keymap.Insert:
if(this.selection.isHide()){
this.km.setStatus('normal');
return;
......@@ -240,6 +242,7 @@ Minder.keyboarder = kity.createClass('keyboarder', function(){
switch (keyCode) {
case keymap.Enter:
case keymap.Tab:
case keymap.Insert:
case keymap.F2:
if(browser.ipad){
if(this.selection.isShow()){
......
//模拟光标
Minder.Selection = kity.createClass( 'Selection', {
base: kity.Group,
base: kity.Path,
constructor: function ( height, color, width ) {
this.callBase();
this.height = height || 20;
......@@ -15,7 +15,7 @@ Minder.Selection = kity.createClass( 'Selection', {
this.setStyle('cursor','text');
this._show = false;
this.offset = [];
this.setTranslate(-0.5, -1.5);
},
setMinderNode : function(node){
this.minderNode = node;
......@@ -73,21 +73,31 @@ Minder.Selection = kity.createClass( 'Selection', {
}
this._show = true;
},
updatePosition:function(offset){
updatePosition: function(offset){
var me = this;
this.clear();
var r = Math.round;
var rect = function (x, y, w, h) {
return ['M', r(x), r(y),
'h', r(w),
'v', r(h),
'h', -r(w),
'v', -r(h),
'z'];
};
offset = offset || this.offset;
if(this.collapsed){
var rect = new kity.Rect().fill(null).stroke(null).setWidth(2).setHeight(this.height);
rect.setPosition(Math.round(offset.x) - 0.5,Math.round(offset.y) - 1.5);
this.addShape(rect);
}else{
utils.each(offset,function(i,v){
var rect = new kity.Rect().fill(null).stroke(null).setWidth(v.width).setHeight(me.height);
rect.setPosition(Math.round(v.x) - 0.5,Math.round(v.y) - 1.5);
me.addShape(rect);
});
if(this.collapsed){
if (isNaN(offset.x) || isNaN(offset.y)) {
if (console) console.warn('editor.selection.js 不正确的偏移位置');
return this;
}
this.setPathData(rect(offset.x, offset.y, this.width, this.height));
} else {
this.setPathData(offset.reduce(function (prev, current) {
return prev.concat(rect(current.x, current.y, current.width, me.height));
}, []));
}
this._show = true;
return this;
......
......@@ -5,10 +5,11 @@ KityMinder.registerModule("hyperlink", function() {
"hyperlink": kity.createClass("hyperlink", {
base: Command,
execute: function(km, url) {
execute: function(km, url, title) {
var nodes = km.getSelectedNodes();
utils.each(nodes, function(i, n) {
n.setData('hyperlink', url);
n.setData('hyperlinkTitle', title);
n.render();
});
km.layout();
......@@ -29,7 +30,10 @@ KityMinder.registerModule("hyperlink", function() {
},
queryValue: function(km) {
var node = km.getSelectedNode();
return node.getData('hyperlink');
return {
url: node.getData('hyperlink'),
title: node.getData('hyperlinkTitle')
};
}
}),
"unhyperlink": kity.createClass("hyperlink", {
......@@ -80,7 +84,6 @@ KityMinder.registerModule("hyperlink", function() {
link.setTarget('_blank');
link.setStyle('cursor', 'pointer');
link.on('mouseover', function() {
outline.fill('rgba(255, 255, 200, .8)');
}).on('mouseout', function() {
......@@ -90,7 +93,6 @@ KityMinder.registerModule("hyperlink", function() {
},
shouldRender: function(node) {
return node.getData('hyperlink');
},
......@@ -98,7 +100,16 @@ KityMinder.registerModule("hyperlink", function() {
var href = node.getData('hyperlink');
link.setHref(href);
link.setAttr('xlink:title', href);
var title = node.getData('hyperlinkTitle');
if (title) {
title = [title, '(', href, ')'].join('');
} else {
title = href;
}
link.node.setAttributeNS('http://www.w3.org/1999/xlink', 'title', title);
var spaceRight = node.getStyle('space-right');
link.setTranslate(box.right + spaceRight + 2, -5);
......
......@@ -32,7 +32,7 @@ KityMinder.registerModule('image', function() {
var ImageCommand = kity.createClass('ImageCommand', {
base: Command,
execute: function(km, url) {
execute: function(km, url, title) {
var nodes = km.getSelectedNodes();
loadImageSize(url, function(width, height) {
......@@ -43,6 +43,7 @@ KityMinder.registerModule('image', function() {
km.getOptions('maxImageWidth'),
km.getOptions('maxImageHeight'));
n.setData('image', url);
n.setData('imageTitle', title);
n.setData('imageSize', size);
n.render();
});
......@@ -67,7 +68,10 @@ KityMinder.registerModule('image', function() {
},
queryValue: function(km) {
var node = km.getSelectedNode();
return node.getData('image');
return {
url: node.getData('image'),
title: node.getData('imageTitle')
};
}
});
......@@ -114,11 +118,16 @@ KityMinder.registerModule('image', function() {
update: function(image, node, box) {
var url = node.getData('image');
var title = node.getData('imageTitle');
var size = node.getData('imageSize');
var spaceTop = node.getStyle('space-top');
if (!size) return;
if (title) {
image.node.setAttributeNS('http://www.w3.org/1999/xlink', 'title', title);
}
var x = box.cx - size.width / 2;
var y = box.y - size.height - spaceTop;
......
......@@ -106,7 +106,7 @@ KityMinder.registerModule('NodeModule', function() {
'appendsiblingnode': 'normal::Enter',
'appendchildnode': 'normal::Insert|Tab',
'editnode': 'normal::F2',
'removenode': 'normal::Delete|Backspace'
'removenode': 'normal::Del|Backspace'
}
};
});
\ No newline at end of file
......@@ -20,7 +20,7 @@ KityMinder.registerModule('Select', function() {
return {
selectStart: function(e) {
// 只接受左键
if (e.originEvent.button) return;
if (e.originEvent.button || e.originEvent.altKey) return;
// 清理不正确状态
if (startPosition) {
......
......@@ -100,7 +100,7 @@ var ViewDragger = kity.createClass("ViewDragger", {
e.originEvent.preventDefault(); // 阻止中键拉动
}
// 点击未选中的根节点临时开启
if (e.getTargetNode() == this.getRoot() || e.originEvent.button == 2) {
if (e.getTargetNode() == this.getRoot() || e.originEvent.button == 2 || e.originEvent.altKey) {
lastPosition = e.getPosition();
isTempDrag = true;
}
......@@ -228,20 +228,8 @@ KityMinder.registerModule('View', function() {
'move': MoveCommand
},
events: {
keyup: function(e) {
if (this.getStatus() == 'hand' && e.getKeyCode() == 18) {
this.execCommand('hand');
e.preventDefault();
}
},
keydown: function(e) {
var minder = this;
if (this.getStatus() != 'hand' && e.getKeyCode() == 18) {
this.execCommand('hand');
e.preventDefault();
} else if (this.getStatus() == 'hand') {
this.execCommand('hand');
}
['up', 'down', 'left', 'right'].forEach(function(name) {
if (e.isShortcutKey('ctrl+' + name)) {
......@@ -302,7 +290,7 @@ KityMinder.registerModule('View', function() {
new kity.Point((a.width - b.width) / 2 | 0, (a.height - b.height) / 2 | 0));
this._lastClientSize = a;
},
selectionchange: function() {
'selectionchange layoutallfinish': function(e) {
var selected = this.getSelectedNode();
if (!selected) return;
......
......@@ -81,7 +81,7 @@ KityMinder.registerUI('menu/share/share', function(minder) {
lang: minder.getLang('ui'),
minder: minder
}));
zeroCopy();
setTimeout(zeroCopy, 10);
return $create_menu;
});
}
......@@ -104,6 +104,15 @@ KityMinder.registerUI('menu/share/share', function(minder) {
$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() {
......@@ -390,24 +399,24 @@ KityMinder.registerUI('menu/share/share', function(minder) {
function zeroCopy() {
/* global ZeroClipboard:true */
ZeroClipboard.setDefaults({
moviePath: 'lib/ZeroClipboard.swf'
});
var $copy_url_btn = $('#copy-share-url', $create_menu);
if (window.ZeroClipboard) {
var clip = new window.ZeroClipboard($copy_url_btn, {
ZeroClipboard.config({
hoverClass: 'hover',
activeClass: 'active'
});
clip.on('dataRequested', function(client, args) {
$copy_url_btn.text(minder.getLang('ui.copied')).attr('disabled', 'disabled');
setTimeout(function() {
$copy_url_btn
.text(minder.getLang('ui.copy'))
.removeAttr('disabled');
}, 3000);
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);
});
});
}
}
......
......@@ -28,32 +28,36 @@ KityMinder.registerUI('image', function(minder) {
var $imageDialog = new FUI.Dialog({
width: 500,
height: 400,
prompt: true,
caption: minder.getLang('ui.image')
}).appendTo(document.getElementById('content-wrapper'));
$imageDialog.on('ok', function() {
minder.execCommand('image', $url.val());
});
$imageDialog.on('open', function() {
$url.val(minder.queryCommandValue('image'));
$preview.attr('src', '');
error(false);
});
var $dialogBody = $($imageDialog.getBodyElement());
$dialogBody.html([
'<p><label>图片地址:</label><input type="url" class="image-url fui-widget fui-selection" /></p>',
'<p><label>提示文本:</label><input type="text" class="image-title /"></p>',
'<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(''));
var $url = $dialogBody.find('.image-url');
var $title = $dialogBody.find('.image-title');
var $preview = $dialogBody.find('.image-preview');
var $ok = $imageDialog.getButton(0);
var $errorMsg = $('<span class="validate-error"></span>');
$imageDialog.on('ok', function() {
minder.execCommand('image', $url.val(), $title.val());
});
$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');
......
......@@ -30,6 +30,7 @@ KityMinder.registerUI('ribbon/idea/link', function(minder) {
var $linkDialog = new FUI.Dialog({
width: 600,
height: 200,
prompt: true,
caption: minder.getLang('ui.link')
}).appendTo(document.getElementById('content-wrapper'));
......@@ -41,6 +42,7 @@ KityMinder.registerUI('ribbon/idea/link', function(minder) {
].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>');
......@@ -73,11 +75,13 @@ KityMinder.registerUI('ribbon/idea/link', function(minder) {
});
$linkDialog.on('ok', function() {
minder.execCommand('hyperlink', $href.val());
minder.execCommand('hyperlink', $href.val(), $title.val() || '');
});
$linkDialog.on('open', function() {
$href.val(minder.queryCommandValue('hyperlink'));
var value = minder.queryCommandValue('hyperlink');
$href.val(value.url);
$title.val(value.title);
error(false);
});
......
......@@ -32,7 +32,7 @@ KityMinder.registerUI('ribbon/idea/resource', function(minder) {
var resource = $addInput.getValue();
var origin = minder.queryCommandValue('resource');
if (resource) {
origin.push(resource);
if (!~origin.indexOf(resource)) origin.unshift(resource);
minder.execCommand('resource', origin);
}
$addInput.setValue(null);
......@@ -68,6 +68,21 @@ KityMinder.registerUI('ribbon/idea/resource', function(minder) {
var resource = minder.queryCommandValue('resource');
var used = minder.getUsedResource();
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;
......@@ -91,20 +106,6 @@ KityMinder.registerUI('ribbon/idea/resource', function(minder) {
backgroundColor: ~resource.indexOf(name) ? color : color.dec('a', 0.85).toRGBA()
});
});
switch (minder.queryCommandState('resource')) {
case 0:
$addInput.enable();
$addButton.enable();
$resourceDrop.enable();
$ul.find('input[type=checkbox]').removeProp('disabled');
break;
case -1:
$addInput.disable();
$addButton.disable();
$resourceDrop.disable();
$ul.find('input[type=checkbox]').prop('disabled', 'disabled');
}
}
minder.on('interactchange', update);
......
......@@ -28,6 +28,7 @@ KityMinder.registerUI('ribbon/tabs', function(minder) {
// 隐藏效果
var lastIndex = 0;
var muteRemember = false;
$tab.on('tabsselect', function(e, info) {
if (info.index == lastIndex) {
$container.toggleClass('collapsed');
......@@ -36,8 +37,10 @@ KityMinder.registerUI('ribbon/tabs', function(minder) {
$container.removeClass('collapsed');
$header.removeClass('collapsed');
}
memory.set('ribbon-tab-collapsed', $container.hasClass('collapsed'));
memory.set('ribbon-tab-index', info.index);
if (!muteRemember) {
memory.set('ribbon-tab-collapsed', $container.hasClass('collapsed'));
memory.set('ribbon-tab-index', info.index);
}
lastIndex = info.index;
});
......@@ -48,7 +51,9 @@ KityMinder.registerUI('ribbon/tabs', function(minder) {
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');
......
......@@ -46,6 +46,10 @@
vertical-align: middle;
}
span.validate-error {
margin-left: 5px;
}
.button, button {
display: inline-block;
height: 30px;
......
......@@ -410,6 +410,10 @@
color: white;
}
}
.menu-label {
display: inline-block;
}
.shortcut {
float: right;
......
......@@ -562,6 +562,9 @@
border-color: red !important;
vertical-align: middle;
}
span.validate-error {
margin-left: 5px;
}
.button,
button {
display: inline-block;
......@@ -1242,6 +1245,9 @@ li {
.fui-popup-menu .fui-item :focus .fui-label {
color: white;
}
.fui-popup-menu .fui-item .menu-label {
display: inline-block;
}
.fui-popup-menu .fui-item .shortcut {
float: right;
margin-left: 20px;
......
This diff is collapsed.
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