forked from siteserver/cms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayerUtils.cs
More file actions
156 lines (137 loc) · 6.96 KB
/
Copy pathLayerUtils.cs
File metadata and controls
156 lines (137 loc) · 6.96 KB
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
using System.Web.UI;
namespace SiteServer.Utils
{
public class LayerUtils
{
private LayerUtils()
{
}
public const string CloseScript = "if (window.parent.closeWindow) window.parent.closeWindow();if (window.parent.layer) window.parent.layer.closeAll();";
public const string OpenPageCreateStatusFuncName = "openPageCreateStatus";
public static string GetOpenScript(string title, string pageUrl)
{
return GetOpenScript(title, pageUrl, 0, 0);
}
public static string GetOpenScript(string title, string pageUrl, int width, int height)
{
string areaWidth = $"'{width}px'";
string areaHeight = $"'{height}px'";
var offsetLeft = "''";
var offsetRight = "''";
if (width == 0)
{
areaWidth = "($(window).width() - 50) +'px'";
offsetRight = "'25px'";
}
if (height == 0)
{
areaHeight = "($(window).height() - 50) +'px'";
offsetLeft = "'25px'";
}
return
$@"$.layer({{type: 2, maxmin: true, shadeClose: true, title: '{title}', shade: [0.1,'#fff'], iframe: {{src: '{pageUrl}'}}, area: [{areaWidth}, {areaHeight}], offset: [{offsetLeft}, {offsetRight}]}});return false;";
}
public static string GetOpenScriptWithTextBoxValue(string title, string pageUrl, string textBoxId)
{
return GetOpenScriptWithTextBoxValue(title, pageUrl, textBoxId, 0, 0);
}
public static string GetOpenScriptWithTextBoxValue(string title, string pageUrl, string textBoxId, int width, int height)
{
string areaWidth = $"'{width}px'";
string areaHeight = $"'{height}px'";
var offsetLeft = "''";
var offsetRight = "''";
if (width == 0)
{
areaWidth = "($(window).width() - 50) +'px'";
offsetRight = "'25px'";
}
if (height == 0)
{
areaHeight = "($(window).height() - 50) +'px'";
offsetLeft = "'25px'";
}
return
$@"$.layer({{type: 2, maxmin: true, shadeClose: true, title: '{title}', shade: [0.1,'#fff'], iframe: {{src: '{pageUrl}' + '&{textBoxId}=' + $('#{textBoxId}').val()}}, area: [{areaWidth}, {areaHeight}], offset: [{offsetLeft}, {offsetRight}]}});return false;";
}
public static string GetOpenScriptWithCheckBoxValue(string title, string pageUrl, string checkBoxId, string alertText)
{
return GetOpenScriptWithCheckBoxValue(title, pageUrl, checkBoxId, alertText, 0, 0);
}
public static string GetOpenScriptWithCheckBoxValue(string title, string pageUrl, string checkBoxId, string alertText, int width, int height)
{
string areaWidth = $"'{width}px'";
string areaHeight = $"'{height}px'";
var offsetLeft = "''";
var offsetRight = "''";
if (width == 0)
{
areaWidth = "($(window).width() - 50) +'px'";
offsetRight = "'25px'";
}
if (height == 0)
{
areaHeight = "($(window).height() - 50) +'px'";
offsetLeft = "'25px'";
}
if (string.IsNullOrEmpty(alertText))
{
return
$@"$.layer({{type: 2, maxmin: true, shadeClose: true, title: '{title}', shade: [0.1,'#fff'], iframe: {{src: '{pageUrl}' + '&{checkBoxId}=' + _getCheckBoxCollectionValue(document.getElementsByName('{checkBoxId}'))}}, area: [{areaWidth}, {areaHeight}], offset: [{offsetLeft}, {offsetRight}]}});return false;";
}
return
$@"if (!_alertCheckBoxCollection(document.getElementsByName('{checkBoxId}'), '{alertText}')){{$.layer({{type: 2, maxmin: true, shadeClose: true, title: '{title}', shade: [0.1,'#fff'], iframe: {{src: '{pageUrl}' + '&{checkBoxId}=' + _getCheckBoxCollectionValue(document.getElementsByName('{checkBoxId}'))}}, area: [{areaWidth}, {areaHeight}], offset: [{offsetLeft}, {offsetRight}]}});}};return false;";
}
public static string GetOpenScriptWithTwoCheckBoxValue(string title, string pageUrl, string checkBoxId1, string checkBoxId2, string alertText, int width, int height)
{
var offset = string.Empty;
if (width == 0)
{
offset = "offset: ['0px','0px'],";
}
if (height == 0)
{
offset = "offset: ['0px','0px'],";
}
return
$@"var collectionValue1 = _getCheckBoxCollectionValue(document.getElementsByName('{checkBoxId1}'));var collectionValue2 = _getCheckBoxCollectionValue(document.getElementsByName('{checkBoxId2}'));if (collectionValue1.length == 0 && collectionValue2.length == 0){{alert('{alertText}');}}else{{$.layer({{type: 2, maxmin: true, shadeClose: true, title: '{title}', shade: [0.1,'#fff'], iframe: {{src: '{pageUrl}' + '&{checkBoxId1}=' + _getCheckBoxCollectionValue(document.getElementsByName('{checkBoxId1}')) + '&{checkBoxId2}=' + _getCheckBoxCollectionValue(document.getElementsByName('{checkBoxId2}'))}}, area: [{width}, {height}], {offset}}});}};return false;";
}
public static void Close(Page page)
{
page.Response.Clear();
page.Response.Write($"<script>window.parent.location.reload(true);{CloseScript}</script>");
}
public static void Close(Page page, string scripts)
{
page.Response.Clear();
page.Response.Write($"<script>{scripts}</script>");
page.Response.Write($"<script>window.parent.location.reload(true);{CloseScript}</script>");
}
public static void CloseAndRedirect(Page page, string redirectUrl)
{
page.Response.Clear();
page.Response.Write($"<script>window.parent.location.href = '{redirectUrl}';{CloseScript}</script>");
}
public static void CloseAndRedirect(Page page, string redirectUrl, string scripts)
{
page.Response.Clear();
page.Response.Write($"<script>{scripts}</script>");
page.Response.Write($"<script>window.parent.location.href = '{redirectUrl}';{CloseScript}</script>");
}
public static void CloseWithoutRefresh(Page page)
{
page.Response.Clear();
page.Response.Write($"<script>{CloseScript}</script>");
}
public static void CloseWithoutRefresh(Page page, string scripts)
{
page.Response.Clear();
page.Response.Write($"<script>{scripts}</script>");
page.Response.Write($"<script>{CloseScript}</script>");
}
public static void CloseAndOpenPageCreateStatus(Page page)
{
CloseWithoutRefresh(page, $"window.top.{OpenPageCreateStatusFuncName}();");
}
}
}