Preview updates.
This commit is contained in:
parent
11f6b3792d
commit
72c7b32a94
5 changed files with 22 additions and 35 deletions
|
@ -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),
|
||||||
-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-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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
|
||||||
#pv-txt-text {
|
#pv-txt-text {
|
||||||
max-width: 800px;
|
max-width: 960px;
|
||||||
max-height: 100%;
|
|
||||||
height: 100%;
|
|
||||||
text-align: left;
|
text-align: left;
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
|
||||||
|
box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.3);
|
||||||
|
|
||||||
&.highlighted {
|
&.highlighted {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#pv-content {
|
#pv-content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
overflow: hidden;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#pv-spinner {
|
#pv-spinner {
|
||||||
|
|
|
@ -92,32 +92,6 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
loadScript(allsettings.h5aiAbsHref + 'client/js/markdown.js', 'markdown', callback);
|
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) {
|
preloadText = function (absHref, callback) {
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -141,6 +115,17 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
currentIdx = idx,
|
currentIdx = idx,
|
||||||
currentItem = items[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) {
|
onIdxChange = function (rel) {
|
||||||
|
|
||||||
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
currentIdx = (currentIdx + rel + currentItems.length) % currentItems.length;
|
||||||
|
@ -158,8 +143,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
var $text;
|
var $text;
|
||||||
|
|
||||||
if (currentItem.type === 'markdown') {
|
if (currentItem.type === 'markdown') {
|
||||||
|
|
||||||
$text = $(templateMarkdown).text(textContent);
|
$text = $(templateMarkdown).text(textContent);
|
||||||
$text.replaceWith($text);
|
|
||||||
|
|
||||||
loadMarkdown(function (md) {
|
loadMarkdown(function (md) {
|
||||||
|
|
||||||
|
@ -168,8 +153,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$text = $(templateText).text(textContent);
|
$text = $(templateText).text(textContent);
|
||||||
$text.replaceWith($text);
|
|
||||||
|
|
||||||
loadSyntaxhighlighter(function (sh) {
|
loadSyntaxhighlighter(function (sh) {
|
||||||
|
|
||||||
|
@ -187,8 +172,8 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$('#pv-content').empty().append($text).fadeIn(200);
|
$('#pv-content').empty().append($text).fadeIn(200);
|
||||||
|
onAdjustSize();
|
||||||
|
|
||||||
preview.setIndex(currentIdx + 1, currentItems.length);
|
preview.setIndex(currentIdx + 1, currentItems.length);
|
||||||
preview.setLabels([
|
preview.setLabels([
|
||||||
|
@ -202,6 +187,7 @@ modulejs.define('ext/preview-txt', ['_', '$', 'core/settings', 'core/event', 'ex
|
||||||
|
|
||||||
onIdxChange(0);
|
onIdxChange(0);
|
||||||
preview.setOnIndexChange(onIdxChange);
|
preview.setOnIndexChange(onIdxChange);
|
||||||
|
preview.setOnAdjustSize(onAdjustSize);
|
||||||
preview.enter();
|
preview.enter();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -244,7 +244,7 @@ modulejs.define('ext/preview', ['_', '$', 'core/settings', 'core/resource', 'cor
|
||||||
var fsTimer = null;
|
var fsTimer = null;
|
||||||
$('#pv-overlay')
|
$('#pv-overlay')
|
||||||
.on('keydown', onKeydown)
|
.on('keydown', onKeydown)
|
||||||
.on('mousemove', onMouseMove)
|
.on('mousemove click mousedown', onMouseMove)
|
||||||
.on('click mousedown mousemove keydown keypress', function (event) {
|
.on('click mousedown mousemove keydown keypress', function (event) {
|
||||||
|
|
||||||
event.stopImmediatePropagation();
|
event.stopImmediatePropagation();
|
||||||
|
|
Loading…
Add table
Reference in a new issue