Make share buttons extendable
authorFabii547 <fabiangossner@gmail.com>
Tue, 5 Jul 2016 14:48:05 +0000 (16:48 +0200)
committerFabii547 <fabiangossner@gmail.com>
Tue, 5 Jul 2016 14:48:05 +0000 (16:48 +0200)
wcfsetup/install/files/js/WoltLab/WCF/Ui/Message/Share.js

index 6e9ef327a378c26749940e9001eca4e0c871a821..15e0b2b85c4c6bf3e6b6a69aa19560d3a2e0561d 100644 (file)
@@ -6,7 +6,7 @@
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @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) {