mirror of https://github.com/SixLabors/ImageSharp
Browse Source
Github is correctly interpreting the project as being written in javascript so I've chopped out all of it to try and get it to correctly interpret it as C# Former-commit-id: caf279d1c173f03cf7e5a4ba7ac7fd600cfb075faf/merge-core
32 changed files with 44 additions and 5872 deletions
@ -1,193 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Web; |
|||
using System.Web.Mvc; |
|||
using System.Web.Routing; |
|||
using System.Web.Security; |
|||
using Test.Models; |
|||
|
|||
namespace Test.Controllers |
|||
{ |
|||
public class AccountController : Controller |
|||
{ |
|||
|
|||
//
|
|||
// GET: /Account/LogOn
|
|||
|
|||
public ActionResult LogOn() |
|||
{ |
|||
return View(); |
|||
} |
|||
|
|||
//
|
|||
// POST: /Account/LogOn
|
|||
|
|||
[HttpPost] |
|||
public ActionResult LogOn(LogOnModel model, string returnUrl) |
|||
{ |
|||
if (ModelState.IsValid) |
|||
{ |
|||
if (Membership.ValidateUser(model.UserName, model.Password)) |
|||
{ |
|||
FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); |
|||
if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") |
|||
&& !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\")) |
|||
{ |
|||
return Redirect(returnUrl); |
|||
} |
|||
else |
|||
{ |
|||
return RedirectToAction("Index", "Home"); |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
ModelState.AddModelError("", "The user name or password provided is incorrect."); |
|||
} |
|||
} |
|||
|
|||
// If we got this far, something failed, redisplay form
|
|||
return View(model); |
|||
} |
|||
|
|||
//
|
|||
// GET: /Account/LogOff
|
|||
|
|||
public ActionResult LogOff() |
|||
{ |
|||
FormsAuthentication.SignOut(); |
|||
|
|||
return RedirectToAction("Index", "Home"); |
|||
} |
|||
|
|||
//
|
|||
// GET: /Account/Register
|
|||
|
|||
public ActionResult Register() |
|||
{ |
|||
return View(); |
|||
} |
|||
|
|||
//
|
|||
// POST: /Account/Register
|
|||
|
|||
[HttpPost] |
|||
public ActionResult Register(RegisterModel model) |
|||
{ |
|||
if (ModelState.IsValid) |
|||
{ |
|||
// Attempt to register the user
|
|||
MembershipCreateStatus createStatus; |
|||
Membership.CreateUser(model.UserName, model.Password, model.Email, null, null, true, null, out createStatus); |
|||
|
|||
if (createStatus == MembershipCreateStatus.Success) |
|||
{ |
|||
FormsAuthentication.SetAuthCookie(model.UserName, false /* createPersistentCookie */); |
|||
return RedirectToAction("Index", "Home"); |
|||
} |
|||
else |
|||
{ |
|||
ModelState.AddModelError("", ErrorCodeToString(createStatus)); |
|||
} |
|||
} |
|||
|
|||
// If we got this far, something failed, redisplay form
|
|||
return View(model); |
|||
} |
|||
|
|||
//
|
|||
// GET: /Account/ChangePassword
|
|||
|
|||
[Authorize] |
|||
public ActionResult ChangePassword() |
|||
{ |
|||
return View(); |
|||
} |
|||
|
|||
//
|
|||
// POST: /Account/ChangePassword
|
|||
|
|||
[Authorize] |
|||
[HttpPost] |
|||
public ActionResult ChangePassword(ChangePasswordModel model) |
|||
{ |
|||
if (ModelState.IsValid) |
|||
{ |
|||
|
|||
// ChangePassword will throw an exception rather
|
|||
// than return false in certain failure scenarios.
|
|||
bool changePasswordSucceeded; |
|||
try |
|||
{ |
|||
MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */); |
|||
changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword); |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
changePasswordSucceeded = false; |
|||
} |
|||
|
|||
if (changePasswordSucceeded) |
|||
{ |
|||
return RedirectToAction("ChangePasswordSuccess"); |
|||
} |
|||
else |
|||
{ |
|||
ModelState.AddModelError("", "The current password is incorrect or the new password is invalid."); |
|||
} |
|||
} |
|||
|
|||
// If we got this far, something failed, redisplay form
|
|||
return View(model); |
|||
} |
|||
|
|||
//
|
|||
// GET: /Account/ChangePasswordSuccess
|
|||
|
|||
public ActionResult ChangePasswordSuccess() |
|||
{ |
|||
return View(); |
|||
} |
|||
|
|||
#region Status Codes
|
|||
private static string ErrorCodeToString(MembershipCreateStatus createStatus) |
|||
{ |
|||
// See http://go.microsoft.com/fwlink/?LinkID=177550 for
|
|||
// a full list of status codes.
|
|||
switch (createStatus) |
|||
{ |
|||
case MembershipCreateStatus.DuplicateUserName: |
|||
return "User name already exists. Please enter a different user name."; |
|||
|
|||
case MembershipCreateStatus.DuplicateEmail: |
|||
return "A user name for that e-mail address already exists. Please enter a different e-mail address."; |
|||
|
|||
case MembershipCreateStatus.InvalidPassword: |
|||
return "The password provided is invalid. Please enter a valid password value."; |
|||
|
|||
case MembershipCreateStatus.InvalidEmail: |
|||
return "The e-mail address provided is invalid. Please check the value and try again."; |
|||
|
|||
case MembershipCreateStatus.InvalidAnswer: |
|||
return "The password retrieval answer provided is invalid. Please check the value and try again."; |
|||
|
|||
case MembershipCreateStatus.InvalidQuestion: |
|||
return "The password retrieval question provided is invalid. Please check the value and try again."; |
|||
|
|||
case MembershipCreateStatus.InvalidUserName: |
|||
return "The user name provided is invalid. Please check the value and try again."; |
|||
|
|||
case MembershipCreateStatus.ProviderError: |
|||
return "The authentication provider returned an error. Please verify your entry and try again. If the problem persists, please contact your system administrator."; |
|||
|
|||
case MembershipCreateStatus.UserRejected: |
|||
return "The user creation request has been canceled. Please verify your entry and try again. If the problem persists, please contact your system administrator."; |
|||
|
|||
default: |
|||
return "An unknown error occurred. Please verify your entry and try again. If the problem persists, please contact your system administrator."; |
|||
} |
|||
} |
|||
#endregion
|
|||
} |
|||
} |
|||
@ -1,67 +0,0 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.ComponentModel.DataAnnotations; |
|||
using System.Globalization; |
|||
using System.Web.Mvc; |
|||
using System.Web.Security; |
|||
|
|||
namespace Test.Models |
|||
{ |
|||
|
|||
public class ChangePasswordModel |
|||
{ |
|||
[Required] |
|||
[DataType(DataType.Password)] |
|||
[Display(Name = "Current password")] |
|||
public string OldPassword { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] |
|||
[DataType(DataType.Password)] |
|||
[Display(Name = "New password")] |
|||
public string NewPassword { get; set; } |
|||
|
|||
[DataType(DataType.Password)] |
|||
[Display(Name = "Confirm new password")] |
|||
[Compare("NewPassword", ErrorMessage = "The new password and confirmation password do not match.")] |
|||
public string ConfirmPassword { get; set; } |
|||
} |
|||
|
|||
public class LogOnModel |
|||
{ |
|||
[Required] |
|||
[Display(Name = "User name")] |
|||
public string UserName { get; set; } |
|||
|
|||
[Required] |
|||
[DataType(DataType.Password)] |
|||
[Display(Name = "Password")] |
|||
public string Password { get; set; } |
|||
|
|||
[Display(Name = "Remember me?")] |
|||
public bool RememberMe { get; set; } |
|||
} |
|||
|
|||
public class RegisterModel |
|||
{ |
|||
[Required] |
|||
[Display(Name = "User name")] |
|||
public string UserName { get; set; } |
|||
|
|||
[Required] |
|||
[DataType(DataType.EmailAddress)] |
|||
[Display(Name = "Email address")] |
|||
public string Email { get; set; } |
|||
|
|||
[Required] |
|||
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)] |
|||
[DataType(DataType.Password)] |
|||
[Display(Name = "Password")] |
|||
public string Password { get; set; } |
|||
|
|||
[DataType(DataType.Password)] |
|||
[Display(Name = "Confirm password")] |
|||
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")] |
|||
public string ConfirmPassword { get; set; } |
|||
} |
|||
} |
|||
@ -1 +0,0 @@ |
|||
a5f7942ef2b6b06e3c1aac2110fe7e5a1d88bf51 |
|||
@ -1 +0,0 @@ |
|||
52e6626a072ad18c35926f81b94995a0c5eeee31 |
|||
@ -1,408 +0,0 @@ |
|||
//!----------------------------------------------------------
|
|||
//! Copyright (C) Microsoft Corporation. All rights reserved.
|
|||
//!----------------------------------------------------------
|
|||
//! MicrosoftMvcAjax.js
|
|||
|
|||
Type.registerNamespace('Sys.Mvc'); |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.AjaxOptions
|
|||
|
|||
Sys.Mvc.$create_AjaxOptions = function Sys_Mvc_AjaxOptions() { return {}; } |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.InsertionMode
|
|||
|
|||
Sys.Mvc.InsertionMode = function() { |
|||
/// <field name="replace" type="Number" integer="true" static="true">
|
|||
/// </field>
|
|||
/// <field name="insertBefore" type="Number" integer="true" static="true">
|
|||
/// </field>
|
|||
/// <field name="insertAfter" type="Number" integer="true" static="true">
|
|||
/// </field>
|
|||
}; |
|||
Sys.Mvc.InsertionMode.prototype = { |
|||
replace: 0, |
|||
insertBefore: 1, |
|||
insertAfter: 2 |
|||
} |
|||
Sys.Mvc.InsertionMode.registerEnum('Sys.Mvc.InsertionMode', false); |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.AjaxContext
|
|||
|
|||
Sys.Mvc.AjaxContext = function Sys_Mvc_AjaxContext(request, updateTarget, loadingElement, insertionMode) { |
|||
/// <param name="request" type="Sys.Net.WebRequest">
|
|||
/// </param>
|
|||
/// <param name="updateTarget" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="loadingElement" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="insertionMode" type="Sys.Mvc.InsertionMode">
|
|||
/// </param>
|
|||
/// <field name="_insertionMode" type="Sys.Mvc.InsertionMode">
|
|||
/// </field>
|
|||
/// <field name="_loadingElement" type="Object" domElement="true">
|
|||
/// </field>
|
|||
/// <field name="_response" type="Sys.Net.WebRequestExecutor">
|
|||
/// </field>
|
|||
/// <field name="_request" type="Sys.Net.WebRequest">
|
|||
/// </field>
|
|||
/// <field name="_updateTarget" type="Object" domElement="true">
|
|||
/// </field>
|
|||
this._request = request; |
|||
this._updateTarget = updateTarget; |
|||
this._loadingElement = loadingElement; |
|||
this._insertionMode = insertionMode; |
|||
} |
|||
Sys.Mvc.AjaxContext.prototype = { |
|||
_insertionMode: 0, |
|||
_loadingElement: null, |
|||
_response: null, |
|||
_request: null, |
|||
_updateTarget: null, |
|||
|
|||
get_data: function Sys_Mvc_AjaxContext$get_data() { |
|||
/// <value type="String"></value>
|
|||
if (this._response) { |
|||
return this._response.get_responseData(); |
|||
} |
|||
else { |
|||
return null; |
|||
} |
|||
}, |
|||
|
|||
get_insertionMode: function Sys_Mvc_AjaxContext$get_insertionMode() { |
|||
/// <value type="Sys.Mvc.InsertionMode"></value>
|
|||
return this._insertionMode; |
|||
}, |
|||
|
|||
get_loadingElement: function Sys_Mvc_AjaxContext$get_loadingElement() { |
|||
/// <value type="Object" domElement="true"></value>
|
|||
return this._loadingElement; |
|||
}, |
|||
|
|||
get_object: function Sys_Mvc_AjaxContext$get_object() { |
|||
/// <value type="Object"></value>
|
|||
var executor = this.get_response(); |
|||
return (executor) ? executor.get_object() : null; |
|||
}, |
|||
|
|||
get_response: function Sys_Mvc_AjaxContext$get_response() { |
|||
/// <value type="Sys.Net.WebRequestExecutor"></value>
|
|||
return this._response; |
|||
}, |
|||
set_response: function Sys_Mvc_AjaxContext$set_response(value) { |
|||
/// <value type="Sys.Net.WebRequestExecutor"></value>
|
|||
this._response = value; |
|||
return value; |
|||
}, |
|||
|
|||
get_request: function Sys_Mvc_AjaxContext$get_request() { |
|||
/// <value type="Sys.Net.WebRequest"></value>
|
|||
return this._request; |
|||
}, |
|||
|
|||
get_updateTarget: function Sys_Mvc_AjaxContext$get_updateTarget() { |
|||
/// <value type="Object" domElement="true"></value>
|
|||
return this._updateTarget; |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.AsyncHyperlink
|
|||
|
|||
Sys.Mvc.AsyncHyperlink = function Sys_Mvc_AsyncHyperlink() { |
|||
} |
|||
Sys.Mvc.AsyncHyperlink.handleClick = function Sys_Mvc_AsyncHyperlink$handleClick(anchor, evt, ajaxOptions) { |
|||
/// <param name="anchor" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="evt" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
/// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
|
|||
/// </param>
|
|||
evt.preventDefault(); |
|||
Sys.Mvc.MvcHelpers._asyncRequest(anchor.href, 'post', '', anchor, ajaxOptions); |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.MvcHelpers
|
|||
|
|||
Sys.Mvc.MvcHelpers = function Sys_Mvc_MvcHelpers() { |
|||
} |
|||
Sys.Mvc.MvcHelpers._serializeSubmitButton = function Sys_Mvc_MvcHelpers$_serializeSubmitButton(element, offsetX, offsetY) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="offsetX" type="Number" integer="true">
|
|||
/// </param>
|
|||
/// <param name="offsetY" type="Number" integer="true">
|
|||
/// </param>
|
|||
/// <returns type="String"></returns>
|
|||
if (element.disabled) { |
|||
return null; |
|||
} |
|||
var name = element.name; |
|||
if (name) { |
|||
var tagName = element.tagName.toUpperCase(); |
|||
var encodedName = encodeURIComponent(name); |
|||
var inputElement = element; |
|||
if (tagName === 'INPUT') { |
|||
var type = inputElement.type; |
|||
if (type === 'submit') { |
|||
return encodedName + '=' + encodeURIComponent(inputElement.value); |
|||
} |
|||
else if (type === 'image') { |
|||
return encodedName + '.x=' + offsetX + '&' + encodedName + '.y=' + offsetY; |
|||
} |
|||
} |
|||
else if ((tagName === 'BUTTON') && (name.length) && (inputElement.type === 'submit')) { |
|||
return encodedName + '=' + encodeURIComponent(inputElement.value); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
Sys.Mvc.MvcHelpers._serializeForm = function Sys_Mvc_MvcHelpers$_serializeForm(form) { |
|||
/// <param name="form" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="String"></returns>
|
|||
var formElements = form.elements; |
|||
var formBody = new Sys.StringBuilder(); |
|||
var count = formElements.length; |
|||
for (var i = 0; i < count; i++) { |
|||
var element = formElements[i]; |
|||
var name = element.name; |
|||
if (!name || !name.length) { |
|||
continue; |
|||
} |
|||
var tagName = element.tagName.toUpperCase(); |
|||
if (tagName === 'INPUT') { |
|||
var inputElement = element; |
|||
var type = inputElement.type; |
|||
if ((type === 'text') || (type === 'password') || (type === 'hidden') || (((type === 'checkbox') || (type === 'radio')) && element.checked)) { |
|||
formBody.append(encodeURIComponent(name)); |
|||
formBody.append('='); |
|||
formBody.append(encodeURIComponent(inputElement.value)); |
|||
formBody.append('&'); |
|||
} |
|||
} |
|||
else if (tagName === 'SELECT') { |
|||
var selectElement = element; |
|||
var optionCount = selectElement.options.length; |
|||
for (var j = 0; j < optionCount; j++) { |
|||
var optionElement = selectElement.options[j]; |
|||
if (optionElement.selected) { |
|||
formBody.append(encodeURIComponent(name)); |
|||
formBody.append('='); |
|||
formBody.append(encodeURIComponent(optionElement.value)); |
|||
formBody.append('&'); |
|||
} |
|||
} |
|||
} |
|||
else if (tagName === 'TEXTAREA') { |
|||
formBody.append(encodeURIComponent(name)); |
|||
formBody.append('='); |
|||
formBody.append(encodeURIComponent((element.value))); |
|||
formBody.append('&'); |
|||
} |
|||
} |
|||
var additionalInput = form._additionalInput; |
|||
if (additionalInput) { |
|||
formBody.append(additionalInput); |
|||
formBody.append('&'); |
|||
} |
|||
return formBody.toString(); |
|||
} |
|||
Sys.Mvc.MvcHelpers._asyncRequest = function Sys_Mvc_MvcHelpers$_asyncRequest(url, verb, body, triggerElement, ajaxOptions) { |
|||
/// <param name="url" type="String">
|
|||
/// </param>
|
|||
/// <param name="verb" type="String">
|
|||
/// </param>
|
|||
/// <param name="body" type="String">
|
|||
/// </param>
|
|||
/// <param name="triggerElement" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
|
|||
/// </param>
|
|||
if (ajaxOptions.confirm) { |
|||
if (!confirm(ajaxOptions.confirm)) { |
|||
return; |
|||
} |
|||
} |
|||
if (ajaxOptions.url) { |
|||
url = ajaxOptions.url; |
|||
} |
|||
if (ajaxOptions.httpMethod) { |
|||
verb = ajaxOptions.httpMethod; |
|||
} |
|||
if (body.length > 0 && !body.endsWith('&')) { |
|||
body += '&'; |
|||
} |
|||
body += 'X-Requested-With=XMLHttpRequest'; |
|||
var upperCaseVerb = verb.toUpperCase(); |
|||
var isGetOrPost = (upperCaseVerb === 'GET' || upperCaseVerb === 'POST'); |
|||
if (!isGetOrPost) { |
|||
body += '&'; |
|||
body += 'X-HTTP-Method-Override=' + upperCaseVerb; |
|||
} |
|||
var requestBody = ''; |
|||
if (upperCaseVerb === 'GET' || upperCaseVerb === 'DELETE') { |
|||
if (url.indexOf('?') > -1) { |
|||
if (!url.endsWith('&')) { |
|||
url += '&'; |
|||
} |
|||
url += body; |
|||
} |
|||
else { |
|||
url += '?'; |
|||
url += body; |
|||
} |
|||
} |
|||
else { |
|||
requestBody = body; |
|||
} |
|||
var request = new Sys.Net.WebRequest(); |
|||
request.set_url(url); |
|||
if (isGetOrPost) { |
|||
request.set_httpVerb(verb); |
|||
} |
|||
else { |
|||
request.set_httpVerb('POST'); |
|||
request.get_headers()['X-HTTP-Method-Override'] = upperCaseVerb; |
|||
} |
|||
request.set_body(requestBody); |
|||
if (verb.toUpperCase() === 'PUT') { |
|||
request.get_headers()['Content-Type'] = 'application/x-www-form-urlencoded;'; |
|||
} |
|||
request.get_headers()['X-Requested-With'] = 'XMLHttpRequest'; |
|||
var updateElement = null; |
|||
if (ajaxOptions.updateTargetId) { |
|||
updateElement = $get(ajaxOptions.updateTargetId); |
|||
} |
|||
var loadingElement = null; |
|||
if (ajaxOptions.loadingElementId) { |
|||
loadingElement = $get(ajaxOptions.loadingElementId); |
|||
} |
|||
var ajaxContext = new Sys.Mvc.AjaxContext(request, updateElement, loadingElement, ajaxOptions.insertionMode); |
|||
var continueRequest = true; |
|||
if (ajaxOptions.onBegin) { |
|||
continueRequest = ajaxOptions.onBegin(ajaxContext) !== false; |
|||
} |
|||
if (loadingElement) { |
|||
Sys.UI.DomElement.setVisible(ajaxContext.get_loadingElement(), true); |
|||
} |
|||
if (continueRequest) { |
|||
request.add_completed(Function.createDelegate(null, function(executor) { |
|||
Sys.Mvc.MvcHelpers._onComplete(request, ajaxOptions, ajaxContext); |
|||
})); |
|||
request.invoke(); |
|||
} |
|||
} |
|||
Sys.Mvc.MvcHelpers._onComplete = function Sys_Mvc_MvcHelpers$_onComplete(request, ajaxOptions, ajaxContext) { |
|||
/// <param name="request" type="Sys.Net.WebRequest">
|
|||
/// </param>
|
|||
/// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
|
|||
/// </param>
|
|||
/// <param name="ajaxContext" type="Sys.Mvc.AjaxContext">
|
|||
/// </param>
|
|||
ajaxContext.set_response(request.get_executor()); |
|||
if (ajaxOptions.onComplete && ajaxOptions.onComplete(ajaxContext) === false) { |
|||
return; |
|||
} |
|||
var statusCode = ajaxContext.get_response().get_statusCode(); |
|||
if ((statusCode >= 200 && statusCode < 300) || statusCode === 304 || statusCode === 1223) { |
|||
if (statusCode !== 204 && statusCode !== 304 && statusCode !== 1223) { |
|||
var contentType = ajaxContext.get_response().getResponseHeader('Content-Type'); |
|||
if ((contentType) && (contentType.indexOf('application/x-javascript') !== -1)) { |
|||
eval(ajaxContext.get_data()); |
|||
} |
|||
else { |
|||
Sys.Mvc.MvcHelpers.updateDomElement(ajaxContext.get_updateTarget(), ajaxContext.get_insertionMode(), ajaxContext.get_data()); |
|||
} |
|||
} |
|||
if (ajaxOptions.onSuccess) { |
|||
ajaxOptions.onSuccess(ajaxContext); |
|||
} |
|||
} |
|||
else { |
|||
if (ajaxOptions.onFailure) { |
|||
ajaxOptions.onFailure(ajaxContext); |
|||
} |
|||
} |
|||
if (ajaxContext.get_loadingElement()) { |
|||
Sys.UI.DomElement.setVisible(ajaxContext.get_loadingElement(), false); |
|||
} |
|||
} |
|||
Sys.Mvc.MvcHelpers.updateDomElement = function Sys_Mvc_MvcHelpers$updateDomElement(target, insertionMode, content) { |
|||
/// <param name="target" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="insertionMode" type="Sys.Mvc.InsertionMode">
|
|||
/// </param>
|
|||
/// <param name="content" type="String">
|
|||
/// </param>
|
|||
if (target) { |
|||
switch (insertionMode) { |
|||
case Sys.Mvc.InsertionMode.replace: |
|||
target.innerHTML = content; |
|||
break; |
|||
case Sys.Mvc.InsertionMode.insertBefore: |
|||
if (content && content.length > 0) { |
|||
target.innerHTML = content + target.innerHTML.trimStart(); |
|||
} |
|||
break; |
|||
case Sys.Mvc.InsertionMode.insertAfter: |
|||
if (content && content.length > 0) { |
|||
target.innerHTML = target.innerHTML.trimEnd() + content; |
|||
} |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.AsyncForm
|
|||
|
|||
Sys.Mvc.AsyncForm = function Sys_Mvc_AsyncForm() { |
|||
} |
|||
Sys.Mvc.AsyncForm.handleClick = function Sys_Mvc_AsyncForm$handleClick(form, evt) { |
|||
/// <param name="form" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="evt" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
var additionalInput = Sys.Mvc.MvcHelpers._serializeSubmitButton(evt.target, evt.offsetX, evt.offsetY); |
|||
form._additionalInput = additionalInput; |
|||
} |
|||
Sys.Mvc.AsyncForm.handleSubmit = function Sys_Mvc_AsyncForm$handleSubmit(form, evt, ajaxOptions) { |
|||
/// <param name="form" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="evt" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
/// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
|
|||
/// </param>
|
|||
evt.preventDefault(); |
|||
var validationCallbacks = form.validationCallbacks; |
|||
if (validationCallbacks) { |
|||
for (var i = 0; i < validationCallbacks.length; i++) { |
|||
var callback = validationCallbacks[i]; |
|||
if (!callback()) { |
|||
return; |
|||
} |
|||
} |
|||
} |
|||
var body = Sys.Mvc.MvcHelpers._serializeForm(form); |
|||
Sys.Mvc.MvcHelpers._asyncRequest(form.action, form.method || 'post', body, form, ajaxOptions); |
|||
} |
|||
|
|||
|
|||
Sys.Mvc.AjaxContext.registerClass('Sys.Mvc.AjaxContext'); |
|||
Sys.Mvc.AsyncHyperlink.registerClass('Sys.Mvc.AsyncHyperlink'); |
|||
Sys.Mvc.MvcHelpers.registerClass('Sys.Mvc.MvcHelpers'); |
|||
Sys.Mvc.AsyncForm.registerClass('Sys.Mvc.AsyncForm'); |
|||
|
|||
// ---- Do not remove this footer ----
|
|||
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
|
|||
// -----------------------------------
|
|||
@ -1,25 +0,0 @@ |
|||
//----------------------------------------------------------
|
|||
// Copyright (C) Microsoft Corporation. All rights reserved.
|
|||
//----------------------------------------------------------
|
|||
// MicrosoftMvcAjax.js
|
|||
|
|||
Type.registerNamespace('Sys.Mvc');Sys.Mvc.$create_AjaxOptions=function(){return {};} |
|||
Sys.Mvc.InsertionMode=function(){};Sys.Mvc.InsertionMode.prototype = {replace:0,insertBefore:1,insertAfter:2} |
|||
Sys.Mvc.InsertionMode.registerEnum('Sys.Mvc.InsertionMode',false);Sys.Mvc.AjaxContext=function(request,updateTarget,loadingElement,insertionMode){this.$3=request;this.$4=updateTarget;this.$1=loadingElement;this.$0=insertionMode;} |
|||
Sys.Mvc.AjaxContext.prototype={$0:0,$1:null,$2:null,$3:null,$4:null,get_data:function(){if(this.$2){return this.$2.get_responseData();}else{return null;}},get_insertionMode:function(){return this.$0;},get_loadingElement:function(){return this.$1;},get_object:function(){var $0=this.get_response();return ($0)?$0.get_object():null;},get_response:function(){return this.$2;},set_response:function(value){this.$2=value;return value;},get_request:function(){return this.$3;},get_updateTarget:function(){return this.$4;}} |
|||
Sys.Mvc.AsyncHyperlink=function(){} |
|||
Sys.Mvc.AsyncHyperlink.handleClick=function(anchor,evt,ajaxOptions){evt.preventDefault();Sys.Mvc.MvcHelpers.$2(anchor.href,'post','',anchor,ajaxOptions);} |
|||
Sys.Mvc.MvcHelpers=function(){} |
|||
Sys.Mvc.MvcHelpers.$0=function($p0,$p1,$p2){if($p0.disabled){return null;}var $0=$p0.name;if($0){var $1=$p0.tagName.toUpperCase();var $2=encodeURIComponent($0);var $3=$p0;if($1==='INPUT'){var $4=$3.type;if($4==='submit'){return $2+'='+encodeURIComponent($3.value);}else if($4==='image'){return $2+'.x='+$p1+'&'+$2+'.y='+$p2;}}else if(($1==='BUTTON')&&($0.length)&&($3.type==='submit')){return $2+'='+encodeURIComponent($3.value);}}return null;} |
|||
Sys.Mvc.MvcHelpers.$1=function($p0){var $0=$p0.elements;var $1=new Sys.StringBuilder();var $2=$0.length;for(var $4=0;$4<$2;$4++){var $5=$0[$4];var $6=$5.name;if(!$6||!$6.length){continue;}var $7=$5.tagName.toUpperCase();if($7==='INPUT'){var $8=$5;var $9=$8.type;if(($9==='text')||($9==='password')||($9==='hidden')||((($9==='checkbox')||($9==='radio'))&&$5.checked)){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent($8.value));$1.append('&');}}else if($7==='SELECT'){var $A=$5;var $B=$A.options.length;for(var $C=0;$C<$B;$C++){var $D=$A.options[$C];if($D.selected){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent($D.value));$1.append('&');}}}else if($7==='TEXTAREA'){$1.append(encodeURIComponent($6));$1.append('=');$1.append(encodeURIComponent(($5.value)));$1.append('&');}}var $3=$p0._additionalInput;if($3){$1.append($3);$1.append('&');}return $1.toString();} |
|||
Sys.Mvc.MvcHelpers.$2=function($p0,$p1,$p2,$p3,$p4){if($p4.confirm){if(!confirm($p4.confirm)){return;}}if($p4.url){$p0=$p4.url;}if($p4.httpMethod){$p1=$p4.httpMethod;}if($p2.length>0&&!$p2.endsWith('&')){$p2+='&';}$p2+='X-Requested-With=XMLHttpRequest';var $0=$p1.toUpperCase();var $1=($0==='GET'||$0==='POST');if(!$1){$p2+='&';$p2+='X-HTTP-Method-Override='+$0;}var $2='';if($0==='GET'||$0==='DELETE'){if($p0.indexOf('?')>-1){if(!$p0.endsWith('&')){$p0+='&';}$p0+=$p2;}else{$p0+='?';$p0+=$p2;}}else{$2=$p2;}var $3=new Sys.Net.WebRequest();$3.set_url($p0);if($1){$3.set_httpVerb($p1);}else{$3.set_httpVerb('POST');$3.get_headers()['X-HTTP-Method-Override']=$0;}$3.set_body($2);if($p1.toUpperCase()==='PUT'){$3.get_headers()['Content-Type']='application/x-www-form-urlencoded;';}$3.get_headers()['X-Requested-With']='XMLHttpRequest';var $4=null;if($p4.updateTargetId){$4=$get($p4.updateTargetId);}var $5=null;if($p4.loadingElementId){$5=$get($p4.loadingElementId);}var $6=new Sys.Mvc.AjaxContext($3,$4,$5,$p4.insertionMode);var $7=true;if($p4.onBegin){$7=$p4.onBegin($6)!==false;}if($5){Sys.UI.DomElement.setVisible($6.get_loadingElement(),true);}if($7){$3.add_completed(Function.createDelegate(null,function($p1_0){ |
|||
Sys.Mvc.MvcHelpers.$3($3,$p4,$6);}));$3.invoke();}} |
|||
Sys.Mvc.MvcHelpers.$3=function($p0,$p1,$p2){$p2.set_response($p0.get_executor());if($p1.onComplete&&$p1.onComplete($p2)===false){return;}var $0=$p2.get_response().get_statusCode();if(($0>=200&&$0<300)||$0===304||$0===1223){if($0!==204&&$0!==304&&$0!==1223){var $1=$p2.get_response().getResponseHeader('Content-Type');if(($1)&&($1.indexOf('application/x-javascript')!==-1)){eval($p2.get_data());}else{Sys.Mvc.MvcHelpers.updateDomElement($p2.get_updateTarget(),$p2.get_insertionMode(),$p2.get_data());}}if($p1.onSuccess){$p1.onSuccess($p2);}}else{if($p1.onFailure){$p1.onFailure($p2);}}if($p2.get_loadingElement()){Sys.UI.DomElement.setVisible($p2.get_loadingElement(),false);}} |
|||
Sys.Mvc.MvcHelpers.updateDomElement=function(target,insertionMode,content){if(target){switch(insertionMode){case 0:target.innerHTML=content;break;case 1:if(content&&content.length>0){target.innerHTML=content+target.innerHTML.trimStart();}break;case 2:if(content&&content.length>0){target.innerHTML=target.innerHTML.trimEnd()+content;}break;}}} |
|||
Sys.Mvc.AsyncForm=function(){} |
|||
Sys.Mvc.AsyncForm.handleClick=function(form,evt){var $0=Sys.Mvc.MvcHelpers.$0(evt.target,evt.offsetX,evt.offsetY);form._additionalInput = $0;} |
|||
Sys.Mvc.AsyncForm.handleSubmit=function(form,evt,ajaxOptions){evt.preventDefault();var $0=form.validationCallbacks;if($0){for(var $2=0;$2<$0.length;$2++){var $3=$0[$2];if(!$3()){return;}}}var $1=Sys.Mvc.MvcHelpers.$1(form);Sys.Mvc.MvcHelpers.$2(form.action,form.method||'post',$1,form,ajaxOptions);} |
|||
Sys.Mvc.AjaxContext.registerClass('Sys.Mvc.AjaxContext');Sys.Mvc.AsyncHyperlink.registerClass('Sys.Mvc.AsyncHyperlink');Sys.Mvc.MvcHelpers.registerClass('Sys.Mvc.MvcHelpers');Sys.Mvc.AsyncForm.registerClass('Sys.Mvc.AsyncForm'); |
|||
// ---- Do not remove this footer ----
|
|||
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
|
|||
// -----------------------------------
|
|||
@ -1,883 +0,0 @@ |
|||
//!----------------------------------------------------------
|
|||
//! Copyright (C) Microsoft Corporation. All rights reserved.
|
|||
//!----------------------------------------------------------
|
|||
//! MicrosoftMvcValidation.js
|
|||
|
|||
|
|||
Type.registerNamespace('Sys.Mvc'); |
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.Validation
|
|||
|
|||
Sys.Mvc.$create_Validation = function Sys_Mvc_Validation() { return {}; } |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.JsonValidationField
|
|||
|
|||
Sys.Mvc.$create_JsonValidationField = function Sys_Mvc_JsonValidationField() { return {}; } |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.JsonValidationOptions
|
|||
|
|||
Sys.Mvc.$create_JsonValidationOptions = function Sys_Mvc_JsonValidationOptions() { return {}; } |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.JsonValidationRule
|
|||
|
|||
Sys.Mvc.$create_JsonValidationRule = function Sys_Mvc_JsonValidationRule() { return {}; } |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.ValidationContext
|
|||
|
|||
Sys.Mvc.$create_ValidationContext = function Sys_Mvc_ValidationContext() { return {}; } |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.NumberValidator
|
|||
|
|||
Sys.Mvc.NumberValidator = function Sys_Mvc_NumberValidator() { |
|||
} |
|||
Sys.Mvc.NumberValidator.create = function Sys_Mvc_NumberValidator$create(rule) { |
|||
/// <param name="rule" type="Sys.Mvc.JsonValidationRule">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.Validator"></returns>
|
|||
return Function.createDelegate(new Sys.Mvc.NumberValidator(), new Sys.Mvc.NumberValidator().validate); |
|||
} |
|||
Sys.Mvc.NumberValidator.prototype = { |
|||
|
|||
validate: function Sys_Mvc_NumberValidator$validate(value, context) { |
|||
/// <param name="value" type="String">
|
|||
/// </param>
|
|||
/// <param name="context" type="Sys.Mvc.ValidationContext">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) { |
|||
return true; |
|||
} |
|||
var n = Number.parseLocale(value); |
|||
return (!isNaN(n)); |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.FormContext
|
|||
|
|||
Sys.Mvc.FormContext = function Sys_Mvc_FormContext(formElement, validationSummaryElement) { |
|||
/// <param name="formElement" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="validationSummaryElement" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <field name="_validationSummaryErrorCss" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_validationSummaryValidCss" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_formValidationTag" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_onClickHandler" type="Sys.UI.DomEventHandler">
|
|||
/// </field>
|
|||
/// <field name="_onSubmitHandler" type="Sys.UI.DomEventHandler">
|
|||
/// </field>
|
|||
/// <field name="_errors" type="Array">
|
|||
/// </field>
|
|||
/// <field name="_submitButtonClicked" type="Object" domElement="true">
|
|||
/// </field>
|
|||
/// <field name="_validationSummaryElement" type="Object" domElement="true">
|
|||
/// </field>
|
|||
/// <field name="_validationSummaryULElement" type="Object" domElement="true">
|
|||
/// </field>
|
|||
/// <field name="fields" type="Array" elementType="FieldContext">
|
|||
/// </field>
|
|||
/// <field name="_formElement" type="Object" domElement="true">
|
|||
/// </field>
|
|||
/// <field name="replaceValidationSummary" type="Boolean">
|
|||
/// </field>
|
|||
this._errors = []; |
|||
this.fields = new Array(0); |
|||
this._formElement = formElement; |
|||
this._validationSummaryElement = validationSummaryElement; |
|||
formElement[Sys.Mvc.FormContext._formValidationTag] = this; |
|||
if (validationSummaryElement) { |
|||
var ulElements = validationSummaryElement.getElementsByTagName('ul'); |
|||
if (ulElements.length > 0) { |
|||
this._validationSummaryULElement = ulElements[0]; |
|||
} |
|||
} |
|||
this._onClickHandler = Function.createDelegate(this, this._form_OnClick); |
|||
this._onSubmitHandler = Function.createDelegate(this, this._form_OnSubmit); |
|||
} |
|||
Sys.Mvc.FormContext._Application_Load = function Sys_Mvc_FormContext$_Application_Load() { |
|||
var allFormOptions = window.mvcClientValidationMetadata; |
|||
if (allFormOptions) { |
|||
while (allFormOptions.length > 0) { |
|||
var thisFormOptions = allFormOptions.pop(); |
|||
Sys.Mvc.FormContext._parseJsonOptions(thisFormOptions); |
|||
} |
|||
} |
|||
} |
|||
Sys.Mvc.FormContext._getFormElementsWithName = function Sys_Mvc_FormContext$_getFormElementsWithName(formElement, name) { |
|||
/// <param name="formElement" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="name" type="String">
|
|||
/// </param>
|
|||
/// <returns type="Array" elementType="Object" elementDomElement="true"></returns>
|
|||
var allElementsWithNameInForm = []; |
|||
var allElementsWithName = document.getElementsByName(name); |
|||
for (var i = 0; i < allElementsWithName.length; i++) { |
|||
var thisElement = allElementsWithName[i]; |
|||
if (Sys.Mvc.FormContext._isElementInHierarchy(formElement, thisElement)) { |
|||
Array.add(allElementsWithNameInForm, thisElement); |
|||
} |
|||
} |
|||
return allElementsWithNameInForm; |
|||
} |
|||
Sys.Mvc.FormContext.getValidationForForm = function Sys_Mvc_FormContext$getValidationForForm(formElement) { |
|||
/// <param name="formElement" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.FormContext"></returns>
|
|||
return formElement[Sys.Mvc.FormContext._formValidationTag]; |
|||
} |
|||
Sys.Mvc.FormContext._isElementInHierarchy = function Sys_Mvc_FormContext$_isElementInHierarchy(parent, child) { |
|||
/// <param name="parent" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="child" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
while (child) { |
|||
if (parent === child) { |
|||
return true; |
|||
} |
|||
child = child.parentNode; |
|||
} |
|||
return false; |
|||
} |
|||
Sys.Mvc.FormContext._parseJsonOptions = function Sys_Mvc_FormContext$_parseJsonOptions(options) { |
|||
/// <param name="options" type="Sys.Mvc.JsonValidationOptions">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.FormContext"></returns>
|
|||
var formElement = $get(options.FormId); |
|||
var validationSummaryElement = (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(options.ValidationSummaryId)) ? $get(options.ValidationSummaryId) : null; |
|||
var formContext = new Sys.Mvc.FormContext(formElement, validationSummaryElement); |
|||
formContext.enableDynamicValidation(); |
|||
formContext.replaceValidationSummary = options.ReplaceValidationSummary; |
|||
for (var i = 0; i < options.Fields.length; i++) { |
|||
var field = options.Fields[i]; |
|||
var fieldElements = Sys.Mvc.FormContext._getFormElementsWithName(formElement, field.FieldName); |
|||
var validationMessageElement = (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(field.ValidationMessageId)) ? $get(field.ValidationMessageId) : null; |
|||
var fieldContext = new Sys.Mvc.FieldContext(formContext); |
|||
Array.addRange(fieldContext.elements, fieldElements); |
|||
fieldContext.validationMessageElement = validationMessageElement; |
|||
fieldContext.replaceValidationMessageContents = field.ReplaceValidationMessageContents; |
|||
for (var j = 0; j < field.ValidationRules.length; j++) { |
|||
var rule = field.ValidationRules[j]; |
|||
var validator = Sys.Mvc.ValidatorRegistry.getValidator(rule); |
|||
if (validator) { |
|||
var validation = Sys.Mvc.$create_Validation(); |
|||
validation.fieldErrorMessage = rule.ErrorMessage; |
|||
validation.validator = validator; |
|||
Array.add(fieldContext.validations, validation); |
|||
} |
|||
} |
|||
fieldContext.enableDynamicValidation(); |
|||
Array.add(formContext.fields, fieldContext); |
|||
} |
|||
var registeredValidatorCallbacks = formElement.validationCallbacks; |
|||
if (!registeredValidatorCallbacks) { |
|||
registeredValidatorCallbacks = []; |
|||
formElement.validationCallbacks = registeredValidatorCallbacks; |
|||
} |
|||
registeredValidatorCallbacks.push(Function.createDelegate(null, function() { |
|||
return Sys.Mvc._validationUtil.arrayIsNullOrEmpty(formContext.validate('submit')); |
|||
})); |
|||
return formContext; |
|||
} |
|||
Sys.Mvc.FormContext.prototype = { |
|||
_onClickHandler: null, |
|||
_onSubmitHandler: null, |
|||
_submitButtonClicked: null, |
|||
_validationSummaryElement: null, |
|||
_validationSummaryULElement: null, |
|||
_formElement: null, |
|||
replaceValidationSummary: false, |
|||
|
|||
addError: function Sys_Mvc_FormContext$addError(message) { |
|||
/// <param name="message" type="String">
|
|||
/// </param>
|
|||
this.addErrors([ message ]); |
|||
}, |
|||
|
|||
addErrors: function Sys_Mvc_FormContext$addErrors(messages) { |
|||
/// <param name="messages" type="Array" elementType="String">
|
|||
/// </param>
|
|||
if (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(messages)) { |
|||
Array.addRange(this._errors, messages); |
|||
this._onErrorCountChanged(); |
|||
} |
|||
}, |
|||
|
|||
clearErrors: function Sys_Mvc_FormContext$clearErrors() { |
|||
Array.clear(this._errors); |
|||
this._onErrorCountChanged(); |
|||
}, |
|||
|
|||
_displayError: function Sys_Mvc_FormContext$_displayError() { |
|||
if (this._validationSummaryElement) { |
|||
if (this._validationSummaryULElement) { |
|||
Sys.Mvc._validationUtil.removeAllChildren(this._validationSummaryULElement); |
|||
for (var i = 0; i < this._errors.length; i++) { |
|||
var liElement = document.createElement('li'); |
|||
Sys.Mvc._validationUtil.setInnerText(liElement, this._errors[i]); |
|||
this._validationSummaryULElement.appendChild(liElement); |
|||
} |
|||
} |
|||
Sys.UI.DomElement.removeCssClass(this._validationSummaryElement, Sys.Mvc.FormContext._validationSummaryValidCss); |
|||
Sys.UI.DomElement.addCssClass(this._validationSummaryElement, Sys.Mvc.FormContext._validationSummaryErrorCss); |
|||
} |
|||
}, |
|||
|
|||
_displaySuccess: function Sys_Mvc_FormContext$_displaySuccess() { |
|||
var validationSummaryElement = this._validationSummaryElement; |
|||
if (validationSummaryElement) { |
|||
var validationSummaryULElement = this._validationSummaryULElement; |
|||
if (validationSummaryULElement) { |
|||
validationSummaryULElement.innerHTML = ''; |
|||
} |
|||
Sys.UI.DomElement.removeCssClass(validationSummaryElement, Sys.Mvc.FormContext._validationSummaryErrorCss); |
|||
Sys.UI.DomElement.addCssClass(validationSummaryElement, Sys.Mvc.FormContext._validationSummaryValidCss); |
|||
} |
|||
}, |
|||
|
|||
enableDynamicValidation: function Sys_Mvc_FormContext$enableDynamicValidation() { |
|||
Sys.UI.DomEvent.addHandler(this._formElement, 'click', this._onClickHandler); |
|||
Sys.UI.DomEvent.addHandler(this._formElement, 'submit', this._onSubmitHandler); |
|||
}, |
|||
|
|||
_findSubmitButton: function Sys_Mvc_FormContext$_findSubmitButton(element) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Object" domElement="true"></returns>
|
|||
if (element.disabled) { |
|||
return null; |
|||
} |
|||
var tagName = element.tagName.toUpperCase(); |
|||
var inputElement = element; |
|||
if (tagName === 'INPUT') { |
|||
var type = inputElement.type; |
|||
if (type === 'submit' || type === 'image') { |
|||
return inputElement; |
|||
} |
|||
} |
|||
else if ((tagName === 'BUTTON') && (inputElement.type === 'submit')) { |
|||
return inputElement; |
|||
} |
|||
return null; |
|||
}, |
|||
|
|||
_form_OnClick: function Sys_Mvc_FormContext$_form_OnClick(e) { |
|||
/// <param name="e" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
this._submitButtonClicked = this._findSubmitButton(e.target); |
|||
}, |
|||
|
|||
_form_OnSubmit: function Sys_Mvc_FormContext$_form_OnSubmit(e) { |
|||
/// <param name="e" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
var form = e.target; |
|||
var submitButton = this._submitButtonClicked; |
|||
if (submitButton && submitButton.disableValidation) { |
|||
return; |
|||
} |
|||
var errorMessages = this.validate('submit'); |
|||
if (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(errorMessages)) { |
|||
e.preventDefault(); |
|||
} |
|||
}, |
|||
|
|||
_onErrorCountChanged: function Sys_Mvc_FormContext$_onErrorCountChanged() { |
|||
if (!this._errors.length) { |
|||
this._displaySuccess(); |
|||
} |
|||
else { |
|||
this._displayError(); |
|||
} |
|||
}, |
|||
|
|||
validate: function Sys_Mvc_FormContext$validate(eventName) { |
|||
/// <param name="eventName" type="String">
|
|||
/// </param>
|
|||
/// <returns type="Array" elementType="String"></returns>
|
|||
var fields = this.fields; |
|||
var errors = []; |
|||
for (var i = 0; i < fields.length; i++) { |
|||
var field = fields[i]; |
|||
if (!field.elements[0].disabled) { |
|||
var thisErrors = field.validate(eventName); |
|||
if (thisErrors) { |
|||
Array.addRange(errors, thisErrors); |
|||
} |
|||
} |
|||
} |
|||
if (this.replaceValidationSummary) { |
|||
this.clearErrors(); |
|||
this.addErrors(errors); |
|||
} |
|||
return errors; |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.FieldContext
|
|||
|
|||
Sys.Mvc.FieldContext = function Sys_Mvc_FieldContext(formContext) { |
|||
/// <param name="formContext" type="Sys.Mvc.FormContext">
|
|||
/// </param>
|
|||
/// <field name="_hasTextChangedTag" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_hasValidationFiredTag" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_inputElementErrorCss" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_inputElementValidCss" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_validationMessageErrorCss" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_validationMessageValidCss" type="String" static="true">
|
|||
/// </field>
|
|||
/// <field name="_onBlurHandler" type="Sys.UI.DomEventHandler">
|
|||
/// </field>
|
|||
/// <field name="_onChangeHandler" type="Sys.UI.DomEventHandler">
|
|||
/// </field>
|
|||
/// <field name="_onInputHandler" type="Sys.UI.DomEventHandler">
|
|||
/// </field>
|
|||
/// <field name="_onPropertyChangeHandler" type="Sys.UI.DomEventHandler">
|
|||
/// </field>
|
|||
/// <field name="_errors" type="Array">
|
|||
/// </field>
|
|||
/// <field name="defaultErrorMessage" type="String">
|
|||
/// </field>
|
|||
/// <field name="elements" type="Array" elementType="Object" elementDomElement="true">
|
|||
/// </field>
|
|||
/// <field name="formContext" type="Sys.Mvc.FormContext">
|
|||
/// </field>
|
|||
/// <field name="replaceValidationMessageContents" type="Boolean">
|
|||
/// </field>
|
|||
/// <field name="validationMessageElement" type="Object" domElement="true">
|
|||
/// </field>
|
|||
/// <field name="validations" type="Array" elementType="Validation">
|
|||
/// </field>
|
|||
this._errors = []; |
|||
this.elements = new Array(0); |
|||
this.validations = new Array(0); |
|||
this.formContext = formContext; |
|||
this._onBlurHandler = Function.createDelegate(this, this._element_OnBlur); |
|||
this._onChangeHandler = Function.createDelegate(this, this._element_OnChange); |
|||
this._onInputHandler = Function.createDelegate(this, this._element_OnInput); |
|||
this._onPropertyChangeHandler = Function.createDelegate(this, this._element_OnPropertyChange); |
|||
} |
|||
Sys.Mvc.FieldContext.prototype = { |
|||
_onBlurHandler: null, |
|||
_onChangeHandler: null, |
|||
_onInputHandler: null, |
|||
_onPropertyChangeHandler: null, |
|||
defaultErrorMessage: null, |
|||
formContext: null, |
|||
replaceValidationMessageContents: false, |
|||
validationMessageElement: null, |
|||
|
|||
addError: function Sys_Mvc_FieldContext$addError(message) { |
|||
/// <param name="message" type="String">
|
|||
/// </param>
|
|||
this.addErrors([ message ]); |
|||
}, |
|||
|
|||
addErrors: function Sys_Mvc_FieldContext$addErrors(messages) { |
|||
/// <param name="messages" type="Array" elementType="String">
|
|||
/// </param>
|
|||
if (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(messages)) { |
|||
Array.addRange(this._errors, messages); |
|||
this._onErrorCountChanged(); |
|||
} |
|||
}, |
|||
|
|||
clearErrors: function Sys_Mvc_FieldContext$clearErrors() { |
|||
Array.clear(this._errors); |
|||
this._onErrorCountChanged(); |
|||
}, |
|||
|
|||
_displayError: function Sys_Mvc_FieldContext$_displayError() { |
|||
var validationMessageElement = this.validationMessageElement; |
|||
if (validationMessageElement) { |
|||
if (this.replaceValidationMessageContents) { |
|||
Sys.Mvc._validationUtil.setInnerText(validationMessageElement, this._errors[0]); |
|||
} |
|||
Sys.UI.DomElement.removeCssClass(validationMessageElement, Sys.Mvc.FieldContext._validationMessageValidCss); |
|||
Sys.UI.DomElement.addCssClass(validationMessageElement, Sys.Mvc.FieldContext._validationMessageErrorCss); |
|||
} |
|||
var elements = this.elements; |
|||
for (var i = 0; i < elements.length; i++) { |
|||
var element = elements[i]; |
|||
Sys.UI.DomElement.removeCssClass(element, Sys.Mvc.FieldContext._inputElementValidCss); |
|||
Sys.UI.DomElement.addCssClass(element, Sys.Mvc.FieldContext._inputElementErrorCss); |
|||
} |
|||
}, |
|||
|
|||
_displaySuccess: function Sys_Mvc_FieldContext$_displaySuccess() { |
|||
var validationMessageElement = this.validationMessageElement; |
|||
if (validationMessageElement) { |
|||
if (this.replaceValidationMessageContents) { |
|||
Sys.Mvc._validationUtil.setInnerText(validationMessageElement, ''); |
|||
} |
|||
Sys.UI.DomElement.removeCssClass(validationMessageElement, Sys.Mvc.FieldContext._validationMessageErrorCss); |
|||
Sys.UI.DomElement.addCssClass(validationMessageElement, Sys.Mvc.FieldContext._validationMessageValidCss); |
|||
} |
|||
var elements = this.elements; |
|||
for (var i = 0; i < elements.length; i++) { |
|||
var element = elements[i]; |
|||
Sys.UI.DomElement.removeCssClass(element, Sys.Mvc.FieldContext._inputElementErrorCss); |
|||
Sys.UI.DomElement.addCssClass(element, Sys.Mvc.FieldContext._inputElementValidCss); |
|||
} |
|||
}, |
|||
|
|||
_element_OnBlur: function Sys_Mvc_FieldContext$_element_OnBlur(e) { |
|||
/// <param name="e" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
if (e.target[Sys.Mvc.FieldContext._hasTextChangedTag] || e.target[Sys.Mvc.FieldContext._hasValidationFiredTag]) { |
|||
this.validate('blur'); |
|||
} |
|||
}, |
|||
|
|||
_element_OnChange: function Sys_Mvc_FieldContext$_element_OnChange(e) { |
|||
/// <param name="e" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
e.target[Sys.Mvc.FieldContext._hasTextChangedTag] = true; |
|||
}, |
|||
|
|||
_element_OnInput: function Sys_Mvc_FieldContext$_element_OnInput(e) { |
|||
/// <param name="e" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
e.target[Sys.Mvc.FieldContext._hasTextChangedTag] = true; |
|||
if (e.target[Sys.Mvc.FieldContext._hasValidationFiredTag]) { |
|||
this.validate('input'); |
|||
} |
|||
}, |
|||
|
|||
_element_OnPropertyChange: function Sys_Mvc_FieldContext$_element_OnPropertyChange(e) { |
|||
/// <param name="e" type="Sys.UI.DomEvent">
|
|||
/// </param>
|
|||
if (e.rawEvent.propertyName === 'value') { |
|||
e.target[Sys.Mvc.FieldContext._hasTextChangedTag] = true; |
|||
if (e.target[Sys.Mvc.FieldContext._hasValidationFiredTag]) { |
|||
this.validate('input'); |
|||
} |
|||
} |
|||
}, |
|||
|
|||
enableDynamicValidation: function Sys_Mvc_FieldContext$enableDynamicValidation() { |
|||
var elements = this.elements; |
|||
for (var i = 0; i < elements.length; i++) { |
|||
var element = elements[i]; |
|||
if (Sys.Mvc._validationUtil.elementSupportsEvent(element, 'onpropertychange')) { |
|||
var compatMode = document.documentMode; |
|||
if (compatMode && compatMode >= 8) { |
|||
Sys.UI.DomEvent.addHandler(element, 'propertychange', this._onPropertyChangeHandler); |
|||
} |
|||
} |
|||
else { |
|||
Sys.UI.DomEvent.addHandler(element, 'input', this._onInputHandler); |
|||
} |
|||
Sys.UI.DomEvent.addHandler(element, 'change', this._onChangeHandler); |
|||
Sys.UI.DomEvent.addHandler(element, 'blur', this._onBlurHandler); |
|||
} |
|||
}, |
|||
|
|||
_getErrorString: function Sys_Mvc_FieldContext$_getErrorString(validatorReturnValue, fieldErrorMessage) { |
|||
/// <param name="validatorReturnValue" type="Object">
|
|||
/// </param>
|
|||
/// <param name="fieldErrorMessage" type="String">
|
|||
/// </param>
|
|||
/// <returns type="String"></returns>
|
|||
var fallbackErrorMessage = fieldErrorMessage || this.defaultErrorMessage; |
|||
if (Boolean.isInstanceOfType(validatorReturnValue)) { |
|||
return (validatorReturnValue) ? null : fallbackErrorMessage; |
|||
} |
|||
if (String.isInstanceOfType(validatorReturnValue)) { |
|||
return ((validatorReturnValue).length) ? validatorReturnValue : fallbackErrorMessage; |
|||
} |
|||
return null; |
|||
}, |
|||
|
|||
_getStringValue: function Sys_Mvc_FieldContext$_getStringValue() { |
|||
/// <returns type="String"></returns>
|
|||
var elements = this.elements; |
|||
return (elements.length > 0) ? elements[0].value : null; |
|||
}, |
|||
|
|||
_markValidationFired: function Sys_Mvc_FieldContext$_markValidationFired() { |
|||
var elements = this.elements; |
|||
for (var i = 0; i < elements.length; i++) { |
|||
var element = elements[i]; |
|||
element[Sys.Mvc.FieldContext._hasValidationFiredTag] = true; |
|||
} |
|||
}, |
|||
|
|||
_onErrorCountChanged: function Sys_Mvc_FieldContext$_onErrorCountChanged() { |
|||
if (!this._errors.length) { |
|||
this._displaySuccess(); |
|||
} |
|||
else { |
|||
this._displayError(); |
|||
} |
|||
}, |
|||
|
|||
validate: function Sys_Mvc_FieldContext$validate(eventName) { |
|||
/// <param name="eventName" type="String">
|
|||
/// </param>
|
|||
/// <returns type="Array" elementType="String"></returns>
|
|||
var validations = this.validations; |
|||
var errors = []; |
|||
var value = this._getStringValue(); |
|||
for (var i = 0; i < validations.length; i++) { |
|||
var validation = validations[i]; |
|||
var context = Sys.Mvc.$create_ValidationContext(); |
|||
context.eventName = eventName; |
|||
context.fieldContext = this; |
|||
context.validation = validation; |
|||
var retVal = validation.validator(value, context); |
|||
var errorMessage = this._getErrorString(retVal, validation.fieldErrorMessage); |
|||
if (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(errorMessage)) { |
|||
Array.add(errors, errorMessage); |
|||
} |
|||
} |
|||
this._markValidationFired(); |
|||
this.clearErrors(); |
|||
this.addErrors(errors); |
|||
return errors; |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.RangeValidator
|
|||
|
|||
Sys.Mvc.RangeValidator = function Sys_Mvc_RangeValidator(minimum, maximum) { |
|||
/// <param name="minimum" type="Number">
|
|||
/// </param>
|
|||
/// <param name="maximum" type="Number">
|
|||
/// </param>
|
|||
/// <field name="_minimum" type="Number">
|
|||
/// </field>
|
|||
/// <field name="_maximum" type="Number">
|
|||
/// </field>
|
|||
this._minimum = minimum; |
|||
this._maximum = maximum; |
|||
} |
|||
Sys.Mvc.RangeValidator.create = function Sys_Mvc_RangeValidator$create(rule) { |
|||
/// <param name="rule" type="Sys.Mvc.JsonValidationRule">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.Validator"></returns>
|
|||
var min = rule.ValidationParameters['min']; |
|||
var max = rule.ValidationParameters['max']; |
|||
return Function.createDelegate(new Sys.Mvc.RangeValidator(min, max), new Sys.Mvc.RangeValidator(min, max).validate); |
|||
} |
|||
Sys.Mvc.RangeValidator.prototype = { |
|||
_minimum: null, |
|||
_maximum: null, |
|||
|
|||
validate: function Sys_Mvc_RangeValidator$validate(value, context) { |
|||
/// <param name="value" type="String">
|
|||
/// </param>
|
|||
/// <param name="context" type="Sys.Mvc.ValidationContext">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) { |
|||
return true; |
|||
} |
|||
var n = Number.parseLocale(value); |
|||
return (!isNaN(n) && this._minimum <= n && n <= this._maximum); |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.RegularExpressionValidator
|
|||
|
|||
Sys.Mvc.RegularExpressionValidator = function Sys_Mvc_RegularExpressionValidator(pattern) { |
|||
/// <param name="pattern" type="String">
|
|||
/// </param>
|
|||
/// <field name="_pattern" type="String">
|
|||
/// </field>
|
|||
this._pattern = pattern; |
|||
} |
|||
Sys.Mvc.RegularExpressionValidator.create = function Sys_Mvc_RegularExpressionValidator$create(rule) { |
|||
/// <param name="rule" type="Sys.Mvc.JsonValidationRule">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.Validator"></returns>
|
|||
var pattern = rule.ValidationParameters['pattern']; |
|||
return Function.createDelegate(new Sys.Mvc.RegularExpressionValidator(pattern), new Sys.Mvc.RegularExpressionValidator(pattern).validate); |
|||
} |
|||
Sys.Mvc.RegularExpressionValidator.prototype = { |
|||
_pattern: null, |
|||
|
|||
validate: function Sys_Mvc_RegularExpressionValidator$validate(value, context) { |
|||
/// <param name="value" type="String">
|
|||
/// </param>
|
|||
/// <param name="context" type="Sys.Mvc.ValidationContext">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) { |
|||
return true; |
|||
} |
|||
var regExp = new RegExp(this._pattern); |
|||
var matches = regExp.exec(value); |
|||
return (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(matches) && matches[0].length === value.length); |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.RequiredValidator
|
|||
|
|||
Sys.Mvc.RequiredValidator = function Sys_Mvc_RequiredValidator() { |
|||
} |
|||
Sys.Mvc.RequiredValidator.create = function Sys_Mvc_RequiredValidator$create(rule) { |
|||
/// <param name="rule" type="Sys.Mvc.JsonValidationRule">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.Validator"></returns>
|
|||
return Function.createDelegate(new Sys.Mvc.RequiredValidator(), new Sys.Mvc.RequiredValidator().validate); |
|||
} |
|||
Sys.Mvc.RequiredValidator._isRadioInputElement = function Sys_Mvc_RequiredValidator$_isRadioInputElement(element) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
if (element.tagName.toUpperCase() === 'INPUT') { |
|||
var inputType = (element.type).toUpperCase(); |
|||
if (inputType === 'RADIO') { |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
Sys.Mvc.RequiredValidator._isSelectInputElement = function Sys_Mvc_RequiredValidator$_isSelectInputElement(element) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
if (element.tagName.toUpperCase() === 'SELECT') { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
Sys.Mvc.RequiredValidator._isTextualInputElement = function Sys_Mvc_RequiredValidator$_isTextualInputElement(element) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
if (element.tagName.toUpperCase() === 'INPUT') { |
|||
var inputType = (element.type).toUpperCase(); |
|||
switch (inputType) { |
|||
case 'TEXT': |
|||
case 'PASSWORD': |
|||
case 'FILE': |
|||
return true; |
|||
} |
|||
} |
|||
if (element.tagName.toUpperCase() === 'TEXTAREA') { |
|||
return true; |
|||
} |
|||
return false; |
|||
} |
|||
Sys.Mvc.RequiredValidator._validateRadioInput = function Sys_Mvc_RequiredValidator$_validateRadioInput(elements) { |
|||
/// <param name="elements" type="Array" elementType="Object" elementDomElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
for (var i = 0; i < elements.length; i++) { |
|||
var element = elements[i]; |
|||
if (element.checked) { |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
Sys.Mvc.RequiredValidator._validateSelectInput = function Sys_Mvc_RequiredValidator$_validateSelectInput(optionElements) { |
|||
/// <param name="optionElements" type="DOMElementCollection">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
for (var i = 0; i < optionElements.length; i++) { |
|||
var element = optionElements[i]; |
|||
if (element.selected) { |
|||
if (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(element.value)) { |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
return false; |
|||
} |
|||
Sys.Mvc.RequiredValidator._validateTextualInput = function Sys_Mvc_RequiredValidator$_validateTextualInput(element) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
return (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(element.value)); |
|||
} |
|||
Sys.Mvc.RequiredValidator.prototype = { |
|||
|
|||
validate: function Sys_Mvc_RequiredValidator$validate(value, context) { |
|||
/// <param name="value" type="String">
|
|||
/// </param>
|
|||
/// <param name="context" type="Sys.Mvc.ValidationContext">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
var elements = context.fieldContext.elements; |
|||
if (!elements.length) { |
|||
return true; |
|||
} |
|||
var sampleElement = elements[0]; |
|||
if (Sys.Mvc.RequiredValidator._isTextualInputElement(sampleElement)) { |
|||
return Sys.Mvc.RequiredValidator._validateTextualInput(sampleElement); |
|||
} |
|||
if (Sys.Mvc.RequiredValidator._isRadioInputElement(sampleElement)) { |
|||
return Sys.Mvc.RequiredValidator._validateRadioInput(elements); |
|||
} |
|||
if (Sys.Mvc.RequiredValidator._isSelectInputElement(sampleElement)) { |
|||
return Sys.Mvc.RequiredValidator._validateSelectInput((sampleElement).options); |
|||
} |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.StringLengthValidator
|
|||
|
|||
Sys.Mvc.StringLengthValidator = function Sys_Mvc_StringLengthValidator(minLength, maxLength) { |
|||
/// <param name="minLength" type="Number" integer="true">
|
|||
/// </param>
|
|||
/// <param name="maxLength" type="Number" integer="true">
|
|||
/// </param>
|
|||
/// <field name="_maxLength" type="Number" integer="true">
|
|||
/// </field>
|
|||
/// <field name="_minLength" type="Number" integer="true">
|
|||
/// </field>
|
|||
this._minLength = minLength; |
|||
this._maxLength = maxLength; |
|||
} |
|||
Sys.Mvc.StringLengthValidator.create = function Sys_Mvc_StringLengthValidator$create(rule) { |
|||
/// <param name="rule" type="Sys.Mvc.JsonValidationRule">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.Validator"></returns>
|
|||
var minLength = (rule.ValidationParameters['min'] || 0); |
|||
var maxLength = (rule.ValidationParameters['max'] || Number.MAX_VALUE); |
|||
return Function.createDelegate(new Sys.Mvc.StringLengthValidator(minLength, maxLength), new Sys.Mvc.StringLengthValidator(minLength, maxLength).validate); |
|||
} |
|||
Sys.Mvc.StringLengthValidator.prototype = { |
|||
_maxLength: 0, |
|||
_minLength: 0, |
|||
|
|||
validate: function Sys_Mvc_StringLengthValidator$validate(value, context) { |
|||
/// <param name="value" type="String">
|
|||
/// </param>
|
|||
/// <param name="context" type="Sys.Mvc.ValidationContext">
|
|||
/// </param>
|
|||
/// <returns type="Object"></returns>
|
|||
if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) { |
|||
return true; |
|||
} |
|||
return (this._minLength <= value.length && value.length <= this._maxLength); |
|||
} |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc._validationUtil
|
|||
|
|||
Sys.Mvc._validationUtil = function Sys_Mvc__validationUtil() { |
|||
} |
|||
Sys.Mvc._validationUtil.arrayIsNullOrEmpty = function Sys_Mvc__validationUtil$arrayIsNullOrEmpty(array) { |
|||
/// <param name="array" type="Array" elementType="Object">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
return (!array || !array.length); |
|||
} |
|||
Sys.Mvc._validationUtil.stringIsNullOrEmpty = function Sys_Mvc__validationUtil$stringIsNullOrEmpty(value) { |
|||
/// <param name="value" type="String">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
return (!value || !value.length); |
|||
} |
|||
Sys.Mvc._validationUtil.elementSupportsEvent = function Sys_Mvc__validationUtil$elementSupportsEvent(element, eventAttributeName) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="eventAttributeName" type="String">
|
|||
/// </param>
|
|||
/// <returns type="Boolean"></returns>
|
|||
return (eventAttributeName in element); |
|||
} |
|||
Sys.Mvc._validationUtil.removeAllChildren = function Sys_Mvc__validationUtil$removeAllChildren(element) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
while (element.firstChild) { |
|||
element.removeChild(element.firstChild); |
|||
} |
|||
} |
|||
Sys.Mvc._validationUtil.setInnerText = function Sys_Mvc__validationUtil$setInnerText(element, innerText) { |
|||
/// <param name="element" type="Object" domElement="true">
|
|||
/// </param>
|
|||
/// <param name="innerText" type="String">
|
|||
/// </param>
|
|||
var textNode = document.createTextNode(innerText); |
|||
Sys.Mvc._validationUtil.removeAllChildren(element); |
|||
element.appendChild(textNode); |
|||
} |
|||
|
|||
|
|||
////////////////////////////////////////////////////////////////////////////////
|
|||
// Sys.Mvc.ValidatorRegistry
|
|||
|
|||
Sys.Mvc.ValidatorRegistry = function Sys_Mvc_ValidatorRegistry() { |
|||
/// <field name="validators" type="Object" static="true">
|
|||
/// </field>
|
|||
} |
|||
Sys.Mvc.ValidatorRegistry.getValidator = function Sys_Mvc_ValidatorRegistry$getValidator(rule) { |
|||
/// <param name="rule" type="Sys.Mvc.JsonValidationRule">
|
|||
/// </param>
|
|||
/// <returns type="Sys.Mvc.Validator"></returns>
|
|||
var creator = Sys.Mvc.ValidatorRegistry.validators[rule.ValidationType]; |
|||
return (creator) ? creator(rule) : null; |
|||
} |
|||
Sys.Mvc.ValidatorRegistry._getDefaultValidators = function Sys_Mvc_ValidatorRegistry$_getDefaultValidators() { |
|||
/// <returns type="Object"></returns>
|
|||
return { required: Function.createDelegate(null, Sys.Mvc.RequiredValidator.create), length: Function.createDelegate(null, Sys.Mvc.StringLengthValidator.create), regex: Function.createDelegate(null, Sys.Mvc.RegularExpressionValidator.create), range: Function.createDelegate(null, Sys.Mvc.RangeValidator.create), number: Function.createDelegate(null, Sys.Mvc.NumberValidator.create) }; |
|||
} |
|||
|
|||
|
|||
Sys.Mvc.NumberValidator.registerClass('Sys.Mvc.NumberValidator'); |
|||
Sys.Mvc.FormContext.registerClass('Sys.Mvc.FormContext'); |
|||
Sys.Mvc.FieldContext.registerClass('Sys.Mvc.FieldContext'); |
|||
Sys.Mvc.RangeValidator.registerClass('Sys.Mvc.RangeValidator'); |
|||
Sys.Mvc.RegularExpressionValidator.registerClass('Sys.Mvc.RegularExpressionValidator'); |
|||
Sys.Mvc.RequiredValidator.registerClass('Sys.Mvc.RequiredValidator'); |
|||
Sys.Mvc.StringLengthValidator.registerClass('Sys.Mvc.StringLengthValidator'); |
|||
Sys.Mvc._validationUtil.registerClass('Sys.Mvc._validationUtil'); |
|||
Sys.Mvc.ValidatorRegistry.registerClass('Sys.Mvc.ValidatorRegistry'); |
|||
Sys.Mvc.FormContext._validationSummaryErrorCss = 'validation-summary-errors'; |
|||
Sys.Mvc.FormContext._validationSummaryValidCss = 'validation-summary-valid'; |
|||
Sys.Mvc.FormContext._formValidationTag = '__MVC_FormValidation'; |
|||
Sys.Mvc.FieldContext._hasTextChangedTag = '__MVC_HasTextChanged'; |
|||
Sys.Mvc.FieldContext._hasValidationFiredTag = '__MVC_HasValidationFired'; |
|||
Sys.Mvc.FieldContext._inputElementErrorCss = 'input-validation-error'; |
|||
Sys.Mvc.FieldContext._inputElementValidCss = 'input-validation-valid'; |
|||
Sys.Mvc.FieldContext._validationMessageErrorCss = 'field-validation-error'; |
|||
Sys.Mvc.FieldContext._validationMessageValidCss = 'field-validation-valid'; |
|||
Sys.Mvc.ValidatorRegistry.validators = Sys.Mvc.ValidatorRegistry._getDefaultValidators(); |
|||
|
|||
// ---- Do not remove this footer ----
|
|||
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
|
|||
// -----------------------------------
|
|||
|
|||
// register validation
|
|||
Sys.Application.add_load(function() { |
|||
Sys.Application.remove_load(arguments.callee); |
|||
Sys.Mvc.FormContext._Application_Load(); |
|||
}); |
|||
@ -1,55 +0,0 @@ |
|||
//----------------------------------------------------------
|
|||
// Copyright (C) Microsoft Corporation. All rights reserved.
|
|||
//----------------------------------------------------------
|
|||
// MicrosoftMvcValidation.js
|
|||
|
|||
Type.registerNamespace('Sys.Mvc');Sys.Mvc.$create_Validation=function(){return {};} |
|||
Sys.Mvc.$create_JsonValidationField=function(){return {};} |
|||
Sys.Mvc.$create_JsonValidationOptions=function(){return {};} |
|||
Sys.Mvc.$create_JsonValidationRule=function(){return {};} |
|||
Sys.Mvc.$create_ValidationContext=function(){return {};} |
|||
Sys.Mvc.NumberValidator=function(){} |
|||
Sys.Mvc.NumberValidator.create=function(rule){return Function.createDelegate(new Sys.Mvc.NumberValidator(),new Sys.Mvc.NumberValidator().validate);} |
|||
Sys.Mvc.NumberValidator.prototype={validate:function(value,context){if(Sys.Mvc._ValidationUtil.$1(value)){return true;}var $0=Number.parseLocale(value);return (!isNaN($0));}} |
|||
Sys.Mvc.FormContext=function(formElement,validationSummaryElement){this.$5=[];this.fields=new Array(0);this.$9=formElement;this.$7=validationSummaryElement;formElement['__MVC_FormValidation'] = this;if(validationSummaryElement){var $0=validationSummaryElement.getElementsByTagName('ul');if($0.length>0){this.$8=$0[0];}}this.$3=Function.createDelegate(this,this.$D);this.$4=Function.createDelegate(this,this.$E);} |
|||
Sys.Mvc.FormContext._Application_Load=function(){var $0=window.mvcClientValidationMetadata;if($0){while($0.length>0){var $1=$0.pop();Sys.Mvc.FormContext.$12($1);}}} |
|||
Sys.Mvc.FormContext.$F=function($p0,$p1){var $0=[];var $1=document.getElementsByName($p1);for(var $2=0;$2<$1.length;$2++){var $3=$1[$2];if(Sys.Mvc.FormContext.$10($p0,$3)){Array.add($0,$3);}}return $0;} |
|||
Sys.Mvc.FormContext.getValidationForForm=function(formElement){return formElement['__MVC_FormValidation'];} |
|||
Sys.Mvc.FormContext.$10=function($p0,$p1){while($p1){if($p0===$p1){return true;}$p1=$p1.parentNode;}return false;} |
|||
Sys.Mvc.FormContext.$12=function($p0){var $0=$get($p0.FormId);var $1=(!Sys.Mvc._ValidationUtil.$1($p0.ValidationSummaryId))?$get($p0.ValidationSummaryId):null;var $2=new Sys.Mvc.FormContext($0,$1);$2.enableDynamicValidation();$2.replaceValidationSummary=$p0.ReplaceValidationSummary;for(var $4=0;$4<$p0.Fields.length;$4++){var $5=$p0.Fields[$4];var $6=Sys.Mvc.FormContext.$F($0,$5.FieldName);var $7=(!Sys.Mvc._ValidationUtil.$1($5.ValidationMessageId))?$get($5.ValidationMessageId):null;var $8=new Sys.Mvc.FieldContext($2);Array.addRange($8.elements,$6);$8.validationMessageElement=$7;$8.replaceValidationMessageContents=$5.ReplaceValidationMessageContents;for(var $9=0;$9<$5.ValidationRules.length;$9++){var $A=$5.ValidationRules[$9];var $B=Sys.Mvc.ValidatorRegistry.getValidator($A);if($B){var $C=Sys.Mvc.$create_Validation();$C.fieldErrorMessage=$A.ErrorMessage;$C.validator=$B;Array.add($8.validations,$C);}}$8.enableDynamicValidation();Array.add($2.fields,$8);}var $3=$0.validationCallbacks;if(!$3){$3=[];$0.validationCallbacks = $3;}$3.push(Function.createDelegate(null,function(){ |
|||
return Sys.Mvc._ValidationUtil.$0($2.validate('submit'));}));return $2;} |
|||
Sys.Mvc.FormContext.prototype={$3:null,$4:null,$6:null,$7:null,$8:null,$9:null,replaceValidationSummary:false,addError:function(message){this.addErrors([message]);},addErrors:function(messages){if(!Sys.Mvc._ValidationUtil.$0(messages)){Array.addRange(this.$5,messages);this.$11();}},clearErrors:function(){Array.clear(this.$5);this.$11();},$A:function(){if(this.$7){if(this.$8){Sys.Mvc._ValidationUtil.$3(this.$8);for(var $0=0;$0<this.$5.length;$0++){var $1=document.createElement('li');Sys.Mvc._ValidationUtil.$4($1,this.$5[$0]);this.$8.appendChild($1);}}Sys.UI.DomElement.removeCssClass(this.$7,'validation-summary-valid');Sys.UI.DomElement.addCssClass(this.$7,'validation-summary-errors');}},$B:function(){var $0=this.$7;if($0){var $1=this.$8;if($1){$1.innerHTML='';}Sys.UI.DomElement.removeCssClass($0,'validation-summary-errors');Sys.UI.DomElement.addCssClass($0,'validation-summary-valid');}},enableDynamicValidation:function(){Sys.UI.DomEvent.addHandler(this.$9,'click',this.$3);Sys.UI.DomEvent.addHandler(this.$9,'submit',this.$4);},$C:function($p0){if($p0.disabled){return null;}var $0=$p0.tagName.toUpperCase();var $1=$p0;if($0==='INPUT'){var $2=$1.type;if($2==='submit'||$2==='image'){return $1;}}else if(($0==='BUTTON')&&($1.type==='submit')){return $1;}return null;},$D:function($p0){this.$6=this.$C($p0.target);},$E:function($p0){var $0=$p0.target;var $1=this.$6;if($1&&$1.disableValidation){return;}var $2=this.validate('submit');if(!Sys.Mvc._ValidationUtil.$0($2)){$p0.preventDefault();}},$11:function(){if(!this.$5.length){this.$B();}else{this.$A();}},validate:function(eventName){var $0=this.fields;var $1=[];for(var $2=0;$2<$0.length;$2++){var $3=$0[$2];if(!$3.elements[0].disabled){var $4=$3.validate(eventName);if($4){Array.addRange($1,$4);}}}if(this.replaceValidationSummary){this.clearErrors();this.addErrors($1);}return $1;}} |
|||
Sys.Mvc.FieldContext=function(formContext){this.$A=[];this.elements=new Array(0);this.validations=new Array(0);this.formContext=formContext;this.$6=Function.createDelegate(this,this.$D);this.$7=Function.createDelegate(this,this.$E);this.$8=Function.createDelegate(this,this.$F);this.$9=Function.createDelegate(this,this.$10);} |
|||
Sys.Mvc.FieldContext.prototype={$6:null,$7:null,$8:null,$9:null,defaultErrorMessage:null,formContext:null,replaceValidationMessageContents:false,validationMessageElement:null,addError:function(message){this.addErrors([message]);},addErrors:function(messages){if(!Sys.Mvc._ValidationUtil.$0(messages)){Array.addRange(this.$A,messages);this.$14();}},clearErrors:function(){Array.clear(this.$A);this.$14();},$B:function(){var $0=this.validationMessageElement;if($0){if(this.replaceValidationMessageContents){Sys.Mvc._ValidationUtil.$4($0,this.$A[0]);}Sys.UI.DomElement.removeCssClass($0,'field-validation-valid');Sys.UI.DomElement.addCssClass($0,'field-validation-error');}var $1=this.elements;for(var $2=0;$2<$1.length;$2++){var $3=$1[$2];Sys.UI.DomElement.removeCssClass($3,'input-validation-valid');Sys.UI.DomElement.addCssClass($3,'input-validation-error');}},$C:function(){var $0=this.validationMessageElement;if($0){if(this.replaceValidationMessageContents){Sys.Mvc._ValidationUtil.$4($0,'');}Sys.UI.DomElement.removeCssClass($0,'field-validation-error');Sys.UI.DomElement.addCssClass($0,'field-validation-valid');}var $1=this.elements;for(var $2=0;$2<$1.length;$2++){var $3=$1[$2];Sys.UI.DomElement.removeCssClass($3,'input-validation-error');Sys.UI.DomElement.addCssClass($3,'input-validation-valid');}},$D:function($p0){if($p0.target['__MVC_HasTextChanged']||$p0.target['__MVC_HasValidationFired']){this.validate('blur');}},$E:function($p0){$p0.target['__MVC_HasTextChanged'] = true;},$F:function($p0){$p0.target['__MVC_HasTextChanged'] = true;if($p0.target['__MVC_HasValidationFired']){this.validate('input');}},$10:function($p0){if($p0.rawEvent.propertyName==='value'){$p0.target['__MVC_HasTextChanged'] = true;if($p0.target['__MVC_HasValidationFired']){this.validate('input');}}},enableDynamicValidation:function(){var $0=this.elements;for(var $1=0;$1<$0.length;$1++){var $2=$0[$1];if(Sys.Mvc._ValidationUtil.$2($2,'onpropertychange')){var $3=document.documentMode;if($3&&$3>=8){Sys.UI.DomEvent.addHandler($2,'propertychange',this.$9);}}else{Sys.UI.DomEvent.addHandler($2,'input',this.$8);}Sys.UI.DomEvent.addHandler($2,'change',this.$7);Sys.UI.DomEvent.addHandler($2,'blur',this.$6);}},$11:function($p0,$p1){var $0=$p1||this.defaultErrorMessage;if(Boolean.isInstanceOfType($p0)){return ($p0)?null:$0;}if(String.isInstanceOfType($p0)){return (($p0).length)?$p0:$0;}return null;},$12:function(){var $0=this.elements;return ($0.length>0)?$0[0].value:null;},$13:function(){var $0=this.elements;for(var $1=0;$1<$0.length;$1++){var $2=$0[$1];$2['__MVC_HasValidationFired'] = true;}},$14:function(){if(!this.$A.length){this.$C();}else{this.$B();}},validate:function(eventName){var $0=this.validations;var $1=[];var $2=this.$12();for(var $3=0;$3<$0.length;$3++){var $4=$0[$3];var $5=Sys.Mvc.$create_ValidationContext();$5.eventName=eventName;$5.fieldContext=this;$5.validation=$4;var $6=$4.validator($2,$5);var $7=this.$11($6,$4.fieldErrorMessage);if(!Sys.Mvc._ValidationUtil.$1($7)){Array.add($1,$7);}}this.$13();this.clearErrors();this.addErrors($1);return $1;}} |
|||
Sys.Mvc.RangeValidator=function(minimum,maximum){this.$0=minimum;this.$1=maximum;} |
|||
Sys.Mvc.RangeValidator.create=function(rule){var $0=rule.ValidationParameters['min'];var $1=rule.ValidationParameters['max'];return Function.createDelegate(new Sys.Mvc.RangeValidator($0,$1),new Sys.Mvc.RangeValidator($0,$1).validate);} |
|||
Sys.Mvc.RangeValidator.prototype={$0:null,$1:null,validate:function(value,context){if(Sys.Mvc._ValidationUtil.$1(value)){return true;}var $0=Number.parseLocale(value);return (!isNaN($0)&&this.$0<=$0&&$0<=this.$1);}} |
|||
Sys.Mvc.RegularExpressionValidator=function(pattern){this.$0=pattern;} |
|||
Sys.Mvc.RegularExpressionValidator.create=function(rule){var $0=rule.ValidationParameters['pattern'];return Function.createDelegate(new Sys.Mvc.RegularExpressionValidator($0),new Sys.Mvc.RegularExpressionValidator($0).validate);} |
|||
Sys.Mvc.RegularExpressionValidator.prototype={$0:null,validate:function(value,context){if(Sys.Mvc._ValidationUtil.$1(value)){return true;}var $0=new RegExp(this.$0);var $1=$0.exec(value);return (!Sys.Mvc._ValidationUtil.$0($1)&&$1[0].length===value.length);}} |
|||
Sys.Mvc.RequiredValidator=function(){} |
|||
Sys.Mvc.RequiredValidator.create=function(rule){return Function.createDelegate(new Sys.Mvc.RequiredValidator(),new Sys.Mvc.RequiredValidator().validate);} |
|||
Sys.Mvc.RequiredValidator.$0=function($p0){if($p0.tagName.toUpperCase()==='INPUT'){var $0=($p0.type).toUpperCase();if($0==='RADIO'){return true;}}return false;} |
|||
Sys.Mvc.RequiredValidator.$1=function($p0){if($p0.tagName.toUpperCase()==='SELECT'){return true;}return false;} |
|||
Sys.Mvc.RequiredValidator.$2=function($p0){if($p0.tagName.toUpperCase()==='INPUT'){var $0=($p0.type).toUpperCase();switch($0){case 'TEXT':case 'PASSWORD':case 'FILE':return true;}}if($p0.tagName.toUpperCase()==='TEXTAREA'){return true;}return false;} |
|||
Sys.Mvc.RequiredValidator.$3=function($p0){for(var $0=0;$0<$p0.length;$0++){var $1=$p0[$0];if($1.checked){return true;}}return false;} |
|||
Sys.Mvc.RequiredValidator.$4=function($p0){for(var $0=0;$0<$p0.length;$0++){var $1=$p0[$0];if($1.selected){if(!Sys.Mvc._ValidationUtil.$1($1.value)){return true;}}}return false;} |
|||
Sys.Mvc.RequiredValidator.$5=function($p0){return (!Sys.Mvc._ValidationUtil.$1($p0.value));} |
|||
Sys.Mvc.RequiredValidator.prototype={validate:function(value,context){var $0=context.fieldContext.elements;if(!$0.length){return true;}var $1=$0[0];if(Sys.Mvc.RequiredValidator.$2($1)){return Sys.Mvc.RequiredValidator.$5($1);}if(Sys.Mvc.RequiredValidator.$0($1)){return Sys.Mvc.RequiredValidator.$3($0);}if(Sys.Mvc.RequiredValidator.$1($1)){return Sys.Mvc.RequiredValidator.$4(($1).options);}return true;}} |
|||
Sys.Mvc.StringLengthValidator=function(minLength,maxLength){this.$1=minLength;this.$0=maxLength;} |
|||
Sys.Mvc.StringLengthValidator.create=function(rule){var $0=(rule.ValidationParameters['min']||0);var $1=(rule.ValidationParameters['max']||Number.MAX_VALUE);return Function.createDelegate(new Sys.Mvc.StringLengthValidator($0,$1),new Sys.Mvc.StringLengthValidator($0,$1).validate);} |
|||
Sys.Mvc.StringLengthValidator.prototype={$0:0,$1:0,validate:function(value,context){if(Sys.Mvc._ValidationUtil.$1(value)){return true;}return (this.$1<=value.length&&value.length<=this.$0);}} |
|||
Sys.Mvc._ValidationUtil=function(){} |
|||
Sys.Mvc._ValidationUtil.$0=function($p0){return (!$p0||!$p0.length);} |
|||
Sys.Mvc._ValidationUtil.$1=function($p0){return (!$p0||!$p0.length);} |
|||
Sys.Mvc._ValidationUtil.$2=function($p0,$p1){return ($p1 in $p0);} |
|||
Sys.Mvc._ValidationUtil.$3=function($p0){while($p0.firstChild){$p0.removeChild($p0.firstChild);}} |
|||
Sys.Mvc._ValidationUtil.$4=function($p0,$p1){var $0=document.createTextNode($p1);Sys.Mvc._ValidationUtil.$3($p0);$p0.appendChild($0);} |
|||
Sys.Mvc.ValidatorRegistry=function(){} |
|||
Sys.Mvc.ValidatorRegistry.getValidator=function(rule){var $0=Sys.Mvc.ValidatorRegistry.validators[rule.ValidationType];return ($0)?$0(rule):null;} |
|||
Sys.Mvc.ValidatorRegistry.$0=function(){return {required:Function.createDelegate(null,Sys.Mvc.RequiredValidator.create),length:Function.createDelegate(null,Sys.Mvc.StringLengthValidator.create),regex:Function.createDelegate(null,Sys.Mvc.RegularExpressionValidator.create),range:Function.createDelegate(null,Sys.Mvc.RangeValidator.create),number:Function.createDelegate(null,Sys.Mvc.NumberValidator.create)};} |
|||
Sys.Mvc.NumberValidator.registerClass('Sys.Mvc.NumberValidator');Sys.Mvc.FormContext.registerClass('Sys.Mvc.FormContext');Sys.Mvc.FieldContext.registerClass('Sys.Mvc.FieldContext');Sys.Mvc.RangeValidator.registerClass('Sys.Mvc.RangeValidator');Sys.Mvc.RegularExpressionValidator.registerClass('Sys.Mvc.RegularExpressionValidator');Sys.Mvc.RequiredValidator.registerClass('Sys.Mvc.RequiredValidator');Sys.Mvc.StringLengthValidator.registerClass('Sys.Mvc.StringLengthValidator');Sys.Mvc._ValidationUtil.registerClass('Sys.Mvc._ValidationUtil');Sys.Mvc.ValidatorRegistry.registerClass('Sys.Mvc.ValidatorRegistry');Sys.Mvc.ValidatorRegistry.validators=Sys.Mvc.ValidatorRegistry.$0(); |
|||
// ---- Do not remove this footer ----
|
|||
// Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
|
|||
// -----------------------------------
|
|||
Sys.Application.add_load(function(){Sys.Application.remove_load(arguments.callee);Sys.Mvc.FormContext._Application_Load();}); |
|||
@ -1 +0,0 @@ |
|||
8f56f29ea15515370d52a560396067bb28b52005 |
|||
@ -1 +0,0 @@ |
|||
5948d8cc4932a48bc126343cf1d5ea2ac5f0b3c0 |
|||
@ -1 +0,0 @@ |
|||
eec584bc589cf1ab1fe50781c1780f89c90aa31b |
|||
@ -1 +0,0 @@ |
|||
79285779228262f9c021d1ee5a455c6f7f4c1113 |
|||
@ -1 +0,0 @@ |
|||
89ff61bcba0fbfbe359c0d3734942d260b702a4b |
|||
@ -1,165 +0,0 @@ |
|||
/// <reference path="jquery-1.5.1.js" />
|
|||
|
|||
/*! |
|||
** Unobtrusive Ajax support library for jQuery |
|||
** Copyright (C) Microsoft Corporation. All rights reserved. |
|||
*/ |
|||
|
|||
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ |
|||
/*global window: false, jQuery: false */ |
|||
|
|||
(function ($) { |
|||
var data_click = "unobtrusiveAjaxClick", |
|||
data_validation = "unobtrusiveValidation"; |
|||
|
|||
function getFunction(code, argNames) { |
|||
var fn = window, parts = (code || "").split("."); |
|||
while (fn && parts.length) { |
|||
fn = fn[parts.shift()]; |
|||
} |
|||
if (typeof (fn) === "function") { |
|||
return fn; |
|||
} |
|||
argNames.push(code); |
|||
return Function.constructor.apply(null, argNames); |
|||
} |
|||
|
|||
function isMethodProxySafe(method) { |
|||
return method === "GET" || method === "POST"; |
|||
} |
|||
|
|||
function asyncOnBeforeSend(xhr, method) { |
|||
if (!isMethodProxySafe(method)) { |
|||
xhr.setRequestHeader("X-HTTP-Method-Override", method); |
|||
} |
|||
} |
|||
|
|||
function asyncOnSuccess(element, data, contentType) { |
|||
var mode; |
|||
|
|||
if (contentType.indexOf("application/x-javascript") !== -1) { // jQuery already executes JavaScript for us
|
|||
return; |
|||
} |
|||
|
|||
mode = (element.getAttribute("data-ajax-mode") || "").toUpperCase(); |
|||
$(element.getAttribute("data-ajax-update")).each(function (i, update) { |
|||
var top; |
|||
|
|||
switch (mode) { |
|||
case "BEFORE": |
|||
top = update.firstChild; |
|||
$("<div />").html(data).contents().each(function () { |
|||
update.insertBefore(this, top); |
|||
}); |
|||
break; |
|||
case "AFTER": |
|||
$("<div />").html(data).contents().each(function () { |
|||
update.appendChild(this); |
|||
}); |
|||
break; |
|||
default: |
|||
$(update).html(data); |
|||
break; |
|||
} |
|||
}); |
|||
} |
|||
|
|||
function asyncRequest(element, options) { |
|||
var confirm, loading, method, duration; |
|||
|
|||
confirm = element.getAttribute("data-ajax-confirm"); |
|||
if (confirm && !window.confirm(confirm)) { |
|||
return; |
|||
} |
|||
|
|||
loading = $(element.getAttribute("data-ajax-loading")); |
|||
duration = element.getAttribute("data-ajax-loading-duration") || 0; |
|||
|
|||
$.extend(options, { |
|||
type: element.getAttribute("data-ajax-method") || undefined, |
|||
url: element.getAttribute("data-ajax-url") || undefined, |
|||
beforeSend: function (xhr) { |
|||
var result; |
|||
asyncOnBeforeSend(xhr, method); |
|||
result = getFunction(element.getAttribute("data-ajax-begin"), ["xhr"]).apply(this, arguments); |
|||
if (result !== false) { |
|||
loading.show(duration); |
|||
} |
|||
return result; |
|||
}, |
|||
complete: function () { |
|||
loading.hide(duration); |
|||
getFunction(element.getAttribute("data-ajax-complete"), ["xhr", "status"]).apply(this, arguments); |
|||
}, |
|||
success: function (data, status, xhr) { |
|||
asyncOnSuccess(element, data, xhr.getResponseHeader("Content-Type") || "text/html"); |
|||
getFunction(element.getAttribute("data-ajax-success"), ["data", "status", "xhr"]).apply(this, arguments); |
|||
}, |
|||
error: getFunction(element.getAttribute("data-ajax-failure"), ["xhr", "status", "error"]) |
|||
}); |
|||
|
|||
options.data.push({ name: "X-Requested-With", value: "XMLHttpRequest" }); |
|||
|
|||
method = options.type.toUpperCase(); |
|||
if (!isMethodProxySafe(method)) { |
|||
options.type = "POST"; |
|||
options.data.push({ name: "X-HTTP-Method-Override", value: method }); |
|||
} |
|||
|
|||
$.ajax(options); |
|||
} |
|||
|
|||
function validate(form) { |
|||
var validationInfo = $(form).data(data_validation); |
|||
return !validationInfo || !validationInfo.validate || validationInfo.validate(); |
|||
} |
|||
|
|||
$("a[data-ajax=true]").live("click", function (evt) { |
|||
evt.preventDefault(); |
|||
asyncRequest(this, { |
|||
url: this.href, |
|||
type: "GET", |
|||
data: [] |
|||
}); |
|||
}); |
|||
|
|||
$("form[data-ajax=true] input[type=image]").live("click", function (evt) { |
|||
var name = evt.target.name, |
|||
$target = $(evt.target), |
|||
form = $target.parents("form")[0], |
|||
offset = $target.offset(); |
|||
|
|||
$(form).data(data_click, [ |
|||
{ name: name + ".x", value: Math.round(evt.pageX - offset.left) }, |
|||
{ name: name + ".y", value: Math.round(evt.pageY - offset.top) } |
|||
]); |
|||
|
|||
setTimeout(function () { |
|||
$(form).removeData(data_click); |
|||
}, 0); |
|||
}); |
|||
|
|||
$("form[data-ajax=true] :submit").live("click", function (evt) { |
|||
var name = evt.target.name, |
|||
form = $(evt.target).parents("form")[0]; |
|||
|
|||
$(form).data(data_click, name ? [{ name: name, value: evt.target.value }] : []); |
|||
|
|||
setTimeout(function () { |
|||
$(form).removeData(data_click); |
|||
}, 0); |
|||
}); |
|||
|
|||
$("form[data-ajax=true]").live("submit", function (evt) { |
|||
var clickInfo = $(this).data(data_click) || []; |
|||
evt.preventDefault(); |
|||
if (!validate(this)) { |
|||
return; |
|||
} |
|||
asyncRequest(this, { |
|||
url: this.action, |
|||
type: this.method || "GET", |
|||
data: clickInfo.concat($(this).serializeArray()) |
|||
}); |
|||
}); |
|||
}(jQuery)); |
|||
@ -1,5 +0,0 @@ |
|||
/* |
|||
** Unobtrusive Ajax support library for jQuery |
|||
** Copyright (C) Microsoft Corporation. All rights reserved. |
|||
*/ |
|||
(function(a){var b="unobtrusiveAjaxClick",g="unobtrusiveValidation";function c(d,b){var a=window,c=(d||"").split(".");while(a&&c.length)a=a[c.shift()];if(typeof a==="function")return a;b.push(d);return Function.constructor.apply(null,b)}function d(a){return a==="GET"||a==="POST"}function f(b,a){!d(a)&&b.setRequestHeader("X-HTTP-Method-Override",a)}function h(c,b,e){var d;if(e.indexOf("application/x-javascript")!==-1)return;d=(c.getAttribute("data-ajax-mode")||"").toUpperCase();a(c.getAttribute("data-ajax-update")).each(function(f,c){var e;switch(d){case"BEFORE":e=c.firstChild;a("<div />").html(b).contents().each(function(){c.insertBefore(this,e)});break;case"AFTER":a("<div />").html(b).contents().each(function(){c.appendChild(this)});break;default:a(c).html(b)}})}function e(b,e){var j,k,g,i;j=b.getAttribute("data-ajax-confirm");if(j&&!window.confirm(j))return;k=a(b.getAttribute("data-ajax-loading"));i=b.getAttribute("data-ajax-loading-duration")||0;a.extend(e,{type:b.getAttribute("data-ajax-method")||undefined,url:b.getAttribute("data-ajax-url")||undefined,beforeSend:function(d){var a;f(d,g);a=c(b.getAttribute("data-ajax-begin"),["xhr"]).apply(this,arguments);a!==false&&k.show(i);return a},complete:function(){k.hide(i);c(b.getAttribute("data-ajax-complete"),["xhr","status"]).apply(this,arguments)},success:function(a,e,d){h(b,a,d.getResponseHeader("Content-Type")||"text/html");c(b.getAttribute("data-ajax-success"),["data","status","xhr"]).apply(this,arguments)},error:c(b.getAttribute("data-ajax-failure"),["xhr","status","error"])});e.data.push({name:"X-Requested-With",value:"XMLHttpRequest"});g=e.type.toUpperCase();if(!d(g)){e.type="POST";e.data.push({name:"X-HTTP-Method-Override",value:g})}a.ajax(e)}function i(c){var b=a(c).data(g);return!b||!b.validate||b.validate()}a("a[data-ajax=true]").live("click",function(a){a.preventDefault();e(this,{url:this.href,type:"GET",data:[]})});a("form[data-ajax=true] input[type=image]").live("click",function(c){var g=c.target.name,d=a(c.target),f=d.parents("form")[0],e=d.offset();a(f).data(b,[{name:g+".x",value:Math.round(c.pageX-e.left)},{name:g+".y",value:Math.round(c.pageY-e.top)}]);setTimeout(function(){a(f).removeData(b)},0)});a("form[data-ajax=true] :submit").live("click",function(c){var e=c.target.name,d=a(c.target).parents("form")[0];a(d).data(b,e?[{name:e,value:c.target.value}]:[]);setTimeout(function(){a(d).removeData(b)},0)});a("form[data-ajax=true]").live("submit",function(d){var c=a(this).data(b)||[];d.preventDefault();if(!i(this))return;e(this,{url:this.action,type:this.method||"GET",data:c.concat(a(this).serializeArray())})})})(jQuery); |
|||
File diff suppressed because it is too large
File diff suppressed because it is too large
@ -1,53 +0,0 @@ |
|||
/** |
|||
* Note: While Microsoft is not the author of this file, Microsoft is |
|||
* offering you a license subject to the terms of the Microsoft Software |
|||
* License Terms for Microsoft ASP.NET Model View Controller 3. |
|||
* Microsoft reserves all other rights. The notices below are provided |
|||
* for informational purposes only and are not the license terms under |
|||
* which Microsoft distributed this file. |
|||
* |
|||
* jQuery Validation Plugin 1.8.0 |
|||
* |
|||
* http://bassistance.de/jquery-plugins/jquery-plugin-validation/
|
|||
* http://docs.jquery.com/Plugins/Validation
|
|||
* |
|||
* Copyright (c) 2006 - 2011 Jörn Zaefferer |
|||
*/ |
|||
(function(c){c.extend(c.fn,{validate:function(a){if(this.length){var b=c.data(this[0],"validator");if(b)return b;b=new c.validator(a,this[0]);c.data(this[0],"validator",b);if(b.settings.onsubmit){this.find("input, button").filter(".cancel").click(function(){b.cancelSubmit=true});b.settings.submitHandler&&this.find("input, button").filter(":submit").click(function(){b.submitButton=this});this.submit(function(d){function e(){if(b.settings.submitHandler){if(b.submitButton)var f=c("<input type='hidden'/>").attr("name", |
|||
b.submitButton.name).val(b.submitButton.value).appendTo(b.currentForm);b.settings.submitHandler.call(b,b.currentForm);b.submitButton&&f.remove();return false}return true}b.settings.debug&&d.preventDefault();if(b.cancelSubmit){b.cancelSubmit=false;return e()}if(b.form()){if(b.pendingRequest){b.formSubmitted=true;return false}return e()}else{b.focusInvalid();return false}})}return b}else a&&a.debug&&window.console&&console.warn("nothing selected, can't validate, returning nothing")},valid:function(){if(c(this[0]).is("form"))return this.validate().form(); |
|||
else{var a=true,b=c(this[0].form).validate();this.each(function(){a&=b.element(this)});return a}},removeAttrs:function(a){var b={},d=this;c.each(a.split(/\s/),function(e,f){b[f]=d.attr(f);d.removeAttr(f)});return b},rules:function(a,b){var d=this[0];if(a){var e=c.data(d.form,"validator").settings,f=e.rules,g=c.validator.staticRules(d);switch(a){case "add":c.extend(g,c.validator.normalizeRule(b));f[d.name]=g;if(b.messages)e.messages[d.name]=c.extend(e.messages[d.name],b.messages);break;case "remove":if(!b){delete f[d.name]; |
|||
return g}var h={};c.each(b.split(/\s/),function(j,i){h[i]=g[i];delete g[i]});return h}}d=c.validator.normalizeRules(c.extend({},c.validator.metadataRules(d),c.validator.classRules(d),c.validator.attributeRules(d),c.validator.staticRules(d)),d);if(d.required){e=d.required;delete d.required;d=c.extend({required:e},d)}return d}});c.extend(c.expr[":"],{blank:function(a){return!c.trim(""+a.value)},filled:function(a){return!!c.trim(""+a.value)},unchecked:function(a){return!a.checked}});c.validator=function(a, |
|||
b){this.settings=c.extend(true,{},c.validator.defaults,a);this.currentForm=b;this.init()};c.validator.format=function(a,b){if(arguments.length==1)return function(){var d=c.makeArray(arguments);d.unshift(a);return c.validator.format.apply(this,d)};if(arguments.length>2&&b.constructor!=Array)b=c.makeArray(arguments).slice(1);if(b.constructor!=Array)b=[b];c.each(b,function(d,e){a=a.replace(RegExp("\\{"+d+"\\}","g"),e)});return a};c.extend(c.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error", |
|||
validClass:"valid",errorElement:"label",focusInvalid:true,errorContainer:c([]),errorLabelContainer:c([]),onsubmit:true,ignore:[],ignoreTitle:false,onfocusin:function(a){this.lastActive=a;if(this.settings.focusCleanup&&!this.blockFocusCleanup){this.settings.unhighlight&&this.settings.unhighlight.call(this,a,this.settings.errorClass,this.settings.validClass);this.addWrapper(this.errorsFor(a)).hide()}},onfocusout:function(a){if(!this.checkable(a)&&(a.name in this.submitted||!this.optional(a)))this.element(a)}, |
|||
onkeyup:function(a){if(a.name in this.submitted||a==this.lastElement)this.element(a)},onclick:function(a){if(a.name in this.submitted)this.element(a);else a.parentNode.name in this.submitted&&this.element(a.parentNode)},highlight:function(a,b,d){c(a).addClass(b).removeClass(d)},unhighlight:function(a,b,d){c(a).removeClass(b).addClass(d)}},setDefaults:function(a){c.extend(c.validator.defaults,a)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.", |
|||
url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",creditcard:"Please enter a valid credit card number.",equalTo:"Please enter the same value again.",accept:"Please enter a value with a valid extension.",maxlength:c.validator.format("Please enter no more than {0} characters."),minlength:c.validator.format("Please enter at least {0} characters."),rangelength:c.validator.format("Please enter a value between {0} and {1} characters long."), |
|||
range:c.validator.format("Please enter a value between {0} and {1}."),max:c.validator.format("Please enter a value less than or equal to {0}."),min:c.validator.format("Please enter a value greater than or equal to {0}.")},autoCreateRanges:false,prototype:{init:function(){function a(e){var f=c.data(this[0].form,"validator");e="on"+e.type.replace(/^validate/,"");f.settings[e]&&f.settings[e].call(f,this[0])}this.labelContainer=c(this.settings.errorLabelContainer);this.errorContext=this.labelContainer.length&& |
|||
this.labelContainer||c(this.currentForm);this.containers=c(this.settings.errorContainer).add(this.settings.errorLabelContainer);this.submitted={};this.valueCache={};this.pendingRequest=0;this.pending={};this.invalid={};this.reset();var b=this.groups={};c.each(this.settings.groups,function(e,f){c.each(f.split(/\s/),function(g,h){b[h]=e})});var d=this.settings.rules;c.each(d,function(e,f){d[e]=c.validator.normalizeRule(f)});c(this.currentForm).validateDelegate(":text, :password, :file, select, textarea", |
|||
"focusin focusout keyup",a).validateDelegate(":radio, :checkbox, select, option","click",a);this.settings.invalidHandler&&c(this.currentForm).bind("invalid-form.validate",this.settings.invalidHandler)},form:function(){this.checkForm();c.extend(this.submitted,this.errorMap);this.invalid=c.extend({},this.errorMap);this.valid()||c(this.currentForm).triggerHandler("invalid-form",[this]);this.showErrors();return this.valid()},checkForm:function(){this.prepareForm();for(var a=0,b=this.currentElements=this.elements();b[a];a++)this.check(b[a]); |
|||
return this.valid()},element:function(a){this.lastElement=a=this.clean(a);this.prepareElement(a);this.currentElements=c(a);var b=this.check(a);if(b)delete this.invalid[a.name];else this.invalid[a.name]=true;if(!this.numberOfInvalids())this.toHide=this.toHide.add(this.containers);this.showErrors();return b},showErrors:function(a){if(a){c.extend(this.errorMap,a);this.errorList=[];for(var b in a)this.errorList.push({message:a[b],element:this.findByName(b)[0]});this.successList=c.grep(this.successList, |
|||
function(d){return!(d.name in a)})}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){c.fn.resetForm&&c(this.currentForm).resetForm();this.submitted={};this.prepareForm();this.hideErrors();this.elements().removeClass(this.settings.errorClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(a){var b=0,d;for(d in a)b++;return b},hideErrors:function(){this.addWrapper(this.toHide).hide()}, |
|||
valid:function(){return this.size()==0},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{c(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").focus().trigger("focusin")}catch(a){}},findLastActive:function(){var a=this.lastActive;return a&&c.grep(this.errorList,function(b){return b.element.name==a.name}).length==1&&a},elements:function(){var a=this,b={};return c([]).add(this.currentForm.elements).filter(":input").not(":submit, :reset, :image, [disabled]").not(this.settings.ignore).filter(function(){!this.name&& |
|||
a.settings.debug&&window.console&&console.error("%o has no name assigned",this);if(this.name in b||!a.objectLength(c(this).rules()))return false;return b[this.name]=true})},clean:function(a){return c(a)[0]},errors:function(){return c(this.settings.errorElement+"."+this.settings.errorClass,this.errorContext)},reset:function(){this.successList=[];this.errorList=[];this.errorMap={};this.toShow=c([]);this.toHide=c([]);this.currentElements=c([])},prepareForm:function(){this.reset();this.toHide=this.errors().add(this.containers)}, |
|||
prepareElement:function(a){this.reset();this.toHide=this.errorsFor(a)},check:function(a){a=this.clean(a);if(this.checkable(a))a=this.findByName(a.name).not(this.settings.ignore)[0];var b=c(a).rules(),d=false,e;for(e in b){var f={method:e,parameters:b[e]};try{var g=c.validator.methods[e].call(this,a.value.replace(/\r/g,""),a,f.parameters);if(g=="dependency-mismatch")d=true;else{d=false;if(g=="pending"){this.toHide=this.toHide.not(this.errorsFor(a));return}if(!g){this.formatAndAdd(a,f);return false}}}catch(h){this.settings.debug&& |
|||
window.console&&console.log("exception occured when checking element "+a.id+", check the '"+f.method+"' method",h);throw h;}}if(!d){this.objectLength(b)&&this.successList.push(a);return true}},customMetaMessage:function(a,b){if(c.metadata){var d=this.settings.meta?c(a).metadata()[this.settings.meta]:c(a).metadata();return d&&d.messages&&d.messages[b]}},customMessage:function(a,b){var d=this.settings.messages[a];return d&&(d.constructor==String?d:d[b])},findDefined:function(){for(var a=0;a<arguments.length;a++)if(arguments[a]!== |
|||
undefined)return arguments[a]},defaultMessage:function(a,b){return this.findDefined(this.customMessage(a.name,b),this.customMetaMessage(a,b),!this.settings.ignoreTitle&&a.title||undefined,c.validator.messages[b],"<strong>Warning: No message defined for "+a.name+"</strong>")},formatAndAdd:function(a,b){var d=this.defaultMessage(a,b.method),e=/\$?\{(\d+)\}/g;if(typeof d=="function")d=d.call(this,b.parameters,a);else if(e.test(d))d=jQuery.format(d.replace(e,"{$1}"),b.parameters);this.errorList.push({message:d, |
|||
element:a});this.errorMap[a.name]=d;this.submitted[a.name]=d},addWrapper:function(a){if(this.settings.wrapper)a=a.add(a.parent(this.settings.wrapper));return a},defaultShowErrors:function(){for(var a=0;this.errorList[a];a++){var b=this.errorList[a];this.settings.highlight&&this.settings.highlight.call(this,b.element,this.settings.errorClass,this.settings.validClass);this.showLabel(b.element,b.message)}if(this.errorList.length)this.toShow=this.toShow.add(this.containers);if(this.settings.success)for(a= |
|||
0;this.successList[a];a++)this.showLabel(this.successList[a]);if(this.settings.unhighlight){a=0;for(b=this.validElements();b[a];a++)this.settings.unhighlight.call(this,b[a],this.settings.errorClass,this.settings.validClass)}this.toHide=this.toHide.not(this.toShow);this.hideErrors();this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return c(this.errorList).map(function(){return this.element})},showLabel:function(a, |
|||
b){var d=this.errorsFor(a);if(d.length){d.removeClass().addClass(this.settings.errorClass);d.attr("generated")&&d.html(b)}else{d=c("<"+this.settings.errorElement+"/>").attr({"for":this.idOrName(a),generated:true}).addClass(this.settings.errorClass).html(b||"");if(this.settings.wrapper)d=d.hide().show().wrap("<"+this.settings.wrapper+"/>").parent();this.labelContainer.append(d).length||(this.settings.errorPlacement?this.settings.errorPlacement(d,c(a)):d.insertAfter(a))}if(!b&&this.settings.success){d.text(""); |
|||
typeof this.settings.success=="string"?d.addClass(this.settings.success):this.settings.success(d)}this.toShow=this.toShow.add(d)},errorsFor:function(a){var b=this.idOrName(a);return this.errors().filter(function(){return c(this).attr("for")==b})},idOrName:function(a){return this.groups[a.name]||(this.checkable(a)?a.name:a.id||a.name)},checkable:function(a){return/radio|checkbox/i.test(a.type)},findByName:function(a){var b=this.currentForm;return c(document.getElementsByName(a)).map(function(d,e){return e.form== |
|||
b&&e.name==a&&e||null})},getLength:function(a,b){switch(b.nodeName.toLowerCase()){case "select":return c("option:selected",b).length;case "input":if(this.checkable(b))return this.findByName(b.name).filter(":checked").length}return a.length},depend:function(a,b){return this.dependTypes[typeof a]?this.dependTypes[typeof a](a,b):true},dependTypes:{"boolean":function(a){return a},string:function(a,b){return!!c(a,b.form).length},"function":function(a,b){return a(b)}},optional:function(a){return!c.validator.methods.required.call(this, |
|||
c.trim(a.value),a)&&"dependency-mismatch"},startRequest:function(a){if(!this.pending[a.name]){this.pendingRequest++;this.pending[a.name]=true}},stopRequest:function(a,b){this.pendingRequest--;if(this.pendingRequest<0)this.pendingRequest=0;delete this.pending[a.name];if(b&&this.pendingRequest==0&&this.formSubmitted&&this.form()){c(this.currentForm).submit();this.formSubmitted=false}else if(!b&&this.pendingRequest==0&&this.formSubmitted){c(this.currentForm).triggerHandler("invalid-form",[this]);this.formSubmitted= |
|||
false}},previousValue:function(a){return c.data(a,"previousValue")||c.data(a,"previousValue",{old:null,valid:true,message:this.defaultMessage(a,"remote")})}},classRuleSettings:{required:{required:true},email:{email:true},url:{url:true},date:{date:true},dateISO:{dateISO:true},dateDE:{dateDE:true},number:{number:true},numberDE:{numberDE:true},digits:{digits:true},creditcard:{creditcard:true}},addClassRules:function(a,b){a.constructor==String?this.classRuleSettings[a]=b:c.extend(this.classRuleSettings, |
|||
a)},classRules:function(a){var b={};(a=c(a).attr("class"))&&c.each(a.split(" "),function(){this in c.validator.classRuleSettings&&c.extend(b,c.validator.classRuleSettings[this])});return b},attributeRules:function(a){var b={};a=c(a);for(var d in c.validator.methods){var e=a.attr(d);if(e)b[d]=e}b.maxlength&&/-1|2147483647|524288/.test(b.maxlength)&&delete b.maxlength;return b},metadataRules:function(a){if(!c.metadata)return{};var b=c.data(a.form,"validator").settings.meta;return b?c(a).metadata()[b]: |
|||
c(a).metadata()},staticRules:function(a){var b={},d=c.data(a.form,"validator");if(d.settings.rules)b=c.validator.normalizeRule(d.settings.rules[a.name])||{};return b},normalizeRules:function(a,b){c.each(a,function(d,e){if(e===false)delete a[d];else if(e.param||e.depends){var f=true;switch(typeof e.depends){case "string":f=!!c(e.depends,b.form).length;break;case "function":f=e.depends.call(b,b)}if(f)a[d]=e.param!==undefined?e.param:true;else delete a[d]}});c.each(a,function(d,e){a[d]=c.isFunction(e)? |
|||
e(b):e});c.each(["minlength","maxlength","min","max"],function(){if(a[this])a[this]=Number(a[this])});c.each(["rangelength","range"],function(){if(a[this])a[this]=[Number(a[this][0]),Number(a[this][1])]});if(c.validator.autoCreateRanges){if(a.min&&a.max){a.range=[a.min,a.max];delete a.min;delete a.max}if(a.minlength&&a.maxlength){a.rangelength=[a.minlength,a.maxlength];delete a.minlength;delete a.maxlength}}a.messages&&delete a.messages;return a},normalizeRule:function(a){if(typeof a=="string"){var b= |
|||
{};c.each(a.split(/\s/),function(){b[this]=true});a=b}return a},addMethod:function(a,b,d){c.validator.methods[a]=b;c.validator.messages[a]=d!=undefined?d:c.validator.messages[a];b.length<3&&c.validator.addClassRules(a,c.validator.normalizeRule(a))},methods:{required:function(a,b,d){if(!this.depend(d,b))return"dependency-mismatch";switch(b.nodeName.toLowerCase()){case "select":return(a=c(b).val())&&a.length>0;case "input":if(this.checkable(b))return this.getLength(a,b)>0;default:return c.trim(a).length> |
|||
0}},remote:function(a,b,d){if(this.optional(b))return"dependency-mismatch";var e=this.previousValue(b);this.settings.messages[b.name]||(this.settings.messages[b.name]={});e.originalMessage=this.settings.messages[b.name].remote;this.settings.messages[b.name].remote=e.message;d=typeof d=="string"&&{url:d}||d;if(this.pending[b.name])return"pending";if(e.old===a)return e.valid;e.old=a;var f=this;this.startRequest(b);var g={};g[b.name]=a;c.ajax(c.extend(true,{url:d,mode:"abort",port:"validate"+b.name, |
|||
dataType:"json",data:g,success:function(h){f.settings.messages[b.name].remote=e.originalMessage;var j=h===true;if(j){var i=f.formSubmitted;f.prepareElement(b);f.formSubmitted=i;f.successList.push(b);f.showErrors()}else{i={};h=h||f.defaultMessage(b,"remote");i[b.name]=e.message=c.isFunction(h)?h(a):h;f.showErrors(i)}e.valid=j;f.stopRequest(b,j)}},d));return"pending"},minlength:function(a,b,d){return this.optional(b)||this.getLength(c.trim(a),b)>=d},maxlength:function(a,b,d){return this.optional(b)|| |
|||
this.getLength(c.trim(a),b)<=d},rangelength:function(a,b,d){a=this.getLength(c.trim(a),b);return this.optional(b)||a>=d[0]&&a<=d[1]},min:function(a,b,d){return this.optional(b)||a>=d},max:function(a,b,d){return this.optional(b)||a<=d},range:function(a,b,d){return this.optional(b)||a>=d[0]&&a<=d[1]},email:function(a,b){return this.optional(b)||/^((([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])))\.?$/i.test(a)}, |
|||
url:function(a,b){return this.optional(b)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([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])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(a)}, |
|||
date:function(a,b){return this.optional(b)||!/Invalid|NaN/.test(new Date(a))},dateISO:function(a,b){return this.optional(b)||/^\d{4}[\/-]\d{1,2}[\/-]\d{1,2}$/.test(a)},number:function(a,b){return this.optional(b)||/^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(a)},digits:function(a,b){return this.optional(b)||/^\d+$/.test(a)},creditcard:function(a,b){if(this.optional(b))return"dependency-mismatch";if(/[^0-9-]+/.test(a))return false;var d=0,e=0,f=false;a=a.replace(/\D/g,"");for(var g=a.length-1;g>= |
|||
0;g--){e=a.charAt(g);e=parseInt(e,10);if(f)if((e*=2)>9)e-=9;d+=e;f=!f}return d%10==0},accept:function(a,b,d){d=typeof d=="string"?d.replace(/,/g,"|"):"png|jpe?g|gif";return this.optional(b)||a.match(RegExp(".("+d+")$","i"))},equalTo:function(a,b,d){d=c(d).unbind(".validate-equalTo").bind("blur.validate-equalTo",function(){c(b).valid()});return a==d.val()}}});c.format=c.validator.format})(jQuery); |
|||
(function(c){var a={};if(c.ajaxPrefilter)c.ajaxPrefilter(function(d,e,f){e=d.port;if(d.mode=="abort"){a[e]&&a[e].abort();a[e]=f}});else{var b=c.ajax;c.ajax=function(d){var e=("port"in d?d:c.ajaxSettings).port;if(("mode"in d?d:c.ajaxSettings).mode=="abort"){a[e]&&a[e].abort();return a[e]=b.apply(this,arguments)}return b.apply(this,arguments)}}})(jQuery); |
|||
(function(c){!jQuery.event.special.focusin&&!jQuery.event.special.focusout&&document.addEventListener&&c.each({focus:"focusin",blur:"focusout"},function(a,b){function d(e){e=c.event.fix(e);e.type=b;return c.event.handle.call(this,e)}c.event.special[b]={setup:function(){this.addEventListener(a,d,true)},teardown:function(){this.removeEventListener(a,d,true)},handler:function(e){arguments[0]=c.event.fix(e);arguments[0].type=b;return c.event.handle.apply(this,arguments)}}});c.extend(c.fn,{validateDelegate:function(a, |
|||
b,d){return this.bind(b,function(e){var f=c(e.target);if(f.is(a))return d.apply(f,arguments)})}})})(jQuery); |
|||
@ -1,319 +0,0 @@ |
|||
/// <reference path="jquery-1.5.1.js" />
|
|||
/// <reference path="jquery.validate.js" />
|
|||
|
|||
/*! |
|||
** Unobtrusive validation support library for jQuery and jQuery Validate |
|||
** Copyright (C) Microsoft Corporation. All rights reserved. |
|||
*/ |
|||
|
|||
/*jslint white: true, browser: true, onevar: true, undef: true, nomen: true, eqeqeq: true, plusplus: true, bitwise: true, regexp: true, newcap: true, immed: true, strict: false */ |
|||
/*global document: false, jQuery: false */ |
|||
|
|||
(function ($) { |
|||
var $jQval = $.validator, |
|||
adapters, |
|||
data_validation = "unobtrusiveValidation"; |
|||
|
|||
function setValidationValues(options, ruleName, value) { |
|||
options.rules[ruleName] = value; |
|||
if (options.message) { |
|||
options.messages[ruleName] = options.message; |
|||
} |
|||
} |
|||
|
|||
function splitAndTrim(value) { |
|||
return value.replace(/^\s+|\s+$/g, "").split(/\s*,\s*/g); |
|||
} |
|||
|
|||
function getModelPrefix(fieldName) { |
|||
return fieldName.substr(0, fieldName.lastIndexOf(".") + 1); |
|||
} |
|||
|
|||
function appendModelPrefix(value, prefix) { |
|||
if (value.indexOf("*.") === 0) { |
|||
value = value.replace("*.", prefix); |
|||
} |
|||
return value; |
|||
} |
|||
|
|||
function onError(error, inputElement) { // 'this' is the form element
|
|||
var container = $(this).find("[data-valmsg-for='" + inputElement[0].name + "']"), |
|||
replace = $.parseJSON(container.attr("data-valmsg-replace")) !== false; |
|||
|
|||
container.removeClass("field-validation-valid").addClass("field-validation-error"); |
|||
error.data("unobtrusiveContainer", container); |
|||
|
|||
if (replace) { |
|||
container.empty(); |
|||
error.removeClass("input-validation-error").appendTo(container); |
|||
} |
|||
else { |
|||
error.hide(); |
|||
} |
|||
} |
|||
|
|||
function onErrors(form, validator) { // 'this' is the form element
|
|||
var container = $(this).find("[data-valmsg-summary=true]"), |
|||
list = container.find("ul"); |
|||
|
|||
if (list && list.length && validator.errorList.length) { |
|||
list.empty(); |
|||
container.addClass("validation-summary-errors").removeClass("validation-summary-valid"); |
|||
|
|||
$.each(validator.errorList, function () { |
|||
$("<li />").html(this.message).appendTo(list); |
|||
}); |
|||
} |
|||
} |
|||
|
|||
function onSuccess(error) { // 'this' is the form element
|
|||
var container = error.data("unobtrusiveContainer"), |
|||
replace = $.parseJSON(container.attr("data-valmsg-replace")); |
|||
|
|||
if (container) { |
|||
container.addClass("field-validation-valid").removeClass("field-validation-error"); |
|||
error.removeData("unobtrusiveContainer"); |
|||
|
|||
if (replace) { |
|||
container.empty(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
function validationInfo(form) { |
|||
var $form = $(form), |
|||
result = $form.data(data_validation); |
|||
|
|||
if (!result) { |
|||
result = { |
|||
options: { // options structure passed to jQuery Validate's validate() method
|
|||
errorClass: "input-validation-error", |
|||
errorElement: "span", |
|||
errorPlacement: $.proxy(onError, form), |
|||
invalidHandler: $.proxy(onErrors, form), |
|||
messages: {}, |
|||
rules: {}, |
|||
success: $.proxy(onSuccess, form) |
|||
}, |
|||
attachValidation: function () { |
|||
$form.validate(this.options); |
|||
}, |
|||
validate: function () { // a validation function that is called by unobtrusive Ajax
|
|||
$form.validate(); |
|||
return $form.valid(); |
|||
} |
|||
}; |
|||
$form.data(data_validation, result); |
|||
} |
|||
|
|||
return result; |
|||
} |
|||
|
|||
$jQval.unobtrusive = { |
|||
adapters: [], |
|||
|
|||
parseElement: function (element, skipAttach) { |
|||
/// <summary>
|
|||
/// Parses a single HTML element for unobtrusive validation attributes.
|
|||
/// </summary>
|
|||
/// <param name="element" domElement="true">The HTML element to be parsed.</param>
|
|||
/// <param name="skipAttach" type="Boolean">[Optional] true to skip attaching the
|
|||
/// validation to the form. If parsing just this single element, you should specify true.
|
|||
/// If parsing several elements, you should specify false, and manually attach the validation
|
|||
/// to the form when you are finished. The default is false.</param>
|
|||
var $element = $(element), |
|||
form = $element.parents("form")[0], |
|||
valInfo, rules, messages; |
|||
|
|||
if (!form) { // Cannot do client-side validation without a form
|
|||
return; |
|||
} |
|||
|
|||
valInfo = validationInfo(form); |
|||
valInfo.options.rules[element.name] = rules = {}; |
|||
valInfo.options.messages[element.name] = messages = {}; |
|||
|
|||
$.each(this.adapters, function () { |
|||
var prefix = "data-val-" + this.name, |
|||
message = $element.attr(prefix), |
|||
paramValues = {}; |
|||
|
|||
if (message !== undefined) { // Compare against undefined, because an empty message is legal (and falsy)
|
|||
prefix += "-"; |
|||
|
|||
$.each(this.params, function () { |
|||
paramValues[this] = $element.attr(prefix + this); |
|||
}); |
|||
|
|||
this.adapt({ |
|||
element: element, |
|||
form: form, |
|||
message: message, |
|||
params: paramValues, |
|||
rules: rules, |
|||
messages: messages |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
jQuery.extend(rules, { "__dummy__": true }); |
|||
|
|||
if (!skipAttach) { |
|||
valInfo.attachValidation(); |
|||
} |
|||
}, |
|||
|
|||
parse: function (selector) { |
|||
/// <summary>
|
|||
/// Parses all the HTML elements in the specified selector. It looks for input elements decorated
|
|||
/// with the [data-val=true] attribute value and enables validation according to the data-val-*
|
|||
/// attribute values.
|
|||
/// </summary>
|
|||
/// <param name="selector" type="String">Any valid jQuery selector.</param>
|
|||
$(selector).find(":input[data-val=true]").each(function () { |
|||
$jQval.unobtrusive.parseElement(this, true); |
|||
}); |
|||
|
|||
$("form").each(function () { |
|||
var info = validationInfo(this); |
|||
if (info) { |
|||
info.attachValidation(); |
|||
} |
|||
}); |
|||
} |
|||
}; |
|||
|
|||
adapters = $jQval.unobtrusive.adapters; |
|||
|
|||
adapters.add = function (adapterName, params, fn) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|||
/// <param name="params" type="Array" optional="true">[Optional] An array of parameter names (strings) that will
|
|||
/// be extracted from the data-val-nnnn-mmmm HTML attributes (where nnnn is the adapter name, and
|
|||
/// mmmm is the parameter name).</param>
|
|||
/// <param name="fn" type="Function">The function to call, which adapts the values from the HTML
|
|||
/// attributes into jQuery Validate rules and/or messages.</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
if (!fn) { // Called with no params, just a function
|
|||
fn = params; |
|||
params = []; |
|||
} |
|||
this.push({ name: adapterName, params: params, adapt: fn }); |
|||
return this; |
|||
}; |
|||
|
|||
adapters.addBool = function (adapterName, ruleName) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|||
/// the jQuery Validate validation rule has no parameter values.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|||
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
|
|||
/// of adapterName will be used instead.</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
return this.add(adapterName, function (options) { |
|||
setValidationValues(options, ruleName || adapterName, true); |
|||
}); |
|||
}; |
|||
|
|||
adapters.addMinMax = function (adapterName, minRuleName, maxRuleName, minMaxRuleName, minAttribute, maxAttribute) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|||
/// the jQuery Validate validation has three potential rules (one for min-only, one for max-only, and
|
|||
/// one for min-and-max). The HTML parameters are expected to be named -min and -max.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute (where nnnn is the adapter name).</param>
|
|||
/// <param name="minRuleName" type="String">The name of the jQuery Validate rule to be used when you only
|
|||
/// have a minimum value.</param>
|
|||
/// <param name="maxRuleName" type="String">The name of the jQuery Validate rule to be used when you only
|
|||
/// have a maximum value.</param>
|
|||
/// <param name="minMaxRuleName" type="String">The name of the jQuery Validate rule to be used when you
|
|||
/// have both a minimum and maximum value.</param>
|
|||
/// <param name="minAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
|
|||
/// contains the minimum value. The default is "min".</param>
|
|||
/// <param name="maxAttribute" type="String" optional="true">[Optional] The name of the HTML attribute that
|
|||
/// contains the maximum value. The default is "max".</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
return this.add(adapterName, [minAttribute || "min", maxAttribute || "max"], function (options) { |
|||
var min = options.params.min, |
|||
max = options.params.max; |
|||
|
|||
if (min && max) { |
|||
setValidationValues(options, minMaxRuleName, [min, max]); |
|||
} |
|||
else if (min) { |
|||
setValidationValues(options, minRuleName, min); |
|||
} |
|||
else if (max) { |
|||
setValidationValues(options, maxRuleName, max); |
|||
} |
|||
}); |
|||
}; |
|||
|
|||
adapters.addSingleVal = function (adapterName, attribute, ruleName) { |
|||
/// <summary>Adds a new adapter to convert unobtrusive HTML into a jQuery Validate validation, where
|
|||
/// the jQuery Validate validation rule has a single value.</summary>
|
|||
/// <param name="adapterName" type="String">The name of the adapter to be added. This matches the name used
|
|||
/// in the data-val-nnnn HTML attribute(where nnnn is the adapter name).</param>
|
|||
/// <param name="attribute" type="String">[Optional] The name of the HTML attribute that contains the value.
|
|||
/// The default is "val".</param>
|
|||
/// <param name="ruleName" type="String" optional="true">[Optional] The name of the jQuery Validate rule. If not provided, the value
|
|||
/// of adapterName will be used instead.</param>
|
|||
/// <returns type="jQuery.validator.unobtrusive.adapters" />
|
|||
return this.add(adapterName, [attribute || "val"], function (options) { |
|||
setValidationValues(options, ruleName || adapterName, options.params[attribute]); |
|||
}); |
|||
}; |
|||
|
|||
$jQval.addMethod("__dummy__", function (value, element, params) { |
|||
return true; |
|||
}); |
|||
|
|||
$jQval.addMethod("regex", function (value, element, params) { |
|||
var match; |
|||
if (this.optional(element)) { |
|||
return true; |
|||
} |
|||
|
|||
match = new RegExp(params).exec(value); |
|||
return (match && (match.index === 0) && (match[0].length === value.length)); |
|||
}); |
|||
|
|||
adapters.addSingleVal("accept", "exts").addSingleVal("regex", "pattern"); |
|||
adapters.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url"); |
|||
adapters.addMinMax("length", "minlength", "maxlength", "rangelength").addMinMax("range", "min", "max", "range"); |
|||
adapters.add("equalto", ["other"], function (options) { |
|||
var prefix = getModelPrefix(options.element.name), |
|||
other = options.params.other, |
|||
fullOtherName = appendModelPrefix(other, prefix), |
|||
element = $(options.form).find(":input[name=" + fullOtherName + "]")[0]; |
|||
|
|||
setValidationValues(options, "equalTo", element); |
|||
}); |
|||
adapters.add("required", function (options) { |
|||
// jQuery Validate equates "required" with "mandatory" for checkbox elements
|
|||
if (options.element.tagName.toUpperCase() !== "INPUT" || options.element.type.toUpperCase() !== "CHECKBOX") { |
|||
setValidationValues(options, "required", true); |
|||
} |
|||
}); |
|||
adapters.add("remote", ["url", "type", "additionalfields"], function (options) { |
|||
var value = { |
|||
url: options.params.url, |
|||
type: options.params.type || "GET", |
|||
data: {} |
|||
}, |
|||
prefix = getModelPrefix(options.element.name); |
|||
|
|||
$.each(splitAndTrim(options.params.additionalfields || options.element.name), function (i, fieldName) { |
|||
var paramName = appendModelPrefix(fieldName, prefix); |
|||
value.data[paramName] = function () { |
|||
return $(options.form).find(":input[name='" + paramName + "']").val(); |
|||
}; |
|||
}); |
|||
|
|||
setValidationValues(options, "remote", value); |
|||
}); |
|||
|
|||
$(function () { |
|||
$jQval.unobtrusive.parse(document); |
|||
}); |
|||
}(jQuery)); |
|||
@ -1,5 +0,0 @@ |
|||
/* |
|||
** Unobtrusive validation support library for jQuery and jQuery Validate |
|||
** Copyright (C) Microsoft Corporation. All rights reserved. |
|||
*/ |
|||
(function(a){var d=a.validator,b,f="unobtrusiveValidation";function c(a,b,c){a.rules[b]=c;if(a.message)a.messages[b]=a.message}function i(a){return a.replace(/^\s+|\s+$/g,"").split(/\s*,\s*/g)}function g(a){return a.substr(0,a.lastIndexOf(".")+1)}function e(a,b){if(a.indexOf("*.")===0)a=a.replace("*.",b);return a}function l(c,d){var b=a(this).find("[data-valmsg-for='"+d[0].name+"']"),e=a.parseJSON(b.attr("data-valmsg-replace"))!==false;b.removeClass("field-validation-valid").addClass("field-validation-error");c.data("unobtrusiveContainer",b);if(e){b.empty();c.removeClass("input-validation-error").appendTo(b)}else c.hide()}function k(e,d){var c=a(this).find("[data-valmsg-summary=true]"),b=c.find("ul");if(b&&b.length&&d.errorList.length){b.empty();c.addClass("validation-summary-errors").removeClass("validation-summary-valid");a.each(d.errorList,function(){a("<li />").html(this.message).appendTo(b)})}}function j(c){var b=c.data("unobtrusiveContainer"),d=a.parseJSON(b.attr("data-valmsg-replace"));if(b){b.addClass("field-validation-valid").removeClass("field-validation-error");c.removeData("unobtrusiveContainer");d&&b.empty()}}function h(d){var b=a(d),c=b.data(f);if(!c){c={options:{errorClass:"input-validation-error",errorElement:"span",errorPlacement:a.proxy(l,d),invalidHandler:a.proxy(k,d),messages:{},rules:{},success:a.proxy(j,d)},attachValidation:function(){b.validate(this.options)},validate:function(){b.validate();return b.valid()}};b.data(f,c)}return c}d.unobtrusive={adapters:[],parseElement:function(b,i){var d=a(b),f=d.parents("form")[0],c,e,g;if(!f)return;c=h(f);c.options.rules[b.name]=e={};c.options.messages[b.name]=g={};a.each(this.adapters,function(){var c="data-val-"+this.name,i=d.attr(c),h={};if(i!==undefined){c+="-";a.each(this.params,function(){h[this]=d.attr(c+this)});this.adapt({element:b,form:f,message:i,params:h,rules:e,messages:g})}});jQuery.extend(e,{__dummy__:true});!i&&c.attachValidation()},parse:function(b){a(b).find(":input[data-val=true]").each(function(){d.unobtrusive.parseElement(this,true)});a("form").each(function(){var a=h(this);a&&a.attachValidation()})}};b=d.unobtrusive.adapters;b.add=function(c,a,b){if(!b){b=a;a=[]}this.push({name:c,params:a,adapt:b});return this};b.addBool=function(a,b){return this.add(a,function(d){c(d,b||a,true)})};b.addMinMax=function(e,g,f,a,d,b){return this.add(e,[d||"min",b||"max"],function(b){var e=b.params.min,d=b.params.max;if(e&&d)c(b,a,[e,d]);else if(e)c(b,g,e);else d&&c(b,f,d)})};b.addSingleVal=function(a,b,d){return this.add(a,[b||"val"],function(e){c(e,d||a,e.params[b])})};d.addMethod("__dummy__",function(){return true});d.addMethod("regex",function(b,c,d){var a;if(this.optional(c))return true;a=(new RegExp(d)).exec(b);return a&&a.index===0&&a[0].length===b.length});b.addSingleVal("accept","exts").addSingleVal("regex","pattern");b.addBool("creditcard").addBool("date").addBool("digits").addBool("email").addBool("number").addBool("url");b.addMinMax("length","minlength","maxlength","rangelength").addMinMax("range","min","max","range");b.add("equalto",["other"],function(b){var h=g(b.element.name),i=b.params.other,d=e(i,h),f=a(b.form).find(":input[name="+d+"]")[0];c(b,"equalTo",f)});b.add("required",function(a){(a.element.tagName.toUpperCase()!=="INPUT"||a.element.type.toUpperCase()!=="CHECKBOX")&&c(a,"required",true)});b.add("remote",["url","type","additionalfields"],function(b){var d={url:b.params.url,type:b.params.type||"GET",data:{}},f=g(b.element.name);a.each(i(b.params.additionalfields||b.element.name),function(h,g){var c=e(g,f);d.data[c]=function(){return a(b.form).find(":input[name='"+c+"']").val()}});c(b,"remote",d)});a(function(){d.unobtrusive.parse(document)})})(jQuery); |
|||
@ -1,969 +0,0 @@ |
|||
/*! |
|||
* Note: While Microsoft is not the author of this file, Microsoft is |
|||
* offering you a license subject to the terms of the Microsoft Software |
|||
* License Terms for Microsoft ASP.NET Model View Controller 3. |
|||
* Microsoft reserves all other rights. The notices below are provided |
|||
* for informational purposes only and are not the license terms under |
|||
* which Microsoft distributed this file. |
|||
* |
|||
* Modernizr v1.7 |
|||
* http://www.modernizr.com
|
|||
* |
|||
* Developed by: |
|||
* - Faruk Ates http://farukat.es/
|
|||
* - Paul Irish http://paulirish.com/
|
|||
* |
|||
* Copyright (c) 2009-2011 |
|||
*/ |
|||
|
|||
|
|||
/* |
|||
* Modernizr is a script that detects native CSS3 and HTML5 features |
|||
* available in the current UA and provides an object containing all |
|||
* features with a true/false value, depending on whether the UA has |
|||
* native support for it or not. |
|||
* |
|||
* Modernizr will also add classes to the <html> element of the page, |
|||
* one for each feature it detects. If the UA supports it, a class |
|||
* like "cssgradients" will be added. If not, the class name will be |
|||
* "no-cssgradients". This allows for simple if-conditionals in your |
|||
* CSS, giving you fine control over the look & feel of your website. |
|||
* |
|||
* @author Faruk Ates |
|||
* @author Paul Irish |
|||
* @copyright (c) 2009-2011 Faruk Ates. |
|||
* @contributor Ben Alman |
|||
*/ |
|||
|
|||
window.Modernizr = (function(window,document,undefined){ |
|||
|
|||
var version = '1.7', |
|||
|
|||
ret = {}, |
|||
|
|||
/** |
|||
* !! DEPRECATED !! |
|||
* |
|||
* enableHTML5 is a private property for advanced use only. If enabled, |
|||
* it will make Modernizr.init() run through a brief while() loop in |
|||
* which it will create all HTML5 elements in the DOM to allow for |
|||
* styling them in Internet Explorer, which does not recognize any |
|||
* non-HTML4 elements unless created in the DOM this way. |
|||
* |
|||
* enableHTML5 is ON by default. |
|||
* |
|||
* The enableHTML5 toggle option is DEPRECATED as per 1.6, and will be |
|||
* replaced in 2.0 in lieu of the modular, configurable nature of 2.0. |
|||
*/ |
|||
enableHTML5 = true, |
|||
|
|||
|
|||
docElement = document.documentElement, |
|||
docHead = document.head || document.getElementsByTagName('head')[0], |
|||
|
|||
/** |
|||
* Create our "modernizr" element that we do most feature tests on. |
|||
*/ |
|||
mod = 'modernizr', |
|||
modElem = document.createElement( mod ), |
|||
m_style = modElem.style, |
|||
|
|||
/** |
|||
* Create the input element for various Web Forms feature tests. |
|||
*/ |
|||
inputElem = document.createElement( 'input' ), |
|||
|
|||
smile = ':)', |
|||
|
|||
tostring = Object.prototype.toString, |
|||
|
|||
// List of property values to set for css tests. See ticket #21
|
|||
prefixes = ' -webkit- -moz- -o- -ms- -khtml- '.split(' '), |
|||
|
|||
// Following spec is to expose vendor-specific style properties as:
|
|||
// elem.style.WebkitBorderRadius
|
|||
// and the following would be incorrect:
|
|||
// elem.style.webkitBorderRadius
|
|||
|
|||
// Webkit ghosts their properties in lowercase but Opera & Moz do not.
|
|||
// Microsoft foregoes prefixes entirely <= IE8, but appears to
|
|||
// use a lowercase `ms` instead of the correct `Ms` in IE9
|
|||
|
|||
// More here: http://github.com/Modernizr/Modernizr/issues/issue/21
|
|||
domPrefixes = 'Webkit Moz O ms Khtml'.split(' '), |
|||
|
|||
ns = {'svg': 'http://www.w3.org/2000/svg'}, |
|||
|
|||
tests = {}, |
|||
inputs = {}, |
|||
attrs = {}, |
|||
|
|||
classes = [], |
|||
|
|||
featurename, // used in testing loop
|
|||
|
|||
|
|||
|
|||
// todo: consider using http://javascript.nwbox.com/CSSSupport/css-support.js instead
|
|||
testMediaQuery = function(mq){ |
|||
|
|||
var st = document.createElement('style'), |
|||
div = document.createElement('div'), |
|||
ret; |
|||
|
|||
st.textContent = mq + '{#modernizr{height:3px}}'; |
|||
docHead.appendChild(st); |
|||
div.id = 'modernizr'; |
|||
docElement.appendChild(div); |
|||
|
|||
ret = div.offsetHeight === 3; |
|||
|
|||
st.parentNode.removeChild(st); |
|||
div.parentNode.removeChild(div); |
|||
|
|||
return !!ret; |
|||
|
|||
}, |
|||
|
|||
|
|||
/** |
|||
* isEventSupported determines if a given element supports the given event |
|||
* function from http://yura.thinkweb2.com/isEventSupported/
|
|||
*/ |
|||
isEventSupported = (function(){ |
|||
|
|||
var TAGNAMES = { |
|||
'select':'input','change':'input', |
|||
'submit':'form','reset':'form', |
|||
'error':'img','load':'img','abort':'img' |
|||
}; |
|||
|
|||
function isEventSupported(eventName, element) { |
|||
|
|||
element = element || document.createElement(TAGNAMES[eventName] || 'div'); |
|||
eventName = 'on' + eventName; |
|||
|
|||
// When using `setAttribute`, IE skips "unload", WebKit skips "unload" and "resize", whereas `in` "catches" those
|
|||
var isSupported = (eventName in element); |
|||
|
|||
if (!isSupported) { |
|||
// If it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element
|
|||
if (!element.setAttribute) { |
|||
element = document.createElement('div'); |
|||
} |
|||
if (element.setAttribute && element.removeAttribute) { |
|||
element.setAttribute(eventName, ''); |
|||
isSupported = is(element[eventName], 'function'); |
|||
|
|||
// If property was created, "remove it" (by setting value to `undefined`)
|
|||
if (!is(element[eventName], undefined)) { |
|||
element[eventName] = undefined; |
|||
} |
|||
element.removeAttribute(eventName); |
|||
} |
|||
} |
|||
|
|||
element = null; |
|||
return isSupported; |
|||
} |
|||
return isEventSupported; |
|||
})(); |
|||
|
|||
|
|||
// hasOwnProperty shim by kangax needed for Safari 2.0 support
|
|||
var _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty; |
|||
if (!is(_hasOwnProperty, undefined) && !is(_hasOwnProperty.call, undefined)) { |
|||
hasOwnProperty = function (object, property) { |
|||
return _hasOwnProperty.call(object, property); |
|||
}; |
|||
} |
|||
else { |
|||
hasOwnProperty = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */ |
|||
return ((property in object) && is(object.constructor.prototype[property], undefined)); |
|||
}; |
|||
} |
|||
|
|||
/** |
|||
* set_css applies given styles to the Modernizr DOM node. |
|||
*/ |
|||
function set_css( str ) { |
|||
m_style.cssText = str; |
|||
} |
|||
|
|||
/** |
|||
* set_css_all extrapolates all vendor-specific css strings. |
|||
*/ |
|||
function set_css_all( str1, str2 ) { |
|||
return set_css(prefixes.join(str1 + ';') + ( str2 || '' )); |
|||
} |
|||
|
|||
/** |
|||
* is returns a boolean for if typeof obj is exactly type. |
|||
*/ |
|||
function is( obj, type ) { |
|||
return typeof obj === type; |
|||
} |
|||
|
|||
/** |
|||
* contains returns a boolean for if substr is found within str. |
|||
*/ |
|||
function contains( str, substr ) { |
|||
return (''+str).indexOf( substr ) !== -1; |
|||
} |
|||
|
|||
/** |
|||
* test_props is a generic CSS / DOM property test; if a browser supports |
|||
* a certain property, it won't return undefined for it. |
|||
* A supported CSS property returns empty string when its not yet set. |
|||
*/ |
|||
function test_props( props, callback ) { |
|||
for ( var i in props ) { |
|||
if ( m_style[ props[i] ] !== undefined && ( !callback || callback( props[i], modElem ) ) ) { |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* test_props_all tests a list of DOM properties we want to check against. |
|||
* We specify literally ALL possible (known and/or likely) properties on |
|||
* the element including the non-vendor prefixed one, for forward- |
|||
* compatibility. |
|||
*/ |
|||
function test_props_all( prop, callback ) { |
|||
|
|||
var uc_prop = prop.charAt(0).toUpperCase() + prop.substr(1), |
|||
props = (prop + ' ' + domPrefixes.join(uc_prop + ' ') + uc_prop).split(' '); |
|||
|
|||
return !!test_props( props, callback ); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* Tests |
|||
* ----- |
|||
*/ |
|||
|
|||
tests['flexbox'] = function() { |
|||
/** |
|||
* set_prefixed_value_css sets the property of a specified element |
|||
* adding vendor prefixes to the VALUE of the property. |
|||
* @param {Element} element |
|||
* @param {string} property The property name. This will not be prefixed. |
|||
* @param {string} value The value of the property. This WILL be prefixed. |
|||
* @param {string=} extra Additional CSS to append unmodified to the end of |
|||
* the CSS string. |
|||
*/ |
|||
function set_prefixed_value_css(element, property, value, extra) { |
|||
property += ':'; |
|||
element.style.cssText = (property + prefixes.join(value + ';' + property)).slice(0, -property.length) + (extra || ''); |
|||
} |
|||
|
|||
/** |
|||
* set_prefixed_property_css sets the property of a specified element |
|||
* adding vendor prefixes to the NAME of the property. |
|||
* @param {Element} element |
|||
* @param {string} property The property name. This WILL be prefixed. |
|||
* @param {string} value The value of the property. This will not be prefixed. |
|||
* @param {string=} extra Additional CSS to append unmodified to the end of |
|||
* the CSS string. |
|||
*/ |
|||
function set_prefixed_property_css(element, property, value, extra) { |
|||
element.style.cssText = prefixes.join(property + ':' + value + ';') + (extra || ''); |
|||
} |
|||
|
|||
var c = document.createElement('div'), |
|||
elem = document.createElement('div'); |
|||
|
|||
set_prefixed_value_css(c, 'display', 'box', 'width:42px;padding:0;'); |
|||
set_prefixed_property_css(elem, 'box-flex', '1', 'width:10px;'); |
|||
|
|||
c.appendChild(elem); |
|||
docElement.appendChild(c); |
|||
|
|||
var ret = elem.offsetWidth === 42; |
|||
|
|||
c.removeChild(elem); |
|||
docElement.removeChild(c); |
|||
|
|||
return ret; |
|||
}; |
|||
|
|||
// On the S60 and BB Storm, getContext exists, but always returns undefined
|
|||
// http://github.com/Modernizr/Modernizr/issues/issue/97/
|
|||
|
|||
tests['canvas'] = function() { |
|||
var elem = document.createElement( 'canvas' ); |
|||
return !!(elem.getContext && elem.getContext('2d')); |
|||
}; |
|||
|
|||
tests['canvastext'] = function() { |
|||
return !!(ret['canvas'] && is(document.createElement( 'canvas' ).getContext('2d').fillText, 'function')); |
|||
}; |
|||
|
|||
// This WebGL test false positives in FF depending on graphics hardware. But really it's quite impossible to know
|
|||
// wether webgl will succeed until after you create the context. You might have hardware that can support
|
|||
// a 100x100 webgl canvas, but will not support a 1000x1000 webgl canvas. So this feature inference is weak,
|
|||
// but intentionally so.
|
|||
tests['webgl'] = function(){ |
|||
return !!window.WebGLRenderingContext; |
|||
}; |
|||
|
|||
/* |
|||
* The Modernizr.touch test only indicates if the browser supports |
|||
* touch events, which does not necessarily reflect a touchscreen |
|||
* device, as evidenced by tablets running Windows 7 or, alas, |
|||
* the Palm Pre / WebOS (touch) phones. |
|||
* |
|||
* Additionally, Chrome (desktop) used to lie about its support on this, |
|||
* but that has since been rectified: http://crbug.com/36415
|
|||
* |
|||
* We also test for Firefox 4 Multitouch Support. |
|||
* |
|||
* For more info, see: http://modernizr.github.com/Modernizr/touch.html
|
|||
*/ |
|||
|
|||
tests['touch'] = function() { |
|||
|
|||
return ('ontouchstart' in window) || testMediaQuery('@media ('+prefixes.join('touch-enabled),(')+'modernizr)'); |
|||
|
|||
}; |
|||
|
|||
|
|||
/** |
|||
* geolocation tests for the new Geolocation API specification. |
|||
* This test is a standards compliant-only test; for more complete |
|||
* testing, including a Google Gears fallback, please see: |
|||
* http://code.google.com/p/geo-location-javascript/
|
|||
* or view a fallback solution using google's geo API: |
|||
* http://gist.github.com/366184
|
|||
*/ |
|||
tests['geolocation'] = function() { |
|||
return !!navigator.geolocation; |
|||
}; |
|||
|
|||
// Per 1.6:
|
|||
// This used to be Modernizr.crosswindowmessaging but the longer
|
|||
// name has been deprecated in favor of a shorter and property-matching one.
|
|||
// The old API is still available in 1.6, but as of 2.0 will throw a warning,
|
|||
// and in the first release thereafter disappear entirely.
|
|||
tests['postmessage'] = function() { |
|||
return !!window.postMessage; |
|||
}; |
|||
|
|||
// Web SQL database detection is tricky:
|
|||
|
|||
// In chrome incognito mode, openDatabase is truthy, but using it will
|
|||
// throw an exception: http://crbug.com/42380
|
|||
// We can create a dummy database, but there is no way to delete it afterwards.
|
|||
|
|||
// Meanwhile, Safari users can get prompted on any database creation.
|
|||
// If they do, any page with Modernizr will give them a prompt:
|
|||
// http://github.com/Modernizr/Modernizr/issues/closed#issue/113
|
|||
|
|||
// We have chosen to allow the Chrome incognito false positive, so that Modernizr
|
|||
// doesn't litter the web with these test databases. As a developer, you'll have
|
|||
// to account for this gotcha yourself.
|
|||
tests['websqldatabase'] = function() { |
|||
var result = !!window.openDatabase; |
|||
/* if (result){ |
|||
try { |
|||
result = !!openDatabase( mod + "testdb", "1.0", mod + "testdb", 2e4); |
|||
} catch(e) { |
|||
} |
|||
} */ |
|||
return result; |
|||
}; |
|||
|
|||
// Vendors have inconsistent prefixing with the experimental Indexed DB:
|
|||
// - Firefox is shipping indexedDB in FF4 as moz_indexedDB
|
|||
// - Webkit's implementation is accessible through webkitIndexedDB
|
|||
// We test both styles.
|
|||
tests['indexedDB'] = function(){ |
|||
for (var i = -1, len = domPrefixes.length; ++i < len; ){ |
|||
var prefix = domPrefixes[i].toLowerCase(); |
|||
if (window[prefix + '_indexedDB'] || window[prefix + 'IndexedDB']){ |
|||
return true; |
|||
} |
|||
} |
|||
return false; |
|||
}; |
|||
|
|||
// documentMode logic from YUI to filter out IE8 Compat Mode
|
|||
// which false positives.
|
|||
tests['hashchange'] = function() { |
|||
return isEventSupported('hashchange', window) && ( document.documentMode === undefined || document.documentMode > 7 ); |
|||
}; |
|||
|
|||
// Per 1.6:
|
|||
// This used to be Modernizr.historymanagement but the longer
|
|||
// name has been deprecated in favor of a shorter and property-matching one.
|
|||
// The old API is still available in 1.6, but as of 2.0 will throw a warning,
|
|||
// and in the first release thereafter disappear entirely.
|
|||
tests['history'] = function() { |
|||
return !!(window.history && history.pushState); |
|||
}; |
|||
|
|||
tests['draganddrop'] = function() { |
|||
return isEventSupported('dragstart') && isEventSupported('drop'); |
|||
}; |
|||
|
|||
tests['websockets'] = function(){ |
|||
return ('WebSocket' in window); |
|||
}; |
|||
|
|||
|
|||
// http://css-tricks.com/rgba-browser-support/
|
|||
tests['rgba'] = function() { |
|||
// Set an rgba() color and check the returned value
|
|||
|
|||
set_css( 'background-color:rgba(150,255,150,.5)' ); |
|||
|
|||
return contains( m_style.backgroundColor, 'rgba' ); |
|||
}; |
|||
|
|||
tests['hsla'] = function() { |
|||
// Same as rgba(), in fact, browsers re-map hsla() to rgba() internally,
|
|||
// except IE9 who retains it as hsla
|
|||
|
|||
set_css('background-color:hsla(120,40%,100%,.5)' ); |
|||
|
|||
return contains( m_style.backgroundColor, 'rgba' ) || contains( m_style.backgroundColor, 'hsla' ); |
|||
}; |
|||
|
|||
tests['multiplebgs'] = function() { |
|||
// Setting multiple images AND a color on the background shorthand property
|
|||
// and then querying the style.background property value for the number of
|
|||
// occurrences of "url(" is a reliable method for detecting ACTUAL support for this!
|
|||
|
|||
set_css( 'background:url(//:),url(//:),red url(//:)' ); |
|||
|
|||
// If the UA supports multiple backgrounds, there should be three occurrences
|
|||
// of the string "url(" in the return value for elem_style.background
|
|||
|
|||
return new RegExp("(url\\s*\\(.*?){3}").test(m_style.background); |
|||
}; |
|||
|
|||
|
|||
// In testing support for a given CSS property, it's legit to test:
|
|||
// `elem.style[styleName] !== undefined`
|
|||
// If the property is supported it will return an empty string,
|
|||
// if unsupported it will return undefined.
|
|||
|
|||
// We'll take advantage of this quick test and skip setting a style
|
|||
// on our modernizr element, but instead just testing undefined vs
|
|||
// empty string.
|
|||
|
|||
|
|||
tests['backgroundsize'] = function() { |
|||
return test_props_all( 'backgroundSize' ); |
|||
}; |
|||
|
|||
tests['borderimage'] = function() { |
|||
return test_props_all( 'borderImage' ); |
|||
}; |
|||
|
|||
|
|||
// Super comprehensive table about all the unique implementations of
|
|||
// border-radius: http://muddledramblings.com/table-of-css3-border-radius-compliance
|
|||
|
|||
tests['borderradius'] = function() { |
|||
return test_props_all( 'borderRadius', '', function( prop ) { |
|||
return contains( prop, 'orderRadius' ); |
|||
}); |
|||
}; |
|||
|
|||
// WebOS unfortunately false positives on this test.
|
|||
tests['boxshadow'] = function() { |
|||
return test_props_all( 'boxShadow' ); |
|||
}; |
|||
|
|||
// FF3.0 will false positive on this test
|
|||
tests['textshadow'] = function(){ |
|||
return document.createElement('div').style.textShadow === ''; |
|||
}; |
|||
|
|||
|
|||
tests['opacity'] = function() { |
|||
// Browsers that actually have CSS Opacity implemented have done so
|
|||
// according to spec, which means their return values are within the
|
|||
// range of [0.0,1.0] - including the leading zero.
|
|||
|
|||
set_css_all( 'opacity:.55' ); |
|||
|
|||
// The non-literal . in this regex is intentional:
|
|||
// German Chrome returns this value as 0,55
|
|||
// https://github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632
|
|||
return /^0.55$/.test(m_style.opacity); |
|||
}; |
|||
|
|||
|
|||
tests['cssanimations'] = function() { |
|||
return test_props_all( 'animationName' ); |
|||
}; |
|||
|
|||
|
|||
tests['csscolumns'] = function() { |
|||
return test_props_all( 'columnCount' ); |
|||
}; |
|||
|
|||
|
|||
tests['cssgradients'] = function() { |
|||
/** |
|||
* For CSS Gradients syntax, please see: |
|||
* http://webkit.org/blog/175/introducing-css-gradients/
|
|||
* https://developer.mozilla.org/en/CSS/-moz-linear-gradient
|
|||
* https://developer.mozilla.org/en/CSS/-moz-radial-gradient
|
|||
* http://dev.w3.org/csswg/css3-images/#gradients-
|
|||
*/ |
|||
|
|||
var str1 = 'background-image:', |
|||
str2 = 'gradient(linear,left top,right bottom,from(#9f9),to(white));', |
|||
str3 = 'linear-gradient(left top,#9f9, white);'; |
|||
|
|||
set_css( |
|||
(str1 + prefixes.join(str2 + str1) + prefixes.join(str3 + str1)).slice(0,-str1.length) |
|||
); |
|||
|
|||
return contains( m_style.backgroundImage, 'gradient' ); |
|||
}; |
|||
|
|||
|
|||
tests['cssreflections'] = function() { |
|||
return test_props_all( 'boxReflect' ); |
|||
}; |
|||
|
|||
|
|||
tests['csstransforms'] = function() { |
|||
return !!test_props([ 'transformProperty', 'WebkitTransform', 'MozTransform', 'OTransform', 'msTransform' ]); |
|||
}; |
|||
|
|||
|
|||
tests['csstransforms3d'] = function() { |
|||
|
|||
var ret = !!test_props([ 'perspectiveProperty', 'WebkitPerspective', 'MozPerspective', 'OPerspective', 'msPerspective' ]); |
|||
|
|||
// Webkit’s 3D transforms are passed off to the browser's own graphics renderer.
|
|||
// It works fine in Safari on Leopard and Snow Leopard, but not in Chrome in
|
|||
// some conditions. As a result, Webkit typically recognizes the syntax but
|
|||
// will sometimes throw a false positive, thus we must do a more thorough check:
|
|||
if (ret && 'webkitPerspective' in docElement.style){ |
|||
|
|||
// Webkit allows this media query to succeed only if the feature is enabled.
|
|||
// `@media (transform-3d),(-o-transform-3d),(-moz-transform-3d),(-ms-transform-3d),(-webkit-transform-3d),(modernizr){ ... }`
|
|||
ret = testMediaQuery('@media ('+prefixes.join('transform-3d),(')+'modernizr)'); |
|||
} |
|||
return ret; |
|||
}; |
|||
|
|||
|
|||
tests['csstransitions'] = function() { |
|||
return test_props_all( 'transitionProperty' ); |
|||
}; |
|||
|
|||
|
|||
// @font-face detection routine by Diego Perini
|
|||
// http://javascript.nwbox.com/CSSSupport/
|
|||
tests['fontface'] = function(){ |
|||
|
|||
var |
|||
sheet, bool, |
|||
head = docHead || docElement, |
|||
style = document.createElement("style"), |
|||
impl = document.implementation || { hasFeature: function() { return false; } }; |
|||
|
|||
style.type = 'text/css'; |
|||
head.insertBefore(style, head.firstChild); |
|||
sheet = style.sheet || style.styleSheet; |
|||
|
|||
var supportAtRule = impl.hasFeature('CSS2', '') ? |
|||
function(rule) { |
|||
if (!(sheet && rule)) return false; |
|||
var result = false; |
|||
try { |
|||
sheet.insertRule(rule, 0); |
|||
result = (/src/i).test(sheet.cssRules[0].cssText); |
|||
sheet.deleteRule(sheet.cssRules.length - 1); |
|||
} catch(e) { } |
|||
return result; |
|||
} : |
|||
function(rule) { |
|||
if (!(sheet && rule)) return false; |
|||
sheet.cssText = rule; |
|||
|
|||
return sheet.cssText.length !== 0 && (/src/i).test(sheet.cssText) && |
|||
sheet.cssText |
|||
.replace(/\r+|\n+/g, '') |
|||
.indexOf(rule.split(' ')[0]) === 0; |
|||
}; |
|||
|
|||
bool = supportAtRule('@font-face { font-family: "font"; src: url(data:,); }'); |
|||
head.removeChild(style); |
|||
return bool; |
|||
}; |
|||
|
|||
|
|||
// These tests evaluate support of the video/audio elements, as well as
|
|||
// testing what types of content they support.
|
|||
//
|
|||
// We're using the Boolean constructor here, so that we can extend the value
|
|||
// e.g. Modernizr.video // true
|
|||
// Modernizr.video.ogg // 'probably'
|
|||
//
|
|||
// Codec values from : http://github.com/NielsLeenheer/html5test/blob/9106a8/index.html#L845
|
|||
// thx to NielsLeenheer and zcorpan
|
|||
|
|||
// Note: in FF 3.5.1 and 3.5.0, "no" was a return value instead of empty string.
|
|||
// Modernizr does not normalize for that.
|
|||
|
|||
tests['video'] = function() { |
|||
var elem = document.createElement('video'), |
|||
bool = !!elem.canPlayType; |
|||
|
|||
if (bool){ |
|||
bool = new Boolean(bool); |
|||
bool.ogg = elem.canPlayType('video/ogg; codecs="theora"'); |
|||
|
|||
// Workaround required for IE9, which doesn't report video support without audio codec specified.
|
|||
// bug 599718 @ msft connect
|
|||
var h264 = 'video/mp4; codecs="avc1.42E01E'; |
|||
bool.h264 = elem.canPlayType(h264 + '"') || elem.canPlayType(h264 + ', mp4a.40.2"'); |
|||
|
|||
bool.webm = elem.canPlayType('video/webm; codecs="vp8, vorbis"'); |
|||
} |
|||
return bool; |
|||
}; |
|||
|
|||
tests['audio'] = function() { |
|||
var elem = document.createElement('audio'), |
|||
bool = !!elem.canPlayType; |
|||
|
|||
if (bool){ |
|||
bool = new Boolean(bool); |
|||
bool.ogg = elem.canPlayType('audio/ogg; codecs="vorbis"'); |
|||
bool.mp3 = elem.canPlayType('audio/mpeg;'); |
|||
|
|||
// Mimetypes accepted:
|
|||
// https://developer.mozilla.org/En/Media_formats_supported_by_the_audio_and_video_elements
|
|||
// http://bit.ly/iphoneoscodecs
|
|||
bool.wav = elem.canPlayType('audio/wav; codecs="1"'); |
|||
bool.m4a = elem.canPlayType('audio/x-m4a;') || elem.canPlayType('audio/aac;'); |
|||
} |
|||
return bool; |
|||
}; |
|||
|
|||
|
|||
// Firefox has made these tests rather unfun.
|
|||
|
|||
// In FF4, if disabled, window.localStorage should === null.
|
|||
|
|||
// Normally, we could not test that directly and need to do a
|
|||
// `('localStorage' in window) && ` test first because otherwise Firefox will
|
|||
// throw http://bugzil.la/365772 if cookies are disabled
|
|||
|
|||
// However, in Firefox 4 betas, if dom.storage.enabled == false, just mentioning
|
|||
// the property will throw an exception. http://bugzil.la/599479
|
|||
// This looks to be fixed for FF4 Final.
|
|||
|
|||
// Because we are forced to try/catch this, we'll go aggressive.
|
|||
|
|||
// FWIW: IE8 Compat mode supports these features completely:
|
|||
// http://www.quirksmode.org/dom/html5.html
|
|||
// But IE8 doesn't support either with local files
|
|||
|
|||
tests['localstorage'] = function() { |
|||
try { |
|||
return !!localStorage.getItem; |
|||
} catch(e) { |
|||
return false; |
|||
} |
|||
}; |
|||
|
|||
tests['sessionstorage'] = function() { |
|||
try { |
|||
return !!sessionStorage.getItem; |
|||
} catch(e){ |
|||
return false; |
|||
} |
|||
}; |
|||
|
|||
|
|||
tests['webWorkers'] = function () { |
|||
return !!window.Worker; |
|||
}; |
|||
|
|||
|
|||
tests['applicationcache'] = function() { |
|||
return !!window.applicationCache; |
|||
}; |
|||
|
|||
|
|||
// Thanks to Erik Dahlstrom
|
|||
tests['svg'] = function(){ |
|||
return !!document.createElementNS && !!document.createElementNS(ns.svg, "svg").createSVGRect; |
|||
}; |
|||
|
|||
tests['inlinesvg'] = function() { |
|||
var div = document.createElement('div'); |
|||
div.innerHTML = '<svg/>'; |
|||
return (div.firstChild && div.firstChild.namespaceURI) == ns.svg; |
|||
}; |
|||
|
|||
// Thanks to F1lt3r and lucideer
|
|||
// http://github.com/Modernizr/Modernizr/issues#issue/35
|
|||
tests['smil'] = function(){ |
|||
return !!document.createElementNS && /SVG/.test(tostring.call(document.createElementNS(ns.svg,'animate'))); |
|||
}; |
|||
|
|||
tests['svgclippaths'] = function(){ |
|||
// Possibly returns a false positive in Safari 3.2?
|
|||
return !!document.createElementNS && /SVG/.test(tostring.call(document.createElementNS(ns.svg,'clipPath'))); |
|||
}; |
|||
|
|||
|
|||
// input features and input types go directly onto the ret object, bypassing the tests loop.
|
|||
// Hold this guy to execute in a moment.
|
|||
function webforms(){ |
|||
|
|||
// Run through HTML5's new input attributes to see if the UA understands any.
|
|||
// We're using f which is the <input> element created early on
|
|||
// Mike Taylr has created a comprehensive resource for testing these attributes
|
|||
// when applied to all input types:
|
|||
// http://miketaylr.com/code/input-type-attr.html
|
|||
// spec: http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
|
|||
ret['input'] = (function(props) { |
|||
for (var i = 0, len = props.length; i<len; i++) { |
|||
attrs[ props[i] ] = !!(props[i] in inputElem); |
|||
} |
|||
return attrs; |
|||
})('autocomplete autofocus list placeholder max min multiple pattern required step'.split(' ')); |
|||
|
|||
// Run through HTML5's new input types to see if the UA understands any.
|
|||
// This is put behind the tests runloop because it doesn't return a
|
|||
// true/false like all the other tests; instead, it returns an object
|
|||
// containing each input type with its corresponding true/false value
|
|||
|
|||
// Big thanks to @miketaylr for the html5 forms expertise. http://miketaylr.com/
|
|||
ret['inputtypes'] = (function(props) { |
|||
|
|||
for (var i = 0, bool, inputElemType, defaultView, len=props.length; i < len; i++) { |
|||
|
|||
inputElem.setAttribute('type', inputElemType = props[i]); |
|||
bool = inputElem.type !== 'text'; |
|||
|
|||
// We first check to see if the type we give it sticks..
|
|||
// If the type does, we feed it a textual value, which shouldn't be valid.
|
|||
// If the value doesn't stick, we know there's input sanitization which infers a custom UI
|
|||
if (bool){ |
|||
|
|||
inputElem.value = smile; |
|||
inputElem.style.cssText = 'position:absolute;visibility:hidden;'; |
|||
|
|||
if (/^range$/.test(inputElemType) && inputElem.style.WebkitAppearance !== undefined){ |
|||
|
|||
docElement.appendChild(inputElem); |
|||
defaultView = document.defaultView; |
|||
|
|||
// Safari 2-4 allows the smiley as a value, despite making a slider
|
|||
bool = defaultView.getComputedStyle && |
|||
defaultView.getComputedStyle(inputElem, null).WebkitAppearance !== 'textfield' && |
|||
// Mobile android web browser has false positive, so must
|
|||
// check the height to see if the widget is actually there.
|
|||
(inputElem.offsetHeight !== 0); |
|||
|
|||
docElement.removeChild(inputElem); |
|||
|
|||
} else if (/^(search|tel)$/.test(inputElemType)){ |
|||
// Spec doesnt define any special parsing or detectable UI
|
|||
// behaviors so we pass these through as true
|
|||
|
|||
// Interestingly, opera fails the earlier test, so it doesn't
|
|||
// even make it here.
|
|||
|
|||
} else if (/^(url|email)$/.test(inputElemType)) { |
|||
// Real url and email support comes with prebaked validation.
|
|||
bool = inputElem.checkValidity && inputElem.checkValidity() === false; |
|||
|
|||
} else if (/^color$/.test(inputElemType)) { |
|||
// chuck into DOM and force reflow for Opera bug in 11.00
|
|||
// github.com/Modernizr/Modernizr/issues#issue/159
|
|||
docElement.appendChild(inputElem); |
|||
docElement.offsetWidth; |
|||
bool = inputElem.value != smile; |
|||
docElement.removeChild(inputElem); |
|||
|
|||
} else { |
|||
// If the upgraded input compontent rejects the :) text, we got a winner
|
|||
bool = inputElem.value != smile; |
|||
} |
|||
} |
|||
|
|||
inputs[ props[i] ] = !!bool; |
|||
} |
|||
return inputs; |
|||
})('search tel url email datetime date month week time datetime-local number range color'.split(' ')); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
// End of test definitions
|
|||
// -----------------------
|
|||
|
|||
|
|||
|
|||
// Run through all tests and detect their support in the current UA.
|
|||
// todo: hypothetically we could be doing an array of tests and use a basic loop here.
|
|||
for ( var feature in tests ) { |
|||
if ( hasOwnProperty( tests, feature ) ) { |
|||
// run the test, throw the return value into the Modernizr,
|
|||
// then based on that boolean, define an appropriate className
|
|||
// and push it into an array of classes we'll join later.
|
|||
featurename = feature.toLowerCase(); |
|||
ret[ featurename ] = tests[ feature ](); |
|||
|
|||
classes.push( ( ret[ featurename ] ? '' : 'no-' ) + featurename ); |
|||
} |
|||
} |
|||
|
|||
// input tests need to run.
|
|||
if (!ret.input) webforms(); |
|||
|
|||
|
|||
|
|||
// Per 1.6: deprecated API is still accesible for now:
|
|||
ret.crosswindowmessaging = ret.postmessage; |
|||
ret.historymanagement = ret.history; |
|||
|
|||
|
|||
|
|||
/** |
|||
* Addtest allows the user to define their own feature tests |
|||
* the result will be added onto the Modernizr object, |
|||
* as well as an appropriate className set on the html element |
|||
* |
|||
* @param feature - String naming the feature |
|||
* @param test - Function returning true if feature is supported, false if not |
|||
*/ |
|||
ret.addTest = function (feature, test) { |
|||
feature = feature.toLowerCase(); |
|||
|
|||
if (ret[ feature ]) { |
|||
return; // quit if you're trying to overwrite an existing test
|
|||
} |
|||
test = !!(test()); |
|||
docElement.className += ' ' + (test ? '' : 'no-') + feature; |
|||
ret[ feature ] = test; |
|||
return ret; // allow chaining.
|
|||
}; |
|||
|
|||
/** |
|||
* Reset m.style.cssText to nothing to reduce memory footprint. |
|||
*/ |
|||
set_css( '' ); |
|||
modElem = inputElem = null; |
|||
|
|||
//>>BEGIN IEPP
|
|||
// Enable HTML 5 elements for styling in IE.
|
|||
// fyi: jscript version does not reflect trident version
|
|||
// therefore ie9 in ie7 mode will still have a jScript v.9
|
|||
if ( enableHTML5 && window.attachEvent && (function(){ var elem = document.createElement("div"); |
|||
elem.innerHTML = "<elem></elem>"; |
|||
return elem.childNodes.length !== 1; })()) { |
|||
// iepp v1.6.2 by @jon_neal : code.google.com/p/ie-print-protector
|
|||
(function(win, doc) { |
|||
var elems = 'abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video', |
|||
elemsArr = elems.split('|'), |
|||
elemsArrLen = elemsArr.length, |
|||
elemRegExp = new RegExp('(^|\\s)('+elems+')', 'gi'), |
|||
tagRegExp = new RegExp('<(\/*)('+elems+')', 'gi'), |
|||
ruleRegExp = new RegExp('(^|[^\\n]*?\\s)('+elems+')([^\\n]*)({[\\n\\w\\W]*?})', 'gi'), |
|||
docFrag = doc.createDocumentFragment(), |
|||
html = doc.documentElement, |
|||
head = html.firstChild, |
|||
bodyElem = doc.createElement('body'), |
|||
styleElem = doc.createElement('style'), |
|||
body; |
|||
function shim(doc) { |
|||
var a = -1; |
|||
while (++a < elemsArrLen) |
|||
// Use createElement so IE allows HTML5-named elements in a document
|
|||
doc.createElement(elemsArr[a]); |
|||
} |
|||
function getCSS(styleSheetList, mediaType) { |
|||
var a = -1, |
|||
len = styleSheetList.length, |
|||
styleSheet, |
|||
cssTextArr = []; |
|||
while (++a < len) { |
|||
styleSheet = styleSheetList[a]; |
|||
// Get css from all non-screen stylesheets and their imports
|
|||
if ((mediaType = styleSheet.media || mediaType) != 'screen') cssTextArr.push(getCSS(styleSheet.imports, mediaType), styleSheet.cssText); |
|||
} |
|||
return cssTextArr.join(''); |
|||
} |
|||
// Shim the document and iepp fragment
|
|||
shim(doc); |
|||
shim(docFrag); |
|||
// Add iepp custom print style element
|
|||
head.insertBefore(styleElem, head.firstChild); |
|||
styleElem.media = 'print'; |
|||
win.attachEvent( |
|||
'onbeforeprint', |
|||
function() { |
|||
var a = -1, |
|||
cssText = getCSS(doc.styleSheets, 'all'), |
|||
cssTextArr = [], |
|||
rule; |
|||
body = body || doc.body; |
|||
// Get only rules which reference HTML5 elements by name
|
|||
while ((rule = ruleRegExp.exec(cssText)) != null) |
|||
// Replace all html5 element references with iepp substitute classnames
|
|||
cssTextArr.push((rule[1]+rule[2]+rule[3]).replace(elemRegExp, '$1.iepp_$2')+rule[4]); |
|||
// Write iepp custom print CSS
|
|||
styleElem.styleSheet.cssText = cssTextArr.join('\n'); |
|||
while (++a < elemsArrLen) { |
|||
var nodeList = doc.getElementsByTagName(elemsArr[a]), |
|||
nodeListLen = nodeList.length, |
|||
b = -1; |
|||
while (++b < nodeListLen) |
|||
if (nodeList[b].className.indexOf('iepp_') < 0) |
|||
// Append iepp substitute classnames to all html5 elements
|
|||
nodeList[b].className += ' iepp_'+elemsArr[a]; |
|||
} |
|||
docFrag.appendChild(body); |
|||
html.appendChild(bodyElem); |
|||
// Write iepp substitute print-safe document
|
|||
bodyElem.className = body.className; |
|||
// Replace HTML5 elements with <font> which is print-safe and shouldn't conflict since it isn't part of html5
|
|||
bodyElem.innerHTML = body.innerHTML.replace(tagRegExp, '<$1font'); |
|||
} |
|||
); |
|||
win.attachEvent( |
|||
'onafterprint', |
|||
function() { |
|||
// Undo everything done in onbeforeprint
|
|||
bodyElem.innerHTML = ''; |
|||
html.removeChild(bodyElem); |
|||
html.appendChild(body); |
|||
styleElem.styleSheet.cssText = ''; |
|||
} |
|||
); |
|||
})(window, document); |
|||
} |
|||
//>>END IEPP
|
|||
|
|||
// Assign private properties to the return object with prefix
|
|||
ret._enableHTML5 = enableHTML5; |
|||
ret._version = version; |
|||
|
|||
// Remove "no-js" class from <html> element, if it exists:
|
|||
docElement.className = docElement.className.replace(/\bno-js\b/,'') |
|||
+ ' js ' |
|||
|
|||
// Add the new classes to the <html> element.
|
|||
+ classes.join( ' ' ); |
|||
|
|||
return ret; |
|||
|
|||
})(this,this.document); |
|||
File diff suppressed because one or more lines are too long
@ -1,53 +0,0 @@ |
|||
@model Test.Models.ChangePasswordModel |
|||
|
|||
@{ |
|||
ViewBag.Title = "Change Password"; |
|||
} |
|||
|
|||
<h2>Change Password</h2> |
|||
<p> |
|||
Use the form below to change your password. |
|||
</p> |
|||
<p> |
|||
New passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length. |
|||
</p> |
|||
|
|||
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> |
|||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> |
|||
|
|||
@using (Html.BeginForm()) { |
|||
@Html.ValidationSummary(true, "Password change was unsuccessful. Please correct the errors and try again.") |
|||
<div> |
|||
<fieldset> |
|||
<legend>Account Information</legend> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.OldPassword) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.PasswordFor(m => m.OldPassword) |
|||
@Html.ValidationMessageFor(m => m.OldPassword) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.NewPassword) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.PasswordFor(m => m.NewPassword) |
|||
@Html.ValidationMessageFor(m => m.NewPassword) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.ConfirmPassword) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.PasswordFor(m => m.ConfirmPassword) |
|||
@Html.ValidationMessageFor(m => m.ConfirmPassword) |
|||
</div> |
|||
|
|||
<p> |
|||
<input type="submit" value="Change Password" /> |
|||
</p> |
|||
</fieldset> |
|||
</div> |
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
@{ |
|||
ViewBag.Title = "Change Password"; |
|||
} |
|||
|
|||
<h2>Change Password</h2> |
|||
<p> |
|||
Your password has been changed successfully. |
|||
</p> |
|||
@ -1,48 +0,0 @@ |
|||
@model Test.Models.LogOnModel |
|||
|
|||
@{ |
|||
ViewBag.Title = "Log On"; |
|||
} |
|||
|
|||
<h2>Log On</h2> |
|||
<p> |
|||
Please enter your user name and password. @Html.ActionLink("Register", "Register") if you don't have an account. |
|||
</p> |
|||
|
|||
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> |
|||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> |
|||
|
|||
@Html.ValidationSummary(true, "Login was unsuccessful. Please correct the errors and try again.") |
|||
|
|||
@using (Html.BeginForm()) { |
|||
<div> |
|||
<fieldset> |
|||
<legend>Account Information</legend> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.UserName) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.TextBoxFor(m => m.UserName) |
|||
@Html.ValidationMessageFor(m => m.UserName) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.Password) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.PasswordFor(m => m.Password) |
|||
@Html.ValidationMessageFor(m => m.Password) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.CheckBoxFor(m => m.RememberMe) |
|||
@Html.LabelFor(m => m.RememberMe) |
|||
</div> |
|||
|
|||
<p> |
|||
<input type="submit" value="Log On" /> |
|||
</p> |
|||
</fieldset> |
|||
</div> |
|||
} |
|||
@ -1,61 +0,0 @@ |
|||
@model Test.Models.RegisterModel |
|||
|
|||
@{ |
|||
ViewBag.Title = "Register"; |
|||
} |
|||
|
|||
<h2>Create a New Account</h2> |
|||
<p> |
|||
Use the form below to create a new account. |
|||
</p> |
|||
<p> |
|||
Passwords are required to be a minimum of @Membership.MinRequiredPasswordLength characters in length. |
|||
</p> |
|||
|
|||
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> |
|||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> |
|||
|
|||
@using (Html.BeginForm()) { |
|||
@Html.ValidationSummary(true, "Account creation was unsuccessful. Please correct the errors and try again.") |
|||
<div> |
|||
<fieldset> |
|||
<legend>Account Information</legend> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.UserName) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.TextBoxFor(m => m.UserName) |
|||
@Html.ValidationMessageFor(m => m.UserName) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.Email) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.TextBoxFor(m => m.Email) |
|||
@Html.ValidationMessageFor(m => m.Email) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.Password) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.PasswordFor(m => m.Password) |
|||
@Html.ValidationMessageFor(m => m.Password) |
|||
</div> |
|||
|
|||
<div class="editor-label"> |
|||
@Html.LabelFor(m => m.ConfirmPassword) |
|||
</div> |
|||
<div class="editor-field"> |
|||
@Html.PasswordFor(m => m.ConfirmPassword) |
|||
@Html.ValidationMessageFor(m => m.ConfirmPassword) |
|||
</div> |
|||
|
|||
<p> |
|||
<input type="submit" value="Register" /> |
|||
</p> |
|||
</fieldset> |
|||
</div> |
|||
} |
|||
@ -1,10 +1,10 @@ |
|||
@{ |
|||
ViewBag.Title = "Home Page"; |
|||
} |
|||
|
|||
<h2>@ViewBag.Message</h2> |
|||
<p> |
|||
To learn more about ASP.NET MVC visit <a href="http://asp.net/mvc" title="ASP.NET MVC Website">http://asp.net/mvc</a>. |
|||
</p> |
|||
<h3>Test remote image</h3> |
|||
@{ |
|||
ViewBag.Title = "Home Page"; |
|||
} |
|||
|
|||
<h2>@ViewBag.Message</h2> |
|||
<p> |
|||
Click the about tab to load up a page of resized images. |
|||
</p> |
|||
<h3>Remote image test</h3> |
|||
<img src="/remote.axd?http://images.mymovies.net/images/film/cin/500x377/fid11707.jpg?width=200"/> |
|||
@ -1,33 +1,31 @@ |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8" /> |
|||
<title>@ViewBag.Title</title> |
|||
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> |
|||
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script> |
|||
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script> |
|||
</head> |
|||
<body> |
|||
<div class="page"> |
|||
<header> |
|||
<div id="title"> |
|||
<h1>My MVC Application</h1> |
|||
</div> |
|||
<div id="logindisplay"> |
|||
@Html.Partial("_LogOnPartial") |
|||
</div> |
|||
<nav> |
|||
<ul id="menu"> |
|||
<li>@Html.ActionLink("Home", "Index", "Home")</li> |
|||
<li>@Html.ActionLink("About", "About", "Home")</li> |
|||
</ul> |
|||
</nav> |
|||
</header> |
|||
<section id="main"> |
|||
@RenderBody() |
|||
</section> |
|||
<footer> |
|||
</footer> |
|||
</div> |
|||
</body> |
|||
</html> |
|||
<!DOCTYPE html> |
|||
<html> |
|||
<head> |
|||
<meta charset="utf-8" /> |
|||
<title>@ViewBag.Title</title> |
|||
<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" /> |
|||
</head> |
|||
<body> |
|||
<div class="page"> |
|||
<header> |
|||
<div id="title"> |
|||
<h1> |
|||
ImageProcessor Test Website</h1> |
|||
</div> |
|||
<div id="logindisplay"> |
|||
</div> |
|||
<nav> |
|||
<ul id="menu"> |
|||
<li>@Html.ActionLink("Home", "Index", "Home")</li> |
|||
<li>@Html.ActionLink("About", "About", "Home")</li> |
|||
</ul> |
|||
</nav> |
|||
</header> |
|||
<section id="main"> |
|||
@RenderBody() |
|||
</section> |
|||
<footer> |
|||
</footer> |
|||
</div> |
|||
</body> |
|||
</html> |
|||
|
|||
@ -1,7 +0,0 @@ |
|||
@if(Request.IsAuthenticated) { |
|||
<text>Welcome <strong>@User.Identity.Name</strong>! |
|||
[ @Html.ActionLink("Log Off", "LogOff", "Account") ]</text> |
|||
} |
|||
else { |
|||
@:[ @Html.ActionLink("Log On", "LogOn", "Account") ] |
|||
} |
|||
Loading…
Reference in new issue