Skip to content

Commit d165856

Browse files
committed
fixing up and styling warning banner for expander.js
1 parent 3355fca commit d165856

File tree

3 files changed

+46
-48
lines changed

3 files changed

+46
-48
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ v1.8.4
4242
- Changed popup warnings when Chrome is not syncing the shortcuts properly to use a warning banner instead that is less in-your-face and still let you navigate sites without crying in frustration.
4343
- Fixing inconsistency with handling of trailing spaces. Should only add a space after the expansion if you typed a space.
4444
- Adding auto-capitalization with checking for lower-case versions of the word typed, and applying all-caps or just first letter capitalization automatically.
45+
- Updating crouton banners to require user-initiated dismiss sometimes, so they notice them.
4546

4647
v1.8.3
4748
- Replacing console.log() statements with debugLog() to reduce developer console spam.

css/options.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ button img {
195195
bottom: 0;
196196
left: 0;
197197
right: 0;
198-
padding: 8px 12px;
198+
padding: 8px 0;
199199
text-align: center;
200200
font: bold 13px/16px Verdana;
201201
color: #fff;
@@ -207,10 +207,9 @@ button img {
207207
.crouton.orange { background-color: #e90; }
208208
.crouton .closeButton {
209209
font: bold 13px/13px Verdana;
210-
margin: 0 4px;
210+
margin: 0 6px;
211211
padding: 4px;
212212
float: right;
213-
margin-right: 20px;
214213
}
215214

216215
.popup {

js/expander.js

+43-45
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jQuery.noConflict();
1212

1313
, DEFAULT_CLEAR_BUFFER_TIMEOUT = 750
1414
, TIME_EDITOR_CHECK = 500
15+
, ANIMATION_FAST = 200
16+
, ANIMATION_NORMAL = 400
17+
, ANIMATION_SLOW = 1000
1518
, TIME_SHOW_CROUTON = 1000 * 3 // Show croutons for 3s
1619

1720
, ENUM_CAPITALIZATION_NONE = 0
@@ -1061,7 +1064,7 @@ jQuery.noConflict();
10611064
console.log('Database version:', data[SHORTCUT_VERSION_KEY]);
10621065
console.log('Extension version:', APP_VERSION);
10631066
if (!disableShortcuts) {
1064-
showCrouton(warning, 'red');
1067+
showCrouton(warning);
10651068
}
10661069

10671070
// Flag shortcuts disabled
@@ -1074,51 +1077,46 @@ jQuery.noConflict();
10741077
}
10751078

10761079
// Create and show a warning message crouton that can be dismissed or autohide
1077-
function showCrouton(message, color, autohide)
1080+
function showCrouton(message, autohide)
10781081
{
1079-
$('body').append($(document.createElement('div'))
1080-
.text(message)
1081-
.css({
1082-
'width': '100%',
1083-
'position': 'fixed',
1084-
'bottom': 0,
1085-
'left': 0,
1086-
'right': 0,
1087-
'padding': '8px 12px',
1088-
'text-align': 'center',
1089-
'font': 'bold 13px/16px Verdana',
1090-
'color': '#fff',
1091-
'background-color': color || '#bbb',
1092-
'display': 'none',
1093-
})
1094-
.fadeIn(ANIMATION_FAST, function()
1095-
{
1096-
if (autohide)
1097-
{
1098-
$(this).delay(TIME_SHOW_CROUTON).fadeOut(ANIMATION_FAST, function() {
1099-
$(this).remove();
1100-
})
1101-
}
1102-
else // Show a close button
1103-
{
1104-
$(this).append($(document.createElement('button'))
1105-
.text('x')
1106-
.css({
1107-
'font': 'bold 13px/13px Verdana',
1108-
'margin': '0 4px',
1109-
'padding': '4px',
1110-
'float': 'right',
1111-
'margin-right': '20px',
1112-
})
1113-
.click(function(e) {
1114-
$(this).parent().fadeOut(ANIMATION_FAST, function() {
1115-
$(this).remove();
1116-
});
1117-
})
1118-
);
1119-
}
1120-
})
1121-
);
1082+
// Create and style crouton
1083+
var crouton = document.createElement('div');
1084+
crouton.style['width'] = '100%';
1085+
crouton.style['position'] = 'fixed';
1086+
crouton.style['bottom'] = 0;
1087+
crouton.style['left'] = 0;
1088+
crouton.style['right'] = 0;
1089+
crouton.style['padding'] = '4px 0';
1090+
crouton.style['text-align'] = 'center';
1091+
crouton.style['font'] = 'bold 13px/16px Verdana';
1092+
crouton.style['color'] = '#fff';
1093+
crouton.style['background-color'] = '#c66';
1094+
crouton.style['opacity'] = '.8';
1095+
1096+
// Add to body, add content
1097+
var $crouton = $(crouton);
1098+
$('body').append($crouton.text(message));
1099+
1100+
if (autohide) {
1101+
$crouton.delay(TIME_SHOW_CROUTON).remove();
1102+
}
1103+
else // Show a close button
1104+
{
1105+
// Create and style close button
1106+
var button = document.createElement('button');
1107+
button.style['font'] = 'bold 13px/13px Verdana';
1108+
button.style['margin'] = '0 6px';
1109+
button.style['padding'] = '4px';
1110+
button.style['float'] = 'right';
1111+
1112+
// Add to body, add content, and actions
1113+
$crouton.append($(button)
1114+
.text('x')
1115+
.click(function(e) {
1116+
$(this).parent().remove();
1117+
})
1118+
);
1119+
}
11221120
}
11231121

11241122
// Document ready function

0 commit comments

Comments
 (0)