PageSourceSearch

https://caxapa.ru/search/monthpicker.js?qsw2fzp

js caxapa.ru collected 2026-09-24 18:29:04 UTC 7,225 bytes, 154 lines download raw bytes

1(function( $, undefined ) {
2  $.extend($.datepicker, {
3    _generateDaysHTML: $.datepicker._generateHTML,
4    _generateMonthsHTML: function(inst) {
5      inst.dpDiv.addClass('ui-monthpicker');
6      var maxDraw, prevText, prev, nextText, next,
7			controls, buttonPanel, showWeek, dayNames, dayNamesMin,
8			monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
9			selectOtherMonths, defaultDate, html, group, col, selectedDate,
10			cornerClass, calender, day, daysInMonth,
11			printDate, otherMonth, unselectable,
12			tempDate = new Date(),
13			today = this._daylightSavingAdjust(
14				new Date(tempDate.getFullYear(), tempDate.getMonth(), 1)), // clear time
15			isRTL = this._get(inst, "isRTL"),
16			showButtonPanel = this._get(inst, "showButtonPanel"),
17			hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
18			navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
19			numMonths = this._getNumberOfMonths(inst),
20			showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
21			stepMonths = this._get(inst, "stepMonths"),
22			currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
23				new Date(inst.currentYear, inst.currentMonth, 1))),
24			minDate = this._getMinMaxDate(inst, "min"),
25			maxDate = this._getMinMaxDate(inst, "max"),
26			drawMonth = inst.drawMonth - showCurrentAtPos,
27			drawYear = inst.drawYear;
28
29		if (drawMonth < 0) {
30			drawMonth += 12;
31			drawYear--;
32		}
33		if (maxDate) {
34			maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
35				maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
36			maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
37			while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
38				drawMonth--;
39				if (drawMonth < 0) {
40					drawMonth = 11;
41					drawYear--;
42				}
43			}
44		}
45		inst.drawMonth = drawMonth;
46		inst.drawYear = drawYear;
47
48		prevText = this._get(inst, "prevText");
49		prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
50			this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
51			this._getFormatConfig(inst)));
52
53		prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
54			"<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
55			" title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
56			(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>"));
57
58		nextText = this._get(inst, "nextText");
59		nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
60			this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
61			this._getFormatConfig(inst)));
62
63		next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
64			"<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
65			" title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
66			(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>"));
67
68		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'>" +
69			this._get(inst, "closeText") + "</button>" : "");
70
71		buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + controls + "</div>" : "";
72
73		showWeek = this._get(inst, "showWeek");
74		dayNames = this._get(inst, "dayNames");
75		dayNamesMin = this._get(inst, "dayNamesMin");
76		monthNames = this._get(inst, "monthNames");
77		monthNamesShort = this._get(inst, "monthNamesShort");
78		beforeShowDay = this._get(inst, "beforeShowDay");
79		showOtherMonths = this._get(inst, "showOtherMonths");
80		selectOtherMonths = this._get(inst, "selectOtherMonths");
81		defaultDate = this._getDefaultDate(inst);
82		html = "";
83		for (row = 0; row < numMonths[0]; row++) {
84			group = "";
85			this.maxRows = 4;
86			for (col = 0; col < numMonths[1]; col++) {
87				selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
88				cornerClass = " ui-corner-all";
89				calender = "";
90				calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
91					(/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
92					(/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
93					this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
94					row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
95					"</div><table class='ui-datepicker-calendar'>";
96				daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
97				if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
98					inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
99				}
100				numRows = 4;
101				this.maxRows = numRows;
102				printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1));
103        calender += '<tr>';
104        for (mRow = 0; mRow < 4; mRow++) {
105          calender += '<tr>';
106          for (mData = 0; mData < 3; mData++) {
107            var month = mRow*3 + mData;
108            printDate = this._daylightSavingAdjust(new Date(drawYear, month, 1));
109            calender += "<td class='" +
110							(printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
111							(printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "") + "'" + // highlight today (if different)
112              " data-handler='selectDay' data-event='click' data-month='" + month + "' data-year='" + printDate.getFullYear() + "'>" +
113              "<span class='ui-state-default" +
114              (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
115              (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
116							"'>" + monthNamesShort[month] + "</span><a href='#' data-date='1' style='display: none;'>1</a></td>"; // display selectable date
117          }
118          calender += '</tr>';
119        }
120				calender += "</tbody></table>";
121				group += calender;
122			}
123			html += group;
124		}
125		html += buttonPanel;
126		inst._keyEvent = false;
127		return html;
128
129    },
130    _generateHTML: function(inst) {
131      if ( inst.settings.monthPicker ) {
132        return this._generateMonthsHTML(inst);
133      } else {
134        return this._generateDaysHTML(inst);
135      }
136    }
137  });
138 
139  $.fn.monthpicker = function(options) {
140    return this.each(function() {
141      var $this = $(this);
142      var altField = $this.next();
143      altField.on('focus', function() { $this.datepicker('show') });
144      var settings = {
145        monthPicker: true,
146        stepMonths: 12,
147        changeMonth: false,
148        altField: altField,
149        altFormat: 'M yy' }
150      $.extend(settings, options);
151      $this.datepicker(settings);
152    });
153  }
154}) (jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.