diff --git a/bower.json b/bower.json index c23b5ae..ac49b7f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "lightgallery.js", - "version": "1.0.0", + "version": "1.0.2", "description": "Full featured lightbox gallery. Zero dependencies", "main": [ "dist/js/lightgallery.min.js", diff --git a/demo/js/lg-share.js b/demo/js/lg-share.js index 6cf650f..eebf63a 100644 --- a/demo/js/lg-share.js +++ b/demo/js/lg-share.js @@ -1,5 +1,5 @@ /**! - * lg-share.js | 1.0.0 | October 5th 2016 + * lg-share.js | 1.2.0 | January 14th 2018 * http://sachinchoolur.github.io/lg-share.js * Copyright (c) 2016 Sachin N; * @license GPLv3 @@ -45,6 +45,12 @@ pinterestDropdownText: 'Pinterest' }; + function toCamelCase(input) { + return input.toLowerCase().replace(/-(.)/g, function (match, group1) { + return group1.toUpperCase(); + }); + } + var Share = function Share(element) { this.el = element; @@ -85,17 +91,40 @@ utils.on(_this.core.el, 'onAfterSlide.lgtm', function (event) { setTimeout(function () { - document.getElementById('lg-share-facebook').setAttribute('href', 'https://www.facebook.com/sharer/sharer.php?u=' + encodeURIComponent(_this.core.items[event.detail.index].getAttribute('data-facebook-share-url') || window.location.href)); - - document.getElementById('lg-share-twitter').setAttribute('href', 'https://twitter.com/intent/tweet?text=' + _this.core.items[event.detail.index].getAttribute('data-tweet-text') + '&url=' + encodeURIComponent(_this.core.items[event.detail.index].getAttribute('data-twitter-share-url') || window.location.href)); - - document.getElementById('lg-share-googleplus').setAttribute('href', 'https://plus.google.com/share?url=' + encodeURIComponent(_this.core.items[event.detail.index].getAttribute('data-googleplus-share-url') || window.location.href)); - - document.getElementById('lg-share-pinterest').setAttribute('href', 'http://www.pinterest.com/pin/create/button/?url=' + encodeURIComponent(_this.core.items[event.detail.index].getAttribute('data-pinterest-share-url') || window.location.href) + '&media=' + encodeURIComponent(_this.core.items[event.detail.index].getAttribute('href') || _this.core.items[event.detail.index].getAttribute('data-src')) + '&description=' + _this.core.items[event.detail.index].getAttribute('data-pinterest-text')); + if (_this.core.s.facebook) { + document.getElementById('lg-share-facebook').setAttribute('href', 'https://www.facebook.com/sharer/sharer.php?u=' + _this.getSharePropsUrl(event.detail.index, 'data-facebook-share-url')); + } + if (_this.core.s.twitter) { + document.getElementById('lg-share-twitter').setAttribute('href', 'https://twitter.com/intent/tweet?text=' + _this.getShareProps(event.detail.index, 'data-tweet-text') + '&url=' + _this.getSharePropsUrl(event.detail.index, 'data-twitter-share-url')); + } + if (_this.core.s.googlePlus) { + document.getElementById('lg-share-googleplus').setAttribute('href', 'https://plus.google.com/share?url=' + _this.getSharePropsUrl(event.detail.index, 'data-googleplus-share-url')); + } + if (_this.core.s.pinterest) { + document.getElementById('lg-share-pinterest').setAttribute('href', 'http://www.pinterest.com/pin/create/button/?url=' + _this.getSharePropsUrl(event.detail.index, 'data-pinterest-share-url') + '&media=' + encodeURIComponent(_this.getShareProps(event.detail.index, 'href') || _this.getShareProps(event.detail.index, 'data-src')) + '&description=' + _this.getShareProps(event.detail.index, 'data-pinterest-text')); + } }, 100); }); }; + Share.prototype.getSharePropsUrl = function (index, prop) { + var shareProp = this.getShareProps(index, prop); + if (!shareProp) { + shareProp = window.location.href; + } + return encodeURIComponent(shareProp); + }; + + Share.prototype.getShareProps = function (index, prop) { + var shareProp = ''; + if (this.core.s.dynamic) { + shareProp = this.core.items[index][toCamelCase(prop.replace('data-', ''))]; + } else if (this.core.items[index].getAttribute(prop)) { + shareProp = this.core.items[index].getAttribute(prop); + } + return shareProp; + }; + Share.prototype.destroy = function () {}; window.lgModules.share = Share; diff --git a/demo/js/lg-share.min.js b/demo/js/lg-share.min.js index a010f46..53e4672 100644 --- a/demo/js/lg-share.min.js +++ b/demo/js/lg-share.min.js @@ -1,7 +1,7 @@ /**! - * lg-share.js | 1.0.0 | October 5th 2016 + * lg-share.js | 1.2.0 | January 14th 2018 * http://sachinchoolur.github.io/lg-share.js * Copyright (c) 2016 Sachin N; * @license GPLv3 */ -!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.LgShare=e()}}(function(){var e,t,o;return function e(t,o,r){function n(s,l){if(!o[s]){if(!t[s]){var a="function"==typeof require&&require;if(!l&&a)return a(s,!0);if(i)return i(s,!0);var d=new Error("Cannot find module '"+s+"'");throw d.code="MODULE_NOT_FOUND",d}var c=o[s]={exports:{}};t[s][0].call(c.exports,function(e){var o=t[s][1][e];return n(o?o:e)},c,c.exports,e,t,o,r)}return o[s].exports}for(var i="function"==typeof require&&require,s=0;s",this.core.outer.querySelector(".lg-toolbar").insertAdjacentHTML("beforeend",t),this.core.outer.querySelector(".lg").insertAdjacentHTML("beforeend",'
'),utils.on(document.getElementById("lg-share"),"click.lg",function(){utils.hasClass(e.core.outer,"lg-dropdown-active")?utils.removeClass(e.core.outer,"lg-dropdown-active"):utils.addClass(e.core.outer,"lg-dropdown-active")}),utils.on(document.getElementById("lg-dropdown-overlay"),"click.lg",function(){utils.removeClass(e.core.outer,"lg-dropdown-active")}),utils.on(e.core.el,"onAfterSlide.lgtm",function(t){setTimeout(function(){document.getElementById("lg-share-facebook").setAttribute("href","https://www.facebook.com/sharer/sharer.php?u="+encodeURIComponent(e.core.items[t.detail.index].getAttribute("data-facebook-share-url")||window.location.href)),document.getElementById("lg-share-twitter").setAttribute("href","https://twitter.com/intent/tweet?text="+e.core.items[t.detail.index].getAttribute("data-tweet-text")+"&url="+encodeURIComponent(e.core.items[t.detail.index].getAttribute("data-twitter-share-url")||window.location.href)),document.getElementById("lg-share-googleplus").setAttribute("href","https://plus.google.com/share?url="+encodeURIComponent(e.core.items[t.detail.index].getAttribute("data-googleplus-share-url")||window.location.href)),document.getElementById("lg-share-pinterest").setAttribute("href","http://www.pinterest.com/pin/create/button/?url="+encodeURIComponent(e.core.items[t.detail.index].getAttribute("data-pinterest-share-url")||window.location.href)+"&media="+encodeURIComponent(e.core.items[t.detail.index].getAttribute("href")||e.core.items[t.detail.index].getAttribute("data-src"))+"&description="+e.core.items[t.detail.index].getAttribute("data-pinterest-text"))},100)})},o.prototype.destroy=function(){},window.lgModules.share=o})},{}]},{},[1])(1)}); \ No newline at end of file +!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.LgShare=e()}}(function(){var e,t,o;return function e(t,o,r){function n(i,a){if(!o[i]){if(!t[i]){var l="function"==typeof require&&require;if(!a&&l)return l(i,!0);if(s)return s(i,!0);var c=new Error("Cannot find module '"+i+"'");throw c.code="MODULE_NOT_FOUND",c}var d=o[i]={exports:{}};t[i][0].call(d.exports,function(e){var o=t[i][1][e];return n(o?o:e)},d,d.exports,e,t,o,r)}return o[i].exports}for(var s="function"==typeof require&&require,i=0;i",this.core.outer.querySelector(".lg-toolbar").insertAdjacentHTML("beforeend",t),this.core.outer.querySelector(".lg").insertAdjacentHTML("beforeend",'
'),utils.on(document.getElementById("lg-share"),"click.lg",function(){utils.hasClass(e.core.outer,"lg-dropdown-active")?utils.removeClass(e.core.outer,"lg-dropdown-active"):utils.addClass(e.core.outer,"lg-dropdown-active")}),utils.on(document.getElementById("lg-dropdown-overlay"),"click.lg",function(){utils.removeClass(e.core.outer,"lg-dropdown-active")}),utils.on(e.core.el,"onAfterSlide.lgtm",function(t){setTimeout(function(){e.core.s.facebook&&document.getElementById("lg-share-facebook").setAttribute("href","https://www.facebook.com/sharer/sharer.php?u="+e.getSharePropsUrl(t.detail.index,"data-facebook-share-url")),e.core.s.twitter&&document.getElementById("lg-share-twitter").setAttribute("href","https://twitter.com/intent/tweet?text="+e.getShareProps(t.detail.index,"data-tweet-text")+"&url="+e.getSharePropsUrl(t.detail.index,"data-twitter-share-url")),e.core.s.googlePlus&&document.getElementById("lg-share-googleplus").setAttribute("href","https://plus.google.com/share?url="+e.getSharePropsUrl(t.detail.index,"data-googleplus-share-url")),e.core.s.pinterest&&document.getElementById("lg-share-pinterest").setAttribute("href","http://www.pinterest.com/pin/create/button/?url="+e.getSharePropsUrl(t.detail.index,"data-pinterest-share-url")+"&media="+encodeURIComponent(e.getShareProps(t.detail.index,"href")||e.getShareProps(t.detail.index,"data-src"))+"&description="+e.getShareProps(t.detail.index,"data-pinterest-text"))},100)})},r.prototype.getSharePropsUrl=function(e,t){var o=this.getShareProps(e,t);return o||(o=window.location.href),encodeURIComponent(o)},r.prototype.getShareProps=function(t,o){var r="";return this.core.s.dynamic?r=this.core.items[t][e(o.replace("data-",""))]:this.core.items[t].getAttribute(o)&&(r=this.core.items[t].getAttribute(o)),r},r.prototype.destroy=function(){},window.lgModules.share=r})},{}]},{},[1])(1)}); \ No newline at end of file diff --git a/dist/js/lightgallery.js b/dist/js/lightgallery.js index f748960..ae1cdf3 100644 --- a/dist/js/lightgallery.js +++ b/dist/js/lightgallery.js @@ -1,5 +1,5 @@ /**! - * lightgallery.js | 1.0.1 | December 22nd 2016 + * lightgallery.js | 1.0.2 | January 14th 2018 * http://sachinchoolur.github.io/lightgallery.js/ * Copyright (c) 2016 Sachin N; * @license GPLv3 diff --git a/dist/js/lightgallery.min.js b/dist/js/lightgallery.min.js index 4fd68df..89d4800 100644 --- a/dist/js/lightgallery.min.js +++ b/dist/js/lightgallery.min.js @@ -1,5 +1,5 @@ /**! - * lightgallery.js | 1.0.1 | December 22nd 2016 + * lightgallery.js | 1.0.2 | January 14th 2018 * http://sachinchoolur.github.io/lightgallery.js/ * Copyright (c) 2016 Sachin N; * @license GPLv3 diff --git a/package.json b/package.json index b3d1776..ebb559b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "lightgallery.js", - "version": "1.0.1", + "version": "1.0.2", "description": "Full featured lightbox gallery. Zero dependencies", "keywords": [ "gallery",