Skip to content

Commit

Permalink
Introduce sharing option for dynamic mode
Browse files Browse the repository at this point in the history
  • Loading branch information
sachinchoolur committed Oct 3, 2017
1 parent d4e342c commit 08e91d3
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 28 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightgallery",
"version": "1.6.1",
"version": "1.6.2",
"description": "A lightweight, customizable, modular, responsive, lightbox gallery plugin for jQuery.",
"main": [
"dist/js/lightgallery.min.js",
Expand Down
2 changes: 1 addition & 1 deletion dist/css/lg-fb-comment-box.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! lightgallery - v1.6.1 - 2017-09-18
/*! lightgallery - v1.6.2 - 2017-10-03
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
.lg-outer.fb-comments .lg-img-wrap, .lg-outer.fb-comments .lg-video-cont {
Expand Down
2 changes: 1 addition & 1 deletion dist/css/lg-transitions.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/css/lightgallery.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 22 additions & 9 deletions dist/js/lightgallery-all.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! lightgallery - v1.6.1 - 2017-09-18
/*! lightgallery - v1.6.2 - 2017-10-03
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
/*! lightgallery - v1.6.1 - 2017-09-18
/*! lightgallery - v1.6.2 - 2017-10-03
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
(function (root, factory) {
Expand Down Expand Up @@ -3222,9 +3222,9 @@

}));

/*! lg-share - v1.0.2 - 2016-11-26
/*! lg-share - v1.1.0 - 2017-10-03
* http://sachinchoolur.github.io/lightGallery
* Copyright (c) 2016 Sachin N; Licensed GPLv3 */
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -3292,19 +3292,32 @@

_this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) {

setTimeout(function() {
$('#lg-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-facebook-share-url') || window.location.href)));
setTimeout(function() {

$('#lg-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(_this.getSahreProps(index, 'facebookShareUrl') || window.location.href)));

$('#lg-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + _this.core.$items.eq(index).attr('data-tweet-text') + '&url=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-twitter-share-url') || window.location.href)));
$('#lg-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + _this.getSahreProps(index, 'tweetText') + '&url=' + (encodeURIComponent(_this.getSahreProps(index, 'twitterShareUrl') || window.location.href)));

$('#lg-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-googleplus-share-url') || window.location.href)));
$('#lg-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(_this.getSahreProps(index, 'googleplusShareUrl') || window.location.href)));

$('#lg-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-pinterest-share-url') || window.location.href)) + '&media=' + encodeURIComponent(_this.core.$items.eq(index).attr('href') || _this.core.$items.eq(index).attr('data-src')) + '&description=' + _this.core.$items.eq(index).attr('data-pinterest-text'));
$('#lg-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(_this.getSahreProps(index, 'pinterestShareUrl') || window.location.href)) + '&media=' + encodeURIComponent(_this.getSahreProps(index, 'src')) + '&description=' + _this.getSahreProps(index, 'pinterestText'));

}, 100);
});
};

Share.prototype.getSahreProps = function(index, prop){
var shareProp = '';
if(this.core.s.dynamic) {
shareProp = this.core.s.dynamicEl[index][prop];
} else {
var _href = this.core.$items.eq(index).attr('href');
var _prop = this.core.$items.eq(index).data(prop);
shareProp = prop === 'src' ? _href || _prop : _prop;
}
return shareProp;
};

Share.prototype.destroy = function() {

};
Expand Down
4 changes: 2 additions & 2 deletions dist/js/lightgallery-all.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/js/lightgallery.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! lightgallery - v1.6.1 - 2017-09-18
/*! lightgallery - v1.6.2 - 2017-10-03
* http://sachinchoolur.github.io/lightGallery/
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */
(function (root, factory) {
Expand Down
2 changes: 1 addition & 1 deletion dist/js/lightgallery.min.js

Large diffs are not rendered by default.

27 changes: 20 additions & 7 deletions modules/lg-share.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! lg-share - v1.0.2 - 2016-11-26
/*! lg-share - v1.1.0 - 2017-10-03
* http://sachinchoolur.github.io/lightGallery
* Copyright (c) 2016 Sachin N; Licensed GPLv3 */
* Copyright (c) 2017 Sachin N; Licensed GPLv3 */

(function (root, factory) {
if (typeof define === 'function' && define.amd) {
Expand Down Expand Up @@ -68,19 +68,32 @@

_this.core.$el.on('onAfterSlide.lg.tm', function(event, prevIndex, index) {

setTimeout(function() {
$('#lg-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-facebook-share-url') || window.location.href)));
setTimeout(function() {

$('#lg-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + _this.core.$items.eq(index).attr('data-tweet-text') + '&url=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-twitter-share-url') || window.location.href)));
$('#lg-share-facebook').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + (encodeURIComponent(_this.getSahreProps(index, 'facebookShareUrl') || window.location.href)));

$('#lg-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-googleplus-share-url') || window.location.href)));
$('#lg-share-twitter').attr('href', 'https://twitter.com/intent/tweet?text=' + _this.getSahreProps(index, 'tweetText') + '&url=' + (encodeURIComponent(_this.getSahreProps(index, 'twitterShareUrl') || window.location.href)));

$('#lg-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(_this.core.$items.eq(index).attr('data-pinterest-share-url') || window.location.href)) + '&media=' + encodeURIComponent(_this.core.$items.eq(index).attr('href') || _this.core.$items.eq(index).attr('data-src')) + '&description=' + _this.core.$items.eq(index).attr('data-pinterest-text'));
$('#lg-share-googleplus').attr('href', 'https://plus.google.com/share?url=' + (encodeURIComponent(_this.getSahreProps(index, 'googleplusShareUrl') || window.location.href)));

$('#lg-share-pinterest').attr('href', 'http://www.pinterest.com/pin/create/button/?url=' + (encodeURIComponent(_this.getSahreProps(index, 'pinterestShareUrl') || window.location.href)) + '&media=' + encodeURIComponent(_this.getSahreProps(index, 'src')) + '&description=' + _this.getSahreProps(index, 'pinterestText'));

}, 100);
});
};

Share.prototype.getSahreProps = function(index, prop){
var shareProp = '';
if(this.core.s.dynamic) {
shareProp = this.core.s.dynamicEl[index][prop];
} else {
var _href = this.core.$items.eq(index).attr('href');
var _prop = this.core.$items.eq(index).data(prop);
shareProp = prop === 'src' ? _href || _prop : _prop;
}
return shareProp;
};

Share.prototype.destroy = function() {

};
Expand Down
6 changes: 3 additions & 3 deletions modules/lg-share.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "lightgallery",
"version": "1.6.1",
"version": "1.6.2",
"description": "A lightweight, customizable, modular, responsive, lightbox gallery plugin for jQuery.",
"keywords": [
"jquery-plugin",
Expand Down

0 comments on commit 08e91d3

Please sign in to comment.