Last active
August 29, 2015 14:03
-
-
Save dhigginbotham/356644fe5230b170cfa2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//- | |
//- Albums, Galleries & Images Mixins | |
//- ----------------------------------- | |
//- | |
//- This is where the mixins for general | |
//- kindreviews images mixins. | |
//- | |
//- placer | |
//- default image not found placeholder | |
//- [size] {String} - size of the placeholder | |
//- [message] {String} - optional custom message | |
mixin placer(size, message) | |
- msg = (typeof message == 'undefined' ? 'No Image' : message) | |
.no-img | |
.no-img.placer(class=size) | |
i.glyphicon.glyphicon-picture | |
| !{msg} | |
//- img | |
//- default image path builder | |
//- [thumb] {Object} - image object provided by model | |
//- [size] {String} - size of the image to present | |
//- [href] {String} - endpoint to image | |
mixin img(thumb, size, href) | |
- thumb = (typeof thumb == 'object' ? thumb : null) | |
if (thumb) | |
if (thumb.relation && thumb.relationid) | |
- url = '/uploads/' + thumb.relation + '/' + thumb.relationid | |
else | |
- url = false | |
if (url) | |
if (href) | |
- href = url + '/' + thumb.filename | |
- ext = thumb.filename.split('.').pop(); | |
- file = thumb.filename.replace('.' + ext,''); | |
- link = url + '/thumbs/' + file + '_kr_' + size + '.' + ext; | |
if (href) | |
a.thumbnail(href=href): img(src=link, style="overflow: hidden;") | |
else | |
.gallery.gallery-thumb: img(src=link) | |
else | |
+placer(size) | |
//- gallery | |
//- default gallery builder | |
//- [thumbnails] {Array} - collection of image objects | |
//- [social] {Boolean} - toggle for showing social icons | |
//- [thumbsize] {String} - size of the image to present | |
//- [galsize] {String} - size of the main gallery image | |
mixin gallery(thumbnails, social, thumbsize, galsize) | |
- thumbs = (thumbnails.length > 0 ? thumbnails : []); | |
- social = (typeof social == 'undefined' ? true : social); | |
- tsize = (typeof thumbsize == 'undefined' ? 'small' : thumbsize); | |
- gsize = (typeof galsize == 'undefined' ? 'hero' : galsize); | |
.gallery | |
if (social) | |
.gallery.social | |
i.glyphicon.glyphicon-heart | |
| | |
i.glyphicon.glyphicon-star | |
if (thumbs.length > 0) | |
.gallery.img | |
+img(thumbs[0], gsize) | |
.clearfix | |
.gallery.thumbs | |
- ln = (thumbs.length <= 6 ? thumbs.length : 6) | |
- for (var i=0;i<ln;++i) | |
.col-md-2.col-xs-4 | |
+img(thumbs[i], tsize, true) | |
.clearfix | |
.clearfix | |
else | |
.gallery.img | |
+placer(gsize) | |
.clearfix | |
//- thumbnails | |
//- grid driven thumbnails | |
//- [images] {Array} - collection of image objects | |
//- [size] {String} - size of the thumbnail to present | |
//- [cols] {Int} - columns of the grid | |
//- [limit] {Int} - limit of gallery images to display | |
mixin thumbnails(images, size, cols, limit) | |
- imgs = (images.length > 0 ? images : []); | |
- size = (typeof size == 'undefined' ? 'small' : size); | |
- cols = (typeof cols == 'undefined' ? 3 : cols); | |
- limit = (typeof limit == 'undefined' ? limit : imgs.length); | |
- mod = cols + 1; | |
.row | |
if (imgs) | |
- for(var i = 0;i<limit;++i) | |
div(class='col-md-' + cols + ' ' + 'col-xs-' + cols) | |
+img(imgs[i], size, true) | |
if ((i+1)%mod==0) | |
.clearfix | |
else | |
+placer(size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment