读书人

ExtJS 四 : desktop shortcut location

发布时间: 2012-09-03 09:48:39 作者: rapoo

ExtJS 4 : desktop shortcut location
ExtJS 4 Desktop 例子中的桌面图标始终在第一列显示,不论有多少个。重写Desktop的部分方法,让其自动适应位置。

  Ext.override(Ext.ux.desktop.Desktop, {      createDataView: function () {        var me = this;        return {          xtype: 'dataview',          overItemCls: 'x-view-over',          trackOver: true,          itemSelector: me.shortcutItemSelector,          store: me.shortcuts,          tpl: new Ext.XTemplate(me.shortcutTpl),          listeners: {            'refresh': me.positionItems,            'resize': me.positionItems          }        };      },      positionItems: function() {        var me = this,            height = this.getHeight(),            x = 0,            y = 0;        // get  the max width and height of shortcuts        if (!me.itemWidth && !me.itemHeight) {          me.itemHeight = 0;          var h = 0, rh;          this.all.each(function(item) {            var el = Ext.get(item),                box = el.getBox();            me.itemWidth = me.itemWidth || box.right;            me.itemHeight = (rh = box.bottom - h) > me.itemHeight ? rh : me.itemHeight;            h = box.bottom;          });        }        this.all.each(function(item) {          var el = Ext.get(item);          if ((y+me.itemHeight) > height) {            x += me.itemWidth;            y = 0;          }          el.setXY([x, y]);          y += me.itemHeight;        });      }    });

读书人网 >JavaScript

热点推荐