Add share button support in message share content dialog
authorMatthias Schmidt <gravatronics@live.com>
Thu, 7 Feb 2019 18:11:52 +0000 (19:11 +0100)
committerMatthias Schmidt <gravatronics@live.com>
Thu, 7 Feb 2019 18:11:52 +0000 (19:11 +0100)
Close #2845

wcfsetup/install/files/js/WCF.Message.js

index cdb140c01d8181de3f3cdac3433f8891f788faa6..4e2a33171c26833059957672e7e01ca85a8925ba 100644 (file)
@@ -2181,10 +2181,19 @@ WCF.Message.Share.Content = Class.extend({
         */
        _dialog: null,
        
+       /**
+        * template containing the social media share buttons
+        * @var string
+        */
+       _shareButtonsTemplate: '',
+       
        /**
         * Initializes the WCF.Message.Share.Content class.
+        * 
+        * @param       {string?}       shareButtonsTemplate
         */
-       init: function() {
+       init: function(shareButtonsTemplate) {
+               this._shareButtonsTemplate = shareButtonsTemplate || '';
                this._cache = { };
                this._dialog = null;
                
@@ -2235,6 +2244,12 @@ WCF.Message.Share.Content = Class.extend({
                        var $section = $('<section class="section"><h2 class="sectionTitle"><label for="__sharePermalinkHTML">' + WCF.Language.get('wcf.message.share.permalink.html') + '</label></h2></section>').appendTo(this._dialog);
                        $('<input type="text" id="__sharePermalinkHTML" class="long" readonly />').attr('value', '<a href="' + $link + '">' + WCF.String.escapeHTML($title) + '</a>').appendTo($section);
                        
+                       // share buttons
+                       if (this._shareButtonsTemplate !== '') {
+                               $section = $('<section class="section"><h2 class="sectionTitle">' + WCF.Language.get('wcf.message.share') + '</h2>'  + this._shareButtonsTemplate + '</section>').appendTo(this._dialog);
+                               elData($section.children('.jsMessageShareButtons')[0], 'url', WCF.String.escapeHTML($link));
+                       }
+                       
                        this._cache[$key] = this._dialog.html();
                        
                        if ($dialogInitialized) {