Skip to content

Commit f3ef46a

Browse files
committedMay 25, 2020
Bug fixes, mostly dealing with previewing themes.
1 parent bee57ce commit f3ef46a

File tree

14 files changed

+85
-175
lines changed

14 files changed

+85
-175
lines changed
 

‎_locales/de/messages.json

-8
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,6 @@
7979
"description": "Title of the options menu pane",
8080
"message": "Thematic Einstellungen"
8181
},
82-
"options_previewDelay_desc": {
83-
"description": "Text displayed in the options pane",
84-
"message": "(ms) delay."
85-
},
86-
"options_previewDelay_hint": {
87-
"description": "Text displayed in the options pane",
88-
"message": "Values between 100 and 10000"
89-
},
9082
"options_preview_desc": {
9183
"description": "Text displayed in the options pane",
9284
"message": "Personavorschau bei Men\u00fcauswahl."

‎_locales/en_US/messages.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,9 @@
7575
"description": "Title of the options menu pane",
7676
"message": "Thematic preferences"
7777
},
78-
"options_previewDelay_desc": {
79-
"description": "Text displayed in the options pane",
80-
"message": "(ms) delay, values between 100 and 10000."
81-
},
8278
"options_preview_desc": {
8379
"description": "Text displayed in the options pane",
84-
"message": "Preview themes on menu selection with"
80+
"message": "Preview themes on menu selection."
8581
},
8682
"options_random_desc": {
8783
"description": "Text displayed in the options pane",

‎_locales/it/messages.json

+1-9
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,9 @@
7979
"description": "Title of the options menu pane",
8080
"message": "Thematic: Settaggi di Configurazione"
8181
},
82-
"options_previewDelay_desc": {
83-
"description": "Text displayed in the options pane",
84-
"message": "(ms)"
85-
},
86-
"options_previewDelay_hint": {
87-
"description": "Text displayed in the options pane",
88-
"message": "Values between 100 and 10000"
89-
},
9082
"options_preview_desc": {
9183
"description": "Text displayed in the options pane",
92-
"message": "Anteprima del Tema selezionato nella lista\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0Ritardata di:"
84+
"message": "Anteprima del Tema selezionato."
9385
},
9486
"options_random_desc": {
9587
"description": "Text displayed in the options pane",

‎_locales/zh_CN/messages.json

-8
Original file line numberDiff line numberDiff line change
@@ -115,14 +115,6 @@
115115
"message": "光标停留于选单选项​​经过一千分之",
116116
"description": "Text displayed in the options pane"
117117
},
118-
"options_previewDelay_desc": {
119-
"message": "秒后预览",
120-
"description": "Text displayed in the options pane"
121-
},
122-
"options_previewDelay_hint": {
123-
"message": "Values between 100 and 10000",
124-
"description": "Text displayed in the options pane"
125-
},
126118
"options_iconPreview_desc": {
127119
"message": "Add icon preview to menu items.",
128120
"description": "Text displayed in the options pane"

‎_locales/zh_TW/messages.json

-8
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,6 @@
7575
"message": "游標停留於選單選項經過一千分之",
7676
"description": "Text displayed in the options pane"
7777
},
78-
"options_previewDelay_desc": {
79-
"message": "秒後預覽。",
80-
"description": "Text displayed in the options pane"
81-
},
82-
"options_previewDelay_hint": {
83-
"message": "Values between 100 and 10000",
84-
"description": "Text displayed in the options pane"
85-
},
8678
"options_iconPreview_desc": {
8779
"message": "在選單中顯示縮圖圖示。",
8880
"description": "Text displayed in the options pane"

‎background_scripts/listeners.js

+9-23
Original file line numberDiff line numberDiff line change
@@ -22,34 +22,20 @@ var clickListener = function(theTheme, theIndex)
2222
};
2323
};
2424

