-
Notifications
You must be signed in to change notification settings - Fork 0
/
FieldChooser.ascx
94 lines (78 loc) · 3.33 KB
/
FieldChooser.ascx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="FieldChooser.ascx.vb" Inherits="Albatros.DNN.Modules.Registration.FieldChooser" %>
<table id="fieldchooser" cellspacing="4">
<tr>
<th></th>
<asp:Repeater runat="server" ID="rpRoles">
<ItemTemplate>
<th data-id="<%# Eval("RoleId")%>" class="ar_th_role"><%# Eval("RoleName")%></th>
</ItemTemplate>
</asp:Repeater>
</tr>
<asp:Repeater runat="server" ID="rpFields">
<ItemTemplate>
<tr data-id="<%# Eval("PropertyDefinitionId")%>" class="ar_property">
<td class="ar_property_title"><%# DotNetNuke.Services.Localization.Localization.GetString("ProfileProperties_" & Eval("PropertyName"),"DesktopModules\Admin\Security\App_LocalResources\Profile.ascx.resx").TrimEnd(":")%></td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
<div class="ar_buttonbar">
<asp:Button runat="server" ID="cmdReturn" resourcekey="cmdReturn" class="dnnPrimaryAction" />
</div>
<script type="text/javascript">
(function ($, Sys) {
$(document).ready(function () {
$('#fieldchooser tr:odd').addClass('stripe');
service = new RegistrationService($, {
serverErrorText: '<%= LocalizeJSString("ServerError") %>',
serverErrorWithDescriptionText: '<%= LocalizeJSString("ServerErrorWithDescription") %>',
errorBoxId: '#pUrlsServiceErrorBox<%= ModuleId %>'
}, <%= ModuleId %>);
var roles = [];
roles = $('.ar_th_role').map(function() {
return $(this).attr('data-id');
});
var checkboxes = ''
$.each(roles, function(index, roleId) {
checkboxes += '<td><img src="<%= ResolveUrl("~/DesktopModules/Albatros/Registration/images/check.png") %>" width="24" height="24" data-value="' + roleId + '" data-state="notselected" class="ar_checkbox" /></td>'
});
$('.ar_property').append(checkboxes);
service.getRoleProperties(function (data) {
$.each(data, function(index, roleprop) {
if (roleprop.Required) {
$('tr[data-id=' + roleprop.PropertyDefinitionID + '] td img.ar_checkbox[data-value=' + roleprop.RoleId + ']').attr('src', '<%= ResolveUrl("~/DesktopModules/Albatros/Registration/images/check_required.png") %>').attr('data-state', 'required');
} else {
$('tr[data-id=' + roleprop.PropertyDefinitionID + '] td img.ar_checkbox[data-value=' + roleprop.RoleId + ']').attr('src', '<%= ResolveUrl("~/DesktopModules/Albatros/Registration/images/check_selected.png") %>').attr('data-state', 'selected');
}
});
});
$('.ar_checkbox').click(function() {
var switchTo = ''
switch ($(this).attr('data-state')) {
case 'required':
switchTo = 'notselected';
break;
case 'selected':
switchTo = 'required';
break;
default:
switchTo = 'selected';
}
var that = $(this);
service.setRoleProperty($(this).parent().parent().attr('data-id'), $(this).attr('data-value'), switchTo, function() {
$(that).attr('data-state', switchTo);
switch (switchTo) {
case 'required':
$(that).attr('src', '<%= ResolveUrl("~/DesktopModules/Albatros/Registration/images/check_required.png") %>');
break;
case 'selected':
$(that).attr('src', '<%= ResolveUrl("~/DesktopModules/Albatros/Registration/images/check_selected.png") %>');
break;
default:
$(that).attr('src', '<%= ResolveUrl("~/DesktopModules/Albatros/Registration/images/check.png") %>');
}
});
});
}); // doc ready
} (jQuery, window.Sys));
</script>