RightMenu.js 9.1 KB

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