Skip to content

Commit

Permalink
JS interpreters have improved in performance so much, makes more sens…
Browse files Browse the repository at this point in the history
…e to do a short delay() instead of a defer()

Not going to make an appreciable difference from a UX perspective, while
potentially eliminating a bunch of unnecessary CPU work.
  • Loading branch information
slusarz committed Dec 17, 2013
1 parent 870f9f1 commit 55214ea
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 30 deletions.
2 changes: 1 addition & 1 deletion imp/js/compose-base.js
Expand Up @@ -44,7 +44,7 @@ var ImpComposeBase = {
Field.focus(input);
input.setSelectionRange(pos, pos);
if (pos) {
(function() { input.scrollTop = input.scrollHeight - input.offsetHeight; }).defer();
(function() { input.scrollTop = input.scrollHeight - input.offsetHeight; }).delay(0.1);
}
} else if (input.createTextRange) {
/* This works in IE */
Expand Down
16 changes: 8 additions & 8 deletions imp/js/compose-dimp.js
Expand Up @@ -211,7 +211,7 @@ var DimpCompose = {
}

if (this.editor_wait) {
return this.uniqueSubmit.bind(this, action).defer();
return this.uniqueSubmit.bind(this, action).delay(0.1);
}

switch (action) {
Expand Down Expand Up @@ -397,7 +397,7 @@ var DimpCompose = {
}

if (this.editor_wait) {
return this.toggleHtmlEditor.bind(this, noupdate).defer();
return this.toggleHtmlEditor.bind(this, noupdate).delay(0.1);
}

if (ImpComposeBase.editor_on) {
Expand Down Expand Up @@ -556,7 +556,7 @@ var DimpCompose = {
} else if (!this.rte_loaded && !rte) {
ta.setValue(r.text);
} else {
this.setMessageText.bind(this, rte, r).defer();
this.setMessageText.bind(this, rte, r).delay(0.1);
return;
}

Expand All @@ -569,7 +569,7 @@ var DimpCompose = {
fillForm: function(ob)
{
if (!document.loaded || $('dimpLoading').visible()) {
this.fillForm.bind(this, ob).defer();
this.fillForm.bind(this, ob).delay(0.1);
return;
}

Expand Down Expand Up @@ -642,7 +642,7 @@ var DimpCompose = {
fillFormHash: function()
{
if (ImpComposeBase.editor_on && !this.rte_loaded) {
this.fillFormHash.bind(this).defer();
this.fillFormHash.bind(this).delay(0.1);
return;
}

Expand Down Expand Up @@ -713,7 +713,7 @@ var DimpCompose = {
updateSigHash: function()
{
if (ImpComposeBase.editor_on && !ImpComposeBase.rte_loaded) {
this.updateSigHash.bind(this).defer();
this.updateSigHash.bind(this).delay(0.1);
return;
}
this.hash_sigOrig = this.sigHash();
Expand Down Expand Up @@ -781,7 +781,7 @@ var DimpCompose = {
if (this.rte.focus) {
this.rte.focus();
} else {
this.focusEditor.bind(this).defer();
this.focusEditor.bind(this).delay(0.1);
}
},

Expand Down Expand Up @@ -898,7 +898,7 @@ var DimpCompose = {
resizeMsgArea: function(e)
{
if (!document.loaded || $('dimpLoading').visible()) {
this.resizeMsgArea.bind(this).defer();
this.resizeMsgArea.bind(this).delay(0.1);
return;
}

Expand Down
6 changes: 3 additions & 3 deletions imp/js/compose.js
Expand Up @@ -169,7 +169,7 @@ var ImpCompose = {
$(document).fire('AutoComplete:update');

if (this.editor_wait && ImpComposeBase.editor_on) {
return this.uniqSubmit.bind(this, actionID, e).defer();
return this.uniqSubmit.bind(this, actionID, e).delay(0.1);
}

// Ticket #6727; this breaks on WebKit w/FCKeditor.
Expand Down Expand Up @@ -237,7 +237,7 @@ var ImpCompose = {
updateSigHash: function()
{
if (ImpComposeBase.editor_on && !ImpComposeBase.rte_loaded) {
this.updateSigHash.bind(this).defer();
this.updateSigHash.bind(this).delay(0.1);
return;
}
this.last_sig = this.sigHash();
Expand Down Expand Up @@ -413,7 +413,7 @@ var ImpCompose = {
if (this.popup && !this.reloaded) {
e = e.getHeight();
if (!e) {
return this.resize.bind(this).defer();
return this.resize.bind(this).delay(0.1);
}
d = Math.min(e, screen.height - 50) - document.viewport.getHeight();
if (d > 0) {
Expand Down
6 changes: 3 additions & 3 deletions imp/js/dimpbase.js
Expand Up @@ -290,7 +290,7 @@ var DimpBase = {
{
// Folder bar may not be fully loaded yet.
if ($('foldersLoading').visible()) {
this.highlightSidebar.bind(this, id).defer();
this.highlightSidebar.bind(this, id).delay(0.1);
return;
}

Expand Down Expand Up @@ -2122,7 +2122,7 @@ var DimpBase = {
/* Don't update polled status until the sidebar is visible. Otherwise,
* preview callbacks may not correctly update unseen status. */
if (!$('foldersSidebar').visible()) {
return this.pollCallback.bind(this, r).defer();
return this.pollCallback.bind(this, r).delay(0.1);
}

$H(r).each(function(u) {
Expand Down Expand Up @@ -4161,7 +4161,7 @@ document.observe('FormGhost:submit', DimpBase.searchSubmit.bindAsEventListener(D
document.observe('dom:loaded', function() {
if (Prototype.Browser.IE && !document.addEventListener) {
// For IE 8
DimpBase.onDomLoad.bind(DimpBase).defer();
DimpBase.onDomLoad.bind(DimpBase).delay(0.1);
} else {
DimpBase.onDomLoad();
}
Expand Down
2 changes: 1 addition & 1 deletion imp/js/flagprefs.js
Expand Up @@ -71,7 +71,7 @@ var ImpFlagPrefs = {
{
HordeCore.initHandler('click');
$('prefs').observe('reset', function() {
this.resetHandler.defer();
this.resetHandler.delay(0.1);
}.bind(this));
}

Expand Down
7 changes: 1 addition & 6 deletions imp/js/imp.js
Expand Up @@ -95,12 +95,7 @@ var IMP_JS = {

id.observe('load', function(i) {
i.stopObserving('load');
if (Prototype.Browser.IE && !document.addEventListener) {
// IE8
this.iframeResize.bind(this, i).delay(1);
} else {
this.iframeResize.bind(this, i).defer();
}
this.iframeResize.bind(this, i).delay(0.1);
}.bind(this, id));

d.open();
Expand Down
2 changes: 1 addition & 1 deletion imp/js/message-dimp.js
Expand Up @@ -303,7 +303,7 @@ var DimpMessage = {
document.observe('dom:loaded', function() {
if (Prototype.Browser.IE && !document.addEventListener) {
// IE 8
DimpMessage.onDomLoad.bind(DimpMessage).defer();
DimpMessage.onDomLoad.bind(DimpMessage).delay(0.1);
} else {
DimpMessage.onDomLoad();
}
Expand Down
2 changes: 1 addition & 1 deletion imp/js/search.js
Expand Up @@ -670,7 +670,7 @@ var ImpSearch = {
onDomLoad: function()
{
if (!this.data) {
this.onDomLoad.bind(this).defer();
this.onDomLoad.bind(this).delay(0.1);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion imp/js/signaturehtml.js
Expand Up @@ -16,7 +16,7 @@ var ImpHtmlSignaturePrefs = {
if (this.ready) {
CKEDITOR.instances.signature_html.setData(this.sigs[e.memo.i]);
} else {
this.changeIdentity.bind(this, e).defer();
this.changeIdentity.bind(this, e).delay(0.1);
}
break;
}
Expand Down
10 changes: 5 additions & 5 deletions imp/js/viewport.js
Expand Up @@ -295,7 +295,7 @@ var ViewPort = Class.create({
if (this.page_size === null) {
ps = this.getPageSize(this.pane_mode ? 'default' : 'max');
if (isNaN(ps)) {
return this.loadView.bind(this, view, opts).defer();
return this.loadView.bind(this, view, opts).delay(0.1);
}
this.page_size = ps;
}
Expand Down Expand Up @@ -421,7 +421,7 @@ var ViewPort = Class.create({
{
if (vs.size()) {
if (this.isbusy) {
this.remove.bind(this, vs).defer();
this.remove.bind(this, vs).delay(0.1);
} else {
this.isbusy = true;
try {
Expand Down Expand Up @@ -466,7 +466,7 @@ var ViewPort = Class.create({
if (nowait) {
this._onResize(size);
} else {
this.resizefunc = this._onResize.bind(this, size).defer();
this.resizefunc = this._onResize.bind(this, size).delay(0.1);
}
},

Expand Down Expand Up @@ -599,7 +599,7 @@ var ViewPort = Class.create({
_fetchBuffer: function(opts)
{
if (this.isbusy) {
this._fetchBuffer.bind(this, opts).defer();
this._fetchBuffer.bind(this, opts).delay(0.1);
} else {
this.isbusy = true;
try {
Expand Down Expand Up @@ -814,7 +814,7 @@ var ViewPort = Class.create({
_ajaxResponse: function(r)
{
if (this.isbusy) {
this._ajaxResponse.bind(this, r).defer();
this._ajaxResponse.bind(this, r).delay(0.1);
} else {
this.isbusy = true;
try {
Expand Down

0 comments on commit 55214ea

Please sign in to comment.