tabalinas / jssocials

Social Network Sharing jQuery Plugin
http://js-socials.com
MIT License
464 stars 104 forks source link

Title variable is missing from urls #215

Open skyiron opened 6 years ago

skyiron commented 6 years ago

Thank you for jssocials! It is really useful.

I've found that the title variable is missing from shareurls that are supposed to have it. I checked the code, but couldn't find it defined anywhere.

I've been able to add the title variable with the following changes (4th line from top and 3rd line from the bottom).

_initDefaults: function() {
            this.url = window.location.href;
            this.text = $.trim($("meta[name=description]").attr("content") || $("title").text());
        this.title =$("title").text();          
        },

_initShares: function() {
            this.shares = $.map(this.shares, $.proxy(function(shareConfig) {
                if(typeof shareConfig === "string") {
                    shareConfig = { share: shareConfig };
                }

                var share = (shareConfig.share && shares[shareConfig.share]);

                if(!share && !shareConfig.renderer) {
                    throw Error("Share '" + shareConfig.share + "' is not found");
                }

                return $.extend({ url: this.url, text: this.text, title: this.title }, share, shareConfig); 
            }, this));
        },

I've made a pull request for the above changes https://github.com/tabalinas/jssocials/pull/214