123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- //--------------------------------------------------------------右键菜单----------------------------------------------------------------------
- Namespace.register("U.MD.DK.RM"); //Disk的右键命名空间
- //#region 右键查看处理
- /**
- * 右键菜单弹出
- *
- **/
- U.MD.DK.RM.rightMenu = function (el, fileordir, diskinfo) {
- var _diskinfo = diskinfo || US.disk.UserDisk, //网盘信息
- _userid = _diskinfo.userInfo.UserId, //用户ID
- _fileordir = fileordir || U.Json.select(_diskinfo.directoryOrFiles, { "UserDirectoryID": _diskinfo.directoryid })[0], //右键的文件或者文件夹
- _permissions = U.MD.DK.C.getDirectoryPermissions(_fileordir.UserDirectoryID, _diskinfo), //获取操作的权限
- _rightel = $("#U_MD_DK_M", _diskinfo.formel)[0], //右键菜单
- _childel = $(_rightel).Child() //右键的菜单节点
- ;
- //打开权限的处理
- if (_permissions.isopen && fileordir) {
- _childel[0].style.display = "block";
- _childel[0].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.LE.openFileDirectory(fileordir, _userid); //打开文件或者文件夹
- };
- }
- else {
- _childel[0].style.display = "none";
- }
- //修改权限的处理 重命名
- if (_permissions.isupadte && fileordir) {
- _childel[1].style.display = "block";
- _childel[1].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.rename(el, fileordir, _diskinfo); //打开文件或者文件夹
- };
- }
- else {
- _childel[1].style.display = "none";
- }
- //删除权限的处理
- if (_permissions.isdelete && fileordir) {
- _childel[2].style.display = "block";
- _childel[2].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.deleteFileOrDir(fileordir, _userid); //删除文件或者文件夹
- }
- }
- else {
- _childel[2].style.display = "none";
- }
- //复制权限的处理
- if (_permissions.iscopy && fileordir) {
- _childel[3].style.display = "block";
- _childel[3].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.copyorshear(fileordir, "copy", _diskinfo); //复制文件或者文件夹
- }
- }
- else {
- _childel[3].style.display = "none";
- }
- //剪切权限的处理
- if (_permissions.isshear && fileordir) {
- _childel[4].style.display = "block";
- _childel[4].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.copyorshear(fileordir, "shear", _diskinfo); //剪贴文件或者文件夹
- }
- }
- else {
- _childel[4].style.display = "none";
- }
- //加密权限的处理
- if (_permissions.isencryption && fileordir) {
- _childel[5].style.display = "block";
- _childel[5].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.asynSetPermissions(fileordir);
- }
- }
- else {
- _childel[5].style.display = "none";
- }
- //下载权限的处理
- if (_permissions.isdownload && fileordir) {
- _childel[6].style.display = "block";
- _childel[6].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.downloadFile(fileordir.UserDirectoryID, fileordir.filetype == 0); //弹出下载的处理
- }
- }
- else {
- _childel[6].style.display = "none";
- }
- //新建权限的处理
- if (_permissions.isnew && !fileordir) {
- _childel[7].style.display = "block";
- _childel[8].style.display = "block";
- _childel[9].style.display = "block";
- _childel[10].style.display = "block";
- _childel[7].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newFolder(_diskinfo); //新建文件夹
- }
- _childel[8].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newText(_diskinfo); //新建txt文件
- }
- _childel[9].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newDocument(_diskinfo); //新建word文件
- }
- _childel[10].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.newExcel(_diskinfo); //新建excel文件
- }
- }
- else {
- _childel[7].style.display = "none";
- _childel[8].style.display = "none";
- _childel[9].style.display = "none";
- _childel[10].style.display = "none";
- }
- //评论权限的处理
- if (_permissions.isreply && !fileordir) {
- _childel[11].style.display = "block";
- _childel[11].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.replay(fileordir);
- }
- }
- else {
- _childel[11].style.display = "none";
- }
- //粘贴权限处理
- if (_permissions.ispaste && !fileordir) {
- _childel[12].style.display = "block";
- _childel[12].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.paste(_diskinfo); //粘贴函数
- }
- }
- else {
- _childel[12].style.display = "none";
- }
- //刷新权限处理
- if (_permissions.isrefresh && !fileordir) {
- _childel[13].style.display = "block";
- _childel[13].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.refresh(_userid, _fileordir, _diskinfo); //刷新函数
- }
- }
- else {
- _childel[13].style.display = "none";
- }
- //上传权限的处理
- if (_permissions.isupload && !fileordir) {
- _childel[14].style.display = "block";
- _childel[14].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.C.upload(_diskinfo); //文件上传
- }
- }
- else {
- _childel[14].style.display = "none";
- }
- //视图权限的处理
- if (_permissions.isview && !fileordir) {
- _childel[15].style.display = "block";
- _childel[16].style.display = "block";
- _childel[15].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.VW.viewsSwitch("Normal", _diskinfo); //普通视图
- }
- _childel[16].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.VW.viewsSwitch("Detailed", _diskinfo); //详细视图
- }
- }
- else {
- _childel[15].style.display = "none";
- _childel[16].style.display = "none";
- }
- //允许查看属性
- if (fileordir && _permissions.isopen) {
- _childel[17].style.display = "block";
- _childel[17].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.DK.RE.attribute(fileordir);
- }
- }
- else {
- _childel[17].style.display = "none";
- }
- //编辑权限的处理
- if (_permissions.isedit && US.disk.fileType.text.indexOf(_fileordir.UserDirectoryExtendType) > -1) {
- _childel[18].style.display = "block";
- _childel[18].onclick = function () {
- U.MD.DK.RM.hiddenRightMenu(_diskinfo); //隐藏右键菜单
- U.MD.D.I.openApplication("txt", _fileordir); //弹出应用处理
- }
- }
- else {
- _childel[18].style.display = "none";
- }
- //显示右键菜单
- _rightel.style.display = "block";
- if (_rightel.offsetHeight < 10) { //判断是否需要展开右键菜单的处理
- _rightel.style.display = "none"
- }
- else {
- //给右键菜单定位
- U.UF.C.rightClickMenuLocation(_rightel);
- }
- }
- /**
- * 隐藏右键菜单
- * @param {object} 网盘的值
- *
- **/
- U.MD.DK.RM.hiddenRightMenu = function (diskinfo) {
- $("#U_MD_DK_M", diskinfo.formel)[0].style.display = "none";
- }
- /**
- * 多文件右键菜单的显示
- * @param {object} 网盘的值
- *
- **/
- U.MD.DK.RM.getSelectionFilesOrDir = function (el) {
- // var i, _UCE = [];
- // for (i = 0; i < UDAD.length; i++) {
- // _UCE.push(UDAD[i].id);
- // };
- // return U.Json.Like(UGE, { "UserDirectoryID": _UCE.join(",") });
- }
- //#endregion
|