Only show can edit (if not checked) and unshare button on hover

This commit is contained in:
Michael Gapczynski 2011-08-09 17:55:51 -04:00
parent 7c840e9bbb
commit 88e338ec23
2 changed files with 32 additions and 10 deletions

View file

@ -2,7 +2,7 @@
-moz-box-shadow:0 1px 1px #777; -webkit-box-shadow:0 1px 1px #777; box-shadow:0 1px 1px #777;
-moz-border-radius-bottomleft:1em; -webkit-border-bottom-left-radius:1em; border-bottom-left-radius:1em;
-moz-border-radius-bottomright:1em; -webkit-border-bottom-right-radius:1em; border-bottom-right-radius:1em; }
#shared_list>ul { list-style-type: none; }
#public { border-top:1px solid #ddd; margin-top:1em; padding-top:0.5em; }
#shared_list { padding:0.5em; list-style-type: none; }
#public { border-top:1px solid #ddd; padding-top:0.5em; }
a.unshare { float:right; display:inline; margin:0 .5em; padding:.3em .3em 0 .3em !important; }
a.unshare:hover { background:#fff; -moz-box-shadow:0 0 10px #fff; -webkit-box-shadow:0 0 10px #fff; box-shadow:0 0 10px #fff; -moz-border-radius:10px; -webkit-border-radius:10px; border-radius:10px; }

View file

@ -37,12 +37,32 @@ $(document).ready(function() {
type: 'POST',
url: OC.linkTo('files_sharing','ajax/share.php'),
cache: false,
data: data
data: data,
success: function() {
$('#uid_shared_with option[value="'+uid_shared_with+'"]').remove();
$('#uid_shared_with').trigger('liszt:updated');
var list = "<li data-uid_shared_with='"+uid_shared_with+"'>";
list += uid_shared_with;
list += "<input type='checkbox' name='permissions' class='permissions' style='display:none;' /><label>can edit</label>";
list += "<a href='' title='Unshare' class='unshare' data-uid_shared_with='"+uid_shared_with+"' style='display:none;'><img class='svg' src='"+OC.imagePath('core','actions/delete')+"'/></a>";
list += "</li>";
$(list).prependTo('#shared_list');
}
});
});
$('#shared_list > li').live('mouseenter', function(event) {
$(':hidden', this).show();
});
$('#shared_list > li').live('mouseleave', function(event) {
$('a', this).hide();
if (!$('input:[type=checkbox]', this).is(':checked')) {
$('input:[type=checkbox]', this).hide();
$('label', this).hide();
}
});
$('.permissions').live('change', function() {
var permissions;
if ($(this).checked) {
if (this.checked) {
permissions = 1;
} else {
permissions = 0;
@ -118,13 +138,13 @@ function createShareDropdown(filenames, files) {
html += "<select data-placeholder='User or Group' style='width:220px;' id='uid_shared_with' class='chzen-select'>";
html += "<option value=''></option>";
html += "</select>";
html += "<div id='shared_list'></div>";
html += "<ul id='shared_list'></ul>";
html += "</div>";
html += "<div id='public'>";
html += "<input type='checkbox' name='makelink' id='makelink' value='1' /><label for='makelink'>make public</label>";
html += "<input type='checkbox' name='public_link_write' id='public_link_write' value='1' /><label for='public_link_write'>allow upload</label>";
html += "<br />";
html += "<input id='link' style='display:none;width:100%' />";
html += "<input id='link' style='display:none; width:90%;' />";
html += "</div>";
$('tr[data-file="'+filenames+'"]').addClass('mouseOver');
$(html).appendTo($('tr[data-file="'+filenames+'"] td.filename'));
@ -138,7 +158,7 @@ function createShareDropdown(filenames, files) {
});
$.getJSON(OC.linkTo('files_sharing', 'ajax/getitem.php'), { source: files }, function(users) {
if (users) {
var list = "<ul>";
var list;
$.each(users, function(index, row) {
$('#uid_shared_with option[value="'+row.uid_shared_with+'"]').remove();
if (typeof(index) == 'string') {
@ -148,16 +168,18 @@ function createShareDropdown(filenames, files) {
list += "<li data-uid_shared_with='"+row.uid_shared_with+"'>";
list += row.uid_shared_with;
var checked;
var style;
if (row.permissions > 0) {
checked = "checked='checked'";
} else {
style = "style='display:none;'";
}
list += "<input type='checkbox' name='permissions' id='"+index+"' class='permissions' "+checked+" /><label for='"+index+"'>can edit</label>";
list += "<a href='' title='Unshare' class='unshare' data-uid_shared_with='"+row.uid_shared_with+"'><img class='svg' src='"+OC.imagePath('core','actions/delete')+"'/></a>";
list += "<input type='checkbox' name='permissions' id='"+index+"' class='permissions' "+checked+" "+style+" /><label for='"+index+"' "+style+">can edit</label>";
list += "<a href='' title='Unshare' class='unshare' data-uid_shared_with='"+row.uid_shared_with+"' style='display:none;'><img class='svg' src='"+OC.imagePath('core','actions/delete')+"'/></a>";
list += "</li>";
}
});
list += "</ul>";
$(list).appendTo('#shared_list');
$('#uid_shared_with').trigger('liszt:updated');
}