Commit 9bd882c3 authored by campaign's avatar campaign

by zhanyi

parent 7647a609
KM.registerUI( 'contextmenu', function () { KM.registerUI( 'contextmenu', function () {
var me = this; var me = this;
function getItemByLabel(label){
var result;
utils.each(me.getContextmenu(),function(i,item){
if(item.label == label){
result = item;
return false;
}
});
return result;
}
var $menu = $.kmuidropmenu({ var $menu = $.kmuidropmenu({
click:function(e,v){ click:function(e,v,l){
me.execCommand(v);
var item = getItemByLabel(l);
if(item.exec){
item.exec.apply(km)
}else{
me.execCommand(item.cmdName);
}
this.hide(); this.hide();
} }
}); });
...@@ -10,23 +30,23 @@ KM.registerUI( 'contextmenu', function () { ...@@ -10,23 +30,23 @@ KM.registerUI( 'contextmenu', function () {
me.on('contextmenu',function(e){ me.on('contextmenu',function(e){
var items = me.getContextmenu(); var items = me.getContextmenu();
var data = []; var data = [];
utils.each(items,function(i,item){ utils.each(items,function(i,item){
if(me.queryCommandState(item.cmdName)!=-1){ if(me.queryCommandState(item.cmdName)!=-1){
data.push({ data.push({
label:item.label, label:item.label,
value:item.cmdName value:item.cmdName
}) })
} }
}); });
if(data.length){ if(data.length){
var offset = e.getPosition();
$menu.kmui().setData({ $menu.kmui().setData({
data:data data:data
}).position({ }).position(e.getPosition()).show();
left: offset.x,
top: offset.y
}).show();
e.preventDefault() e.preventDefault()
} }
...@@ -34,7 +54,6 @@ KM.registerUI( 'contextmenu', function () { ...@@ -34,7 +54,6 @@ KM.registerUI( 'contextmenu', function () {
me.on('click',function(){ me.on('click',function(){
$menu.kmui().hide(); $menu.kmui().hide();
}); });
me.on('beforemousedown',function(e){ me.on('beforemousedown',function(e){
var isRightMB; var isRightMB;
......
...@@ -42,5 +42,18 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) { ...@@ -42,5 +42,18 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
comboboxWidget.selectItemByLabel( value ); comboboxWidget.selectItemByLabel( value );
} }
} ); } );
var data = [];
utils.each(me.getLayoutStyleItems(),function(i,v){
data.push({
label:me.getLang( 'tooltips.' + name ) + ' ' + v,
cmdName:'switchlayout',
exec:function(){
me.execCommand('switchlayout',v);
}
})
});
me.addContextmenu(data);
return comboboxWidget.button().addClass( 'kmui-combobox' ); return comboboxWidget.button().addClass( 'kmui-combobox' );
} ); } );
\ No newline at end of file
...@@ -27,6 +27,18 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -27,6 +27,18 @@ KityMinder.registerModule( "TextEditModule", function () {
}, },
"events": { "events": {
'beforemousedown':function(e){ 'beforemousedown':function(e){
var isRightMB;
if ("which" in e.originEvent) // Gecko (Firefox), WebKit (Safari/Chrome) & Opera
isRightMB = e.originEvent.which == 3;
else if ("button" in e.originEvent) // IE, Opera
isRightMB = e.originEvent.button == 2;
if(isRightMB){
e.stopPropagationImmediately();
return;
}
sel.setHide(); sel.setHide();
var node = e.getTargetNode(); var node = e.getTargetNode();
if(!node){ if(!node){
...@@ -68,7 +80,12 @@ KityMinder.registerModule( "TextEditModule", function () { ...@@ -68,7 +80,12 @@ KityMinder.registerModule( "TextEditModule", function () {
'mouseup':function(e){ 'mouseup':function(e){
if(mouseDownStatus){ if(mouseDownStatus){
if(!sel.collapsed ){ if(!sel.collapsed ){
receiver.updateRange(range) try{
receiver.updateRange(range)
}catch(e){
debugger
}
}else }else
sel.setShow() sel.setShow()
} }
......
...@@ -205,10 +205,16 @@ KityMinder.registerModule( "LayoutModule", function () { ...@@ -205,10 +205,16 @@ KityMinder.registerModule( "LayoutModule", function () {
'contextmenu':[ 'contextmenu':[
{ {
label:this.getLang('node.appendsiblingnode'), label:this.getLang('node.appendsiblingnode'),
exec:function(){
this.execCommand('appendsiblingnode',new MinderNode(this.getLang('topic')))
},
cmdName:'appendsiblingnode' cmdName:'appendsiblingnode'
}, },
{ {
label:this.getLang('node.appendchildnode'), label:this.getLang('node.appendchildnode'),
exec:function(){
this.execCommand('appendchildnode',new MinderNode(this.getLang('topic')))
},
cmdName:'appendchildnode' cmdName:'appendchildnode'
}, },
{ {
......
...@@ -5,7 +5,7 @@ KM.ui.define('dropmenu', { ...@@ -5,7 +5,7 @@ KM.ui.define('dropmenu', {
'</ul>', '</ul>',
subTmpl: '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' + subTmpl: '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' + '<%if(ci.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>">' + '<li <%if(ci.active||ci.disabled){%>class="<%= ci.active|| \'\' %> <%=ci.disabled||\'\' %>" <%}%> data-value="<%= ci.value%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' + '<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
'</li><%}}%>' + '</li><%}}%>' +
'<%}%>', '<%}%>',
...@@ -15,11 +15,16 @@ KM.ui.define('dropmenu', { ...@@ -15,11 +15,16 @@ KM.ui.define('dropmenu', {
} }
}, },
setData:function(items){ setData:function(items){
this.root().html($.parseTmpl(this.subTmpl,items));
this.root().html($.parseTmpl(this.subTmpl,items))
return this; return this;
}, },
position:function(offset){ position:function(offset){
this.root().offset(offset); this.root().css({
left:offset.x,
top:offset.y
});
return this; return this;
}, },
show:function(){ show:function(){
...@@ -40,7 +45,7 @@ KM.ui.define('dropmenu', { ...@@ -40,7 +45,7 @@ KM.ui.define('dropmenu', {
}; };
this.root($($.parseTmpl(this.tmpl, options))).on('click', 'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]',function (evt) { this.root($($.parseTmpl(this.tmpl, options))).on('click', 'li[class!="kmui-disabled kmui-divider kmui-dropdown-submenu"]',function (evt) {
$.proxy(options.click, me, evt, $(this).data('value'), $(this))() $.proxy(options.click, me, evt, $(this).data('value'), $(this).data('label'),$(this))()
}).find('li').each(function (i, el) { }).find('li').each(function (i, el) {
var $this = $(this); var $this = $(this);
if (!$this.hasClass("kmui-disabled kmui-divider kmui-dropdown-submenu")) { if (!$this.hasClass("kmui-disabled kmui-divider kmui-dropdown-submenu")) {
......
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