Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Thomas Rientjes
tor-browser-settings
Commits
ee5cca00
Commit
ee5cca00
authored
Dec 28, 2016
by
Thomas Rientjes
Browse files
Improve code documentation
parent
d3f8e343
Changes
2
Hide whitespace changes
Inline
Side-by-side
chrome/js/settings.js
View file @
ee5cca00
...
@@ -6,18 +6,31 @@
...
@@ -6,18 +6,31 @@
'
use strict
'
;
'
use strict
'
;
/**
* Page event aggregator.
*
* @var {Object} vent
*/
var
vent
=
{};
var
vent
=
{};
/**
* Fires at the end of the document loading process.
*/
window
.
onload
=
function
()
{
window
.
onload
=
function
()
{
let
controls
=
document
.
querySelectorAll
(
'
[data-setting-id]
'
);
let
controls
=
document
.
querySelectorAll
(
'
[data-setting-id]
'
);
for
(
var
index
=
0
,
control
;
control
=
controls
[
index
];
index
++
)
{
for
(
var
index
=
0
,
control
;
control
=
controls
[
index
];
index
++
)
{
control
.
addEventListener
(
'
change
'
,
handleSetting
Change
);
control
.
addEventListener
(
'
change
'
,
handleSetting
Alteration
);
}
}
};
};
function
handleSettingChange
({
target
})
{
/**
* Fires once a setting value has been altered.
*
* @property {Event} event A representation of a DOM event.
*/
function
handleSettingAlteration
({
target
})
{
let
settingId
,
previousValue
,
currentValue
;
let
settingId
,
previousValue
,
currentValue
;
...
@@ -25,17 +38,20 @@ function handleSettingChange ({ target }) {
...
@@ -25,17 +38,20 @@ function handleSettingChange ({ target }) {
previousValue
=
target
.
getAttribute
(
'
data-previous-value
'
)
||
null
;
previousValue
=
target
.
getAttribute
(
'
data-previous-value
'
)
||
null
;
currentValue
=
target
.
value
;
currentValue
=
target
.
value
;
// Apply the setting to the user interface.
applySetting
({
applySetting
({
id
:
settingId
,
id
:
settingId
,
value
:
currentValue
value
:
currentValue
});
});
// Inform the attached content script.
vent
.
emit
(
'
setting:altered
'
,
{
vent
.
emit
(
'
setting:altered
'
,
{
settingId
:
settingId
,
settingId
:
settingId
,
previousValue
:
previousValue
,
previousValue
:
previousValue
,
currentValue
:
currentValue
currentValue
:
currentValue
});
});
// Memorize the previous value of the setting.
target
.
setAttribute
(
'
data-previous-value
'
,
currentValue
);
target
.
setAttribute
(
'
data-previous-value
'
,
currentValue
);
}
}
...
@@ -101,7 +117,6 @@ function applySetting (setting) {
...
@@ -101,7 +117,6 @@ function applySetting (setting) {
* https://bugzilla.mozilla.org/show_bug.cgi?id=787351
* https://bugzilla.mozilla.org/show_bug.cgi?id=787351
*
*
* @param {Object} l10n A localization object.
* @param {Object} l10n A localization object.
* @private
*/
*/
function
applyL10n
(
l10n
)
{
function
applyL10n
(
l10n
)
{
...
...
src/main.js
View file @
ee5cca00
...
@@ -116,12 +116,15 @@ function showSettingsPanel () {
...
@@ -116,12 +116,15 @@ function showSettingsPanel () {
if
(
settingsTab
===
null
)
{
if
(
settingsTab
===
null
)
{
// Open up the settings panel in a new tab.
tabBrowser
.
addTab
(
SETTINGS_URI
,
{
tabBrowser
.
addTab
(
SETTINGS_URI
,
{
selected
:
true
,
selected
:
true
,
parentId
:
tabBrowser
.
selectedTab
.
id
parentId
:
tabBrowser
.
selectedTab
.
id
});
});
}
else
{
}
else
{
// Activate an existing settings panel tab.
tabBrowser
.
selectTab
(
settingsTab
);
tabBrowser
.
selectTab
(
settingsTab
);
}
}
}
}
Thomas Rientjes
@Synzvato
mentioned in issue
#13 (closed)
·
Apr 07, 2017
mentioned in issue
#13 (closed)
mentioned in issue #13
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment