Commit 9bd882c3 authored by campaign's avatar campaign

by zhanyi

parent 7647a609
KM.registerUI( 'contextmenu', function () {
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({
click:function(e,v){
me.execCommand(v);
click:function(e,v,l){
var item = getItemByLabel(l);
if(item.exec){
item.exec.apply(km)
}else{
me.execCommand(item.cmdName);
}
this.hide();
}
});
......@@ -10,23 +30,23 @@ KM.registerUI( 'contextmenu', function () {
me.on('contextmenu',function(e){
var items = me.getContextmenu();
var data = [];
utils.each(items,function(i,item){
if(me.queryCommandState(item.cmdName)!=-1){
data.push({
label:item.label,
value:item.cmdName
})
}
});
if(data.length){
var offset = e.getPosition();
$menu.kmui().setData({
data:data
}).position({
left: offset.x,
top: offset.y
}).show();
}).position(e.getPosition()).show();
e.preventDefault()
}
......@@ -34,7 +54,6 @@ KM.registerUI( 'contextmenu', function () {
me.on('click',function(){
$menu.kmui().hide();
});
me.on('beforemousedown',function(e){
var isRightMB;
......
......@@ -42,5 +42,18 @@ KM.registerToolbarUI( 'switchlayout', function ( name ) {
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' );
} );
\ No newline at end of file
......@@ -27,6 +27,18 @@ KityMinder.registerModule( "TextEditModule", function () {
},
"events": {
'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();
var node = e.getTargetNode();
if(!node){
......@@ -68,7 +80,12 @@ KityMinder.registerModule( "TextEditModule", function () {
'mouseup':function(e){
if(mouseDownStatus){
if(!sel.collapsed ){
receiver.updateRange(range)
try{
receiver.updateRange(range)
}catch(e){
debugger
}
}else
sel.setShow()
}
......
......@@ -205,10 +205,16 @@ KityMinder.registerModule( "LayoutModule", function () {
'contextmenu':[
{
label:this.getLang('node.appendsiblingnode'),
exec:function(){
this.execCommand('appendsiblingnode',new MinderNode(this.getLang('topic')))
},
cmdName:'appendsiblingnode'
},
{
label:this.getLang('node.appendchildnode'),
exec:function(){
this.execCommand('appendchildnode',new MinderNode(this.getLang('topic')))
},
cmdName:'appendchildnode'
},
{
......
......@@ -5,7 +5,7 @@ KM.ui.define('dropmenu', {
'</ul>',
subTmpl: '<%if(data && data.length){for(var i=0,ci;ci=data[i++];){%>' +
'<%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>' +
'</li><%}}%>' +
'<%}%>',
......@@ -15,11 +15,16 @@ KM.ui.define('dropmenu', {
}
},
setData:function(items){
this.root().html($.parseTmpl(this.subTmpl,items));
this.root().html($.parseTmpl(this.subTmpl,items))
return this;
},
position:function(offset){
this.root().offset(offset);
this.root().css({
left:offset.x,
top:offset.y
});
return this;
},
show:function(){
......@@ -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) {
$.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) {
var $this = $(this);
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