Merge pull request #5638 from owncloud/admin-quotafield

Improve quota input field
This commit is contained in:
Morris Jobke 2013-10-31 04:25:42 -07:00
commit ea4dfa7e38
3 changed files with 27 additions and 6 deletions

View File

@ -1,10 +1,13 @@
(function ($) {
$.fn.singleSelect = function () {
return this.each(function (i, select) {
var input = $('<input/>');
var input = $('<input/>'),
inputTooltip = $(select).attr('data-inputtitle');
if (inputTooltip){
input.attr('title', inputTooltip);
}
select = $(select);
input.css('position', 'absolute');
input.css(select.offset());
input.css({
'box-sizing': 'border-box',
'-moz-box-sizing': 'border-box',
@ -28,7 +31,13 @@
select.data('previous', value);
} else {
event.stopImmediatePropagation();
// adjust offset, in case the user scrolled
input.css(select.offset());
input.show();
if ($.fn.tipsy){
input.tipsy({gravity: 'n', trigger: 'manual'});
input.tipsy('show');
}
select.css('background-color', 'white');
input.focus();
}
@ -70,6 +79,9 @@
input.on('blur', function () {
$(this).change();
if ($.fn.tipsy){
$(this).tipsy('hide');
}
});
});
}

View File

@ -147,7 +147,11 @@ var UserList = {
quotaSelect.on('change', function () {
var uid = $(this).parent().parent().attr('data-uid');
var quota = $(this).val();
setQuota(uid, quota);
setQuota(uid, quota, function(returnedQuota){
if (quota !== returnedQuota) {
$(quotaSelect).find(':selected').text(returnedQuota);
}
});
});
},
// From http://my.opera.com/GreyWyvern/blog/show.dml/1671288
@ -428,9 +432,14 @@ $(document).ready(function () {
});
$('select.quota, select.quota-user').singleSelect().on('change', function () {
var select = $(this);
var uid = $(this).parent().parent().attr('data-uid');
var quota = $(this).val();
setQuota(uid, quota);
setQuota(uid, quota, function(returnedQuota){
if (quota !== returnedQuota) {
select.find(':selected').text(returnedQuota);
}
});
});
$('#newuser').submit(function (event) {

View File

@ -41,7 +41,7 @@ $_['subadmingroups'] = array_flip($items);
<div class="quota">
<span><?php p($l->t('Default Storage'));?></span>
<?php if((bool) $_['isadmin']): ?>
<select class='quota'>
<select class='quota' data-inputtitle="<?php p($l->t('Please enter storage quota (ex: "512 MB" or "12 GB")')) ?>">
<option
<?php if($_['default_quota'] === 'none') print_unescaped('selected="selected"');?>
value='none'>
@ -136,7 +136,7 @@ $_['subadmingroups'] = array_flip($items);
</td>
<?php endif;?>
<td class="quota">
<select class='quota-user'>
<select class='quota-user' data-inputtitle="<?php p($l->t('Please enter storage quota (ex: "512 MB" or "12 GB")')) ?>">
<option
<?php if($user['quota'] === 'default') print_unescaped('selected="selected"');?>
value='default'>