PageRenderTime 20ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/ext-4.0.7/src/data/proxy/SessionStorage.js

https://bitbucket.org/srogerf/javascript
JavaScript | 54 lines | 8 code | 2 blank | 44 comment | 0 complexity | 7b6b053272316ad6b60694f78aa16fbc MD5 | raw file
  1. /*
  2. This file is part of Ext JS 4
  3. Copyright (c) 2011 Sencha Inc
  4. Contact: http://www.sencha.com/contact
  5. GNU General Public License Usage
  6. This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
  7. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
  8. */
  9. /**
  10. * @author Ed Spencer
  11. *
  12. * Proxy which uses HTML5 session storage as its data storage/retrieval mechanism. If this proxy is used in a browser
  13. * where session storage is not supported, the constructor will throw an error. A session storage proxy requires a
  14. * unique ID which is used as a key in which all record data are stored in the session storage object.
  15. *
  16. * It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided but the
  17. * attached store has a storeId, the storeId will be used. If neither option is presented the proxy will throw an error.
  18. *
  19. * Proxies are almost always used with a {@link Ext.data.Store store}:
  20. *
  21. * new Ext.data.Store({
  22. * proxy: {
  23. * type: 'sessionstorage',
  24. * id : 'myProxyKey'
  25. * }
  26. * });
  27. *
  28. * Alternatively you can instantiate the Proxy directly:
  29. *
  30. * new Ext.data.proxy.SessionStorage({
  31. * id : 'myOtherProxyKey'
  32. * });
  33. *
  34. * Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser
  35. * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts
  36. * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.
  37. */
  38. Ext.define('Ext.data.proxy.SessionStorage', {
  39. extend: 'Ext.data.proxy.WebStorage',
  40. alias: 'proxy.sessionstorage',
  41. alternateClassName: 'Ext.data.SessionStorageProxy',
  42. //inherit docs
  43. getStorageObject: function() {
  44. return window.sessionStorage;
  45. }
  46. });