From 5c521f7b4e1924e5457ee7407e8c28ca8a1a9484 Mon Sep 17 00:00:00 2001 From: tilutza Date: Fri, 29 Aug 2014 13:07:27 +0300 Subject: [PATCH 1/5] Add URL support for clicking on the image --- js/gamma.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/gamma.js b/js/gamma.js index f399a0b..6a7866e 100644 --- a/js/gamma.js +++ b/js/gamma.js @@ -364,11 +364,11 @@ var Gamma = (function() { } else if( id === undefined ) { - History.pushState( - null, - null, - url('protocol') + '://' + url('hostname') + ((url('port') != 80)?':' + url('port'):'') + url('path') - ); +- History.pushState( +- null, +- null, +- url('protocol') + '://' + url('hostname') + ((url('port') != 80)?':' + url('port'):'') + url('path') +- ); } // adds a new state to the history object From b1edcf0348fa616d538d1e6d79e3032f927599d8 Mon Sep 17 00:00:00 2001 From: tilutza Date: Fri, 29 Aug 2014 13:08:56 +0300 Subject: [PATCH 2/5] Add support for the image click URL --- js/gamma.js | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/js/gamma.js b/js/gamma.js index 6a7866e..c7bdf85 100644 --- a/js/gamma.js +++ b/js/gamma.js @@ -396,11 +396,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
  • element $item.data( { @@ -410,14 +411,29 @@ var Gamma = (function() { maxheight : $picEl.data( 'maxHeight' ) } ); - $( '
    ' ).addClass( 'gamma-description' ).html( description ).insertAfter( $picEl ); - - $( '' ).attr( { - alt : $picEl.data( 'alt' ), - title : $picEl.data( 'title' ), - src : source.src - } ).insertAfter( $picEl ); + var overlay = $(''); + if (url != null) { + overlay.attr("href", url); + } + overlay.addClass('gamma-description').html(description).insertAfter($picEl); + + var img = $('').attr({ + alt: $picEl.data('alt'), + title: $picEl.data('title'), + src: source.src + }); + + if (url != null) { + var anchor = $(''); + img.appendTo(anchor); + anchor.insertAfter($picEl); + } + else + { + img.insertAfter($picEl); + } + $picEl.remove(); } ); @@ -475,7 +491,7 @@ var Gamma = (function() { Gamma.gallery.masonry( { itemSelector : 'li', columnWidth : function( containerWidth ) { - return containerWidth / Gamma.columns; + return containerWidth / Gamma.columns; } } ); @@ -747,7 +763,7 @@ var Gamma = (function() { var id = $item.index(), data = $item.data(), - $img = $item.children( 'img' ); + $img = $item.find( 'img' ); if( anim ) { From 817821a93da6fae2ef9bddff6ecdf494cb20991e Mon Sep 17 00:00:00 2001 From: tilutza Date: Fri, 29 Aug 2014 13:15:32 +0300 Subject: [PATCH 3/5] Add Full Image button --- css/style.css | 9 +++++++++ js/gamma.js | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/css/style.css b/css/style.css index b1c8ba0..a99ee81 100755 --- a/css/style.css +++ b/css/style.css @@ -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'; } diff --git a/js/gamma.js b/js/gamma.js index c7bdf85..23aabda 100644 --- a/js/gamma.js +++ b/js/gamma.js @@ -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. @@ -256,12 +260,17 @@ var Gamma = (function() { if( !Gamma.singleview ) { - $( '
    ' ) + $('
    ') .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(); @@ -1263,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' : @@ -1274,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 ) { @@ -1343,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 ) { From bc4bfac7532eae3d7820977a320ab67ab2f4ec16 Mon Sep 17 00:00:00 2001 From: tilutza Date: Fri, 29 Aug 2014 13:16:22 +0300 Subject: [PATCH 4/5] Put the close gallery button at the right most --- js/gamma.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/gamma.js b/js/gamma.js index 23aabda..6c82454 100644 --- a/js/gamma.js +++ b/js/gamma.js @@ -287,7 +287,7 @@ var Gamma = (function() { if( Gamma.itemsCount > 1 ) { - Gamma.svplay = $( '' ).insertAfter( Gamma.svclose ); + Gamma.svplay = $( '' ).insertBefore( Gamma.svclose ); Gamma.nav = $( '' ).appendTo( Gamma.singleview ); Gamma.svnavnext = Gamma.nav.find( 'span.gamma-next' ); Gamma.svnavprev = Gamma.nav.find( 'span.gamma-prev' ); From a636c817af94b43b52ad682775f777fe64fb2447 Mon Sep 17 00:00:00 2001 From: tilutza Date: Fri, 29 Aug 2014 13:20:16 +0300 Subject: [PATCH 5/5] Delete the copy paste minuses --- js/gamma.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/gamma.js b/js/gamma.js index 6c82454..46a3a35 100644 --- a/js/gamma.js +++ b/js/gamma.js @@ -373,11 +373,11 @@ var Gamma = (function() { } else if( id === undefined ) { -- History.pushState( -- null, -- null, -- url('protocol') + '://' + url('hostname') + ((url('port') != 80)?':' + url('port'):'') + url('path') -- ); + History.pushState( + null, + null, + url('protocol') + '://' + url('hostname') + ((url('port') != 80)?':' + url('port'):'') + url('path') + ); } // adds a new state to the history object