PageRenderTime 291ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/samples/OpenIdProviderMvc/Scripts/MicrosoftMvcAjax.debug.js

http://github.com/AArnott/dotnetopenid
JavaScript | 1208 lines | 761 code | 97 blank | 350 comment | 143 complexity | 05c119fb6ae3a002033d01027955b0c5 MD5 | raw file
  1. //!----------------------------------------------------------
  2. //! Copyright (C) Microsoft Corporation. All rights reserved.
  3. //!----------------------------------------------------------
  4. //! MicrosoftMvcAjax.js
  5. Type.registerNamespace('Sys.Mvc');
  6. ////////////////////////////////////////////////////////////////////////////////
  7. // Sys.Mvc.AjaxOptions
  8. Sys.Mvc.$create_AjaxOptions = function Sys_Mvc_AjaxOptions() { return {}; }
  9. ////////////////////////////////////////////////////////////////////////////////
  10. // Sys.Mvc.InsertionMode
  11. Sys.Mvc.InsertionMode = function() {
  12. /// <field name="replace" type="Number" integer="true" static="true">
  13. /// </field>
  14. /// <field name="insertBefore" type="Number" integer="true" static="true">
  15. /// </field>
  16. /// <field name="insertAfter" type="Number" integer="true" static="true">
  17. /// </field>
  18. };
  19. Sys.Mvc.InsertionMode.prototype = {
  20. replace: 0,
  21. insertBefore: 1,
  22. insertAfter: 2
  23. }
  24. Sys.Mvc.InsertionMode.registerEnum('Sys.Mvc.InsertionMode', false);
  25. ////////////////////////////////////////////////////////////////////////////////
  26. // Sys.Mvc.JsonValidationField
  27. Sys.Mvc.$create_JsonValidationField = function Sys_Mvc_JsonValidationField() { return {}; }
  28. ////////////////////////////////////////////////////////////////////////////////
  29. // Sys.Mvc.JsonValidationOptions
  30. Sys.Mvc.$create_JsonValidationOptions = function Sys_Mvc_JsonValidationOptions() { return {}; }
  31. ////////////////////////////////////////////////////////////////////////////////
  32. // Sys.Mvc.JsonValidationRule
  33. Sys.Mvc.$create_JsonValidationRule = function Sys_Mvc_JsonValidationRule() { return {}; }
  34. ////////////////////////////////////////////////////////////////////////////////
  35. // Sys.Mvc.AjaxContext
  36. Sys.Mvc.AjaxContext = function Sys_Mvc_AjaxContext(request, updateTarget, loadingElement, insertionMode) {
  37. /// <param name="request" type="Sys.Net.WebRequest">
  38. /// </param>
  39. /// <param name="updateTarget" type="Object" domElement="true">
  40. /// </param>
  41. /// <param name="loadingElement" type="Object" domElement="true">
  42. /// </param>
  43. /// <param name="insertionMode" type="Sys.Mvc.InsertionMode">
  44. /// </param>
  45. /// <field name="_insertionMode" type="Sys.Mvc.InsertionMode">
  46. /// </field>
  47. /// <field name="_loadingElement" type="Object" domElement="true">
  48. /// </field>
  49. /// <field name="_response" type="Sys.Net.WebRequestExecutor">
  50. /// </field>
  51. /// <field name="_request" type="Sys.Net.WebRequest">
  52. /// </field>
  53. /// <field name="_updateTarget" type="Object" domElement="true">
  54. /// </field>
  55. this._request = request;
  56. this._updateTarget = updateTarget;
  57. this._loadingElement = loadingElement;
  58. this._insertionMode = insertionMode;
  59. }
  60. Sys.Mvc.AjaxContext.prototype = {
  61. _insertionMode: 0,
  62. _loadingElement: null,
  63. _response: null,
  64. _request: null,
  65. _updateTarget: null,
  66. get_data: function Sys_Mvc_AjaxContext$get_data() {
  67. /// <value type="String"></value>
  68. if (this._response) {
  69. return this._response.get_responseData();
  70. }
  71. else {
  72. return null;
  73. }
  74. },
  75. get_insertionMode: function Sys_Mvc_AjaxContext$get_insertionMode() {
  76. /// <value type="Sys.Mvc.InsertionMode"></value>
  77. return this._insertionMode;
  78. },
  79. get_loadingElement: function Sys_Mvc_AjaxContext$get_loadingElement() {
  80. /// <value type="Object" domElement="true"></value>
  81. return this._loadingElement;
  82. },
  83. get_object: function Sys_Mvc_AjaxContext$get_object() {
  84. /// <value type="Object"></value>
  85. var executor = this.get_response();
  86. return (executor) ? executor.get_object() : null;
  87. },
  88. get_response: function Sys_Mvc_AjaxContext$get_response() {
  89. /// <value type="Sys.Net.WebRequestExecutor"></value>
  90. return this._response;
  91. },
  92. set_response: function Sys_Mvc_AjaxContext$set_response(value) {
  93. /// <value type="Sys.Net.WebRequestExecutor"></value>
  94. this._response = value;
  95. return value;
  96. },
  97. get_request: function Sys_Mvc_AjaxContext$get_request() {
  98. /// <value type="Sys.Net.WebRequest"></value>
  99. return this._request;
  100. },
  101. get_updateTarget: function Sys_Mvc_AjaxContext$get_updateTarget() {
  102. /// <value type="Object" domElement="true"></value>
  103. return this._updateTarget;
  104. }
  105. }
  106. ////////////////////////////////////////////////////////////////////////////////
  107. // Sys.Mvc.AsyncHyperlink
  108. Sys.Mvc.AsyncHyperlink = function Sys_Mvc_AsyncHyperlink() {
  109. }
  110. Sys.Mvc.AsyncHyperlink.handleClick = function Sys_Mvc_AsyncHyperlink$handleClick(anchor, evt, ajaxOptions) {
  111. /// <param name="anchor" type="Object" domElement="true">
  112. /// </param>
  113. /// <param name="evt" type="Sys.UI.DomEvent">
  114. /// </param>
  115. /// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
  116. /// </param>
  117. evt.preventDefault();
  118. Sys.Mvc.MvcHelpers._asyncRequest(anchor.href, 'post', '', anchor, ajaxOptions);
  119. }
  120. ////////////////////////////////////////////////////////////////////////////////
  121. // Sys.Mvc.FieldValidation
  122. Sys.Mvc.FieldValidation = function Sys_Mvc_FieldValidation(formValidation, fieldElements, validationMessageElement, replaceValidationMessageContents) {
  123. /// <param name="formValidation" type="Sys.Mvc.FormValidation">
  124. /// </param>
  125. /// <param name="fieldElements" type="Array" elementType="Object" elementDomElement="true">
  126. /// </param>
  127. /// <param name="validationMessageElement" type="Object" domElement="true">
  128. /// </param>
  129. /// <param name="replaceValidationMessageContents" type="Boolean">
  130. /// </param>
  131. /// <field name="_hasTextChangedTag" type="String" static="true">
  132. /// </field>
  133. /// <field name="_hasValidationFiredTag" type="String" static="true">
  134. /// </field>
  135. /// <field name="_inputElementErrorCss" type="String" static="true">
  136. /// </field>
  137. /// <field name="_inputElementValidCss" type="String" static="true">
  138. /// </field>
  139. /// <field name="_validationMessageErrorCss" type="String" static="true">
  140. /// </field>
  141. /// <field name="_validationMessageValidCss" type="String" static="true">
  142. /// </field>
  143. /// <field name="_onBlurHandler" type="Sys.UI.DomEventHandler">
  144. /// </field>
  145. /// <field name="_onChangeHandler" type="Sys.UI.DomEventHandler">
  146. /// </field>
  147. /// <field name="_onInputHandler" type="Sys.UI.DomEventHandler">
  148. /// </field>
  149. /// <field name="_onPropertyChangeHandler" type="Sys.UI.DomEventHandler">
  150. /// </field>
  151. /// <field name="_errors" type="Array">
  152. /// </field>
  153. /// <field name="_fieldElements" type="Array" elementType="Object" elementDomElement="true">
  154. /// </field>
  155. /// <field name="_formValidation" type="Sys.Mvc.FormValidation">
  156. /// </field>
  157. /// <field name="_replaceValidationMessageContents" type="Boolean">
  158. /// </field>
  159. /// <field name="_validationMessageElement" type="Object" domElement="true">
  160. /// </field>
  161. /// <field name="_validators" type="Array">
  162. /// </field>
  163. this._errors = [];
  164. this._validators = [];
  165. this._formValidation = formValidation;
  166. this._fieldElements = fieldElements;
  167. this._validationMessageElement = validationMessageElement;
  168. this._replaceValidationMessageContents = replaceValidationMessageContents;
  169. this._onBlurHandler = Function.createDelegate(this, this._element_OnBlur);
  170. this._onChangeHandler = Function.createDelegate(this, this._element_OnChange);
  171. this._onInputHandler = Function.createDelegate(this, this._element_OnInput);
  172. this._onPropertyChangeHandler = Function.createDelegate(this, this._element_OnPropertyChange);
  173. }
  174. Sys.Mvc.FieldValidation.prototype = {
  175. _onBlurHandler: null,
  176. _onChangeHandler: null,
  177. _onInputHandler: null,
  178. _onPropertyChangeHandler: null,
  179. _fieldElements: null,
  180. _formValidation: null,
  181. _replaceValidationMessageContents: false,
  182. _validationMessageElement: null,
  183. addError: function Sys_Mvc_FieldValidation$addError(message) {
  184. /// <param name="message" type="String">
  185. /// </param>
  186. this.addErrors([ message ]);
  187. },
  188. addErrors: function Sys_Mvc_FieldValidation$addErrors(messages) {
  189. /// <param name="messages" type="Array" elementType="String">
  190. /// </param>
  191. if (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(messages)) {
  192. Array.addRange(this._errors, messages);
  193. this._onErrorCountChanged();
  194. }
  195. },
  196. addValidator: function Sys_Mvc_FieldValidation$addValidator(validator) {
  197. /// <param name="validator" type="Sys.Mvc.Validator">
  198. /// </param>
  199. Array.add(this._validators, validator);
  200. },
  201. disableDynamicValidation: function Sys_Mvc_FieldValidation$disableDynamicValidation() {
  202. for (var i = 0; i < this._fieldElements.length; i++) {
  203. var fieldElement = this._fieldElements[i];
  204. if (Sys.Mvc._validationUtil.elementSupportsEvent(fieldElement, 'onpropertychange')) {
  205. Sys.UI.DomEvent.removeHandler(fieldElement, 'propertychange', this._onPropertyChangeHandler);
  206. }
  207. else {
  208. Sys.UI.DomEvent.removeHandler(fieldElement, 'input', this._onInputHandler);
  209. }
  210. Sys.UI.DomEvent.removeHandler(fieldElement, 'change', this._onChangeHandler);
  211. Sys.UI.DomEvent.removeHandler(fieldElement, 'blur', this._onBlurHandler);
  212. }
  213. },
  214. _displayError: function Sys_Mvc_FieldValidation$_displayError() {
  215. if (this._validationMessageElement) {
  216. if (this._replaceValidationMessageContents) {
  217. Sys.Mvc._validationUtil.setInnerText(this._validationMessageElement, this._errors[0]);
  218. }
  219. Sys.UI.DomElement.removeCssClass(this._validationMessageElement, Sys.Mvc.FieldValidation._validationMessageValidCss);
  220. Sys.UI.DomElement.addCssClass(this._validationMessageElement, Sys.Mvc.FieldValidation._validationMessageErrorCss);
  221. }
  222. for (var i = 0; i < this._fieldElements.length; i++) {
  223. var fieldElement = this._fieldElements[i];
  224. Sys.UI.DomElement.removeCssClass(fieldElement, Sys.Mvc.FieldValidation._inputElementValidCss);
  225. Sys.UI.DomElement.addCssClass(fieldElement, Sys.Mvc.FieldValidation._inputElementErrorCss);
  226. }
  227. },
  228. _displaySuccess: function Sys_Mvc_FieldValidation$_displaySuccess() {
  229. if (this._validationMessageElement) {
  230. if (this._replaceValidationMessageContents) {
  231. Sys.Mvc._validationUtil.setInnerText(this._validationMessageElement, '');
  232. }
  233. Sys.UI.DomElement.removeCssClass(this._validationMessageElement, Sys.Mvc.FieldValidation._validationMessageErrorCss);
  234. Sys.UI.DomElement.addCssClass(this._validationMessageElement, Sys.Mvc.FieldValidation._validationMessageValidCss);
  235. }
  236. for (var i = 0; i < this._fieldElements.length; i++) {
  237. var fieldElement = this._fieldElements[i];
  238. Sys.UI.DomElement.removeCssClass(fieldElement, Sys.Mvc.FieldValidation._inputElementErrorCss);
  239. Sys.UI.DomElement.addCssClass(fieldElement, Sys.Mvc.FieldValidation._inputElementValidCss);
  240. }
  241. },
  242. _element_OnInput: function Sys_Mvc_FieldValidation$_element_OnInput(e) {
  243. /// <param name="e" type="Sys.UI.DomEvent">
  244. /// </param>
  245. e.target[Sys.Mvc.FieldValidation._hasTextChangedTag] = true;
  246. if (e.target[Sys.Mvc.FieldValidation._hasValidationFiredTag]) {
  247. this.validate();
  248. }
  249. },
  250. _element_OnBlur: function Sys_Mvc_FieldValidation$_element_OnBlur(e) {
  251. /// <param name="e" type="Sys.UI.DomEvent">
  252. /// </param>
  253. if (e.target[Sys.Mvc.FieldValidation._hasTextChangedTag] || e.target[Sys.Mvc.FieldValidation._hasValidationFiredTag]) {
  254. this.validate();
  255. }
  256. },
  257. _element_OnChange: function Sys_Mvc_FieldValidation$_element_OnChange(e) {
  258. /// <param name="e" type="Sys.UI.DomEvent">
  259. /// </param>
  260. e.target[Sys.Mvc.FieldValidation._hasTextChangedTag] = true;
  261. },
  262. _element_OnPropertyChange: function Sys_Mvc_FieldValidation$_element_OnPropertyChange(e) {
  263. /// <param name="e" type="Sys.UI.DomEvent">
  264. /// </param>
  265. if (e.rawEvent.propertyName === 'value') {
  266. e.target[Sys.Mvc.FieldValidation._hasTextChangedTag] = true;
  267. if (e.target[Sys.Mvc.FieldValidation._hasValidationFiredTag]) {
  268. this.validate();
  269. }
  270. }
  271. },
  272. enableDynamicValidation: function Sys_Mvc_FieldValidation$enableDynamicValidation() {
  273. for (var i = 0; i < this._fieldElements.length; i++) {
  274. var fieldElement = this._fieldElements[i];
  275. if (Sys.Mvc._validationUtil.elementSupportsEvent(fieldElement, 'onpropertychange')) {
  276. Sys.UI.DomEvent.addHandler(fieldElement, 'propertychange', this._onPropertyChangeHandler);
  277. }
  278. else {
  279. Sys.UI.DomEvent.addHandler(fieldElement, 'input', this._onInputHandler);
  280. }
  281. Sys.UI.DomEvent.addHandler(fieldElement, 'change', this._onChangeHandler);
  282. Sys.UI.DomEvent.addHandler(fieldElement, 'blur', this._onBlurHandler);
  283. }
  284. },
  285. _getStringValue: function Sys_Mvc_FieldValidation$_getStringValue() {
  286. /// <returns type="String"></returns>
  287. return (this._fieldElements.length > 0) ? this._fieldElements[0].value : null;
  288. },
  289. _onErrorCountChanged: function Sys_Mvc_FieldValidation$_onErrorCountChanged() {
  290. if (!this._errors.length) {
  291. this._displaySuccess();
  292. }
  293. else {
  294. this._displayError();
  295. }
  296. },
  297. removeAllErrors: function Sys_Mvc_FieldValidation$removeAllErrors() {
  298. Array.clear(this._errors);
  299. this._onErrorCountChanged();
  300. },
  301. validate: function Sys_Mvc_FieldValidation$validate() {
  302. /// <returns type="Array" elementType="String"></returns>
  303. var allErrors = [];
  304. for (var i = 0; i < this._validators.length; i++) {
  305. var validator = this._validators[i];
  306. var thisErrors = validator.validate(this, this._fieldElements, this._getStringValue());
  307. if (thisErrors) {
  308. Array.addRange(allErrors, thisErrors);
  309. }
  310. }
  311. for (var i = 0; i < this._fieldElements.length; i++) {
  312. var fieldElement = this._fieldElements[i];
  313. fieldElement[Sys.Mvc.FieldValidation._hasValidationFiredTag] = true;
  314. }
  315. this.removeAllErrors();
  316. this.addErrors(allErrors);
  317. return allErrors;
  318. }
  319. }
  320. ////////////////////////////////////////////////////////////////////////////////
  321. // Sys.Mvc.FormValidation
  322. Sys.Mvc.FormValidation = function Sys_Mvc_FormValidation(formElement, validationSummaryElement) {
  323. /// <param name="formElement" type="Object" domElement="true">
  324. /// </param>
  325. /// <param name="validationSummaryElement" type="Object" domElement="true">
  326. /// </param>
  327. /// <field name="_validationSummaryErrorCss" type="String" static="true">
  328. /// </field>
  329. /// <field name="_validationSummaryValidCss" type="String" static="true">
  330. /// </field>
  331. /// <field name="_formValidationTag" type="String" static="true">
  332. /// </field>
  333. /// <field name="_onSubmitHandler" type="Sys.UI.DomEventHandler">
  334. /// </field>
  335. /// <field name="_errors" type="Array">
  336. /// </field>
  337. /// <field name="_fieldValidations" type="Array">
  338. /// </field>
  339. /// <field name="_formElement" type="Object" domElement="true">
  340. /// </field>
  341. /// <field name="_validationSummaryElement" type="Object" domElement="true">
  342. /// </field>
  343. /// <field name="_validationSummaryULElement" type="Object" domElement="true">
  344. /// </field>
  345. this._errors = [];
  346. this._fieldValidations = [];
  347. this._formElement = formElement;
  348. this._validationSummaryElement = validationSummaryElement;
  349. formElement[Sys.Mvc.FormValidation._formValidationTag] = this;
  350. if (validationSummaryElement) {
  351. var ulElements = validationSummaryElement.getElementsByTagName('ul');
  352. if (ulElements.length > 0) {
  353. this._validationSummaryULElement = ulElements[0];
  354. }
  355. }
  356. this._onSubmitHandler = Function.createDelegate(this, this._form_OnSubmit);
  357. }
  358. Sys.Mvc.FormValidation.enableClientValidation = function Sys_Mvc_FormValidation$enableClientValidation(options, userState) {
  359. /// <param name="options" type="Sys.Mvc.JsonValidationOptions">
  360. /// </param>
  361. /// <param name="userState" type="Object">
  362. /// </param>
  363. Sys.Application.add_load(Function.createDelegate(null, function(sender, e) {
  364. Sys.Mvc.FormValidation.parseJsonOptions(options);
  365. }));
  366. }
  367. Sys.Mvc.FormValidation._getFormElementsWithName = function Sys_Mvc_FormValidation$_getFormElementsWithName(formElement, name) {
  368. /// <param name="formElement" type="Object" domElement="true">
  369. /// </param>
  370. /// <param name="name" type="String">
  371. /// </param>
  372. /// <returns type="Array" elementType="Object" elementDomElement="true"></returns>
  373. var allElementsWithNameInForm = [];
  374. var allElementsWithName = document.getElementsByName(name);
  375. for (var i = 0; i < allElementsWithName.length; i++) {
  376. var thisElement = allElementsWithName[i];
  377. if (Sys.Mvc.FormValidation._isElementInHierarchy(formElement, thisElement)) {
  378. Array.add(allElementsWithNameInForm, thisElement);
  379. }
  380. }
  381. return allElementsWithNameInForm;
  382. }
  383. Sys.Mvc.FormValidation.getValidationForForm = function Sys_Mvc_FormValidation$getValidationForForm(formElement) {
  384. /// <param name="formElement" type="Object" domElement="true">
  385. /// </param>
  386. /// <returns type="Sys.Mvc.FormValidation"></returns>
  387. return formElement[Sys.Mvc.FormValidation._formValidationTag];
  388. }
  389. Sys.Mvc.FormValidation._isElementInHierarchy = function Sys_Mvc_FormValidation$_isElementInHierarchy(parent, child) {
  390. /// <param name="parent" type="Object" domElement="true">
  391. /// </param>
  392. /// <param name="child" type="Object" domElement="true">
  393. /// </param>
  394. /// <returns type="Boolean"></returns>
  395. while (child) {
  396. if (parent === child) {
  397. return true;
  398. }
  399. child = child.parentNode;
  400. }
  401. return false;
  402. }
  403. Sys.Mvc.FormValidation.parseJsonOptions = function Sys_Mvc_FormValidation$parseJsonOptions(options) {
  404. /// <param name="options" type="Sys.Mvc.JsonValidationOptions">
  405. /// </param>
  406. /// <returns type="Sys.Mvc.FormValidation"></returns>
  407. var formElement = $get(options.FormId);
  408. var validationSummaryElement = (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(options.ValidationSummaryId)) ? $get(options.ValidationSummaryId) : null;
  409. var formValidation = new Sys.Mvc.FormValidation(formElement, validationSummaryElement);
  410. formValidation.enableDynamicValidation();
  411. for (var i = 0; i < options.Fields.length; i++) {
  412. var field = options.Fields[i];
  413. var fieldElements = Sys.Mvc.FormValidation._getFormElementsWithName(formElement, field.FieldName);
  414. var validationMessageElement = (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(field.ValidationMessageId)) ? $get(field.ValidationMessageId) : null;
  415. var fieldValidation = new Sys.Mvc.FieldValidation(formValidation, fieldElements, validationMessageElement, field.ReplaceValidationMessageContents);
  416. for (var j = 0; j < field.ValidationRules.length; j++) {
  417. var rule = field.ValidationRules[j];
  418. var validator = Sys.Mvc.ValidatorRegistry.getValidator(rule);
  419. if (validator) {
  420. fieldValidation.addValidator(validator);
  421. }
  422. }
  423. fieldValidation.enableDynamicValidation();
  424. formValidation.addFieldValidation(fieldValidation);
  425. }
  426. return formValidation;
  427. }
  428. Sys.Mvc.FormValidation.prototype = {
  429. _onSubmitHandler: null,
  430. _formElement: null,
  431. _validationSummaryElement: null,
  432. _validationSummaryULElement: null,
  433. addError: function Sys_Mvc_FormValidation$addError(message) {
  434. /// <param name="message" type="String">
  435. /// </param>
  436. this.addErrors([ message ]);
  437. },
  438. addErrors: function Sys_Mvc_FormValidation$addErrors(messages) {
  439. /// <param name="messages" type="Array" elementType="String">
  440. /// </param>
  441. if (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(messages)) {
  442. Array.addRange(this._errors, messages);
  443. this._onErrorCountChanged();
  444. }
  445. },
  446. addFieldValidation: function Sys_Mvc_FormValidation$addFieldValidation(validation) {
  447. /// <param name="validation" type="Sys.Mvc.FieldValidation">
  448. /// </param>
  449. Array.add(this._fieldValidations, validation);
  450. },
  451. disableDynamicValidation: function Sys_Mvc_FormValidation$disableDynamicValidation() {
  452. Sys.UI.DomEvent.removeHandler(this._formElement, 'submit', this._onSubmitHandler);
  453. },
  454. _displayError: function Sys_Mvc_FormValidation$_displayError() {
  455. if (this._validationSummaryElement) {
  456. if (this._validationSummaryULElement) {
  457. Sys.Mvc._validationUtil.removeAllChildren(this._validationSummaryULElement);
  458. for (var i = 0; i < this._errors.length; i++) {
  459. var liElement = document.createElement('li');
  460. Sys.Mvc._validationUtil.setInnerText(liElement, this._errors[i]);
  461. this._validationSummaryULElement.appendChild(liElement);
  462. }
  463. }
  464. Sys.UI.DomElement.removeCssClass(this._validationSummaryElement, Sys.Mvc.FormValidation._validationSummaryValidCss);
  465. Sys.UI.DomElement.addCssClass(this._validationSummaryElement, Sys.Mvc.FormValidation._validationSummaryErrorCss);
  466. }
  467. },
  468. _displaySuccess: function Sys_Mvc_FormValidation$_displaySuccess() {
  469. if (this._validationSummaryElement) {
  470. if (this._validationSummaryULElement) {
  471. this._validationSummaryULElement.innerHTML = '';
  472. }
  473. Sys.UI.DomElement.removeCssClass(this._validationSummaryElement, Sys.Mvc.FormValidation._validationSummaryErrorCss);
  474. Sys.UI.DomElement.addCssClass(this._validationSummaryElement, Sys.Mvc.FormValidation._validationSummaryValidCss);
  475. }
  476. },
  477. enableDynamicValidation: function Sys_Mvc_FormValidation$enableDynamicValidation() {
  478. Sys.UI.DomEvent.addHandler(this._formElement, 'submit', this._onSubmitHandler);
  479. },
  480. _form_OnSubmit: function Sys_Mvc_FormValidation$_form_OnSubmit(e) {
  481. /// <param name="e" type="Sys.UI.DomEvent">
  482. /// </param>
  483. var form = e.target;
  484. var errorMessages = this.validate(true);
  485. if (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(errorMessages)) {
  486. e.preventDefault();
  487. }
  488. },
  489. _onErrorCountChanged: function Sys_Mvc_FormValidation$_onErrorCountChanged() {
  490. if (!this._errors.length) {
  491. this._displaySuccess();
  492. }
  493. else {
  494. this._displayError();
  495. }
  496. },
  497. removeAllErrors: function Sys_Mvc_FormValidation$removeAllErrors() {
  498. Array.clear(this._errors);
  499. this._onErrorCountChanged();
  500. },
  501. validate: function Sys_Mvc_FormValidation$validate(replaceValidationSummary) {
  502. /// <param name="replaceValidationSummary" type="Boolean">
  503. /// </param>
  504. /// <returns type="Array" elementType="String"></returns>
  505. var allErrors = [];
  506. for (var i = 0; i < this._fieldValidations.length; i++) {
  507. var validation = this._fieldValidations[i];
  508. var thisErrors = validation.validate();
  509. if (thisErrors) {
  510. Array.addRange(allErrors, thisErrors);
  511. }
  512. }
  513. if (replaceValidationSummary) {
  514. this.removeAllErrors();
  515. this.addErrors(allErrors);
  516. }
  517. return allErrors;
  518. }
  519. }
  520. ////////////////////////////////////////////////////////////////////////////////
  521. // Sys.Mvc.MvcHelpers
  522. Sys.Mvc.MvcHelpers = function Sys_Mvc_MvcHelpers() {
  523. }
  524. Sys.Mvc.MvcHelpers._serializeSubmitButton = function Sys_Mvc_MvcHelpers$_serializeSubmitButton(element, offsetX, offsetY) {
  525. /// <param name="element" type="Object" domElement="true">
  526. /// </param>
  527. /// <param name="offsetX" type="Number" integer="true">
  528. /// </param>
  529. /// <param name="offsetY" type="Number" integer="true">
  530. /// </param>
  531. /// <returns type="String"></returns>
  532. if (element.disabled) {
  533. return null;
  534. }
  535. var name = element.name;
  536. if (name) {
  537. var tagName = element.tagName.toUpperCase();
  538. var encodedName = encodeURIComponent(name);
  539. var inputElement = element;
  540. if (tagName === 'INPUT') {
  541. var type = inputElement.type;
  542. if (type === 'submit') {
  543. return encodedName + '=' + encodeURIComponent(inputElement.value);
  544. }
  545. else if (type === 'image') {
  546. return encodedName + '.x=' + offsetX + '&' + encodedName + '.y=' + offsetY;
  547. }
  548. }
  549. else if ((tagName === 'BUTTON') && (name.length) && (inputElement.type === 'submit')) {
  550. return encodedName + '=' + encodeURIComponent(inputElement.value);
  551. }
  552. }
  553. return null;
  554. }
  555. Sys.Mvc.MvcHelpers._serializeForm = function Sys_Mvc_MvcHelpers$_serializeForm(form) {
  556. /// <param name="form" type="Object" domElement="true">
  557. /// </param>
  558. /// <returns type="String"></returns>
  559. var formElements = form.elements;
  560. var formBody = new Sys.StringBuilder();
  561. var count = formElements.length;
  562. for (var i = 0; i < count; i++) {
  563. var element = formElements[i];
  564. var name = element.name;
  565. if (!name || !name.length) {
  566. continue;
  567. }
  568. var tagName = element.tagName.toUpperCase();
  569. if (tagName === 'INPUT') {
  570. var inputElement = element;
  571. var type = inputElement.type;
  572. if ((type === 'text') || (type === 'password') || (type === 'hidden') || (((type === 'checkbox') || (type === 'radio')) && element.checked)) {
  573. formBody.append(encodeURIComponent(name));
  574. formBody.append('=');
  575. formBody.append(encodeURIComponent(inputElement.value));
  576. formBody.append('&');
  577. }
  578. }
  579. else if (tagName === 'SELECT') {
  580. var selectElement = element;
  581. var optionCount = selectElement.options.length;
  582. for (var j = 0; j < optionCount; j++) {
  583. var optionElement = selectElement.options[j];
  584. if (optionElement.selected) {
  585. formBody.append(encodeURIComponent(name));
  586. formBody.append('=');
  587. formBody.append(encodeURIComponent(optionElement.value));
  588. formBody.append('&');
  589. }
  590. }
  591. }
  592. else if (tagName === 'TEXTAREA') {
  593. formBody.append(encodeURIComponent(name));
  594. formBody.append('=');
  595. formBody.append(encodeURIComponent((element.value)));
  596. formBody.append('&');
  597. }
  598. }
  599. var additionalInput = form._additionalInput;
  600. if (additionalInput) {
  601. formBody.append(additionalInput);
  602. formBody.append('&');
  603. }
  604. return formBody.toString();
  605. }
  606. Sys.Mvc.MvcHelpers._asyncRequest = function Sys_Mvc_MvcHelpers$_asyncRequest(url, verb, body, triggerElement, ajaxOptions) {
  607. /// <param name="url" type="String">
  608. /// </param>
  609. /// <param name="verb" type="String">
  610. /// </param>
  611. /// <param name="body" type="String">
  612. /// </param>
  613. /// <param name="triggerElement" type="Object" domElement="true">
  614. /// </param>
  615. /// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
  616. /// </param>
  617. if (ajaxOptions.confirm) {
  618. if (!confirm(ajaxOptions.confirm)) {
  619. return;
  620. }
  621. }
  622. if (ajaxOptions.url) {
  623. url = ajaxOptions.url;
  624. }
  625. if (ajaxOptions.httpMethod) {
  626. verb = ajaxOptions.httpMethod;
  627. }
  628. if (body.length > 0 && !body.endsWith('&')) {
  629. body += '&';
  630. }
  631. body += 'X-Requested-With=XMLHttpRequest';
  632. var upperCaseVerb = verb.toUpperCase();
  633. var isGetOrPost = (upperCaseVerb === 'GET' || upperCaseVerb === 'POST');
  634. if (!isGetOrPost) {
  635. body += '&';
  636. body += 'X-HTTP-Method-Override=' + upperCaseVerb;
  637. }
  638. var requestBody = '';
  639. if (upperCaseVerb === 'GET' || upperCaseVerb === 'DELETE') {
  640. if (url.indexOf('?') > -1) {
  641. if (!url.endsWith('&')) {
  642. url += '&';
  643. }
  644. url += body;
  645. }
  646. else {
  647. url += '?';
  648. url += body;
  649. }
  650. }
  651. else {
  652. requestBody = body;
  653. }
  654. var request = new Sys.Net.WebRequest();
  655. request.set_url(url);
  656. if (isGetOrPost) {
  657. request.set_httpVerb(verb);
  658. }
  659. else {
  660. request.set_httpVerb('POST');
  661. request.get_headers()['X-HTTP-Method-Override'] = upperCaseVerb;
  662. }
  663. request.set_body(requestBody);
  664. if (verb.toUpperCase() === 'PUT') {
  665. request.get_headers()['Content-Type'] = 'application/x-www-form-urlencoded;';
  666. }
  667. request.get_headers()['X-Requested-With'] = 'XMLHttpRequest';
  668. var updateElement = null;
  669. if (ajaxOptions.updateTargetId) {
  670. updateElement = $get(ajaxOptions.updateTargetId);
  671. }
  672. var loadingElement = null;
  673. if (ajaxOptions.loadingElementId) {
  674. loadingElement = $get(ajaxOptions.loadingElementId);
  675. }
  676. var ajaxContext = new Sys.Mvc.AjaxContext(request, updateElement, loadingElement, ajaxOptions.insertionMode);
  677. var continueRequest = true;
  678. if (ajaxOptions.onBegin) {
  679. continueRequest = ajaxOptions.onBegin(ajaxContext) !== false;
  680. }
  681. if (loadingElement) {
  682. Sys.UI.DomElement.setVisible(ajaxContext.get_loadingElement(), true);
  683. }
  684. if (continueRequest) {
  685. request.add_completed(Function.createDelegate(null, function(executor) {
  686. Sys.Mvc.MvcHelpers._onComplete(request, ajaxOptions, ajaxContext);
  687. }));
  688. request.invoke();
  689. }
  690. }
  691. Sys.Mvc.MvcHelpers._onComplete = function Sys_Mvc_MvcHelpers$_onComplete(request, ajaxOptions, ajaxContext) {
  692. /// <param name="request" type="Sys.Net.WebRequest">
  693. /// </param>
  694. /// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
  695. /// </param>
  696. /// <param name="ajaxContext" type="Sys.Mvc.AjaxContext">
  697. /// </param>
  698. ajaxContext.set_response(request.get_executor());
  699. if (ajaxOptions.onComplete && ajaxOptions.onComplete(ajaxContext) === false) {
  700. return;
  701. }
  702. var statusCode = ajaxContext.get_response().get_statusCode();
  703. if ((statusCode >= 200 && statusCode < 300) || statusCode === 304 || statusCode === 1223) {
  704. if (statusCode !== 204 && statusCode !== 304 && statusCode !== 1223) {
  705. var contentType = ajaxContext.get_response().getResponseHeader('Content-Type');
  706. if ((contentType) && (contentType.indexOf('application/x-javascript') !== -1)) {
  707. eval(ajaxContext.get_data());
  708. }
  709. else {
  710. Sys.Mvc.MvcHelpers.updateDomElement(ajaxContext.get_updateTarget(), ajaxContext.get_insertionMode(), ajaxContext.get_data());
  711. }
  712. }
  713. if (ajaxOptions.onSuccess) {
  714. ajaxOptions.onSuccess(ajaxContext);
  715. }
  716. }
  717. else {
  718. if (ajaxOptions.onFailure) {
  719. ajaxOptions.onFailure(ajaxContext);
  720. }
  721. }
  722. if (ajaxContext.get_loadingElement()) {
  723. Sys.UI.DomElement.setVisible(ajaxContext.get_loadingElement(), false);
  724. }
  725. }
  726. Sys.Mvc.MvcHelpers.updateDomElement = function Sys_Mvc_MvcHelpers$updateDomElement(target, insertionMode, content) {
  727. /// <param name="target" type="Object" domElement="true">
  728. /// </param>
  729. /// <param name="insertionMode" type="Sys.Mvc.InsertionMode">
  730. /// </param>
  731. /// <param name="content" type="String">
  732. /// </param>
  733. if (target) {
  734. switch (insertionMode) {
  735. case Sys.Mvc.InsertionMode.replace:
  736. target.innerHTML = content;
  737. break;
  738. case Sys.Mvc.InsertionMode.insertBefore:
  739. if (content && content.length > 0) {
  740. target.innerHTML = content + target.innerHTML.trimStart();
  741. }
  742. break;
  743. case Sys.Mvc.InsertionMode.insertAfter:
  744. if (content && content.length > 0) {
  745. target.innerHTML = target.innerHTML.trimEnd() + content;
  746. }
  747. break;
  748. }
  749. }
  750. }
  751. ////////////////////////////////////////////////////////////////////////////////
  752. // Sys.Mvc.AsyncForm
  753. Sys.Mvc.AsyncForm = function Sys_Mvc_AsyncForm() {
  754. }
  755. Sys.Mvc.AsyncForm.handleClick = function Sys_Mvc_AsyncForm$handleClick(form, evt) {
  756. /// <param name="form" type="Object" domElement="true">
  757. /// </param>
  758. /// <param name="evt" type="Sys.UI.DomEvent">
  759. /// </param>
  760. var additionalInput = Sys.Mvc.MvcHelpers._serializeSubmitButton(evt.target, evt.offsetX, evt.offsetY);
  761. form._additionalInput = additionalInput;
  762. }
  763. Sys.Mvc.AsyncForm.handleSubmit = function Sys_Mvc_AsyncForm$handleSubmit(form, evt, ajaxOptions) {
  764. /// <param name="form" type="Object" domElement="true">
  765. /// </param>
  766. /// <param name="evt" type="Sys.UI.DomEvent">
  767. /// </param>
  768. /// <param name="ajaxOptions" type="Sys.Mvc.AjaxOptions">
  769. /// </param>
  770. evt.preventDefault();
  771. var body = Sys.Mvc.MvcHelpers._serializeForm(form);
  772. Sys.Mvc.MvcHelpers._asyncRequest(form.action, form.method || 'post', body, form, ajaxOptions);
  773. }
  774. ////////////////////////////////////////////////////////////////////////////////
  775. // Sys.Mvc.RangeValidator
  776. Sys.Mvc.RangeValidator = function Sys_Mvc_RangeValidator(errorMessage, minimum, maximum) {
  777. /// <param name="errorMessage" type="String">
  778. /// </param>
  779. /// <param name="minimum" type="Number">
  780. /// </param>
  781. /// <param name="maximum" type="Number">
  782. /// </param>
  783. /// <field name="_errorMessage$1" type="String">
  784. /// </field>
  785. /// <field name="_minimum$1" type="Number">
  786. /// </field>
  787. /// <field name="_maximum$1" type="Number">
  788. /// </field>
  789. Sys.Mvc.RangeValidator.initializeBase(this);
  790. this._errorMessage$1 = errorMessage;
  791. this._minimum$1 = minimum;
  792. this._maximum$1 = maximum;
  793. }
  794. Sys.Mvc.RangeValidator._create = function Sys_Mvc_RangeValidator$_create(rule) {
  795. /// <param name="rule" type="Sys.Mvc.JsonValidationRule">
  796. /// </param>
  797. /// <returns type="Sys.Mvc.RangeValidator"></returns>
  798. var min = rule.ValidationParameters['minimum'];
  799. var max = rule.ValidationParameters['maximum'];
  800. return new Sys.Mvc.RangeValidator(rule.ErrorMessage, min, max);
  801. }
  802. Sys.Mvc.RangeValidator.prototype = {
  803. _errorMessage$1: null,
  804. _minimum$1: null,
  805. _maximum$1: null,
  806. validate: function Sys_Mvc_RangeValidator$validate(validation, elements, value) {
  807. /// <param name="validation" type="Sys.Mvc.FieldValidation">
  808. /// </param>
  809. /// <param name="elements" type="Array" elementType="Object" elementDomElement="true">
  810. /// </param>
  811. /// <param name="value" type="String">
  812. /// </param>
  813. /// <returns type="Array" elementType="String"></returns>
  814. if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) {
  815. return null;
  816. }
  817. var n = Number.parseLocale(value);
  818. return (isNaN(n) || n < this._minimum$1 || n > this._maximum$1) ? [ this._errorMessage$1 ] : null;
  819. }
  820. }
  821. ////////////////////////////////////////////////////////////////////////////////
  822. // Sys.Mvc.RegularExpressionValidator
  823. Sys.Mvc.RegularExpressionValidator = function Sys_Mvc_RegularExpressionValidator(errorMessage, pattern) {
  824. /// <param name="errorMessage" type="String">
  825. /// </param>
  826. /// <param name="pattern" type="String">
  827. /// </param>
  828. /// <field name="_errorMessage$1" type="String">
  829. /// </field>
  830. /// <field name="_pattern$1" type="String">
  831. /// </field>
  832. Sys.Mvc.RegularExpressionValidator.initializeBase(this);
  833. this._errorMessage$1 = errorMessage;
  834. this._pattern$1 = pattern;
  835. }
  836. Sys.Mvc.RegularExpressionValidator._create = function Sys_Mvc_RegularExpressionValidator$_create(rule) {
  837. /// <param name="rule" type="Sys.Mvc.JsonValidationRule">
  838. /// </param>
  839. /// <returns type="Sys.Mvc.RegularExpressionValidator"></returns>
  840. var pattern = rule.ValidationParameters['pattern'];
  841. return new Sys.Mvc.RegularExpressionValidator(rule.ErrorMessage, pattern);
  842. }
  843. Sys.Mvc.RegularExpressionValidator.prototype = {
  844. _errorMessage$1: null,
  845. _pattern$1: null,
  846. validate: function Sys_Mvc_RegularExpressionValidator$validate(validation, elements, value) {
  847. /// <param name="validation" type="Sys.Mvc.FieldValidation">
  848. /// </param>
  849. /// <param name="elements" type="Array" elementType="Object" elementDomElement="true">
  850. /// </param>
  851. /// <param name="value" type="String">
  852. /// </param>
  853. /// <returns type="Array" elementType="String"></returns>
  854. if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) {
  855. return null;
  856. }
  857. var regExp = new RegExp(this._pattern$1);
  858. var matches = regExp.exec(value);
  859. return (!Sys.Mvc._validationUtil.arrayIsNullOrEmpty(matches) && matches[0].length === value.length) ? null : [ this._errorMessage$1 ];
  860. }
  861. }
  862. ////////////////////////////////////////////////////////////////////////////////
  863. // Sys.Mvc.RequiredValidator
  864. Sys.Mvc.RequiredValidator = function Sys_Mvc_RequiredValidator(errorMessage) {
  865. /// <param name="errorMessage" type="String">
  866. /// </param>
  867. /// <field name="_errorMessage$1" type="String">
  868. /// </field>
  869. Sys.Mvc.RequiredValidator.initializeBase(this);
  870. this._errorMessage$1 = errorMessage;
  871. }
  872. Sys.Mvc.RequiredValidator._create = function Sys_Mvc_RequiredValidator$_create(rule) {
  873. /// <param name="rule" type="Sys.Mvc.JsonValidationRule">
  874. /// </param>
  875. /// <returns type="Sys.Mvc.RequiredValidator"></returns>
  876. return new Sys.Mvc.RequiredValidator(rule.ErrorMessage);
  877. }
  878. Sys.Mvc.RequiredValidator._isRadioInputElement$1 = function Sys_Mvc_RequiredValidator$_isRadioInputElement$1(element) {
  879. /// <param name="element" type="Object" domElement="true">
  880. /// </param>
  881. /// <returns type="Boolean"></returns>
  882. if (element.tagName.toUpperCase() === 'INPUT') {
  883. var inputType = (element.type).toUpperCase();
  884. if (inputType === 'RADIO') {
  885. return true;
  886. }
  887. }
  888. return false;
  889. }
  890. Sys.Mvc.RequiredValidator._isSelectInputElement$1 = function Sys_Mvc_RequiredValidator$_isSelectInputElement$1(element) {
  891. /// <param name="element" type="Object" domElement="true">
  892. /// </param>
  893. /// <returns type="Boolean"></returns>
  894. if (element.tagName.toUpperCase() === 'SELECT') {
  895. return true;
  896. }
  897. return false;
  898. }
  899. Sys.Mvc.RequiredValidator._isTextualInputElement$1 = function Sys_Mvc_RequiredValidator$_isTextualInputElement$1(element) {
  900. /// <param name="element" type="Object" domElement="true">
  901. /// </param>
  902. /// <returns type="Boolean"></returns>
  903. if (element.tagName.toUpperCase() === 'INPUT') {
  904. var inputType = (element.type).toUpperCase();
  905. switch (inputType) {
  906. case 'TEXT':
  907. case 'PASSWORD':
  908. case 'FILE':
  909. return true;
  910. }
  911. }
  912. if (element.tagName.toUpperCase() === 'TEXTAREA') {
  913. return true;
  914. }
  915. return false;
  916. }
  917. Sys.Mvc.RequiredValidator.prototype = {
  918. _errorMessage$1: null,
  919. validate: function Sys_Mvc_RequiredValidator$validate(validation, elements, value) {
  920. /// <param name="validation" type="Sys.Mvc.FieldValidation">
  921. /// </param>
  922. /// <param name="elements" type="Array" elementType="Object" elementDomElement="true">
  923. /// </param>
  924. /// <param name="value" type="String">
  925. /// </param>
  926. /// <returns type="Array" elementType="String"></returns>
  927. if (!elements.length) {
  928. return null;
  929. }
  930. var sampleElement = elements[0];
  931. if (Sys.Mvc.RequiredValidator._isTextualInputElement$1(sampleElement)) {
  932. return this._validateTextualInput$1(sampleElement);
  933. }
  934. if (Sys.Mvc.RequiredValidator._isRadioInputElement$1(sampleElement)) {
  935. return this._validateRadioInput$1(elements);
  936. }
  937. if (Sys.Mvc.RequiredValidator._isSelectInputElement$1(sampleElement)) {
  938. return this._validateSelectInput$1((sampleElement).options);
  939. }
  940. return null;
  941. },
  942. _validateRadioInput$1: function Sys_Mvc_RequiredValidator$_validateRadioInput$1(elements) {
  943. /// <param name="elements" type="Array" elementType="Object" elementDomElement="true">
  944. /// </param>
  945. /// <returns type="Array" elementType="String"></returns>
  946. for (var i = 0; i < elements.length; i++) {
  947. var element = elements[i];
  948. if (element.checked) {
  949. return null;
  950. }
  951. }
  952. return [ this._errorMessage$1 ];
  953. },
  954. _validateSelectInput$1: function Sys_Mvc_RequiredValidator$_validateSelectInput$1(optionElements) {
  955. /// <param name="optionElements" type="DOMElementCollection">
  956. /// </param>
  957. /// <returns type="Array" elementType="String"></returns>
  958. for (var i = 0; i < optionElements.length; i++) {
  959. var element = optionElements[i];
  960. if (element.selected) {
  961. if (!Sys.Mvc._validationUtil.stringIsNullOrEmpty(element.value)) {
  962. return null;
  963. }
  964. }
  965. }
  966. return [ this._errorMessage$1 ];
  967. },
  968. _validateTextualInput$1: function Sys_Mvc_RequiredValidator$_validateTextualInput$1(element) {
  969. /// <param name="element" type="Object" domElement="true">
  970. /// </param>
  971. /// <returns type="Array" elementType="String"></returns>
  972. return (Sys.Mvc._validationUtil.stringIsNullOrEmpty(element.value)) ? [ this._errorMessage$1 ] : null;
  973. }
  974. }
  975. ////////////////////////////////////////////////////////////////////////////////
  976. // Sys.Mvc.StringLengthValidator
  977. Sys.Mvc.StringLengthValidator = function Sys_Mvc_StringLengthValidator(errorMessage, minLength, maxLength) {
  978. /// <param name="errorMessage" type="String">
  979. /// </param>
  980. /// <param name="minLength" type="Number" integer="true">
  981. /// </param>
  982. /// <param name="maxLength" type="Number" integer="true">
  983. /// </param>
  984. /// <field name="_errorMessage$1" type="String">
  985. /// </field>
  986. /// <field name="_maxLength$1" type="Number" integer="true">
  987. /// </field>
  988. /// <field name="_minLength$1" type="Number" integer="true">
  989. /// </field>
  990. Sys.Mvc.StringLengthValidator.initializeBase(this);
  991. this._errorMessage$1 = errorMessage;
  992. this._minLength$1 = minLength;
  993. this._maxLength$1 = maxLength;
  994. }
  995. Sys.Mvc.StringLengthValidator._create = function Sys_Mvc_StringLengthValidator$_create(rule) {
  996. /// <param name="rule" type="Sys.Mvc.JsonValidationRule">
  997. /// </param>
  998. /// <returns type="Sys.Mvc.StringLengthValidator"></returns>
  999. var minLength = rule.ValidationParameters['minimumLength'];
  1000. var maxLength = rule.ValidationParameters['maximumLength'];
  1001. return new Sys.Mvc.StringLengthValidator(rule.ErrorMessage, minLength, maxLength);
  1002. }
  1003. Sys.Mvc.StringLengthValidator.prototype = {
  1004. _errorMessage$1: null,
  1005. _maxLength$1: 0,
  1006. _minLength$1: 0,
  1007. validate: function Sys_Mvc_StringLengthValidator$validate(validation, elements, value) {
  1008. /// <param name="validation" type="Sys.Mvc.FieldValidation">
  1009. /// </param>
  1010. /// <param name="elements" type="Array" elementType="Object" elementDomElement="true">
  1011. /// </param>
  1012. /// <param name="value" type="String">
  1013. /// </param>
  1014. /// <returns type="Array" elementType="String"></returns>
  1015. if (Sys.Mvc._validationUtil.stringIsNullOrEmpty(value)) {
  1016. return null;
  1017. }
  1018. return (this._minLength$1 <= value.length && value.length <= this._maxLength$1) ? null : [ this._errorMessage$1 ];
  1019. }
  1020. }
  1021. ////////////////////////////////////////////////////////////////////////////////
  1022. // Sys.Mvc._validationUtil
  1023. Sys.Mvc._validationUtil = function Sys_Mvc__validationUtil() {
  1024. }
  1025. Sys.Mvc._validationUtil.arrayIsNullOrEmpty = function Sys_Mvc__validationUtil$arrayIsNullOrEmpty(array) {
  1026. /// <param name="array" type="Array" elementType="Object">
  1027. /// </param>
  1028. /// <returns type="Boolean"></returns>
  1029. return (!array || !array.length);
  1030. }
  1031. Sys.Mvc._validationUtil.stringIsNullOrEmpty = function Sys_Mvc__validationUtil$stringIsNullOrEmpty(value) {
  1032. /// <param name="value" type="String">
  1033. /// </param>
  1034. /// <returns type="Boolean"></returns>
  1035. return (!value || !value.length);
  1036. }
  1037. Sys.Mvc._validationUtil.elementSupportsEvent = function Sys_Mvc__validationUtil$elementSupportsEvent(element, eventAttributeName) {
  1038. /// <param name="element" type="Object" domElement="true">
  1039. /// </param>
  1040. /// <param name="eventAttributeName" type="String">
  1041. /// </param>
  1042. /// <returns type="Boolean"></returns>
  1043. return (eventAttributeName in element);
  1044. }
  1045. Sys.Mvc._validationUtil.removeAllChildren = function Sys_Mvc__validationUtil$removeAllChildren(element) {
  1046. /// <param name="element" type="Object" domElement="true">
  1047. /// </param>
  1048. while (element.firstChild) {
  1049. element.removeChild(element.firstChild);
  1050. }
  1051. }
  1052. Sys.Mvc._validationUtil.setInnerText = function Sys_Mvc__validationUtil$setInnerText(element, innerText) {
  1053. /// <param name="element" type="Object" domElement="true">
  1054. /// </param>
  1055. /// <param name="innerText" type="String">
  1056. /// </param>
  1057. var textNode = document.createTextNode(innerText);
  1058. Sys.Mvc._validationUtil.removeAllChildren(element);
  1059. element.appendChild(textNode);
  1060. }
  1061. ////////////////////////////////////////////////////////////////////////////////
  1062. // Sys.Mvc.Validator
  1063. Sys.Mvc.Validator = function Sys_Mvc_Validator() {
  1064. }
  1065. ////////////////////////////////////////////////////////////////////////////////
  1066. // Sys.Mvc.ValidatorRegistry
  1067. Sys.Mvc.ValidatorRegistry = function Sys_Mvc_ValidatorRegistry() {
  1068. /// <field name="_validators" type="Object" static="true">
  1069. /// </field>
  1070. }
  1071. Sys.Mvc.ValidatorRegistry.get_creators = function Sys_Mvc_ValidatorRegistry$get_creators() {
  1072. /// <value type="Object"></value>
  1073. return Sys.Mvc.ValidatorRegistry._validators;
  1074. }
  1075. Sys.Mvc.ValidatorRegistry.getValidator = function Sys_Mvc_ValidatorRegistry$getValidator(rule) {
  1076. /// <param name="rule" type="Sys.Mvc.JsonValidationRule">
  1077. /// </param>
  1078. /// <returns type="Sys.Mvc.Validator"></returns>
  1079. var creator = Sys.Mvc.ValidatorRegistry._validators[rule.ValidationType];
  1080. return (creator) ? creator(rule) : null;
  1081. }
  1082. Sys.Mvc.ValidatorRegistry._getDefaultValidators = function Sys_Mvc_ValidatorRegistry$_getDefaultValidators() {
  1083. /// <returns type="Object"></returns>
  1084. return { required: Function.createDelegate(null, Sys.Mvc.RequiredValidator._create), stringLength: Function.createDelegate(null, Sys.Mvc.StringLengthValidator._create), regularExpression: Function.createDelegate(null, Sys.Mvc.RegularExpressionValidator._create), range: Function.createDelegate(null, Sys.Mvc.RangeValidator._create) };
  1085. }
  1086. Sys.Mvc.AjaxContext.registerClass('Sys.Mvc.AjaxContext');
  1087. Sys.Mvc.AsyncHyperlink.registerClass('Sys.Mvc.AsyncHyperlink');
  1088. Sys.Mvc.FieldValidation.registerClass('Sys.Mvc.FieldValidation');
  1089. Sys.Mvc.FormValidation.registerClass('Sys.Mvc.FormValidation');
  1090. Sys.Mvc.MvcHelpers.registerClass('Sys.Mvc.MvcHelpers');
  1091. Sys.Mvc.AsyncForm.registerClass('Sys.Mvc.AsyncForm');
  1092. Sys.Mvc.Validator.registerClass('Sys.Mvc.Validator');
  1093. Sys.Mvc.RangeValidator.registerClass('Sys.Mvc.RangeValidator', Sys.Mvc.Validator);
  1094. Sys.Mvc.RegularExpressionValidator.registerClass('Sys.Mvc.RegularExpressionValidator', Sys.Mvc.Validator);
  1095. Sys.Mvc.RequiredValidator.registerClass('Sys.Mvc.RequiredValidator', Sys.Mvc.Validator);
  1096. Sys.Mvc.StringLengthValidator.registerClass('Sys.Mvc.StringLengthValidator', Sys.Mvc.Validator);
  1097. Sys.Mvc._validationUtil.registerClass('Sys.Mvc._validationUtil');
  1098. Sys.Mvc.ValidatorRegistry.registerClass('Sys.Mvc.ValidatorRegistry');
  1099. Sys.Mvc.FieldValidation._hasTextChangedTag = '__MVC_HasTextChanged';
  1100. Sys.Mvc.FieldValidation._hasValidationFiredTag = '__MVC_HasValidationFired';
  1101. Sys.Mvc.FieldValidation._inputElementErrorCss = 'input-validation-error';
  1102. Sys.Mvc.FieldValidation._inputElementValidCss = 'input-validation-valid';
  1103. Sys.Mvc.FieldValidation._validationMessageErrorCss = 'field-validation-error';
  1104. Sys.Mvc.FieldValidation._validationMessageValidCss = 'field-validation-valid';
  1105. Sys.Mvc.FormValidation._validationSummaryErrorCss = 'validation-summary-errors';
  1106. Sys.Mvc.FormValidation._validationSummaryValidCss = 'validation-summary-valid';
  1107. Sys.Mvc.FormValidation._formValidationTag = '__MVC_FormValidation';
  1108. Sys.Mvc.ValidatorRegistry._validators = Sys.Mvc.ValidatorRegistry._getDefaultValidators();
  1109. // ---- Do not remove this footer ----
  1110. // Generated using Script# v0.5.0.0 (http://projects.nikhilk.net)
  1111. // -----------------------------------