Commit c949ffd1 authored by Akikonata's avatar Akikonata

changed cmd

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