RightMenu.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //--------------------------------------------------------------右键菜单----------------------------------------------------------------------
  2. Namespace.register("U.MD.DK.RM"); //Disk的右键命名空间
  3. //#region 右键查看处理
  4. /**
  5. * 右键菜单弹出
  6. *
  7. **/
  8. U.MD.DK.RM.rightMenu = function (el, fileordir, diskinfo) {
  9. var _diskinfo = diskinfo || US.disk.UserDisk, //网盘信息
  10. _userid = _diskinfo.userInfo.UserId, //用户ID
  11. _fileordir = fileordir || U.Json.select(_diskinfo.directoryOrFiles, { "UserDirectoryID": _diskinfo.directoryid })[0], //右键的文件或者文件夹
  12. _permissions = U.MD.DK.C.getDirectoryPermissions(_fileordir.UserDirectoryID, _diskinfo), //获取操作的权限
  13. _rightel = $("#U_MD_DK_M", _diskinfo.formel)[0], //右键菜单
  14. _childel = $(_rightel).Child() //右键的菜单节点
  15. ;
  16. //打开权限的处理
  17. if (_permissions.isopen && fileordir) {
  18. _childel[0].style.display = "block";
  19. _childel[0].onclick = function () {
  20. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  21. U.MD.DK.LE.openFileDirectory(fileordir, _userid); //打开文件或者文件夹
  22. };
  23. }
  24. else {
  25. _childel[0].style.display = "none";
  26. }
  27. //修改权限的处理 重命名
  28. if (_permissions.isupadte && fileordir) {
  29. _childel[1].style.display = "block";
  30. _childel[1].onclick = function () {
  31. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  32. U.MD.DK.RE.rename(el, fileordir, _diskinfo); //打开文件或者文件夹
  33. };
  34. }
  35. else {
  36. _childel[1].style.display = "none";
  37. }
  38. //删除权限的处理
  39. if (_permissions.isdelete && fileordir) {
  40. _childel[2].style.display = "block";
  41. _childel[2].onclick = function () {
  42. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  43. U.MD.DK.RE.deleteFileOrDir(fileordir, _userid); //删除文件或者文件夹
  44. }
  45. }
  46. else {
  47. _childel[2].style.display = "none";
  48. }
  49. //复制权限的处理
  50. if (_permissions.iscopy && fileordir) {
  51. _childel[3].style.display = "block";
  52. _childel[3].onclick = function () {
  53. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  54. U.MD.DK.RE.copyorshear(fileordir, "copy", _diskinfo); //复制文件或者文件夹
  55. }
  56. }
  57. else {
  58. _childel[3].style.display = "none";
  59. }
  60. //剪切权限的处理
  61. if (_permissions.isshear && fileordir) {
  62. _childel[4].style.display = "block";
  63. _childel[4].onclick = function () {
  64. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  65. U.MD.DK.RE.copyorshear(fileordir, "shear", _diskinfo); //剪贴文件或者文件夹
  66. }
  67. }
  68. else {
  69. _childel[4].style.display = "none";
  70. }
  71. //加密权限的处理
  72. if (_permissions.isencryption && fileordir) {
  73. _childel[5].style.display = "block";
  74. _childel[5].onclick = function () {
  75. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  76. U.MD.DK.RE.asynSetPermissions(fileordir);
  77. }
  78. }
  79. else {
  80. _childel[5].style.display = "none";
  81. }
  82. //下载权限的处理
  83. if (_permissions.isdownload && fileordir) {
  84. _childel[6].style.display = "block";
  85. _childel[6].onclick = function () {
  86. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  87. U.MD.DK.RE.downloadFile(fileordir.UserDirectoryID, fileordir.filetype == 0); //弹出下载的处理
  88. }
  89. }
  90. else {
  91. _childel[6].style.display = "none";
  92. }
  93. //新建权限的处理
  94. if (_permissions.isnew && !fileordir) {
  95. _childel[7].style.display = "block";
  96. _childel[8].style.display = "block";
  97. _childel[9].style.display = "block";
  98. _childel[10].style.display = "block";
  99. _childel[7].onclick = function () {
  100. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  101. U.MD.DK.RE.newFolder(_diskinfo); //新建文件夹
  102. }
  103. _childel[8].onclick = function () {
  104. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  105. U.MD.DK.RE.newText(_diskinfo); //新建txt文件
  106. }
  107. _childel[9].onclick = function () {
  108. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  109. U.MD.DK.RE.newDocument(_diskinfo); //新建word文件
  110. }
  111. _childel[10].onclick = function () {
  112. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  113. U.MD.DK.RE.newExcel(_diskinfo); //新建excel文件
  114. }
  115. }
  116. else {
  117. _childel[7].style.display = "none";
  118. _childel[8].style.display = "none";
  119. _childel[9].style.display = "none";
  120. _childel[10].style.display = "none";
  121. }
  122. //评论权限的处理
  123. if (_permissions.isreply && !fileordir) {
  124. _childel[11].style.display = "block";
  125. _childel[11].onclick = function () {
  126. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  127. U.MD.DK.RE.replay(fileordir);
  128. }
  129. }
  130. else {
  131. _childel[11].style.display = "none";
  132. }
  133. //粘贴权限处理
  134. if (_permissions.ispaste && !fileordir) {
  135. _childel[12].style.display = "block";
  136. _childel[12].onclick = function () {
  137. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  138. U.MD.DK.RE.paste(_diskinfo); //粘贴函数
  139. }
  140. }
  141. else {
  142. _childel[12].style.display = "none";
  143. }
  144. //刷新权限处理
  145. if (_permissions.isrefresh && !fileordir) {
  146. _childel[13].style.display = "block";
  147. _childel[13].onclick = function () {
  148. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  149. U.MD.DK.RE.refresh(_userid, _fileordir, _diskinfo); //刷新函数
  150. }
  151. }
  152. else {
  153. _childel[13].style.display = "none";
  154. }
  155. //上传权限的处理
  156. if (_permissions.isupload && !fileordir) {
  157. _childel[14].style.display = "block";
  158. _childel[14].onclick = function () {
  159. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  160. U.MD.DK.C.upload(_diskinfo); //文件上传
  161. }
  162. }
  163. else {
  164. _childel[14].style.display = "none";
  165. }
  166. //视图权限的处理
  167. if (_permissions.isview && !fileordir) {
  168. _childel[15].style.display = "block";
  169. _childel[16].style.display = "block";
  170. _childel[15].onclick = function () {
  171. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  172. U.MD.DK.VW.viewsSwitch("Normal", _diskinfo); //普通视图
  173. }
  174. _childel[16].onclick = function () {
  175. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  176. U.MD.DK.VW.viewsSwitch("Detailed", _diskinfo); //详细视图
  177. }
  178. }
  179. else {
  180. _childel[15].style.display = "none";
  181. _childel[16].style.display = "none";
  182. }
  183. //允许查看属性
  184. if (fileordir && _permissions.isopen) {
  185. _childel[17].style.display = "block";
  186. _childel[17].onclick = function () {
  187. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  188. U.MD.DK.RE.attribute(fileordir);
  189. }
  190. }
  191. else {
  192. _childel[17].style.display = "none";
  193. }
  194. //编辑权限的处理
  195. if (_permissions.isedit && US.disk.fileType.text.indexOf(_fileordir.UserDirectoryExtendType) > -1) {
  196. _childel[18].style.display = "block";
  197. _childel[18].onclick = function () {
  198. U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
  199. U.MD.D.I.openApplication("txt", _fileordir); //弹出应用处理
  200. }
  201. }
  202. else {
  203. _childel[18].style.display = "none";
  204. }
  205. //显示右键菜单
  206. _rightel.style.display = "block";
  207. if (_rightel.offsetHeight < 10) { //判断是否需要展开右键菜单的处理
  208. _rightel.style.display = "none"
  209. }
  210. else {
  211. //给右键菜单定位
  212. U.UF.C.rightClickMenuLocation(_rightel);
  213. }
  214. }
  215. /**
  216. * 隐藏右键菜单
  217. * @param {object} 网盘的值
  218. *
  219. **/
  220. U.MD.DK.RM.hiddenRightMenu = function (diskinfo) {
  221. $("#U_MD_DK_M", diskinfo.formel)[0].style.display = "none";
  222. }
  223. /**
  224. * 多文件右键菜单的显示
  225. * @param {object} 网盘的值
  226. *
  227. **/
  228. U.MD.DK.RM.getSelectionFilesOrDir = function (el) {
  229. // var i, _UCE = [];
  230. // for (i = 0; i < UDAD.length; i++) {
  231. // _UCE.push(UDAD[i].id);
  232. // };
  233. // return U.Json.Like(UGE, { "UserDirectoryID": _UCE.join(",") });
  234. }
  235. //#endregion