|
1 | 1 | /*! |
2 | | - * Social Share Kit v1.0.1 (http://socialsharekit.com) |
| 2 | + * Social Share Kit v1.0.3 (http://socialsharekit.com) |
3 | 3 | * Copyright 2015 Social Share Kit / Kaspars Sprogis. |
4 | 4 | * Licensed under Creative Commons Attribution-NonCommercial 3.0 license: |
5 | 5 | * https://github.com/darklow/social-share-kit/blob/master/LICENSE |
@@ -126,8 +126,8 @@ var SocialShareKit = (function () { |
126 | 126 | var url, dataOpts = getDataOpts(network, el), |
127 | 127 | shareUrl = getShareUrl(network, el, dataOpts), |
128 | 128 | shareUrlEnc = encodeURIComponent(shareUrl), |
129 | | - title = typeof dataOpts['title'] !== 'undefined' ? dataOpts['title'] : document.title, |
130 | | - text = typeof dataOpts['text'] !== 'undefined' ? dataOpts['text'] : getMetaContent('description'), |
| 129 | + title = typeof dataOpts['title'] !== 'undefined' ? dataOpts['title'] : getTitle(network), |
| 130 | + text = typeof dataOpts['text'] !== 'undefined' ? dataOpts['text'] : getText(network), |
131 | 131 | image = dataOpts['image'], via = dataOpts['via']; |
132 | 132 | switch (network) { |
133 | 133 | case 'facebook': |
@@ -176,6 +176,20 @@ var SocialShareKit = (function () { |
176 | 176 | return dataOpts['url'] || window.location.href; |
177 | 177 | } |
178 | 178 |
|
| 179 | + function getTitle(network) { |
| 180 | + var title; |
| 181 | + if (network == 'twitter') |
| 182 | + title = getMetaContent('twitter:title'); |
| 183 | + return title || document.title; |
| 184 | + } |
| 185 | + |
| 186 | + function getText(network) { |
| 187 | + var text; |
| 188 | + if (network == 'twitter') |
| 189 | + text = getMetaContent('twitter:description'); |
| 190 | + return text || getMetaContent('description'); |
| 191 | + } |
| 192 | + |
179 | 193 | function getMetaContent(tagName, attr) { |
180 | 194 | var text, tag = $('meta[' + (attr ? attr : tagName.indexOf('og:') === 0 ? 'property' : 'name') + '="' + tagName + '"]'); |
181 | 195 | if (tag.length) { |
|
0 commit comments