@ -907,7 +907,7 @@ async function initRepository() {
} ) ;
} ) ;
// Quote reply
// Quote reply
$ ( '.quote-reply' ) . on ( 'click' , function ( event ) {
$ ( document ) . on ( 'click' , '.quote-reply ' , function ( event ) {
$ ( this ) . closest ( '.dropdown' ) . find ( '.menu' ) . toggle ( 'visible' ) ;
$ ( this ) . closest ( '.dropdown' ) . find ( '.menu' ) . toggle ( 'visible' ) ;
const target = $ ( this ) . data ( 'target' ) ;
const target = $ ( this ) . data ( 'target' ) ;
const quote = $ ( ` #comment- ${ target } ` ) . text ( ) . replace ( /\n/g , '\n> ' ) ;
const quote = $ ( ` #comment- ${ target } ` ) . text ( ) . replace ( /\n/g , '\n> ' ) ;
@ -933,7 +933,7 @@ async function initRepository() {
} ) ;
} ) ;
// Edit issue or comment content
// Edit issue or comment content
$ ( '.edit-content' ) . on ( 'click' , async function ( event ) {
$ ( document ) . on ( 'click' , '.edit-content ' , async function ( event ) {
$ ( this ) . closest ( '.dropdown' ) . find ( '.menu' ) . toggle ( 'visible' ) ;
$ ( this ) . closest ( '.dropdown' ) . find ( '.menu' ) . toggle ( 'visible' ) ;
const $segment = $ ( this ) . closest ( '.header' ) . next ( ) ;
const $segment = $ ( this ) . closest ( '.header' ) . next ( ) ;
const $editContentZone = $segment . find ( '.edit-content-zone' ) ;
const $editContentZone = $segment . find ( '.edit-content-zone' ) ;
@ -1096,7 +1096,7 @@ async function initRepository() {
} ) ;
} ) ;
// Delete comment
// Delete comment
$ ( '.delete-comment' ) . on ( 'click' , function ( ) {
$ ( document ) . on ( 'click' , '.delete-comment ' , function ( ) {
const $this = $ ( this ) ;
const $this = $ ( this ) ;
if ( window . confirm ( $this . data ( 'locale' ) ) ) {
if ( window . confirm ( $this . data ( 'locale' ) ) ) {
$ . post ( $this . data ( 'url' ) , {
$ . post ( $this . data ( 'url' ) , {
@ -1105,6 +1105,15 @@ async function initRepository() {
const $conversationHolder = $this . closest ( '.conversation-holder' ) ;
const $conversationHolder = $this . closest ( '.conversation-holder' ) ;
$ ( ` # ${ $this . data ( 'comment-id' ) } ` ) . remove ( ) ;
$ ( ` # ${ $this . data ( 'comment-id' ) } ` ) . remove ( ) ;
if ( $conversationHolder . length && ! $conversationHolder . find ( '.comment' ) . length ) {
if ( $conversationHolder . length && ! $conversationHolder . find ( '.comment' ) . length ) {
const path = $conversationHolder . data ( 'path' ) ;
const side = $conversationHolder . data ( 'side' ) ;
const idx = $conversationHolder . data ( 'idx' ) ;
const lineType = $conversationHolder . closest ( 'tr' ) . data ( 'line-type' ) ;
if ( lineType === 'same' ) {
$ ( ` a.add-code-comment[data-path=" ${ path } "][data-idx=" ${ idx } "] ` ) . removeClass ( 'invisible' ) ;
} else {
$ ( ` a.add-code-comment[data-path=" ${ path } "][data-side=" ${ side } "][data-idx=" ${ idx } "] ` ) . removeClass ( 'invisible' ) ;
}
$conversationHolder . remove ( ) ;
$conversationHolder . remove ( ) ;
}
}
} ) ;
} ) ;
@ -1235,7 +1244,7 @@ function initPullRequestReview() {
}
}
}
}
$ ( '.show-outdated' ) . on ( 'click' , function ( e ) {
$ ( document ) . on ( 'click' , '.show-outdated ' , function ( e ) {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
const id = $ ( this ) . data ( 'comment' ) ;
const id = $ ( this ) . data ( 'comment' ) ;
$ ( this ) . addClass ( 'hide' ) ;
$ ( this ) . addClass ( 'hide' ) ;
@ -1244,7 +1253,7 @@ function initPullRequestReview() {
$ ( ` #hide-outdated- ${ id } ` ) . removeClass ( 'hide' ) ;
$ ( ` #hide-outdated- ${ id } ` ) . removeClass ( 'hide' ) ;
} ) ;
} ) ;
$ ( '.hide-outdated' ) . on ( 'click' , function ( e ) {
$ ( document ) . on ( 'click' , '.hide-outdated ' , function ( e ) {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
const id = $ ( this ) . data ( 'comment' ) ;
const id = $ ( this ) . data ( 'comment' ) ;
$ ( this ) . addClass ( 'hide' ) ;
$ ( this ) . addClass ( 'hide' ) ;
@ -1253,7 +1262,7 @@ function initPullRequestReview() {
$ ( ` #show-outdated- ${ id } ` ) . removeClass ( 'hide' ) ;
$ ( ` #show-outdated- ${ id } ` ) . removeClass ( 'hide' ) ;
} ) ;
} ) ;
$ ( 'button.comment-form-reply' ) . on ( 'click' , function ( e ) {
$ ( document ) . on ( 'click' , 'button.comment-form-reply ' , function ( e ) {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
$ ( this ) . hide ( ) ;
$ ( this ) . hide ( ) ;
const form = $ ( this ) . parent ( ) . find ( '.comment-form' ) ;
const form = $ ( this ) . parent ( ) . find ( '.comment-form' ) ;
@ -1284,7 +1293,7 @@ function initPullRequestReview() {
$ ( this ) . closest ( '.menu' ) . toggle ( 'visible' ) ;
$ ( this ) . closest ( '.menu' ) . toggle ( 'visible' ) ;
} ) ;
} ) ;
$ ( '.add-code-comment' ) . on ( 'click' , function ( e ) {
$ ( 'a .add-code-comment' ) . on ( 'click' , async function ( e ) {
if ( $ ( e . target ) . hasClass ( 'btn-add-single' ) ) return ; // https://github.com/go-gitea/gitea/issues/4745
if ( $ ( e . target ) . hasClass ( 'btn-add-single' ) ) return ; // https://github.com/go-gitea/gitea/issues/4745
e . preventDefault ( ) ;
e . preventDefault ( ) ;
@ -1292,18 +1301,13 @@ function initPullRequestReview() {
const side = $ ( this ) . data ( 'side' ) ;
const side = $ ( this ) . data ( 'side' ) ;
const idx = $ ( this ) . data ( 'idx' ) ;
const idx = $ ( this ) . data ( 'idx' ) ;
const path = $ ( this ) . data ( 'path' ) ;
const path = $ ( this ) . data ( 'path' ) ;
const form = $ ( '#pull_review_add_comment' ) . html ( ) ;
const tr = $ ( this ) . closest ( 'tr' ) ;
const tr = $ ( this ) . closest ( 'tr' ) ;
const lineType = tr . data ( 'line-type' ) ;
const oldLineNum = tr . find ( '.lines-num-old' ) . data ( 'line-num' ) ;
const newLineNum = tr . find ( '.lines-num-new' ) . data ( 'line-num' ) ;
const addCommentKey = ` ${ oldLineNum } | ${ newLineNum } ` ;
if ( document . querySelector ( ` [data-add-comment-key=" ${ addCommentKey } "] ` ) ) return ; // don't add same comment box twice
let ntr = tr . next ( ) ;
let ntr = tr . next ( ) ;
if ( ! ntr . hasClass ( 'add-comment' ) ) {
if ( ! ntr . hasClass ( 'add-comment' ) ) {
ntr = $ ( `
ntr = $ ( `
< tr class = "add-comment" data - add - comment - key = "${addCommentKey }">
< tr class = "add-comment" data - line - type = "${lineType }">
$ { isSplit ? `
$ { isSplit ? `
< td class = "lines-num" > < / t d >
< td class = "lines-num" > < / t d >
< td class = "lines-type-marker" > < / t d >
< td class = "lines-type-marker" > < / t d >
@ -1312,8 +1316,7 @@ function initPullRequestReview() {
< td class = "lines-type-marker" > < / t d >
< td class = "lines-type-marker" > < / t d >
< td class = "add-comment-right" > < / t d >
< td class = "add-comment-right" > < / t d >
` : `
` : `
< td class = "lines-num" > < / t d >
< td colspan = "2" class = "lines-num" > < / t d >
< td class = "lines-num" > < / t d >
< td class = "add-comment-left add-comment-right" colspan = "2" > < / t d >
< td class = "add-comment-left add-comment-right" colspan = "2" > < / t d >
` }
` }
< / t r > ` ) ;
< / t r > ` ) ;
@ -1322,21 +1325,20 @@ function initPullRequestReview() {
const td = ntr . find ( ` .add-comment- ${ side } ` ) ;
const td = ntr . find ( ` .add-comment- ${ side } ` ) ;
let commentCloud = td . find ( '.comment-code-cloud' ) ;
let commentCloud = td . find ( '.comment-code-cloud' ) ;
if ( commentCloud . length === 0 ) {
if ( commentCloud . length === 0 && ! ntr . find ( 'button[name="is_review"]' ) . length ) {
td . html ( form ) ;
const data = await $ . get ( $ ( this ) . data ( 'new-comment-url' ) ) ;
td . html ( data ) ;
commentCloud = td . find ( '.comment-code-cloud' ) ;
commentCloud = td . find ( '.comment-code-cloud' ) ;
assingMenuAttributes ( commentCloud . find ( '.menu' ) ) ;
assingMenuAttributes ( commentCloud . find ( '.menu' ) ) ;
td . find ( "input[name='line']" ) . val ( idx ) ;
td . find ( "input[name='line']" ) . val ( idx ) ;
td . find ( "input[name='side']" ) . val ( side === 'left' ? 'previous' : 'proposed' ) ;
td . find ( "input[name='side']" ) . val ( side === 'left' ? 'previous' : 'proposed' ) ;
td . find ( "input[name='path']" ) . val ( path ) ;
td . find ( "input[name='path']" ) . val ( path ) ;
}
const $textarea = commentCloud . find ( 'textarea' ) ;
const $textarea = commentCloud . find ( 'textarea' ) ;
attachTribute ( $textarea . get ( ) , { mentions : true , emoji : true } ) ;
attachTribute ( $textarea . get ( ) , { mentions : true , emoji : true } ) ;
const $simplemde = setCommentSimpleMDE ( $textarea ) ;
const $simplemde = setCommentSimpleMDE ( $textarea ) ;
$textarea . focus ( ) ;
$textarea . focus ( ) ;
$simplemde . codemirror . focus ( ) ;
$simplemde . codemirror . focus ( ) ;
}
} ) ;
} ) ;
}
}
@ -2497,17 +2499,24 @@ $(document).ready(async () => {
$ ( e ) . trigger ( 'click' ) ;
$ ( e ) . trigger ( 'click' ) ;
} ) ;
} ) ;
$ ( '.resolve-conversation' ) . on ( 'click' , function ( e ) {
$ ( document ) . on ( 'click' , '.resolve-conversation' , async function ( e ) {
e . preventDefault ( ) ;
e . preventDefault ( ) ;
const id = $ ( this ) . data ( 'comment-id' ) ;
const comment _id = $ ( this ) . data ( 'comment-id' ) ;
const origin = $ ( this ) . data ( 'origin' ) ;
const action = $ ( this ) . data ( 'action' ) ;
const action = $ ( this ) . data ( 'action' ) ;
const url = $ ( this ) . data ( 'update-url' ) ;
const url = $ ( this ) . data ( 'update-url' ) ;
$ . post ( url , {
const data = await $ . post ( url , { _csrf : csrf , origin , action , comment _id } ) ;
_csrf : csrf ,
action ,
if ( $ ( this ) . closest ( '.conversation-holder' ) . length ) {
comment _id : id ,
const conversation = $ ( data ) ;
} ) . then ( reload ) ;
$ ( this ) . closest ( '.conversation-holder' ) . replaceWith ( conversation ) ;
conversation . find ( '.dropdown' ) . dropdown ( ) ;
initReactionSelector ( conversation ) ;
initClipboard ( ) ;
} else {
reload ( ) ;
}
} ) ;
} ) ;
buttonsClickOnEnter ( ) ;
buttonsClickOnEnter ( ) ;
@ -3626,6 +3635,28 @@ function initIssueList() {
}
}
} ) ;
} ) ;
}
}
$ ( document ) . on ( 'click' , 'button[name="is_review"]' , ( e ) => {
$ ( e . target ) . closest ( 'form' ) . append ( '<input type="hidden" name="is_review" value="true">' ) ;
} ) ;
$ ( document ) . on ( 'submit' , '.conversation-holder form' , async ( e ) => {
e . preventDefault ( ) ;
const form = $ ( e . target ) ;
const newConversationHolder = $ ( await $ . post ( form . attr ( 'action' ) , form . serialize ( ) ) ) ;
const { path , side , idx } = newConversationHolder . data ( ) ;
form . closest ( '.conversation-holder' ) . replaceWith ( newConversationHolder ) ;
if ( form . closest ( 'tr' ) . data ( 'line-type' ) === 'same' ) {
$ ( ` a.add-code-comment[data-path=" ${ path } "][data-idx=" ${ idx } "] ` ) . addClass ( 'invisible' ) ;
} else {
$ ( ` a.add-code-comment[data-path=" ${ path } "][data-side=" ${ side } "][data-idx=" ${ idx } "] ` ) . addClass ( 'invisible' ) ;
}
newConversationHolder . find ( '.dropdown' ) . dropdown ( ) ;
initReactionSelector ( newConversationHolder ) ;
initClipboard ( ) ;
} ) ;
window . cancelCodeComment = function ( btn ) {
window . cancelCodeComment = function ( btn ) {
const form = $ ( btn ) . closest ( 'form' ) ;
const form = $ ( btn ) . closest ( 'form' ) ;
if ( form . length > 0 && form . hasClass ( 'comment-form' ) ) {
if ( form . length > 0 && form . hasClass ( 'comment-form' ) ) {
@ -3636,13 +3667,6 @@ window.cancelCodeComment = function (btn) {
}
}
} ;
} ;
window . submitReply = function ( btn ) {
const form = $ ( btn ) . closest ( 'form' ) ;
if ( form . length > 0 && form . hasClass ( 'comment-form' ) ) {
form . trigger ( 'submit' ) ;
}
} ;
window . onOAuthLoginClick = function ( ) {
window . onOAuthLoginClick = function ( ) {
const oauthLoader = $ ( '#oauth2-login-loader' ) ;
const oauthLoader = $ ( '#oauth2-login-loader' ) ;
const oauthNav = $ ( '#oauth2-login-navigator' ) ;
const oauthNav = $ ( '#oauth2-login-navigator' ) ;