+ All event handlers sent into iQ.fn.bind and its aliases are now automatically wrapped in a try/catch (the catch simply does a Utils.log with the error)

+ Fixed a couple of issues found with the new event try/catch
+ Converted Group.newTab over to iQ (was the last jQuery bit besides drag/drop/resize)
This commit is contained in:
Ian Gilman 2010-06-07 17:20:15 -07:00
parent 343ec477cb
commit ad374945f9
4 changed files with 63 additions and 34 deletions

View File

@ -1036,7 +1036,8 @@ window.Group.prototype = iQ.extend(new Item(), new Subscribable(), {
var activeTab = self.getActiveTab();
if( activeTab ) TabItems.zoomTo(activeTab)
// TODO: This should also accept TabItems
else TabItems.zoomTo(self.getChild(0).tab.mirror.el);
else if(self.getChild(0))
TabItems.zoomTo(self.getChild(0).tab.mirror.el);
});
$(container).droppable({
@ -1106,7 +1107,7 @@ window.Group.prototype = iQ.extend(new Item(), new Subscribable(), {
var group = Groups.getActiveGroup();
iQ(tab.container).css({opacity: 0});
anim = $("<div>")
var $anim = iQ("<div>")
.addClass('newTabAnimatee')
.css({
top: tab.bounds.top+5,
@ -1120,31 +1121,33 @@ window.Group.prototype = iQ.extend(new Item(), new Subscribable(), {
.animate({
opacity: 1.0
}, {
duration: 500
})
.animate({
top: 0,
left: 0,
width: window.innerWidth,
height: window.innerHeight
}, {
duration: 270,
complete: function(){
$(tab.container).css({opacity: 1});
newTab.focus();
Page.showChrome()
UI.navBar.urlBar.focus();
anim.remove();
// We need a timeout here so that there is a chance for the
// new tab to get made! Otherwise it won't appear in the list
// of the group's tab.
// TODO: This is probably a terrible hack that sets up a race
// condition. We need a better solution.
setTimeout(function(){
UI.tabBar.showOnlyTheseTabs(Groups.getActiveGroup()._children);
}, 400);
duration: 500,
complete: function() {
$anim.animate({
top: 0,
left: 0,
width: window.innerWidth,
height: window.innerHeight
}, {
duration: 270,
complete: function(){
iQ(tab.container).css({opacity: 1});
newTab.focus();
Page.showChrome()
UI.navBar.urlBar.focus();
$anim.remove();
// We need a timeout here so that there is a chance for the
// new tab to get made! Otherwise it won't appear in the list
// of the group's tab.
// TODO: This is probably a terrible hack that sets up a race
// condition. We need a better solution.
setTimeout(function(){
UI.tabBar.showOnlyTheseTabs(Groups.getActiveGroup()._children);
}, 400);
}
});
}
});
});
}
// TODO: Because this happens as a callback, there is

View File

@ -296,7 +296,7 @@ window.TabItems = {
self.lastMouseDownTarget = e.target;
});
$div.mouseup(function(e) {
$div.mouseup(function(e) {
var same = (e.target == self.lastMouseDownTarget);
self.lastMouseDownTarget = null;
if(!same)

View File

@ -534,8 +534,12 @@ UIClass.prototype = {
});
iQ(window).bind('beforeunload', function() {
self.showChrome();
self.tabBar.showAllTabs();
// Things may not all be set up by now, so check for everything
if(self.showChrome)
self.showChrome();
if(self.tabBar && self.tabBar.showAllTabs)
self.tabBar.showAllTabs();
});
// ___ Page

View File

@ -697,18 +697,27 @@ iQ.fn = iQ.prototype = {
bind: function(type, func) {
Utils.assert('does not support eventData argument', iQ.isFunction(func));
/*
var handler = function(e) {
try {
return func(e);
return func.apply(this, [e]);
} catch(e) {
Utils.log(e);
}
};
*/
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
elem.addEventListener(type, func, false);
if(!elem.iQEventData)
elem.iQEventData = {};
if(!elem.iQEventData[type])
elem.iQEventData[type] = [];
elem.iQEventData[type].push({
original: func,
modified: handler
});
elem.addEventListener(type, handler, false);
}
return this;
@ -733,7 +742,19 @@ iQ.fn = iQ.prototype = {
Utils.assert('Must provide a function', iQ.isFunction(func));
for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
elem.removeEventListener(type, func, false);
var handler = func;
if(elem.iQEventData && elem.iQEventData[type]) {
for(var a = 0, count = elem.iQEventData[type].length; a < count; a++) {
var pair = elem.iQEventData[type][a];
if(pair.original == func) {
handler = pair.modified;
elem.iQEventData[type].splice(a, 1);
break;
}
}
}
elem.removeEventListener(type, handler, false);
}
return this;
@ -995,6 +1016,7 @@ iQ.extend({
'keydown',
'mouseup',
'mousedown',
'mouseover',
'mousemove',
'click',
'resize',