Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c07e9d9

Browse files
committed
Dialog samples
1 parent 4039592 commit c07e9d9

19 files changed

+745
-14
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// AnimatedDialog.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Sample/Button
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using jQueryApi;
8+
using jQueryApi.UI.Widgets;
9+
10+
namespace Sample.Dialog {
11+
internal static class AnimatedDialog {
12+
static AnimatedDialog() {
13+
// increase the default animation speed to exaggerate the effect
14+
//$.fx.speeds._default = 1000;
15+
16+
jQuery.OnDocumentReady(delegate() {
17+
jQuery.Select("#dialog2")
18+
.Plugin<DialogObject>()
19+
.Dialog(new DialogOptions(DialogOption.AutoOpen, false,
20+
DialogOption.Show, "blind",
21+
DialogOption.Hide, "explode"));
22+
23+
jQuery.Select("#opener")
24+
.Click(new jQueryEventHandler(delegate(jQueryEvent e) {
25+
jQuery.Select("#dialog2")
26+
.Plugin<DialogObject>()
27+
.Dialog(DialogMethod.Open);
28+
29+
e.PreventDefault();
30+
e.StopPropagation();
31+
}));
32+
});
33+
}
34+
}
35+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Default.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Sample/Button
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using jQueryApi;
8+
using jQueryApi.UI.Widgets;
9+
10+
namespace Sample.Dialog {
11+
internal static class Default {
12+
static Default() {
13+
jQuery.OnDocumentReady(delegate() {
14+
jQuery.Select("#dialog1")
15+
.Plugin<DialogObject>()
16+
.Dialog();
17+
});
18+
}
19+
}
20+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// ModalConfirmation.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Sample/Button
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using System;
8+
using jQueryApi;
9+
using jQueryApi.UI.Widgets;
10+
11+
namespace Sample.Dialog {
12+
internal static class ModalConfirmation {
13+
static ModalConfirmation() {
14+
jQuery.OnDocumentReady(delegate() {
15+
jQuery.Select("#dialog-confirm")
16+
.Plugin<DialogObject>()
17+
.Dialog(new DialogOptions(DialogOption.Resizable, false,
18+
DialogOption.Height, 200,
19+
DialogOption.Width, 500,
20+
DialogOption.Modal, true,
21+
DialogOption.Buttons, new DialogOptions(
22+
"Delete all items", new Action(delegate() {
23+
jQuery.This.Plugin<DialogObject>()
24+
.Dialog(DialogMethod.Close);
25+
}),
26+
"Cancel", new Action(delegate() {
27+
jQuery.This.Plugin<DialogObject>()
28+
.Dialog(DialogMethod.Close);
29+
}))));
30+
});
31+
}
32+
}
33+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// ModalDialog.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Sample/Button
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using jQueryApi;
8+
using jQueryApi.UI.Widgets;
9+
10+
namespace Sample.Dialog {
11+
internal static class ModalDialog {
12+
static ModalDialog() {
13+
jQuery.OnDocumentReady(delegate() {
14+
jQuery.Select("#dialog-modal")
15+
.Plugin<DialogObject>()
16+
.Dialog(new DialogOptions(DialogOption.Height, 140,
17+
DialogOption.Modal, true));
18+
});
19+
}
20+
}
21+
}
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Default.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Sample/Button
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using System;
8+
using System.Html;
9+
using jQueryApi;
10+
using jQueryApi.UI.Widgets;
11+
12+
namespace Sample.Dialog {
13+
internal static class ModalForm {
14+
static ModalForm() {
15+
jQuery.OnDocumentReady(delegate() {
16+
jQueryObject name = jQuery.Select("#name");
17+
jQueryObject email = jQuery.Select("#email");
18+
jQueryObject password = jQuery.Select("#password");
19+
jQueryObject allFields = jQuery.FromObject(new jQuery[] { }).Add(name).Add(email).Add(password);
20+
jQueryObject tips = jQuery.Select(".validateTips");
21+
22+
Action<string> updateTips = new Action<string>(delegate(string t) {
23+
tips.Text(t)
24+
.AddClass("ui-state-highlight");
25+
26+
Window.SetTimeout(new Action(delegate() {
27+
tips.RemoveClass("ui-state-highlight"); //, 1500 );
28+
}), 500);
29+
});
30+
31+
Func<jQueryObject, string, int, int, bool> checkLength = new Func<jQueryObject, string, int, int, bool>(
32+
delegate(jQueryObject o, string n, int min, int max) {
33+
if (o.GetValue().Length > max || o.GetValue().Length < min) {
34+
o.AddClass("ui-state-error");
35+
updateTips("Length of " + n + " must be between " + min + " and " + max + ".");
36+
return false;
37+
} else {
38+
return true;
39+
}
40+
});
41+
42+
Func<jQueryObject, RegularExpression, string, bool> checkRegexp = new Func<jQueryObject, RegularExpression, string, bool>(
43+
delegate(jQueryObject o, RegularExpression regexp, string n) {
44+
if (!(regexp.Test(o.GetValue()))) {
45+
o.AddClass("ui-state-error");
46+
updateTips(n);
47+
return false;
48+
} else {
49+
return true;
50+
}
51+
});
52+
53+
jQuery.Select("#dialog-form")
54+
.Plugin<DialogObject>()
55+
.Dialog(new DialogOptions(
56+
DialogOption.AutoOpen, false,
57+
DialogOption.Height, 300,
58+
DialogOption.Width, 350,
59+
DialogOption.Modal, true,
60+
DialogOption.Buttons, new DialogOptions(
61+
"Create an account", new Action(delegate() {
62+
bool bValid = true;
63+
allFields.RemoveClass("ui-state-error");
64+
65+
bValid = bValid && checkLength(name, "username", 3, 16);
66+
bValid = bValid && checkLength(email, "email", 6, 80);
67+
bValid = bValid && checkLength(password, "password", 5, 16);
68+
69+
bValid = bValid && checkRegexp(name, new RegularExpression("^[a-z]([0-9a-z_])+$"), "Username may consist of a-z, 0-9, underscores, begin with a letter.");
70+
// From jquery.validate.js (by joern), contributed by Scott Gonzalez: http://projects.scottsplayground.com/email_address_validation/
71+
bValid = bValid && checkRegexp(email, new RegularExpression(@"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$"), "eg. [email protected]");
72+
bValid = bValid && checkRegexp(password, new RegularExpression("^([0-9a-zA-Z])+$"), "Password field only allow : a-z 0-9");
73+
74+
if (bValid) {
75+
jQuery.Select("#users tbody")
76+
.Append("<tr>" +
77+
"<td>" + name.GetValue() + "</td>" +
78+
"<td>" + email.GetValue() + "</td>" +
79+
"<td>" + password.GetValue() + "</td>" +
80+
"</tr>");
81+
jQuery.This.Plugin<DialogObject>()
82+
.Dialog(DialogMethod.Close);
83+
}
84+
}),
85+
"Cancel", new Action(delegate() {
86+
jQuery.This.Plugin<DialogObject>()
87+
.Dialog(DialogMethod.Close);
88+
})),
89+
DialogEvents.Close, new Action(delegate() {
90+
allFields.Value("").RemoveClass("ui-state-error");
91+
})));
92+
93+
jQuery.Select("#create-user")
94+
.Plugin<ButtonObject>()
95+
.Button()
96+
.Click(new jQueryEventHandler(delegate(jQueryEvent e) {
97+
jQuery.Select("#dialog-form").Plugin<DialogObject>().Dialog(DialogMethod.Open);
98+
}));
99+
});
100+
}
101+
}
102+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// ModalMessage.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Sample/Button
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using System;
8+
using jQueryApi;
9+
using jQueryApi.UI.Widgets;
10+
11+
namespace Sample.Dialog {
12+
internal static class ModalMessage {
13+
static ModalMessage() {
14+
jQuery.OnDocumentReady(delegate() {
15+
jQuery.Select("#dialog-message")
16+
.Plugin<DialogObject>()
17+
.Dialog(new DialogOptions(DialogOption.Modal, true,
18+
DialogOption.Buttons, new DialogOptions(
19+
"Ok", new Action(delegate() {
20+
jQuery.This.Plugin<DialogObject>()
21+
.Dialog(DialogMethod.Close);
22+
}))));
23+
});
24+
}
25+
}
26+
}

Samples/jQuery.UI.Sample/jQuery.UI.Sample.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@
7171
<Compile Include="Button\Icons.cs" />
7272
<Compile Include="Button\Radios.cs" />
7373
<Compile Include="Button\Default.cs" />
74+
<Compile Include="Dialog\AnimatedDialog.cs" />
75+
<Compile Include="Dialog\ModalForm.cs" />
76+
<Compile Include="Dialog\ModalConfirmation.cs" />
77+
<Compile Include="Dialog\ModalMessage.cs" />
78+
<Compile Include="Dialog\ModalDialog.cs" />
79+
<Compile Include="Dialog\Default.cs" />
7480
<Compile Include="Position\Cycling.cs" />
7581
<Compile Include="Position\Default.cs" />
7682
<Compile Include="Sortable\ConnectLists.cs" />
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// DialogController.cs
2+
// Script#/samples/jQuery.UI/jQuery.UI.Web/Controllers
3+
// Copyright (c) Ivaylo Gochkov, 2012
4+
// This source code is subject to terms and conditions of the Apache License, Version 2.0.
5+
//
6+
7+
using System.Web.Mvc;
8+
9+
namespace jQuery.UI.Web.Controllers {
10+
public class DialogController : Controller {
11+
public ActionResult Default() {
12+
return View();
13+
}
14+
15+
public ActionResult AnimatedDialog() {
16+
return View();
17+
}
18+
19+
public ActionResult ModalDialog() {
20+
return View();
21+
}
22+
23+
public ActionResult ModalMessage() {
24+
return View();
25+
}
26+
27+
public ActionResult ModalConfirmation() {
28+
return View();
29+
}
30+
31+
public ActionResult ModalForm() {
32+
return View();
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)