Commit 9e0d0b69 authored by techird's avatar techird

save to

parent d66345b0
KM.registerUI('saveto', function( name ) { KM.registerUI( 'saveto', function ( name ) {
var me = this, var me = this,
label = me.getLang('tooltips.' + name), label = me.getLang( 'tooltips.' + name ),
options = { options = {
label: label, label: label,
title: label, title: label,
...@@ -14,32 +14,38 @@ KM.registerUI('saveto', function( name ) { ...@@ -14,32 +14,38 @@ KM.registerUI('saveto', function( name ) {
$combox = null, $combox = null,
comboboxWidget = null; comboboxWidget = null;
var downloadLink = document.createElement( 'a' );
utils.each(KityMinder.getAllRegisteredProtocals(),function(k){ utils.each( KityMinder.getAllRegisteredProtocals(), function ( k ) {
var p = KityMinder.findProtocal( k );
options.value.push(k); var text = p.fileDescription + '(' + p.fileExtension + ')';
options.items.push(k); options.value.push( k );
options.autowidthitem.push($.wordCountAdaptive( k ) ); options.items.push( text );
}); options.autowidthitem.push( $.wordCountAdaptive( text ), true );
} );
//实例化 //实例化
$combox = $.kmuibuttoncombobox(options).css('zIndex',me.getOptions('zIndex') + 1); $combox = $.kmuibuttoncombobox( options ).css( 'zIndex', me.getOptions( 'zIndex' ) + 1 );
comboboxWidget = $combox.kmui(); comboboxWidget = $combox.kmui();
comboboxWidget.on('comboboxselect', function( evt, res ){ comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
alert(me.exportData(res.value)); var data = me.exportData( res.value );
}).on("beforeshow", function(){ var p = KityMinder.findProtocal( res.value );
if( $combox.parent().length === 0 ) { var a = downloadLink;
$combox.appendTo( me.$container.find('.kmui-dialog-container') ); a.setAttribute( 'download', 'MyMind' + p.fileExtension );
a.setAttribute( 'href', 'data:text/plain; utf-8,' + encodeURI( data ) );
a.dispatchEvent( new MouseEvent( 'click' ) );
} ).on( "beforeshow", function () {
if ( $combox.parent().length === 0 ) {
$combox.appendTo( me.$container.find( '.kmui-dialog-container' ) );
} }
}).on('aftercomboboxselect',function(){ } ).on( 'aftercomboboxselect', function () {
this.setLabelWithDefaultValue() this.setLabelWithDefaultValue();
}); } );
return comboboxWidget.button().addClass('kmui-combobox');
}); return comboboxWidget.button().addClass( 'kmui-combobox' );
} );
\ No newline at end of file
...@@ -6,6 +6,8 @@ KityMinder.registerProtocal( 'json', function () { ...@@ -6,6 +6,8 @@ KityMinder.registerProtocal( 'json', function () {
return value; return value;
} }
return { return {
fileDescription: 'KityMinder',
fileExtension: '.km',
encode: function ( json ) { encode: function ( json ) {
return JSON.stringify( json, filter ); return JSON.stringify( json, filter );
}, },
......
...@@ -85,6 +85,8 @@ KityMinder.registerProtocal( "plain", function () { ...@@ -85,6 +85,8 @@ KityMinder.registerProtocal( "plain", function () {
return !!lastResult; return !!lastResult;
} }
return { return {
fileDescription: '大纲文本',
fileExtension: '.txt',
encode: function ( json ) { encode: function ( json ) {
return encode( json, 0 ); return encode( json, 0 );
}, },
......
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