- Unify typeof and undefined usage

release-0.6
alecpl 14 years ago
parent d8cf6d7278
commit ef4f591a1d

@ -167,7 +167,7 @@ get_keycode: function(e)
get_button: function(e) get_button: function(e)
{ {
e = e || window.event; e = e || window.event;
return e && (typeof e.button != 'undefined') ? e.button : (e && e.which ? e.which : 0); return e && e.button !== undefined ? e.button : (e && e.which ? e.which : 0);
}, },
/** /**
@ -318,7 +318,7 @@ addEventListener: function(evt, func, obj)
*/ */
removeEventListener: function(evt, func, obj) removeEventListener: function(evt, func, obj)
{ {
if (typeof obj == 'undefined') if (obj === undefined)
obj = window; obj = window;
for (var h,i=0; this._events && this._events[evt] && i < this._events[evt].length; i++) for (var h,i=0; this._events && this._events[evt] && i < this._events[evt].length; i++)
@ -335,22 +335,22 @@ removeEventListener: function(evt, func, obj)
triggerEvent: function(evt, e) triggerEvent: function(evt, e)
{ {
var ret, h; var ret, h;
if (typeof e == 'undefined') if (e === undefined)
e = this; e = this;
else if (typeof e == 'object') else if (typeof e === 'object')
e.event = evt; e.event = evt;
if (this._events && this._events[evt] && !this._event_exec) { if (this._events && this._events[evt] && !this._event_exec) {
this._event_exec = true; this._event_exec = true;
for (var i=0; i < this._events[evt].length; i++) { for (var i=0; i < this._events[evt].length; i++) {
if ((h = this._events[evt][i])) { if ((h = this._events[evt][i])) {
if (typeof h.func == 'function') if (typeof h.func === 'function')
ret = h.func.call ? h.func.call(h.obj, e) : h.func(e); ret = h.func.call ? h.func.call(h.obj, e) : h.func(e);
else if (typeof h.obj[h.func] == 'function') else if (typeof h.obj[h.func] === 'function')
ret = h.obj[h.func](e); ret = h.obj[h.func](e);
// cancel event execution // cancel event execution
if (typeof ret != 'undefined' && !ret) if (ret !== undefined && !ret)
break; break;
} }
} }
@ -513,7 +513,7 @@ function rcube_clone_object(obj)
var out = {}; var out = {};
for (var key in obj) { for (var key in obj) {
if (obj[key] && typeof obj[key] == 'object') if (obj[key] && typeof obj[key] === 'object')
out[key] = clone_object(obj[key]); out[key] = clone_object(obj[key]);
else else
out[key] = obj[key]; out[key] = obj[key];

@ -91,7 +91,7 @@ function GoogieSpell(img_dir, server_url) {
this.decorateTextarea = function(id) { this.decorateTextarea = function(id) {
this.text_area = typeof(id) == 'string' ? document.getElementById(id) : id; this.text_area = typeof id === 'string' ? document.getElementById(id) : id;
if (this.text_area) { if (this.text_area) {
if (!this.spell_container && this.decoration) { if (!this.spell_container && this.decoration) {
@ -120,7 +120,7 @@ this.decorateTextarea = function(id) {
// API Functions (the ones that you can call) // API Functions (the ones that you can call)
///// /////
this.setSpellContainer = function(id) { this.setSpellContainer = function(id) {
this.spell_container = typeof(id) == 'string' ? document.getElementById(id) : id; this.spell_container = typeof id === 'string' ? document.getElementById(id) : id;
}; };
this.setLanguages = function(lang_dict) { this.setLanguages = function(lang_dict) {
@ -931,7 +931,7 @@ this.checkSpellingState = function(fire) {
// Misc. functions // Misc. functions
///// /////
this.isDefined = function(o) { this.isDefined = function(o) {
return (o != 'undefined' && o != null) return (o !== undefined && o !== null)
}; };
this.errorFixed = function() { this.errorFixed = function() {

@ -58,7 +58,7 @@ function rcube_list_widget(list, p)
this.row_init = function(){}; this.row_init = function(){};
// overwrite default paramaters // overwrite default paramaters
if (p && typeof(p) == 'object') if (p && typeof p === 'object')
for (var n in p) for (var n in p)
this[n] = p[n]; this[n] = p[n];
}; };

Loading…
Cancel
Save