Changeset 6073 for trunk/library/ckeditor/plugins
- Timestamp:
- 05/02/12 17:02:36 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/library/ckeditor/plugins/expresso/plugin.js
r5984 r6073 99 99 }); 100 100 function bindFileUpload(e) { 101 102 103 104 105 var maxAttachmentSise = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false;101 var ID = currentTab; 102 var newImageId = new Date().getTime(); 103 var fileUploadIMG = $('#fileupload_img'+ID); 104 var fileUploadMSG = $('#fileupload_msg'+ID); 105 var maxAttachmentSize = (preferences.max_attachment_size !== "" && preferences.max_attachment_size != 0) ? (parseInt(preferences.max_attachment_size.replace('M', '')) * 1048576 ) : false; 106 106 fileUploadIMG.fileupload({ 107 sequentialUploads: true, 107 type: 'post', 108 dataType : 'json', 109 url: "../prototype/post.php", 110 forceIframeTransport: true, 111 formData: function(form) { 112 return [ 113 { 114 name : "mailAttachment[0][source]", 115 value : "files0" 116 }, 117 { 118 name : "mailAttachment[0][disposition]", 119 value : $('#attDisposition'+ID).val() 120 }, 121 { 122 name: "MAX_FILE_SIZE", 123 value : maxAttachmentSize 124 } 125 ]; 126 }, 108 127 add: function (e, data) { 109 128 110 if(!maxAttachmentSi se || data.files[0].size < maxAttachmentSise) {129 if(!maxAttachmentSize || data.files[0].size < maxAttachmentSize) { 111 130 setTimeout(function() { 112 131 $('#attDisposition'+ID).val('embedded'); … … 124 143 attach.fileName = file.name.substr(0, 18) + "..." + file.name.substr(file.name.length-9, file.name.length); 125 144 attach.fileSize = formatBytes(file.size); 126 if(maxAttachmentSi se && file.size > maxAttachmentSise)145 if(maxAttachmentSize && file.size > maxAttachmentSize) 127 146 attach.error = 'Tamanho de arquivo nao permitido!!' 128 147 129 148 fileUploadMSG.find('.attachments-list').append(DataLayer.render("../prototype/modules/mail/templates/attachment_add_itemlist.ejs", {file : attach})); 130 149 131 if(!maxAttachmentSi se || file.size < maxAttachmentSise){150 if(!maxAttachmentSize || file.size < maxAttachmentSize){ 132 151 fileUploadMSG.find(' .fileinput-button.new').append(data.fileInput[0]).removeClass('new'); 133 152 fileUploadMSG.find(' .attachments-list').find('[type=file]').addClass('hidden'); … … 168 187 done: function(e, data){ 169 188 if(!!data.result && data.result != "[]"){ 170 var newAttach = jQuery.parseJSON(data.result); 171 172 //Compatibilidade com Firefox3.6 173 if(newAttach === null ) newAttach = jQuery.parseJSON(data.result.text()); 174 175 if(newAttach.rollback !== false) 176 { 177 fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>').find('.status-upload').addClass('ui-icon ui-icon-check'); 178 addAttachment(ID,newAttach['mailAttachment'][0][0].id); 179 var content_body = RichTextEditor.getData('body_'+ID); 180 var rex = new RegExp('<img id="'+newImageId+'" src="" [^\/>]*\/>', 'i'); 181 var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />'; 182 content_body = content_body.replace(rex,newImg); 183 RichTextEditor.setData('body_'+ID,content_body); 184 } 185 else 186 fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error'); 187 189 var newAttach = data.result; 190 if(!newAttach.mailAttachment.error){ 191 if(newAttach.rollback !== false) 192 { 193 fileUploadMSG.find('.in-progress:first').parents('p').append('<input type="hidden" name="fileId[]" value="'+newAttach['mailAttachment'][0][0].id+'"/>').find('.status-upload').addClass('ui-icon ui-icon-check'); 194 addAttachment(ID,newAttach['mailAttachment'][0][0].id); 195 var content_body = RichTextEditor.getData('body_'+ID); 196 var rex = new RegExp('<img id="'+newImageId+'" src="" [^\/>]*\/>', 'i'); 197 var newImg = '<img src="../prototype/getArchive.php?mailAttachment='+newAttach['mailAttachment'][0][0].id+'" />'; 198 content_body = content_body.replace(rex,newImg); 199 RichTextEditor.setData('body_'+ID,content_body); 200 } 201 else 202 fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error'); 203 }else{ 204 fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append(newAttach.mailAttachment.error).addClass('message-attach-error'); 205 } 188 206 }else { 189 207 fileUploadMSG.find('.in-progress:first').parents('p').find('.status-upload').append('Erro ao fazer upload!').addClass('message-attach-error');
Note: See TracChangeset
for help on using the changeset viewer.