Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Edit link toggler for spacehey.com personal profile pages
- // ~ Vina
- jQuery.extend(
- jQuery.expr[':'], {
- regex: function(a, i, m, r) {
- var r = new RegExp(m[3], 'i');
- return r.test(jQuery(a).text());
- }
- }
- );
- $(document).ready(function() {
- control = $('<span class="toggler"></span>');
- control.css({position: 'absolute', top: 0, left: 0});
- control.html('👁')
- var visible = true;
- control.click(function() {
- $('.profile-info').toggle();
- $('a:regex("^(edit|edit photo)$")').each(function(i, o) {
- $(o).toggle();
- // manage the brackets around the edit links:
- if (visible) {
- o.previousSibling.data = o.previousSibling.data.slice(0, -1);
- o.nextSibling.data = o.nextSibling.data.slice(1);
- control.html('—')
- }
- else {
- o.previousSibling.data += "[";
- o.nextSibling.data = "]" + o.nextSibling.data;
- control.html('👁')
- }
- })
- visible = !visible;
- })
- $(document.body).append(control)
- control.click();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement