Commit 01ce0443 authored by campaign's avatar campaign

Merge branch 'dev' into gh-pages

parents 52a72af9 cc6e3076
...@@ -884,7 +884,8 @@ baidu.frontia = {}, function(e) { ...@@ -884,7 +884,8 @@ baidu.frontia = {}, function(e) {
var i = []; var i = [];
t.response_params.users.forEach(function(t) { t.response_params.users.forEach(function(t) {
var r = new e.User({socialId: t.user_id,mediaType: t.media_type,name: t.username}); var r = new e.User({socialId: t.user_id,mediaType: t.media_type,name: t.username});
i.push(r) r.extra = t;
i.push(r);
}), u.options.success({result: i,count: t.response_params.count}), c.err_code = 0 }), u.options.success({result: i,count: t.response_params.count}), c.err_code = 0
} }
c.restimestamp = n(), r(c) c.restimestamp = n(), r(c)
......
...@@ -1313,7 +1313,6 @@ kity.extendClass( Minder, { ...@@ -1313,7 +1313,6 @@ kity.extendClass( Minder, {
rc.addShape( current.getRenderContainer() ); rc.addShape( current.getRenderContainer() );
} ); } );
}, },
handelNodeRemove: function ( node ) { handelNodeRemove: function ( node ) {
var rc = this._rc; var rc = this._rc;
node.traverse( function ( current ) { node.traverse( function ( current ) {
...@@ -1330,6 +1329,9 @@ kity.extendClass( Minder, { ...@@ -1330,6 +1329,9 @@ kity.extendClass( Minder, {
} else { } else {
km.renderNode( nodes ); km.renderNode( nodes );
} }
},
getMinderTitle: function() {
return this.getRoot().getText();
} }
} ); } );
...@@ -2665,9 +2667,11 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -2665,9 +2667,11 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout.connect = null; Layout.connect = null;
Layout.shicon = null; Layout.shicon = null;
} else { } else {
_buffer[ 0 ].getRenderContainer().remove(); try {
Layout.connect.remove(); _buffer[ 0 ].getRenderContainer().remove();
if ( Layout.shicon ) Layout.shicon.remove(); Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove();
} catch ( error ) {}
} }
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
...@@ -3292,6 +3296,39 @@ kity.extendClass( Minder, function () { ...@@ -3292,6 +3296,39 @@ kity.extendClass( Minder, function () {
}, },
isSingleSelect: function () { isSingleSelect: function () {
return this._selectedNodes.length == 1; return this._selectedNodes.length == 1;
},
getSelectedAncestors: function() {
var nodes = this.getSelectedNodes().slice( 0 ),
ancestors = [],
judge;
// 根节点不参与计算
var rootIndex = nodes.indexOf( this.getRoot() );
if ( ~rootIndex ) {
nodes.splice( rootIndex, 1 );
}
// 判断 nodes 列表中是否存在 judge 的祖先
function hasAncestor( nodes, judge ) {
for ( var i = nodes.length - 1; i >= 0; --i ) {
if ( nodes[ i ].isAncestorOf( judge ) ) return true;
}
return false;
}
// 按照拓扑排序
nodes.sort( function ( node1, node2 ) {
return node1.getLevel() - node2.getLevel();
} );
// 因为是拓扑有序的,所以只需往上查找
while ( ( judge = nodes.pop() ) ) {
if ( !hasAncestor( nodes, judge ) ) {
ancestors.push( judge );
}
}
return ancestors;
} }
}; };
}() ); }() );
...@@ -3327,6 +3364,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -3327,6 +3364,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
if ( dragger.isEnabled() ) { if ( dragger.isEnabled() ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
e.stopPropagation(); e.stopPropagation();
e.originEvent.preventDefault();
} }
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
else if ( e.getTargetNode() == this.getRoot() && else if ( e.getTargetNode() == this.getRoot() &&
...@@ -3469,36 +3507,7 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -3469,36 +3507,7 @@ var DragBox = kity.createClass( "DragBox", {
// 2. 从后往前枚举排序的结果,如果发现枚举目标之前存在其祖先, // 2. 从后往前枚举排序的结果,如果发现枚举目标之前存在其祖先,
// 则排除枚举目标作为拖放源,否则加入拖放源 // 则排除枚举目标作为拖放源,否则加入拖放源
_calcDragSources: function () { _calcDragSources: function () {
var nodes = this._minder.getSelectedNodes().slice( 0 ), this._dragSources = this._minder.getSelectedAncestors();
ancestors = [],
judge;
// 根节点不参与计算
var rootIndex = nodes.indexOf( this._minder.getRoot() );
if ( ~rootIndex ) {
nodes.splice( rootIndex, 1 );
}
// 判断 nodes 列表中是否存在 judge 的祖先
function hasAncestor( nodes, judge ) {
for ( var i = nodes.length - 1; i >= 0; --i ) {
if ( nodes[ i ].isAncestorOf( judge ) ) return true;
}
return false;
}
// 按照拓扑排序
nodes.sort( function ( node1, node2 ) {
return node1.getLevel() - node2.getLevel();
} );
// 因为是拓扑有序的,所以只需往上查找
while ( ( judge = nodes.pop() ) ) {
if ( !hasAncestor( nodes, judge ) ) {
ancestors.push( judge );
}
}
this._dragSources = ancestors;
}, },
...@@ -5090,7 +5099,8 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -5090,7 +5099,8 @@ KityMinder.registerModule( 'Zoom', function () {
'ready': function () { 'ready': function () {
this._zoomValue = 1; this._zoomValue = 1;
}, },
'mousewheel': function ( e ) { // disable mouse wheel
'mousewheel_': function ( e ) {
var delta = e.originEvent.wheelDelta; var delta = e.originEvent.wheelDelta;
var me = this; var me = this;
...@@ -5405,11 +5415,11 @@ KM.ui.define('button', { ...@@ -5405,11 +5415,11 @@ KM.ui.define('button', {
//menu 类 //menu 类
KM.ui.define('menu',{ KM.ui.define('menu',{
show : function($obj,dir,fnname,topOffset,leftOffset){ show : function($obj,dir,fnname,topOffset,leftOffset){
fnname = fnname || 'position'; fnname = fnname || 'position';
if(this.trigger('beforeshow') === false){ if(this.trigger('beforeshow') === false){
return; return;
}else{ }else{
this.root().css($.extend({display:'block'},$obj ? { this.root().css($.extend({display:'block'},$obj ? {
top : $obj[fnname]().top + ( dir == 'right' ? 0 : $obj.outerHeight()) - (topOffset || 0), top : $obj[fnname]().top + ( dir == 'right' ? 0 : $obj.outerHeight()) - (topOffset || 0),
left : $obj[fnname]().left + (dir == 'right' ? $obj.outerWidth() : 0) - (leftOffset || 0) left : $obj[fnname]().left + (dir == 'right' ? $obj.outerWidth() : 0) - (leftOffset || 0)
...@@ -5435,9 +5445,16 @@ KM.ui.define('menu',{ ...@@ -5435,9 +5445,16 @@ KM.ui.define('menu',{
var me = this; var me = this;
if(!$obj.data('$mergeObj')){ if(!$obj.data('$mergeObj')){
$obj.data('$mergeObj',me.root()); $obj.data('$mergeObj',me.root());
$obj.on('wrapclick',function(evt){ if($obj.kmui()){
me.show() $obj.on('wrapclick',function(evt){
}); me.supper.show.call(me,$obj,'','offset',15)
});
}else{
$obj.on('click',function(evt){
me.supper.show.call(me,$obj,'','offset',15)
})
}
me.register('click',$obj,function(evt){ me.register('click',$obj,function(evt){
me.hide() me.hide()
}); });
...@@ -5447,9 +5464,14 @@ KM.ui.define('menu',{ ...@@ -5447,9 +5464,14 @@ KM.ui.define('menu',{
}); });
//dropmenu 类 //dropmenu 类
KM.ui.define('dropmenu', { KM.ui.define( 'dropmenu', {
tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' + tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' +
this.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%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
'</li><%}}%>' +
'<%}%>' +
'</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{%>' +
...@@ -5459,32 +5481,33 @@ KM.ui.define('dropmenu', { ...@@ -5459,32 +5481,33 @@ KM.ui.define('dropmenu', {
'<%}%>', '<%}%>',
defaultOpt: { defaultOpt: {
data: [], data: [],
click: function () { click: function () {}
}
}, },
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().css({ this.root().css( {
left:offset.x, left: offset.x,
top:offset.y top: offset.y
}); } );
return this; return this;
}, },
show:function(){ show: function () {
if(this.trigger('beforeshow') === false){ if ( this.trigger( 'beforeshow' ) === false ) {
return; return;
}else{ } else {
this.root().css({display:'block'}); this.root().css( {
this.trigger('aftershow'); display: 'block'
} );
this.trigger( 'aftershow' );
} }
return this; return this;
}, },
init: function (options) { init: function ( options ) {
var me = this; var me = this;
var eventName = { var eventName = {
click: 1, click: 1,
...@@ -5492,66 +5515,75 @@ KM.ui.define('dropmenu', { ...@@ -5492,66 +5515,75 @@ KM.ui.define('dropmenu', {
mouseout: 1 mouseout: 1
}; };
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).data('label'),$(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" ) ) {
var data = options.data[i]; var data = options.data[ i ];
$.each(eventName, function (k) { $.each( eventName, function ( k ) {
data[k] && $this[k](function (evt) { data[ k ] && $this[ k ]( function ( evt ) {
$.proxy(data[k], el)(evt, data, me.root) $.proxy( data[ k ], el )( evt, data, me.root )
}) } )
}) } )
} }
}) } )
}, },
disabled: function (cb) { disabled: function ( cb ) {
$('li[class!=kmui-divider]', this.root()).each(function () { $( 'li[class!=kmui-divider]', this.root() ).each( function () {
var $el = $(this); var $el = $( this );
if (cb === true) { if ( cb === true ) {
$el.addClass('kmui-disabled') $el.addClass( 'kmui-disabled' )
} else if ($.isFunction(cb)) { } else if ( $.isFunction( cb ) ) {
$el.toggleClass('kmui-disabled', cb(li)) $el.toggleClass( 'kmui-disabled', cb( li ) )
} else { } else {
$el.removeClass('kmui-disabled') $el.removeClass( 'kmui-disabled' )
} }
}); } );
}, },
val: function (val) { val: function ( val ) {
var currentVal; var currentVal;
$('li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]', this.root()).each(function () { $( 'li[class!="kmui-divider kmui-disabled kmui-dropdown-submenu"]', this.root() ).each( function () {
var $el = $(this); var $el = $( this );
if (val === undefined) { if ( val === undefined ) {
if ($el.find('em.kmui-dropmenu-checked').length) { if ( $el.find( 'em.kmui-dropmenu-checked' ).length ) {
currentVal = $el.data('value'); currentVal = $el.data( 'value' );
return false return false
} }
} else { } else {
$el.find('em').toggleClass('kmui-dropmenu-checked', $el.data('value') == val) $el.find( 'em' ).toggleClass( 'kmui-dropmenu-checked', $el.data( 'value' ) == val )
} }
}); } );
if (val === undefined) { if ( val === undefined ) {
return currentVal return currentVal
} }
}, },
addSubmenu: function (label, menu, index) { appendItem: function ( item ) {
var itemTpl = '<%if(item.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(item.active||item.disabled){%>class="<%= item.active|| \'\' %> <%=item.disabled||\'\' %>" <%}%> data-value="<%= item.value%>" data-label="<%= item.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= item.label%></a>' +
'</li><%}%>';
var html = $.parseTmpl( itemTpl, item );
var $item = $( html ).click( item.click );
this.root().append( $item );
},
addSubmenu: function ( label, menu, index ) {
index = index || 0; index = index || 0;
var $list = $('li[class!=kmui-divider]', this.root()); var $list = $( 'li[class!=kmui-divider]', this.root() );
var $node = $('<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>').append(menu); var $node = $( '<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>' ).append( menu );
if (index >= 0 && index < $list.length) { if ( index >= 0 && index < $list.length ) {
$node.insertBefore($list[index]); $node.insertBefore( $list[ index ] );
} else if (index < 0) { } else if ( index < 0 ) {
$node.insertBefore($list[0]); $node.insertBefore( $list[ 0 ] );
} else if (index >= $list.length) { } else if ( index >= $list.length ) {
$node.appendTo($list); $node.appendTo( $list );
} }
} }
}, 'menu'); }, 'menu' );
//splitbutton 类 //splitbutton 类
///import button ///import button
...@@ -7125,8 +7157,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) { ...@@ -7125,8 +7157,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
temp = options.items[ i ]; temp = options.items[ i ];
tempItems.push( temp ); tempItems.push( temp );
options.itemStyles.push( 'font-size: ' + temp + 'px' ); options.itemStyles.push( 'font-size: ' + temp + 'px; height:' + (temp+2) + 'px; line-height: ' + (temp + 2) + 'px' );
} }
options.value = options.items; options.value = options.items;
......
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
<script src="social.js" charset="utf-8"></script> <script src="social.js" charset="utf-8"></script>
<script src="../kity/dist/kitygraph.all.js" charset="utf-8"></script> <script src="../kity/dist/kitygraph.all.js" charset="utf-8"></script>
<script src="../configure.js" charset="utf-8"></script> <script src="../configure.js" charset="utf-8"></script>
<script src="../dist/dev.js" charset="utf-8"></script> <script src="../dist/dev.php" charset="utf-8"></script>
<script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script> <script src="../lang/zh-cn/zh-cn.js" charset="utf-8"></script>
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet"> <link href="../themes/default/css/import.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="social.css">
<style> <style>
.km_receiver{ .km_receiver{
width:0; width:0;
...@@ -26,37 +27,9 @@ ...@@ -26,37 +27,9 @@
margin: 0; margin: 0;
padding: 0; padding: 0;
} }
#social { html, body, div.kmui-editor-body {
position: absolute; height: 100%;
right: 10px; -moz-user-select: none;
top: 10px;
line-height: 20px;
text-align: right;
overflow: hidden;
}
#social button {
outline: none;
display: inline-block;
bottom: 20px;
right: 30px;
background: #0099f2;
padding: 0 15px;
height: 35px;
font-size: 13px;
line-height: 35px;
text-align: center;
border-radius: 5px;
color: #ffffff;
text-decoration: none;
border: none;
margin-left: 5px;
cursor: pointer;
}
#social button:hover {
background: #009fff;
}
#social button[disabled] {
background-color: #AAA;
} }
</style> </style>
</head> </head>
......
#social {
position: absolute;
right: 10px;
top: 10px;
line-height: 20px;
text-align: right;
overflow: hidden;
}
#social button {
font-family: Arial, "Heiti SC", "Microsoft Yahei";
outline: none;
display: inline-block;
padding: 0 15px;
height: 35px;
font-size: 13px;
line-height: 35px;
text-align: center;
border-radius: 5px;
color: #ffffff;
text-decoration: none;
border: none;
margin-left: 5px;
cursor: pointer;
background: #0099f2;
/* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%);
/* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #0099f2), color-stop(0%, #4096ee), color-stop(100%, #0076dd));
/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%);
/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%);
/* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%);
/* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%, #4096ee 0%, #0076dd 100%);
/* W3C */
}
#social button:hover {
background: #009fff;
}
#social button[disabled] {
background: #AAA;
}
#social button.baidu-cloud {
padding-left: 35px;
position: relative;
}
#social button.baidu-cloud:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/baiducloud.png);
position: absolute;
left: 7px;
top: 5px;
}
#social button.share {
padding-left: 35px;
position: relative;
}
#social button.share:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/share.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
#social button img {
position: relative;
top: 3px;
border-radius: 2px;
margin-right: 7px;
}
#social button.user-file {
padding-right: 28px;
position: relative;
}
#social button.user-file:after {
content: ' ';
display: block;
position: absolute;
right: 10px;
top: 15px;
width: 0;
height: 0;
border: solid;
border-width: 4px 5px;
border-color: #FFFFFF transparent transparent transparent;
}
.user-file-menu {
margin-top: 20px;
margin-left: 1px;
}
$.extend( $.fn, {
disabled: function ( value ) {
if ( value === undefined ) return !!this.attr( 'disabled' );
if ( value ) {
this.attr( 'disabled', 'disabled' );
} else {
this.removeAttr( 'disabled' );
}
return this;
},
loading: function ( text ) {
if ( text ) {
if ( !this.disabled() ) {
this.disabled( true );
this.attr( 'origin-text', this.text() );
}
this.text( text );
} else {
this.text( this.attr( 'origin-text' ) );
this.removeAttr( 'origin-text' );
this.disabled( false );
}
return this;
},
text: ( function () {
var originFn = $.fn.text;
return function () {
var textSpan = this.children( 'span.text' );
if ( textSpan.length ) {
return originFn.apply( textSpan, arguments );
} else {
return originFn.apply( this, arguments );
}
};
} )()
} );
$( function () { $( function () {
var $panel = $( '#social' ); var $panel = $( '#social' );
var $login_btn, $save_btn, $share_btn; var $login_btn, $save_btn, $share_btn, $user_btn, $user_menu;
var baseUrl = ( function () { var baseUrl = ( function () {
var scripts = document.getElementsByTagName( 'script' ); var scripts = document.getElementsByTagName( 'script' );
...@@ -12,77 +49,39 @@ $( function () { ...@@ -12,77 +49,39 @@ $( function () {
} }
} )(); } )();
$login_btn = $( '<button>登录</button>' ).click( function () { $login_btn = $( '<button>登录</button>' ).addClass( 'login' ).click( login );
if ( currentUser === null ) {
login();
} else {
baidu.frontia.logOutCurrentAccount();
currentUser = null;
//$save_btn.detach();
$share_btn.detach();
$login_btn.text( '登录' );
}
} ).appendTo( $panel );
$save_btn = $( '<button>保存到云盘</button>' ).click( function () {
var data = window.km.exportData( 'json' );
save( data, 'apps/kityminder/mymind.km' );
} );
$share_btn = $( '<button>分享脑图</button>' ).click( function () {
if ( $share_btn.attr( 'disabled' ) ) {
}
var data = window.km.exportData( 'json' );
$share_btn.attr( 'disabled', 'disabled' ).text( '正在分享...' );
var share_id = uuid();
var shareUrl = baseUrl + 'index.html?share_id=' + share_id;
share( data, share_id, function ( success ) {
if ( success ) {
var $popup = $( '<div></div>' ).addClass( 'popup' ).appendTo( 'body' );
$popup.css( {
'position': 'absolute',
'right': 10,
'top': $share_btn.offset().top + $share_btn.height() + 10,
'width': 250,
'padding': 10,
'background': 'white',
'border-radius': '5px',
'box-shadow': '1px 2px 4px rgba(0, 0, 0, .3)'
} );
$popup.append( '<p style="margin: 5px 0; font-size: 12px;">分享成功,请复制URL:</p>' );
var $input = $( '<input type="text" style="width: 250px;" value="' + shareUrl + '"></input>' ).appendTo( $popup ); $user_btn = $( '<button><span class="text"></span></button>' ).addClass( 'user-file' );
$input[0].select();
$popup.mousedown( function ( e ) { $user_menu = $.kmuidropmenu( {
e.stopPropagation(); data: [ {
} ); label: '新建脑图',
$( 'body' ).on( 'mousedown', function ( e ) { click: newFile
$popup.fadeOut( 'fast', function () { }, {
$popup.remove(); label: '到网盘管理文件...',
} ); click: function () {
$share_btn.removeAttr( 'disabled' ).text( '分享脑图' ); window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' );
$( 'body' ).off( 'mousedown', arguments.callee );
} );
} }
} ); }, {
divider: true
} ]
} ).addClass( 'user-file-menu' ).appendTo( 'body' ).kmui();
$user_menu.attachTo( $user_btn );
$save_btn = $( '<button>保存</button>' ).click( saveThisFile ).addClass( 'baidu-cloud' );
} ); $share_btn = $( '<button>分享</button>' ).click( shareThisFile ).addClass( 'share' );
baidu.frontia.init( 'wiE55BGOG8BkGnpPs6UNtPbb' ); var AK, thisMapFilename, currentUser, share_id = uuid(),
var currentUser = baidu.frontia.getCurrentAccount(); isShareLink;
if ( currentUser ) {
setLogined( currentUser ); AK = 'wiE55BGOG8BkGnpPs6UNtPbb';
}
baidu.frontia.init( AK );
baidu.frontia.social.setLoginCallback( { baidu.frontia.social.setLoginCallback( {
success: setLogined, success: setCurrentUser,
error: function ( error ) { error: function ( error ) {
console.log( error ); console.log( error );
} }
...@@ -98,31 +97,179 @@ $( function () { ...@@ -98,31 +97,179 @@ $( function () {
baidu.frontia.social.login( options ); baidu.frontia.social.login( options );
} }
function setLogined( user ) { function setCurrentUser( user ) {
currentUser = user; currentUser = user;
$login_btn.text( '注销 ' + user.getName() ); $user_btn.text( user.getName() + ' 的脑图' );
//$save_btn.appendTo( $panel ); $user_btn.appendTo( $panel );
$save_btn.appendTo( $panel );
$share_btn.appendTo( $panel ); $share_btn.appendTo( $panel );
$login_btn.detach();
loadRecent();
loadAvator();
window.location.hash = '';
}
function loadAvator() {
currentUser.getDetailInfo( {
success: function ( user ) {
var $img = $( '<img />' ).attr( {
'src': user.extra.tinyurl,
'width': 16,
'height': 16
} );
$img.prependTo( $user_btn );
}
} );
}
function loadRecent() {
var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载最近脑图...' );
sto.listFile( 'apps/kityminder/', {
by: 'time',
success: function ( result ) {
if ( result.list.length ) {
if ( !isShareLink ) {
loadPersonal( result.list[ 0 ].path );
} else {
$user_btn.loading( false );
}
addToRecentMenu( result.list );
}
}
} );
}
function addToRecentMenu( list ) {
list.splice(8);
list.forEach( function ( file ) {
$user_menu.appendItem( {
item: {
label: getFileName( file.path ),
value: file.path
},
click: openFile
} );
} );
}
function getFileName( path ) {
var filename = path.substr( path.lastIndexOf( '/' ) + 1 );
return filename.substr( 0, filename.lastIndexOf( '.' ) );
}
function openFile( e ) {
var path = $( this ).data( 'value' );
loadPersonal( path );
}
function loadPersonal( path ) {
var sto = baidu.frontia.personalStorage;
thisMapFilename = path;
$user_btn.loading( '加载“' + getFileName( path ) + '”...' );
sto.getFileUrl( path, {
success: function ( url ) {
$.ajax( {
cache: false,
url: url,
dataType: 'text',
success: function ( result ) {
window.km.importData( result, 'json' );
$user_btn.loading( false ).text( getFileName( path ) );
}
} );
}
} );
}
function getMapFileName() {
return '/apps/kityminder/' + window.km.getMinderTitle() + '.km';
}
function newFile() {
thisMapFilename = null;
window.km.importData( '新建脑图', 'plain' );
$user_btn.text( '<新建脑图>' );
} }
function save( file, filename ) { function saveThisFile() {
var personlStorage = baidu.frontia.personalStorage; var data = window.km.exportData( 'json' );
save( data, thisMapFilename || getMapFileName(), function ( success, info ) {
if ( success ) {
$save_btn.text( '保存成功!' );
setTimeout( function () {
$save_btn.loading( false );
}, 3000 );
if ( !thisMapFilename ) {
thisMapFilename = info.path;
addToRecentMenu( [ info ] );
$user_btn.text( getFileName( thisMapFilename ) );
}
}
console.log( info );
} );
$save_btn.loading( '正在保存...' );
}
function save( file, filename, callback ) {
var sto = baidu.frontia.personalStorage;
var options = { var options = {
ondup: personlStorage.constant.ONDUP_OVERWRITE, ondup: thisMapFilename ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( result ) { success: function ( result ) {
console.log( result ); callback( true, result );
}, },
error: function ( error ) { error: function ( error ) {
console.log( error ); callback( false, error );
} }
}; };
personlStorage.uploadTextFile( file, filename, options ); sto.uploadTextFile( file, filename, options );
} }
function uuid() { function uuid() {
return ( ( +new Date() * 10000 ) + ( Math.random() * 9999 ) ).toString( 36 ); return ( ( +new Date() * 10000 ) + ( Math.random() * 9999 ) ).toString( 36 );
} }
function shareThisFile() {
if ( $share_btn.disabled() ) {
return;
}
var data = window.km.exportData( 'json' );
$share_btn.loading( '正在分享...' );
var shareUrl = baseUrl + 'index.html?share_id=' + share_id;
share( data, share_id, function ( success ) {
if ( success ) {
var $popup = $( '<div></div>' ).addClass( 'popup' ).appendTo( 'body' );
$popup.css( {
'position': 'absolute',
'right': 10,
'top': $share_btn.offset().top + $share_btn.height() + 10,
'width': 250,
'padding': 10,
'background': 'white',
'border-radius': '5px',
'box-shadow': '1px 2px 4px rgba(0, 0, 0, .3)'
} );
$popup.append( '<p style="margin: 5px 0; font-size: 12px;">分享成功,请复制URL:</p>' );
var $input = $( '<input type="text" style="width: 250px;" value="' + shareUrl + '"></input>' ).appendTo( $popup );
$input[ 0 ].select();
$popup.mousedown( function ( e ) {
e.stopPropagation();
} );
$( 'body' ).on( 'mousedown', function ( e ) {
$popup.fadeOut( 'fast', function () {
$popup.remove();
} );
$share_btn.loading( false );
$( 'body' ).off( 'mousedown', arguments.callee );
} );
}
} );
}
function share( text, shareId, callback ) { function share( text, shareId, callback ) {
var data = new baidu.frontia.Data( { var data = new baidu.frontia.Data( {
shareMinder: { shareMinder: {
...@@ -148,14 +295,25 @@ $( function () { ...@@ -148,14 +295,25 @@ $( function () {
var shareId = match[ 1 ]; var shareId = match[ 1 ];
var query = new baidu.frontia.storage.Query(); var query = new baidu.frontia.storage.Query();
query.on( 'shareMinder.id' ).equal( shareId ); query.on( 'shareMinder.id' ).equal( shareId );
$share_btn.loading( '正在加载分享内容...' );
baidu.frontia.storage.findData( query, { baidu.frontia.storage.findData( query, {
success: function ( ret ) { success: function ( ret ) {
window.km.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' ); window.km.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
$share_btn.loading( false );
}, },
error: function ( e ) { error: function ( e ) {
console.log( e ); console.log( e );
} }
} ); } );
isShareLink = true;
} }
loadShare(); loadShare();
currentUser = baidu.frontia.getCurrentAccount();
if ( currentUser ) {
setCurrentUser( currentUser );
} else {
$login_btn.appendTo( $panel );
}
} ); } );
\ No newline at end of file
#social {
position: absolute;
right: 10px;
top: 10px;
line-height: 20px;
text-align: right;
overflow: hidden;
button {
font-family: Arial, "Heiti SC", "Microsoft Yahei";
outline: none;
display: inline-block;
padding: 0 15px;
height: 35px;
font-size: 13px;
line-height: 35px;
text-align: center;
border-radius: 5px;
color: #ffffff;
text-decoration: none;
border: none;
margin-left: 5px;
cursor: pointer;background: #0099f2; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
&:hover {
background: #009fff;
}
&[disabled] {
background: #AAA;
}
&.baidu-cloud {
padding-left: 35px;
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/baiducloud.png);
position: absolute;
left: 7px;
top: 5px;
}
}
&.share {
padding-left: 35px;
position: relative;
&:before {
content: ' ';
display: block;
width: 24px;
height: 24px;
background: url(../themes/default/images/share.png) no-repeat;
position: absolute;
left: 7px;
top: 5px;
}
}
img {
position: relative;
top: 3px;
border-radius: 2px;
margin-right: 7px;
}
&.user-file {
padding-right: 28px;
position: relative;
&:after {
content: ' ';
display: block;
position: absolute;
right: 10px;
top: 15px;
width: 0;
height: 0;
border: solid;
border-width: 4px 5px;
border-color: #FFFFFF transparent transparent transparent;
}
}
}
}
.user-file-menu {
margin-top: 20px;
margin-left: 1px;
}
\ No newline at end of file
Subproject commit a9630e638b29633f62cdc2df239bc702118b231a Subproject commit 48128c2e87fb9c8f2f93e64fc2df3f04ffa0a692
...@@ -95,8 +95,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) { ...@@ -95,8 +95,7 @@ KM.registerToolbarUI( 'fontfamily fontsize', function ( name ) {
temp = options.items[ i ]; temp = options.items[ i ];
tempItems.push( temp ); tempItems.push( temp );
options.itemStyles.push( 'font-size: ' + temp + 'px' ); options.itemStyles.push( 'font-size: ' + temp + 'px; height:' + (temp+2) + 'px; line-height: ' + (temp + 2) + 'px' );
} }
options.value = options.items; options.value = options.items;
......
...@@ -27,6 +27,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", { ...@@ -27,6 +27,9 @@ var Minder = KityMinder.Minder = kity.createClass( "KityMinder", {
this._paper = new kity.Paper(); this._paper = new kity.Paper();
this._paper.getNode().setAttribute( 'contenteditable', true ); this._paper.getNode().setAttribute( 'contenteditable', true );
this._paper.getNode().ondragstart = function(e) {
e.preventDefault();
};
this._addRenderContainer(); this._addRenderContainer();
......
...@@ -12,7 +12,6 @@ kity.extendClass( Minder, { ...@@ -12,7 +12,6 @@ kity.extendClass( Minder, {
rc.addShape( current.getRenderContainer() ); rc.addShape( current.getRenderContainer() );
} ); } );
}, },
handelNodeRemove: function ( node ) { handelNodeRemove: function ( node ) {
var rc = this._rc; var rc = this._rc;
node.traverse( function ( current ) { node.traverse( function ( current ) {
...@@ -29,6 +28,9 @@ kity.extendClass( Minder, { ...@@ -29,6 +28,9 @@ kity.extendClass( Minder, {
} else { } else {
km.renderNode( nodes ); km.renderNode( nodes );
} }
},
getMinderTitle: function() {
return this.getRoot().getText();
} }
} ); } );
\ No newline at end of file
...@@ -67,6 +67,39 @@ kity.extendClass( Minder, function () { ...@@ -67,6 +67,39 @@ kity.extendClass( Minder, function () {
}, },
isSingleSelect: function () { isSingleSelect: function () {
return this._selectedNodes.length == 1; return this._selectedNodes.length == 1;
},
getSelectedAncestors: function() {
var nodes = this.getSelectedNodes().slice( 0 ),
ancestors = [],
judge;
// 根节点不参与计算
var rootIndex = nodes.indexOf( this.getRoot() );
if ( ~rootIndex ) {
nodes.splice( rootIndex, 1 );
}
// 判断 nodes 列表中是否存在 judge 的祖先
function hasAncestor( nodes, judge ) {
for ( var i = nodes.length - 1; i >= 0; --i ) {
if ( nodes[ i ].isAncestorOf( judge ) ) return true;
}
return false;
}
// 按照拓扑排序
nodes.sort( function ( node1, node2 ) {
return node1.getLevel() - node2.getLevel();
} );
// 因为是拓扑有序的,所以只需往上查找
while ( ( judge = nodes.pop() ) ) {
if ( !hasAncestor( nodes, judge ) ) {
ancestors.push( judge );
}
}
return ancestors;
} }
}; };
}() ); }() );
\ No newline at end of file
...@@ -75,36 +75,7 @@ var DragBox = kity.createClass( "DragBox", { ...@@ -75,36 +75,7 @@ var DragBox = kity.createClass( "DragBox", {
// 2. 从后往前枚举排序的结果,如果发现枚举目标之前存在其祖先, // 2. 从后往前枚举排序的结果,如果发现枚举目标之前存在其祖先,
// 则排除枚举目标作为拖放源,否则加入拖放源 // 则排除枚举目标作为拖放源,否则加入拖放源
_calcDragSources: function () { _calcDragSources: function () {
var nodes = this._minder.getSelectedNodes().slice( 0 ), this._dragSources = this._minder.getSelectedAncestors();
ancestors = [],
judge;
// 根节点不参与计算
var rootIndex = nodes.indexOf( this._minder.getRoot() );
if ( ~rootIndex ) {
nodes.splice( rootIndex, 1 );
}
// 判断 nodes 列表中是否存在 judge 的祖先
function hasAncestor( nodes, judge ) {
for ( var i = nodes.length - 1; i >= 0; --i ) {
if ( nodes[ i ].isAncestorOf( judge ) ) return true;
}
return false;
}
// 按照拓扑排序
nodes.sort( function ( node1, node2 ) {
return node1.getLevel() - node2.getLevel();
} );
// 因为是拓扑有序的,所以只需往上查找
while ( ( judge = nodes.pop() ) ) {
if ( !hasAncestor( nodes, judge ) ) {
ancestors.push( judge );
}
}
this._dragSources = ancestors;
}, },
......
...@@ -32,7 +32,9 @@ Minder.Receiver = kity.createClass('Receiver',{ ...@@ -32,7 +32,9 @@ Minder.Receiver = kity.createClass('Receiver',{
var text = this.container.firstChild; var text = this.container.firstChild;
this.range = range; this.range = range;
range.setStart(text || this.container, this.index).collapse(true); range.setStart(text || this.container, this.index).collapse(true);
var me = this;
setTimeout(function(){ setTimeout(function(){
me.container.focus();
range.select() range.select()
}); });
return this; return this;
......
...@@ -29,6 +29,7 @@ var ViewDragger = kity.createClass( "ViewDragger", { ...@@ -29,6 +29,7 @@ var ViewDragger = kity.createClass( "ViewDragger", {
if ( dragger.isEnabled() ) { if ( dragger.isEnabled() ) {
lastPosition = e.getPosition(); lastPosition = e.getPosition();
e.stopPropagation(); e.stopPropagation();
e.originEvent.preventDefault();
} }
// 点击未选中的根节点临时开启 // 点击未选中的根节点临时开启
else if ( e.getTargetNode() == this.getRoot() && else if ( e.getTargetNode() == this.getRoot() &&
......
...@@ -614,9 +614,11 @@ KityMinder.registerModule( "LayoutDefault", function () { ...@@ -614,9 +614,11 @@ KityMinder.registerModule( "LayoutDefault", function () {
Layout.connect = null; Layout.connect = null;
Layout.shicon = null; Layout.shicon = null;
} else { } else {
_buffer[ 0 ].getRenderContainer().remove(); try {
Layout.connect.remove(); _buffer[ 0 ].getRenderContainer().remove();
if ( Layout.shicon ) Layout.shicon.remove(); Layout.connect.remove();
if ( Layout.shicon ) Layout.shicon.remove();
} catch ( error ) {}
} }
_buffer = _buffer.concat( _buffer[ 0 ].getChildren() ); _buffer = _buffer.concat( _buffer[ 0 ].getChildren() );
_buffer.shift(); _buffer.shift();
......
KityMinder.registerModule( "pasteModule", function () {
var km = this;
//getSelectedTopNodes
return {
};
} );
\ No newline at end of file
...@@ -69,7 +69,8 @@ KityMinder.registerModule( 'Zoom', function () { ...@@ -69,7 +69,8 @@ KityMinder.registerModule( 'Zoom', function () {
'ready': function () { 'ready': function () {
this._zoomValue = 1; this._zoomValue = 1;
}, },
'mousewheel': function ( e ) { // disable mouse wheel
'mousewheel_': function ( e ) {
var delta = e.originEvent.wheelDelta; var delta = e.originEvent.wheelDelta;
var me = this; var me = this;
......
/*
http://www.xmind.net/developer/
Parsing XMind file
XMind files are generated in XMind Workbook (.xmind) format, an open format that is based on the principles of OpenDocument. It consists of a ZIP compressed archive containing separate XML documents for content and styles, a .jpg image file for thumbnails, and directories for related attachments.
*/
KityMinder.registerProtocal( 'xmind', {
fileExtension: '.xmind',
} );
\ No newline at end of file
# XMind 文件格式
## 官方说明
官方上对 XMind 文件的介绍是这样的:
> XMind files are generated in XMind Workbook (.xmind) format, an open format that is based on the principles of OpenDocument. It consists of a ZIP compressed archive containing separate XML documents for content and styles, a .jpg image file for thumbnails, and directories for related attachments.
整体来说这是一个 zip 包,里面有两个 XML 文档,一个存放内容,一个存放样式,还有一个 jpg 格式的缩略图。如果有附件,还会有存放附件的目录。
## 解析和生成目标
只解析 KityMinder 支持部分的文件内容;只生成 KityMinder 和 XMind 都支持的文件内容
\ No newline at end of file
//dropmenu 类 //dropmenu 类
KM.ui.define('dropmenu', { KM.ui.define('dropmenu', {
tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' + tmpl: '<ul class="kmui-dropdown-menu" aria-labelledby="dropdownMenu" >' +
this.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%>" data-label="<%= ci.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= ci.label%></a>' +
'</li><%}}%>' +
'<%}%>'+
'</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%>" data-label="<%= ci.label%>">' + '<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>' +
...@@ -16,7 +21,7 @@ KM.ui.define('dropmenu', { ...@@ -16,7 +21,7 @@ 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;
}, },
...@@ -56,9 +61,15 @@ KM.ui.define('dropmenu', { ...@@ -56,9 +61,15 @@ KM.ui.define('dropmenu', {
}) })
}) })
} }
}) });
}, },
_initEvent:function(){
this.root().on('mouseover','li[class="kmui-dropdown-submenu',function(e){
var $submenu = $(this).data('widget');
$submenu.kmui().show($(this),'right','position',5,2)
});
},
disabled: function (cb) { disabled: function (cb) {
$('li[class!=kmui-divider]', this.root()).each(function () { $('li[class!=kmui-divider]', this.root()).each(function () {
var $el = $(this); var $el = $(this);
...@@ -89,12 +100,21 @@ KM.ui.define('dropmenu', { ...@@ -89,12 +100,21 @@ KM.ui.define('dropmenu', {
return currentVal return currentVal
} }
}, },
appendItem: function ( item ) {
var itemTpl = '<%if(item.divider){%><li class="kmui-divider"></li><%}else{%>' +
'<li <%if(item.active||item.disabled){%>class="<%= item.active|| \'\' %> <%=item.disabled||\'\' %>" <%}%> data-value="<%= item.value%>" data-label="<%= item.label%>">' +
'<a href="#" tabindex="-1"><em class="kmui-dropmenu-checkbox"><i class="kmui-icon-ok"></i></em><%= item.label%></a>' +
'</li><%}%>';
var html = $.parseTmpl( itemTpl, item );
var $item = $( html ).click( item.click );
this.root().append( $item );
},
addSubmenu: function (label, menu, index) { addSubmenu: function (label, menu, index) {
index = index || 0; index = index || 0;
var $list = $('li[class!=kmui-divider]', this.root()); var $list = $('li[class!=kmui-divider]', this.root());
var $node = $('<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>').append(menu); var $node = $('<li class="kmui-dropdown-submenu"><a tabindex="-1" href="#">' + label + '</a></li>').append(menu);
$node.data('widget',menu);
if (index >= 0 && index < $list.length) { if (index >= 0 && index < $list.length) {
$node.insertBefore($list[index]); $node.insertBefore($list[index]);
} else if (index < 0) { } else if (index < 0) {
......
//menu 类 //menu 类
KM.ui.define('menu',{ KM.ui.define('menu',{
show : function($obj,dir,fnname,topOffset,leftOffset){ show : function($obj,dir,fnname,topOffset,leftOffset){
fnname = fnname || 'position'; fnname = fnname || 'position';
if(this.trigger('beforeshow') === false){ if(this.trigger('beforeshow') === false){
return; return;
}else{ }else{
this.root().css($.extend({display:'block'},$obj ? { this.root().css($.extend({display:'block'},$obj ? {
top : $obj[fnname]().top + ( dir == 'right' ? 0 : $obj.outerHeight()) - (topOffset || 0), top : $obj[fnname]().top + ( dir == 'right' ? 0 : $obj.outerHeight()) - (topOffset || 0),
left : $obj[fnname]().left + (dir == 'right' ? $obj.outerWidth() : 0) - (leftOffset || 0) left : $obj[fnname]().left + (dir == 'right' ? $obj.outerWidth() : 0) - (leftOffset || 0)
...@@ -31,9 +31,16 @@ KM.ui.define('menu',{ ...@@ -31,9 +31,16 @@ KM.ui.define('menu',{
var me = this; var me = this;
if(!$obj.data('$mergeObj')){ if(!$obj.data('$mergeObj')){
$obj.data('$mergeObj',me.root()); $obj.data('$mergeObj',me.root());
$obj.on('wrapclick',function(evt){ if($obj.kmui()){
me.show() $obj.on('wrapclick',function(evt){
}); me.supper.show.call(me,$obj,'','offset',15)
});
}else{
$obj.on('click',function(evt){
me.supper.show.call(me,$obj,'','offset',15)
})
}
me.register('click',$obj,function(evt){ me.register('click',$obj,function(evt){
me.hide() me.hide()
}); });
......
.kmui-combobox-menu{ .kmui-combobox-menu{
position: absolute; position: absolute;
top: 100%;
left: 2px;
display: none; display: none;
list-style: none; list-style: none;
text-decoration: none; text-decoration: none;
margin: 0; margin: 0;
padding:5px; padding: 5px 0;
background-color: #ffffff; background-color: #ffffff;
font-size: 12px; font-size: 12px;
box-shadow: 2px 2px 5px rgba(0, 0, 0, .5); box-shadow: 2px 5px 15px rgba(0, 0, 0, .5);
border-radius: 3px;
min-width: 160px; min-width: 160px;
_width: 160px; _width: 160px;
-webkit-transform: translateX(2px); -webkit-transform: translateX(2px);
...@@ -18,38 +17,55 @@ ...@@ -18,38 +17,55 @@
.kmui-combobox-menu .kmui-combobox-item { .kmui-combobox-menu .kmui-combobox-item {
display: block; display: block;
border: 1px solid white; padding: 2px 15px 2px 2px;
white-space:nowrap; white-space:nowrap;
} }
.kmui-combobox-menu .kmui-combobox-item:first-child:last-child {
border-radius: 2px;
}
.kmui-combobox-menu .kmui-combobox-item-label { .kmui-combobox-menu .kmui-combobox-item-label {
height: 25px; height: 25px;
line-height: 25px; line-height: 25px;
display: inline-block; display: inline-block;
vertical-align: middle;
_display: inline; _display: inline;
_zoom: 1; _zoom: 1;
margin-left: 10px;
} }
.kmui-combobox-menu .kmui-combobox-item:hover, .kmui-combobox-menu .kmui-combobox-stack-item:hover, .kmui-combobox-menu .kmui-combobox-item-hover { .kmui-combobox-menu .kmui-combobox-item:hover, .kmui-combobox-menu .kmui-combobox-stack-item:hover, .kmui-combobox-menu .kmui-combobox-item-hover {
background-color: #d5e1f2; background: #0099f2; /* Old browsers */
padding: 0; /* IE9 SVG, needs conditional override of 'filter' to 'none' */
border: 1px solid #a3bde3; background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white;
/*border: 1px solid #a3bde3;*/
} }
.kmui-combobox-menu .kmui-combobox-item .kmui-combobox-icon { .kmui-combobox-menu .kmui-combobox-item .kmui-combobox-icon {
display: inline-block; display: inline-block;
*zoom: 1; *zoom: 1;
*display: inline; *display: inline;
width: 24px; width: 30px;
height: 25px; height: 12px;
background: red; line-height: 12px;
vertical-align: bottom; vertical-align: middle;
background: url(../images/ok.gif) no-repeat 1000px 1000px; background: url(../images/check.png) no-repeat 1000px 1000px;
} }
.kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon { .kmui-combobox-menu .kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px; background-position: center 0;
}
.kmui-combobox-menu .kmui-combobox-checked:hover .kmui-combobox-icon {
background-position: center -12px;
} }
...@@ -65,133 +81,13 @@ ...@@ -65,133 +81,13 @@
/* 字体样式校正 */ /* 字体样式校正 */
.kmui-combobox-fontsize .kmui-combobox-item-0.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-fontsize .kmui-combobox-item-1.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-fontsize .kmui-combobox-item-2.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
.kmui-combobox-fontsize .kmui-combobox-item-3.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
/* 24 */
.kmui-combobox-fontsize .kmui-combobox-item-4 .kmui-combobox-item-label {
height: 27px;
line-height: 27px;
}
.kmui-combobox-fontsize .kmui-combobox-item-4.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 5px;
}
/* 32 */
.kmui-combobox-fontsize .kmui-combobox-item-5 .kmui-combobox-item-label {
height: 31px;
line-height: 31px;
}
.kmui-combobox-fontsize .kmui-combobox-item-5.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 4px;
}
/* 48 */
.kmui-combobox-fontsize .kmui-combobox-item-6 .kmui-combobox-item-label {
height: 47px;
line-height: 47px;
}
/*.kmui-combobox-fontsize .kmui-combobox-item-6 .kmui-combobox-icon {*/
/*height: 25px;*/
/*margin-bottom: 11px;*/
/*}*/
/*.kmui-combobox-fontsize .kmui-combobox-item-6.kmui-combobox-checked .kmui-combobox-icon {*/
/*background-position: 10px 7px;*/
/*}*/
/* 段落样式校正 */
/* h1 */
.kmui-combobox-paragraph .kmui-combobox-item-1 .kmui-combobox-item-label {
font-size: 32px;
height: 36px;
line-height: 36px;
}
.kmui-combobox-paragraph .kmui-combobox-item-1 .kmui-combobox-icon {
height: 25px;
margin-bottom: 5px;
}
.kmui-combobox-paragraph .kmui-combobox-item-1.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 7px;
}
/* h2 */
.kmui-combobox-paragraph .kmui-combobox-item-2 .kmui-combobox-item-label {
font-size: 28px;
height: 27px;
line-height: 27px;
}
.kmui-combobox-paragraph .kmui-combobox-item-2 .kmui-combobox-icon {
margin-bottom: 5px;
}
.kmui-combobox-paragraph .kmui-combobox-item-2.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 10px;
}
/* h3 */
.kmui-combobox-paragraph .kmui-combobox-item-3 .kmui-combobox-item-label {
font-size: 24px;
height: 25px;
line-height: 25px;
}
.kmui-combobox-paragraph .kmui-combobox-item-3 .kmui-combobox-icon {
height: 25px;
margin-bottom: 5px;
}
.kmui-combobox-paragraph .kmui-combobox-item-3.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 11px;
}
/* h4 */
.kmui-combobox-paragraph .kmui-combobox-item-4 .kmui-combobox-item-label {
font-size: 18px;
height: 25px;
line-height: 25px;
}
.kmui-combobox-paragraph .kmui-combobox-item-4.kmui-combobox-checked .kmui-combobox-icon {
background-position: 10px 6px;
}
/* h5 */
.kmui-combobox-paragraph .kmui-combobox-item-5 .kmui-combobox-item-label {
font-size: 16px;
}
/* h6 */
.kmui-combobox-paragraph .kmui-combobox-item-6 .kmui-combobox-item-label {
font-size: 12px;
}
.kmui-combobox-menu .kmui-combobox-item-disabled { .kmui-combobox-menu .kmui-combobox-item-disabled {
color: black;
opacity: 0.3; opacity: 0.3;
} }
.kmui-combobox-menu .kmui-combobox-item-disabled:HOVER { .kmui-combobox-menu .kmui-combobox-item-disabled:hover {
border-color: #fff; border-color: #fff;
background-color: #fff; background: #fff;
color: black;
} }
\ No newline at end of file
.kmui-modal { .kmui-modal {
position: fixed; position: fixed;
top: 10px; top: 60px;
right:10px; right:10px;
background-color: #ffffff; background-color: #ffffff;
outline: 0; outline: 0;
......
.kmui-dropdown-menu { .kmui-dropdown-menu {
position: absolute; position: absolute;
top: 100%;
left: 0;
z-index: 1000; z-index: 1000;
display: none; display: none;
float: left;
min-width: 160px; min-width: 160px;
padding:5px; padding: 5px 0;
margin: 2px 0 0; font-size: 12px;
font-size: 14px;
list-style: none; list-style: none;
background-color: #ffffff; background-color: #ffffff;
border: 1px solid #cccccc; border-radius: 3px;
border: 1px solid rgba(0, 0, 0, 0.15); box-shadow: 2px 5px 15px rgba(0, 0, 0, .5);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
background-clip: padding-box; background-clip: padding-box;
font-family: Arial, "Heiti SC", "Microsoft Yahei";
} }
.kmui-dropdown-menu.pull-right { .kmui-dropdown-menu.pull-right {
...@@ -27,17 +20,22 @@ ...@@ -27,17 +20,22 @@
.kmui-dropdown-menu .kmui-divider { .kmui-dropdown-menu .kmui-divider {
height: 1px; height: 1px;
margin: 9px 0; margin: 5px 0;
overflow: hidden; overflow: hidden;
background-color: #e5e5e5; background-color: #e5e5e5;
} }
.kmui-dropdown-menu .kmui-divider:first-child,
.kmui-dropdown-menu .kmui-divider:last-child {
display: none;
}
.kmui-dropdown-menu > li > a { .kmui-dropdown-menu > li > a {
display: block; display: block;
padding: 3px 20px; padding: 2px 15px 2px 30px;
height: 25px;
line-height: 25px;
clear: both; clear: both;
font-weight: normal; font-weight: normal;
line-height: 1.428571429;
color: #333333; color: #333333;
white-space: nowrap; white-space: nowrap;
text-decoration: none; text-decoration: none;
...@@ -45,8 +43,18 @@ ...@@ -45,8 +43,18 @@
.kmui-dropdown-menu > li > a:hover, .kmui-dropdown-menu > li > a:hover,
.kmui-dropdown-menu > li > a:focus { .kmui-dropdown-menu > li > a:focus {
color: #262626; background: #0099f2; /* Old browsers */
background-color: #d5e1f2; /* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);
background: -moz-linear-gradient(top, #0099f2 0%, #4096ee 0%, #0076dd 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#0099f2), color-stop(0%,#4096ee), color-stop(100%,#0076dd)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* IE10+ */
background: linear-gradient(to bottom, #0099f2 0%,#4096ee 0%,#0076dd 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0099f2', endColorstr='#0076dd',GradientType=0 ); /* IE6-8 */
color: white;
} }
.kmui-dropdown-menu > .active > a, .kmui-dropdown-menu > .active > a,
......
...@@ -14,9 +14,9 @@ ...@@ -14,9 +14,9 @@
border-radius: 4px; border-radius: 4px;
box-shadow: 3px 3px 8px rgba(0,0,0, .5); box-shadow: 3px 3px 8px rgba(0,0,0, .5);
} }
.kmui-container .kmui-editor-body{ .kmui-container .kmui-editor-body {
background: rgb(50, 60, 61) url(../images/grid.png) repeat; background: rgb(50, 60, 61) url(../images/grid.png) repeat;
line-height: 0; /*line-height: 0;*/
overflow: hidden; overflow: hidden;
} }
svg { svg {
......
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