[common] depends moved for LocalStorage
This commit is contained in:
parent
12ca6e79ab
commit
2461b1d7b6
|
@ -38,71 +38,73 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Common.localStorage = new (function() {
|
define(['gateway'], function () {
|
||||||
var _storeName, _filter;
|
Common.localStorage = new (function() {
|
||||||
var _store = {};
|
var _storeName, _filter;
|
||||||
|
var _store = {};
|
||||||
|
|
||||||
var ongetstore = function(data) {
|
var ongetstore = function(data) {
|
||||||
if (data.type == 'localstorage') {
|
if (data.type == 'localstorage') {
|
||||||
_store = data.keys;
|
_store = data.keys;
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Common.Gateway.on('internalcommand', ongetstore);
|
|
||||||
|
|
||||||
var _refresh = function() {
|
|
||||||
if (!_lsAllowed)
|
|
||||||
Common.Gateway.internalMessage('localstorage', {cmd:'get', keys:_filter});
|
|
||||||
};
|
|
||||||
|
|
||||||
var _save = function() {
|
|
||||||
if (!_lsAllowed)
|
|
||||||
Common.Gateway.internalMessage('localstorage', {cmd:'set', keys:_store});
|
|
||||||
};
|
|
||||||
|
|
||||||
var _setItem = function(name, value, just) {
|
|
||||||
if (_lsAllowed) {
|
|
||||||
localStorage.setItem(name, value);
|
|
||||||
} else {
|
|
||||||
_store[name] = value;
|
|
||||||
|
|
||||||
if (just===true) {
|
|
||||||
Common.Gateway.internalMessage('localstorage', {
|
|
||||||
cmd:'set',
|
|
||||||
keys: {
|
|
||||||
name: value
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Common.Gateway.on('internalcommand', ongetstore);
|
||||||
|
|
||||||
|
var _refresh = function() {
|
||||||
|
if (!_lsAllowed)
|
||||||
|
Common.Gateway.internalMessage('localstorage', {cmd:'get', keys:_filter});
|
||||||
|
};
|
||||||
|
|
||||||
|
var _save = function() {
|
||||||
|
if (!_lsAllowed)
|
||||||
|
Common.Gateway.internalMessage('localstorage', {cmd:'set', keys:_store});
|
||||||
|
};
|
||||||
|
|
||||||
|
var _setItem = function(name, value, just) {
|
||||||
|
if (_lsAllowed) {
|
||||||
|
localStorage.setItem(name, value);
|
||||||
|
} else {
|
||||||
|
_store[name] = value;
|
||||||
|
|
||||||
|
if (just===true) {
|
||||||
|
Common.Gateway.internalMessage('localstorage', {
|
||||||
|
cmd:'set',
|
||||||
|
keys: {
|
||||||
|
name: value
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var _getItem = function(name) {
|
||||||
|
if (_lsAllowed)
|
||||||
|
return localStorage.getItem(name);
|
||||||
|
else
|
||||||
|
return _store[name]===undefined ? null : _store[name];
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
var _lsAllowed = !!window.localStorage;
|
||||||
|
} catch (e) {
|
||||||
|
_lsAllowed = false;
|
||||||
}
|
}
|
||||||
};
|
|
||||||
|
|
||||||
var _getItem = function(name) {
|
return {
|
||||||
if (_lsAllowed)
|
getId: function() {
|
||||||
return localStorage.getItem(name);
|
return _storeName;
|
||||||
else
|
},
|
||||||
return _store[name]===undefined ? null : _store[name];
|
setId: function(name) {
|
||||||
};
|
_storeName = name;
|
||||||
|
},
|
||||||
try {
|
getItem: _getItem,
|
||||||
var _lsAllowed = !!window.localStorage;
|
setItem: _setItem,
|
||||||
} catch (e) {
|
setKeysFilter: function(value) {
|
||||||
_lsAllowed = false;
|
_filter = value;
|
||||||
}
|
},
|
||||||
|
sync: _refresh,
|
||||||
return {
|
save: _save
|
||||||
getId: function() {
|
};
|
||||||
return _storeName;
|
})();
|
||||||
},
|
});
|
||||||
setId: function(name) {
|
|
||||||
_storeName = name;
|
|
||||||
},
|
|
||||||
getItem: _getItem,
|
|
||||||
setItem: _setItem,
|
|
||||||
setKeysFilter: function(value) {
|
|
||||||
_filter = value;
|
|
||||||
},
|
|
||||||
sync: _refresh,
|
|
||||||
save: _save
|
|
||||||
};
|
|
||||||
})();
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ define([
|
||||||
'common/main/lib/controller/Fonts',
|
'common/main/lib/controller/Fonts',
|
||||||
'common/main/lib/collection/TextArt',
|
'common/main/lib/collection/TextArt',
|
||||||
'common/main/lib/view/OpenDialog',
|
'common/main/lib/view/OpenDialog',
|
||||||
|
'common/main/lib/util/LocalStorage',
|
||||||
'documenteditor/main/app/collection/ShapeGroups',
|
'documenteditor/main/app/collection/ShapeGroups',
|
||||||
'documenteditor/main/app/collection/EquationGroups'
|
'documenteditor/main/app/collection/EquationGroups'
|
||||||
], function () {
|
], function () {
|
||||||
|
|
Loading…
Reference in a new issue