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 00000000..e87d006e Binary files /dev/null and b/app/assets/images/MMCCicon_edit_permission_black.png differ diff --git a/app/assets/javascripts/Jit/graphsettings-event-handlers.js b/app/assets/javascripts/Jit/graphsettings-event-handlers.js index 6817e040..f333bb52 100644 --- a/app/assets/javascripts/Jit/graphsettings-event-handlers.js +++ b/app/assets/javascripts/Jit/graphsettings-event-handlers.js @@ -52,6 +52,14 @@ function selectEdgeOnRightClickHandler(adj, e) { if (userid != null) menustring += '
  • Delete
  • '; if (mapid && userid != null) menustring += '
  • Remove from Map
  • '; menustring += '
  • Hide until refresh
  • '; + if (userid) { + var options = ''; + + menustring += '
  • Change permissions' + options + '
  • '; + } 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 = ''; + + 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;