@@ -227,7 +227,9 @@ $.extend(Datepicker.prototype, {
227
227
inst . append . remove ( ) ;
228
228
}
229
229
if ( appendText ) {
230
- inst . append = $ ( "<span class='" + this . _appendClass + "'>" + appendText + "</span>" ) ;
230
+ inst . append = $ ( "<span>" )
231
+ . addClass ( this . _appendClass )
232
+ . text ( appendText ) ;
231
233
input [ isRTL ? "before" : "after" ] ( inst . append ) ;
232
234
}
233
235
@@ -244,12 +246,32 @@ $.extend(Datepicker.prototype, {
244
246
if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
245
247
buttonText = this . _get ( inst , "buttonText" ) ;
246
248
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
+
253
275
input [ isRTL ? "before" : "after" ] ( inst . trigger ) ;
254
276
inst . trigger . click ( function ( ) {
255
277
if ( $ . datepicker . _datepickerShowing && $ . datepicker . _lastInput === input [ 0 ] ) {
@@ -1071,7 +1093,7 @@ $.extend(Datepicker.prototype, {
1071
1093
altFormat = this . _get ( inst , "altFormat" ) || this . _get ( inst , "dateFormat" ) ;
1072
1094
date = this . _getDate ( inst ) ;
1073
1095
dateStr = this . formatDate ( altFormat , date , this . _getFormatConfig ( inst ) ) ;
1074
- $ ( altField ) . each ( function ( ) { $ ( this ) . val ( dateStr ) ; } ) ;
1096
+ $ ( document ) . find ( altField ) . val ( dateStr ) ;
1075
1097
}
1076
1098
} ,
1077
1099
@@ -1676,32 +1698,104 @@ $.extend(Datepicker.prototype, {
1676
1698
this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth - stepMonths , 1 ) ) ,
1677
1699
this . _getFormatConfig ( inst ) ) ) ;
1678
1700
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
+ }
1683
1730
1684
1731
nextText = this . _get ( inst , "nextText" ) ;
1685
1732
nextText = ( ! navigationAsDateFormat ? nextText : this . formatDate ( nextText ,
1686
1733
this . _daylightSavingAdjust ( new Date ( drawYear , drawMonth + stepMonths , 1 ) ) ,
1687
1734
this . _getFormatConfig ( inst ) ) ) ;
1688
1735
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
+ }
1693
1765
1694
1766
currentText = this . _get ( inst , "currentText" ) ;
1695
1767
gotoDate = ( this . _get ( inst , "gotoCurrent" ) && inst . currentDay ? currentDate : today ) ;
1696
1768
currentText = ( ! navigationAsDateFormat ? currentText :
1697
1769
this . formatDate ( currentText , gotoDate , this . _getFormatConfig ( inst ) ) ) ;
1698
1770
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
+ }
1705
1799
1706
1800
firstDay = parseInt ( this . _get ( inst , "firstDay" ) , 10 ) ;
1707
1801
firstDay = ( isNaN ( firstDay ) ? 0 : firstDay ) ;
0 commit comments