File tree Expand file tree Collapse file tree 1 file changed +19
-12
lines changed Expand file tree Collapse file tree 1 file changed +19
-12
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,23 @@ $(function() {
48
48
}
49
49
}
50
50
51
+ // restore edit mode after navigating back
52
+ function restoreEditMode ( ) {
53
+ if ( ! $ ( '#editing' ) . val ( ) )
54
+ return ;
55
+ $ ( '.module' )
56
+ . each ( function ( ) {
57
+ slide_module ( $ ( this ) , 'hide' , true ) ;
58
+ } ) ;
59
+ $ ( $ ( '#editing' ) . val ( ) . split ( ' ' ) )
60
+ . each ( function ( ) {
61
+ slide_module ( $ ( '#' + this ) , 'show' , true ) ;
62
+ } ) ;
63
+ $ ( '#mode-btn' ) . click ( ) ;
64
+ $ ( '.save-btn' ) . prop ( 'disabled' , false ) ;
65
+ $ ( '#editing' ) . val ( '' ) ;
66
+ }
67
+
51
68
// expand all modules
52
69
$ ( '#expand-all-btn' )
53
70
. click ( function ( event ) {
@@ -996,18 +1013,8 @@ $(function() {
996
1013
} ) ;
997
1014
998
1015
// finally switch to edit mode if we navigate back to a page that was editing
999
- if ( $ ( '#editing' ) . val ( ) ) {
1000
- $ ( '.module' )
1001
- . each ( function ( ) {
1002
- slide_module ( $ ( this ) , 'hide' , true ) ;
1003
- } ) ;
1004
- $ ( $ ( '#editing' ) . val ( ) . split ( ' ' ) )
1005
- . each ( function ( ) {
1006
- slide_module ( $ ( '#' + this ) , 'show' , true ) ;
1007
- } ) ;
1008
- $ ( '#mode-btn' ) . click ( ) ;
1009
- $ ( '#editing' ) . val ( '' ) ;
1010
- }
1016
+ $ ( window ) . on ( 'pageshow' , restoreEditMode ) ;
1017
+ restoreEditMode ( ) ;
1011
1018
} ) ;
1012
1019
1013
1020
function confirmUnsafeURL ( url ) {
You can’t perform that action at this time.
0 commit comments