forked from sachatrauwaen/OpenContent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditSettings.ascx
199 lines (177 loc) · 7.54 KB
/
EditSettings.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<%@ Control Language="C#" AutoEventWireup="false" Inherits="Satrabel.OpenContent.EditSettings" CodeBehind="EditSettings.ascx.cs" %>
<%@ Register TagPrefix="dnn" TagName="Label" Src="~/controls/LabelControl.ascx" %>
<asp:Panel ID="ScopeWrapper" runat="server" CssClass="dnnForm">
<div id="field1" class="alpaca"></div>
<ul class="dnnActions dnnClear" style="display: block; padding-left: 35%">
<li>
<asp:HyperLink ID="cmdSave" runat="server" class="dnnPrimaryAction" resourcekey="cmdSave" />
</li>
<li>
<asp:HyperLink ID="hlCancel" runat="server" class="dnnSecondaryAction" resourcekey="cmdCancel" />
</li>
</ul>
</asp:Panel>
<script type="text/javascript">
/*globals jQuery, window, Sys */
(function ($, Sys) {
function setupStructSettings() {
var windowTop = parent;
var popup = windowTop.jQuery("#iPopUp");
if (popup.length > 0) {
var $window = $(windowTop),
newHeight,
newWidth;
newHeight = $window.height() - 36;
newWidth = Math.min($window.width() - 40, 1200);
popup.dialog("option", {
close: function () { window.dnnModal.closePopUp(false, ""); },
//'position': 'top',
height: newHeight,
width: newWidth,
minWidth: newWidth,
minHeight: newHeight,
//position: 'center'
resizable: false,
});
$("#<%=hlCancel.ClientID%>").click(function () {
dnnModal.closePopUp(false, "");
return false;
});
}
var moduleScope = $('#<%=ScopeWrapper.ClientID %>'),
self = moduleScope,
sf = $.ServicesFramework(<%=ModuleId %>);
self.CreateForm = function () {
var postData = {};
var getData = "";
var action = "Settings";
$.ajax({
type: "GET",
url: sf.getServiceRoot('OpenContent') + "OpenContentAPI/" + action,
data: getData,
beforeSend: sf.setModuleHeaders
}).done(function (config) {
if (config.schema) {
var jsmodules = [];
/*
oc_loadmodules(config.options, function () {
self.FormEdit(config);
});
*/
self.FormEdit(config);
/*
if (config.options) {
var types = self.GetFieldTypes(config.options);
if ($.inArray("address", types) != -1) {
jsmodules.push('addressfield');
}
}
if (jsmodules.length > 0) {
require(jsmodules, function () {
self.FormEdit(config);
});
}
else {
self.FormEdit(config);
}
*/
}
else {
$("#<%=cmdSave.ClientID%>").click(function () {
var href = $(this).attr('href');
self.FormSubmit("", href);
return false;
});
}
}).fail(function (xhr, result, status) {
alert("Uh-oh, something broke: " + status);
});
};
self.FormEdit = function (config) {
$.alpaca.setDefaultLocale("<%= AlpacaCulture %>");
var ConnectorClass = Alpaca.getConnectorClass("default");
connector = new ConnectorClass("default");
connector.servicesFramework = sf;
connector.culture = '<%=CurrentCulture%>';
connector.defaultCulture = '<%=DefaultCulture%>';
connector.numberDecimalSeparator = '<%=NumberDecimalSeparator%>';
$("#field1").alpaca({
"schema": config.schema,
"options": config.options,
"data": config.data,
"view": "dnn-edit",
"connector": connector,
"postRender": function (control) {
var selfControl = control;
$("#<%=cmdSave.ClientID%>").click(function () {
selfControl.refreshValidationState(true);
if (selfControl.isValid(true)) {
var value = selfControl.getValue();
//alert(JSON.stringify(value, null, " "));
var href = $(this).attr('href');
self.FormSubmit(value, href);
}
return false;
});
}
});
};
self.FormSubmit = function (data, href) {
//var postData = { 'data': data, 'template': Template };
var postData = JSON.stringify({ 'data': data});
var action = "UpdateSettings";
$.ajax({
type: "POST",
url: sf.getServiceRoot('OpenContent') + "OpenContentAPI/" + action,
contentType: "application/json; charset=utf-8",
dataType: "json",
data: postData,
beforeSend: sf.setModuleHeaders
}).done(function (data) {
var windowTop = parent; //needs to be assign to a varaible for Opera compatibility issues.
var popup = windowTop.jQuery("#iPopUp");
if (popup.length > 0) {
windowTop.__doPostBack('dnn_ctr<%=ModuleId %>_View__UP', '');
dnnModal.closePopUp(false, href);
}
else {
window.location.href = href;
}
}).fail(function (xhr, result, status) {
alert("Uh-oh, something broke: " + status + " " + xhr.responseText);
});
};
/*
self.GetFieldTypes = function (options) {
var types = [];
if (options.fields) {
var fields = options.fields;
for (var key in fields) {
var field = fields[key];
if (field.type) {
types.push(field.type);
}
var subtypes = self.GetFieldTypes(field);
types = types.concat(subtypes);
}
}
return types;
}
*/
self.CreateForm();
}
$(document).ready(function () {
setupStructSettings();
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(function () {
setupStructSettings();
});
//setTimeout(function () {
//}, 2000);
});
}(jQuery, window.Sys));
var gminitializecallback;
function gminitialize() {
if (gminitializecallback)
gminitializecallback();
}
</script>