+
@@ -614,6 +614,7 @@ function log(o) {
60% Complete
+
diff --git a/public/js/app/note.js b/public/js/app/note.js
index a64f77a0..fddffdf7 100644
--- a/public/js/app/note.js
+++ b/public/js/app/note.js
@@ -2319,8 +2319,14 @@ Note.initContextmenu = function() {
var menuItem = new gui.MenuItem({
label: menu.label,
click: function(e) {
- var note = Note.getNote($(self.target).attr('noteId'));
- clickBac && clickBac(note);
+ if (Note.inBatch) {
+ var noteIds = Note.getBatchNoteIds();
+ }
+ else {
+ var noteIds = [$(self.target).attr('noteId')];
+ }
+ // var note = Note.getNote();
+ clickBac && clickBac(noteIds);
}
});
diff --git a/public/js/common.js b/public/js/common.js
index 3f84b3da..f8aa94c3 100644
--- a/public/js/common.js
+++ b/public/js/common.js
@@ -1568,12 +1568,26 @@ var trimTitle = function(title) {
var Loading = {
$loadingDialog: $('#loadingDialog'),
$progressBar: $('#loadingDialog .progress-bar'),
+ $progressRate: $('#loadingDialog .progress-rate'),
+ $msg: $('#loadingDialogBodyMsg'),
// option {hasProgress: true, onClose: function}
inited: false,
+ setMsg: function (msg) {
+ this.$msg.html(msg);
+ },
+ setProgressRate: function (msg) {
+ this.$progressRate.html(msg);
+ },
show: function(msg, option) {
option = option || {};
msg || (msg = getMsg("loading..."));
- $('#loadingDialogBodyMsg').html(msg);
+ this.$msg.html(msg);
+ if (option.isLarge) {
+ this.$loadingDialog.find('.modal-dialog').addClass('modal-large');
+ }
+ else {
+ this.$loadingDialog.find('.modal-dialog').addClass('modal-large');
+ }
this.$loadingDialog.modal({backdrop: 'static', keyboard: true});
if (option.hasProgress) {
this.$loadingDialog.addClass('has-progress');
diff --git a/public/plugins/export_html/plugin.js b/public/plugins/export_html/plugin.js
index a9081f74..bbaed344 100644
--- a/public/plugins/export_html/plugin.js
+++ b/public/plugins/export_html/plugin.js
@@ -11,17 +11,23 @@ define(function() {
langs: {
'en-us': {
'export': 'Export HTML',
+ 'Exporting': 'Exporting',
+ 'Exporting: ': 'Exporting: ',
'exportSuccess': 'HTML saved successful!',
'exportFailure': 'HTML saved failure!',
'notExists': 'Please sync your note to ther server firslty.'
},
'zh-cn': {
'export': '导出HTML',
+ 'Exporting': '正在导出',
+ 'Exporting: ': '正在导出: ',
'exportSuccess': 'HTML导出成功!',
'exportFailure': 'HTML导出失败!'
},
'zh-hk': {
'export': '導出HTML',
+ 'Exporting': '正在導出',
+ 'Exporting: ': '正在導出: ',
'exportSuccess': 'HTML導出成功!',
'exportFailure': 'HTML導出失敗!'
}
@@ -125,7 +131,7 @@ define(function() {
},
// 得到存放images, js, css的路径
- getFilesPath: function(basePath, nameNotExt, n, cb) {
+ getAssetsPath: function(basePath, nameNotExt, n, cb) {
var me = this;
var absPath = basePath + '/' + nameNotExt + '_files';
if (n > 1) {
@@ -136,7 +142,7 @@ define(function() {
cb(absPath);
}
else {
- me.getFilesPath(basePath, nameNotExt, n+1, cb);
+ me.getAssetsPath(basePath, nameNotExt, n+1, cb);
}
});
},
@@ -148,8 +154,6 @@ define(function() {
pathInfo.nameNotExt = pathInfo.nameNotExtRaw + '-' + n;
}
var absPath = pathInfo.getFullPath();
- // 总是覆盖
- return cb(absPath);
// Api.nodeFs.existsSync(absPath) 总是返回false, 不知道什么原因
// 在控制台上是可以的
@@ -163,36 +167,105 @@ define(function() {
});
},
- exportHTML: function(note) {
+ loadingIsClosed: false,
+
+ exportHTML: function (noteIds) {
+ var me = this;
+ if (!noteIds || noteIds.length == 0) {
+ return;
+ }
+ // showSaveDialog 不支持property选择文件夹
+ Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
+ {
+ defaultPath: Api.gui.app.getPath('userDesktop') + '/',
+ properties: ['openDirectory']
+ },
+ function(targetPath) {
+ if(!targetPath) {
+ return;
+ }
+
+ me.loadingIsClosed = false;
+ Api.loading.show(Api.getMsg('plugin.export_html.Exporting'),
+ {
+ hasProgress: true,
+ isLarge: true,
+ onClose: function () {
+ me.loadingIsClosed = true;
+ setTimeout(function() {
+ Api.loading.hide();
+ });
+ }});
+ Api.loading.setProgress(1);
+
+ var i = 0;
+ var total = noteIds.length;
+
+ async.eachSeries(noteIds, function(noteId, cb) {
+ if (me.loadingIsClosed) {
+ cb();
+ return;
+ }
+
+ // setTimeout(function () {
+
+ i++;
+ Api.loading.setProgress(100 * i / total);
+ Api.noteService.getNote(noteId, function(note) {
+ me._exportHTML(note, targetPath, function() {
+ cb();
+ }, i, total);
+ });
+
+ // }, i * 1000);
+
+ }, function () {
+ Api.loading.hide();
+ Notify.show({title: 'Info', body: getMsg('plugin.export_html.exportSuccess')});
+ });
+ });
+ },
+
+ _exportHTML: function(note, path, callback, i, total) {
var me = this;
if(!note) {
return;
}
+ if (me.loadingIsClosed) {
+ callback();
+ return;
+ }
+
+ setTimeout(function () {
+ Api.loading.setMsg(Api.getMsg('plugin.export_html.Exporting: ') + (note.Title || getMsg('Untitled')));
+ Api.loading.setProgressRate(i + '/' + total);
+ }, 100);
+
var name = note.Title ? note.Title + '.html' : getMsg('Untitled') + '.html';
name = me.fixFilename(name);
- Api.gui.dialog.showSaveDialog(Api.gui.getCurrentWindow(), {title: name, defaultPath: name}, function(targetPath) {
- if(targetPath) {
- // 将路径和名字区分开
- var pathInfo = Api.commonService.splitFile(targetPath);
- pathInfo.nameNotExt = me.fixFilename(pathInfo.nameNotExt); // 重新修正一次
- var nameNotExt = pathInfo.nameNotExt;
- pathInfo.nameNotExtRaw = pathInfo.nameNotExt;
- // 得到可用文件的绝对路径
- me.getHtmlFilePath(pathInfo, 1, function(absHtmlFilePath) {
- me.getFilesPath(pathInfo.path, pathInfo.nameNotExt, 1, function(absFilesPath) {
- // alert(absHtmlFilePath + ' --- ' + absFilesPath);
- var html = me.render(note);
- // 写图片
- me.writeFiles(absFilesPath, html, function(html) {
- // 把文件写到
- Api.commonService.writeFile(absHtmlFilePath, html);
- Notify.show({title: 'Info', body: getMsg('plugin.export_html.exportSuccess')});
- });
- });
+ var targetPath = path + '/' + name;
+
+ // 将路径和名字区分开
+ var pathInfo = Api.commonService.splitFile(targetPath);
+ pathInfo.nameNotExt = me.fixFilename(pathInfo.nameNotExt); // 重新修正一次
+ var nameNotExt = pathInfo.nameNotExt;
+ pathInfo.nameNotExtRaw = pathInfo.nameNotExt;
+
+ // 得到可用文件的绝对路径
+ me.getHtmlFilePath(pathInfo, 1, function(absHtmlFilePath) {
+ // 得到存放assets的目录
+ me.getAssetsPath(pathInfo.path, pathInfo.nameNotExt, 1, function(absFilesPath) {
+ // alert(absHtmlFilePath + ' --- ' + absFilesPath);
+ var html = me.render(note);
+ // 写图片
+ me.writeFiles(absFilesPath, html, function(html) {
+ // 把html文件写到
+ Api.commonService.writeFile(absHtmlFilePath, html);
+ callback();
});
- }
+ });
});
},
@@ -207,8 +280,8 @@ define(function() {
return true;
},
click: (function() {
- return function(note) {
- me.exportHTML(note);
+ return function(noteIds) {
+ me.exportHTML(noteIds);
}
})()
};
diff --git a/public/plugins/export_pdf/plugin.js b/public/plugins/export_pdf/plugin.js
index eb70b9d0..2de5a663 100644
--- a/public/plugins/export_pdf/plugin.js
+++ b/public/plugins/export_pdf/plugin.js
@@ -117,18 +117,26 @@ define(function() {
var menu = {
label: Api.getMsg('plugin.export_pdf.export'),
enabled: function(noteIds) {
+ if(UserInfo.IsLocal) {
+ return false;
+ }
if (noteIds && noteIds.length == 1) {
return true;
}
return false;
},
click: (function() {
- return function(note) {
+ return function(noteIds) {
if (UserInfo.IsLocal) {
Notify.show({type: 'warning', title: 'Warning', body: getMsg('plugin.export_pdf.localUser')});
return;
}
- me.exportPDF(note);
+ if (!noteIds || noteIds.length > 1) {
+ return;
+ }
+ Api.noteService.getNote(noteIds[0], function(note) {
+ me.exportPDF(note);
+ });
}
})()
};
diff --git a/public/themes/basic.less b/public/themes/basic.less
index e7cd7b6e..887c8f20 100644
--- a/public/themes/basic.less
+++ b/public/themes/basic.less
@@ -1861,19 +1861,32 @@ img::selection {
left: 50%;
margin-left: -100px;
}
+ .modal-dialog.modal-large {
+ width: 300px !important;
+ }
.modal-body {
text-align: center;
border-radius: 5px;
}
#loadingDialogBodyMsg {
- font-size: 16px;
+ font-size: 14px;
+ margin-top: 10px;
+ height: 20px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
}
-
.progress {
margin: 0;
margin-top: 20px;
height: 1px;
display: none;
+ overflow: visible;
+ }
+
+ .progress-rate {
+ clear: both;
+ font-size: 12px;
}
&.has-progress {
diff --git a/public/themes/default.css b/public/themes/default.css
index 49986a27..5461a2a2 100644
--- a/public/themes/default.css
+++ b/public/themes/default.css
@@ -1638,18 +1638,31 @@ img::selection {
left: 50%;
margin-left: -100px;
}
+#loadingDialog .modal-dialog.modal-large {
+ width: 300px !important;
+}
#loadingDialog .modal-body {
text-align: center;
border-radius: 5px;
}
#loadingDialog #loadingDialogBodyMsg {
- font-size: 16px;
+ font-size: 14px;
+ margin-top: 10px;
+ height: 20px;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+ overflow: hidden;
}
#loadingDialog .progress {
margin: 0;
margin-top: 20px;
height: 1px;
display: none;
+ overflow: visible;
+}
+#loadingDialog .progress-rate {
+ clear: both;
+ font-size: 12px;
}
#loadingDialog.has-progress .progress {
display: block;