Commit 5902d9a8 authored by campaign's avatar campaign

Merge remote-tracking branch 'origin/dev' into dev

parents bb5dd29a a4301c1c
......@@ -5,9 +5,9 @@
<script src="../dist/jquery-2.1.0.min.js"></script>
<script src="../kity/dist/kitygraph.all.js"></script>
<script src="../configure.js"></script>
<script src="../dist/dev.php"></script>
<script src="../dist/dev.js"></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">
<style>
.km_receiver{
width:0;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -74,9 +74,9 @@ $dependency = Array(
$content = "";
header('Content-Type: text/javascript; charset=utf-8');
foreach ($dependency as $index => $dep) {
if( $_GET['join'] != null) {
header('Content-Type: text/javascript; charset=utf-8');
if( $_GET['join'] != null || $argv[1] == 'join') {
echo file_get_contents("../$dep")."\n\n";
} else {
echo "document.write('<script charset=utf-8 src=\"../$dep\"></script>');";
......
......@@ -2,12 +2,13 @@
<html>
<head>
<meta charset="utf-8">
<script src="jquery-2.1.0.min.js" charset="utf-8"></script>
<script src="baidu-frontia-js-full-1.0.0.js" charset="utf-8"></script>
<script src="social.js" charset="utf-8"></script>
<script src="../kity/dist/kitygraph.all.js"></script>
<script src="../configure.js"></script>
<script src="../dist/dev.php"></script>
<script src="../kity/dist/kitygraph.all.js" charset="utf-8"></script>
<script src="../configure.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>
<link href="../themes/default/css/import.css" type="text/css" rel="stylesheet">
<link rel="stylesheet" href="social.css">
......
#social{position:absolute;right:10px;top:10px;line-height:20px;text-align:right;overflow:hidden}#social button,#social .kmui-btn{outline:none;display:inline-block;padding:0 15px;height:35px;font-size:13px;line-height:35px;text-align:center;border-radius:5px;color:#fff;text-decoration:none;border:none;margin-left:5px;cursor:pointer;background:#0099f2;background:url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzAwOTlmMiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjNDA5NmVlIiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzAwNzZkZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);background:-moz-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0, #0099f2), color-stop(0, #4096ee), color-stop(100%, #0076dd));background:-webkit-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-o-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:-ms-linear-gradient(top, #0099f2 0, #4096ee 0, #0076dd 100%);background:linear-gradient(to bottom, #0099f2 0, #4096ee 0, #0076dd 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0099f2', endColorstr='#0076dd', GradientType=0);}#social button:hover,#social .kmui-btn:hover{background:#009fff}
#social button[disabled],#social .kmui-btn[disabled]{background:#aaa}
#social button.baidu-cloud,#social .kmui-btn.baidu-cloud{padding-left:35px;position:relative}#social button.baidu-cloud:before,#social .kmui-btn.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,#social .kmui-btn.share{padding-left:35px;position:relative}#social button.share:before,#social .kmui-btn.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,#social .kmui-btn img{position:relative;top:3px;border-radius:2px;margin-right:7px}
#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 () {
var $panel = $( '#social' );
var $login_btn, $save_btn, $share_btn, $user_btn, $user_menu;
......@@ -12,68 +49,33 @@ $( function () {
}
} )();
$login_btn = $( '<button>登录</button>' ).addClass('login').click( login );
$login_btn = $( '<button>登录</button>' ).addClass( 'login' ).click( login );
$user_btn = $( '<button></button>' ).addClass('user-file');
$user_btn = $( '<button><span class="text"></span></button>' ).addClass( 'user-file' );
$user_menu = $.kmuidropmenu( {
data: [ {
label: '新建脑图',
value: 'action_newminder'
click: newFile
}, {
divider: true
label: '到网盘管理文件...',
click: function () {
window.open( 'http://pan.baidu.com/disk/home#dir/path=/apps/kityminder' );
}
}, {
label: '最近脑图',
value: 'action_recent'
divider: true
} ]
} ).appendTo( 'body' ).kmui().attachTo( $user_btn );
} ).addClass( 'user-file-menu' ).appendTo( 'body' ).kmui();
$save_btn = $( '<button>保存</button>' ).click( saveThisFile ).addClass( 'baidu-cloud' );
$user_menu.attachTo( $user_btn );
$share_btn = $( '<button>分享</button>' ).click( function () {
if ( $share_btn.attr( 'disabled' ) ) {
return;
}
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 );
$input[ 0 ].select();
$save_btn = $( '<button>保存</button>' ).click( saveThisFile ).addClass( 'baidu-cloud' );
$popup.mousedown( function ( e ) {
e.stopPropagation();
} );
$( 'body' ).on( 'mousedown', function ( e ) {
$popup.fadeOut( 'fast', function () {
$popup.remove();
} );
$share_btn.removeAttr( 'disabled' ).text( '分享' );
$( 'body' ).off( 'mousedown', arguments.callee );
} );
}
} );
} ).addClass( 'share' );
$share_btn = $( '<button>分享</button>' ).click( shareThisFile ).addClass( 'share' );
var AK, thisMapFilename, currentUser;
var AK, thisMapFilename, currentUser, share_id = uuid(),
isShareLink;
AK = 'wiE55BGOG8BkGnpPs6UNtPbb';
......@@ -85,11 +87,6 @@ $( function () {
}
} );
currentUser = baidu.frontia.getCurrentAccount();
if ( currentUser ) {
setCurrentUser( currentUser );
}
function login() {
var options = {
response_type: 'token',
......@@ -127,19 +124,49 @@ $( function () {
function loadRecent() {
var sto = baidu.frontia.personalStorage;
$user_btn.loading( '加载最近脑图...' );
sto.listFile( 'apps/kityminder/', {
by: 'time',
success: function ( result ) {
if ( result.list.length ) {
loadPersonal( result.list[ 0 ].path );
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( {
......@@ -148,30 +175,46 @@ $( function () {
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 saveThisFile() {
var data = window.km.exportData( 'json' );
save( data, thisMapFilename, function ( success, info ) {
save( data, thisMapFilename || getMapFileName(), function ( success, info ) {
if ( success ) {
$save_btn.text( '保存成功!' );
setTimeout( function () {
$save_btn.removeAttr( 'disabled' ).text( '保存' );
$save_btn.loading( false );
}, 3000 );
if ( !thisMapFilename ) {
thisMapFilename = info.path;
addToRecentMenu( [ info ] );
$user_btn.text( getFileName( thisMapFilename ) );
}
}
console.log( info );
} );
$save_btn.attr( 'disabled', 'disabled' ).text( '正在保存...' );
$save_btn.loading( '正在保存...' );
}
function save( file, filename, callback ) {
var sto = baidu.frontia.personalStorage;
var options = {
ondup: sto.constant.ONDUP_OVERWRITE,
ondup: thisMapFilename ? sto.constant.ONDUP_OVERWRITE : sto.constant.ONDUP_NEWCOPY,
success: function ( result ) {
callback( true, result );
},
......@@ -186,6 +229,47 @@ $( function () {
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 ) {
var data = new baidu.frontia.Data( {
shareMinder: {
......@@ -212,16 +296,24 @@ $( function () {
var query = new baidu.frontia.storage.Query();
query.on( 'shareMinder.id' ).equal( shareId );
$share_btn.attr('disabled', 'disabled').text('正在加载分享内容...');
$share_btn.loading( '正在加载分享内容...' );
baidu.frontia.storage.findData( query, {
success: function ( ret ) {
window.km.importData( ret.result[ 0 ].obj.shareMinder.data, 'json' );
$share_btn.removeAttr('disabled').text('分享');
$share_btn.loading( false );
},
error: function ( e ) {
console.log( e );
}
} );
isShareLink = true;
}
loadShare();
currentUser = baidu.frontia.getCurrentAccount();
if ( currentUser ) {
setCurrentUser( currentUser );
} else {
$login_btn.appendTo( $panel );
}
} );
\ No newline at end of file
......@@ -5,7 +5,8 @@
line-height: 20px;
text-align: right;
overflow: hidden;
button, .kmui-btn {
button {
font-family: Arial, "Heiti SC", "Microsoft Yahei";
outline: none;
display: inline-block;
padding: 0 15px;
......@@ -27,8 +28,7 @@
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 */
&:hover {
background: #009fff;
}
......@@ -72,5 +72,25 @@
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 48128c2e87fb9c8f2f93e64fc2df3f04ffa0a692
Subproject commit 95a7c76b5880e335a09cb5e7504e1edb8776f17d
......@@ -100,6 +100,15 @@ KM.ui.define('dropmenu', {
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) {
index = index || 0;
......
......@@ -14,7 +14,7 @@
border-radius: 4px;
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;
/*line-height: 0;*/
overflow: hidden;
......
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