@@ -44,28 +44,35 @@ jQuery( function() {
4444
4545 /**
4646 * Media manager
47+ * FIXME this should be moved to a separate file
4748 */
49+
50+ /* are we in media manager context? */
4851 const $mm_page = jQuery ( '#mediamanager__page' ) ;
4952 const $mm_popup = jQuery ( '#media__manager' ) ;
50- if ( ! $mm_page . length && ! $mm_popup . length ) return ;
53+ const isMMPage = $mm_page . length > 0 ;
54+ const isMMPopup = $mm_popup . length > 0 ;
55+ if ( ! isMMPage && ! isMMPopup ) return ;
5156
57+ /* in the namespace tree add a link to create a new diagram */
5258 const $mm_tree = jQuery ( "#media__tree" ) ;
53- $mm_tree . prepend ( newDiagramForm ( ) ) ;
54-
55- // update diagram NS when clicking in media tree
56- $mm_tree . find ( 'a.idx_dir' ) . each ( function ( e ) {
57- const $this = jQuery ( this ) ;
58- $this . on ( 'click' , function ( e ) {
59- e . preventDefault ( ) ;
60-
61- const $nsSpan = jQuery ( '#drawio__current-ns' ) ;
62- $nsSpan . text ( extractNs ( e . target ) ) ;
59+ const $createLink = jQuery ( '<a href="#">' + LANG . plugins . drawio . createLink + '</a>' ) . on ( 'click' , function ( e ) {
60+ e . preventDefault ( ) ;
61+ newDiagramForm ( ) . dialog ( {
62+ title : LANG . plugins . drawio . createLink ,
63+ width : 600 ,
64+ appendTo : '.dokuwiki' ,
65+ modal : true ,
66+ open : ( ) => {
67+ const ns = isMMPage ? jQuery ( '.panelHeader h3 strong' ) . html ( ) : jQuery ( '#media__ns' ) . html ( ) ;
68+ jQuery ( '#drawio__current-ns' ) . text ( ns ) ;
69+ } ,
6370 } ) ;
6471 } ) ;
72+ $mm_tree . prepend ( $createLink ) ;
6573
66- // FIXME
67- if ( ! $mm_page . length ) return ;
6874 // attach edit button to detail view of SVG files
75+ if ( ! isMMPage ) return ;
6976 $mm_page . on ( 'click' , '.panel.filelist .panelContent a' , function ( e ) {
7077
7178 // observe div.file for mutations
0 commit comments