PDA

View Full Version : [FIXED][3.0] Ext.ux.TabCloseMenu.js broken



mschwartz
17 Apr 2009, 9:36 AM
See: /examples/tabs/tabs-adv.html

The example doesn't work :)

mschwartz
17 Apr 2009, 9:41 AM
Additionally, items member removed from Ext.menu.Menu so none of the container methods work on it anymore.

mschwartz
17 Apr 2009, 9:53 AM
Fix:



// Ext.ux.TabCloseMenu.js for 3.0-rc1

// Very simple plugin for adding a close context menu to tabs

Ext.ux.TabCloseMenu = function() {
var tabs, menu, ctxItem;
this.init = function(tp) {
tabs = tp;
tabs.on('contextmenu', onContextMenu);
}

function onContextMenu(tabPanel, tab, e) {
var items = [];
if (tab.closable) {
items.push({
text: 'Close Tab',
handler: function() {
tabPanel.remove(tab);
}
});
}
var canCloseOthers = false;
tabPanel.items.each(function() {
if (this != tab && this.closable) {
canCloseOthers = true;
return false;
}
return true;
});
if (canCloseOthers) {
items.push({
text: 'Close Other Tabs',
handler: function() {
tabPanel.items.each(function() {
if (this != tab && this.closable) {
tabPanel.remove(this);
}
})
}
})
}
var menu = new Ext.menu.Menu({
items: items
});
menu.showAt(e.getXY());
}
};

evant
17 Apr 2009, 2:08 PM
Fixed in SVN.

stever
17 Apr 2009, 2:23 PM
I don't think you meant to keep that console.log in there!!

;)

evant
17 Apr 2009, 3:11 PM
Cut me some slack, I just landed back in Sydney ;)

Removed the log() statement.

stever
17 Apr 2009, 5:47 PM
Hahaha! No problem, not a complaint or anything, just a heads up. Part of me hesitates to mention it, but part of me knows it is easier to spot now than later...

I tend to review changes from SVN; it is a good way to learn things. Take docs, for example. When some are changed I can see how the wording changed to make things clearer, or how to use something new without having to hunt for changes by rereading all the docs again.

Which is also why I hate big changes in SVN. I'll never get through a big changeset, so I'll never learn much about whatever that big new thing is. Wish the designer were in SVN all this time. Could see how it changes over time, learn what the author learns. Or some other big example that gets improved on a continuous basis. Particularly from ExtJS people, as they would use the best practices on a public project like that.

mschwartz
18 Apr 2009, 10:32 AM
Perhaps in Ext.js (the file), you could detect if window.console exists, and if not, create stubs for it so console.* functions won't break?

evant
20 Apr 2009, 7:07 AM
I'm just kidding, we appreciate the reports :)