From 4fc60c13e7a3c4322d9028b119e19743d5fd65d3 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Sun, 2 Mar 2014 15:05:03 -0800 Subject: [PATCH] ability to change the permissions of multiple through the right click menu implemented --- .../images/MMCCicon_edit_permission_black.png | Bin 0 -> 620 bytes .../Jit/graphsettings-event-handlers.js | 72 ++++++++++++++++++ app/assets/stylesheets/application.css | 39 +++++++++- 3 files changed, 108 insertions(+), 3 deletions(-) create mode 100644 app/assets/images/MMCCicon_edit_permission_black.png diff --git a/app/assets/images/MMCCicon_edit_permission_black.png b/app/assets/images/MMCCicon_edit_permission_black.png new file mode 100644 index 0000000000000000000000000000000000000000..e87d006e5a3bf51f61eb49a20bc0621ae7ae37d7 GIT binary patch literal 620 zcmV-y0+aoTP)wsr)8c+$KHVyj)rr@N-8nANp z*u>yMgG&!nE0XUfK+k&T2|u@rU4ZuS0Ri4Bg34_=M0leJ3IPoPywoe2kqS`J!xQWR zRnL!sFbSsplamP08`lNCGmKT4L{kZt^^aU`-Y-F{5(>xuz32BQ zU5<mDc=^TziSI_GWAMCOz$0DduZA3?y6X{AFJ@DKJ0Ghdl5yV5|x$0O#N zTe_4PY%1PNSBs6ypjH7;qzOamTR6ZM^AZ5FuE0JjF5NohR5ySLgWJ%|JVO*Bho=<4 z0#7A?4gMwy>1dPBHg_93{7n=>s4PjN4M!9zS!W)354?N2To3{j{AI7gDLFFyRsp-i zZxIj#ysv;@;K%$m-Hqx?)zZ>m{W{WzbozPz*<'; + } menustring += ''; rightclickmenu.innerHTML = menustring; @@ -96,6 +104,13 @@ function selectEdgeOnRightClickHandler(adj, e) { hideSelectedEdges(); hideSelectedNodes(); }); + + // change the permission of all the selected nodes and synapses that you were the originator of + $('.rc-permission li').click(function() { + $('.rightclickmenu').remove(); + // $(this).text() will be 'commons' 'public' or 'private' + updateSelectedPermissions( $(this).text() ); + }); } //selectEdgeOnRightClickHandler @@ -236,6 +251,14 @@ function selectNodeOnClickHandler(node, e) { if (!mapid) menustring += '
  • Center This Topic
  • '; menustring += '
  • Open In New Tab
  • '; + if (userid) { + var options = '
    • commons
    • \ +
    • public
    • \ +
    • private
    • \ +
    '; + + menustring += '
  • Change permissions' + options + '
  • '; + } menustring += ''; rightclickmenu.innerHTML = menustring; @@ -293,6 +316,13 @@ function selectNodeOnClickHandler(node, e) { var win=window.open('/topics/' + node.id, '_blank'); win.focus(); }); + + // change the permission of all the selected nodes and synapses that you were the originator of + $('.rc-permission li').click(function() { + $('.rightclickmenu').remove(); + // $(this).text() will be 'commons' 'public' or 'private' + updateSelectedPermissions( $(this).text() ); + }); } //selectNodeOnRightClickHandler @@ -533,3 +563,45 @@ function touchPanZoomHandler(eventInfo, e) { } } + +function updateSelectedPermissions(permission) { + + + if ( $('.notice.metamaps').length == 0 ) { + $('body').prepend('
    '); + } + $('.notice.metamaps').hide().html('Working...').fadeIn('fast'); + + // variables to keep track of how many nodes and synapses you had the ability to change the permission of + var nCount = 0, sCount = 0; + + // change the permission of the selected synapses, if logged in user is the original creator + var l = MetamapsModel.selectedEdges.length; + for (var i = l-1; i >= 0; i -= 1) { + var edge = MetamapsModel.selectedEdges[i]; + + if (edge.getData('userid') == userid) { + updateSynapsePermission(edge,permission); + sCount++; + } + } + + // change the permission of the selected topics, if logged in user is the original creator + var l = MetamapsModel.selectedNodes.length; + for (var i = l-1; i >= 0; i -= 1) { + var node = MetamapsModel.selectedNodes[i]; + + if (node.getData('userid') == userid) { + updateTopicPermission(node,permission); + nCount++; + } + } + + var nString = nCount == 1 ? (nCount.toString() + ' topic and ') : (nCount.toString() + ' topics and '); + var sString = sCount == 1 ? (sCount.toString() + ' synapse') : (sCount.toString() + ' synapses'); + + $('.notice.metamaps').html(nString + sString + ' you created updated to ' + permission) + setTimeout( function() { + $('.notice.metamaps').fadeOut('fast'); + }, 8000); +} diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 082c52a9..f4680e92 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1291,13 +1291,13 @@ left: 13px; color: black; } -.rightclickmenu > ul { +.rightclickmenu ul { padding: 2px; } .rightclickmenu ul li { list-style: none; -padding: 3px 45px 3px 30px; +padding: 3px 10px 3px 30px; font-family: arial, sans-serif; font-size: 17px; line-height: 17px; @@ -1305,8 +1305,14 @@ background-repeat: no-repeat; background-size: 20px 20px; background-position: 5px 2px; } +.rightclickmenu ul li:nth-child(odd){ + background-color: #FFF; +} +.rightclickmenu ul li:nth-child(even){ + background-color: #EEE; +} .rightclickmenu ul li:hover { - background-color: #e4e4e4; + background-color: #BBB; background-position: 7px 2px; cursor:pointer; } @@ -1322,6 +1328,33 @@ background-position: 5px 2px; .rightclickmenu .rc-popout { background-image: url(MMCCicon_pop-out_black.png); } +.rightclickmenu .rc-permission { + background-image: url(MMCCicon_edit_permission_black.png); + position:relative; +} + +.rightclickmenu .rc-permission ul { + display:none; + background:white; + top: 0; + left:100%; + position:absolute; + border-bottom-left-radius: 2px; + border-bottom-right-radius: 2px; + border-top-right-radius: 2px; +} +.rightclickmenu .rc-permission:hover ul { + display:block; +} +.rightclickmenu .rc-permission .toCommons { + background-image: url(MMCCicon_commons.png); +} +.rightclickmenu .rc-permission .toPublic { + background-image: url(MMCCicon_public.png); +} +.rightclickmenu .rc-permission .toPrivate { + background-image: url(MMCCicon_private.png); +} .rightclickmenu p { padding:7px;