Permalink
Browse files

Merge pull request #225 from danitrap/backspace-tolerance

Backspace tolerance
  • Loading branch information...
2 parents 76fb531 + 3260a61 commit 8d33429cdd6004398a7718a0b6c53c31a99ed784 @ankit ankit committed Mar 2, 2012
@@ -65,8 +65,12 @@ Glee.Events = {
}
// Backspace takes user back in history if gleeBox is empty
- else if (e.keyCode === 8 && Glee.isEmpty()) {
- window.history.back();
+ else if (e.keyCode === 8) {
+ // if the user is not holding the backspace key or ragepressing it
+ if (!Glee.isDeleting && Glee.isEmpty())
+ window.history.back();
+
+ Glee.isDeleting = true;
}
},
@@ -114,7 +118,7 @@ Glee.Events = {
if (Glee.options.bookmarkSearchStatus) {
Glee.bookmarks = [];
}
-
+
Glee.resetTimer();
Glee.setSearchActivity(false);
var command = value.substring(1);
@@ -160,6 +164,15 @@ Glee.Events = {
// you're not pulled up to another position on the page
Glee.selectTopElement();
}
+
+ // Backspace key: set the deleting state to false
+ if (e.keyCode === 8 && Glee.isEmpty()) {
+ Glee.resetTimer();
+ Glee.timer = setTimeout(function() {
+ Glee.isDeleting = false;
+ }, Glee.defaults.backspaceToleranceTimer);
+ }
+
},
/**
@@ -19,6 +19,8 @@ var Glee = {
linkSearchTimer: 0,
+ backspaceToleranceTimer: 500,
+
themes: [
'GleeThemeDefault',
'GleeThemeWhite',
@@ -114,6 +116,7 @@ var Glee = {
// last query executed in jQuery mode
lastjQuery: null,
isSearching: false,
+ isDeleting: false,
isEspRunning: false,
isDOMSearchRequired: true,
commandMode: false,
@@ -65,8 +65,12 @@ Glee.Events = {
}
// Backspace takes user back in history if gleeBox is empty
- else if (e.keyCode === 8 && Glee.isEmpty()) {
- window.history.back();
+ else if (e.keyCode === 8) {
+ // if the user is not holding the backspace key or ragepressing it
+ if (!Glee.isDeleting && Glee.isEmpty())
+ window.history.back();
+
+ Glee.isDeleting = true;
}
},
@@ -114,7 +118,7 @@ Glee.Events = {
if (Glee.options.bookmarkSearchStatus) {
Glee.bookmarks = [];
}
-
+
Glee.resetTimer();
Glee.setSearchActivity(false);
var command = value.substring(1);
@@ -160,6 +164,15 @@ Glee.Events = {
// you're not pulled up to another position on the page
Glee.selectTopElement();
}
+
+ // Backspace key: set the deleting state to false
+ if (e.keyCode === 8 && Glee.isEmpty()) {
+ Glee.resetTimer();
+ Glee.timer = setTimeout(function() {
+ Glee.isDeleting = false;
+ }, Glee.defaults.backspaceToleranceTimer);
+ }
+
},
/**
@@ -19,6 +19,8 @@ var Glee = {
linkSearchTimer: 0,
+ backspaceToleranceTimer: 500,
+
themes: [
'GleeThemeDefault',
'GleeThemeWhite',
@@ -114,6 +116,7 @@ var Glee = {
// last query executed in jQuery mode
lastjQuery: null,
isSearching: false,
+ isDeleting: false,
isEspRunning: false,
isDOMSearchRequired: true,
commandMode: false,

0 comments on commit 8d33429

Please sign in to comment.