Skip to content

Commit

Permalink
Sync with Kendo UI Professional
Browse files Browse the repository at this point in the history
  • Loading branch information
Kendo Bot committed May 18, 2021
1 parent de0c969 commit f143896
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 3 deletions.
87 changes: 87 additions & 0 deletions docs/controls/layout/tilelayout/add-remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,93 @@ The example below demonstrates how you can enable users to remove a tile from th
</style>
```

The following example demonstrates how you can enable users to add a tile to the TileLayout by clicking on a button.

```dojo
<base href="https://demos.telerik.com/kendo-ui/tilelayout/reordering">
<button id="addNew" class="k-button">Add tile</button>
<div id="tilelayout"></div>
<!-- container templates -->
<script id="barcelona" type="text/x-kendo-template">
<img class="k-card-image" draggable="false" src="../content/web/cards/barcelona.jpg")" />
</script>
<script id="sofia" type="text/x-kendo-template">
<img class="k-card-image" draggable="false" src="../content/web/cards/sofia.jpg")" />
</script>
<script id="rome" type="text/x-kendo-template">
<img class="k-card-image" draggable="false" src="../content/web/cards/rome.jpg")" />
</script>
<script id="sa" type="text/x-kendo-template">
<img class="k-card-image" draggable="false" src="../content/web/cards/south-africa.jpg")" />
</script>
<script id="sanfran" type="text/x-kendo-template">
<img class="k-card-image" draggable="false" src="../content/web/cards/sanfran.jpg")" />
</script>
<script>
$("#tilelayout").kendoTileLayout({
containers: [{
colSpan: 1,
rowSpan: 1,
header: {
text: "Barcelona"
},
bodyTemplate: kendo.template($("#barcelona").html())
}, {
colSpan: 1,
rowSpan: 1,
header: {
text: "Sofia"
},
bodyTemplate: kendo.template($("#sofia").html())
}, {
colSpan: 1,
rowSpan: 1,
header: {
text: "Rome"
},
bodyTemplate: kendo.template($("#rome").html())
}, {
colSpan: 1,
rowSpan: 1,
header: {
text: "South Africa"
},
bodyTemplate: kendo.template($("#sa").html())
}],
columns: 2,
columnsWidth: 285,
rowsHeight: 285,
reorderable: true
});
$("#addNew").click(function() {
var tileLayout = $("#tilelayout").data("kendoTileLayout");
var items = tileLayout.items;
var item = {
colSpan: 1,
rowSpan: 1,
header: {
text: "San Francisco"
},
bodyTemplate: kendo.template($("#sanfran").html())
};
items.push(item);
tileLayout.setOptions({ containers: items });
});
</script>
<style>
.k-card-image {
width: 285px;
height: 189px;
}
</style>
```

For a full implementation of the Add/Remove functionality please refer to the official [`Add/Remove demo`](https://demos.telerik.com/kendo-ui/tilelayout/add-remove) page.


Expand Down
12 changes: 11 additions & 1 deletion src/kendo.numerictextbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,12 @@ var __meta__ = { // jshint ignore:line
this._numPadDot = false;
}

if (this._isPasted) {
value = this._parse(value)
.toString()
.replace(POINT, numberFormat[POINT]);
}

if (this._numericRegex(numberFormat).test(value) && !minInvalid) {
this._oldText = value;
} else {
Expand All @@ -612,6 +618,8 @@ var __meta__ = { // jshint ignore:line
this._cachedCaret = null;
}
}

this._isPasted = false;
},

_blinkInvalidState: function () {
Expand Down Expand Up @@ -671,7 +679,9 @@ var __meta__ = { // jshint ignore:line
var value = element.value;
var numberFormat = that._format(that.options.format);

setTimeout(function() {
that._isPasted = true;

setTimeout(function() {
var result = that._parse(element.value);

if (result === NULL) {
Expand Down
44 changes: 42 additions & 2 deletions tests/numerictextbox/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@
assert.equal(input.val(), "1");
});



it("Allow decimal separator '.'", function() {
var textbox = new NumericTextBox(input);

Expand Down Expand Up @@ -256,6 +254,48 @@
}, 100);
});

it("Apply pasted value with different decimal separator", function(done) {
var textbox = new NumericTextBox(input),
textboxEl = textbox.element;

textboxEl.focus();

textboxEl.val("3,321");

textboxEl.trigger("paste", {
target: input[0]
});

textboxEl.trigger("input");

setTimeout(function() {
assert.equal(textboxEl.val(), 3321);
done();
}, 100);
});

it("Apply pasted value with different decimal separator based on culture", function(done) {
var textbox = new NumericTextBox(input, {
culture: "de-DE"
}),
textboxEl = textbox.element;

textboxEl.focus();

textboxEl.val("1.012,56");

textboxEl.trigger("paste", {
target: input[0]
});

textboxEl.trigger("input");

setTimeout(function() {
assert.equal(textboxEl.val(), "1012,56");
done();
}, 100);
});

it("Accept pasted value with different decimal separator", function(done) {
var textbox = new NumericTextBox(input);
kendo.culture("bg-BG");
Expand Down

0 comments on commit f143896

Please sign in to comment.