Commit 8aedd457 authored by techird's avatar techird

merge changes

parents 4df655fe d53af815
(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) {
return true;
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>" +
"</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>" +
"</ul>",
initContent: function ( km ) {
var lang = km.getLang( 'dialogs.markers' );
if ( lang ) {
var html = $.parseTmpl( this.tpl, lang );
}
}
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);
}
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 ) {
$w.on( "click", "li", function () {
var $this = $( this );
$this.siblings().removeClass( "active" );
$this.toggleClass( "active" );
var val = $this.val();
if ( !$this.hasClass( "active" ) ) {
val = null;
}
var type = $this.attr( "type" );
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" );
} );
},
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
})
})();
width: 200,
} )
} )();
\ No newline at end of file
......@@ -59,7 +59,7 @@ $dependency = Array(
,'src/adapter/combobox.js'
,'src/adapter/saveto.js'
,'src/adapter/hand.js'
,'src/adapter/icon.js'
,'src/adapter/dialog.js'
,'src/protocal/plain.js'
,'src/protocal/json.js'
);
......
KityMinder.LANG[ 'zh-cn' ] = {
'maintopic': '中心主题',
'topic': '分支主题',
'tooltips': {
'undo': '撤销',
'redo': '重做',
......@@ -9,23 +11,30 @@ KityMinder.LANG[ 'zh-cn' ] = {
'fontsize': '字号',
'layoutstyle': '主题',
'saveto': '导出',
'hand': '允许拖拽'
'hand': '允许拖拽',
'markers': '添加标签'
},
'popupcolor': {
'clearColor': '清空颜色',
'standardColor': '标准颜色',
'themeColor': '主题颜色'
},
'dialogs':{
'markers':{
'static':{
'lang_input_text':'文本内容:',
'lang_input_url':'链接地址:',
'lang_input_title':'标题:',
'lang_input_target':'是否在新窗口打开:'
'dialogs': {
'markers': {
'static': {
'lang_input_text': '文本内容:',
'lang_input_url': '链接地址:',
'lang_input_title': '标题:',
'lang_input_target': '是否在新窗口打开:'
},
'validLink':'只支持选中一个链接时生效',
'httpPrompt':'您输入的超链接中不包含http等协议名称,默认将为您添加http://前缀'
'priority': '优先级',
'progress': {
'notdone': "未完成",
'quarterdone': '完成1/4',
'halfdone': '完成1/2',
'threequartersdone': '完成3/4',
'done': '已完成',
}
}
}
......
KM.registerUI('markers',function(name){
KM.registerUI( 'markers', function ( name ) {
var me = this, currentRange, $dialog,
var me = this,
currentRange, $dialog,
opt = {
title: this.getLang('tooltips')[name] || '',
url: me.getOptions('KITYMINDER_HOME_URL') + 'dialogs/' + name + '/' + name + '.js'
width: 200,
title: this.getLang( 'tooltips' )[ name ] || '',
url: me.getOptions( 'KITYMINDER_HOME_URL' ) + 'dialogs/' + name + '/' + name + '.js',
};
var $btn = $.kmuibutton({
var $btn = $.kmuibutton( {
icon: name,
title: this.getLang('tooltips')[name] || ''
});
title: this.getLang( 'tooltips' )[ name ] || ''
} );
//加载模版数据
utils.loadFile(document,{
utils.loadFile( document, {
src: opt.url,
tag: "script",
type: "text/javascript",
defer: "defer"
},function(){
//调整数据
var data = KM.getWidgetData(name);
if(data.buttons){
var ok = data.buttons.ok;
if(ok){
opt.oklabel = ok.label || me.getLang('ok');
if(ok.exec){
opt.okFn = function(){
return $.proxy(ok.exec,null,me,$dialog)()
}
}
}
var cancel = data.buttons.cancel;
if(cancel){
opt.cancellabel = cancel.label || me.getLang('cancel');
if(cancel.exec){
opt.cancelFn = function(){
return $.proxy(cancel.exec,null,me,$dialog)()
}
}
}
}
data.width && (opt.width = data.width);
data.height && (opt.height = data.height);
}, function () {
$dialog = $.kmuimodal(opt);
$dialog = $.kmuimodal( opt );
$dialog.attr('id', 'kmui-dialog-' + name).addClass('kmui-dialog-' + name)
.find('.kmui-modal-body').addClass('kmui-dialog-' + name + '-body');
$dialog.attr( 'id', 'kmui-dialog-' + name ).addClass( 'kmui-dialog-' + name )
.find( '.kmui-modal-body' ).addClass( 'kmui-dialog-' + name + '-body' );
$dialog.kmui().on('beforeshow', function () {
$dialog.kmui().on( 'beforeshow', function () {
var $root = this.root(),
win = null,
offset = null;
if (!$root.parent()[0]) {
me.$container.find('.kmui-dialog-container').append($root);
if ( !$root.parent()[ 0 ] ) {
me.$container.find( '.kmui-dialog-container' ).append( $root );
}
KM.setWidgetBody(name,$dialog,me);
}).on('afterbackdrop',function(){
this.$backdrop.css('zIndex',me.getOptions('zIndex')+1).appendTo(me.$container.find('.kmui-dialog-container'))
$dialog.css('zIndex',me.getOptions('zIndex')+2)
}).attachTo($btn)
});
KM.setWidgetBody( name, $dialog, me );
} ).attachTo( $btn )
} );
me.on('interactchange', function () {
var state = this.queryCommandState(name);
$btn.kmui().disabled(state == -1).active(state == 1)
});
me.on( 'interactchange', function () {
var state = this.queryCommandState( name );
$btn.kmui().disabled( state == -1 ).active( state == 1 )
} );
return $btn;
});
\ No newline at end of file
} );
\ No newline at end of file
var KityMinder =
window.KM =
window.KityMinder = function(){
window.KityMinder = function () {
var instanceMap = {}, instanceId = 0;
return {
version : '1.0.0',
createMinder : function ( renderTarget, options ) {
version: '1.0.0',
createMinder: function ( renderTarget, options ) {
options = options || {};
options.renderTo = Utils.isString( renderTarget ) ? document.getElementById( renderTarget ) : renderTarget;
var minder = new Minder( options );
this.addMinder(options.renderTo,minder);
this.addMinder( options.renderTo, minder );
return minder;
},
addMinder : function ( target, minder ) {
addMinder: function ( target, minder ) {
var id;
if ( typeof ( target ) === 'string' ) {
id = target;
......@@ -20,17 +20,16 @@ var KityMinder =
}
instanceMap[ id ] = minder;
},
getMinder : function(target,options){
getMinder: function ( target, options ) {
var id;
if ( typeof ( target ) === 'string' ) {
id = target;
} else {
id = target.id || ( "KM_INSTANCE_" + instanceId++ );
}
return instanceMap[ id ] || this.createMinder(target,options);
return instanceMap[ id ] || this.createMinder( target, options );
},
//挂接多语言
LANG:{}
LANG: {}
}
}();
}();
\ No newline at end of file
......@@ -39,7 +39,7 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._addRenderContainer();
this._root = new MinderNode( "Main Topic" );
this._root = new MinderNode( this.getLang().maintopic );
this._root.setType( "root" );
if ( this._options.renderTo ) {
this.renderTo( this._options.renderTo );
......
//添加多语言模块
kity.extendClass( Minder, {
getLang:function(path){
getLang: function ( path ) {
var lang = KM.LANG[this.getOptions('lang')];
if (!lang) {
throw Error("not import language file");
var lang = KM.LANG[ this.getOptions( 'lang' ) ];
if ( !lang ) {
throw Error( "not import language file" );
}
path = (path || "").split(".");
for (var i = 0, ci; ci = path[i++];) {
lang = lang[ci];
if (!lang)break;
path = ( path || "" ).split( "." );
for ( var i = 0, ci; ci = path[ i++ ]; ) {
lang = lang[ ci ];
if ( !lang ) break;
}
return lang;
}
......
......@@ -38,12 +38,12 @@ kity.extendClass( Minder, {
}
}
if(moduleDeals.defaultOptions){
this.setDefaultOptions(moduleDeals.defaultOptions);
if ( moduleDeals.defaultOptions ) {
this.setDefaultOptions( moduleDeals.defaultOptions );
}
//添加模块的快捷键
if(moduleDeals.addShortcutKeys){
this.addShortcutKeys(moduleDeals.addShortcutKeys)
if ( moduleDeals.addShortcutKeys ) {
this.addShortcutKeys( moduleDeals.addShortcutKeys )
}
}
......
......@@ -83,7 +83,43 @@ 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);
}
}
}
};
......
......@@ -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:
......@@ -263,5 +265,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
KityMinder.registerModule( "IconModule", function () {
var renderPriorityIcon = function ( node, val ) {
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "orange", "#876DDA" ];
var colors = [ "", "#A92E24", "#29A6BD", "#1E8D54", "#eb6100", "#876DDA" ];
var _bg = new kity.Rect().fill( colors[ val ] ).setRadius( 3 ).setWidth( 20 ).setHeight( 20 );
var _number = new kity.Text().setContent( val ).fill( "white" ).setSize( 12 );
var _rc = new kity.Group();
......@@ -34,45 +34,63 @@ KityMinder.registerModule( "IconModule", function () {
d.carcTo( 6, 0, 6, 1, 0 );
break;
case 5:
_percent.addShape( new kity.Circle().setRadius( 6 ).fill( "#29A6BD" ) );
var check = new kity.Path();
_percent.addShapes( [ new kity.Circle().setRadius( 6 ).fill( "#29A6BD" ), check ] );
check.getDrawer().moveTo( -3, 0 ).lineTo( -1, 3 ).lineTo( 3, -2 );
check.stroke( new kity.Pen( "white", 2 ).setLineCap( "round" ) );
break;
}
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 ] );
}
},
queryValue: function ( km ) {
var nodes = km.getSelectedNodes();
var val;
for ( var i = 0; i < nodes.length; i++ ) {
val = nodes[ i ].getData( "PriorityIcon" );
if ( val ) break;
}
return val;
}
};
} )() );
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 ] );
}
},
queryValue: function ( km ) {
var nodes = km.getSelectedNodes();
var val;
for ( var i = 0; i < nodes.length; i++ ) {
val = nodes[ i ].getData( "ProgressIcon" );
if ( val ) break;
}
return val;
}
};
} )() );
return {
"commands": {
"changeicon": ChangeIconCommand,
"removeicon": RemoveIconCommand
"setpriority": setPriorityCommand,
"setprogress": setProgressCommand
},
"events": {
"": function ( e ) {
},
"RenderNode": function ( e ) {
var node = e.node;
var iconRc = node.getIconRc();
......@@ -92,6 +110,7 @@ KityMinder.registerModule( "IconModule", function () {
var iconWidth = iconRc.getWidth();
var textShape = node.getTextShape();
if ( iconWidth ) textShape.setTransform( new kity.Matrix().translate( iconWidth + 5, 0 ) );
else textShape.setTransform( new kity.Matrix().translate( 0, 0 ) );
}
}
};
......
......@@ -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,13 +86,15 @@ 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( 'Topic' ) );
this.execCommand( 'appendSiblingNode', new MinderNode( this.getLang().topic ) );
e.preventDefault();
break;
case keys.Tab:
this.execCommand( 'appendChildNode', new MinderNode( 'Topic' ) );
this.execCommand( 'appendChildNode', new MinderNode( this.getLang().topic ) );
e.preventDefault();
break;
case keys.Backspace:
......
......@@ -49,7 +49,6 @@ KM.ui.define( 'modal', {
return me[ !me.data( "isShown" ) ? 'show' : 'hide' ]();
},
show: function () {
var me = this;
me.trigger( "beforeshow" );
......
......@@ -17,7 +17,7 @@
.kmui-btn-toolbar .kmui-btn .kmui-icon-hand {
background: url(../images/hand.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-flag {
.kmui-btn-toolbar .kmui-btn .kmui-icon-markers {
background: url(../images/flag.png) no-repeat 2px 2px;
}
.kmui-btn-toolbar .kmui-btn .kmui-icon-clock {
......
.kmui-modal {
position: fixed;
_position: absolute;
top: 10%;
left: 50%;
border: 1px solid #acacac;
box-shadow: 2px 2px 5px #d3d6da;
top: 10px;
right:10px;
background-color: #ffffff;
outline: 0;
border-radius: 5px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5);
}
.kmui-modal-header {
padding: 5px 10px;
......
.kmui-modal-header .kmui-title{
font-size: 14px;
}
.kmui-dialog-markers-body {
width: 700px;
height: 400px;
padding-bottom: 5px
}
.icon-list{
margin: 0;
padding: 0
}
.icon-list li{
padding: 5px 10px;
margin: 0;
list-style: none;
cursor: pointer;
color: #333
}
.icon-list li:hover,.icon-list li.active{
background: #cfe0f7
}
.icon-list li span.icon{
display: inline-block;
width: 20px;
height: 20px;
vertical-align: middle;
margin-right: 10px;
}
\ 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