webuploader不能在ie11浏览器拖拽文件

发布于 2022-09-06 23:21:23 字数 4060 浏览 17 评论 0

问题1:
webuploader插件的【继续添加】按钮点击后,弹出文件框后,不能拖拽文件,但是谷歌可以拖拽。

代码:
-------webuploader.js------

define('lib/filepicker',[
    'base',
    'runtime/client',
    'lib/file'
], function( Base, RuntimeClient, File ) {

    var $ = Base.$;

    function FilePicker( opts ) {
        opts = this.options = $.extend({}, FilePicker.options, opts );

        opts.container = $( opts.id );

        if ( !opts.container.length ) {
            throw new Error('按钮指定错误');
        }

        opts.innerHTML = opts.innerHTML || opts.label ||
                opts.container.html() || '';

        opts.button = $( opts.button || document.createElement('div') );
        opts.button.html( opts.innerHTML );
        opts.container.html( opts.button );

        RuntimeClient.call( this, 'FilePicker', true );
    }

    FilePicker.options = {
        button: null,
        container: null,
        label: null,
        innerHTML: null,
        multiple: true,
        accept: null,
        name: 'file',
        style: 'webuploader-pick'   //pick element class attribute, default is "webuploader-pick"
    };

    Base.inherits(RuntimeClient, {
        constructor: FilePicker,

        init: function() {
            var me = this,
                opts = me.options,
                button = opts.button,
                style = opts.style;

            if (style)
                button.addClass('webuploader-pick');

            me.on( 'all', function( type ) {
                var files;

                switch ( type ) {
                    case 'mouseenter':
                        if (style)
                            button.addClass('webuploader-pick-hover');
                        break;

                    case 'mouseleave':
                        if (style)
                            button.removeClass('webuploader-pick-hover');
                        break;

                    case 'change':
                        files = me.exec('getFiles');
                        me.trigger( 'select', $.map( files, function( file ) {
                            file = new File( me.getRuid(), file );

                            // 记录来源。
                            file._refer = opts.container;
                            return file;
                        }), opts.container );
                        break;
                }
            });

            me.connectRuntime( opts, function() {
                me.refresh();
                me.exec( 'init', opts );
                me.trigger('ready');
            });

            this._resizeHandler = Base.bindFn( this.refresh, this );
            $( window ).on( 'resize', this._resizeHandler );
        },

        refresh: function() {
            var shimContainer = this.getRuntime().getContainer(),
                button = this.options.button,
                width = button.outerWidth ?
                        button.outerWidth() : button.width(),

                height = button.outerHeight ?
                        button.outerHeight() : button.height(),

                pos = button.offset();

            width && height && shimContainer.css({
                bottom: 'auto',
                right: 'auto',
                width: width + 'px',
                height: height + 'px'
            }).offset( pos );
        },

        enable: function() {
            var btn = this.options.button;

            btn.removeClass('webuploader-pick-disable');
            this.refresh();
        },

        disable: function() {
            var btn = this.options.button;

            this.getRuntime().getContainer().css({
                top: '-99999px'
            });

            btn.addClass('webuploader-pick-disable');
        },

        destroy: function() {
            var btn = this.options.button;
            $( window ).off( 'resize', this._resizeHandler );
            btn.removeClass('webuploader-pick-disable webuploader-pick-hover ' +
                'webuploader-pick');
        }
    });

    return FilePicker;
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文