25-
var mouseEnterListener = function(theTheme, previewDelay)
26-
{
27-
const MS_TO_MINUTE_CONVERSION = 60000;
28-
return function()
29-
{
30-
const delayInMinutes = previewDelay/MS_TO_MINUTE_CONVERSION;
31-
var innerAlarmListener = function(alarmInfo)
32-
{
25+
var mouseEnterListener = function(theTheme, preview) {
26+
return function() {
27+
if(preview) {
3328
startThemePreview(theTheme);
34-
};
35-
previewAlarmListener = innerAlarmListener;
36-
browser.alarms.create("previewAlarm", {delayInMinutes});
37-
browser.alarms.onAlarm.addListener(previewAlarmListener);
29+
}
3830
};
3931
};
4032

41-
var mouseLeaveListener = function(elementClass, preview)
42-
{
43-
return function()
44-
{
45-
if(preview)
46-
{
47-
browser.alarms.clear("previewAlarm");
48-
browser.alarms.onAlarm.removeListener(previewAlarmListener);
49-
if('browserActionMenu' === elementClass)
50-
{
33+
var mouseLeaveListener = function(elementClass, preview) {
34+
return function() {
35+
if(preview) {
36+
if('browserActionMenu' === elementClass) {
5137
endThemePreview();
5238
}
5339
}
5440
};
55-
};
41+
};

‎background_scripts/menus.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var loadedThemes;
77

88
function getMenuData()
99
{
10-
var menuPreferences = ["iconPreview", "preview", "previewDelay", "current",
10+
var menuPreferences = ["iconPreview", "preview", "current",
1111
"currentThemeId"];
1212
var getData = Promise.all([
1313
browser.storage.local.get(menuPreferences),
@@ -80,7 +80,7 @@ function buildMenuItem(theme, prefs, theIndex)
8080
if (true === prefs.preview)
8181
{
8282
themeChoice.addEventListener('mouseenter',
83-
mouseEnterListener(theme, prefs.previewDelay));
83+
mouseEnterListener(theme, prefs.preview));
8484
themeChoice.addEventListener('mouseleave',
8585
mouseLeaveListener('button theme', prefs.preview));
8686
}

‎background_scripts/prefs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ function reactToPrefChange(prefName, prefData)
2727
// of icons to the menu
2828
// toggleMenuIcons(prefData.newValue);
2929
break;
30-
case 'preview': // falls through to previewDelay
31-
case 'previewDelay':
30+
case 'preview':
3231
getMenuData().then(buildBrowserActionMenu, handleError);
3332
break;
3433
case 'debug':

‎background_scripts/rotate.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ function autoRotate()
6969

7070
function rotate()
7171
{
72-
if (1 >= currentThemes.length) return;
72+
if (1 > currentThemes.length) return;
7373

7474
var getRotatePref = browser.storage.local.get(["random", "current"]);
7575
getRotatePref.then((prefs) =>

‎background_scripts/startup.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function loadDefaultPrefs()
4646
preferences.debug = false;
4747
preferences.fastSwitch = false;
4848
preferences.autoMinutes = 30;
49-
preferences.previewDelay = 100;
5049
preferences.current = 0;
5150
preferences.currentThemeId = null;
5251
preferences.defaults_loaded = true;
@@ -102,23 +101,22 @@ browser.menus.onClicked.addListener((info) =>
102101

103102
browser.commands.onCommand.addListener(function(command)
104103
{
105-
switch (command)
106-
{
104+
logger.log(command);
105+
switch (command) {
107106
case "switch_to_default":
108107
activateDefaultTheme();
109108
break;
110109
case "rotate":
111110
rotate();
112111
break;
113112
case "toggle_autoswitch":
114-
var getAutoPref = browser.storage.local.get("auto");
115-
getAutoPref.then((pref) =>
116-
{
117-
browser.storage.local.set({'auto': !pref.auto})
118-
.catch(handleError);
119-
logger.log(`Auto: ${!pref.auto}`);
120-
}
121-
);
113+
browser.storage.local.get("auto").then((pref) => {
114+
browser.storage.local.set({'auto': !pref.auto})
115+
.catch(handleError);
116+
logger.log(`Auto: ${!pref.auto}`);
117+
// give visual feedback
118+
if(pref.auto) rotate();
119+
});
122120
break;
123121
default:
124122
// should never get here
@@ -127,4 +125,4 @@ browser.commands.onCommand.addListener(function(command)
127125
}
128126
});
129127

130-
handleStartup();
128+
handleStartup();

0 commit comments

Comments
 (0)