Advertisement
Guest User

Edit link toggler for spacehey.com personal profile pages

a guest
Jan 28th, 2021
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Edit link toggler for spacehey.com personal profile pages
  2. //   ~ Vina
  3. jQuery.extend(
  4.     jQuery.expr[':'], {
  5.         regex: function(a, i, m, r) {
  6.             var r = new RegExp(m[3], 'i');
  7.             return r.test(jQuery(a).text());
  8.         }
  9.     }
  10. );
  11. $(document).ready(function() {
  12.   control = $('<span class="toggler"></span>');
  13.   control.css({position: 'absolute', top: 0, left: 0});
  14.   control.html('&#128065;')
  15.   var visible = true;
  16.   control.click(function() {
  17.     $('.profile-info').toggle();
  18.     $('a:regex("^(edit|edit photo)$")').each(function(i, o) {
  19.       $(o).toggle();
  20.       // manage the brackets around the edit links:
  21.       if (visible) {
  22.         o.previousSibling.data = o.previousSibling.data.slice(0, -1);
  23.         o.nextSibling.data = o.nextSibling.data.slice(1);
  24.         control.html('&mdash;')
  25.       }
  26.       else {
  27.         o.previousSibling.data += "[";
  28.         o.nextSibling.data = "]" + o.nextSibling.data;
  29.         control.html('&#128065;')
  30.       }
  31.     })
  32.  
  33.     visible = !visible;
  34.   })
  35.   $(document.body).append(control)
  36.   control.click();
  37. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement