viewcardfiles.html.php 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php if($files):?>
  2. <?php $sessionString = session_name() . '=' . session_id();?>
  3. <?php if($fieldset == 'true'):?>
  4. <div class="detail">
  5. <div class="detail-title"><?php echo $lang->marketreport->report;?> <i class="icon icon-paper-clip icon-sm"></i></div>
  6. <div class="detail-content">
  7. <?php endif;?>
  8. <style>
  9. .file {padding-top: 2px;}
  10. ul.files-list {margin-bottom: unset}
  11. .files-list>li>a {display: inline; word-wrap: break-word;}
  12. .files-list>li>.right-icon {opacity: 1;}
  13. .fileAction {color: #0c64eb !important;}
  14. .renameFile {display: flex;}
  15. .renameFile .icon {margin-top: 8px;}
  16. .renameFile .input-group-addon {width: 60px;}
  17. .backgroundColor {background: #eff5ff; }
  18. .right-icon .btn {padding: 0 6px;}
  19. </style>
  20. <script>
  21. $(document).ready(function()
  22. {
  23. $('.item').mouseover(function()
  24. {
  25. $(this).find('div span.right-icon').removeClass("invisible");
  26. $(this).addClass('backgroundColor');
  27. });
  28. $('.item').mouseout(function()
  29. {
  30. $(this).find('div span.right-icon').addClass("invisible");
  31. $(this).removeClass('backgroundColor');
  32. });
  33. });
  34. /**
  35. * Delete a file.
  36. *
  37. * @param int $fileID
  38. * @param object $obj
  39. * @access public
  40. * @return void
  41. */
  42. function deleteFile(fileID, obj)
  43. {
  44. if(!fileID) return;
  45. <?php if($showDelete and $method == 'edit'):?>
  46. $('<input />').attr('type', 'hidden').attr('name', 'deleteFiles[' + fileID + ']').attr('value', fileID).appendTo('ul.files-list');
  47. $(obj).closest('li.file').addClass('hidden');
  48. <?php else:?>
  49. hiddenwin.location.href = createLink('file', 'delete', 'fileID=' + fileID);
  50. <?php endif;?>
  51. }
  52. /**
  53. * Download a file, append the mouse to the link. Thus we call decide to open the file in browser no download it.
  54. *
  55. * @param int $fileID
  56. * @param int $extension
  57. * @param int $imageWidth
  58. * @param string $fileTitle
  59. * @param string $type download|preview
  60. * @access public
  61. * @return void
  62. */
  63. function downloadFile(fileID, extension, imageWidth, fileTitle, type = 'download')
  64. {
  65. if(!fileID) return;
  66. var fileTypes = 'txt,jpg,jpeg,gif,png,bmp';
  67. var windowWidth = $(window).width();
  68. var width = (windowWidth > imageWidth) ? ((imageWidth < windowWidth * 0.5) ? windowWidth * 0.5 : imageWidth) : windowWidth;
  69. var checkExtension = fileTitle.lastIndexOf('.' + extension) == (fileTitle.length - extension.length - 1);
  70. var url = createLink('file', type, 'fileID=' + fileID + '&mouse=left');
  71. url += url.indexOf('?') >= 0 ? '&' : '?';
  72. url += '<?php echo $sessionString;?>';
  73. if(fileTypes.indexOf(extension) >= 0 && checkExtension && config.onlybody != 'yes')
  74. {
  75. $('<a>').modalTrigger({url: url, type: 'iframe', width: width}).trigger('click');
  76. }
  77. else
  78. {
  79. url = url.replace('?onlybody=yes&', '?');
  80. url = url.replace('?onlybody=yes', '?');
  81. url = url.replace('&onlybody=yes', '');
  82. window.open(url, '_blank');
  83. }
  84. return false;
  85. }
  86. /* Show edit box for editing file name. */
  87. /**
  88. * Show edit box for editing file name.
  89. *
  90. * @param int $fileID
  91. * @access public
  92. * @return void
  93. */
  94. function showRenameBox(fileID)
  95. {
  96. $('#renameFile' + fileID).closest('li').addClass('hidden');
  97. $('#renameBox' + fileID).closest('li').removeClass('hidden');
  98. }
  99. /**
  100. * Show File.
  101. *
  102. * @param int $fileID
  103. * @access public
  104. * @return void
  105. */
  106. function showFile(fileID)
  107. {
  108. $('#renameBox' + fileID).closest('li').addClass('hidden');
  109. $('#renameFile' + fileID).closest('li').removeClass('hidden');
  110. }
  111. /**
  112. * Smooth refresh file name.
  113. *
  114. * @param int $fileID
  115. * @access public
  116. * @return void
  117. */
  118. function setFileName(fileID)
  119. {
  120. var fileName = $('#fileName' + fileID).val();
  121. var extension = $('#extension' + fileID).val();
  122. var postData = {'fileName' : fileName, 'extension' : extension};
  123. $.ajax(
  124. {
  125. url:createLink('file', 'edit', 'fileID=' + fileID),
  126. dataType: 'json',
  127. method: 'post',
  128. data: postData,
  129. success: function(data)
  130. {
  131. var fileName = data['title'];
  132. var fileTitle = fileName.substring(0, fileName.lastIndexOf('.'));
  133. $('#fileTitle' + fileID).html(fileName);
  134. $('#cardContent' + fileID).html(fileTitle);
  135. $('#renameFile' + fileID).closest('li').removeClass('hidden');
  136. $('#renameBox' + fileID).closest('li').addClass('hidden');
  137. },
  138. error: function(data)
  139. {
  140. if(data.status == 200) $('#showError').html(data.responseText);
  141. }
  142. })
  143. }
  144. </script>
  145. <?php include './viewfiles.html.php';?>
  146. <?php if($fieldset == 'true'):?>
  147. </div>
  148. </div>
  149. <?php endif;?>
  150. <?php endif;?>