| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- /**
- * DevExtreme (aspnet.js)
- * Version: 19.1.16
- * Build date: Tue Oct 18 2022
- *
- * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
- * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
- */
- "use strict";
- ! function(factory) {
- if ("function" === typeof define && define.amd) {
- define(function(require, exports, module) {
- module.exports = factory(require("jquery"), require("./ui/set_template_engine"), require("./ui/widget/ui.template_base").renderedCallbacks, require("./core/guid"), require("./ui/validation_engine"), require("./core/utils/iterator"), require("./core/utils/dom").extractTemplateMarkup, require("./core/utils/string").encodeHtml)
- })
- } else {
- var ui = DevExpress.ui;
- DevExpress.aspnet = factory(window.jQuery, ui && ui.setTemplateEngine, ui && ui.templateRendered, DevExpress.data.Guid, DevExpress.validationEngine, DevExpress.utils.iterator, DevExpress.utils.dom.extractTemplateMarkup, DevExpress.utils.string.encodeHtml)
- }
- }(function($, _setTemplateEngine, templateRendered, Guid, validationEngine, iteratorUtils, extractTemplateMarkup, encodeHtml) {
- var templateCompiler = createTemplateCompiler();
- var pendingCreateComponentRoutines = [];
- var _enableAlternativeTemplateTags = true;
- function createTemplateCompiler() {
- var OPEN_TAG = "<%",
- CLOSE_TAG = "%>",
- ENCODE_QUALIFIER = "-",
- INTERPOLATE_QUALIFIER = "=";
- var EXTENDED_OPEN_TAG = /[<[]%/g,
- EXTENDED_CLOSE_TAG = /%[>\]]/g;
- function acceptText(bag, text) {
- if (text) {
- bag.push("_.push(", JSON.stringify(text), ");")
- }
- }
- function acceptCode(bag, code) {
- var encode = code.charAt(0) === ENCODE_QUALIFIER,
- value = code.substr(1),
- interpolate = code.charAt(0) === INTERPOLATE_QUALIFIER;
- if (encode || interpolate) {
- bag.push("_.push(");
- bag.push(encode ? "arguments[1](" + value + ")" : value);
- bag.push(");")
- } else {
- bag.push(code + "\n")
- }
- }
- return function(text) {
- var bag = ["var _ = [];", "with(obj||{}) {"],
- chunks = text.split(_enableAlternativeTemplateTags ? EXTENDED_OPEN_TAG : OPEN_TAG);
- acceptText(bag, chunks.shift());
- for (var i = 0; i < chunks.length; i++) {
- var tmp = chunks[i].split(_enableAlternativeTemplateTags ? EXTENDED_CLOSE_TAG : CLOSE_TAG);
- if (2 !== tmp.length) {
- throw "Template syntax error"
- }
- acceptCode(bag, tmp[0]);
- acceptText(bag, tmp[1])
- }
- bag.push("}", "return _.join('')");
- return new Function("obj", bag.join(""))
- }
- }
- function createTemplateEngine() {
- return {
- compile: function(element) {
- return templateCompiler(extractTemplateMarkup(element))
- },
- render: function(template, data) {
- var html = template(data, encodeHtml);
- var dxMvcExtensionsObj = window.MVCx;
- if (dxMvcExtensionsObj && !dxMvcExtensionsObj.isDXScriptInitializedOnLoad) {
- html = html.replace(/(<script[^>]+)id="dxss_.+?"/g, "$1")
- }
- return html
- }
- }
- }
- function getValidationSummary(validationGroup) {
- var result;
- $(".dx-validationsummary").each(function(_, element) {
- var summary = $(element).data("dxValidationSummary");
- if (summary && summary.option("validationGroup") === validationGroup) {
- result = summary;
- return false
- }
- });
- return result
- }
- function createValidationSummaryItemsFromValidators(validators, editorNames) {
- var items = [];
- iteratorUtils.each(validators, function(_, validator) {
- var widget = validator.$element().data("dx-validation-target");
- if (widget && $.inArray(widget.option("name"), editorNames) > -1) {
- items.push({
- text: widget.option("validationError.message"),
- validator: validator
- })
- }
- });
- return items
- }
- function createComponent(name, options, id, validatorOptions) {
- var selector = "#" + String(id).replace(/[^\w-]/g, "\\$&");
- pendingCreateComponentRoutines.push(function() {
- var $element = $(selector);
- if ($element.length) {
- var $component = $(selector)[name](options);
- if ($.isPlainObject(validatorOptions)) {
- $component.dxValidator(validatorOptions)
- }
- return true
- }
- return false
- })
- }
- templateRendered.add(function() {
- var snapshot = pendingCreateComponentRoutines.slice();
- var leftover = [];
- pendingCreateComponentRoutines = [];
- snapshot.forEach(function(func) {
- if (!func()) {
- leftover.push(func)
- }
- });
- pendingCreateComponentRoutines = pendingCreateComponentRoutines.concat(leftover)
- });
- return {
- createComponent: createComponent,
- renderComponent: function(name, options, id, validatorOptions) {
- id = id || "dx-" + new Guid;
- createComponent(name, options, id, validatorOptions);
- return '<div id="' + id + '"></div>'
- },
- getEditorValue: function(inputName) {
- var $widget = $("input[name='" + inputName + "']").closest(".dx-widget");
- if ($widget.length) {
- var dxComponents = $widget.data("dxComponents"),
- widget = $widget.data(dxComponents[0]);
- if (widget) {
- return widget.option("value")
- }
- }
- },
- setTemplateEngine: function() {
- if (_setTemplateEngine) {
- _setTemplateEngine(createTemplateEngine())
- }
- },
- enableAlternativeTemplateTags: function(value) {
- _enableAlternativeTemplateTags = value
- },
- createValidationSummaryItems: function(validationGroup, editorNames) {
- var groupConfig, items, summary = getValidationSummary(validationGroup);
- if (summary) {
- groupConfig = validationEngine.getGroupConfig(validationGroup);
- if (groupConfig) {
- items = createValidationSummaryItemsFromValidators(groupConfig.validators, editorNames);
- items.length && summary.option("items", items)
- }
- }
- }
- }
- });
|