@@ -274,35 +274,25 @@ $(document).on("ready",function()
274274
275275 if ( displayShowing ( ) )
276276 {
277- //Unselect text from doubleclick.
278- window . getSelection ( ) . removeAllRanges ( )
279- editor . setValue ( note ) ;
280- switchDisplay ( "edit" ) ;
281- //Put cursor at end of textarea.
282- setTimeout ( function ( )
283- {
284- editor . clearSelection ( ) ;
285- } , 1 )
286-
277+ edit ( ) ;
287278 }
288279 else
289280 {
290- //unselect text from doubleclick.
291- window . getSelection ( ) . removeAllRanges ( )
292- note = editor . getValue ( ) ;
293- notes [ current ] = note ;
294- buildCache ( current ) ;
295- $ ( "#display" ) . html ( noteCache [ current ] ) ;
296- switchDisplay ( "display" ) ;
297- //Move note (and cache) to the top!
298- notes . splice ( 0 , 0 , notes . splice ( current , 1 ) [ 0 ] ) ;
299- noteCache . splice ( 0 , 0 , noteCache . splice ( current , 1 ) [ 0 ] ) ;
300- current = 0 ;
301- saveNotes ( ) ;
302- updateList ( ) ;
303-
281+ display ( ) ;
304282 }
305283 } )
284+
285+ $ ( "#pageflip" ) . on ( "mousedown" , function ( )
286+ {
287+ if ( displayShowing ( ) )
288+ {
289+ edit ( ) ;
290+ }
291+ else
292+ {
293+ display ( ) ;
294+ }
295+ } ) ;
306296} ) ;
307297
308298//Very cusom Renderer.
@@ -312,6 +302,37 @@ function render(markdown)
312302 return html ;
313303}
314304
305+ function edit ( )
306+ {
307+ //Unselect text from doubleclick.
308+ window . getSelection ( ) . removeAllRanges ( )
309+ editor . setValue ( note ) ;
310+ switchDisplay ( "edit" ) ;
311+ //Put cursor at end of textarea.
312+ setTimeout ( function ( )
313+ {
314+ editor . clearSelection ( ) ;
315+ editor . focus ( ) ;
316+ } , 1 )
317+ }
318+
319+ function display ( )
320+ {
321+ //unselect text from doubleclick.
322+ window . getSelection ( ) . removeAllRanges ( )
323+ note = editor . getValue ( ) ;
324+ notes [ current ] = note ;
325+ buildCache ( current ) ;
326+ $ ( "#display" ) . html ( noteCache [ current ] ) ;
327+ switchDisplay ( "display" ) ;
328+ //Move note (and cache) to the top!
329+ notes . splice ( 0 , 0 , notes . splice ( current , 1 ) [ 0 ] ) ;
330+ noteCache . splice ( 0 , 0 , noteCache . splice ( current , 1 ) [ 0 ] ) ;
331+ current = 0 ;
332+ saveNotes ( ) ;
333+ updateList ( ) ;
334+ }
335+
315336function switchDisplay ( mode )
316337{
317338 if ( mode == "edit" )
0 commit comments