File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1919 autoresize_max_height : h - 130 ,
2020 init_instance_callback : function ( editor ) {
2121 resizeFont ( "13" ) ;
22+ startTimer ( ) ;
2223 }
2324 } ) ;
2425 }
9596 bindEdit ( ) ;
9697 }
9798
99+ var idle = false ;
100+ var idleTime = 0 ;
101+ var idleInterval ;
102+ var origNote ;
103+ var checkDuration = 20 ;
104+ var saveTime = 60 ;
105+ function startTimer ( ) {
106+ origNote = tinymce . activeEditor . getContent ( ) ;
107+ idleIterval = setInterval ( timerIncrement , checkDuration * 1000 ) ;
108+ $ ( document ) . mousemove ( function ( e ) { notIdle ( ) ; } ) ;
109+ $ ( document ) . keypress ( function ( e ) { noteIdle ( ) ; } ) ;
110+ $ ( '#editable_ifr' ) . contents ( ) . find ( "body" ) . mousemove ( function ( e ) { notIdle ( ) ; } ) ;
111+ tinymce . activeEditor . on ( 'keyup' , function ( e ) { notIdle ( ) ; } ) ;
112+ }
113+
114+ function notIdle ( ) {
115+ idle = false ;
116+ idleTime = 0 ;
117+ }
118+
119+ function timerIncrement ( ) {
120+ idleTime = idleTime + checkDuration ;
121+ if ( $ ( '#editable_ifr' ) && $ ( '#editable_ifr' ) . css ( 'display' ) == 'block' ) {
122+ if ( ! idle && idleTime >= saveTime ) {
123+ var content = tinymce . activeEditor . getContent ( ) ;
124+ if ( content != origNote ) {
125+ origNote = content ;
126+ saveNote ( true ) ;
127+ }
128+ idle = true ;
129+ }
130+ } else {
131+ clearInterval ( idleInterval ) ;
132+ }
133+ }
134+
98135 function bindEdit ( ) {
99136 $ ( "#editform" ) . bind ( "submit" , function ( ) { saveNote ( false ) ; } ) ;
100137 $ ( "#quicksave" ) . bind ( "click" , function ( ) { saveNote ( true ) ; } ) ;
You can’t perform that action at this time.
0 commit comments