Commit 003f8207 authored by Akikonata's avatar Akikonata

Merge branch 'dev' of https://github.com/kitygraph/kityminder into dev

parents 938a4fe6 84da7929
...@@ -2,18 +2,18 @@ ...@@ -2,18 +2,18 @@
var utils = KM.utils; var utils = KM.utils;
KM.registerWidget( 'markers', { KM.registerWidget( 'markers', {
tpl: "<ul class='icon-list'>" + tpl: "<ul class='icon-list'>" +
"<li value='1' type='setpriority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) 0 0'></span><span><%= priority %>1</span></li>" + "<li value='1' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) 0 0'></span><span><%= priority %>1</span></li>" +
"<li value='2' type='setpriority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -20px 0'></span><span><%= priority %>2</span></li>" + "<li value='2' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -20px 0'></span><span><%= priority %>2</span></li>" +
"<li value='3' type='setpriority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -40px 0'></span><span><%= priority %>3</span></li>" + "<li value='3' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -40px 0'></span><span><%= priority %>3</span></li>" +
"<li value='4' type='setpriority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -60px 0'></span><span><%= priority %>4</span></li>" + "<li value='4' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -60px 0'></span><span><%= priority %>4</span></li>" +
"<li value='5' type='setpriority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -80px 0'></span><span><%= priority %>5</span></li>" + "<li value='5' type='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -80px 0'></span><span><%= priority %>5</span></li>" +
"</ul>" + "</ul>" +
"<ul class='icon-list'>" + "<ul class='icon-list'>" +
"<li value='1' type='setprogress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) 0 0'></span><span><%= progress.notdone %></span></li>" + "<li value='1' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) 0 0'></span><span><%= progress.notdone %></span></li>" +
"<li value='2' type='setprogress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -20px 0'></span><span><%= progress.quarterdone %></span></li>" + "<li value='2' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -20px 0'></span><span><%= progress.quarterdone %></span></li>" +
"<li value='3' type='setprogress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -40px 0'></span><span><%= progress.halfdone %></span></li>" + "<li value='3' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -40px 0'></span><span><%= progress.halfdone %></span></li>" +
"<li value='4' type='setprogress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -60px 0'></span><span><%= progress.threequartersdone %></span></li>" + "<li value='4' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -60px 0'></span><span><%= progress.threequartersdone %></span></li>" +
"<li value='5' type='setprogress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -80px 0'></span><span><%= progress.done %></span></li>" + "<li value='5' type='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -80px 0'></span><span><%= progress.done %></span></li>" +
"</ul>", "</ul>",
initContent: function ( km ) { initContent: function ( km ) {
var lang = km.getLang( 'dialogs.markers' ); var lang = km.getLang( 'dialogs.markers' );
...@@ -35,12 +35,12 @@ ...@@ -35,12 +35,12 @@
km.execCommand( type, val ); km.execCommand( type, val );
} ); } );
km.on( 'interactchange', function ( e ) { km.on( 'interactchange', function ( e ) {
var valPri = this.queryCommandValue( "setpriority" ); var valPri = this.queryCommandValue( "priority" );
var valPro = this.queryCommandValue( "setprogress" ); var valPro = this.queryCommandValue( "progress" );
$w.find( "li[type='setpriority']" ).removeClass( "active" ); $w.find( "li[type='priority']" ).removeClass( "active" );
$w.find( "li[type='setpriority'][value='" + valPri + "']" ).addClass( "active" ); $w.find( "li[type='priority'][value='" + valPri + "']" ).addClass( "active" );
$w.find( "li[type='setprogress']" ).removeClass( "active" ); $w.find( "li[type='progress']" ).removeClass( "active" );
$w.find( "li[type='setprogress'][value='" + valPro + "']" ).addClass( "active" ); $w.find( "li[type='progress'][value='" + valPro + "']" ).addClass( "active" );
} ); } );
}, },
buttons: { buttons: {
......
...@@ -48,7 +48,7 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -48,7 +48,7 @@ KityMinder.registerModule( "TextEditModule", function () {
} }
}, },
'mouseup':function(e){ 'mouseup':function(e){
if(!sel.collapsed){ if(!sel.collapsed && mouseDownStatus){
receiver.updateRange(range) receiver.updateRange(range)
} }
mouseDownStatus = false; mouseDownStatus = false;
...@@ -83,7 +83,57 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -83,7 +83,57 @@ KityMinder.registerModule( "TextEditModule", function () {
}, },
'stopTextEdit':function(){ 'stopTextEdit':function(){
sel.setHide(); sel.setHide();
receiver.clear().setTextEditStatus(false);
},
'execCommand':function(e){
var cmds = {
'appendchildnode':1,
'appendsiblingnode':1
};
if(cmds[e.commandName]){
var node = km.getSelectedNode();
var textShape = node.getTextShape();
textShape.setStyle('cursor','default');
node.getTextShape().setStyle('cursor','text');
receiver.setTextEditStatus(true)
.setSelection(sel)
.setKityMinder(this)
.setMinderNode(node)
.setTextShape(textShape)
.setBaseOffset()
.setContainerStyle()
.setSelectionHeight()
.getTextOffsetData()
.setIndex(0)
.updateSelection()
.setRange(range);
sel.setStartOffset(0);
sel.setEndOffset(textShape.getContent().length);
sel.setShow();
receiver.updateSelectionShow(1)
.updateRange(range);
}
if(e.commandName == 'priority' || e.commandName == 'progress'){
receiver.setBaseOffset()
.getTextOffsetData();
if(sel.collapsed){
receiver.updateSelection();
}else{
receiver.updateSelectionShow(1)
}
}
} }
} }
}; };
......
...@@ -77,8 +77,10 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -77,8 +77,10 @@ Minder.Receiver = kity.createClass('Receiver',{
switch(keyCode){ switch(keyCode){
case keymap.Enter: case keymap.Enter:
case keymap.Tab: case keymap.Tab:
this.setTextEditStatus(false); if(this.keydownNode === this.minderNode){
this.clear(); this.setTextEditStatus(false);
this.clear();
}
e.preventDefault(); e.preventDefault();
return; return;
case keymap.Shift: case keymap.Shift:
...@@ -141,6 +143,7 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -141,6 +143,7 @@ Minder.Receiver = kity.createClass('Receiver',{
// var textOffset = this.textShape.getRenderBox(); // var textOffset = this.textShape.getRenderBox();
var contRcOffset = this.minderNode.getContRc().getRenderBox(); var contRcOffset = this.minderNode.getContRc().getRenderBox();
this.offset = { this.offset = {
x : nodeOffset.x + contRcOffset.x, x : nodeOffset.x + contRcOffset.x,
y : nodeOffset.y + contRcOffset.y y : nodeOffset.y + contRcOffset.y
...@@ -263,5 +266,9 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -263,5 +266,9 @@ Minder.Receiver = kity.createClass('Receiver',{
range.setEnd(node,this.selection.endOffset); range.setEnd(node,this.selection.endOffset);
range.select(); range.select();
return this; return this;
},
setIndex:function(index){
this.index = index;
return this
} }
}); });
\ No newline at end of file
...@@ -87,8 +87,8 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -87,8 +87,8 @@ KityMinder.registerModule( "IconModule", function () {
} )() ); } )() );
return { return {
"commands": { "commands": {
"setpriority": setPriorityCommand, "priority": setPriorityCommand,
"setprogress": setProgressCommand "progress": setProgressCommand
}, },
"events": { "events": {
"RenderNode": function ( e ) { "RenderNode": function ( e ) {
......
...@@ -67,6 +67,7 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -67,6 +67,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
buildPositionNetwork( this.getRoot() ); buildPositionNetwork( this.getRoot() );
}, },
keydown: function ( e ) { keydown: function ( e ) {
var keys = KityMinder.keymap; var keys = KityMinder.keymap;
if ( this.receiver.isTextEditStatus() ) { if ( this.receiver.isTextEditStatus() ) {
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
...@@ -85,6 +86,8 @@ KityMinder.registerModule( "KeyboardModule", function () { ...@@ -85,6 +86,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
} }
return; return;
} }
var node = e.getTargetNode();
this.receiver.keydownNode = node;
switch ( e.originEvent.keyCode ) { switch ( e.originEvent.keyCode ) {
case keys.Enter: case keys.Enter:
this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ) ); this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ) );
......
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