diff --git a/dist/main.css b/dist/main.css index 76cb355..2a25d96 100644 Binary files a/dist/main.css and b/dist/main.css differ diff --git a/dist/main.js b/dist/main.js index fe56cbb..458a201 100644 Binary files a/dist/main.js and b/dist/main.js differ diff --git a/dist/view.js b/dist/view.js index d1ace76..70b0ffe 100644 Binary files a/dist/view.js and b/dist/view.js differ diff --git a/src/scripts/_retina.js b/src/scripts/_retina.js deleted file mode 100755 index 9252836..0000000 --- a/src/scripts/_retina.js +++ /dev/null @@ -1,46 +0,0 @@ -/*! jQuery Retina Plugin */ -(function(a) { - a.fn.retina = function(c) { - var d = { - "retina-background": false, - "retina-suffix": "@2x" - }; - if (c) { - a.extend(d, c) - } - var b = function(f, g) { - var e = new Image(); - e.onload = function() { - g(e) - }; - e.src = f - }; - if (window.devicePixelRatio > 1) { - this.each(function() { - var e = a(this); - if (this.tagName.toLowerCase() == "img" && e.attr("src")) { - var g = e.attr("src").replace(/\.(?!.*\.)/, d["retina-suffix"] + "."); - b(g, function(h) { - e.attr("src", h.src); - var i = a("
").append(e.clone()).remove().html(); - if (!(/(width|height)=["']\d+["']/.test(i))) { - e.attr("width", h.width / 2) - } - }) - } - if (d["retina-background"]) { - var f = e.css("background-image"); - if (/^url\(.*\)$/.test(f)) { - var g = f.substring(4, f.length - 1).replace(/\.(?!.*\.)/, d["retina-suffix"] + "."); - b(g, function(h) { - e.css("background-image", "url(" + h.src + ")"); - if (e.css("background-size") == "auto auto") { - e.css("background-size", (h.width / 2) + "px auto") - } - }) - } - } - }) - } - } -})(jQuery); \ No newline at end of file diff --git a/src/scripts/build.js b/src/scripts/build.js index 9c8af63..1494ab2 100644 --- a/src/scripts/build.js +++ b/src/scripts/build.js @@ -63,8 +63,7 @@ build.album = function(data) { var html = '', title = data.title, - longTitle = '', - typeThumb = ''; + longTitle = ''; if (title!==null&&title.length>18) { @@ -73,13 +72,13 @@ build.album = function(data) { } - if (data.thumbs[0].split('.').pop()==='svg') typeThumb = 'nonretina'; + var {path: thumbPath, retina: thumbRetina} = lychee.retinize(data.thumbs[0]); html = `
- thumb - thumb - thumb + thumb + thumb + thumb

${ title }

${ data.sysdate } @@ -117,9 +116,11 @@ build.photo = function(data) { } + var {path: thumbPath, retina: thumbRetina} = lychee.retinize(data.thumbUrl); + html = `
- thumb + thumb

${ title }

` diff --git a/src/scripts/lychee.js b/src/scripts/lychee.js index 0c9a805..840ced6 100644 --- a/src/scripts/lychee.js +++ b/src/scripts/lychee.js @@ -323,6 +323,31 @@ lychee.escapeHTML = function(s) { } +lychee.retinize = function(path = '') { + + var pixelRatio = window.devicePixelRatio, + extention = path.split('.').pop(); + + if ((pixelRatio!==undefined&&pixelRatio>1)&& + (extention!=='svg')) { + + path = path.replace(/\.[^/.]+$/, ''); + path = path + '@2x' + '.' + extention; + + return { + path, + retina: true + }; + + } + + return { + path, + retina: false + }; + +} + lychee.loadDropbox = function(callback) { if (!lychee.dropbox&&lychee.dropboxKey) { diff --git a/src/scripts/search.js b/src/scripts/search.js index cb344d2..1a34f3e 100755 --- a/src/scripts/search.js +++ b/src/scripts/search.js @@ -65,7 +65,6 @@ search.find = function(term) { } else { lychee.content.html(html); lychee.animate('#content', 'contentZoomIn'); - $('img[data-type!="svg"]').retina(); } }, 300); diff --git a/src/scripts/view.js b/src/scripts/view.js index 0d7b72d..0b0c0fa 100644 --- a/src/scripts/view.js +++ b/src/scripts/view.js @@ -63,10 +63,9 @@ view.albums = { lychee.content.html(smartData + albumsData); } - $('img[data-type!="nonretina"]').retina(); - // Restore scroll position - if (view.albums.content.scrollPosition!==null) { + if (view.albums.content.scrollPosition!==null&& + view.albums.content.scrollPosition!==0) { $(document).scrollTop(view.albums.content.scrollPosition); } @@ -159,9 +158,8 @@ view.album = { $.each(album.json.content, function() { photosData += build.photo(this); }); - lychee.content.html(photosData); - $('img[data-type!="svg"]').retina(); + lychee.content.html(photosData); }, diff --git a/src/styles/_content.scss b/src/styles/_content.scss index 6d97316..6878d7b 100644 --- a/src/styles/_content.scss +++ b/src/styles/_content.scss @@ -110,7 +110,7 @@ } // No overlay for empty albums - .album img[data-type^='nonretina'] + .overlay { + .album img[data-retina='false'] + .overlay { background: none; } @@ -149,8 +149,8 @@ filter: drop-shadow(0 1px 3px black(.4)); } - .album img[data-type^='nonretina'] + .overlay h1, - .album img[data-type^='nonretina'] + .overlay a { text-shadow: none; } + .album img[data-retina='false'] + .overlay h1, + .album img[data-retina='false'] + .overlay a { text-shadow: none; } /* Badges ------------------------------------------------*/ .album .badge,