Advertisement
Guest User

buddypress/bbpress threaded reply focus fix

a guest
Oct 1st, 2012
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. /* Source: wp-includes/js/comment-reply.js
  2. Modifications to deal with reply-specific IDs. */
  3. addReply = {
  4. moveForm : function(commId, parentId, respondId, postId) {
  5. var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-in-reply-to-link'), parent = t.I('inreplyto'), post = t.I('bbp_topic_id');
  6. t.rmTiny();
  7.  
  8. t.respondId = respondId;
  9. postId = postId || false;
  10.  
  11. if ( ! t.I('wp-temp-form-div') ) {
  12. div = document.createElement('div');
  13. div.id = 'wp-temp-form-div';
  14. div.style.display = 'none';
  15. respond.parentNode.insertBefore(div, respond);
  16. }
  17.  
  18. comm.parentNode.insertBefore(respond, comm.nextSibling);
  19. if ( post && postId )
  20. post.value = postId;
  21. parent.value = parentId;
  22. cancel.style.display = '';
  23.  
  24. cancel.onclick = function() {
  25. var t = addReply, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
  26. t.rmTiny();
  27.  
  28. if ( ! temp || ! respond )
  29. return;
  30.  
  31. t.I('inreplyto').value = '0';
  32. temp.parentNode.insertBefore(respond, temp);
  33. temp.parentNode.removeChild(temp);
  34. this.style.display = 'none';
  35. this.onclick = null;
  36. t.addTiny();
  37. return false;
  38. }
  39. t.addTiny();
  40.  
  41. try { t.I('bbp_reply_content').focus(); }
  42. catch(e) {}
  43.  
  44. return false;
  45. },
  46.  
  47. I : function(e) {
  48. return document.getElementById(e);
  49. },
  50.  
  51. rmTiny : function() {
  52. try {
  53. tinyMCE.triggerSave();
  54. tinyMCE.execCommand('mceFocus', false,'bbp_reply_content');
  55. tinyMCE.execCommand('mceRemoveControl', false,'bbp_reply_content');
  56. } catch(el) {}
  57. },
  58.  
  59. addTiny : function() {
  60. try {
  61. tinyMCE.execCommand('mceAddControl', false, 'bbp_reply_content');
  62. } catch (e) {}
  63. }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement