File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ Toolbar.prototype = {
1414 _currentPanel : null ,
1515 _lastPanel : null ,
1616 _state : 0 ,
17+ _localStorageAvailable : null ,
1718 currentRequest : null ,
1819 originalRequest : null ,
1920 ajaxRequests : [ ] ,
@@ -43,15 +44,36 @@ Toolbar.prototype = {
4344 return this . state ( ) ;
4445 } ,
4546
47+ localStorageAvailable : function ( ) {
48+ if ( this . _localStorageAvailable === null ) {
49+ if ( ! window . localStorage ) {
50+ this . _localStorageAvailable = false ;
51+ } else {
52+ try
53+ {
54+ window . localStorage . setItem ( 'testKey' , '1' ) ;
55+ window . localStorage . removeItem ( 'testKey' ) ;
56+ this . _localStorageAvailable = true ;
57+ }
58+ catch ( error )
59+ {
60+ this . _localStorageAvailable = false ;
61+ }
62+ }
63+ }
64+
65+ return this . _localStorageAvailable ;
66+ } ,
67+
4668 saveState : function ( ) {
47- if ( ! window . localStorage ) {
69+ if ( ! this . localStorageAvailable ( ) ) {
4870 return ;
4971 }
5072 window . localStorage . setItem ( 'toolbar_state' , this . _state ) ;
5173 } ,
5274
5375 loadState : function ( ) {
54- if ( ! window . localStorage ) {
76+ if ( ! this . localStorageAvailable ( ) ) {
5577 return ;
5678 }
5779 var old = window . localStorage . getItem ( 'toolbar_state' ) ;
You can’t perform that action at this time.
0 commit comments