showfiles.ui.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. window.searchTitle = function()
  2. {
  3. const searchTitle = $('#featureBar .searchBox input[name=title]').val();
  4. loadPage(searchLink.replace('%s', searchTitle));
  5. }
  6. $(document).on('keypress', '#featureBar .searchBox #title', function(e)
  7. {
  8. if(e.keyCode == 13) loadPage(searchLink.replace('%s', $(this).val()));
  9. });
  10. window.renderCell = function(result, {col, row})
  11. {
  12. if(col.name == 'title')
  13. {
  14. let titleHtml = '';
  15. let titleClass = '';
  16. if(imageExtensionList.includes(row.data.extension))
  17. {
  18. titleClass = 'file-name';
  19. titleHtml += `<div style='display: inline-block'><img width='16' src='${row.data.webPath}' data-extension='${row.data.extension}' data-id='${row.data.id}' data-width='${row.data.imageWidth}'/></div>`;
  20. }
  21. else
  22. {
  23. titleHtml += row.data.fileIcon;
  24. }
  25. titleHtml += `<span class='ml-1 ${titleClass}'>${row.data.fileName}</span>`;
  26. result[0] = {html: titleHtml};
  27. return result;
  28. }
  29. if(col.name == 'objectID')
  30. {
  31. const sourceAttr = row.data.objectType != 'doc' ? " data-toggle='modal' data-size='lg'" : '';
  32. const objectLink = $.createLink(row.data.objectType == 'requirement' ? 'story' : row.data.objectType, 'view', `objectID=${row.data.objectID}`);
  33. const sourceHtml = `<span>${row.data.objectName}</span><a title='${row.data.sourceName}' href='${objectLink}' ${sourceAttr}> ${row.data.sourceName}</a>`;
  34. result[0] = {html: sourceHtml};
  35. return result;
  36. }
  37. if(col.name == 'size')
  38. {
  39. result[0] = {html: row.data.sizeText};
  40. return result;
  41. }
  42. return result;
  43. }
  44. window.downloadFile = function(fileID, extension, imageWidth)
  45. {
  46. if(!fileID) return;
  47. var windowWidth = $(window).width();
  48. var url = $.createLink('file', 'download', 'fileID=' + fileID + '&mouse=left');
  49. url += url.includes('?') ? '&' : '?';
  50. url += `'${sessionString}'`;
  51. width = (windowWidth > imageWidth) ? ((imageWidth < windowWidth * 0.5) ? windowWidth * 0.5 : imageWidth) : windowWidth;
  52. loadModal(url);
  53. return false;
  54. }
  55. $(document).off('click', '#actionBar .btn.export').on('click', '#actionBar .btn.export', function()
  56. {
  57. const dtable = zui.DTable.query($('#table-doc-showfiles'));
  58. if(!$('#table-doc-showfiles').length) return;
  59. const checkedList = dtable.$.getChecks();
  60. $.cookie.set('checkedItem', checkedList, {expires:config.cookieLife, path:config.webRoot});
  61. });