Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 
 

76 řádky
2.3 KiB

  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'jquery',
  7. 'js-storage/js.storage'
  8. ], function ($, storage) {
  9. 'use strict';
  10. if (window.cookieStorage) {
  11. var cookiesConfig = window.cookiesConfig || {};
  12. $.extend(window.cookieStorage, {
  13. _secure: !!cookiesConfig.secure,
  14. _samesite: cookiesConfig.samesite ? cookiesConfig.samesite : 'lax',
  15. /**
  16. * Set value under name
  17. * @param {String} name
  18. * @param {String} value
  19. * @param {Object} [options]
  20. */
  21. setItem: function (name, value, options) {
  22. var _default = {
  23. expires: this._expires,
  24. path: this._path,
  25. domain: this._domain,
  26. secure: this._secure,
  27. samesite: this._samesite
  28. };
  29. $.cookie(this._prefix + name, value, $.extend(_default, options || {}));
  30. },
  31. /**
  32. * Set default options
  33. * @param {Object} c
  34. * @returns {storage}
  35. */
  36. setConf: function (c) {
  37. if (c.path) {
  38. this._path = c.path;
  39. }
  40. if (c.domain) {
  41. this._domain = c.domain;
  42. }
  43. if (c.expires) {
  44. this._expires = c.expires;
  45. }
  46. if (typeof c.secure !== 'undefined') {
  47. this._secure = c.secure;
  48. }
  49. if (typeof c.samesite !== 'undefined') {
  50. this._samesite = c.samesite;
  51. }
  52. return this;
  53. }
  54. });
  55. }
  56. $.alwaysUseJsonInStorage = $.alwaysUseJsonInStorage || storage.alwaysUseJsonInStorage;
  57. $.cookieStorage = $.cookieStorage || storage.cookieStorage;
  58. $.initNamespaceStorage = $.initNamespaceStorage || storage.initNamespaceStorage;
  59. $.localStorage = $.localStorage || storage.localStorage;
  60. $.namespaceStorages = $.namespaceStorages || storage.namespaceStorages;
  61. $.removeAllStorages = $.removeAllStorages || storage.removeAllStorages;
  62. $.sessionStorage = $.sessionStorage || storage.sessionStorage;
  63. });