/
Bookmarks.js
43 lines (40 loc) · 1.42 KB
/
Bookmarks.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
/*eslint strict: 0*/
define([
'dojo/_base/declare',
'dijit/_WidgetBase',
'esri/dijit/Bookmarks',
'dojo/json',
'dojo/cookie',
'dojo/_base/lang',
'xstyle/css!./Bookmarks/css/Bookmarks.css'
], function (declare, _WidgetBase, Bookmarks, json, cookie, lang) {
return declare([_WidgetBase], {
declaredClass: 'gis.digit.Bookmarks',
postCreate: function () {
this.inherited(arguments);
var bookmarks = this.bookmarks; // from the options passed in
this.bookmarkItems = cookie('bookmarkItems');
if (this.bookmarkItems === undefined) {
this.bookmarkItems = [];
} else {
this.bookmarkItems = json.parse(this.bookmarkItems);
}
this.bookmarks = new Bookmarks({
map: this.map,
id: this.id + '_esri',
editable: this.editable,
bookmarks: lang.mixin(this.bookmarkItems, bookmarks)
}, this.domNode);
this.connect(this.bookmarks, 'onEdit', 'setBookmarks');
this.connect(this.bookmarks, 'onRemove', 'setBookmarks');
},
setBookmarks: function () {
cookie('bookmarkItems', json.stringify(this.bookmarks.toJson()), {
expires: 365
});
},
_export: function () {
return json.stringify(this.bookmarks.toJson());
}
});
});