wp/wp-includes/js/comment-reply.js
author ymh <ymh.work@gmail.com>
Wed, 06 Nov 2013 03:21:17 +0000
changeset 0 d970ebf37754
child 5 5e2f62d02dcd
permissions -rw-r--r--
first import
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
addComment = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
	moveForm : function(commId, parentId, respondId, postId) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
		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');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
		if ( ! comm || ! respond || ! cancel || ! parent )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
			return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
		t.respondId = respondId;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
		postId = postId || false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
		if ( ! t.I('wp-temp-form-div') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
			div = document.createElement('div');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
			div.id = 'wp-temp-form-div';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
			div.style.display = 'none';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
			respond.parentNode.insertBefore(div, respond);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
		comm.parentNode.insertBefore(respond, comm.nextSibling);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
		if ( post && postId )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
			post.value = postId;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
		parent.value = parentId;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
		cancel.style.display = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
		cancel.onclick = function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
			var t = addComment, temp = t.I('wp-temp-form-div'), respond = t.I(t.respondId);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    27
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    28
			if ( ! temp || ! respond )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
				return;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
			t.I('comment_parent').value = '0';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
			temp.parentNode.insertBefore(respond, temp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    33
			temp.parentNode.removeChild(temp);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    34
			this.style.display = 'none';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
			this.onclick = null;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
			return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
		}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
		try { t.I('comment').focus(); }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
		catch(e) {}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
		return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
	},
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
	I : function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
		return document.getElementById(e);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
}