Skip to content

Commit 5ee64dd

Browse files
committed
Calendar: Introduce build methods for year and month title
1 parent c1cb6e3 commit 5ee64dd

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

demos/calendar/dropdown-month-year.html

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,7 @@
99
<script src="../../external/requirejs/require.js"></script>
1010
<script src="../bootstrap.js">
1111
$.widget( "ui.calendar", $.ui.calendar, {
12-
_buildTitle: function() {
13-
var title = $( "<div>", { role: "alert", id: this.gridId + "-month-label" } ),
14-
month = this._renderMonthSelect(),
15-
year = this._renderYearSelect();
16-
17-
this._addClass( title, "ui-calendar-title" )
18-
._addClass( month, "ui-calendar-month" )
19-
._addClass( year, "ui-calendar-year" );
20-
21-
return title
22-
.append( month )
23-
.append( " " )
24-
.append( year );
25-
},
26-
_renderMonthSelect: function() {
12+
_buildTitleMonth: function() {
2713
var select = $( "<select>" ),
2814
date = this.date.clone(),
2915
i = 0,
@@ -48,7 +34,7 @@
4834

4935
return select;
5036
},
51-
_renderYearSelect: function() {
37+
_buildTitleYear: function() {
5238
var current = new Date(),
5339
select = $( "<select>" ),
5440
i = current.getFullYear(),

ui/widgets/calendar.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,8 @@ return $.widget( "ui.calendar", {
366366

367367
_buildTitle: function() {
368368
var title = $( "<div>", { role: "alert", id: this.gridId + "-month-label" } ),
369-
month = $( "<span>" ).text( this.viewDate.monthName() ),
370-
year = $( "<span>" ).text( this.viewDate.year() );
369+
month = this._buildTitleMonth(),
370+
year = this._buildTitleYear();
371371

372372
this._addClass( title, "ui-calendar-title" )
373373
._addClass( month, "ui-calendar-month" )
@@ -379,6 +379,14 @@ return $.widget( "ui.calendar", {
379379
.append( year );
380380
},
381381

382+
_buildTitleMonth: function() {
383+
return $( "<span>" ).text( this.viewDate.monthName() );
384+
},
385+
386+
_buildTitleYear: function() {
387+
return $( "<span>" ).text( this.viewDate.year() );
388+
},
389+
382390
_buildGrid: function() {
383391
var table = $( "<table>", {
384392
role: "grid",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy