浏览代码

Customer portal : Preview for attachments

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@4093 a333f486-631f-4898-b8df-5754b55c2be0
glajarige 9 年之前
父节点
当前提交
d1918d4b4a
共有 1 个文件被更改,包括 24 次插入8 次删除
  1. 24 8
      sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php

+ 24 - 8
sources/renderer/bootstrap/fieldrenderer/bsfileuploadfieldrenderer.class.inc.php

@@ -97,7 +97,7 @@ class BsFileUploadFieldRenderer extends FieldRenderer
 					}
 					else
 					{
-						var sDownloadLink = '{$this->oField->GetDownloadEndpoint()}'.replace(/-sAttId-/, data.result.att_id);
+						var sDownloadLink = '{$this->oField->GetDownloadEndpoint()}'.replace(/-sAttachmentId-/, data.result.att_id);
 
 						$(this).closest('.fileupload_field_content').find('.attachments_container').append(
 							'<div class="attachment col-xs-6 col-sm-3 col-md-2" id="display_attachment_'+data.result.att_id+'">'+
@@ -109,15 +109,22 @@ class BsFileUploadFieldRenderer extends FieldRenderer
 							'	<input type="button" class="btn btn-xs btn-danger hidden" value="{$sDeleteBtn}"/>'+
 							'</div>'
 						);
-
+						// Preview tooltip
+						if(data.result.preview){
+							$('#display_attachment_'+data.result.att_id).tooltip({
+								html: true,
+								title: function(){ return '<img src="'+sDownloadLink+'" style="max-width: 100%;" />'; }
+							});
+						}
+						// Showing remove button on hover
+						$('#display_attachment_'+data.result.att_id).hover( function(){
+							$(this).children(':button').toggleClass('hidden');
+						});
+						// Remove button handler
 						$('#display_attachment_'+data.result.att_id+' :button').click(function(oEvent){
 							oEvent.preventDefault();
 							RemoveAttachment(data.result.att_id);
 						});
-
-						$('#display_attachment_'+data.result.att_id).hover( function(){
-							$(this).children(':button').toggleClass('hidden');
-						});
 					}
 				},
 				start: function() {
@@ -136,12 +143,21 @@ class BsFileUploadFieldRenderer extends FieldRenderer
 					});
 				}
 			});
-			
+
+
+			// Preview tooltip
+			$('.attachment [data-preview="true"]').each(function(iIndex, oElem){
+				$(oElem).parent().tooltip({
+					html: true,
+					title: function(){ return '<img src="'+$(oElem).attr('href')+'" style="max-width: 100%;" />'; }
+				});
+			});
+			// Remove button handler
 			$('.attachments_container .attachment :button').click(function(oEvent){
 				oEvent.preventDefault();
 				RemoveAttachment($(this).closest('.attachment').find(':input[name="attachments[]"]').val());
 			});
-
+			// Remove button showing
 			if($sIsDeleteAllowed)
 			{
 				$('.attachment').hover( function(){