integration/js/common.js
changeset 104 1b84c7b2aeee
parent 91 a94f5c62e4d7
child 115 e48bb5d43ac2
equal deleted inserted replaced
97:213e81430f7a 104:1b84c7b2aeee
    35 
    35 
    36 window.social = function(opts) {
    36 window.social = function(opts) {
    37     
    37     
    38     var opts = opts || {};
    38     var opts = opts || {};
    39     opts.sel = opts.sel || $(".Ldt-Social");
    39     opts.sel = opts.sel || $(".Ldt-Social");
    40     opts.url = opts.url || document.location.href;
    40     opts.url = opts.url || document.location.href
       
    41     opts.text = opts.text || $("title").text();
       
    42     
       
    43     if (!opts.sel.length) {
       
    44         return;
       
    45     }
       
    46     
       
    47     opts.sel.addClass("Ldt-Social");
    41     
    48     
    42     if (opts.swf) {
    49     if (opts.swf) {
    43         ZeroClipboard.setMoviePath(opts.swf);
    50         ZeroClipboard.setMoviePath(opts.swf);
    44     }
    51     }
    45     
    52     
    46     var text = opts.sel.find("title").text(),
    53     var clipId = "Social-Clip-" + (++uid),
    47         clipId = "Social-Clip-" + (++uid),
    54         clip,
    48         clip;
    55         html = '<div class="Ldt-Social-Url-Container"><a href="#" target="_blank" class="Ldt-Social-Square Ldt-Social-Url" title="'
    49 
    56             + gettext("Share URL")
    50     opts.sel.find(".Ldt-Social-CopyBtn").attr("id", clipId);
    57             + '"></a><span class="Ldt-Social-UrlPop"><input class="Ldt-Social-Input"/><div class="Ldt-Social-CopyBtn" id="'
       
    58             + clipId
       
    59             + '">'
       
    60             + gettext("Copy")
       
    61             + '</div></span></div><a href="http://www.facebook.com/share.php?'
       
    62             + $.param({ u: opts.url, t: opts.text })
       
    63             + '" target="_blank" class="Ldt-Social-Fb Ldt-Social-Ext" title="'
       
    64             + gettext("Share on Facebook")
       
    65             + '"></a><a href="https://twitter.com/intent/tweet?'
       
    66             + $.param({ url: opts.url, text: opts.text })
       
    67             + '" target="_blank" class="Ldt-Social-Twitter Ldt-Social-Ext" title="'
       
    68             + gettext("Share on Twitter")
       
    69             + '"></a><a href="https://plus.google.com/share?'
       
    70             + $.param({ url: opts.url, title: opts.text })
       
    71             + '" target="_blank" class="Ldt-Social-Gplus Ldt-Social-Ext" title="'
       
    72             + gettext("Share on Google+")
       
    73             + '"></a><a href="mailto:?'
       
    74             + $.param({ subject: opts.text, body: opts.text + ": " + opts.url })
       
    75             + '" target="_blank" class="Ldt-Social-Mail" title="'
       
    76             + gettext("Share via E-Mail")
       
    77             + '"></a></div>';
       
    78             
       
    79     opts.sel.html(html);
    51 
    80 
    52     opts.sel.find(".Ldt-Social-Url").click(function() {
    81     opts.sel.find(".Ldt-Social-Url").click(function() {
    53         var _pop = opts.sel.find(".Ldt-Social-UrlPop");
    82         var _pop = opts.sel.find(".Ldt-Social-UrlPop");
    54         _pop.toggle();
    83         _pop.toggle();
    55         if (_pop.is(":visible")) {
    84         if (_pop.is(":visible")) {
    79             opts.sel.find(this).attr("href"),
   108             opts.sel.find(this).attr("href"),
    80             "_blank",
   109             "_blank",
    81             "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
   110             "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
    82         return false;
   111         return false;
    83     });
   112     });
    84     
       
    85     opts.sel.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + $.param({ u: opts.url, t: text }));
       
    86     opts.sel.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + $.param({ url: opts.url, text: text }));
       
    87     opts.sel.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + $.param({ url: opts.url, title: text }));
       
    88     opts.sel.find(".Ldt-Social-Mail").attr("href", "mailto:?" + $.param({ subject: text, body: text + ": " + opts.url }));
       
    89 }
   113 }
    90 }());
   114 }());