11/**
22 * Roundcube Notes Plugin
33 *
4- * @version 2.0.4
4+ * @version 2.0.5
55 * @author Offerel
66 * @copyright Copyright (c) 2021, Offerel
77 * @license GNU General Public License, version 3
@@ -81,7 +81,12 @@ $(document).ready(function(){
8181 title : 'Upload and insert local image' ,
8282 } ,
8383 'table' , '|' ,
84- 'preview' , 'side-by-side' , 'fullscreen' , 'guide' , '|' ] ,
84+ 'preview' , 'side-by-side' , 'fullscreen' , 'guide' ,
85+ { name : 'Meta' ,
86+ action : togglemData ,
87+ className : 'fa fa-info-circle' ,
88+ title : 'Display Metadata' ,
89+ } , '|' ] ,
8590 } ) ;
8691
8792 document . querySelectorAll ( '#filelist li a' ) . forEach ( function ( note ) {
@@ -94,7 +99,15 @@ $(document).ready(function(){
9499 window . addEventListener ( 'message' , ( e ) => {
95100 let estate = document . getElementById ( 'estate' ) ;
96101 if ( 'tstate' in e . data ) tagify . setReadonly ( e . data . tstate ) ;
97- if ( 'ttags' in e . data && e . data . ttags == '' ) tagify . removeAllTags ( ) ;
102+ if ( 'ttags' in e . data && e . data . ttags == '' ) tagify . removeAllTags ( {
103+ withoutChangeEvent : true
104+ } ) ;
105+
106+ document . getElementById ( 'author' ) . removeAttribute ( 'disabled' ) ;
107+ document . getElementById ( 'source' ) . removeAttribute ( 'disabled' ) ;
108+ document . getElementById ( 'ndata' ) . style = "top: 21px;" ;
109+ if ( document . getElementById ( 'ibutton' ) ) document . getElementById ( 'ibutton' ) . style = "display: none" ;
110+
98111 if ( 'editor' in e . data && e . data . editor == 'new' ) {
99112 if ( estate . value == 's' ) {
100113 mde . togglePreview ( ) ;
@@ -124,8 +137,6 @@ $(document).ready(function(){
124137 let bSeperator = document . createElement ( 'i' ) ;
125138 bSeperator . classList . add ( "separator" ) ;
126139 toolbar . appendChild ( bSeperator ) ;
127-
128- editor1 . parentNode . insertBefore ( toolbar , editor1 ) ;
129140 document . querySelector ( '.EasyMDEContainer' ) . style = 'display: none' ;
130141 editor1 . style = 'display: block' ;
131142 }
@@ -159,7 +170,13 @@ $(document).ready(function(){
159170 bSeperator . classList . add ( "separator" ) ;
160171 toolbar . appendChild ( bSeperator ) ;
161172
162- editor . parentNode . insertBefore ( toolbar , editor ) ;
173+ if ( document . getElementById ( 'cdiv' ) )
174+ document . getElementById ( 'cdiv' ) . appendChild ( toolbar ) ;
175+ else {
176+ toolbar . style = 'top: 88px;' ;
177+ document . getElementById ( 'main_area' ) . parentNode . insertBefore ( toolbar , document . getElementById ( 'main_area' ) ) ;
178+ }
179+
163180 document . querySelector ( '.EasyMDEContainer' ) . style = 'display: none' ;
164181 editor . style = 'display: block' ;
165182
@@ -195,6 +212,11 @@ $(document).ready(function(){
195212 new rcube_splitter ( { id :'notessplitter' , p1 :'#sidebar' , p2 :'#main' , orientation :'v' , relative :true , start :400 , min :250 , size :12 } ) . init ( ) ;
196213
197214 document . querySelector ( '.EasyMDEContainer' ) . addEventListener ( 'paste' , pasteParse , true ) ;
215+ if ( document . getElementById ( 'ibutton' ) ) document . getElementById ( 'ibutton' ) . addEventListener ( 'click' , function ( event ) {
216+ console . log ( "test" ) ;
217+ event . preventDefault ( ) ;
218+ document . getElementById ( 'ndata' ) . classList . toggle ( 'mtoggle' ) ;
219+ } ) ;
198220
199221 function pasteParse ( event ) {
200222 event . preventDefault ( ) ;
@@ -297,6 +319,10 @@ $(document).ready(function(){
297319 function firstNote ( ) {
298320 showNote ( document . getElementById ( 'filelist' ) . firstElementChild . classList [ 0 ] ) ;
299321 }
322+
323+ function togglemData ( ) {
324+ document . getElementById ( 'ndata' ) . classList . toggle ( 'mtoggle' ) ;
325+ }
300326
301327 function sbfile ( ) {
302328 let tags = tagify . value ;
@@ -329,7 +355,14 @@ $(document).ready(function(){
329355 function showNote ( id ) {
330356 document . querySelector ( '#main_area .editor-toolbar' ) . style . display = 'none' ;
331357 if ( document . getElementById ( 'atoolbar' ) ) document . getElementById ( 'atoolbar' ) . remove ( ) ;
358+ if ( document . getElementById ( 'cdiv' ) ) document . getElementById ( 'cdiv' ) . remove ( ) ;
332359 if ( document . getElementById ( 'tbutton' ) ) document . getElementById ( 'tbutton' ) . remove ( ) ;
360+ if ( document . getElementById ( 'ibutton' ) ) document . getElementById ( 'ibutton' ) . remove ( ) ;
361+ document . getElementById ( 'ndata' ) . classList . remove ( 'mtoggle' ) ;
362+ document . getElementById ( 'author' ) . setAttribute ( 'disabled' , true ) ;
363+ document . getElementById ( 'date' ) . setAttribute ( 'disabled' , true ) ;
364+ document . getElementById ( 'source' ) . setAttribute ( 'disabled' , true ) ;
365+ document . getElementById ( 'ndata' ) . style = "top: -22px;" ;
333366
334367 let loader = document . createElement ( "div" ) ;
335368 loader . classList . add ( "db-spinner" ) ;
@@ -372,11 +405,26 @@ $(document).ready(function(){
372405 document . getElementById ( 'author' ) . value = note . author ;
373406 document . getElementById ( 'date' ) . value = note . date ;
374407 document . getElementById ( 'source' ) . value = note . source ;
408+ document . getElementById ( 'updated' ) . value = note . updated ;
375409
376- tagify . setReadonly ( true ) ;
377- tagify . removeAllTags ( ) ;
410+ tagify . setReadonly ( true ) ;
411+ tagify . removeAllTags ( {
412+ withoutChangeEvent : true
413+ } ) ;
378414 tagify . addTags ( note . tags ) ;
379415
416+ if ( note . filename . endsWith ( '.md' ) ) {
417+ let ibutton = document . createElement ( 'button' ) ;
418+ ibutton . id = 'ibutton' ;
419+ ibutton . classList . add ( 'fa' , 'fa-info-circle' ) ;
420+ ibutton . addEventListener ( 'click' , function ( event ) {
421+ event . preventDefault ( ) ;
422+ document . getElementById ( 'ndata' ) . classList . toggle ( 'mtoggle' ) ;
423+ } ) ;
424+ document . getElementById ( 'main_header' ) . appendChild ( ibutton ) ;
425+ document . getElementById ( 'ibutton' ) . style = "display: block" ;
426+ }
427+
380428 document . querySelector ( '.EasyMDEContainer' ) . style = 'display: block;' ;
381429 document . getElementById ( 'editor1' ) . style = 'display none;' ;
382430
@@ -435,8 +483,12 @@ $(document).ready(function(){
435483 bcontent . id = 'bcontent' ;
436484 if ( note . mime_type . includes ( 'pdf' ) ) bcontent . style = 'width: 100%; height: 100%;' ;
437485
486+ let cdiv = document . createElement ( 'div' ) ;
487+ cdiv . id = 'cdiv' ;
488+ cdiv . appendChild ( bcontent ) ;
489+
438490 document . querySelector ( '.EasyMDEContainer' ) . classList . add ( 'EasyMDEContainerH' ) ;
439- document . getElementById ( 'main_area' ) . appendChild ( bcontent ) ;
491+ document . getElementById ( 'main_area' ) . appendChild ( cdiv ) ;
440492 document . getElementById ( 'editor1' ) . style = 'display: none' ;
441493 if ( document . getElementById ( 'atoolbar' ) ) document . getElementById ( 'atoolbar' ) . remove ( ) ;
442494 }
0 commit comments