[ Index ]

PHP Cross Reference of YOURLS

title

Body

[close]

/js/ -> share.js (source)

   1  $(document).ready(function(){
   2      $('#tweet_body').focus();
   3  
   4      $('#tweet_body').keypress(function(){
   5          setTimeout( function(){update_share()}, 50 ); // we're delaying, otherwise keypress() always triggers too fast before current key press actually inserts a letter?!! Go figure.
   6      });
   7  })
   8  
   9  function update_share() {
  10      var text = encodeURIComponent( $('#tweet_body').val() );
  11      var url = encodeURIComponent( $('#copylink').val() );
  12      var tw = 'https://twitter.com/intent/tweet?text='+text;
  13      var fb = 'https://www.facebook.com/share.php?u='+url ;
  14      $('#share_tw').attr('href', tw);
  15      $('#share_fb').attr('href', fb);
  16  
  17      var charcount = parseInt(280 - $('#tweet_body').val().length);
  18      $('#charcount')
  19          .toggleClass("negative", charcount < 0)
  20          .text( charcount );
  21  }
  22  
  23  function share(dest) {
  24      var url = $('#share_'+dest).attr('href');
  25      switch (dest) {
  26      case 'fb':
  27          //var url = $('#share_fb').attr('href');
  28          window.open( url, 'fb','toolbar=no,width=1000,height=550');
  29          break;
  30      case 'tw':
  31          //var url = $('#share_tw').attr('href');
  32          window.open(url, 'tw','toolbar=no,width=800,height=550');
  33          break;
  34      }
  35      return false;
  36  }
  37  
  38  function init_clipboard() {
  39      var clipboard = new ClipboardJS('#copylink', {
  40          text: function (trigger) {
  41              return $(trigger).val();
  42          }
  43      });
  44  
  45      clipboard.on('success', function () {
  46          $('#copylink').select();
  47          html_pulse('#copybox h2, #copybox h3', 'Copied!');
  48      });
  49  };


Generated: Tue Jan 21 05:10:11 2025 Cross-referenced by PHPXref 0.7.1