在Desktop.js末尾添加函数:
//shortcuts 自动换行
shortcutAutoArrange: function(){var btnHeight = 61;
var btnWidth = 64;
var btnPadding = 15;
var col = {index: 1, x: btnPadding};
var row = {index: 1, y: btnPadding};
var taskbarHeight = Ext.query('.ux-taskbar')[0].clientHeight;
var bodyHeight = Ext.getBody().getHeight() - taskbarHeight;
var items = Ext.query(".ux-desktop-shortcut");
for(var i = 0, len = items.length; i < len; i++){
var bottom = row.y + btnHeight;
var overflow = false;
var y = row.y + btnHeight;
//至少要放置一行
if(y > btnHeight && (y > bodyHeight)){ // || y + this.btnHeight > bodyHeight)){
overflow = true;
}
if(overflow && bottom > (btnHeight + btnPadding)){
col = {index: col.index++, x: col.x + btnWidth + btnPadding};
row = {index: 1, y: btnPadding};
}
Ext.fly(items[i]).setXY([col.x, row.y]);
row.index++;
row.y = row.y + btnHeight + btnPadding;
}
}
//end shortcuts 自动换行
在initComponent函数中添加:
Ext.EventManager.onWindowResize(this.shortcutAutoArrange, this, {delay:500});
同时在afterRender函数中添加:
Ext.Function.defer(me.shortcutAutoArrange, 100);