Commit 8b8b65c9 authored by techird's avatar techird

fix download bug in chrome 35.0.1916.114

parent 60272950
......@@ -35,6 +35,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
var a = document.createElement( 'a' );
a.setAttribute( 'download', filename );
a.setAttribute( 'href', url );
document.body.appendChild(a);
var evt;
try {
evt = new MouseEvent( 'click' );
......@@ -43,6 +44,7 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
evt.initEvent( 'click', true, true );
}
a.dispatchEvent( evt );
document.body.removeChild(a);
}
var ie_ver = function () {
......@@ -63,14 +65,14 @@ KM.registerToolbarUI( 'saveto', function ( name ) {
iframe.contentDocument.writeln( d );
iframe.contentDocument.execCommand( 'saveas', '', filename );
};
comboboxWidget.on( 'comboboxselect', function ( evt, res ) {
var data = me.exportData( res.value );
var p = KityMinder.findProtocal( res.value );
var filename = me.getMinderTitle() + p.fileExtension;
if ( typeof ( data ) == 'string' ) {
var url = 'data:text/plain; utf-8,' + encodeURIComponent( data );
var url = 'data:' + (p.mineType || 'text/plain') + '; utf-8,' + encodeURIComponent( data );
if ( ie_ver() > 0 ) {
//console.log( p.fileExtension );
if ( p.fileExtension === '.km' ) {
doSave( 'application/x-javascript', data, me.getMinderTitle() );
} else if ( p.fileExtension === '.svg' ) {
......
......@@ -8,6 +8,7 @@ KityMinder.registerProtocal( 'json', function () {
return {
fileDescription: 'KityMinder',
fileExtension: '.km',
mineType: 'application/json',
encode: function ( json ) {
return JSON.stringify( json, filter );
},
......
......@@ -87,6 +87,7 @@ KityMinder.registerProtocal( "plain", function () {
return {
fileDescription: '大纲文本',
fileExtension: '.txt',
mineType: 'text/plain',
encode: function ( json ) {
return encode( json, 0 );
},
......
......@@ -72,7 +72,7 @@ KityMinder.registerProtocal( "png", function () {
function generateDataUrl( canvas ) {
var url = canvas.toDataURL( 'png' );
return url.replace( 'image/png', 'image/octet-stream' );
return url;
}
loadImage( url, function () {
var svgImage = this;
......
......@@ -2,6 +2,7 @@ KityMinder.registerProtocal( "svg", function () {
return {
fileDescription: 'SVG 矢量图(暂不支持IE)',
fileExtension: '.svg',
mineType: 'image/svg+xml',
encode: function ( json, km ) {
// svg 含有   符号导出报错 Entity 'nbsp' not defined
return km.getPaper().container.innerHTML.replace( / /g, ' ' );
......
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