{"action":"created","issue":{"url":"https://api.github.com/repos/fex-team/webuploader/issues/955","labels_url":"https://api.github.com/repos/fex-team/webuploader/issues/955/labels{/name}","comments_url":"https://api.github.com/repos/fex-team/webuploader/issues/955/comments","events_url":"https://api.github.com/repos/fex-team/webuploader/issues/955/events","html_url":"https://github.com/fex-team/webuploader/issues/955","id":76559271,"number":955,"title":"bootstrap弹窗上绑定pick按钮或者追加按钮都需要F12一下才能使用。如果不使用bootstrap直接使用页面做上传就没有这个问题。可能是两个插件有兼容问题。怎么解决","user":{"login":"TimeTao","id":12453892,"avatar_url":"https://avatars.githubusercontent.com/u/12453892?v=3","gravatar_id":"","url":"https://api.github.com/users/TimeTao","html_url":"https://github.com/TimeTao","followers_url":"https://api.github.com/users/TimeTao/followers","following_url":"https://api.github.com/users/TimeTao/following{/other_user}","gists_url":"https://api.github.com/users/TimeTao/gists{/gist_id}","starred_url":"https://api.github.com/users/TimeTao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TimeTao/subscriptions","organizations_url":"https://api.github.com/users/TimeTao/orgs","repos_url":"https://api.github.com/users/TimeTao/repos","events_url":"https://api.github.com/users/TimeTao/events{/privacy}","received_events_url":"https://api.github.com/users/TimeTao/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-15T02:16:48Z","updated_at":"2015-08-02T17:18:26Z","closed_at":null,"body":"jQuery(function() {\r\n    var $ = jQuery,    // just in case. Make sure it's not an other libaray.\r\n    \tpage = this,\r\n    \t//文件上传后的路径    \tkey为file id \r\n    \tfilePageArray = {},\r\n    \t$myModal = $('#myModal'),\r\n    \tmyModalHtml = $myModal.html(),\r\n\t\t$btnShowModal = $('.btnShowModal');\r\n\t\t$btnShowModal.click(function(){\r\n\t\t\t$('#myModal').modal({\r\n \t\t    \tkeyboard: true\r\n\t\t    });\r\n\t\t\tpage.init();\r\n\t\t    //alert(\"a\");\r\n\t\t});\r\n\tthis.init = function(){\r\n\t\t\t//弹窗初始化\r\n\t\t\t$myModal.html(myModalHtml);\r\n\t\t \tvar $wrap = $('#uploader'),\r\n\r\n\t        // 文件容器\r\n\t        $queue = $('<ul class=\"wenjianList clearfix\"></ul>')\r\n\t            .appendTo( $wrap.find('.queueList') ),\r\n\t        \r\n\t\r\n\t        // 状态栏，包括进度和控制按钮\r\n\t        $statusBar = $wrap.find('.statusBar'),\r\n\t\r\n\t        // 文件总体选择信息。\r\n\t        $info = $statusBar.find('.info'),\r\n\t\r\n\t        // 上传按钮\r\n\t        $upload = $wrap.find('.uploadBtn'),\r\n\t\r\n\t        // 没选择文件之前的内容。\r\n\t        $placeHolder = $wrap.find('.placeholder'),\r\n\t\r\n\t        // 总体进度条\r\n\t        $progress = $statusBar.find('.progress').hide(),\r\n\t\r\n\t        // 添加的文件数量\r\n\t        fileCount = 0,\r\n\t\r\n\t        // 添加的文件总大小\r\n\t        fileSize = 0,\r\n\t\r\n\t        // 优化retina, 在retina下这个值是2\r\n\t        ratio = window.devicePixelRatio || 1,\r\n\t\r\n\t        // 可能有pedding, ready, uploading, confirm, done.\r\n\t        state = 'pedding',\r\n\t\r\n\t        // 所有文件的进度信息，key为file id\r\n\t        percentages = {},\r\n\t\r\n\t        supportTransition = (function(){\r\n\t            var s = document.createElement('p').style,\r\n\t                r = 'transition' in s ||\r\n\t                      'WebkitTransition' in s ||\r\n\t                      'MozTransition' in s ||\r\n\t                      'msTransition' in s ||\r\n\t                      'OTransition' in s;\r\n\t            s = null;\r\n\t            return r;\r\n\t        })();\r\n\t\r\n\t        // WebUploader实例\r\n\t        uploader;\r\n\t\r\n\t    if ( !WebUploader.Uploader.support() ) {\r\n\t        alert( 'Web Uploader 不支持您的浏览器！如果你使用的是IE浏览器，请尝试升级 flash 播放器');\r\n\t        throw new Error( 'WebUploader does not support the browser you are using.' );\r\n\t    }\r\n\t\r\n\t    // 实例化\r\n\t    uploader = WebUploader.create({\r\n\t        pick: {\r\n\t            id: '#filePicker',\r\n\t            label: '点击选择文件'\r\n\t        },\r\n\t        dnd: '#uploader .queueList',\r\n\t        paste: document.body,\r\n\t\r\n\t        accept: {\r\n\t            title: 'Files',\r\n\t           // extensions: 'gif,jpg,jpeg,bmp,png',\r\n\t            mimeTypes: 'file/*'\r\n\t        },\r\n\t\r\n\t        // swf文件路径\r\n\t        swf: 'webuploader/Uploader.swf',\r\n\t\r\n\t        disableGlobalDnd: true,\r\n\t\r\n\t        chunked: false,\r\n\t        server: '/uploadFileAttachAjax',\r\n\t        fileNumLimit: 12,\r\n\t        fileSizeLimit: 2000 * 1024 * 1024,    // 2G\r\n\t        fileSingleSizeLimit: 100 * 1024 * 1024    // 100 M\r\n\t    });\r\n\t\r\n\t    // 添加“添加文件”的按钮，\r\n\t    uploader.addButton({\r\n\t        id: '#filePicker2',\r\n\t        label: '继续添加'\r\n\t    });\r\n\t\r\n\t    uploader.on( 'uploadSuccess', function( file ,data) {\r\n\t\t\tfilePageArray[ file.id ] = [data.obj];\r\n\t\t    //$( '#'+file.name ).find('p.state').text('已上传');\r\n\t\t});\r\n\t\t\r\n\t\tuploader.on( 'uploadError', function( file  ) {\r\n\t\t\t//alert(file.name+'上传出错');\r\n\t\t});\r\n\t    uploader.on( 'uploadComplete', function( file ) {\r\n\t\t   // $( '#'+file.id ).find('.progress').fadeOut();\r\n\t\t});\r\n\t\t\r\n\t    // 当有文件添加进来时执行，负责view的创建\r\n\t    function addFile( file ) {\r\n\t        var $li = $( '<li id=\"' + file.id + '\">' +\r\n\t                '<p>' + file.name + ' <em>('+ WebUploader.formatSize( file.size ) +')</em> </p>'+\r\n\t                '<p class=\"progress\"><span></span></p>' +\r\n\t                '</li>' ),\r\n\t\r\n\t            $btns = $('<div class=\"file-panel\">' +\r\n\t                '<span class=\"cancel\">删除</span></div>').appendTo( $li ),\r\n\t            $prgress = $li.find('p.progress span'),\r\n\t            $wrap = $li.find( 'p.imgWrap' ),\r\n\t            $info = $('<p class=\"error\"></p>'),\r\n\t\r\n\t            showError = function( code ) {\r\n\t                switch( code ) {\r\n\t                    case 'exceed_size':\r\n\t                        text = '文件大小超出';\r\n\t                        break;\r\n\t\r\n\t                    case 'interrupt':\r\n\t                        text = '上传暂停';\r\n\t                        break;\r\n\t\r\n\t                    default:\r\n\t                        text = '上传失败，请重试';\r\n\t                        break;\r\n\t                }\r\n\t\r\n\t                $info.text( text ).appendTo( $li );\r\n\t            };\r\n\t\r\n\t        if ( file.getStatus() === 'invalid' ) {\r\n\t            showError( file.statusText );\r\n\t        } else {\r\n\t\r\n\t            percentages[ file.id ] = [ file.size, 0 ];\r\n\t            file.rotation = 0;\r\n\t        }\r\n\t\r\n\t        file.on('statuschange', function( cur, prev ) {\r\n\t            if ( prev === 'progress' ) {\r\n\t                $prgress.hide().width(0);\r\n\t            } else if ( prev === 'queued' ) {\r\n\t                $li.off( 'mouseenter mouseleave' );\r\n\t                $btns.remove();\r\n\t            }\r\n\t\r\n\t            // 成功\r\n\t            if ( cur === 'error' || cur === 'invalid' ) {\r\n\t                console.log( file.statusText );\r\n\t                showError( file.statusText );\r\n\t                percentages[ file.id ][ 1 ] = 1;\r\n\t            } else if ( cur === 'interrupt' ) {\r\n\t                showError( 'interrupt' );\r\n\t            } else if ( cur === 'queued' ) {\r\n\t                percentages[ file.id ][ 1 ] = 0;\r\n\t            } else if ( cur === 'progress' ) {\r\n\t                $info.remove();\r\n\t                $prgress.css('display', 'block');\r\n\t            } else if ( cur === 'complete' ) {\r\n\t                $li.append( '<span class=\"success\"></span>' );\r\n\t            }\r\n\t\t\t\t\r\n\t            $li.removeClass( 'state-' + prev ).addClass( 'state-' + cur );\r\n\t        });\r\n\t\r\n\t\r\n\t        $btns.on( 'click', 'span', function() {\r\n\t            var index = $(this).index(),\r\n\t                deg;\r\n\t\r\n\t            switch ( index ) {\r\n\t                case 0:\r\n\t                    uploader.removeFile( file );\r\n\t                    return;\r\n\t\r\n\t                case 1:\r\n\t                    file.rotation += 90;\r\n\t                    break;\r\n\t\r\n\t                case 2:\r\n\t                    file.rotation -= 90;\r\n\t                    break;\r\n\t            }\r\n\t\r\n\t            if ( supportTransition ) {\r\n\t                deg = 'rotate(' + file.rotation + 'deg)';\r\n\t                $wrap.css({\r\n\t                    '-webkit-transform': deg,\r\n\t                    '-mos-transform': deg,\r\n\t                    '-o-transform': deg,\r\n\t                    'transform': deg\r\n\t                });\r\n\t            } else {\r\n\t                $wrap.css( 'filter', 'progid:DXImageTransform.Microsoft.BasicImage(rotation='+ (~~((file.rotation/90)%4 + 4)%4) +')');\r\n\t            }\r\n\t\r\n\t\r\n\t        });\r\n\t\r\n\t        $li.appendTo( $queue );\r\n\t        if(fileCount == 1){\r\n\t       \t\t $('#uploader').find('#dndArea').css('display', 'none'); \r\n\t       \t\t// $('#uploader').find('#statusBar').css('display', 'black');\r\n\t       \t\t $statusBar.show();\r\n\t        }\r\n\t       \r\n\t    }\r\n\t\r\n\t    // 负责view的销毁\r\n\t    function removeFile( file ) {\r\n\t    \t\r\n\t        var $li = $('#'+file.id);\r\n\t\r\n\t        delete percentages[ file.id ];\r\n\t        updateTotalProgress();\r\n\t        $li.off().find('.file-panel').off().end().remove();\r\n\t        \r\n\t    }\r\n\t\r\n\t    function updateTotalProgress() {\r\n\t        var loaded = 0,\r\n\t            total = 0,\r\n\t            spans = $progress.children(),\r\n\t            percent;\r\n\t\r\n\t        $.each( percentages, function( k, v ) {\r\n\t            total += v[ 0 ];\r\n\t            loaded += v[ 0 ] * v[ 1 ];\r\n\t        } );\r\n\t\r\n\t        percent = total ? loaded / total : 0;\r\n\t\r\n\t        spans.eq( 0 ).text( Math.round( percent * 100 ) + '%' );\r\n\t        spans.eq( 1 ).css( 'width', Math.round( percent * 100 ) + '%' );\r\n\t        updateStatus();\r\n\t    }\r\n\t\r\n\t    function updateStatus() {\r\n\t        var text = '', stats;\r\n\t\r\n\t        if ( state === 'ready' ) {\r\n\t            text = '选中' + fileCount + '个文件，共' +\r\n\t                    WebUploader.formatSize( fileSize ) + '。';\r\n\t        } else if ( state === 'confirm' ) {\r\n\t            stats = uploader.getStats();\r\n\t            if ( stats.uploadFailNum ) {\r\n\t                text = '已成功上传' + stats.successNum+ '个文件至服务器，'+\r\n\t                    stats.uploadFailNum + '个文件上传失败，<a class=\"retry\" href=\"#\">重新上传</a>失败文件或<a class=\"ignore\" href=\"#\">忽略</a>'\r\n\t            }\r\n\t\r\n\t        } else {\r\n\t            stats = uploader.getStats();\r\n\t            text = '共' + fileCount + '个文件（' +\r\n\t                    WebUploader.formatSize( fileSize )  +\r\n\t                    '），已上传' + stats.successNum + '个文件';\r\n\t\r\n\t            if ( stats.uploadFailNum ) {\r\n\t                text += '，失败' + stats.uploadFailNum + '个文件';\r\n\t            }\r\n\t        }\r\n\t\r\n\t        $info.html( text );\r\n\t    }\r\n\t\r\n\t    function setState( val ) {\r\n\t        var file, stats;\r\n\t\r\n\t        if ( val === state ) {\r\n\t            return;\r\n\t        }\r\n\t\r\n\t        $upload.removeClass( 'state-' + state );\r\n\t        $upload.addClass( 'state-' + val );\r\n\t        state = val;\r\n\t\r\n\t        switch ( state ) {\r\n\t            case 'pedding':\r\n\t                $placeHolder.removeClass( 'element-invisible' );\r\n\t                $queue.parent().removeClass('filled');\r\n\t                $queue.hide();\r\n\t                $statusBar.addClass( 'element-invisible' );\r\n\t                uploader.refresh();\r\n\t                break;\r\n\t\r\n\t            case 'ready':\r\n\t                $placeHolder.addClass( 'element-invisible' );\r\n\t                $( '#filePicker2' ).removeClass( 'element-invisible');\r\n\t                $queue.parent().addClass('filled');\r\n\t                $queue.show();\r\n\t                $statusBar.removeClass('element-invisible');\r\n\t                uploader.refresh();\r\n\t                break;\r\n\t\r\n\t            case 'uploading':\r\n\t                $( '#filePicker2' ).addClass( 'element-invisible' );\r\n\t                $progress.show();\r\n\t                $upload.text( '暂停上传' );\r\n\t                break;\r\n\t\r\n\t            case 'paused':\r\n\t                $progress.show();\r\n\t                $upload.text( '继续上传' );\r\n\t                break;\r\n\t\r\n\t            case 'confirm':\r\n\t                $progress.hide();\r\n\t                $upload.text( '开始上传' ).addClass( 'disabled' );\r\n\t\r\n\t                stats = uploader.getStats();\r\n\t                if ( stats.successNum && !stats.uploadFailNum ) {\r\n\t                    setState( 'finish' );\r\n\t                    return;\r\n\t                }\r\n\t                break;\r\n\t            case 'finish':\r\n\t                stats = uploader.getStats();\r\n\t                if ( stats.successNum ) {\r\n\t                \talert('文件地址对象：'+filePageArray);\r\n\t                    //alert( '上传成功' );\r\n\t                } else {\r\n\t                    // 没有成功的文件，重设\r\n\t                    state = 'done';\r\n\t                    location.reload();\r\n\t                }\r\n\t                break;\r\n\t        }\r\n\t\r\n\t        updateStatus();\r\n\t    }\r\n\t\r\n\t    uploader.onUploadProgress = function( file, percentage ) {\r\n\t        var $li = $('#'+file.id),\r\n\t            $percent = $li.find('.progress span');\r\n\t\r\n\t        $percent.css( 'width', percentage * 100 + '%' );\r\n\t        percentages[ file.id ][ 1 ] = percentage;\r\n\t        updateTotalProgress();\r\n\t    };\r\n\t\r\n\t    uploader.onFileQueued = function( file ) {\r\n\t        fileCount++;\r\n\t        fileSize += file.size;\r\n\t\r\n\t        if ( fileCount === 1 ) {\r\n\t            $placeHolder.addClass( 'element-invisible' );\r\n\t            $statusBar.show();\r\n\t        }\r\n\t\r\n\t        addFile( file );\r\n\t        setState( 'ready' );\r\n\t        updateTotalProgress();\r\n\t    };\r\n\t\r\n\t    uploader.onFileDequeued = function( file ) {\r\n\t        fileCount--;\r\n\t        fileSize -= file.size;\r\n\t\r\n\t        if ( !fileCount ) {\r\n\t            setState( 'pedding' );\r\n\t        }\r\n\t\t\tif(fileCount == 0){\r\n\t       \t\t $('#uploader').find('#dndArea').css('display', 'block'); \r\n\t       \t\t $statusBar.hide();\r\n\t        }\r\n\t        removeFile( file );\r\n\t        updateTotalProgress();\r\n\t\r\n\t    };\r\n\t\r\n\t    uploader.on( 'all', function( type ) {\r\n\t        var stats;\r\n\t        switch( type ) {\r\n\t            case 'uploadFinished':\r\n\t                setState( 'confirm' );\r\n\t                break;\r\n\t\r\n\t            case 'startUpload':\r\n\t                setState( 'uploading' );\r\n\t                break;\r\n\t\r\n\t            case 'stopUpload':\r\n\t                setState( 'paused' );\r\n\t                break;\r\n\t\r\n\t        }\r\n\t    });\r\n\t\r\n\t    uploader.onError = function( code ) {\r\n\t    \tif(code == 'F_DUPLICATE'){\r\n\t\t        alert( 'Eroor: ' + '文件选择重复' );\r\n\t    \t}else if(code == 'Q_EXCEED_NUM_LIMIT'){\r\n\t    \t\talert( 'Eroor: ' + '文件数量已达上限' );\r\n\t    \t}else if(code == 'Q_EXCEED_NUM_LIMIT'){\r\n\t    \t\talert( 'Eroor: ' + '文件数量已达上限' );\r\n\t    \t}else if(code == 'F_EXCEED_SIZE'){\r\n\t    \t\talert( 'Eroor: ' + '文件大小超出限制' );\r\n\t    \t}else if(code == 'Q_EXCEED_SIZE_LIMIT'){\r\n\t    \t\talert( 'Eroor: ' + '文件总容量超过限制' );\r\n\t    \t}else{\r\n\t    \t\talert( 'Eroor: ' + code );\r\n\t    \t}\r\n\t    };\r\n\t\r\n\t    // 文件上传过程中创建进度条实时显示。\r\n\t\tuploader.on( 'uploadProgress', function( file, percentage ) {\r\n\t\t    var $li = $( '#'+file.id ),\r\n\t\t        $percent = $li.find('.progress .progress-bar');\r\n\t\t\r\n\t\t    // 避免重复创建\r\n\t\t    if ( !$percent.length ) {\r\n\t\t        $percent = $('<div class=\"progress progress-striped active\">' +\r\n\t\t          '<div class=\"progress-bar\" role=\"progressbar\">0%' +\r\n\t\t          '</div>' +\r\n\t\t        '</div>').appendTo( $li ).find('.progress-bar');\r\n\t\t    }\r\n\t\t\r\n\t\t    $li.find('p.state').text('上传中');\r\n\t\t\t$percent.text( percentage * 100 + '%' );\r\n\t\t\t\r\n\t\t\tpercentages[ file.id ][ 1 ] = percentage;\r\n\t\t\t\r\n\t\t    updateTotalProgress();\r\n\t\t});\r\n\t\t\r\n\t    $upload.on('click', function() {\r\n\t    \tif(fileCount == 0){\r\n\t    \t\t$info.text(\"请选择文件\");\r\n\t    \t}else{\r\n\t    \t\t if ( $(this).hasClass( 'disabled' ) ) {\r\n\t\t            return false;\r\n\t\t        }\r\n\t\t\r\n\t\t        if ( state === 'ready' ) {\r\n\t\t            uploader.upload();\r\n\t\t            $wrap.find(\".btns\").html(\"\");\r\n\t\t        } else if ( state === 'paused' ) {\r\n\t\t            uploader.upload();\r\n\t\t        } else if ( state === 'uploading' ) {\r\n\t\t            uploader.stop();\r\n\t\t        }\r\n\t    \t}\r\n\t    });\r\n\t\r\n\t    $info.on( 'click', '.retry', function() {\r\n\t        uploader.retry();\r\n\t    } );\r\n\t\r\n\t    $info.on( 'click', '.ignore', function() {\r\n\t    \t$('#myModal').modal({\r\n \t\t    \tkeyboard: false\r\n\t\t    });\r\n\t    } );\r\n\t\r\n\t    $upload.addClass( 'state-' + state );\r\n\t    updateTotalProgress();\r\n\t}\r\n   \r\n});"},"comment":{"url":"https://api.github.com/repos/fex-team/webuploader/issues/comments/127046838","html_url":"https://github.com/fex-team/webuploader/issues/955#issuecomment-127046838","issue_url":"https://api.github.com/repos/fex-team/webuploader/issues/955","id":127046838,"user":{"login":"499978920","id":4010342,"avatar_url":"https://avatars.githubusercontent.com/u/4010342?v=3","gravatar_id":"","url":"https://api.github.com/users/499978920","html_url":"https://github.com/499978920","followers_url":"https://api.github.com/users/499978920/followers","following_url":"https://api.github.com/users/499978920/following{/other_user}","gists_url":"https://api.github.com/users/499978920/gists{/gist_id}","starred_url":"https://api.github.com/users/499978920/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/499978920/subscriptions","organizations_url":"https://api.github.com/users/499978920/orgs","repos_url":"https://api.github.com/users/499978920/repos","events_url":"https://api.github.com/users/499978920/events{/privacy}","received_events_url":"https://api.github.com/users/499978920/received_events","type":"User","site_admin":false},"created_at":"2015-08-02T17:18:26Z","updated_at":"2015-08-02T17:18:26Z","body":"设置picker的元素样式宽高试试"}}