extjs4.1后台管理图标修改。

基本思路在再官方例子中来。


/**
 * @class Ext.org.ImageView
 * @extends Ext.view.View
 * @xtype imageview
 *
 * This class implements the "My Images" view (the images in the organizer). This class
 * incorporates {@link Ext.ux.DataView.Draggable Draggable} to enable dragging items as
 * well as {@link Ext.ux.DataView.DragSelector DragSelector} to allow multiple selection
 * by simply clicking and dragging the mouse.
 */
Ext.define('Sharera.system.util.ImageOragnizer', {
    extend: 'Ext.view.View',
    alias : 'widget.imageview',
    src:'',
    requires: ['Ext.data.Store'],
    mixins: {
        dragSelector: 'Ext.ux.DataView.DragSelector',
        draggable   : 'Ext.ux.DataView.Draggable'
    },
    
    itemSelector: 'div.thumb-wrap',
    emptyText: '没有图片',
    multiSelect: false,
    singleSelect: true,
    cls: 'x-image-view',
    autoScroll: true,
    
    initComponent: function() {
    	var self = this;
    	this.tpl=[
	        '<tpl for=".">',
	            '<div class="thumb-wrap">',
	                '<div class="thumb">',
	                   /*'<img src="../js/extjs/icons/img/{thumb}" />',*/
	                     '<img src='+self.src+'/{thumb} />',
	                '</div>',
	               /* '<span>{name}</span>',*/
	            '</div>',
	        '</tpl>'
	    ],
        this.store = Ext.create('Ext.data.Store', {
            autoLoad: true,
            fields: ['name', 'thumb', {name: 'leaf', defaultValue: true}],
            proxy: {
                type: 'ajax',
                url : context+'admin/system/icons.json',
                reader: {
                    type: 'json',
                    root: ''
                }
            }
        });
        
        this.mixins.dragSelector.init(this);
        this.mixins.draggable.init(this, {
            ddConfig: {
                ddGroup: 'organizerDD'
            },
            ghostTpl: [
                '<tpl for=".">',
                    '<img src="'+self.src+'/{thumb}" />',
                    '<tpl if="xindex % 4 == 0"><br /></tpl>',
                '</tpl>',
                '<div class="count">',
                    '{[values.length]} images selected',
                '<div>'
            ]
        });
        
        this.callParent();
    }
});

				text : 'image',
				iconCls : 'x-tbar-loading',
				scope : this,
				handler : function(){		
				       var win = Ext.create("Ext.window.Window",{
							title: '双击选择图片',
						    height: 200,
						    width: 400,
						    layout: 'fit',
						    items: [{
						         xtype: 'panel',
						         frame:true,
						         layout:'fit',
						         items: {
				                    xtype: 'imageview',
				                    src:'../js/extjs/icons/img',
				                    listeners: {
				                    	itemdblclick: function (view,record, item,index, e,eOpts) {
				                    	      console.debug(record);
				                    	}
				                    },
				                    trackOver: true
				                }
							}]
					    })
					   win.show();}
			

[
    {
        name: '添加用户',
        thumb: 'user_add.png',
        url: 'kitchensink',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
     {
        name: '添加用户',
        thumb: 'user_add.png',
        url: 'kitchensink',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
     {
        name: '添加用户',
        thumb: 'user_add.png',
        url: 'kitchensink',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
     {
        name: '添加用户',
        thumb: 'user_add.png',
        url: 'kitchensink',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    },
    {
        name: '删除用户',
        thumb: 'delete.png',
        url: 'twitter',
        type: 'Application'
    }
]

/*Sharera.system.util.ImageOragnizer的样式*/
.x-image-view{
    font: 11px Arial, Helvetica, sans-serif;
}
.x-image-view .thumb{
    padding:3px;
}

.x-image-view .thumb-wrap{
    float: left;
    margin: 4px;
    margin-right: 0;
    padding: 5px;
}
.x-image-view .thumb-wrap span{
    display: block;
    overflow: hidden;
    text-align: center;
    width: 76px; /* for ie to ensure that the text is centered */
}
.x-image-view .x-item-selected .thumb {
    background:#8db2e3;
}
.x-image-view .loading-indicator {
    font-size:8pt;
    background-repeat: no-repeat;
    background-position: left;
    padding-left:20px;
    margin:10px;
}


效果丑了点,不过也是可以实现功能

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值