<%
  import org.exoplatform.clouddrive.CloudDrive
  import org.exoplatform.clouddrive.CloudFile
  import org.exoplatform.wcm.webui.reader.ContentReader
  
	// should be set in CloudFileFilter
  def drive = uicomponent.drive
  def file = uicomponent.file
  if (drive && file) {
    def title = ContentReader.getXSSCompatibilityContent(file.title)
    def serviceName = drive.user.serviceName
    def openOn = _ctx.appRes("CloudFileViewer.event.OpenOn")
%>
<div id="CloudFileViewer" file-open-on="${openOn} ${serviceName}" style="position: relative; height: 100%; overflow: hidden;">
  <div style="text-align:center; display: none;" class="file-content">
    <a rel="tooltip" data-placement="bottom" title="$title" onclick="javascript:window.open('$file.link');" style="cursor:pointer">
    	<img src="$file.previewLink" style="overflow: hidden; max-width: 100%; height: auto;"/>
    </a>
  </div>
<%
  } else {%>
		<p>Cannot load cloud file viewer. Refresh the page.</p>
<%}%>
</div>
