1/* 2 * AJAX UPLOADER 3*/ 4 5 6function wppas_vbc_load_ajax_upload(ajaxurl, upload_folder){ 7 8jQuery(function($){ 9 10 var wppas_vbc_Upload = { 11 init:function () { 12 13 window.wppas_vbcUploadCount = typeof(window.vwppas_vbcUploadCount) == 'undefined' ? 0 : window.wppas_vbcUploadCount; 14 this.maxFiles = parseInt(wppas_vbc_upload.number); 15 16 //$('#wppas-vbc-upload-imagelist').on('click', 'a.action-delete', this.removeUploads); 17 $('body').on('click', '.wppas_img_remove', this.removeUploads); 18 19 this.attach(upload_folder); 20 this.hideUploader(); 21 }, 22 attach:function () { 23 // wordpress plupload if not found 24 if (typeof(plupload) === 'undefined') { 25 return; 26 } 27 28 if (wppas_vbc_upload.upload_enabled !== '1') { 29 return 30 } 31 32 var uploader = new plupload.Uploader(wppas_vbc_upload.plupload); 33 34 $('#wppas-vbc-uploader').on('click', function(e) { 35 //console.log(upload_folder); 36 uploader.settings.multipart_params["upload_folder"] = upload_folder; 37 uploader.start(); 38 39 // To prevent default behavior of a tag 40 e.preventDefault(); 41 }); 42 43 //initilize wp plupload 44 uploader.init(); 45 46 uploader.bind('FilesAdded', function (up, files) { 47 $.each(files, function (i, file) { 48 $('#wppas-vbc-upload-imagelist').append( 49 '<div id="' + file.id + '">' + 50 file.name + ' (' + plupload.formatSize(file.size) + ') <b></b>' + 51 '</div>'); 52 }); 53 54 up.refresh();
54 // Reposition Flash/Silverlight 55 uploader.start(); 56 }); 57 58 uploader.bind('UploadProgress', function (up, file) { 59 $('#' + file.id + " b").html(file.percent + "%"); 60 }); 61 62 // On error occur 63 uploader.bind('Error', function (up, err) { 64 $('#wppas-vbc-upload-imagelist').append("<div>Error: " + err.code + 65 ", Message: " + err.message + 66 (err.file ? ", File: " + err.file.name : "") + 67 "</div>" 68 ); 69 70 up.refresh(); // Reposition Flash/Silverlight 71 }); 72 73 uploader.bind('FileUploaded', function (up, file, response) { 74 var result = $.parseJSON(response.response); 75 $('#' + file.id).remove(); 76 77 console.log(result); 78 if (result.success) { 79 window.wppas_vbcUploadCount += 1; 80 81 if( result.type == 'image' ){ 82 $(this).wppas.add_image({'attachment':{'url': result.url, 'id': result.attach_id}}); 83 //$('#wppas-vbc-upload-imagelist ul').append(result.html); 84 }else if( result.type == 'zip' ){ 85 console.log(result.html); 86 $('#all_vbc_items').prepend(result.bnr_item); 87 $('.itm_edit_cont').hide(); 88 } 89 90 //wppas_vbc_Upload.hideUploader(); 91 } 92 }); 93 94 95 }, 96 97 hideUploader:function () { 98 99 if (wppas_vbc_Upload.maxFiles !== 0 && window.wppas_vbcUploadCount >= wppas_vbc_Upload.maxFiles) { 100 $('#wppas-vbc-uploader').hide(); 101 } 102 }, 103 104 removeUploads:function (e) { 105 e.preventDefault(); 106 107 if (confirm(wppas_vbc_upload.confirmMsg)) { 108 109 var el = $(this), 110 data = { 111 'attach_id':el.data('upload_id'), 112 'nonce':wppas_vbc_upload.remove, 113 'action':'wppas_vbc_delete' 114 }; 115 116 $.post(wppas_vbc_upload.ajaxurl, data, function () { 117 el.parent().remove(); 118 119 window.wppas_vbcUploadCount -= 1; 120 if (wppas_vbc_Upload.maxFiles !== 0 && window.wppas_vbcUploadCount < wppas_vbc_Upload.maxFiles) { 121 $('#wppas-vbc-uploader').show(); 122 } 123 }); 124 } 125 } 126 127 }; 128 129 wppas_vbc_Upload.init(); 130 131 132}); 133 134}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.