Changeset 7754 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-feedback.js
- Timestamp:
- 10/19/2018 10:56:22 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes-feedback.js
r6910 r7754 5 5 } 6 6 7 var wpAdminBar = 0; 7 8 var options = wporg_note_feedback; 8 var wpAdminBar = $('#page.admin-bar').length ? 32 : 0; 9 var feedbackToggle = $( '<a class="feedback-toggle" href="#">' + options.show + '</a>' ); 10 var hash = window.location.hash; 9 var feedbackToggle = $( '<a role="button" class="feedback-toggle" href="#">' + options.show + '</a>' ); 10 var commentID = window.location.hash; 11 11 12 12 // Check if the fragment identifier is a comment ID (e.g. #comment-63) 13 if ( ! hash.match( /#comment\-[0-9]+$/ ) ) {14 hash= '';13 if ( !commentID.match( /#comment\-[0-9]+$/ ) ) { 14 commentID = ''; 15 15 } 16 16 17 17 $( '.feedback-editor' ).each( function() { 18 19 // Hide hidden editor with 'hide-if-js' class. 20 if( 'none' === $(this).css('display') ) { 21 $( this ).show().addClass( 'hide-if-js' ); 22 } 18 // Hide feedback editors with hide-if-js class 19 $( this ).not('.edit-feedback-editor').addClass( 'hide-if-js' ); 20 $( this ).removeAttr("style"); 23 21 24 22 // Add quicktag 'inline code' button to editor. … … 38 36 var toggle = feedbackToggle.clone(); 39 37 38 var feedback_id = getCommentID( $(this) ); 40 39 toggle.attr( { 41 40 'aria-expanded': 'false', 42 'aria-controls': 'feedback-' + getCommentID( $(this) )41 'aria-controls': 'feedback-' + feedback_id 43 42 } ); 44 43 … … 48 47 } 49 48 50 feedbackLinks.find( '.feedback-add' ).show(); 49 // Display hidden add feedback link and add aria 50 feedbackLinks.find( '.feedback-add' ).removeAttr("style").attr( { 51 'aria-expanded': 'false', 52 'aria-controls': 'feedback-editor-' + feedback_id 53 } ); 54 51 55 feedbackLinks.append( toggle ); 52 56 } 53 57 54 58 if ( feedbackLinks.length ) { 55 // Move feedback links before feedback.59 // Move the feedback links before the feedback section. 56 60 var clonedElements = feedbackLinks.clone().children(); 57 61 var feedbackLinksTop = $( '<div class="feedback-links"></div>' ).append( clonedElements ); 58 62 $( this ).find( '.feedback' ).first().before( feedbackLinksTop ); 63 64 // Hide the bottom feedback links. 59 65 feedbackLinks.addClass( 'bottom hide-if-js' ); 60 66 } … … 68 74 // Removes added elements 69 75 function resetComment( el ) { 70 71 76 var children = el.find( 'ul.children' ); 72 77 if ( !children.length ) { … … 79 84 // Show hidden child comments if the fragment identifier is a comment ID (e.g. #comment-63). 80 85 $( document ).ready( function() { 81 86 // Set wpAdminBar 87 wpAdminBar = $('#wpadminbar').length ? 32 : 0; 82 88 var childComments = $( '.comment' ).find( 'ul.children' ); 83 89 84 if ( !( hash.length && childComments.length ) ) { 85 return; 86 } 87 88 var hashComment = childComments.find( hash ).first(); 89 if ( hashComment.length ) { 90 // Child comment exists. 91 92 var parent = hashComment.closest( '.comment.depth-1' ); 93 if ( parent.find( '.feedback' ).hasClass( 'hide-if-js' ) ) { 94 // Show child comments. 95 parent.find( '.feedback-toggle' ).first().trigger( 'click' ); 96 } 97 98 // Scroll to the child comment. 99 var pos = hashComment.offset(); 100 $( 'html,body' ).animate( { 101 scrollTop: pos.top - wpAdminBar 102 }, 1 ); 103 } 104 } ); 105 106 // Show/Hide feedback toggle link. 90 if ( ! ( commentID.length && childComments.length ) ) { 91 return; 92 } 93 94 var comment = childComments.find( commentID + '.depth-2' ).first(); 95 if ( ! comment.length ) { 96 return; 97 } 98 // Child comment exists. 99 100 var parent = comment.closest( '.comment.depth-1' ); 101 if ( parent.find( '.feedback' ).hasClass( 'hide-if-js' ) ) { 102 // Show child comments. 103 parent.find( '.feedback-toggle' ).first().trigger( 'click' ); 104 } 105 106 // Scroll to child comment and adjust for admin bar 107 var pos = comment.offset(); 108 $( 'html,body' ).animate( { 109 scrollTop: pos.top - wpAdminBar 110 }, 1 ); 111 112 } ); 113 114 // Click event for Show/Hide feedback toggle link. 107 115 $( document ).on( 'click', '.feedback-toggle', function( e ) { 108 116 e.preventDefault(); … … 131 139 }, 1000 ); 132 140 133 // Addfeedback links at the bottom if there are over 3 feedback notes.141 // Show feedback links at the bottom if there are over 3 feedback notes. 134 142 var children = parent.find( 'ul.children > li' ); 135 143 if ( 3 < children.length ) {
Note: See TracChangeset
for help on using the changeset viewer.