File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-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,33 @@ 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+ window . localStorage . setItem ( 'testKey' , '1' ) ;
54+ window . localStorage . removeItem ( 'testKey' ) ;
55+ this . _localStorageAvailable = true ;
56+ } catch ( error ) {
57+ this . _localStorageAvailable = false ;
58+ }
59+ }
60+ }
61+
62+ return this . _localStorageAvailable ;
63+ } ,
64+
4665 saveState : function ( ) {
47- if ( ! window . localStorage ) {
66+ if ( ! this . localStorageAvailable ( ) ) {
4867 return ;
4968 }
5069 window . localStorage . setItem ( 'toolbar_state' , this . _state ) ;
5170 } ,
5271
5372 loadState : function ( ) {
54- if ( ! window . localStorage ) {
73+ if ( ! this . localStorageAvailable ( ) ) {
5574 return ;
5675 }
5776 var old = window . localStorage . getItem ( 'toolbar_state' ) ;
You can’t perform that action at this time.
0 commit comments