angular-translate-storage-cookie.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*!
  2. * angular-translate - v2.6.1 - 2015-03-01
  3. * http://github.com/angular-translate/angular-translate
  4. * Copyright (c) 2015 ; Licensed MIT
  5. */
  6. angular.module('pascalprecht.translate')
  7. /**
  8. * @ngdoc object
  9. * @name pascalprecht.translate.$translateCookieStorage
  10. * @requires $cookieStore
  11. *
  12. * @description
  13. * Abstraction layer for cookieStore. This service is used when telling angular-translate
  14. * to use cookieStore as storage.
  15. *
  16. */
  17. .factory('$translateCookieStorage', ['$cookieStore', function ($cookieStore) {
  18. var $translateCookieStorage = {
  19. /**
  20. * @ngdoc function
  21. * @name pascalprecht.translate.$translateCookieStorage#get
  22. * @methodOf pascalprecht.translate.$translateCookieStorage
  23. *
  24. * @description
  25. * Returns an item from cookieStorage by given name.
  26. *
  27. * @param {string} name Item name
  28. * @return {string} Value of item name
  29. */
  30. get: function (name) {
  31. return $cookieStore.get(name);
  32. },
  33. /**
  34. * @ngdoc function
  35. * @name pascalprecht.translate.$translateCookieStorage#set
  36. * @methodOf pascalprecht.translate.$translateCookieStorage
  37. *
  38. * @description
  39. * Sets an item in cookieStorage by given name.
  40. *
  41. * @deprecated use #put
  42. *
  43. * @param {string} name Item name
  44. * @param {string} value Item value
  45. */
  46. set: function (name, value) {
  47. $cookieStore.put(name, value);
  48. },
  49. /**
  50. * @ngdoc function
  51. * @name pascalprecht.translate.$translateCookieStorage#put
  52. * @methodOf pascalprecht.translate.$translateCookieStorage
  53. *
  54. * @description
  55. * Sets an item in cookieStorage by given name.
  56. *
  57. * @param {string} name Item name
  58. * @param {string} value Item value
  59. */
  60. put: function (name, value) {
  61. $cookieStore.put(name, value);
  62. }
  63. };
  64. return $translateCookieStorage;
  65. }]);