Skip to content

Commit f143896

Browse files
author
Kendo Bot
committed
Sync with Kendo UI Professional
1 parent de0c969 commit f143896

File tree

3 files changed

+140
-3
lines changed

3 files changed

+140
-3
lines changed

docs/controls/layout/tilelayout/add-remove.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,93 @@ The example below demonstrates how you can enable users to remove a tile from th
110110
</style>
111111
```
112112

113+
The following example demonstrates how you can enable users to add a tile to the TileLayout by clicking on a button.
114+
115+
```dojo
116+
<base href="https://demos.telerik.com/kendo-ui/tilelayout/reordering">
117+
118+
<button id="addNew" class="k-button">Add tile</button>
119+
<div id="tilelayout"></div>
120+
121+
<!-- container templates -->
122+
<script id="barcelona" type="text/x-kendo-template">
123+
<img class="k-card-image" draggable="false" src="../content/web/cards/barcelona.jpg")" />
124+
</script>
125+
<script id="sofia" type="text/x-kendo-template">
126+
<img class="k-card-image" draggable="false" src="../content/web/cards/sofia.jpg")" />
127+
</script>
128+
<script id="rome" type="text/x-kendo-template">
129+
<img class="k-card-image" draggable="false" src="../content/web/cards/rome.jpg")" />
130+
</script>
131+
<script id="sa" type="text/x-kendo-template">
132+
<img class="k-card-image" draggable="false" src="../content/web/cards/south-africa.jpg")" />
133+
</script>
134+
<script id="sanfran" type="text/x-kendo-template">
135+
<img class="k-card-image" draggable="false" src="../content/web/cards/sanfran.jpg")" />
136+
</script>
137+
138+
<script>
139+
$("#tilelayout").kendoTileLayout({
140+
containers: [{
141+
colSpan: 1,
142+
rowSpan: 1,
143+
header: {
144+
text: "Barcelona"
145+
},
146+
bodyTemplate: kendo.template($("#barcelona").html())
147+
}, {
148+
colSpan: 1,
149+
rowSpan: 1,
150+
header: {
151+
text: "Sofia"
152+
},
153+
bodyTemplate: kendo.template($("#sofia").html())
154+
}, {
155+
colSpan: 1,
156+
rowSpan: 1,
157+
header: {
158+
text: "Rome"
159+
},
160+
bodyTemplate: kendo.template($("#rome").html())
161+
}, {
162+
colSpan: 1,
163+
rowSpan: 1,
164+
header: {
165+
text: "South Africa"
166+
},
167+
bodyTemplate: kendo.template($("#sa").html())
168+
}],
169+
columns: 2,
170+
columnsWidth: 285,
171+
rowsHeight: 285,
172+
reorderable: true
173+
});
174+
175+
$("#addNew").click(function() {
176+
var tileLayout = $("#tilelayout").data("kendoTileLayout");
177+
var items = tileLayout.items;
178+
var item = {
179+
colSpan: 1,
180+
rowSpan: 1,
181+
header: {
182+
text: "San Francisco"
183+
},
184+
bodyTemplate: kendo.template($("#sanfran").html())
185+
};
186+
187+
items.push(item);
188+
tileLayout.setOptions({ containers: items });
189+
});
190+
</script>
191+
192+
<style>
193+
.k-card-image {
194+
width: 285px;
195+
height: 189px;
196+
}
197+
</style>
198+
```
199+
113200
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.
114201

115202

src/kendo.numerictextbox.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,12 @@ var __meta__ = { // jshint ignore:line
602602
this._numPadDot = false;
603603
}
604604

605+
if (this._isPasted) {
606+
value = this._parse(value)
607+
.toString()
608+
.replace(POINT, numberFormat[POINT]);
609+
}
610+
605611
if (this._numericRegex(numberFormat).test(value) && !minInvalid) {
606612
this._oldText = value;
607613
} else {
@@ -612,6 +618,8 @@ var __meta__ = { // jshint ignore:line
612618
this._cachedCaret = null;
613619
}
614620
}
621+
622+
this._isPasted = false;
615623
},
616624

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

674-
setTimeout(function() {
682+
that._isPasted = true;
683+
684+
setTimeout(function() {
675685
var result = that._parse(element.value);
676686

677687
if (result === NULL) {

tests/numerictextbox/navigation.js

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@
105105
assert.equal(input.val(), "1");
106106
});
107107

108-
109-
110108
it("Allow decimal separator '.'", function() {
111109
var textbox = new NumericTextBox(input);
112110

@@ -256,6 +254,48 @@
256254
}, 100);
257255
});
258256

257+
it("Apply pasted value with different decimal separator", function(done) {
258+
var textbox = new NumericTextBox(input),
259+
textboxEl = textbox.element;
260+
261+
textboxEl.focus();
262+
263+
textboxEl.val("3,321");
264+
265+
textboxEl.trigger("paste", {
266+
target: input[0]
267+
});
268+
269+
textboxEl.trigger("input");
270+
271+
setTimeout(function() {
272+
assert.equal(textboxEl.val(), 3321);
273+
done();
274+
}, 100);
275+
});
276+
277+
it("Apply pasted value with different decimal separator based on culture", function(done) {
278+
var textbox = new NumericTextBox(input, {
279+
culture: "de-DE"
280+
}),
281+
textboxEl = textbox.element;
282+
283+
textboxEl.focus();
284+
285+
textboxEl.val("1.012,56");
286+
287+
textboxEl.trigger("paste", {
288+
target: input[0]
289+
});
290+
291+
textboxEl.trigger("input");
292+
293+
setTimeout(function() {
294+
assert.equal(textboxEl.val(), "1012,56");
295+
done();
296+
}, 100);
297+
});
298+
259299
it("Accept pasted value with different decimal separator", function(done) {
260300
var textbox = new NumericTextBox(input);
261301
kendo.culture("bg-BG");

0 commit comments

Comments
 (0)