Revision 379 (by ahitrov, 2013/08/21 12:49:37) |
Emails control for credentials
|
% if ( $state->{users}->use_credentials && $object->id ) {
<script type="text/javascript">
<!--
function check_<% $name %>_valid( nID ){
}
$(document).ready(function(){
% foreach my $cred ( @credentials ) {
$('#<% $name %>_name_<% $cred->id %>_text').focusout(function(){
var oEmail = $(this);
$.get('/contenido/ajax/credential_email_valid.html', { 'id' : '<% $object->id %>', 'email' : $(oEmail).val() }, function(data){
if ( data.error ) {
$('#<% $name %>_<% $cred->id %>_check').attr('title', data.error).html('<span style="color:red">Error</span>');
} else {
$('#<% $name %>_<% $cred->id %>_check').attr('title', '').html('<span style="color:green">Ok</span>');
}
}, 'json');
});
% }
$('#<% $name %>_name__text').focusout(function(){
var oEmail = $(this);
$.get('/contenido/ajax/credential_email_valid.html', { 'id' : '<% $object->id %>', 'email' : $(oEmail).val() }, function(data){
if ( data.error ) {
$('#<% $name %>_new_check').attr('title', data.error).html('<span style="color:red">Error</span>');
} else if ( data.nothing ) {
$('#<% $name %>_new_check').attr('title', '').html('');
} else {
$('#<% $name %>_new_check').attr('title', '').html('<span style="color:green">Ok</span>');
}
}, 'json');
});
});
//-->
</script>
<div style="border:1px solid gray; padding:2px; width:95%;">
<table width="100%" cellpadding="5" cellspacing="0">
<tr bgcolor="white">
<th>Main</th>
<th>E-mail</th>
<th>Активен</th>
<th>Удалить</th>
<th></th>
</tr>
% foreach my $cred ( @credentials ) {
% my $checked = $cred->main ? ' checked' : '';
% my $bgcolor = $i++ % 2 ? 'white' : '#e0e0e0';
% my $active = $cred->status == 1 ? ' checked' : '';
<tr bgcolor="<% $bgcolor %>">
<td width="1%"><input type="radio" name="<% $name %>.main" value="<% $cred->id %>"<% $checked %>></td>
<td width="96%"><& /contenido/components/inputs/string.msn, name => $name.'_name_'.$cred->id, prop => $prop, check => $cred->name, object => $object &></td>
<td width="1%"><input type="checkbox" name="<% $name %>_active_<% $cred->id %>" value="1"<% $active %>></td>
<td width="1%"><input type="checkbox" name="<% $name %>.delete" value="<% $cred->id %>"></td>
<td width="1%" id="<% $name %>_<% $cred->id %>_check"><span style="color:green">Ok</span></td>
</tr>
% }
<tr bgcolor="<% $i++ % 2 ? 'white' : '#e0e0e0' %>">
<td><input type="radio" name="<% $name %>.main" value=""></td>
<td><& /contenido/components/inputs/string.msn, name => $name.'_name_', prop => $prop, check => '', object => $object &></td>
<td><input type="checkbox" name="<% $name %>_active_" value="1"></td>
<td></td>
<td id="<% $name %>_new_check"></td>
</tr>
</table>
</div>
% } else {
<& /contenido/components/inputs/string.msn, %ARGS &>
% }
<%args>
$name => undef
$check => undef
$prop => {}
$object => undef
</%args>
<%init>
my @credentials;
if ( $state->{users}->use_credentials ) {
@credentials = $keeper->get_documents(
class => 'users::Email',
uid => $object->id,
order_by => 'main desc, name',
);
}
my $i = 0;
</%init>