';
+ }
+ var permissions = ['commons','public','private'];
+ var permission_choices = "'[";
+ for (var i in permissions) {
+ permission_choices += '["' + permissions[i] + '","' + permissions[i] + '"],';
+ }
+ //remove trailing comma and add ]
+ permission_choices = permission_choices.slice(0, -1);
+ permission_choices += "]'";
+ edit_perm = edit_perm.replace(/\$_permission_choices_\$/g, permission_choices);
+
+ html = html.replace(/\$_edit_permission_\$/g, edit_perm);
+ html = html.replace(/\$_permission_\$/g, node.getData("permission"));
+ html = html.replace(/\$_mk_permission_\$/g, mk_permission(node));
html = html.replace(/\$_id_\$/g, node.id);
html = html.replace(/\$_metacode_\$/g, node.getData("metacode"));
html = html.replace(/\$_imgsrc_\$/g, imgArray[node.getData("metacode")].src);
@@ -156,14 +198,14 @@ function replaceVariables(html, node) {
html = html.replace(/\$_go_link_\$/g, go_link);
html = html.replace(/\$_a_tag_\$/g, a_tag);
html = html.replace(/\$_close_a_tag_\$/g, close_a_tag);
- if (node.getData("link") == "" && userid != null) {
+ if (node.getData("link") == "" && authorizeToEdit(node)) {
html = html.replace(/\$_link_\$/g, link_nil);
} else {
html = html.replace(/\$_link_\$/g, node.getData("link"));
}
html = html.replace(/\$_desc_nil_\$/g, desc_nil);
- if (node.getData("desc") == "" && userid != null) {
+ if (node.getData("desc") == "" && authorizeToEdit(node)) {
//logged in but desc isn't there so it's invisible
html = html.replace(/\$_desc_\$/g, desc_nil);
} else {
@@ -235,6 +277,7 @@ function hideCard(node) {
}
function bindCallbacks(showCard, nameContainer, node) {
+
// add some events to the label
$(showCard).find('img.icon').click(function(){
hideCard(node);
@@ -285,4 +328,51 @@ function bindCallbacks(showCard, nameContainer, node) {
var link = $(this).html();
$(showCard).find('.go-link').attr('href', link);
});
+
+ var sliding2 = false;
+ var lT1,lT2;
+ $(showCard).find(".permActivator").bind('mouseover',
+ function () {
+ clearTimeout(lT2);
+ that = this;
+ lT1 = setTimeout(function() {
+ if (! sliding2) {
+ sliding2 = true;
+ $(that).animate({
+ width: '203px',
+ height: '37px'
+ }, 300, function() {
+ sliding2 = false;
+ });
+ }
+ }, 300);
+ });
+
+ $(showCard).find(".permActivator").bind('mouseout',
+ function () {
+ clearTimeout(lT1);
+ that = this;
+ lT2 = setTimeout(function() {
+ if (! sliding2) {
+ sliding2 = true;
+ $(that).animate({
+ height: '16px',
+ width: '16px'
+ }, 300, function() {
+ sliding2 = false;
+ });
+ }
+ },800);
+ }
+ );
+
+ //bind best_in_place ajax callbacks
+ $(showCard).find('.best_in_place_permission').bind("ajax:success", function() {
+ var permission = $(this).html();
+ var el = $(this).parents('.cardSettings').find('.mapPerm');
+ el.attr('title', permission);
+ if (permission == "commons") el.html("co");
+ else if (permission == "public") el.html("pu");
+ else if (permission == "private") el.html("pr");
+ });
}
diff --git a/app/assets/javascripts/Jit/permissions.js b/app/assets/javascripts/Jit/permissions.js
index e08c47f1..3c372dd3 100644
--- a/app/assets/javascripts/Jit/permissions.js
+++ b/app/assets/javascripts/Jit/permissions.js
@@ -2,4 +2,10 @@
function authorizeToEdit(obj) {
if (userid && (obj.data.$permission == "commons" || obj.data.$userid == userid)) return true;
else return false;
+}
+
+function mk_permission(obj) {
+ if (obj.getData("permission") == "commons") return "co";
+ else if (obj.getData("permission") == "public") return "pu";
+ else if (obj.getData("permission") == "private") return "pr";
}
\ No newline at end of file
diff --git a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js
index 98dcfbff..7de4977c 100644
--- a/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js
+++ b/app/assets/javascripts/Jit/select-edit-delete-nodes-and-edges.js
@@ -46,7 +46,7 @@ function editEdge(edge, e) {
$('#edit_synapse input').focus();
$('#edit_synapse').show();
}
- else if (! authorizeToEdit(edge)) {
+ else if ((! authorizeToEdit(edge)) && userid) {
alert("You don't have the permissions to edit this synapse.");
}
}
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js
index 0d14278c..02c9aa93 100644
--- a/app/assets/javascripts/application.js
+++ b/app/assets/javascripts/application.js
@@ -84,51 +84,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
}
);
-
- // controls the sliding hover of the settings for cards
- var sliding2 = false;
- var lT1,lT2;
- $(".permActivator").hover(
- function () {
- clearTimeout(lT2);
- that = this;
- lT1 = setTimeout(function() {
- if (! sliding2) {
- sliding2 = true;
- $(that).animate({
- width: '203px',
- height: '37px'
- }, 300, function() {
- sliding2 = false;
- });
- }
- }, 300);
- },
- function () {
- clearTimeout(lT1);
- that = this;
- lT2 = setTimeout(function() {
- if (! sliding2) {
- sliding2 = true;
- $(that).animate({
- height: '16px',
- width: '16px'
- }, 300, function() {
- sliding2 = false;
- });
- }
- },800);
- }
- );
- //bind best_in_place ajax callbacks
- $('.best_in_place_permission').bind("ajax:success", function() {
- var permission = $(this).html();
- var el = $(this).parents('.cardSettings').find('.mapPerm');
- el.attr('title', permission);
- if (permission == "commons") el.html("co");
- else if (permission == "public") el.html("pu");
- else if (permission == "private") el.html("pr");
- });
+ addHoverForSettings();
//bind best_in_place ajax callbacks
$('.best_in_place_metacode').bind("ajax:success", function() {
@@ -147,6 +103,59 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
});
+function addHoverForSettings() {
+ // controls the sliding hover of the settings for cards
+ $(".permActivator").unbind('mouseover');
+ $(".permActivator").unbind('mouseout');
+ var sliding2 = false;
+ var lT1,lT2;
+ $(".permActivator").bind('mouseover',
+ function () {
+ clearTimeout(lT2);
+ that = this;
+ lT1 = setTimeout(function() {
+ if (! sliding2) {
+ sliding2 = true;
+ $(that).animate({
+ width: '203px',
+ height: '37px'
+ }, 300, function() {
+ sliding2 = false;
+ });
+ }
+ }, 300);
+ });
+
+ $(".permActivator").bind('mouseout',
+ function () {
+ clearTimeout(lT1);
+ that = this;
+ lT2 = setTimeout(function() {
+ if (! sliding2) {
+ sliding2 = true;
+ $(that).animate({
+ height: '16px',
+ width: '16px'
+ }, 300, function() {
+ sliding2 = false;
+ });
+ }
+ },800);
+ }
+ );
+
+ $('.best_in_place_permission').unbind("ajax:success");
+ //bind best_in_place ajax callbacks
+ $('.best_in_place_permission').bind("ajax:success", function() {
+ var permission = $(this).html();
+ var el = $(this).parents('.cardSettings').find('.mapPerm');
+ el.attr('title', permission);
+ if (permission == "commons") el.html("co");
+ else if (permission == "public") el.html("pu");
+ else if (permission == "private") el.html("pr");
+ });
+}
+
// this is to save the layout of a map
function saveLayoutAll() {
var coor = "";
diff --git a/app/views/maps/edit.html.erb b/app/views/maps/edit.html.erb
index f52f29c4..dedb03fa 100644
--- a/app/views/maps/edit.html.erb
+++ b/app/views/maps/edit.html.erb
@@ -12,6 +12,7 @@
<% if @map.user == user %>
<%= form.select :permission, options_for_select(['commons', 'public', 'private'], @map.permission) %>
+
Topics and synapses you create newly on this map will be set by default to the permissions of your map. Permissions of already created topics will not be changed to your new map permission.
<% end %>
<%= form.submit "Update", class: "update" %>
<% end %>