Changeset 1131 in main


Ignore:
Timestamp:
05/29/12 08:06:46 (7 years ago)
Author:
zali
Message:

file check-in fixed. Input file disable when the upload is launch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/openPLM/media/js/file.js

    r1126 r1131  
    1414    var input = $("<input type='file' name='filename"+num+"' id='id_filename"+num+"'/ >"); 
    1515    input.change(function(){ 
    16         /*var f_name = this.files[0].name; 
    17         if(can_add_file(f_name)){ 
    18             $(".up_fail").remove(); 
    19             $("span.warning").remove(); 
    20             add_file(this); 
    21         }*/ 
    2216        if(at_least_one(this)){ 
    2317            $(".up_fail").remove(); 
     
    216210        $("#div_files > div").remove(); 
    217211    } 
    218  
    219    /* //create line where the progress of the upload will be display for this input 
    220     var f_name = input.value; 
    221     if(f_name.substr(0, 12) == "C:\\fakepath\\"){ 
    222         f_name=f_name.substr(12); 
    223     } 
    224     var key= f_name.replace(".","_"); 
    225     var size = input.files[0].size; 
    226     var mod_2 = nbr_files%2; 
    227     var file_line = $("<div id='"+key+"' class='file_p'><span>"+input.files[0].name+"("+render_size(size)+")</span></div>"); 
    228     var progress = $("<span class='progress'><span class='text'></span></span>"); 
    229     file_line.append(progress); 
    230  
    231     //create link to delete this file from the queue for upload 
    232     var link = $("<span class='del_link'> </span>"); 
    233     link.click(function(){ 
    234             del_file(file_line,input); 
    235     }); 
    236     var del_img = "<img src='/media/img/trash_can1.png' alt='delete' title='"+trans["remove the file from the queue"]+"'>"; 
    237     link.append(del_img); 
    238     file_line.append(link); 
    239     //add the file in the list of files to upload 
    240     $("#div_files").append(file_line);*/ 
    241212    $.each(input.files,function(ind,f){ 
    242213        add_f_file(input,f); 
    243214    }) 
    244215    if($("#fileupload").attr("action")=="."){ 
    245         //add_in_queue_form(input); 
    246         //$(input).parent().parent().hide(); 
    247         //if($.browser.opera){ 
    248             add_in_queue_form(input); 
    249         /*}else{ 
    250             hide(input); 
    251         }*/ 
     216        add_in_queue_form(input); 
    252217        new_input_file(); 
    253218    } 
    254     /*nbr_files+=1; 
     219} 
     220 
     221function check_in_file(input){ 
     222    var f = input.files[0]; 
     223    var key = f.name.replace(".","_"); 
     224    var size=f.size; 
     225 
     226    //create line for file progress 
     227    var file_line = $("<div id='"+key+"' class='file_p'>"+f.name+"("+render_size(size)+") "+"</div>"); 
     228    var progress = $("<span class='progress'><span class='text'></span></span>"); 
     229    file_line.append(progress); 
     230 
     231    //create link to delete this file from the queue for upload 
     232    var link = $("<span class='del_link'> </span>"); 
     233    link.click(function(){ 
     234        del_file(file_line,input); 
     235    }); 
     236    var del_img = "<img src='/media/img/trash_can1.png' alt='delete' title='"+trans["remove the file from the queue"]+"'>"; 
     237    link.append(del_img); 
     238    file_line.append(link); 
     239 
     240    //add the file in the list of files to upload 
     241    $("#div_files").append(file_line); 
     242 
    255243    var f_id = gen_uuid(); 
    256     //create an object related to the file in the files_info array-like 
    257     files_info[key]={"f_name":f_name, "p_id":f_id, "size":size, "uploaded":0, "status":"waiting"};*/ 
     244             
     245    if(($.browser.opera!=true)&&($.browser.msie!=true)){ 
     246    /*var data_key = "filename"; 
     247    if(nbr_files!=0){ 
     248        data_key+=nbr_files; 
     249    } 
     250    data.append(data_key,f);*/ 
     251      
     252        //create an object related to the file in the files_info array-like 
     253        files_info[key]={"field_name":" ", "f_name":f.name, "p_id":f_id, "size":size, "uploaded":0, "status":"waiting"}; 
     254    }else{ 
     255        files_info[key]={"f_name":f.name, "p_id":f_id, "size":size, "uploaded":0, "status":"waiting"}; 
     256    } 
     257                   
     258    nbr_files+=1; 
    258259} 
    259260 
     
    264265 
    265266//delete a file from list and form which contains files to upload 
    266 /*function del_file(item,input){ 
    267     var key = item.attr("id"); 
    268     files_info = files_info.remove(key); 
    269     item.remove(); 
    270     $(input).remove(); 
    271     nbr_files--; 
    272     $(".up_fail").remove(); 
    273 }*/ 
     267 
    274268function del_file(item,input){ 
    275269    var key = item.attr("id"); 
     
    498492 
    499493function upload_failed(){ 
     494    clearTimeout(t); 
    500495    var fail_div = $("<div class='up_fail'></div>"); 
    501496    var span_text=trans["Your upload(s) failed"]+"!<br>"+trans["Try again"]; 
     
    505500        span_text+=". "; 
    506501    } 
    507     span_text+="<br/>"+xhr.responseText; 
    508502    fail_div.append(span_text); 
    509503    $("#fileupload").after(fail_div); 
     
    512506    $(".del_link").show(); 
    513507    $("#global").remove(); 
    514     clearTimeout(t); 
     508    $("#fileupload").find("input[type='file']").removeAttr("disabled"); 
     509    $("#_up").show(); 
     510    $("#_delete").show(); 
    515511} 
    516512//launch and track progress of upload file in the form f_form 
     
    552548            var x=document.getElementById("hidden_frame"); 
    553549            var y=(x.contentWindow || x.contentDocument); 
    554             if(y.document) 
     550            if(y.document){ 
    555551                y=y.document; 
    556              
     552            } 
    557553            if($(y).find("body").text()!=""){ 
    558554                if($(y).find("body").text()=="."){ 
     
    592588*/ 
    593589function reset_upload(){ 
    594     $("a.del_link").click(); 
     590    $(".del_link").click(); 
    595591    nbr_files=0; 
    596592    num_file=0; 
    597     files_info = files_info.removeAll(); 
     593    //files_info = files_info.removeAll(); 
    598594    var table = $("#fileupload > table.Content"); 
    599595    $("#fileupload > table.Content tr:first").remove(); 
     
    612608         }else{ 
    613609             $(".up_fail").remove(); 
    614              add_file(this); 
     610             check_in_file(this); 
    615611         } 
    616612    }); 
     
    619615    var tr_input = $("<tr><th><label for='id_filename'>Filename:</label></th></tr>"); 
    620616    tr_input.append(td_input); 
    621     table.prepend(tr_input);  
     617    table.prepend(tr_input); 
    622618} 
    623619 
     
    721717            global_prog.append("<span class='progress'><span class='text'></span></span>"); 
    722718            $("#fileupload").after(global_prog); 
    723             $("#_delete").hide(); 
    724719            $(".del_link").hide(); 
    725720            $(".progress .text").text("0% (waiting)"); 
     
    731726                up_file($("#fileupload")[0]); 
    732727            } 
     728            $("#fileupload").find("input[type='file']").attr("disabled","disabled"); 
     729            $("#_delete").hide(); 
     730            $("#_up").hide(); 
    733731        }); 
    734732    }else{ 
Note: See TracChangeset for help on using the changeset viewer.