daily pastebin goal
72%
SHARE
TWEET

форма js

a guest Mar 8th, 2017 6 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var current = null;
  2. function toggleReplyForm(postnum) {
  3.     var defaultPlace = document.getElementsByClassName('postarea')[0];
  4.     var form = document.getElementById('postform');
  5.     var post = document.getElementById('reply'+postnum);   
  6.  
  7.     if(current != post) {
  8.         form.classList.add('opened');
  9.         post.appendChild(form);
  10.         post.scrollIntoView(false);
  11.         current = post;
  12.     } else {
  13.         form.classList.remove('opened');
  14.         defaultPlace.appendChild(form);
  15.         current = null;
  16.     }
  17. }
  18.  
  19. document.addEventListener('DOMContentLoaded', function() { //перекинуть отсюда в DOMContentLoaded в tinyib.js
  20.    
  21.     var refs = document.getElementsByClassName('reflink');
  22.     [].forEach.call(refs, function(reflink, i) {
  23.         if(i != 0) {
  24.             var quoteLink = reflink.querySelectorAll('a')[2];
  25.             quoteLink.addEventListener('click', function(e) {
  26.                 if(/res/.test(location)) {
  27.                     e.preventDefault();
  28.                     toggleReplyForm(this.previousElementSibling.innerHTML);
  29.                 }
  30.             });
  31.         }
  32.     });
  33.  
  34. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top