integration/js/social.js
changeset 82 e36c35fb4468
parent 50 89e152523cb6
child 86 4857ac3892e3
equal deleted inserted replaced
81:393e595cd1ac 82:e36c35fb4468
     1 IriSP.social = function(sel, url) {
     1 IriSP.social = function(opts) {
     2     
     2     
     3     var sel = sel || $(".Ldt-Social"),
     3     var opts = opts || {};
     4         url = url || document.location.href,
     4     opts.sel = opts.sel || $(".Ldt-Social");
     5         text = sel.find("title").text(),
     5     opts.url = opts.url || document.location.href;
       
     6     
       
     7     if (opts.swf) {
       
     8         ZeroClipboard.setMoviePath(opts.swf);
       
     9     }
       
    10     
       
    11     var text = opts.sel.find("title").text(),
     6         clipId = IriSP.Model.getUID(),
    12         clipId = IriSP.Model.getUID(),
     7         clip;
    13         clip;
     8 
    14 
     9     sel.find(".Ldt-Social-CopyBtn").attr("id", this.clipId);
    15     opts.sel.find(".Ldt-Social-CopyBtn").attr("id", clipId);
    10 
    16 
    11     sel.find(".Ldt-Social-Url").click(function() {
    17     opts.sel.find(".Ldt-Social-Url").click(function() {
    12         var _pop = sel.find(".Ldt-Social-UrlPop");
    18         var _pop = opts.sel.find(".Ldt-Social-UrlPop");
    13         _pop.toggle();
    19         _pop.toggle();
    14         if (_pop.is(":visible")) {
    20         if (_pop.is(":visible")) {
    15             if (typeof clip == "undefined") {
    21             if (typeof clip == "undefined") {
    16                 clip = new ZeroClipboard.Client();
    22                 clip = new ZeroClipboard.Client();
    17                 clip.setHandCursor( true );
    23                 clip.setHandCursor( true );
    21                     _pop.hide();
    27                     _pop.hide();
    22                     clip.hide();
    28                     clip.hide();
    23                 });
    29                 });
    24             }
    30             }
    25             clip.show();
    31             clip.show();
    26             clip.setText( url );
    32             clip.setText( opts.url );
    27             sel.find(".Ldt-Social-Input").val(url).focus();
    33             opts.sel.find(".Ldt-Social-Input").val(opts.url).focus();
    28         } else {
    34         } else {
    29             clip.hide();
    35             clip.hide();
    30         }
    36         }
    31         return false;
    37         return false;
    32     });
    38     });
    33     sel.find(".Ldt-Social-Input").focus(function() {
    39     opts.sel.find(".Ldt-Social-Input").focus(function() {
    34         this.select();
    40         this.select();
    35     });
    41     });
    36     sel.find(".Ldt-Social-Ext").click(function() {
    42     opts.sel.find(".Ldt-Social-Ext").click(function() {
    37         window.open(
    43         window.open(
    38             sel.find(this).attr("href"),
    44             opts.sel.find(this).attr("href"),
    39             "_blank",
    45             "_blank",
    40             "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
    46             "height=300,width=450,left=100,top=100,toolbar=0,menubar=0,status=0,location=0");
    41         return false;
    47         return false;
    42     });
    48     });
    43     
    49     
    44     sel.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + $.param({ u: url, t: text }));
    50     opts.sel.find(".Ldt-Social-Fb").attr("href", "http://www.facebook.com/share.php?" + $.param({ u: opts.url, t: text }));
    45     sel.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + $.param({ url: url, text: text }));
    51     opts.sel.find(".Ldt-Social-Twitter").attr("href", "https://twitter.com/intent/tweet?" + $.param({ url: opts.url, text: text }));
    46     sel.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + $.param({ url: url, title: text }));
    52     opts.sel.find(".Ldt-Social-Gplus").attr("href", "https://plus.google.com/share?" + $.param({ url: opts.url, title: text }));
    47     sel.find(".Ldt-Social-Mail").attr("href", "mailto:?" + $.param({ subject: text, body: text + ": " + url }));
    53     opts.sel.find(".Ldt-Social-Mail").attr("href", "mailto:?" + $.param({ subject: text, body: text + ": " + opts.url }));
    48 }
    54 }
    49 
    55 
    50 /* END social.js */
    56 /* END social.js */