]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/comment-reply.js
WordPress 4.4-scripts
[autoinstalls/wordpress.git] / wp-includes / js / comment-reply.js
index 524f2ede923ac814d65ea9641dee4c334a5379d6..184726d35e6a1487b779762f0aad968a59854784 100644 (file)
@@ -1 +1,96 @@
-addComment={moveForm:function(d,f,i,c){var m=this,a,h=m.I(d),b=m.I(i),l=m.I("cancel-comment-reply-link"),j=m.I("comment_parent"),k=m.I("comment_post_ID");if(!h||!b||!l||!j){return}m.respondId=i;c=c||false;if(!m.I("wp-temp-form-div")){a=document.createElement("div");a.id="wp-temp-form-div";a.style.display="none";b.parentNode.insertBefore(a,b)}h.parentNode.insertBefore(b,h.nextSibling);if(k&&c){k.value=c}j.value=f;l.style.display="";l.onclick=function(){var n=addComment,e=n.I("wp-temp-form-div"),o=n.I(n.respondId);if(!e||!o){return}n.I("comment_parent").value="0";e.parentNode.insertBefore(o,e);e.parentNode.removeChild(e);this.style.display="none";this.onclick=null;return false};try{m.I("comment").focus()}catch(g){}return false},I:function(a){return document.getElementById(a)}};
\ No newline at end of file
+var addComment = {
+       moveForm: function( commId, parentId, respondId, postId ) {
+               var div, element, style, cssHidden,
+                       t           = this,
+                       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' ),
+                       commentForm = respond.getElementsByTagName( 'form' )[0];
+
+               if ( ! comm || ! respond || ! cancel || ! parent || ! commentForm ) {
+                       return;
+               }
+
+               t.respondId = respondId;
+               postId = postId || false;
+
+               if ( ! t.I( 'wp-temp-form-div' ) ) {
+                       div = document.createElement( 'div' );
+                       div.id = 'wp-temp-form-div';
+                       div.style.display = 'none';
+                       respond.parentNode.insertBefore( div, respond );
+               }
+
+               comm.parentNode.insertBefore( respond, comm.nextSibling );
+               if ( post && postId ) {
+                       post.value = postId;
+               }
+               parent.value = parentId;
+               cancel.style.display = '';
+
+               cancel.onclick = function() {
+                       var t       = addComment,
+                               temp    = t.I( 'wp-temp-form-div' ),
+                               respond = t.I( t.respondId );
+
+                       if ( ! temp || ! respond ) {
+                               return;
+                       }
+
+                       t.I( 'comment_parent' ).value = '0';
+                       temp.parentNode.insertBefore( respond, temp );
+                       temp.parentNode.removeChild( temp );
+                       this.style.display = 'none';
+                       this.onclick = null;
+                       return false;
+               };
+
+               /*
+                * Set initial focus to the first form focusable element.
+                * Try/catch used just to avoid errors in IE 7- which return visibility
+                * 'inherit' when the visibility value is inherited from an ancestor.
+                */
+               try {
+                       for ( var i = 0; i < commentForm.elements.length; i++ ) {
+                               element = commentForm.elements[i];
+                               cssHidden = false;
+
+                               // Modern browsers.
+                               if ( 'getComputedStyle' in window ) {
+                                       style = window.getComputedStyle( element );
+                               // IE 8.
+                               } else if ( document.documentElement.currentStyle ) {
+                                       style = element.currentStyle;
+                               }
+
+                               /*
+                                * For display none, do the same thing jQuery does. For visibility,
+                                * check the element computed style since browsers are already doing
+                                * the job for us. In fact, the visibility computed style is the actual
+                                * computed value and already takes into account the element ancestors.
+                                */
+                               if ( ( element.offsetWidth <= 0 && element.offsetHeight <= 0 ) || style.visibility === 'hidden' ) {
+                                       cssHidden = true;
+                               }
+
+                               // Skip form elements that are hidden or disabled.
+                               if ( 'hidden' === element.type || element.disabled || cssHidden ) {
+                                       continue;
+                               }
+
+                               element.focus();
+                               // Stop after the first focusable element.
+                               break;
+                       }
+
+               } catch( er ) {}
+
+               return false;
+       },
+
+       I: function( id ) {
+               return document.getElementById( id );
+       }
+};