Skip to content

Commit

Permalink
merge: PR #37 from ginger/gabby-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alycejenni committed Feb 17, 2023
2 parents 98a5c1f + c0522dd commit 7630b6b
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 63 deletions.
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
exclude: /(vendor|dist)/
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
Expand Down Expand Up @@ -25,3 +26,9 @@ repos:
# these can't be pulled directly from the config atm, not sure why
args: ["-i", "--wrap-summaries=88", "--wrap-descriptions=88",
"--pre-summary-newline", "--make-summary-multi-line"]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.4
hooks:
- id: prettier
types_or: [ javascript, vue, less, sass, scss, css ]
args: [ '--single-quote' ]
115 changes: 57 additions & 58 deletions ckanext/gallery/theme/assets/js/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,76 +3,75 @@
*/

ckan.module('gallery', function (jQuery, _) {

var self;

return {
initialize: function () {
self = this
$("a", this.el).each(function(i) {
$(this).data("index", i)
$(this).on('click', jQuery.proxy(self._openLightbox));
});
self = this;
$('a', this.el).each(function (i) {
$(this).data('index', i);
$(this).on('click', jQuery.proxy(self._openLightbox));
});
},
getCurrentImage: function () {
var pos = self.gallery.getIndex();
return self.options.images[pos]
var pos = self.gallery.getIndex();
return self.options.images[pos];
},
_openLightbox: function (e) {
var options = {
index: $(this).data("index"),
// onclose: function () {
// self._hideDownloadTooltip()
// },
onslide: function () {
self._onImageUpdate()
}
}
self.gallery = blueimp.Gallery(self.options.images, options)
e.stopPropagation();
return false;
var options = {
index: $(this).data('index'),
// onclose: function () {
// self._hideDownloadTooltip()
// },
onslide: function () {
self._onImageUpdate();
},
};
self.gallery = blueimp.Gallery(self.options.images, options);
e.stopPropagation();
return false;
},
_onImageUpdate: function(){
var image = self.getCurrentImage()
var $gallery = $('#blueimp-gallery')
// Set image data attribute
$gallery.data('image', image)
_onImageUpdate: function () {
var image = self.getCurrentImage();
var $gallery = $('#blueimp-gallery');
// Set image data attribute
$gallery.data('image', image);

// Update download link
$('#blueimp-gallery a.gallery-control-download').attr('href', image.href);
// $('#blueimp-gallery a.gallery-control-download').on('click', jQuery.proxy(self._downloadImage));
// Update download link
$('#blueimp-gallery a.gallery-control-download').attr('href', image.href);
// $('#blueimp-gallery a.gallery-control-download').on('click', jQuery.proxy(self._downloadImage));

if(image.copyright){
$gallery.find('.copyright').html(image.copyright)
}
// If we have a link to record, update the link and show it
// Otherwise, hide the link
if(image.link){
$gallery.find('.gallery-control-link').attr('href', image.link).show()
}else{
$gallery.find('.gallery-control-link').hide()
}
if (image.copyright) {
$gallery.find('.copyright').html(image.copyright);
}
// If we have a link to record, update the link and show it
// Otherwise, hide the link
if (image.link) {
$gallery.find('.gallery-control-link').attr('href', image.link).show();
} else {
$gallery.find('.gallery-control-link').hide();
}
},
// _downloadImage: function(e){
// self.downloadFile('http://www.nhm.ac.uk/services/media-store/asset/2d63e01b999aaa0581397d9e629e4bc9f30677a7/contents/preview', function(blob) {
// saveAs(blob, "image.png");
// });
// e.stopPropagation();
// return false;
// },
// downloadFile: function(url, success){
// var xhr = new XMLHttpRequest();
// xhr.open('GET', url, true);
// xhr.responseType = "blob";
// xhr.onreadystatechange = function () {
// if (xhr.readyState == 4) {
// if (success) success(xhr.response);
// }
// };
// xhr.send(null);
// },
// _downloadImage: function(e){
// self.downloadFile('http://www.nhm.ac.uk/services/media-store/asset/2d63e01b999aaa0581397d9e629e4bc9f30677a7/contents/preview', function(blob) {
// saveAs(blob, "image.png");
// });
// e.stopPropagation();
// return false;
// },
// downloadFile: function(url, success){
// var xhr = new XMLHttpRequest();
// xhr.open('GET', url, true);
// xhr.responseType = "blob";
// xhr.onreadystatechange = function () {
// if (xhr.readyState == 4) {
// if (success) success(xhr.response);
// }
// };
// xhr.send(null);
// },
options: {
images: []
}
images: [],
},
};
});
5 changes: 1 addition & 4 deletions ckanext/gallery/theme/assets/less/gallery.less
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#blueimp-gallery {

.gallery-control {
position: absolute;
z-index: 700;
Expand All @@ -14,7 +13,7 @@
text-align: center;

&:hover {
text-decoration: none
text-decoration: none;
}

i {
Expand Down Expand Up @@ -50,7 +49,6 @@
color: #ccc;
}
}

}

#gallery .gallery-image {
Expand Down Expand Up @@ -81,7 +79,6 @@
display: inline-block;
text-align: center;
}

}
}

Expand Down
8 changes: 7 additions & 1 deletion docs/_scripts/gen_api_pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
py_files = sorted(Path(root).rglob('*.py'))

for path in py_files:
try:
path.relative_to('ckanext/gallery/migration')
continue
except ValueError:
pass

module_path = path.relative_to(root).with_suffix('')
doc_path = path.relative_to(root).with_suffix('.md')
full_doc_path = Path('API', doc_path)
Expand All @@ -35,7 +41,7 @@

nav[parts] = doc_path.as_posix()

with mkdocs_gen_files.open(full_doc_path, "w") as fd:
with mkdocs_gen_files.open(full_doc_path, 'w') as fd:
ident = '.'.join(parts)
fd.write(f'::: ckanext.{ident}')

Expand Down
2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,5 @@ markdown_extensions:
- admonition
- pymdownx.details
- pymdownx.superfences
- toc:
permalink:

0 comments on commit 7630b6b

Please sign in to comment.