-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoptions.js
More file actions
32 lines (26 loc) · 1.07 KB
/
options.js
File metadata and controls
32 lines (26 loc) · 1.07 KB
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
YUI().use('event-base','node-style', 'array-extras', function (Y) {
var title = chrome.extension.getBackgroundPage().NOTIFIER.get('title');
function initializeBoooleanOption(fieldName, legacyFieldName) {
var fieldName = 'options__' + fieldName;
var value = localStorage[fieldName];
Y.all('input[name="' + fieldName + '"]')
.each(function (el) {
if (Y.Lang.isValue(value)) {
if (value === el.get('value')) {
el.set('checked', true);
} else {
el.set('checked', false);
}
}
el.on('click', function (e) {
localStorage[fieldName] = e.target.get('value');
});
});
}
Y.on('domready', function () {
document.title = 'Options for ' + title;
Y.one('h1').setHTML('Settings for ' + title);
initializeBoooleanOption('enable_desktop_notifications');
initializeBoooleanOption('enable_notification_sound');
});
});