1 2/*//åå§åå¾çä¸ä¼ æ§ä»¶*/ 3function Set_drop_SecImageModal(dropid, inputid, typeInt) { 4 var dragImgUpload = new DragImgUpload("#" + dropid, { 5 callback: function (files) { 6 //åè°å½æ°ï¼å¯ä»¥ä¼ éç»åå°çç 7 var file = files[0]; 8 createFormDataAndLoad(file, '/api/fileupload/uploadfileAsync', 'file', typeInt, inputid); 9 } 10 }, $("#" + inputid).val()) 11} 12 13/*//inputæ§ä»¶æ¹åï¼å¯¹ä¸ä¼ å¾ççæ§ä»¶éé¢çå¾ç乿¹å*/ 14function Update_drop_SecImageModalForImageSec(dropid, inputid) { 15 $("#" + dropid).children("#preview").children("img").attr("src", $("#" + inputid).val()); 16 if ($("#" + inputid).val() == "") { 17 $("#" + dropid).children("#preview").children("img").attr("src", '/images/upload.png'); 18 } 19} 20 21function del_drop_SecImageModal(dropid, inputid) { 22 $("#" + dropid).children("#preview").children("img").attr("src", '/images/upload.png'); 23 $("#" + inputid).val(""); 24 25} 26function DragImgUpload(id, options, Thumbnail) { 27 this.me = $(id); 28 var defaultOpt = { 29 boxWidth: '100%', 30 boxHeight: 'auto' 31 } 32 if (Thumbnail == "") { 33 this.preview = $('<div id="preview"><img src="/images/upload.png" class="img-responsive" style="width: 100%;height: auto;" alt="" title=""> </div>'); 34 } 35 else { 36 this.preview = $('<div id="preview"><img src="' + Thumbnail + '" class="img-responsive" style="width: 100%;height: auto;" alt="" title=""> </div>'); 37 38 } 39 this.opts = $.extend(true, defaultOpt, { 40 }, options); 41 this.init(); 42 this.callback = this.opts.callback; 43} 44//å®ä¹ååæ¹æ³ 45DragImgUpload.prototype = { 46 init: function () { 47 this.me.append(this.preview); 48 this.me.append(this.fileupload); 49 this.cssInit(); 50 this.eventClickInit(); 51 }, 52 cssInit: function () { 53 this.me.css({ 54 'width': this.opts.boxWidth, 55 'height': this.opts.boxHeight, 56 'border': '0px solid #cccccc', 57 'padding': '10px', 58 'cursor': 'pointer' 59 }) 60 this.preview.css({ 61 'height': '100%', 62 'overflow': 'hidden' 63 }) 64 65 }, 66 onDragover: function (e) { 67 e.stopPropagation(); 68 e.preventDefault(); 69 e.dataTransfer.dropEffect = 'copy'; 70 }, 71 onDrop: function (e) { 72 var self = this; 73 e.stopPropagation(); 74 e.preventDefault(); 75 var fileList = e.dataTransfer.files; //è·åæä»¶å¯¹è±¡ 76 // do something upload 77 if (fileList.length == 0) { 78 return false; 79 } 80 //æ£æµæä»¶æ¯ä¸æ¯å¾ç 81 if (fileList[0].type.indexOf('image') === -1) { 82 alert("æ¨æç䏿¯å¾çï¼"); 83 return false; 84 } 85 86 //ææå¾çå°æµè§å¨ï¼å¯ä»¥å®ç°é¢è§åè½ 87 var img = window.URL.createObjectURL(fileList[0]); 88 var filename = fileList[0].name; //å¾çåç§° 89 var filesize = Math.floor((fileList[0].size) / 1024); 90 if (filesize > 5000) { 91 alert("ä¸ä¼ 大å°ä¸è½è¶ è¿5000K."); 92 return false; 93 } 94 95 self.me.find("img").attr("src", img); 96 self.me.find("img").attr("title", filename); 97 if (this.callback) { 98 this.callback(fileList); 99 } 100 }, 101 eventClickInit: function () { 102 var self = this; 103 this.me.unbind().click(function () { 104 self.createImageUploadDialog(); 105 }) 106 var dp = this.me[0]; 107 dp.addEventListener('dragover', function (e) { 108 self.onDragover(e); 109 }); 110 dp.addEventListener("drop", function (e) { 111 self.onDrop(e); 112 }); 113 114 115 }, 116 onChangeUploadFile: function () { 117 var fileInput = this.fileInput; 118 var files = fileInput.files; 119 120 if (files.length == 0) { 121 return false; 122 } 123 //æ£æµæä»¶æ¯ä¸æ¯å¾ç 124 if (files[0].type.indexOf('image') === -1) { 125 alert("æ¨éæ©ç䏿¯å¾çï¼"); 126 return false; 127 } 128 var file = files[0]; 129 var img = window.URL.createObjectURL(file); 130 var filename = file.name; 131 this.me.find("img").attr("src", img); 132 this.me.find("img").attr("title", filename); 133 if (this.callback) { 134 this.callback(files); 135 } 136 }, 137 createImageUploadDialog: function () { 138 var fileInput = this.fileInput; 139 if (!fileInput) { 140 //å建临æ¶inputå ç´ 141 fileInput = document.createElement('input'); 142 //设置input type为æä»¶ç±»å 143 fileInput.type = 'file'; 144 //设置æä»¶name 145 fileInput.name = 'ime-images'; 146 //å 许ä¸ä¼ å¤ä¸ªæä»¶ 147 fileInput.multiple = true; 148 fileInput.onchange = this.onChangeUploadFile.bind(this); 149 this.fileInput = fileInput; 150 } 151 //触åç¹å»inputç¹å»äºä»¶ï¼å¼¹åºéæ©æä»¶å¯¹è¯æ¡ 152 fileInput.click(); 153 } 154} 155 156 157function createFormDataAndLoad(image, actionUrl, ParameterName, upLoadFilePathType, urlinputid) { 158 159 var formImage = new FormData(); 160 formImage.append(ParameterName, image); 161 formImage.append("upLoadFilePathType", upLoadFilePathType); 162 uploadFormData(formImage, actionUrl, urlinputid); 163} 164function uploadFormData(formData, actionUrl, urlinputid) { 165 166 // upLoadFilePathType = 1 Article 167 // upLoadFilePathType = 2 userInfo 168 abp.ui.setBusy( 169 null, 170 abp.ajax({ 171 contentType: false, 172 url: actionUrl, 173 data: formData, 174 cache: false, 175 processData: false, 176 }).done(function (data) { 177 abp.notify.success('ä¸ä¼ å¾çæå'); 178 $("#" + urlinputid).val(data[0]); 179 //console.log($("#" + urlinputid).val()); 180 //abp.notify.info('a message text', 'optional title'); 181 //abp.notify.warn('a message text', 'optional title'); 182 //abp.notify.error('a message text', 'optional title'); 183 }) 184 ); 185 186} 187//ä¸ä¼ å¾çç»æ
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.