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