/*
* Copyright (c) 2014
*
* This file is licensed under the Affero General Public License version 3
* or later.
*
* See the COPYING-README file.
*
*/
(function(){
// TODO: move to a separate file
var MOUNT_OPTIONS_DROPDOWN_TEMPLATE =
'
' +
// FIXME: options are hard-coded for now
'
' +
' ' +
' ' +
'
' +
'
' +
' ' +
' ' +
'
' +
'
' +
' ' +
' ' +
'
' +
'
';
/* TODO the current l10n extrator can't handle JS functions within handlebar
templates therefore they are duplicated here
t("files_external", "Enable encryption")
t("files_external", "Enable previews")
t("files_external", "Check for changes")
t("files_external", "Never")
t("files_external", "Once every direct access")
*/
/**
* Returns the selection of applicable users in the given configuration row
*
* @param $row configuration row
* @return array array of user names
*/
function getSelection($row) {
var values = $row.find('.applicableUsers').select2('val');
if (!values || values.length === 0) {
values = [];
}
return values;
}
function highlightBorder($element, highlight) {
$element.toggleClass('warning-input', highlight);
return highlight;
}
function isInputValid($input) {
var optional = $input.hasClass('optional');
switch ($input.attr('type')) {
case 'text':
case 'password':
if ($input.val() === '' && !optional) {
return false;
}
break;
}
return true;
}
function highlightInput($input) {
switch ($input.attr('type')) {
case 'text':
case 'password':
return highlightBorder($input, !isInputValid($input));
}
}
/**
* Initialize select2 plugin on the given elements
*
* @param {Array