Split editable select code used for quota selection into a jquery plugin
This commit is contained in:
parent
4a130d106c
commit
e68e5cc849
|
@ -0,0 +1,76 @@
|
||||||
|
(function ($) {
|
||||||
|
$.fn.singleSelect = function () {
|
||||||
|
return this.each(function (i, select) {
|
||||||
|
var input = $('<input/>');
|
||||||
|
select = $(select);
|
||||||
|
input.css('position', 'absolute');
|
||||||
|
input.css(select.offset());
|
||||||
|
input.css({
|
||||||
|
'box-sizing': 'border-box',
|
||||||
|
'-moz-box-sizing': 'border-box',
|
||||||
|
'margin': 0,
|
||||||
|
'width': (select.width() - 5) + 'px',
|
||||||
|
'height': (select.outerHeight() - 2) + 'px',
|
||||||
|
'border': 'none',
|
||||||
|
'box-shadow': 'none',
|
||||||
|
'margin-top': '1px',
|
||||||
|
'margin-left': '1px',
|
||||||
|
'z-index': 1000
|
||||||
|
});
|
||||||
|
input.hide();
|
||||||
|
$('body').append(input);
|
||||||
|
|
||||||
|
select.on('change', function (event) {
|
||||||
|
var value = $(this).val(),
|
||||||
|
newAttr = $('option:selected', $(this)).attr('data-new');
|
||||||
|
if (!(typeof newAttr !== 'undefined' && newAttr !== false)) {
|
||||||
|
input.hide();
|
||||||
|
select.data('previous', value);
|
||||||
|
} else {
|
||||||
|
event.stopImmediatePropagation();
|
||||||
|
input.show();
|
||||||
|
select.css('background-color', 'white');
|
||||||
|
input.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(select).data('previous', $(select).val());
|
||||||
|
|
||||||
|
input.on('change', function () {
|
||||||
|
var value = $(this).val();
|
||||||
|
if (value) {
|
||||||
|
select.children().attr('selected', null);
|
||||||
|
var existingOption = select.children().filter(function (i, option) {
|
||||||
|
return ($(option).val() == value);
|
||||||
|
});
|
||||||
|
if (existingOption.length) {
|
||||||
|
existingOption.attr('selected', 'selected');
|
||||||
|
} else {
|
||||||
|
var option = $('<option/>');
|
||||||
|
option.attr('selected', 'selected').attr('value', value).text(value);
|
||||||
|
select.children().last().before(option);
|
||||||
|
}
|
||||||
|
select.val(value);
|
||||||
|
select.css('background-color', null);
|
||||||
|
input.val(null);
|
||||||
|
input.hide();
|
||||||
|
select.change();
|
||||||
|
} else {
|
||||||
|
var previous = select.data('previous');
|
||||||
|
select.children().attr('selected', null);
|
||||||
|
select.children().each(function (i, option) {
|
||||||
|
if ($(option).val() == previous) {
|
||||||
|
$(option).attr('selected', 'selected');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
select.removeClass('active');
|
||||||
|
input.hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
input.on('blur', function () {
|
||||||
|
$(this).change();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})(jQuery);
|
|
@ -39,7 +39,6 @@ div.quota { float:right; display:block; position:absolute; right:25em; top:0; }
|
||||||
div.quota-select-wrapper { position: relative; }
|
div.quota-select-wrapper { position: relative; }
|
||||||
select.quota { position:absolute; left:0; top:0.5em; width:10em; }
|
select.quota { position:absolute; left:0; top:0.5em; width:10em; }
|
||||||
select.quota-user { position:relative; left:0; top:0; width:10em; }
|
select.quota-user { position:relative; left:0; top:0; width:10em; }
|
||||||
input.quota-other { display:none; position:absolute; left:0.1em; top:0.1em; width:7em; border:none; box-shadow:none; }
|
|
||||||
div.quota>span { position:absolute; right:0; white-space:nowrap; top:.7em; color:#888; text-shadow:0 1px 0 #fff; }
|
div.quota>span { position:absolute; right:0; white-space:nowrap; top:.7em; color:#888; text-shadow:0 1px 0 #fff; }
|
||||||
select.quota.active { background: #fff; }
|
select.quota.active { background: #fff; }
|
||||||
|
|
||||||
|
|
|
@ -5,449 +5,395 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var UserList = {
|
var UserList = {
|
||||||
useUndo:true,
|
useUndo: true,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initiate user deletion process in UI
|
* @brief Initiate user deletion process in UI
|
||||||
* @param string uid the user ID to be deleted
|
* @param string uid the user ID to be deleted
|
||||||
*
|
*
|
||||||
* Does not actually delete the user; it sets them for
|
* Does not actually delete the user; it sets them for
|
||||||
* deletion when the current page is unloaded, at which point
|
* deletion when the current page is unloaded, at which point
|
||||||
* finishDelete() completes the process. This allows for 'undo'.
|
* finishDelete() completes the process. This allows for 'undo'.
|
||||||
*/
|
*/
|
||||||
do_delete:function (uid) {
|
do_delete: function (uid) {
|
||||||
if (typeof UserList.deleteUid !== 'undefined') {
|
if (typeof UserList.deleteUid !== 'undefined') {
|
||||||
//Already a user in the undo queue
|
//Already a user in the undo queue
|
||||||
UserList.finishDelete(null);
|
UserList.finishDelete(null);
|
||||||
}
|
}
|
||||||
UserList.deleteUid = uid;
|
UserList.deleteUid = uid;
|
||||||
|
|
||||||
// Set undo flag
|
// Set undo flag
|
||||||
UserList.deleteCanceled = false;
|
UserList.deleteCanceled = false;
|
||||||
|
|
||||||
// Provide user with option to undo
|
// Provide user with option to undo
|
||||||
$('#notification').data('deleteuser', true);
|
$('#notification').data('deleteuser', true);
|
||||||
OC.Notification.showHtml(t('users', 'deleted') + ' ' + uid + '<span class="undo">' + t('users', 'undo') + '</span>');
|
OC.Notification.showHtml(t('users', 'deleted') + ' ' + uid + '<span class="undo">' + t('users', 'undo') + '</span>');
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Delete a user via ajax
|
* @brief Delete a user via ajax
|
||||||
* @param bool ready whether to use ready() upon completion
|
* @param bool ready whether to use ready() upon completion
|
||||||
*
|
*
|
||||||
* Executes deletion via ajax of user identified by property deleteUid
|
* Executes deletion via ajax of user identified by property deleteUid
|
||||||
* if 'undo' has not been used. Completes the user deletion procedure
|
* if 'undo' has not been used. Completes the user deletion procedure
|
||||||
* and reflects success in UI.
|
* and reflects success in UI.
|
||||||
*/
|
*/
|
||||||
finishDelete:function (ready) {
|
finishDelete: function (ready) {
|
||||||
|
|
||||||
// Check deletion has not been undone
|
// Check deletion has not been undone
|
||||||
if (!UserList.deleteCanceled && UserList.deleteUid) {
|
if (!UserList.deleteCanceled && UserList.deleteUid) {
|
||||||
|
|
||||||
// Delete user via ajax
|
// Delete user via ajax
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type:'POST',
|
type: 'POST',
|
||||||
url:OC.filePath('settings', 'ajax', 'removeuser.php'),
|
url: OC.filePath('settings', 'ajax', 'removeuser.php'),
|
||||||
async:false,
|
async: false,
|
||||||
data:{ username:UserList.deleteUid },
|
data: { username: UserList.deleteUid },
|
||||||
success:function (result) {
|
success: function (result) {
|
||||||
if (result.status == 'success') {
|
if (result.status == 'success') {
|
||||||
// Remove undo option, & remove user from table
|
// Remove undo option, & remove user from table
|
||||||
OC.Notification.hide();
|
OC.Notification.hide();
|
||||||
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
|
$('tr').filterAttr('data-uid', UserList.deleteUid).remove();
|
||||||
UserList.deleteCanceled = true;
|
UserList.deleteCanceled = true;
|
||||||
if (ready) {
|
if (ready) {
|
||||||
ready();
|
ready();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
oc.dialogs.alert(result.data.message, t('settings', 'Unable to remove user'));
|
oc.dialogs.alert(result.data.message, t('settings', 'Unable to remove user'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
add:function (username, groups, subadmin, quota, sort) {
|
add: function (username, groups, subadmin, quota, sort) {
|
||||||
var tr = $('tbody tr').first().clone();
|
var tr = $('tbody tr').first().clone();
|
||||||
tr.attr('data-uid', username);
|
tr.attr('data-uid', username);
|
||||||
tr.attr('data-displayName', username);
|
tr.attr('data-displayName', username);
|
||||||
tr.find('td.name').text(username);
|
tr.find('td.name').text(username);
|
||||||
tr.find('td.displayName').text(username);
|
tr.find('td.displayName').text(username);
|
||||||
var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="' + t('settings', 'Groups') + '"></select>').attr('data-username', username).attr('data-user-groups', groups);
|
var groupsSelect = $('<select multiple="multiple" class="groupsselect" data-placehoder="Groups" title="' + t('settings', 'Groups') + '"></select>').attr('data-username', username).attr('data-user-groups', groups);
|
||||||
tr.find('td.groups').empty();
|
tr.find('td.groups').empty();
|
||||||
if (tr.find('td.subadmins').length > 0) {
|
if (tr.find('td.subadmins').length > 0) {
|
||||||
var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('settings', 'Group Admin') + '">').attr('data-username', username).attr('data-user-groups', groups).attr('data-subadmin', subadmin);
|
var subadminSelect = $('<select multiple="multiple" class="subadminsselect" data-placehoder="subadmins" title="' + t('settings', 'Group Admin') + '">').attr('data-username', username).attr('data-user-groups', groups).attr('data-subadmin', subadmin);
|
||||||
tr.find('td.subadmins').empty();
|
tr.find('td.subadmins').empty();
|
||||||
}
|
}
|
||||||
var allGroups = String($('#content table').attr('data-groups')).split(', ');
|
var allGroups = String($('#content table').attr('data-groups')).split(', ');
|
||||||
$.each(allGroups, function (i, group) {
|
$.each(allGroups, function (i, group) {
|
||||||
groupsSelect.append($('<option value="' + group + '">' + group + '</option>'));
|
groupsSelect.append($('<option value="' + group + '">' + group + '</option>'));
|
||||||
if (typeof subadminSelect !== 'undefined' && group != 'admin') {
|
if (typeof subadminSelect !== 'undefined' && group != 'admin') {
|
||||||
subadminSelect.append($('<option value="' + group + '">' + group + '</option>'));
|
subadminSelect.append($('<option value="' + group + '">' + group + '</option>'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
tr.find('td.groups').append(groupsSelect);
|
tr.find('td.groups').append(groupsSelect);
|
||||||
UserList.applyMultiplySelect(groupsSelect);
|
UserList.applyMultiplySelect(groupsSelect);
|
||||||
if (tr.find('td.subadmins').length > 0) {
|
if (tr.find('td.subadmins').length > 0) {
|
||||||
tr.find('td.subadmins').append(subadminSelect);
|
tr.find('td.subadmins').append(subadminSelect);
|
||||||
UserList.applyMultiplySelect(subadminSelect);
|
UserList.applyMultiplySelect(subadminSelect);
|
||||||
}
|
}
|
||||||
if (tr.find('td.remove img').length == 0 && OC.currentUser != username) {
|
if (tr.find('td.remove img').length == 0 && OC.currentUser != username) {
|
||||||
var rm_img = $('<img>', {
|
var rm_img = $('<img>', {
|
||||||
class:'svg action',
|
class: 'svg action',
|
||||||
src:OC.imagePath('core', 'actions/delete')
|
src: OC.imagePath('core', 'actions/delete')
|
||||||
});
|
});
|
||||||
var rm_link = $('<a>', { class:'action delete', href:'#', 'original-title':t('settings', 'Delete')}).append(rm_img);
|
var rm_link = $('<a>', { class: 'action delete', href: '#', 'original-title': t('settings', 'Delete')}).append(rm_img);
|
||||||
tr.find('td.remove').append(rm_link);
|
tr.find('td.remove').append(rm_link);
|
||||||
} else if (OC.currentUser == username) {
|
} else if (OC.currentUser == username) {
|
||||||
tr.find('td.remove a').remove();
|
tr.find('td.remove a').remove();
|
||||||
}
|
}
|
||||||
var quotaSelect = tr.find('select.quota-user');
|
var quotaSelect = tr.find('select.quota-user');
|
||||||
if (quota == 'default') {
|
if (quota == 'default') {
|
||||||
quotaSelect.find('option').attr('selected', null);
|
quotaSelect.find('option').attr('selected', null);
|
||||||
quotaSelect.find('option').first().attr('selected', 'selected');
|
quotaSelect.find('option').first().attr('selected', 'selected');
|
||||||
quotaSelect.data('previous', 'default');
|
quotaSelect.data('previous', 'default');
|
||||||
} else {
|
} else {
|
||||||
if (quotaSelect.find('option[value="' + quota + '"]').length > 0) {
|
if (quotaSelect.find('option[value="' + quota + '"]').length > 0) {
|
||||||
quotaSelect.find('option[value="' + quota + '"]').attr('selected', 'selected');
|
quotaSelect.find('option[value="' + quota + '"]').attr('selected', 'selected');
|
||||||
} else {
|
} else {
|
||||||
quotaSelect.append('<option value="' + quota + '" selected="selected">' + quota + '</option>');
|
quotaSelect.append('<option value="' + quota + '" selected="selected">' + quota + '</option>');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var added = false;
|
var added = false;
|
||||||
if (sort) {
|
if (sort) {
|
||||||
username = username.toLowerCase();
|
username = username.toLowerCase();
|
||||||
$('tbody tr').each(function () {
|
$('tbody tr').each(function () {
|
||||||
if (username < $(this).attr('data-uid').toLowerCase()) {
|
if (username < $(this).attr('data-uid').toLowerCase()) {
|
||||||
$(tr).insertBefore($(this));
|
$(tr).insertBefore($(this));
|
||||||
added = true;
|
added = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!added) {
|
if (!added) {
|
||||||
$(tr).appendTo('tbody');
|
$(tr).appendTo('tbody');
|
||||||
}
|
}
|
||||||
return tr;
|
return tr;
|
||||||
},
|
},
|
||||||
|
|
||||||
update:function () {
|
update: function () {
|
||||||
if (typeof UserList.offset === 'undefined') {
|
if (typeof UserList.offset === 'undefined') {
|
||||||
UserList.offset = $('tbody tr').length;
|
UserList.offset = $('tbody tr').length;
|
||||||
}
|
}
|
||||||
$.get(OC.Router.generate('settings_ajax_userlist', { offset:UserList.offset }), function (result) {
|
$.get(OC.Router.generate('settings_ajax_userlist', { offset: UserList.offset }), function (result) {
|
||||||
if (result.status === 'success') {
|
if (result.status === 'success') {
|
||||||
$.each(result.data, function (index, user) {
|
$.each(result.data, function (index, user) {
|
||||||
var tr = UserList.add(user.name, user.groups, user.subadmin, user.quota, false);
|
var tr = UserList.add(user.name, user.groups, user.subadmin, user.quota, false);
|
||||||
UserList.offset++;
|
UserList.offset++;
|
||||||
if (index == 9) {
|
if (index == 9) {
|
||||||
$(tr).bind('inview', function (event, isInView, visiblePartX, visiblePartY) {
|
$(tr).bind('inview', function (event, isInView, visiblePartX, visiblePartY) {
|
||||||
$(this).unbind(event);
|
$(this).unbind(event);
|
||||||
UserList.update();
|
UserList.update();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
applyMultiplySelect:function (element) {
|
applyMultiplySelect: function (element) {
|
||||||
var checked = [];
|
var checked = [];
|
||||||
var user = element.attr('data-username');
|
var user = element.attr('data-username');
|
||||||
if ($(element).attr('class') == 'groupsselect') {
|
if ($(element).attr('class') == 'groupsselect') {
|
||||||
if (element.data('userGroups')) {
|
if (element.data('userGroups')) {
|
||||||
checked = String(element.data('userGroups')).split(', ');
|
checked = String(element.data('userGroups')).split(', ');
|
||||||
}
|
}
|
||||||
if (user) {
|
if (user) {
|
||||||
var checkHandeler = function (group) {
|
var checkHandeler = function (group) {
|
||||||
if (user == OC.currentUser && group == 'admin') {
|
if (user == OC.currentUser && group == 'admin') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!isadmin && checked.length == 1 && checked[0] == group) {
|
if (!isadmin && checked.length == 1 && checked[0] == group) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.post(
|
$.post(
|
||||||
OC.filePath('settings', 'ajax', 'togglegroups.php'),
|
OC.filePath('settings', 'ajax', 'togglegroups.php'),
|
||||||
{
|
{
|
||||||
username:user,
|
username: user,
|
||||||
group:group
|
group: group
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
checkHandeler = false;
|
checkHandeler = false;
|
||||||
}
|
}
|
||||||
var addGroup = function (select, group) {
|
var addGroup = function (select, group) {
|
||||||
$('select[multiple]').each(function (index, element) {
|
$('select[multiple]').each(function (index, element) {
|
||||||
if ($(element).find('option[value="' + group + '"]').length === 0 && select.data('msid') !== $(element).data('msid')) {
|
if ($(element).find('option[value="' + group + '"]').length === 0 && select.data('msid') !== $(element).data('msid')) {
|
||||||
$(element).append('<option value="' + group + '">' + group + '</option>');
|
$(element).append('<option value="' + group + '">' + group + '</option>');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
var label;
|
var label;
|
||||||
if (isadmin) {
|
if (isadmin) {
|
||||||
label = t('settings', 'add group');
|
label = t('settings', 'add group');
|
||||||
} else {
|
} else {
|
||||||
label = null;
|
label = null;
|
||||||
}
|
}
|
||||||
element.multiSelect({
|
element.multiSelect({
|
||||||
createCallback:addGroup,
|
createCallback: addGroup,
|
||||||
createText:label,
|
createText: label,
|
||||||
selectedFirst:true,
|
selectedFirst: true,
|
||||||
checked:checked,
|
checked: checked,
|
||||||
oncheck:checkHandeler,
|
oncheck: checkHandeler,
|
||||||
onuncheck:checkHandeler,
|
onuncheck: checkHandeler,
|
||||||
minWidth:100
|
minWidth: 100
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if ($(element).attr('class') == 'subadminsselect') {
|
if ($(element).attr('class') == 'subadminsselect') {
|
||||||
if (element.data('subadmin')) {
|
if (element.data('subadmin')) {
|
||||||
checked = String(element.data('subadmin')).split(', ');
|
checked = String(element.data('subadmin')).split(', ');
|
||||||
}
|
}
|
||||||
var checkHandeler = function (group) {
|
var checkHandeler = function (group) {
|
||||||
if (group == 'admin') {
|
if (group == 'admin') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$.post(
|
$.post(
|
||||||
OC.filePath('settings', 'ajax', 'togglesubadmins.php'),
|
OC.filePath('settings', 'ajax', 'togglesubadmins.php'),
|
||||||
{
|
{
|
||||||
username:user,
|
username: user,
|
||||||
group:group
|
group: group
|
||||||
},
|
},
|
||||||
function () {
|
function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
var addSubAdmin = function (group) {
|
var addSubAdmin = function (group) {
|
||||||
$('select[multiple]').each(function (index, element) {
|
$('select[multiple]').each(function (index, element) {
|
||||||
if ($(element).find('option[value="' + group + '"]').length == 0) {
|
if ($(element).find('option[value="' + group + '"]').length == 0) {
|
||||||
$(element).append('<option value="' + group + '">' + group + '</option>');
|
$(element).append('<option value="' + group + '">' + group + '</option>');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
element.multiSelect({
|
element.multiSelect({
|
||||||
createCallback:addSubAdmin,
|
createCallback: addSubAdmin,
|
||||||
createText:null,
|
createText: null,
|
||||||
checked:checked,
|
checked: checked,
|
||||||
oncheck:checkHandeler,
|
oncheck: checkHandeler,
|
||||||
onuncheck:checkHandeler,
|
onuncheck: checkHandeler,
|
||||||
minWidth:100
|
minWidth: 100
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
|
||||||
$('tbody tr:last').bind('inview', function (event, isInView, visiblePartX, visiblePartY) {
|
$('tbody tr:last').bind('inview', function (event, isInView, visiblePartX, visiblePartY) {
|
||||||
OC.Router.registerLoadedCallback(function(){
|
OC.Router.registerLoadedCallback(function () {
|
||||||
UserList.update();
|
UserList.update();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function setQuota(uid, quota, ready) {
|
function setQuota (uid, quota, ready) {
|
||||||
$.post(
|
$.post(
|
||||||
OC.filePath('settings', 'ajax', 'setquota.php'),
|
OC.filePath('settings', 'ajax', 'setquota.php'),
|
||||||
{username:uid, quota:quota},
|
{username: uid, quota: quota},
|
||||||
function (result) {
|
function (result) {
|
||||||
if (ready) {
|
if (ready) {
|
||||||
ready(result.data.quota);
|
ready(result.data.quota);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$('select[multiple]').each(function (index, element) {
|
$('select[multiple]').each(function (index, element) {
|
||||||
UserList.applyMultiplySelect($(element));
|
UserList.applyMultiplySelect($(element));
|
||||||
});
|
});
|
||||||
|
|
||||||
$('table').on('click', 'td.remove>a', function (event) {
|
$('table').on('click', 'td.remove>a', function (event) {
|
||||||
var row = $(this).parent().parent();
|
var row = $(this).parent().parent();
|
||||||
var uid = $(row).attr('data-uid');
|
var uid = $(row).attr('data-uid');
|
||||||
$(row).hide();
|
$(row).hide();
|
||||||
// Call function for handling delete/undo
|
// Call function for handling delete/undo
|
||||||
UserList.do_delete(uid);
|
UserList.do_delete(uid);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('table').on('click', 'td.password>img', function (event) {
|
$('table').on('click', 'td.password>img', function (event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
var img = $(this);
|
var img = $(this);
|
||||||
var uid = img.parent().parent().attr('data-uid');
|
var uid = img.parent().parent().attr('data-uid');
|
||||||
var input = $('<input type="password">');
|
var input = $('<input type="password">');
|
||||||
img.css('display', 'none');
|
img.css('display', 'none');
|
||||||
img.parent().children('span').replaceWith(input);
|
img.parent().children('span').replaceWith(input);
|
||||||
input.focus();
|
input.focus();
|
||||||
input.keypress(function (event) {
|
input.keypress(function (event) {
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
if ($(this).val().length > 0) {
|
if ($(this).val().length > 0) {
|
||||||
$.post(
|
$.post(
|
||||||
OC.filePath('settings', 'ajax', 'changepassword.php'),
|
OC.filePath('settings', 'ajax', 'changepassword.php'),
|
||||||
{username:uid, password:$(this).val()},
|
{username: uid, password: $(this).val()},
|
||||||
function (result) {
|
function (result) {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
input.blur();
|
input.blur();
|
||||||
} else {
|
} else {
|
||||||
input.blur();
|
input.blur();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
input.blur(function () {
|
input.blur(function () {
|
||||||
$(this).replaceWith($('<span>●●●●●●●</span>'));
|
$(this).replaceWith($('<span>●●●●●●●</span>'));
|
||||||
img.css('display', '');
|
img.css('display', '');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
$('table').on('click', 'td.password', function (event) {
|
$('table').on('click', 'td.password', function (event) {
|
||||||
$(this).children('img').click();
|
$(this).children('img').click();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('table').on('click', 'td.displayName>img', function (event) {
|
|
||||||
event.stopPropagation();
|
|
||||||
var img = $(this);
|
|
||||||
var uid = img.parent().parent().attr('data-uid');
|
|
||||||
var displayName = img.parent().parent().attr('data-displayName');
|
|
||||||
var input = $('<input type="text" value="'+displayName+'">');
|
|
||||||
img.css('display', 'none');
|
|
||||||
img.parent().children('span').replaceWith(input);
|
|
||||||
input.focus();
|
|
||||||
input.keypress(function (event) {
|
|
||||||
if (event.keyCode == 13) {
|
|
||||||
if ($(this).val().length > 0) {
|
|
||||||
$.post(
|
|
||||||
OC.filePath('settings', 'ajax', 'changedisplayname.php'),
|
|
||||||
{username:uid, displayName:$(this).val()},
|
|
||||||
function (result) {
|
|
||||||
}
|
|
||||||
);
|
|
||||||
input.blur();
|
|
||||||
} else {
|
|
||||||
input.blur();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
input.blur(function () {
|
|
||||||
$(this).replaceWith($(this).val());
|
|
||||||
img.css('display', '');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
$('table').on('click', 'td.displayName', function (event) {
|
|
||||||
$(this).children('img').click();
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('select.quota, select.quota-user').on('change', function () {
|
$('table').on('click', 'td.displayName>img', function (event) {
|
||||||
var select = $(this);
|
event.stopPropagation();
|
||||||
var uid = $(this).parent().parent().parent().attr('data-uid');
|
var img = $(this);
|
||||||
var quota = $(this).val();
|
var uid = img.parent().parent().attr('data-uid');
|
||||||
var other = $(this).next();
|
var displayName = img.parent().parent().attr('data-displayName');
|
||||||
if (quota != 'other') {
|
var input = $('<input type="text" value="' + displayName + '">');
|
||||||
other.hide();
|
img.css('display', 'none');
|
||||||
select.data('previous', quota);
|
img.parent().children('span').replaceWith(input);
|
||||||
setQuota(uid, quota);
|
input.focus();
|
||||||
} else {
|
input.keypress(function (event) {
|
||||||
other.show();
|
if (event.keyCode == 13) {
|
||||||
select.addClass('active');
|
if ($(this).val().length > 0) {
|
||||||
other.focus();
|
$.post(
|
||||||
}
|
OC.filePath('settings', 'ajax', 'changedisplayname.php'),
|
||||||
});
|
{username: uid, displayName: $(this).val()},
|
||||||
$('select.quota, select.quota-user').each(function (i, select) {
|
function (result) {
|
||||||
$(select).data('previous', $(select).val());
|
}
|
||||||
})
|
);
|
||||||
|
input.blur();
|
||||||
|
} else {
|
||||||
|
input.blur();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
input.blur(function () {
|
||||||
|
$(this).replaceWith($(this).val());
|
||||||
|
img.css('display', '');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
$('table').on('click', 'td.displayName', function (event) {
|
||||||
|
$(this).children('img').click();
|
||||||
|
});
|
||||||
|
|
||||||
$('input.quota-other').on('change', function () {
|
$('select.quota, select.quota-user').singleSelect().on('change', function () {
|
||||||
var uid = $(this).parent().parent().parent().attr('data-uid');
|
var uid = $(this).parent().parent().attr('data-uid');
|
||||||
var quota = $(this).val();
|
var quota = $(this).val();
|
||||||
var select = $(this).prev();
|
setQuota(uid, quota);
|
||||||
var other = $(this);
|
});
|
||||||
if (quota) {
|
|
||||||
setQuota(uid, quota, function (quota) {
|
|
||||||
select.children().attr('selected', null);
|
|
||||||
var existingOption = select.children().filter(function (i, option) {
|
|
||||||
return ($(option).val() == quota);
|
|
||||||
});
|
|
||||||
if (existingOption.length) {
|
|
||||||
existingOption.attr('selected', 'selected');
|
|
||||||
} else {
|
|
||||||
var option = $('<option/>');
|
|
||||||
option.attr('selected', 'selected').attr('value', quota).text(quota);
|
|
||||||
select.children().last().before(option);
|
|
||||||
}
|
|
||||||
select.val(quota);
|
|
||||||
select.removeClass('active');
|
|
||||||
other.val(null);
|
|
||||||
other.hide();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
var previous = select.data('previous');
|
|
||||||
select.children().attr('selected', null);
|
|
||||||
select.children().each(function (i, option) {
|
|
||||||
if ($(option).val() == previous) {
|
|
||||||
$(option).attr('selected', 'selected');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
select.removeClass('active');
|
|
||||||
other.hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('input.quota-other').on('blur', function () {
|
$('#newuser').submit(function (event) {
|
||||||
$(this).change();
|
event.preventDefault();
|
||||||
})
|
var username = $('#newusername').val();
|
||||||
|
var password = $('#newuserpassword').val();
|
||||||
$('#newuser').submit(function (event) {
|
if ($('#content table tbody tr').filterAttr('data-uid', username).length > 0) {
|
||||||
event.preventDefault();
|
OC.dialogs.alert(
|
||||||
var username = $('#newusername').val();
|
t('settings', 'The username is already being used'),
|
||||||
var password = $('#newuserpassword').val();
|
t('settings', 'Error creating user'));
|
||||||
if ($('#content table tbody tr').filterAttr('data-uid', username).length > 0) {
|
return;
|
||||||
OC.dialogs.alert(
|
}
|
||||||
t('settings', 'The username is already being used'),
|
if ($.trim(username) == '') {
|
||||||
t('settings', 'Error creating user'));
|
OC.dialogs.alert(
|
||||||
return;
|
t('settings', 'A valid username must be provided'),
|
||||||
}
|
t('settings', 'Error creating user'));
|
||||||
if ($.trim(username) == '') {
|
return false;
|
||||||
OC.dialogs.alert(
|
}
|
||||||
t('settings', 'A valid username must be provided'),
|
if ($.trim(password) == '') {
|
||||||
t('settings', 'Error creating user'));
|
OC.dialogs.alert(
|
||||||
return false;
|
t('settings', 'A valid password must be provided'),
|
||||||
}
|
t('settings', 'Error creating user'));
|
||||||
if ($.trim(password) == '') {
|
return false;
|
||||||
OC.dialogs.alert(
|
}
|
||||||
t('settings', 'A valid password must be provided'),
|
var groups = $('#newusergroups').prev().children('div').data('settings').checked;
|
||||||
t('settings', 'Error creating user'));
|
$('#newuser').get(0).reset();
|
||||||
return false;
|
$.post(
|
||||||
}
|
OC.filePath('settings', 'ajax', 'createuser.php'),
|
||||||
var groups = $('#newusergroups').prev().children('div').data('settings').checked;
|
{
|
||||||
$('#newuser').get(0).reset();
|
username: username,
|
||||||
$.post(
|
password: password,
|
||||||
OC.filePath('settings', 'ajax', 'createuser.php'),
|
groups: groups
|
||||||
{
|
},
|
||||||
username:username,
|
function (result) {
|
||||||
password:password,
|
if (result.status != 'success') {
|
||||||
groups:groups
|
OC.dialogs.alert(result.data.message,
|
||||||
},
|
t('settings', 'Error creating user'));
|
||||||
function (result) {
|
} else {
|
||||||
if (result.status != 'success') {
|
UserList.add(username, result.data.groups, null, 'default', true);
|
||||||
OC.dialogs.alert(result.data.message,
|
}
|
||||||
t('settings', 'Error creating user'));
|
}
|
||||||
} else {
|
);
|
||||||
UserList.add(username, result.data.groups, null, 'default', true);
|
});
|
||||||
}
|
// Handle undo notifications
|
||||||
}
|
OC.Notification.hide();
|
||||||
);
|
$('#notification').on('click', '.undo', function () {
|
||||||
});
|
if ($('#notification').data('deleteuser')) {
|
||||||
// Handle undo notifications
|
$('tbody tr').filterAttr('data-uid', UserList.deleteUid).show();
|
||||||
OC.Notification.hide();
|
UserList.deleteCanceled = true;
|
||||||
$('#notification').on('click', '.undo', function () {
|
}
|
||||||
if ($('#notification').data('deleteuser')) {
|
OC.Notification.hide();
|
||||||
$('tbody tr').filterAttr('data-uid', UserList.deleteUid).show();
|
});
|
||||||
UserList.deleteCanceled = true;
|
UserList.useUndo = ('onbeforeunload' in window)
|
||||||
}
|
$(window).bind('beforeunload', function () {
|
||||||
OC.Notification.hide();
|
UserList.finishDelete(null);
|
||||||
});
|
});
|
||||||
UserList.useUndo = ('onbeforeunload' in window)
|
|
||||||
$(window).bind('beforeunload', function () {
|
|
||||||
UserList.finishDelete(null);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,7 +33,6 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
</form>
|
</form>
|
||||||
<div class="quota">
|
<div class="quota">
|
||||||
<span><?php echo $l->t('Default Storage');?></span>
|
<span><?php echo $l->t('Default Storage');?></span>
|
||||||
<div class="quota-select-wrapper">
|
|
||||||
<?php if((bool) $_['isadmin']): ?>
|
<?php if((bool) $_['isadmin']): ?>
|
||||||
<select class='quota'>
|
<select class='quota'>
|
||||||
<option
|
<option
|
||||||
|
@ -60,7 +59,7 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
<?php echo $l->t('Other');?>
|
<?php echo $l->t('Other');?>
|
||||||
...
|
...
|
||||||
</option>
|
</option>
|
||||||
</select> <input class='quota-other'/>
|
</select>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if((bool) !$_['isadmin']): ?>
|
<?php if((bool) !$_['isadmin']): ?>
|
||||||
<select class='quota' disabled="disabled">
|
<select class='quota' disabled="disabled">
|
||||||
|
@ -69,7 +68,6 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
</option>
|
</option>
|
||||||
</select>
|
</select>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -129,36 +127,34 @@ $_['subadmingroups'] = array_flip($items);
|
||||||
</td>
|
</td>
|
||||||
<?php endif;?>
|
<?php endif;?>
|
||||||
<td class="quota">
|
<td class="quota">
|
||||||
<div class="quota-select-wrapper">
|
<select class='quota-user'>
|
||||||
<select class='quota-user'>
|
<option
|
||||||
<option
|
<?php if($user['quota']=='default') echo 'selected="selected"';?>
|
||||||
<?php if($user['quota']=='default') echo 'selected="selected"';?>
|
value='default'>
|
||||||
value='default'>
|
<?php echo $l->t('Default');?>
|
||||||
<?php echo $l->t('Default');?>
|
</option>
|
||||||
</option>
|
<option
|
||||||
<option
|
<?php if($user['quota']=='none') echo 'selected="selected"';?>
|
||||||
<?php if($user['quota']=='none') echo 'selected="selected"';?>
|
value='none'>
|
||||||
value='none'>
|
<?php echo $l->t('Unlimited');?>
|
||||||
<?php echo $l->t('Unlimited');?>
|
</option>
|
||||||
</option>
|
<?php foreach($_['quota_preset'] as $preset):?>
|
||||||
<?php foreach($_['quota_preset'] as $preset):?>
|
<option
|
||||||
<option
|
<?php if($user['quota']==$preset) echo 'selected="selected"';?>
|
||||||
<?php if($user['quota']==$preset) echo 'selected="selected"';?>
|
value='<?php echo $preset;?>'>
|
||||||
value='<?php echo $preset;?>'>
|
<?php echo $preset;?>
|
||||||
<?php echo $preset;?>
|
</option>
|
||||||
</option>
|
<?php endforeach;?>
|
||||||
<?php endforeach;?>
|
<?php if($user['isQuotaUserDefined']):?>
|
||||||
<?php if($user['isQuotaUserDefined']):?>
|
<option selected="selected" value='<?php echo $user['quota'];?>'>
|
||||||
<option selected="selected" value='<?php echo $user['quota'];?>'>
|
<?php echo $user['quota'];?>
|
||||||
<?php echo $user['quota'];?>
|
</option>
|
||||||
</option>
|
<?php endif;?>
|
||||||
<?php endif;?>
|
<option value='other' data-new>
|
||||||
<option value='other'>
|
<?php echo $l->t('Other');?>
|
||||||
<?php echo $l->t('Other');?>
|
...
|
||||||
...
|
</option>
|
||||||
</option>
|
</select>
|
||||||
</select> <input class='quota-other'/>
|
|
||||||
</div>
|
|
||||||
</td>
|
</td>
|
||||||
<td class="remove">
|
<td class="remove">
|
||||||
<?php if($user['name']!=OC_User::getUser()):?>
|
<?php if($user['name']!=OC_User::getUser()):?>
|
||||||
|
|
|
@ -11,6 +11,7 @@ OC_App::loadApps();
|
||||||
// We have some javascript foo!
|
// We have some javascript foo!
|
||||||
OC_Util::addScript( 'settings', 'users' );
|
OC_Util::addScript( 'settings', 'users' );
|
||||||
OC_Util::addScript( 'core', 'multiselect' );
|
OC_Util::addScript( 'core', 'multiselect' );
|
||||||
|
OC_Util::addScript( 'core', 'singleselect' );
|
||||||
OC_Util::addScript('core', 'jquery.inview');
|
OC_Util::addScript('core', 'jquery.inview');
|
||||||
OC_Util::addStyle( 'settings', 'settings' );
|
OC_Util::addStyle( 'settings', 'settings' );
|
||||||
OC_App::setActiveNavigationEntry( 'core_users' );
|
OC_App::setActiveNavigationEntry( 'core_users' );
|
||||||
|
|
Loading…
Reference in New Issue