Guest

Ben

By: a guest on Feb 4th, 2009  |  syntax: JavaScript  |  size: 1.72 KB  |  hits: 883  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. /* /wp-includes/js/comment-reply.js */
  2. addComment = {
  3.         moveForm : function(commId, parentId, respondId, postId) {
  4.                 CommentTinyMCE_remove();
  5.                 var t = this, div, comm = t.I(commId), respond = t.I(respondId), cancel = t.I('cancel-comment-reply-link'), parent = t.I('comment_parent'), post = t.I('comment_post_ID');
  6.  
  7.                 if ( ! comm || ! respond || ! cancel || ! parent )
  8.                         return;
  9.  
  10.                 t.respondId = respondId;
  11.                 postId = postId || false;
  12.  
  13.                 if ( ! t.I('wp-temp-form-div') ) {
  14.                         div = document.createElement('div');
  15.                         div.id = 'wp-temp-form-div';
  16.                         div.style.display = 'none';
  17.                         respond.parentNode.insertBefore(div, respond);
  18.                 }
  19.  
  20.                 comm.parentNode.insertBefore(respond, comm.nextSibling);
  21.                 if ( post && postId )
  22.                         post.value = postId;
  23.                 parent.value = parentId;
  24.                 cancel.style.display = '';
  25.  
  26.                 cancel.onclick = function() {
  27.                         CommentTinyMCE_remove();
  28.                         var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
  29.  
  30.                         if ( ! temp || ! respond )
  31.                                 return;
  32.  
  33.                         t.I('comment_parent').value = '0';
  34.                         temp.parentNode.insertBefore(respond, temp);
  35.                         temp.parentNode.removeChild(temp);
  36.                         this.style.display = 'none';
  37.                         this.onclick = null;
  38.                         CommentTinyMCE_add();
  39.                         return false;
  40.                 }
  41.                
  42.                 CommentTinyMCE_add();
  43.                
  44.                 try { t.I('comment').focus(); }
  45.                 catch(e) {}
  46.                                
  47.                 return false;
  48.         },
  49.  
  50.         I : function(e) {
  51.                 return document.getElementById(e);
  52.         }
  53. }
  54.  
  55.  
  56. function CommentTinyMCE_remove() {
  57.         try {
  58.                 tinyMCE.triggerSave();
  59.                 tinyMCE.execCommand('mceFocus', false,'comment');
  60.                 tinyMCE.execCommand('mceRemoveControl', false,'comment');
  61.                
  62.         } catch(el) {}
  63. }
  64.  
  65. function CommentTinyMCE_add() {
  66.         try {
  67.                 tinyMCE.execCommand('mceAddControl', false, 'comment');
  68.         } catch (e) {}
  69. }