Commit c949ffd1 authored by Akikonata's avatar Akikonata

changed cmd

parent f48b3d54
(function(){ ( function () {
var utils = KM.utils; var utils = KM.utils;
function hrefStartWith(href, arr) {
href = href.replace(/^\s+|\s+$/g, ''); function hrefStartWith( href, arr ) {
for (var i = 0, ai; ai = arr[i++];) { href = href.replace( /^\s+|\s+$/g, '' );
if (href.indexOf(ai) == 0) { for ( var i = 0, ai; ai = arr[ i++ ]; ) {
if ( href.indexOf( ai ) == 0 ) {
return true; return true;
} }
} }
return false; return false;
} }
KM.registerWidget('markers', { KM.registerWidget( 'markers', {
tpl: "<style type=\"text/css\">" + tpl: '<div class="kmui-modal" tabindex="-1" >' +
".kmui-dialog-link .kmui-link-table{font-size: 12px;margin: 10px;line-height: 30px}" + '<div class="kmui-modal-header">' +
".kmui-dialog-link .kmui-link-txt{width:300px;height:21px;line-height:21px;border:1px solid #d7d7d7;}" + '<div class="kmui-close" data-hide="modal"></div>' +
"</style>" + '<h3 class="kmui-title"><%=title%></h3>' +
"<table class=\"kmui-link-table\">" + '</div>' +
"<tr>" + '<div>' +
"<td><label for=\"href\"><%=lang_input_url%></label></td>" + '<h3>优先级</h3>' +
"<td><input class=\"kmui-link-txt\" id=\"kmui-link-Jhref\" type=\"text\" /></td>" + '<ul class="icon-list" id="icon-priority"><li value="1">1</li><li value="2">2</li><li value="3">3</li><li value="4">4</li><li value="5">5</li></ul>' +
"</tr>" + '<h3>进程</h3>' +
"<tr>" + '<ul class="icon-list" id="icon-progress"><li value="1">1</li><li value="2">2</li><li value="3">3</li><li value="4">4</li><li value="5">5</li></ul>' +
"<td><label for=\"title\"><%=lang_input_title%></label></td>" + '</div>' +
"<td><input class=\"kmui-link-txt\" id=\"kmui-link-Jtitle\" type=\"text\"/></td>" + '</div>',
"</tr>" + initContent: function ( km ) {
"<tr>" + var lang = km.getLang( 'dialogs.markers' );
"<td colspan=\"2\">" + if ( lang ) {
"<label for=\"target\"><%=lang_input_target%></label>" + var html = $.parseTmpl( this.tpl, lang.static );
"<input id=\"kmui-link-Jtarget\" type=\"checkbox\"/>" +
"</td>" +
"</tr>" +
"</table>",
initContent: function (km) {
var lang = km.getLang('dialogs.markers');
if (lang) {
var html = $.parseTmpl(this.tpl, lang.static);
} }
this.root().html(html); this.root().html( html );
}, },
initEvent: function (km, $w) { initEvent: function ( km, $w ) {
var link = km.queryCommandValue('link'); var link = km.queryCommandValue( 'link' );
if(link){ if ( link ) {
$('#kmui-link-Jhref',$w).val(utils.html($(link).attr('href'))); $( '#kmui-link-Jhref', $w ).val( utils.html( $( link ).attr( 'href' ) ) );
$('#kmui-link-Jtitle',$w).val($(link).attr('title')); $( '#kmui-link-Jtitle', $w ).val( $( link ).attr( 'title' ) );
$(link).attr('target') == '_blank' && $('#kmui-link-Jtarget').attr('checked',true) $( link ).attr( 'target' ) == '_blank' && $( '#kmui-link-Jtarget' ).attr( 'checked', true )
} }
}, },
buttons: { buttons: {
'ok': { 'ok': {
exec: function (km, $w) { exec: function ( km, $w ) {
var href = $('#kmui-link-Jhref').val().replace(/^\s+|\s+$/g, ''); var href = $( '#kmui-link-Jhref' ).val().replace( /^\s+|\s+$/g, '' );
if (href) { if ( href ) {
km.execCommand('link', { km.execCommand( 'link', {
'href': href, 'href': href,
'target': $("#kmui-link-Jtarget:checked").length ? "_blank" : '_self', 'target': $( "#kmui-link-Jtarget:checked" ).length ? "_blank" : '_self',
'title': $("#kmui-link-Jtitle").val().replace(/^\s+|\s+$/g, ''), 'title': $( "#kmui-link-Jtitle" ).val().replace( /^\s+|\s+$/g, '' ),
'_href': href '_href': href
}); } );
} }
} }
}, },
'cancel':{} 'cancel': {}
}, },
width: 400 width: 400
}) } )
})(); } )();
\ No newline at end of file
...@@ -37,10 +37,10 @@ KM.registerUI( 'markers', function ( name ) { ...@@ -37,10 +37,10 @@ KM.registerUI( 'markers', function ( name ) {
var $this = $( this ); var $this = $( this );
var val = $this.val(); var val = $this.val();
me.execCommand( "changeicon", "PriorityIcon", val ); me.execCommand( "changeicon", "PriorityIcon", val );
} ).on( "click", "#icon-progress li", function () { } ).on( "click", "#icon-priority li", function () {
var $this = $( this ); var $this = $( this );
var val = $this.val(); var val = $this.val();
me.execCommand( "changeicon", "ProgressIcon", val ); me.execCommand( "changeicon", "PriorityIcon", val );
} ); } );
} ).attachTo( $btn ) } ).attachTo( $btn )
} ); } );
......
...@@ -40,25 +40,25 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -40,25 +40,25 @@ KityMinder.registerModule( "IconModule", function () {
if ( val < 5 ) d.close(); if ( val < 5 ) d.close();
_percent.fill( "#29A6BD" ); _percent.fill( "#29A6BD" );
}; };
var ChangeIconCommand = kity.createClass( "AddIconCommand", ( function () { var setPriorityCommand = kity.createClass( "SetPriorityCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, iconType, 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( iconType, value ); nodes[ i ].setData( "PriorityIcon", value );
km.updateLayout( nodes[ i ] ); km.updateLayout( nodes[ i ] );
} }
} }
}; };
} )() ); } )() );
var RemoveIconCommand = kity.createClass( "RemoveIconCommand", ( function () { var setProgressCommand = kity.createClass( "SetProgressCommand", ( function () {
return { return {
base: Command, base: Command,
execute: function ( km, iconType ) { 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( iconType, null ); nodes[ i ].setData( "ProgressIcon", value );
km.updateLayout( nodes[ i ] ); km.updateLayout( nodes[ i ] );
} }
} }
...@@ -66,13 +66,10 @@ KityMinder.registerModule( "IconModule", function () { ...@@ -66,13 +66,10 @@ KityMinder.registerModule( "IconModule", function () {
} )() ); } )() );
return { return {
"commands": { "commands": {
"changeicon": ChangeIconCommand, "setpriority": setPriorityCommand,
"removeicon": RemoveIconCommand "setprogress": setProgressCommand
}, },
"events": { "events": {
"": function ( e ) {
},
"RenderNode": function ( e ) { "RenderNode": function ( e ) {
var node = e.node; var node = e.node;
var iconRc = node.getIconRc(); var iconRc = node.getIconRc();
......
...@@ -5,13 +5,16 @@ KM.ui.define( 'modal', { ...@@ -5,13 +5,16 @@ KM.ui.define( 'modal', {
'<div class="kmui-close" data-hide="modal"></div>' + '<div class="kmui-close" data-hide="modal"></div>' +
'<h3 class="kmui-title"><%=title%></h3>' + '<h3 class="kmui-title"><%=title%></h3>' +
'</div>' + '</div>' +
'<div>' + '<div class="kmui-modal-body" style="<%if(width){%>width:<%=width%>px;<%}%>' +
'<h3>优先级</h3>' + '<%if(height){%>height:<%=height%>px;<%}%>">' +
'<ul class="icon-list" id="icon-priority"><li value="1">1</li><li value="2">2</li><li value="3">3</li><li value="4">4</li><li value="5">5</li></ul>' + ' </div>' +
'<h3>进程</h3>' + '<% if(cancellabel || oklabel) {%>' +
'<ul class="icon-list" id="icon-progress"><li value="1">1</li><li value="2">2</li><li value="3">3</li><li value="4">4</li><li value="5">5</li></ul>' + '<div class="kmui-modal-footer">' +
'<div class="kmui-modal-tip"></div>' +
'<%if(oklabel){%><div class="kmui-btn kmui-btn-primary" data-ok="modal"><%=oklabel%></div><%}%>' +
'<%if(cancellabel){%><div class="kmui-btn" data-hide="modal"><%=cancellabel%></div><%}%>' +
'</div>' + '</div>' +
'</div>', '<%}%></div>',
defaultOpt: { defaultOpt: {
title: "", title: "",
cancellabel: "", cancellabel: "",
......
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