Skip to content

Commit

Permalink
Better performance when checking for class names
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Mar 9, 2015
1 parent 6dfea09 commit 6010f38
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
12 changes: 7 additions & 5 deletions imp/js/base.js
Expand Up @@ -2862,7 +2862,7 @@ var ImpBase = {

clickHandler: function(e)
{
var tmp,
var cnames, tmp,
elt = e.element(),
id = elt.readAttribute('id');

Expand Down Expand Up @@ -3042,7 +3042,9 @@ var ImpBase = {
break;

default:
if (elt.hasClassName('printAtc')) {
cnames = $w(elt.className);

if (cnames.indexOf('printAtc') !== -1) {
HordeCore.popupWindow(
ImpCore.conf.URI_VIEW,
this.preview.popupWindowParams({
Expand All @@ -3055,7 +3057,7 @@ var ImpBase = {
}
);
e.memo.stop();
} else if (elt.hasClassName('stripAtc')) {
} else if (cnames.indexOf('stripAtc') !== -1) {
if (window.confirm(ImpCore.text.strip_warn)) {
ImpCore.doAction('stripAttachment', this.addViewportParams().merge({
id: elt.readAttribute('mimeid')
Expand All @@ -3072,7 +3074,7 @@ var ImpBase = {
});
}
e.memo.stop();
} else if (elt.hasClassName('flagcolorpicker')) {
} else if (cnames.indexOf('flagcolorpicker') !== -1) {
tmp = elt.previous('INPUT');
this.colorpicker = new ColorPicker({
color: $F(tmp) || '#fff',
Expand All @@ -3085,7 +3087,7 @@ var ImpBase = {
]
});
e.memo.stop();
} else if (elt.hasClassName('imp-sidebar-remote')) {
} else if (cnames.indexOf('imp-sidebar-remote') !== -1) {
elt = this.flist.getMbox(elt);
this.dialogDisplay({
form: $('sidebar_remote_redbox').down().clone(true),
Expand Down
8 changes: 5 additions & 3 deletions imp/js/message.js
Expand Up @@ -115,7 +115,7 @@ var ImpMessage = {
/* Click handlers. */
clickHandler: function(e)
{
var base;
var base, cnames;

switch (e.element().readAttribute('id')) {
case 'windowclose':
Expand Down Expand Up @@ -210,7 +210,9 @@ var ImpMessage = {
break;

default:
if (e.element().hasClassName('printAtc')) {
cnames = $w(e.element().className);

if (cnames.indexOf('printAtc') !== -1) {
HordeCore.popupWindow(ImpCore.conf.URI_VIEW, {
actionID: 'print_attach',
buid: this.buid,
Expand All @@ -221,7 +223,7 @@ var ImpMessage = {
onload: IMP_JS.printWindow
});
e.memo.stop();
} else if (e.element().hasClassName('stripAtc')) {
} else if (cnames.indexOf('stripAtc') !== -1) {
if (window.confirm(ImpCore.text.strip_warn)) {
ImpCore.reloadMessage({
actionID: 'strip_attachment',
Expand Down
41 changes: 23 additions & 18 deletions imp/js/prefs/flag.js
Expand Up @@ -34,28 +34,33 @@ var ImpFlagPrefs = {

clickHandler: function(e)
{
var elt = e.element(), elt2;
var cnames, elt2,
elt = e.element();

if (elt.readAttribute('id') == 'new_button') {
this.addFlag();
} else if (elt.hasClassName('flagcolorpicker')) {
elt2 = elt.previous('INPUT');
new ColorPicker({
color: $F(elt2),
draggable: true,
offsetParent: elt,
resizable: true,
update: [
[ elt2, 'value' ],
[ elt2, 'background' ]
]
});
e.memo.stop();
} else if (elt.hasClassName('flagdelete')) {
if (window.confirm(this.confirm_delete)) {
this._sendData('delete', elt.previous('INPUT').readAttribute('id'));
} else {
cnames = $w(elt.className);

if (cnames.indexOf('flagcolorpicker') !== -1) {
elt2 = elt.previous('INPUT');
new ColorPicker({
color: $F(elt2),
draggable: true,
offsetParent: elt,
resizable: true,
update: [
[ elt2, 'value' ],
[ elt2, 'background' ]
]
});
e.memo.stop();
} else if (cnames.indexOf('flagdelete') !== -1) {
if (window.confirm(this.confirm_delete)) {
this._sendData('delete', elt.previous('INPUT').readAttribute('id'));
}
e.memo.stop();
}
e.memo.stop();
}
},

Expand Down
7 changes: 4 additions & 3 deletions imp/js/prefs/searches.js
Expand Up @@ -13,14 +13,15 @@ var ImpSearchesPrefs = {

clickHandler: function(e)
{
var elt = e.element();
var elt = e.element(),
cnames = $w(elt.className);

if (elt.hasClassName('filterdelete')) {
if (cnames.indexOf('filterdelete') !== -1) {
if (window.confirm(this.confirm_delete_filter)) {
this._sendData('delete', elt.up().previous('.enabled').down('INPUT').readAttribute('name'));
}
e.memo.stop();
} else if (elt.hasClassName('vfolderdelete')) {
} else if (cnames.indexOf('vfolderdelete') !== -1) {
if (window.confirm(this.confirm_delete_vfolder)) {
this._sendData('delete', elt.up().previous('.enabled').down('INPUT').readAttribute('name'));
}
Expand Down
11 changes: 7 additions & 4 deletions imp/js/search.js
Expand Up @@ -530,7 +530,8 @@ var ImpSearch = {

clickHandler: function(e)
{
var elt = e.element();
var cnames,
elt = e.element();

switch (elt.readAttribute('id')) {
case 'search_submit':
Expand Down Expand Up @@ -564,17 +565,19 @@ var ImpSearch = {
break;

default:
if (elt.hasClassName('searchuiDelete')) {
cnames = $w(elt.className);

if (cnames.indexOf('searchuiDelete') !== -1) {
if (elt.up('#search_criteria')) {
this.deleteCriteria(elt.up('DIV.searchId'));
} else {
this.deleteMailbox(elt.up('DIV.searchId'));
}
e.memo.stop();
} else if (elt.hasClassName('calendarImg')) {
} else if (cnames.indexOf('calendarImg') !== -1) {
Horde_Calendar.open(elt.identify(), this.criteria[elt.up('DIV.searchId').identify()].v);
e.memo.stop();
} else if (elt.hasClassName('closeImg') &&
} else if ((cnames.indexOf('closeImg') !== -1) &&
(elt.up('SPAN.beginDate') || elt.up('SPAN.endDate'))) {
this.updateDate(
elt.up('DIV.searchId').identify(),
Expand Down

0 comments on commit 6010f38

Please sign in to comment.