From 72a5ffbf855406a8a5d80bf7c979091e29a60f82 Mon Sep 17 00:00:00 2001 From: Fabii547 Date: Tue, 5 Jul 2016 16:48:05 +0200 Subject: [PATCH] Make share buttons extendable --- .../files/js/WoltLab/WCF/Ui/Message/Share.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Share.js b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Share.js index 6e9ef327a3..15e0b2b85c 100644 --- a/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Share.js +++ b/wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Share.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @module WoltLab/WCF/Ui/Message/Share */ -define([], function() { +define(['EventHandler'], function(EventHandler) { "use strict"; /** @@ -37,15 +37,15 @@ define([], function() { }, linkedIn: { link: elBySel('.jsShareLinkedIn', container), - share: (function() { this._share('twitter', 'https://www.linkedin.com/cws/share?url={pageURL}', false); }).bind(this) + share: (function() { this._share('linkedIn', 'https://www.linkedin.com/cws/share?url={pageURL}', false); }).bind(this) }, pinterest: { link: elBySel('.jsSharePinterest', container), - share: (function() { this._share('twitter', 'https://www.pinterest.com/pin/create/link/?url={pageURL}&description={text}', false); }).bind(this) + share: (function() { this._share('pinterest', 'https://www.pinterest.com/pin/create/link/?url={pageURL}&description={text}', false); }).bind(this) }, xing: { link: elBySel('.jsShareXing', container), - share: (function() { this._share('twitter', 'https://www.xing.com/social_plugins/share?url={pageURL}', false); }).bind(this) + share: (function() { this._share('xing', 'https://www.xing.com/social_plugins/share?url={pageURL}', false); }).bind(this) }, whatsApp: { link: elBySel('.jsShareWhatsApp', container), @@ -54,6 +54,18 @@ define([], function() { }).bind(this) } }; + + var title = elBySel('meta[property="og:title"]'); + if (title !== null) this._pageDescription = encodeURIComponent(title.content); + var url = elBySel('meta[property="og:url"]'); + if (url !== null) this._pageUrl = encodeURIComponent(url.content); + + EventHandler.fire('com.woltlab.wcf.message.share', 'shareProvider', { + container: container, + providers: providers, + pageDescription: this._pageDescription, + pageUrl: this._pageUrl + }); for (var provider in providers) { if (providers.hasOwnProperty(provider)) { @@ -62,11 +74,6 @@ define([], function() { } } } - - var title = elBySel('meta[property="og:title"]'); - if (title !== null) this._pageDescription = encodeURIComponent(title.content); - var url = elBySel('meta[property="og:url"]'); - if (url !== null) this._pageUrl = encodeURIComponent(url.content); }, _share: function(objectName, url, appendURL) { -- 2.20.1