From 8e84f1f55088169bfa2bf5fb6853104c8be2640d Mon Sep 17 00:00:00 2001 From: Rolux Date: Fri, 5 Feb 2010 15:04:07 +0530 Subject: [PATCH] fix for firefox memory leak --- build/js/ox.ui.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index ebedd5c..41a197d 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -212,19 +212,16 @@ requires return { bind: function(id, event, callback) { if (isKeyboardEvent(event)) { - keyboardEvents[id] = keyboardEvents[id] || []; - keyboardEvents[id].push({ - event: event, - callback: callback - }); + keyboardEvents[id] = keyboardEvents[id] || {}; + keyboardEvents[id][event] = callback; } if (!isKeyboardEvent(event) || Ox.Focus.focused() == id) { $eventHandler.bind(event, callback); } }, bindKeyboard: function(id) { - $.each(keyboardEvents[id] || [], function(i, event) { - Ox.Event.bind(id, event.event, event.callback); + $.each(keyboardEvents[id] || [], function(event, callback) { + Ox.Event.bind(id, event, callback); }); }, trigger: function(event, data) { @@ -233,9 +230,9 @@ requires }, unbind: function(id, event, callback) { if (isKeyboardEvent(event)) { - $.each(keyboardEvents[id] || [], function(i, e) { - if (e.event == event) { - keyboardEvents[id].splice(i, 1); + $.each(keyboardEvents[id] || [], function(e, callback) { + if (e == event) { + delete keyboardEvents[id][e]; return false; } }); @@ -245,8 +242,8 @@ requires unbindKeyboard: function(id) { //Ox.print(keyboardEvents) //Ox.print("unbindKeyboard", id, keyboardEvents[id]) - $.each(keyboardEvents[id] || [], function(i, e) { - $eventHandler.unbind(e.event, e.callback); + $.each(keyboardEvents[id] || [], function(event, callback) { + $eventHandler.unbind(event, callback); }); } }