Commit cfc65d13 authored by Akikonata's avatar Akikonata

dev

parent b6a7a3db
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
"<li value='7' type='priority'><span class='icon p7'></span><span><%= priority %>7</span></li>" + "<li value='7' type='priority'><span class='icon p7'></span><span><%= priority %>7</span></li>" +
"<li value='8' type='priority'><span class='icon p8'></span><span><%= priority %>8</span></li>" + "<li value='8' type='priority'><span class='icon p8'></span><span><%= priority %>8</span></li>" +
"<li value='9' type='priority'><span class='icon p9'></span><span><%= priority %>9</span></li>" + "<li value='9' type='priority'><span class='icon p9'></span><span><%= priority %>9</span></li>" +
"<li value='0' type='priority'><span class='icon p0'></span><span><%= priority %>0</span></li>" + "<li value='10' type='priority'><span class='icon p0'></span><span><%= priority %>0</span></li>" +
"</ul>" + "</ul>" +
"<ul class='icon-list progress'>" + "<ul class='icon-list progress'>" +
"<li value='1' type='progress'><span class='icon p1'></span><span><%= progress.notdone %></span></li>" + "<li value='1' type='progress'><span class='icon p1'></span><span><%= progress.notdone %></span></li>" +
......
KityMinder.registerModule( "IconModule", function () { KityMinder.registerModule("IconModule", function () {
var minder = this; var minder = this;
var renderPriorityIcon = function ( node, val ) { var renderPriorityIcon = function (node, val) {
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ]; var colors = ["", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA", "#828282", "#828282", "#828282", "#828282", "#828282"];
var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 ); var bgcolor = colors[val];
var _number = new kity.Text().setContent( val ).fill( "white" ).setSize( 12 ); var _bg = new kity.Rect().fill(colors[val]).setRadius(3).setWidth(20).setHeight(20);
var _number;
if (val < 10) {
_number = new kity.Text().setContent(val).fill("white").setSize(12);
} else {
_number = new kity.Rect().fill("white").setWidth(14).setHeight(14).translate(-3, -12);
}
var _rc = new kity.Group(); var _rc = new kity.Group();
_rc.addShapes( [ _bg, _number ] ); _rc.addShapes([_bg, _number]);
node.getContRc().addShape( _rc ); node.getContRc().addShape(_rc);
_number.setTranslate( 6, 15 ); _number.setTranslate(6, 15);
var rcHeight = _rc.getHeight(); var rcHeight = _rc.getHeight();
_rc.setTranslate( 0, -rcHeight / 2 ); _rc.setTranslate(0, -rcHeight / 2);
}; };
var renderProgressIcon = function ( node, val ) { var renderProgressIcon = function (node, val) {
var _rc = new kity.Group(); var _rc = new kity.Group();
var _contRc = node.getContRc(); var _contRc = node.getContRc();
var _bg = new kity.Circle().setRadius( 8 ).fill( "white" ).stroke( new kity.Pen( "#29A6BD", 2 ) ); var _bg = new kity.Circle().setRadius(8).fill("white").stroke(new kity.Pen("#29A6BD", 2));
var _percent, d; var _percent, d;
if ( val < 5 ) { if (val < 5) {
_percent = new kity.Path(); _percent = new kity.Path();
d = _percent.getDrawer(); d = _percent.getDrawer();
d.moveTo( 0, 0 ).lineTo( 6, 0 ); d.moveTo(0, 0).lineTo(6, 0);
} else _percent = new kity.Group(); } else _percent = new kity.Group();
_rc.addShapes( [ _bg, _percent ] ); _rc.addShapes([_bg, _percent]);
_contRc.addShape( _rc ); _contRc.addShape(_rc);
switch ( val ) { switch (val) {
case 1: case 1:
break; break;
case 2: case 2:
d.carcTo( 6, 0, 0, 0, -6 ); d.carcTo(6, 0, 0, 0, -6);
break; break;
case 3: case 3:
d.carcTo( 6, 0, 0, -6, 0 ); d.carcTo(6, 0, 0, -6, 0);
break; break;
case 4: case 4:
d.carcTo( 6, 1, 0, 0, 6 ); d.carcTo(6, 1, 0, 0, 6);
break; break;
case 5: case 5:
var check = new kity.Path(); var check = new kity.Path();
_percent.addShapes( [ new kity.Circle().setRadius( 6 ).fill( "#29A6BD" ), check ] ); _percent.addShapes([new kity.Circle().setRadius(6).fill("#29A6BD"), check]);
check.getDrawer().moveTo( -3, 0 ).lineTo( -1, 3 ).lineTo( 3, -2 ); check.getDrawer().moveTo(-3, 0).lineTo(-1, 3).lineTo(3, -2);
check.stroke( new kity.Pen( "white", 2 ).setLineCap( "round" ) ); check.stroke(new kity.Pen("white", 2).setLineCap("round"));
break; break;
} }
if ( val < 5 ) d.close(); if (val < 5) d.close();
_percent.fill( "#29A6BD" ); _percent.fill("#29A6BD");
var pre = node.getData( "PriorityIcon" ); var pre = node.getData("PriorityIcon");
var style = minder.getCurrentLayoutStyle()[ node.getType() ]; var style = minder.getCurrentLayoutStyle()[node.getType()];
if ( !pre ) _rc.setTranslate( _rc.getWidth() / 2, 0 ); if (!pre) _rc.setTranslate(_rc.getWidth() / 2, 0);
else _rc.setTranslate( _contRc.getWidth() + style.spaceLeft, 0 ); else _rc.setTranslate(_contRc.getWidth() + style.spaceLeft, 0);
}; };
var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () { var setPriorityCommand = kity.createClass("SetPriorityCommand", (function () {
return { return {
base: Command, base: Command,
execute: function ( km, value ) { execute: function (km, value) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
for ( var i = 0; i < nodes.length; i++ ) { for (var i = 0; i < nodes.length; i++) {
nodes[ i ].setData( "PriorityIcon", value ); nodes[i].setData("PriorityIcon", value);
km.updateLayout( nodes[ i ] ); km.updateLayout(nodes[i]);
} }
}, },
queryValue: function ( km ) { queryValue: function (km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
var val; var val;
for ( var i = 0; i < nodes.length; i++ ) { for (var i = 0; i < nodes.length; i++) {
val = nodes[ i ].getData( "PriorityIcon" ); val = nodes[i].getData("PriorityIcon");
if ( val ) break; if (val) break;
} }
return val; return val;
} }
}; };
} )() ); })());
var setProgressCommand = kity.createClass( "SetProgressCommand", ( function () { var setProgressCommand = kity.createClass("SetProgressCommand", (function () {
return { return {
base: Command, base: Command,
execute: function ( km, value ) { execute: function (km, value) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
for ( var i = 0; i < nodes.length; i++ ) { for (var i = 0; i < nodes.length; i++) {
nodes[ i ].setData( "ProgressIcon", value ); nodes[i].setData("ProgressIcon", value);
km.updateLayout( nodes[ i ] ); km.updateLayout(nodes[i]);
} }
}, },
queryValue: function ( km ) { queryValue: function (km) {
var nodes = km.getSelectedNodes(); var nodes = km.getSelectedNodes();
var val; var val;
for ( var i = 0; i < nodes.length; i++ ) { for (var i = 0; i < nodes.length; i++) {
val = nodes[ i ].getData( "ProgressIcon" ); val = nodes[i].getData("ProgressIcon");
if ( val ) break; if (val) break;
} }
return val; return val;
} }
}; };
} )() ); })());
return { return {
"commands": { "commands": {
"priority": setPriorityCommand, "priority": setPriorityCommand,
"progress": setProgressCommand "progress": setProgressCommand
}, },
"events": { "events": {
"RenderNodeLeft": function ( e ) { "RenderNodeLeft": function (e) {
var node = e.node; var node = e.node;
var PriorityIconVal = node.getData( "PriorityIcon" ); var PriorityIconVal = node.getData("PriorityIcon");
var ProgressIconVal = node.getData( "ProgressIcon" ); var ProgressIconVal = node.getData("ProgressIcon");
var contRc = node.getContRc(); var contRc = node.getContRc();
if ( PriorityIconVal ) { if (PriorityIconVal) {
renderPriorityIcon( node, PriorityIconVal ); renderPriorityIcon(node, PriorityIconVal);
} }
if ( ProgressIconVal ) { if (ProgressIconVal) {
renderProgressIcon( node, ProgressIconVal ); renderProgressIcon(node, ProgressIconVal);
} }
} }
} }
}; };
} ); });
\ No newline at end of file \ 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