Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,15 @@ button.gamma-btn-close:before {
content: '\2715';
}

button.gamma-btn-view {
width: 130px;
display: none;
}

button.gamma-btn-view:before {
content: 'Full image';
}

button.gamma-btn-ssplay:before {
content: '\25b6';
}
Expand Down
81 changes: 67 additions & 14 deletions js/gamma.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ var Gamma = (function() {
overlayAnimated : true,
// if true, the navigate next function is called when the image (singleview) is clicked
nextOnClickImage : true,
// if true, then view the big image on click
viewBigOnClickImage: false,
// if true, then view the Full Image button
viewFullImageButton: false,
// circular navigation
circular : true,
// transition settings for the image in the single view.
Expand Down Expand Up @@ -256,12 +260,17 @@ var Gamma = (function() {

if( !Gamma.singleview ) {

$( '<div class="gamma-single-view"><div class="gamma-options gamma-options-single"><div class="gamma-buttons"><button class="gamma-btn-close"></button></div></div></div>' )
$('<div class="gamma-single-view"><div class="gamma-options gamma-options-single"><div class="gamma-buttons"><button class="gamma-btn-view"></button><button class="gamma-btn-close"></button></div></div></div>')
.appendTo( Gamma.container );

Gamma.singleview = Gamma.container.children( 'div.gamma-single-view' );
Gamma.svclose = Gamma.singleview.find( 'button.gamma-btn-close' );
Gamma.svclose = Gamma.singleview.find('button.gamma-btn-close');

if (Gamma.settings.viewFullImageButton) {
Gamma.fullImageButton = Gamma.singleview.find('button.gamma-btn-view');
Gamma.fullImageButton.css({ display: "block" });
}

_initEvents( 'singleview' );

_createSingleViewNavigation();
Expand All @@ -278,7 +287,7 @@ var Gamma = (function() {

if( Gamma.itemsCount > 1 ) {

Gamma.svplay = $( '<button class="gamma-btn-ssplay"></button>' ).insertAfter( Gamma.svclose );
Gamma.svplay = $( '<button class="gamma-btn-ssplay"></button>' ).insertBefore( Gamma.svclose );
Gamma.nav = $( '<nav class="gamma-nav"><span class="gamma-prev"></span><span class="gamma-next"></span></nav>' ).appendTo( Gamma.singleview );
Gamma.svnavnext = Gamma.nav.find( 'span.gamma-next' );
Gamma.svnavprev = Gamma.nav.find( 'span.gamma-prev' );
Expand Down Expand Up @@ -396,11 +405,12 @@ var Gamma = (function() {
// replace each div element with an image element with the right source
$items.each( function() {

var $item = $( this ),
var $item = $(this),
$picEl = $item.children(),
sources = _getImgSources( $picEl ),
source = _chooseImgSource( sources, $item.outerWidth( true ) ),
description = $picEl.data( 'description' );
description = $picEl.data( 'description' ),
url = $picEl.data("url");

// data is saved in the <li> element
$item.data( {
Expand All @@ -410,14 +420,29 @@ var Gamma = (function() {
maxheight : $picEl.data( 'maxHeight' )
} );

$( '<div/>' ).addClass( 'gamma-description' ).html( description ).insertAfter( $picEl );

$( '<img/>' ).attr( {
alt : $picEl.data( 'alt' ),
title : $picEl.data( 'title' ),
src : source.src
} ).insertAfter( $picEl );
var overlay = $('<a />');
if (url != null) {
overlay.attr("href", url);
}
overlay.addClass('gamma-description').html(description).insertAfter($picEl);

var img = $('<img/>').attr({
alt: $picEl.data('alt'),
title: $picEl.data('title'),
src: source.src
});

if (url != null) {
var anchor = $('<a href="' + url + '" />');
img.appendTo(anchor);
anchor.insertAfter($picEl);
}
else
{
img.insertAfter($picEl);
}


$picEl.remove();

} );
Expand Down Expand Up @@ -475,7 +500,7 @@ var Gamma = (function() {
Gamma.gallery.masonry( {
itemSelector : 'li',
columnWidth : function( containerWidth ) {
return containerWidth / Gamma.columns;
return containerWidth / Gamma.columns;
}
} );

Expand Down Expand Up @@ -747,7 +772,7 @@ var Gamma = (function() {

var id = $item.index(),
data = $item.data(),
$img = $item.children( 'img' );
$img = $item.find( 'img' );

if( anim ) {

Expand Down Expand Up @@ -1247,6 +1272,13 @@ var Gamma = (function() {
Gamma.gallery.on( 'click.gamma', 'li', _singleview );
Gamma.svclose.on( 'click.gamma', _closesingleview );

if (Gamma.fullImageButton) {
Gamma.fullImageButton.on('click.gamma', function () {
var imageAddress = _getHighQualityImage($(Gamma.items[Gamma.current]).data().source).src || e.currentTarget.src;
window.location = imageAddress;
});
}

break;

case 'singleviewnavigation' :
Expand All @@ -1258,6 +1290,16 @@ var Gamma = (function() {

Gamma.singleview.on( 'click.gamma', 'img', function() { _onnavigate( 'next' ); } );

} else {

if (Gamma.settings.viewBigOnClickImage) {
Gamma.singleview.on('click.gamma', 'img', function (e) {
var imageAddress = _getHighQualityImage($(e.currentTarget).data().source).src || e.currentTarget.src;

window.location = imageAddress;
});
}

}

if ( Gamma.settings.keyboard ) {
Expand Down Expand Up @@ -1327,6 +1369,17 @@ var Gamma = (function() {
};

},
//get high resolution image
_getHighQualityImage = function (source) {

var result = source[0];
for (var i = 1 ; i < source.length ; i++) {
if (source[i].width > result.width)
result = source[i];
}
return result;

},
// sets a transition for an element
_setTransition = function( el , property, speed, easing ) {

Expand Down