Skip to content

Commit 7e7b3af

Browse files
committed
Sync with Kendo UI Professional
1 parent c249871 commit 7e7b3af

File tree

2 files changed

+64
-45
lines changed

2 files changed

+64
-45
lines changed

src/kendo.splitter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export const __meta__ = {
153153
that.element
154154
.children(".k-splitbar-draggable-" + orientation)
155155
.on("keydown" + NS, that._keydown.bind(that))
156-
.on("mousedown" + NS, function(e) { e.currentTarget.focus(); })
156+
.on("mousedown" + NS, function(e) { e.currentTarget.focus({ preventScroll: true }); })
157157
.on("focus" + NS, function(e) { $(e.currentTarget).addClass(FOCUSED); })
158158
.on("blur" + NS, function(e) {
159159
$(e.currentTarget).removeClass(FOCUSED);

src/kendo.validator.js

Lines changed: 63 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ export const __meta__ = {
161161
that.element.attr(NOVALIDATE, NOVALIDATE);
162162
}
163163

164-
that._inputSelector = INPUTSELECTOR + validateAttributeSelector;
165-
that._checkboxSelector = CHECKBOXSELECTOR + validateAttributeSelector;
164+
that._shouldSearchDocument = that.element.is(FORM) && that.element.attr("id") !== undefined;
165+
that._containerElement = that._shouldSearchDocument ? $(document) : that.element;
166+
that._inputSelector = that._buildSelector(INPUTSELECTOR, validateAttributeSelector);
167+
that._checkboxSelector = that._buildSelector(CHECKBOXSELECTOR, validateAttributeSelector);
166168

167169
that._errors = {};
168170
that._attachEvents();
@@ -192,12 +194,13 @@ export const __meta__ = {
192194
},
193195
rules: {
194196
required: function(input) {
195-
var noNameCheckbox = !input.attr("name") && !input.is(":checked"),
197+
let containerElement = this._containerElement,
198+
noNameCheckbox = !input.attr("name") && !input.is(":checked"),
196199
name = input.attr("name"),
197200
quote = !!name && name.indexOf("'") > -1 ? '\"' : "'",
198-
namedCheckbox = input.attr("name") && !this.element.find("input[name=" + quote + input.attr("name") + quote + "]:checked").length,
201+
namedCheckbox = input.attr("name") && !containerElement.find("input[name=" + quote + input.attr("name") + quote + "]:checked").length,
199202
checkbox = input.filter("[type=checkbox]").length && (noNameCheckbox || namedCheckbox),
200-
radio = input.filter("[type=radio]").length && !this.element.find("input[name=" + quote + input.attr("name") + quote + "]:checked").length,
203+
radio = input.filter("[type=radio]").length && !containerElement.find("input[name=" + quote + input.attr("name") + quote + "]:checked").length,
201204
value = input.val();
202205

203206
return !(hasAttribute(input, "required") && (!value || value === "" || value.length === 0 || checkbox || radio));
@@ -296,6 +299,18 @@ export const __meta__ = {
296299
validationSummary: false
297300
},
298301

302+
_buildSelector: function(selectorConstant, validateAttributeSelector) {
303+
const that = this,
304+
formSelector = `,[form="${that.element.attr("id")}"]`;
305+
let selector = selectorConstant + validateAttributeSelector;
306+
307+
if ( that._shouldSearchDocument) {
308+
selector += formSelector;
309+
}
310+
311+
return selector;
312+
},
313+
299314
_allowSubmit: function() {
300315
return kendo.ui.validator.allowSubmit(this.element, this.errors());
301316
},
@@ -344,28 +359,29 @@ export const __meta__ = {
344359
},
345360

346361
_attachEvents: function() {
347-
var that = this;
362+
const that = this,
363+
element = that._containerElement;
348364

349365
if (that.element.is(FORM)) {
350366
that.element.on("submit" + NS, that._submit.bind(that));
351367
}
352368

353369
if (that.options.validateOnBlur) {
354-
if (!that.element.is(INPUTSELECTOR)) {
355-
that.element.on(BLUR + NS, that._inputSelector, function() {
370+
if (!element.is(INPUTSELECTOR)) {
371+
element.on(BLUR + NS, that._inputSelector, function() {
356372
that._checkElement($(this));
357373
});
358374

359-
that.element.on("click" + NS, that._checkboxSelector, function() {
375+
element.on("click" + NS, that._checkboxSelector, function() {
360376
that._checkElement($(this));
361377
});
362378
} else {
363-
that.element.on(BLUR + NS, function() {
379+
element.on(BLUR + NS, function() {
364380
that._checkElement(that.element);
365381
});
366382

367-
if (that.element.is(CHECKBOXSELECTOR)) {
368-
that.element.on("click" + NS, function() {
383+
if (element.is(CHECKBOXSELECTOR)) {
384+
element.on("click" + NS, function() {
369385
that._checkElement(that.element);
370386
});
371387
}
@@ -374,19 +390,19 @@ export const __meta__ = {
374390
},
375391

376392
validate: function() {
377-
var inputs;
378-
var idx;
379-
var result = false;
380-
var length;
381-
382-
var isValid = this.value();
393+
let inputs;
394+
let idx;
395+
let result = false;
396+
let length;
397+
let containerElement = this._containerElement;
398+
let isValid = this.value();
383399

384400
this._errors = {};
385401

386402
if (!this.element.is(INPUTSELECTOR)) {
387-
var invalid = false;
403+
let invalid = false;
388404

389-
inputs = this.element.find(this._inputSelector);
405+
inputs = containerElement.find(this._inputSelector);
390406

391407
for (idx = 0, length = inputs.length; idx < length; idx++) {
392408
if (!this.validateInput(inputs.eq(idx))) {
@@ -418,15 +434,14 @@ export const __meta__ = {
418434

419435
this._isValidated = true;
420436

421-
var that = this,
437+
const that = this,
422438
template = that._errorTemplate,
423439
result = that._checkValidity(input),
424440
valid = result.valid,
425-
widgetInstance,
426441
className = "." + INVALIDMSG,
427442
fieldName = (input.attr(NAME) || ""),
428443
lbl = that._findMessageContainer(fieldName).add(input.next(className).filter(function() {
429-
var element = $(this);
444+
let element = that._shouldSearchDocument ? $(document) : $(this);
430445
if (element.filter("[" + kendo.attr("for") + "]").length) {
431446
return element.attr(kendo.attr("for")) === fieldName;
432447
}
@@ -439,6 +454,7 @@ export const __meta__ = {
439454
wasValid = !input.attr(ARIAINVALID),
440455
isInputInner = input.is(INPUTINNER),
441456
inputWrapper = input.parent(INPUTWRAPPER);
457+
let widgetInstance;
442458

443459
input.removeAttr(ARIAINVALID);
444460

@@ -456,7 +472,7 @@ export const __meta__ = {
456472

457473
if (!valid && !input.data("captcha_validating")) {
458474
that._errors[fieldName] = messageText;
459-
var lblId = lbl.attr('id');
475+
let lblId = lbl.attr('id');
460476

461477
that._decorateMessageContainer(messageLabel, fieldName);
462478

@@ -469,9 +485,9 @@ export const __meta__ = {
469485
lbl.replaceWith(messageLabel);
470486
} else {
471487
widgetInstance = widgetInstance || kendo.widgetInstance(input);
472-
var parentElement = input.parent().get(0);
473-
var nextElement = input.next().get(0);
474-
var prevElement = input.prev().get(0);
488+
let parentElement = input.parent().get(0);
489+
let nextElement = input.next().get(0);
490+
let prevElement = input.prev().get(0);
475491

476492
// Get the instance of the RadioGroup which is not initialized on the input element
477493
if (!widgetInstance && input.is("[type=radio]")) {
@@ -520,8 +536,8 @@ export const __meta__ = {
520536
}
521537

522538
if (widgetInstance) {
523-
var inputWrap = widgetInstance._inputWrapper || widgetInstance.wrapper;
524-
var inputLabel = widgetInstance._inputLabel;
539+
let inputWrap = widgetInstance._inputWrapper || widgetInstance.wrapper;
540+
let inputLabel = widgetInstance._inputLabel;
525541

526542
if (inputWrap && !(input.is("[type=checkbox]") || input.is("[type=radio]"))) {
527543
inputWrap.toggleClass(INVALIDINPUT, !valid);
@@ -533,7 +549,7 @@ export const __meta__ = {
533549
}
534550

535551
if (wasValid !== valid) {
536-
var errorId = messageLabel ? messageLabel.attr("id") : lbl.attr("id");
552+
let errorId = messageLabel ? messageLabel.attr("id") : lbl.attr("id");
537553

538554
that._associateMessageContainer(input, errorId);
539555

@@ -546,9 +562,9 @@ export const __meta__ = {
546562
},
547563

548564
hideMessages: function() {
549-
var that = this,
565+
const that = this,
550566
className = "." + INVALIDMSG,
551-
element = that.element;
567+
element = that._containerElement;
552568

553569
that._disassociateMessageContainers();
554570

@@ -560,9 +576,10 @@ export const __meta__ = {
560576
},
561577

562578
reset: function() {
563-
var that = this,
564-
inputs = that.element.find("." + INVALIDINPUT),
565-
labels = that.element.find("." + INVALIDLABEL);
579+
const that = this,
580+
containerElement = that._containerElement,
581+
inputs = containerElement.find("." + INVALIDINPUT),
582+
labels = containerElement.find("." + INVALIDLABEL);
566583

567584
that._errors = [];
568585

@@ -576,16 +593,17 @@ export const __meta__ = {
576593
},
577594

578595
_findMessageContainer: function(fieldName) {
579-
var locators = kendo.ui.validator.messageLocators,
596+
let locators = kendo.ui.validator.messageLocators,
580597
name,
581598
containers = $();
582599

583-
for (var idx = 0, length = this.element.length; idx < length; idx++) {
584-
containers = containers.add(searchForMessageContainer(this.element[idx].getElementsByTagName("*"), fieldName));
600+
for (let idx = 0, length = this.element.length; idx < length; idx++) {
601+
let target = this._shouldSearchDocument ? document : this.element[idx];
602+
containers = containers.add(searchForMessageContainer(target.getElementsByTagName("*"), fieldName));
585603
}
586604

587605
for (name in locators) {
588-
containers = containers.add(locators[name].locate(this.element, fieldName));
606+
containers = containers.add(locators[name].locate(this._containerElement, fieldName));
589607
}
590608

591609
return containers;
@@ -663,12 +681,13 @@ export const __meta__ = {
663681
},
664682

665683
_getInputNames: function() {
666-
var that = this,
667-
inputs = that.element.find(that._inputSelector),
668-
sorted = [];
684+
const that = this,
685+
containerElement = this._containerElement,
686+
inputs = containerElement.find(that._inputSelector);
687+
let sorted = [];
669688

670-
for (var idx = 0, length = inputs.length; idx < length; idx++) {
671-
var input = $(inputs[idx]);
689+
for (let idx = 0, length = inputs.length; idx < length; idx++) {
690+
let input = $(inputs[idx]);
672691

673692
if (hasAttribute(input, NAME)) {
674693
// Add current name if:

0 commit comments

Comments
 (0)