Source: tool/ImageSelector.js

/*
 * redmicro all Copyright (c) 
 * Created by seeker910 on 2015/6/30.
 * 图片选择器
 */
Rsd.define('Rsd.tool.ImageSelector', {
    extend: 'Rsd.container.Dialog',
    requires: [
        'Rsd.widget.AlbumsViewer'
    ],
    xtype: 'image-selector',
    border: false,
    title: '图片选择',
    height: 800,
    width: "80%", 
    layout: 'vbox',
    items: [
        {
            "name": "albums",
            xtype: "list-view",
            label:{
                visible:false,
                //content:'已选择',
                //position:'left',
                //space:0,
                //style:{fontSize:'150%',borderBottom:'1px grey solid'}
            },
            height: 100, 
            width:'100%',
            //style:{backgroundColor: 'aliceblue'},
            itemXtype: 'image',
            itemDblClick:'albumsItemDblClick',
            itemStyle: { marginLeft:5,width: 70, height: 85} 
        }, 
        {
            "name": "images",
            xtype: "albums-viewer", 
            readOnly:true,
            label:{
               // content:'图片列表',
                position:'top',
                space:0,
                style:{
                    textAlign:'left',
                    fontSize: '150%',
                    color: '#151ac3',
                    letterSpacing: '2px',
                    borderBottom:'1px grey solid'
                }
            },
            width:'100%',
            flex: 1,   
            imageDblClick:'imageDblClick', 
            newImageHandler:'newImage',
        }
    ],
    /**
     * 
     */
    services:{
        getAlbumList:"",//'global.merch.album.GetAlbumList'
        saveAlbum:"",//'global.merch.album.SaveAlbum'
        deleteAlbum:"",//'global.merch.album.DeleteAlbum'
        getImageList:""//'global.merch.image.GetImageList'
    },
    /**
     * 支持多选
     */
    multiple:false,
    /**
     * 
     */
    constructor: function ImageSelector(config) {
        config = config || {};
        this.apply(config);
        if(!this.services)
        {
            Rsd.alert('缺少services配置信息');
        }
        this.items[0].height = this.multiple?100:0;
        this.items[1].services = this.services;
    },
    /**
     * 
     */
    load: function load() {
        var me = this;
        me.items[1].loadData();
    },
    
    /**
     * @description 双击图片表示 选择该图片
     * @param {*} item 
     * @param {*} evt 
     */
    imageDblClick: function (item, evt) {
        if(this.multiple)
        {
            //向已选择区添加照片
        }
        else
        {
            this.funApplyByIOC(this.callback, [item, evt]);
            this.close();
        }
        
    },
    newImage:function newImage()
    {
        Rsd.popup('btn_add_image');
    } 
});