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 @@
var utils = KM.utils;
KM.registerWidget( 'markers', {
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='2' type='setpriority'><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='4' type='setpriority'><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='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='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -20px 0'></span><span><%= priority %>2</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='priority'><span class='icon' style='background:url(../dialogs/icons/iconpriority.png) -60px 0'></span><span><%= priority %>4</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 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='2' type='setprogress'><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='4' type='setprogress'><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='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='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -20px 0'></span><span><%= progress.quarterdone %></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='progress'><span class='icon' style='background:url(../dialogs/icons/iconprogress.png) -60px 0'></span><span><%= progress.threequartersdone %></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>",
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.markers' );
......@@ -35,12 +35,12 @@
km.execCommand( type, val );
} );
km.on( 'interactchange', function ( e ) {
var valPri = this.queryCommandValue( "setpriority" );
var valPro = this.queryCommandValue( "setprogress" );
$w.find( "li[type='setpriority']" ).removeClass( "active" );
$w.find( "li[type='setpriority'][value='" + valPri + "']" ).addClass( "active" );
$w.find( "li[type='setprogress']" ).removeClass( "active" );
$w.find( "li[type='setprogress'][value='" + valPro + "']" ).addClass( "active" );
var valPri = this.queryCommandValue( "priority" );
var valPro = this.queryCommandValue( "progress" );
$w.find( "li[type='priority']" ).removeClass( "active" );
$w.find( "li[type='priority'][value='" + valPri + "']" ).addClass( "active" );
$w.find( "li[type='progress']" ).removeClass( "active" );
$w.find( "li[type='progress'][value='" + valPro + "']" ).addClass( "active" );
} );
},
buttons: {
......
......@@ -48,7 +48,7 @@ KityMinder.registerModule( "TextEditModule", function () {
}
},
'mouseup':function(e){
if(!sel.collapsed){
if(!sel.collapsed && mouseDownStatus){
receiver.updateRange(range)
}
mouseDownStatus = false;
......@@ -83,7 +83,57 @@ KityMinder.registerModule( "TextEditModule", function () {
},
'stopTextEdit':function(){
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',{
switch(keyCode){
case keymap.Enter:
case keymap.Tab:
if(this.keydownNode === this.minderNode){
this.setTextEditStatus(false);
this.clear();
}
e.preventDefault();
return;
case keymap.Shift:
......@@ -141,6 +143,7 @@ Minder.Receiver = kity.createClass('Receiver',{
// var textOffset = this.textShape.getRenderBox();
var contRcOffset = this.minderNode.getContRc().getRenderBox();
this.offset = {
x : nodeOffset.x + contRcOffset.x,
y : nodeOffset.y + contRcOffset.y
......@@ -263,5 +266,9 @@ Minder.Receiver = kity.createClass('Receiver',{
range.setEnd(node,this.selection.endOffset);
range.select();
return this;
},
setIndex:function(index){
this.index = index;
return this
}
});
\ No newline at end of file
......@@ -87,8 +87,8 @@ KityMinder.registerModule( "IconModule", function () {
} )() );
return {
"commands": {
"setpriority": setPriorityCommand,
"setprogress": setProgressCommand
"priority": setPriorityCommand,
"progress": setProgressCommand
},
"events": {
"RenderNode": function ( e ) {
......
......@@ -67,6 +67,7 @@ KityMinder.registerModule( "KeyboardModule", function () {
buildPositionNetwork( this.getRoot() );
},
keydown: function ( e ) {
var keys = KityMinder.keymap;
if ( this.receiver.isTextEditStatus() ) {
switch ( e.originEvent.keyCode ) {
......@@ -85,6 +86,8 @@ KityMinder.registerModule( "KeyboardModule", function () {
}
return;
}
var node = e.getTargetNode();
this.receiver.keydownNode = node;
switch ( e.originEvent.keyCode ) {
case keys.Enter:
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