Preview updates.

This commit is contained in:
Lars Jung 2013-08-21 23:00:33 +02:00
parent 11f6b3792d
commit 72c7b32a94
5 changed files with 22 additions and 35 deletions

View file

@ -12,5 +12,7 @@
-webkit-linear-gradient(45deg, @check-black 25%, transparent 25%, transparent 75%, @check-black 75%, @check-black),
-webkit-linear-gradient(45deg, @check-black 25%, transparent 25%, transparent 75%, @check-black 75%, @check-black);
background-size: 60px 60px;
background-position: 0 0, 30px 30px
background-position: 0 0, 30px 30px;
box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.3);
}

View file

@ -1,14 +1,14 @@
#pv-txt-text {
max-width: 800px;
max-height: 100%;
height: 100%;
max-width: 960px;
text-align: left;
background-color: #fff;
margin: 0 auto;
padding: 8px;
overflow: auto;
box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.3);
&.highlighted {
word-break: break-all;

View file

@ -20,7 +20,6 @@
#pv-content {
position: absolute;
overflow: hidden;
}
#pv-spinner {

View file

@ -92,32 +92,6 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
loadScript(allsettings.h5aiAbsHref + 'client/js/markdown.js', 'markdown', callback);
},
adjustSize = function () {
var $window = $(window),
$container = $('#pv-txt-content'),
$spinner = $('#pv-txt-spinner'),
$spinnerimg = $spinner.find('img').width(100).height(100),
margin = 20,
barheight = 31;
$container.css({
height: $window.height() - 2 * margin - barheight - 32,
top: margin
});
$spinner.css({
width: $window.width() - 2 * margin,
height: $window.height() - 2 * margin - barheight,
left: margin,
top: margin
});
$spinnerimg.css({
margin: '' + (($spinner.height() - $spinnerimg.height()) / 2) + 'px ' + (($spinner.width() - $spinnerimg.height()) / 2) + 'px'
});
},
preloadText = function (absHref, callback) {
$.ajax({
@ -141,6 +115,17 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
currentIdx = idx,
currentItem = items[idx],
onAdjustSize = function () {
var $content = $('#pv-content'),
$text = $('#pv-txt-text');
if ($text.length) {
$text.height($content.height() - 16);
}
},
onIdxChange = function (rel) {
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
@ -158,8 +143,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
var $text;
if (currentItem.type === 'markdown') {
$text = $(templateMarkdown).text(textContent);
$text.replaceWith($text);
loadMarkdown(function (md) {
@ -168,8 +153,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
}
});
} else {
$text = $(templateText).text(textContent);
$text.replaceWith($text);
loadSyntaxhighlighter(function (sh) {
@ -187,8 +172,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
}
});
}
$('#pv-content').empty().append($text).fadeIn(200);
onAdjustSize();
preview.setIndex(currentIdx + 1, currentItems.length);
preview.setLabels([
@ -202,6 +187,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
onIdxChange(0);
preview.setOnIndexChange(onIdxChange);
preview.setOnAdjustSize(onAdjustSize);
preview.enter();
},

View file

@ -244,7 +244,7 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
var fsTimer = null;
$('#pv-overlay')
.on('keydown', onKeydown)
.on('mousemove', onMouseMove)
.on('mousemove click mousedown', onMouseMove)
.on('click mousedown mousemove keydown keypress', function (event) {
event.stopImmediatePropagation();