11import $ from 'jquery' ;
2- import { createTippy } from '../modules/tippy.ts' ;
32import { initCompReactionSelector } from './comp/ReactionSelector.ts' ;
43import { initRepoIssueContentHistory } from './repo-issue-content.ts' ;
54import { initDiffFileTree , initDiffFileList } from './repo-diff-filetree.ts' ;
@@ -19,6 +18,7 @@ import {
1918} from '../utils/dom.ts' ;
2019import { POST , GET } from '../modules/fetch.ts' ;
2120import { fomanticQuery } from '../modules/fomantic/base.ts' ;
21+ import { createTippy } from '../modules/tippy.ts' ;
2222
2323const { pageData, i18n} = window . config ;
2424
@@ -141,12 +141,22 @@ export function initRepoDiffConversationNav() {
141141 } ) ;
142142}
143143
144+ function initDiffHeaderPopup ( ) {
145+ for ( const btn of document . querySelectorAll ( '.diff-header-popup-btn:not([data-header-popup-initialized])' ) ) {
146+ btn . setAttribute ( 'data-header-popup-initialized' , '' ) ;
147+ const popup = btn . nextElementSibling ;
148+ if ( ! popup ?. matches ( '.tippy-target' ) ) throw new Error ( 'Popup element not found' ) ;
149+ createTippy ( btn , { content : popup , theme : 'menu' , placement : 'bottom' , trigger : 'click' , interactive : true , hideOnClick : true } ) ;
150+ }
151+ }
152+
144153// Will be called when the show more (files) button has been pressed
145154function onShowMoreFiles ( ) {
146155 initRepoIssueContentHistory ( ) ;
147156 initViewedCheckboxListenerFor ( ) ;
148157 countAndUpdateViewedFiles ( ) ;
149158 initImageDiff ( ) ;
159+ initDiffHeaderPopup ( ) ;
150160}
151161
152162export async function loadMoreFiles ( url ) {
@@ -222,27 +232,8 @@ export function initRepoDiffView() {
222232 initDiffFileList ( ) ;
223233 initDiffCommitSelect ( ) ;
224234 initRepoDiffShowMore ( ) ;
235+ initDiffHeaderPopup ( ) ;
225236 initRepoDiffFileViewToggle ( ) ;
226237 initViewedCheckboxListenerFor ( ) ;
227238 initExpandAndCollapseFilesButton ( ) ;
228239}
229-
230- export function initRepoDiffFileMenu ( ) {
231- let tippyIndex = 0 ;
232- $ ( '.js-btn-diff-file-menu' ) . each ( function ( ) {
233- tippyIndex ++ ;
234- this . setAttribute ( 'data-diff-file-menu-tippy-target-id' , tippyIndex ) ;
235- const $menu = $ ( this ) . find ( '.tippy-target' ) ;
236- if ( $menu . length < 1 ) return ;
237- $menu [ 0 ] . setAttribute ( 'data-diff-file-menu-tippy-id' , tippyIndex ) ;
238- createTippy ( this , {
239- content : $menu [ 0 ] ,
240- role : 'menu' ,
241- theme : 'menu' ,
242- trigger : 'click' ,
243- placement : 'bottom' ,
244- interactive : true ,
245- hideOnClick : true ,
246- } ) ;
247- } ) ;
248- }
0 commit comments