-
Notifications
You must be signed in to change notification settings - Fork 2
/
Notification.js
43 lines (38 loc) · 1.12 KB
/
Notification.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*jslint browser: true */
/*global define: true */
define([
"dojo/_base/declare",
"dojo/_base/json",
"dojo/has",
"dojo/cookie"
], function (
declare,
json,
has,
cookie
) {
"use strict";
return declare([], {
id: 'dojomat-notification',
get: function () {
if (has('native-localstorage') && has('native-history-state')) {
return json.fromJson(localStorage.getItem(this.id));
}
return json.fromJson(cookie(this.id));
},
clear: function () {
if (has('native-localstorage') && has('native-history-state')) {
localStorage.removeItem(this.id);
} else {
cookie(this.id, null, { expires: -1, path: '/' });
}
},
set: function (notification) {
if (has('native-localstorage') && has('native-history-state')) {
localStorage.setItem(this.id, json.toJson(notification));
} else {
cookie(this.id, json.toJson(notification), { expires: 1, path: '/' });
}
}
});
});