Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/xianmin/hugo-theme-jane.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChen Xianmin <xianmin12@gmail.com>2018-05-02 16:38:43 +0300
committerChen Xianmin <xianmin12@gmail.com>2018-05-02 16:38:43 +0300
commitf4967d2ae78d0aab6f7cab77e92b2ac0f635f74f (patch)
tree4c7190895f6f3dfcd44048424540b1442f0e273d
parent70b77d77cf2f140bd18f42e7809f87dab0e34755 (diff)
fix: Unified code style, remove console.log in load-photoswipe.js
-rw-r--r--layouts/shortcodes/gallery.html62
-rw-r--r--static/js/load-photoswipe.js138
2 files changed, 100 insertions, 100 deletions
diff --git a/layouts/shortcodes/gallery.html b/layouts/shortcodes/gallery.html
index aac2ace..9c11670 100644
--- a/layouts/shortcodes/gallery.html
+++ b/layouts/shortcodes/gallery.html
@@ -7,35 +7,35 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
{{- $.Page.Scratch.Add "figurecount" 1 }}
{{ $baseURL := .Site.BaseURL }}
<div class="gallery caption-position-{{ with .Get "caption-position" | default "bottom" }}{{.}}{{end}} caption-effect-{{ with .Get "caption-effect" | default "slide" }}{{.}}{{end}} hover-effect-{{ with .Get "hover-effect" | default "zoom" }}{{.}}{{end}} {{ if ne (.Get "hover-transition") "none" }}hover-transition{{end}}" itemscope itemtype="http://schema.org/ImageGallery">
- {{- with (.Get "dir") -}}
- <!-- If a directory was specified, generate figures for all of the images in the directory -->
- {{- $files := readDir (print "/static/" .) }}
- {{- range $files -}}
- <!-- skip files that aren't images, or that inlcude the thumb suffix in their name -->
- {{- $thumbext := $.Get "thumb" | default "-thumb" }}
- {{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }}<!-- is the current file a thumbnail image? -->
- {{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? -->
- {{- if and $isimg (not $isthumb) }}
- {{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
- {{- $linkURL := print $baseURL ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
- {{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image -->
- {{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? -->
- {{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->
- <div class="box">
- <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
- <div class="img" style="background-image: url('{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}');" >
- <img itemprop="thumbnail" src="{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery -->
- </div>
- <figcaption>
- <p>{{ $caption }}</p>
- </figcaption>
- <a href="{{ $linkURL }}" itemprop="contentUrl"></a><!-- put <a> last so it is stacked on top -->
- </figure>
- </div>
- {{- end }}
- {{- end }}
- {{- else -}}
- <!-- If no directory was specified, include any figure shortcodes called within the gallery -->
- {{ .Inner }}
- {{- end }}
+ {{- with (.Get "dir") -}}
+ <!-- If a directory was specified, generate figures for all of the images in the directory -->
+ {{- $files := readDir (print "/static/" .) }}
+ {{- range $files -}}
+ <!-- skip files that aren't images, or that inlcude the thumb suffix in their name -->
+ {{- $thumbext := $.Get "thumb" | default "-thumb" }}
+ {{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }}<!-- is the current file a thumbnail image? -->
+ {{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? -->
+ {{- if and $isimg (not $isthumb) }}
+ {{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
+ {{- $linkURL := print $baseURL ($.Get "dir") "/" .Name | absURL }}<!-- absolute URL to hi-res image -->
+ {{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image -->
+ {{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? -->
+ {{- $thumbURL := print $baseURL ($.Get "dir") "/" $thumb | absURL }}<!-- absolute URL to thumbnail image -->
+ <div class="box">
+ <figure itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
+ <div class="img" style="background-image: url('{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}');" >
+ <img itemprop="thumbnail" src="{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery -->
+ </div>
+ <figcaption>
+ <p>{{ $caption }}</p>
+ </figcaption>
+ <a href="{{ $linkURL }}" itemprop="contentUrl"></a><!-- put <a> last so it is stacked on top -->
+ </figure>
+ </div>
+ {{- end }}
+ {{- end }}
+ {{- else -}}
+ <!-- If no directory was specified, include any figure shortcodes called within the gallery -->
+ {{ .Inner }}
+ {{- end }}
</div>
diff --git a/static/js/load-photoswipe.js b/static/js/load-photoswipe.js
index 978c66d..7beb53f 100644
--- a/static/js/load-photoswipe.js
+++ b/static/js/load-photoswipe.js
@@ -5,76 +5,76 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
/* Show an alert if this js file has been loaded twice */
if (window.loadphotoswipejs) {
- window.alert("You've loaded load-photoswipe.js twice. See https://github.com/liwenyip/hugo-easy-gallery/issues/6")
-}
+ window.alert("You've loaded load-photoswipe.js twice. See https://github.com/liwenyip/hugo-easy-gallery/issues/6")
+}
var loadphotoswipejs = 1
/* TODO: Make the share function work */
$( document ).ready(function() {
- /*
- Initialise Photoswipe
- */
- var items = []; // array of slide objects that will be passed to PhotoSwipe()
- // for every figure element on the page:
- $('figure').each( function() {
- if ($(this).attr('class') == 'no-photoswipe') return true; // ignore any figures where class="no-photoswipe"
- // get properties from child a/img/figcaption elements,
- var $figure = $(this),
- $a = $figure.find('a'),
- $img = $figure.find('img'),
- $src = $a.attr('href'),
- $title = $img.attr('alt'),
- $msrc = $img.attr('src');
- // if data-size on <a> tag is set, read it and create an item
- if ($a.data('size')) {
- var $size = $a.data('size').split('x');
- var item = {
- src : $src,
- w : $size[0],
- h : $size[1],
- title : $title,
- msrc : $msrc
- };
- console.log("Using pre-defined dimensions for " + $src);
- // if not, set temp default size then load the image to check actual size
- } else {
- var item = {
- src : $src,
- w : 800, // temp default size
- h : 600, // temp default size
- title : $title,
- msrc : $msrc
- };
- console.log("Using default dimensions for " + $src);
- // load the image to check its dimensions
- // update the item as soon as w and h are known (check every 30ms)
- var img = new Image();
- img.src = $src;
- var wait = setInterval(function() {
- var w = img.naturalWidth,
- h = img.naturalHeight;
- if (w && h) {
- clearInterval(wait);
- item.w = w;
- item.h = h;
- console.log("Got actual dimensions for " + img.src);
- }
- }, 30);
- }
- // Save the index of this image then add it to the array
- var index = items.length;
- items.push(item);
- // Event handler for click on a figure
- $figure.on('click', function(event) {
- event.preventDefault(); // prevent the normal behaviour i.e. load the <a> hyperlink
- // Get the PSWP element and initialise it with the desired options
- var $pswp = $('.pswp')[0];
- var options = {
- index: index,
- bgOpacity: 0.8,
- showHideOpacity: true
- }
- new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options).init();
- });
- });
-}); \ No newline at end of file
+ /*
+ Initialise Photoswipe
+ */
+ var items = []; // array of slide objects that will be passed to PhotoSwipe()
+ // for every figure element on the page:
+ $('figure').each( function() {
+ if ($(this).attr('class') == 'no-photoswipe') return true; // ignore any figures where class="no-photoswipe"
+ // get properties from child a/img/figcaption elements,
+ var $figure = $(this),
+ $a = $figure.find('a'),
+ $img = $figure.find('img'),
+ $src = $a.attr('href'),
+ $title = $img.attr('alt'),
+ $msrc = $img.attr('src');
+ // if data-size on <a> tag is set, read it and create an item
+ if ($a.data('size')) {
+ var $size = $a.data('size').split('x');
+ var item = {
+ src: $src,
+ w: $size[0],
+ h: $size[1],
+ title: $title,
+ msrc: $msrc
+ };
+ // console.log("Using pre-defined dimensions for " + $src);
+ // if not, set temp default size then load the image to check actual size
+ } else {
+ var item = {
+ src: $src,
+ w: 800, // temp default size
+ h: 600, // temp default size
+ title: $title,
+ msrc: $msrc
+ };
+ // console.log("Using default dimensions for " + $src);
+ // load the image to check its dimensions
+ // update the item as soon as w and h are known (check every 30ms)
+ var img = new Image();
+ img.src = $src;
+ var wait = setInterval(function() {
+ var w = img.naturalWidth,
+ h = img.naturalHeight;
+ if (w && h) {
+ clearInterval(wait);
+ item.w = w;
+ item.h = h;
+ // console.log("Got actual dimensions for " + img.src);
+ }
+ }, 30);
+ }
+ // Save the index of this image then add it to the array
+ var index = items.length;
+ items.push(item);
+ // Event handler for click on a figure
+ $figure.on('click', function(event) {
+ event.preventDefault(); // prevent the normal behaviour i.e. load the <a> hyperlink
+ // Get the PSWP element and initialise it with the desired options
+ var $pswp = $('.pswp')[0];
+ var options = {
+ index: index,
+ bgOpacity: 0.8,
+ showHideOpacity: true
+ }
+ new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options).init();
+ });
+ });
+});