亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

webuploader模態(tài)框ueditor顯示問(wèn)題解決方法

asal 2017-01-13 15:20:44 650
abstrak:webuploader 模態(tài)框 ueditor 顯示問(wèn)題模態(tài)框z-index 對(duì)應(yīng)的值.modal {  z-index: 10050 !important;  outline: none !important; }遮罩層對(duì)應(yīng)的z-index值.modal-backdrop {  border: 0

webuploader 模態(tài)框 ueditor 顯示問(wèn)題

模態(tài)框z-index 對(duì)應(yīng)的值

.modal {
 z-index: 10050 !important;
 outline: none !important;
}

遮罩層對(duì)應(yīng)的z-index值

.modal-backdrop {
 border: 0 !important;
 outline: none !important;
 z-index: 10049 !important;
}

ueditor 插件中,默認(rèn)的z-index值為900 ;

在模態(tài)框中使用ueditor,可能會(huì)出現(xiàn)不兼容的情況,在ueditor.config.js里面修改z-index值,要比父級(jí)結(jié)構(gòu)要大,否則,字體相關(guān)的下拉框還是會(huì)顯示異常,也可以覆蓋原來(lái)的z-index對(duì)應(yīng)的樣式,

.edui-default{
 z-index: 30111 !important;
}

webupload 百度的上傳插件,如果在模態(tài)框中使用,會(huì)出現(xiàn)點(diǎn)擊無(wú)反應(yīng)的情況,搜索得之,解決方式是在模態(tài)框顯示時(shí)調(diào)用shown.bs.modal 方法去初始化webuploader實(shí)例, 但結(jié)局就是每次顯示模態(tài)框都會(huì)導(dǎo)致選擇文件的按鈕越來(lái)越大。 

以下是方式:

var $list=$("#thelist"); //這幾個(gè)初始化全局的百度文檔上沒(méi)說(shuō)明,好蛋疼。
 var $btn =$("#ctlBtn"); //開(kāi)始上傳
 var thumbnailWidth = 100; //縮略圖高度和寬度 (單位是像素),當(dāng)寬高度是0~1的時(shí)候,是按照百分比計(jì)算,具體可以看api文檔
 var thumbnailHeight = 100;
 $("#upload_pic").modal('show');
 
 $("#upload_pic").on("shown.bs.modal",function(){
  uploader = WebUploader.create({
   // 選完文件后,是否自動(dòng)上傳。
   auto: false,
   // swf文件路徑
   swf: base+'/statics/js/webUploader/Uploader.swf',
   // 文件接收服務(wù)端。
   server: base + '/upload/uploadImg',
   // 選擇文件的按鈕??蛇x。
   // 內(nèi)部根據(jù)當(dāng)前運(yùn)行是創(chuàng)建,可能是input元素,也可能是flash.
   pick: '#filePicker',
   // 只允許選擇圖片文件。
   accept: {
    title: 'Images',
    extensions: 'gif,jpg,jpeg,bmp,png',
    mimeTypes: 'image/*'
   },
   method:'POST',
  });
  // 當(dāng)有文件添加進(jìn)來(lái)的時(shí)候
  uploader.on( 'fileQueued', function( file ) { // webuploader事件.當(dāng)選擇文件后,文件被加載到文件隊(duì)列中,觸發(fā)該事件。等效于 uploader.onFileueued = function(file){...} ,類似js的事件定義。
   var $li = $(
     '<div id="' + file.id + '" class="file-item thumbnail">' +
     '<img>' +
     '<div class="info">' + file.name + '</div>' +
     '</div>'
    ),
    $img = $li.find('img');
   // $list為容器jQuery實(shí)例
   $list.append( $li );
 
   // 創(chuàng)建縮略圖
   // 如果為非圖片文件,可以不用調(diào)用此方法。
   // thumbnailWidth x thumbnailHeight 為 100 x 100
   uploader.makeThumb( file, function( error, src ) { //webuploader方法
    if ( error ) {
     $img.replaceWith('<span>不能預(yù)覽</span>');
     return;
    }
 
    $img.attr( 'src', src );
   }, thumbnailWidth, thumbnailHeight );
  });
  // 文件上傳過(guò)程中創(chuàng)建進(jìn)度條實(shí)時(shí)顯示。
  uploader.on( 'uploadProgress', function( file, percentage ) {
   var $li = $( '#'+file.id ),
    $percent = $li.find('.progress span');
   // 避免重復(fù)創(chuàng)建
   if ( !$percent.length ) {
    $percent = $('<p class="progress"><span></span></p>')
     .appendTo( $li )
     .find('span');
   }
   $percent.css( 'width', percentage * 100 + '%' );
  });
 
  // 文件上傳成功,給item添加成功class, 用樣式標(biāo)記上傳成功。
  uploader.on( 'uploadSuccess', function( file ) {
   $( '#'+file.id ).addClass('upload-state-done');
  });
  // 文件上傳失敗,顯示上傳出錯(cuò)。
  uploader.on( 'uploadError', function( file ) {
   var $li = $( '#'+file.id ),
    $error = $li.find('div.error');
   // 避免重復(fù)創(chuàng)建
   if ( !$error.length ) {
    $error = $('<div class="error"></div>').appendTo( $li );
   }
 
   $error.text('上傳失敗');
  });
 
  // 完成上傳完了,成功或者失敗,先刪除進(jìn)度條。
  uploader.on( 'uploadComplete', function( file ) {
   $( '#'+file.id ).find('.progress').remove();
  });
 });
 
 $btn.on( 'click', function() {
  uploader.upload();
 });

   

解決每次點(diǎn)擊顯示modal導(dǎo)致上傳按鈕變大的方式為覆蓋由webuploader 生成的上傳按鈕樣式

.webuploader-pick{
 padding: 0 !important;
 width: 82px !important;
 height: 38px !important;
 line-height: 38px !important;
}

更多關(guān)于webuploader模態(tài)框ueditor顯示問(wèn)題解決方法請(qǐng)關(guān)注PHP中文網(wǎng)(ipnx.cn)其他文章!   


Nota Keluaran

Penyertaan Popular