From 8a4ccd098c21030aaed452e4f57437f823cb75e0 Mon Sep 17 00:00:00 2001 From: Lars Jung Date: Fri, 22 Jul 2016 03:59:50 +0200 Subject: [PATCH] Clean preview code. --- src/_h5ai/public/css/lib/ext/preview-aud.less | 2 +- src/_h5ai/public/css/lib/ext/preview-img.less | 2 +- src/_h5ai/public/css/lib/ext/preview-txt.less | 96 ++--------- src/_h5ai/public/css/lib/ext/preview-vid.less | 4 +- .../public/js/lib/ext/preview/preview-aud.js | 105 ++++-------- .../public/js/lib/ext/preview/preview-img.js | 151 +++++------------- .../public/js/lib/ext/preview/preview-txt.js | 147 ++++++----------- .../public/js/lib/ext/preview/preview-vid.js | 139 +++++----------- .../public/js/lib/ext/preview/preview-x.js | 68 ++++++++ .../public/js/lib/ext/preview/preview.js | 33 ++-- 10 files changed, 266 insertions(+), 481 deletions(-) create mode 100644 src/_h5ai/public/js/lib/ext/preview/preview-x.js diff --git a/src/_h5ai/public/css/lib/ext/preview-aud.less b/src/_h5ai/public/css/lib/ext/preview-aud.less index a74cc5fb..97675df1 100644 --- a/src/_h5ai/public/css/lib/ext/preview-aud.less +++ b/src/_h5ai/public/css/lib/ext/preview-aud.less @@ -1,4 +1,4 @@ -#pv-aud-audio { +#pv-content-aud { .raised; position: absolute; diff --git a/src/_h5ai/public/css/lib/ext/preview-img.less b/src/_h5ai/public/css/lib/ext/preview-img.less index cd2f299f..d672ea39 100644 --- a/src/_h5ai/public/css/lib/ext/preview-img.less +++ b/src/_h5ai/public/css/lib/ext/preview-img.less @@ -1,4 +1,4 @@ -#pv-img-image { +#pv-content-img { .raised; @check-white: #f8f8f8; diff --git a/src/_h5ai/public/css/lib/ext/preview-txt.less b/src/_h5ai/public/css/lib/ext/preview-txt.less index 6799655e..e005db94 100644 --- a/src/_h5ai/public/css/lib/ext/preview-txt.less +++ b/src/_h5ai/public/css/lib/ext/preview-txt.less @@ -1,4 +1,4 @@ -#pv-txt-text { +#pv-content-txt { .raised; max-width: 960px; @@ -8,101 +8,27 @@ padding: 8px; overflow: auto; + a, a:active, a:visited { + color: #2080FF; + text-decoration: none; + cursor: pointer; + + &:hover { + color: #68A9FF; + } + } + &.highlighted { code { line-height: 1.2em; } - - a, a:active, a:visited { - color: #2080FF; - text-decoration: none; - cursor: pointer; - - &:hover { - color: #68A9FF; - } - } - - .token.comment, - .token.prolog, - .token.doctype, - .token.cdata { - color: #aaa; - } - - .token.punctuation { - color: #999; - } - - .namespace { - opacity: .7; - } - - .token.property, - .token.tag, - .token.boolean, - .token.number, - .token.constant, - .token.symbol { - color: #905; - } - - .token.selector, - .token.attr-name, - .token.string, - .token.builtin { - color: #690; - } - - .token.operator, - .token.entity, - .token.url, - .language-css .token.string, - .style .token.string, - .token.variable { - color: #a67f59; - background: hsla(0,0%,100%,.5); - } - - .token.atrule, - .token.attr-value, - .token.keyword { - color: #07a; - } - - .token.function { - color: #DD4A68; - } - - .token.regex, - .token.important { - color: #e90; - } - - .token.important { - font-weight: bold; - } - - .token.entity { - cursor: help; - } } &.markdown { font-size: 1.1em; padding: 8px 24px; - a, a:active, a:visited { - color: #2080FF; - text-decoration: none; - cursor: pointer; - - &:hover { - color: #68A9FF; - } - } - code { color: #008200; } diff --git a/src/_h5ai/public/css/lib/ext/preview-vid.less b/src/_h5ai/public/css/lib/ext/preview-vid.less index 23ee93b0..757dc26d 100644 --- a/src/_h5ai/public/css/lib/ext/preview-vid.less +++ b/src/_h5ai/public/css/lib/ext/preview-vid.less @@ -1,4 +1,4 @@ -#pv-vid-video { +#pv-content-vid { .raised; position: absolute; @@ -7,7 +7,7 @@ max-height: 100%; } -#pv-vid-video:-webkit-full-screen { +#pv-content-vid:-webkit-full-screen { top: auto !important; left: auto !important; } diff --git a/src/_h5ai/public/js/lib/ext/preview/preview-aud.js b/src/_h5ai/public/js/lib/ext/preview/preview-aud.js index 812abf0c..a91662b6 100644 --- a/src/_h5ai/public/js/lib/ext/preview/preview-aud.js +++ b/src/_h5ai/public/js/lib/ext/preview/preview-aud.js @@ -1,104 +1,57 @@ -const {each, includes, compact, dom} = require('../../util'); -const {win} = require('../../globals'); +const {each, dom} = require('../../util'); const event = require('../../core/event'); const format = require('../../core/format'); const allsettings = require('../../core/settings'); const preview = require('./preview'); +const previewX = require('./preview-x'); const settings = Object.assign({ enabled: false, types: [] }, allsettings['preview-aud']); +const tpl = '