Fix preview label issue.

This commit is contained in:
Lars Jung 2015-05-17 16:27:53 +02:00
parent d0f29ec3cf
commit b33599f4f2
2 changed files with 8 additions and 11 deletions

View File

@ -4,8 +4,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
enabled: false,
types: {}
}, allsettings['preview-txt']);
var templateText = '<pre id="pv-txt-text" class="highlighted"/>';
var templateMarkdown = '<div id="pv-txt-text" class="markdown"/>';
var tplText = '<pre id="pv-txt-text" class="highlighted"/>';
var tplMarkdown = '<div id="pv-txt-text" class="markdown"/>';
var spinnerThreshold = 200;
var spinnerTimeoutId;
var currentItems;
@ -76,13 +76,13 @@ modulejs.define('ext/preview-txt', ['_', '$', 'marked', 'prism', 'core/event', '
var $code;
if (type === 'none') {
$text = $(templateMarkdown).text(textContent);
$text = $(tplMarkdown).text(textContent);
} else if (type === 'fixed') {
$text = $(templateText).text(textContent);
$text = $(tplText).text(textContent);
} else if (type === 'markdown') {
$text = $(templateMarkdown).html(marked(textContent));
$text = $(tplMarkdown).html(marked(textContent));
} else {
$text = $(templateText);
$text = $(tplText);
$code = $('<code/>').appendTo($text);
if (textContent.length < 20000) {

View File

@ -4,7 +4,7 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
enabled: true
}, allsettings.preview);
var $window = $(window);
var template =
var tplOverlay =
'<div id="pv-overlay">' +
'<div id="pv-content"/>' +
'<div id="pv-spinner"><img class="back"/><img class="spinner" src="' + resource.image('spinner') + '"/></div>' +
@ -65,11 +65,8 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
function onEnter() {
$('#pv-content').empty();
setLabels([]);
$('#pv-overlay').stop(true, true).fadeIn(200);
$window.on('keydown', onKeydown);
adjustSize();
}
@ -215,7 +212,7 @@ modulejs.define('ext/preview', ['_', '$', 'core/resource', 'core/settings', 'cor
return;
}
$(template).appendTo('body');
$(tplOverlay).appendTo('body');
$('#pv-spinner').hide();
$('#pv-bar-prev, #pv-prev-area').on('click', onPrevious);