Skip to content

Commit bcf8aca

Browse files
Merge pull request #3 from philips-emr/1.11.4_custom.SO-2932013
Datepicker: Various *Text options no longer accept HTML input [SO-2932013]
2 parents 7d18e9d + 570cde4 commit bcf8aca

File tree

1 file changed

+116
-22
lines changed

1 file changed

+116
-22
lines changed

ui/datepicker.js

Lines changed: 116 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,9 @@ $.extend(Datepicker.prototype, {
227227
inst.append.remove();
228228
}
229229
if (appendText) {
230-
inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
230+
inst.append = $("<span>")
231+
.addClass(this._appendClass)
232+
.text(appendText);
231233
input[isRTL ? "before" : "after"](inst.append);
232234
}
233235

@@ -244,12 +246,32 @@ $.extend(Datepicker.prototype, {
244246
if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
245247
buttonText = this._get(inst, "buttonText");
246248
buttonImage = this._get(inst, "buttonImage");
247-
inst.trigger = $(this._get(inst, "buttonImageOnly") ?
248-
$("<img/>").addClass(this._triggerClass).
249-
attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
250-
$("<button type='button'></button>").addClass(this._triggerClass).
251-
html(!buttonImage ? buttonText : $("<img/>").attr(
252-
{ src:buttonImage, alt:buttonText, title:buttonText })));
249+
250+
if (this._get(inst, "buttonImageOnly")) {
251+
inst.trigger = $("<img>")
252+
.addClass(this._triggerClass)
253+
.attr({
254+
src: buttonImage,
255+
alt: buttonText,
256+
title: buttonText
257+
});
258+
} else {
259+
inst.trigger = $("<button type='button'>")
260+
.addClass(this._triggerClass);
261+
if (buttonImage) {
262+
inst.trigger.html(
263+
$("<img>")
264+
.attr({
265+
src: buttonImage,
266+
alt: buttonText,
267+
title: buttonText
268+
})
269+
);
270+
} else {
271+
inst.trigger.text(buttonText);
272+
}
273+
}
274+
253275
input[isRTL ? "before" : "after"](inst.trigger);
254276
inst.trigger.click(function() {
255277
if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
@@ -1071,7 +1093,7 @@ $.extend(Datepicker.prototype, {
10711093
altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
10721094
date = this._getDate(inst);
10731095
dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
1074-
$(altField).each(function() { $(this).val(dateStr); });
1096+
$(document).find(altField).val(dateStr);
10751097
}
10761098
},
10771099

@@ -1676,32 +1698,104 @@ $.extend(Datepicker.prototype, {
16761698
this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
16771699
this._getFormatConfig(inst)));
16781700

1679-
prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
1680-
"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
1681-
" title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
1682-
(hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='"+ prevText +"'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>"));
1701+
if (this._canAdjustMonth(inst, -1, drawYear, drawMonth)) {
1702+
prev = $("<a>")
1703+
.attr({
1704+
"class": "ui-datepicker-prev ui-corner-all",
1705+
"data-handler": "prev",
1706+
"data-event": "click",
1707+
title: prevText
1708+
})
1709+
.append(
1710+
$("<span>")
1711+
.addClass("ui-icon ui-icon-circle-triangle-" +
1712+
(isRTL ? "e" : "w"))
1713+
.text(prevText)
1714+
)[0].outerHTML;
1715+
} else if (hideIfNoPrevNext) {
1716+
prev = "";
1717+
} else {
1718+
prev = $("<a>")
1719+
.attr({
1720+
"class": "ui-datepicker-prev ui-corner-all ui-state-disabled",
1721+
title: prevText
1722+
})
1723+
.append(
1724+
$("<span>")
1725+
.addClass("ui-icon ui-icon-circle-triangle-" +
1726+
(isRTL ? "e" : "w"))
1727+
.text(prevText)
1728+
)[0].outerHTML;
1729+
}
16831730

16841731
nextText = this._get(inst, "nextText");
16851732
nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
16861733
this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
16871734
this._getFormatConfig(inst)));
16881735

1689-
next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
1690-
"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
1691-
" title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
1692-
(hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='"+ nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>"));
1736+
if (this._canAdjustMonth(inst, +1, drawYear, drawMonth)) {
1737+
next = $("<a>")
1738+
.attr({
1739+
"class": "ui-datepicker-next ui-corner-all",
1740+
"data-handler": "next",
1741+
"data-event": "click",
1742+
title: nextText
1743+
})
1744+
.append(
1745+
$("<span>")
1746+
.addClass("ui-icon ui-icon-circle-triangle-" +
1747+
(isRTL ? "w" : "e"))
1748+
.text(nextText)
1749+
)[0].outerHTML;
1750+
} else if (hideIfNoPrevNext) {
1751+
next = "";
1752+
} else {
1753+
next = $("<a>")
1754+
.attr({
1755+
"class": "ui-datepicker-next ui-corner-all ui-state-disabled",
1756+
title: nextText
1757+
})
1758+
.append(
1759+
$("<span>")
1760+
.attr("class", "ui-icon ui-icon-circle-triangle-" +
1761+
(isRTL ? "w" : "e"))
1762+
.text(nextText)
1763+
)[0].outerHTML;
1764+
}
16931765

16941766
currentText = this._get(inst, "currentText");
16951767
gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
16961768
currentText = (!navigationAsDateFormat ? currentText :
16971769
this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
16981770

1699-
controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
1700-
this._get(inst, "closeText") + "</button>" : "");
1701-
1702-
buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
1703-
(this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
1704-
">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
1771+
controls = "";
1772+
if (!inst.inline) {
1773+
controls = $("<button>")
1774+
.attr({
1775+
type: "button",
1776+
"class": "ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all",
1777+
"data-handler": "hide",
1778+
"data-event": "click"
1779+
})
1780+
.text(this._get(inst, "closeText"))[0].outerHTML;
1781+
}
1782+
1783+
buttonPanel = "";
1784+
if (showButtonPanel) {
1785+
buttonPanel = $("<div class='ui-datepicker-buttonpane ui-widget-content'>")
1786+
.append(isRTL ? controls : "")
1787+
.append(this._isInRange(inst, gotoDate) ?
1788+
$("<button>")
1789+
.attr({
1790+
type: "button",
1791+
"class": "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all",
1792+
"data-handler": "today",
1793+
"data-event": "click"
1794+
})
1795+
.text(currentText) :
1796+
"")
1797+
.append(isRTL ? "" : controls)[0].outerHTML;
1798+
}
17051799

17061800
firstDay = parseInt(this._get(inst, "firstDay"),10);
17071801
firstDay = (isNaN(firstDay) ? 0 : firstDay);

0 commit comments

Comments
 (0)