can3p (can3p) wrote in changelog,
can3p
can3p
changelog

[livejournal] r22026: LJSUP-12126: Port choose date widget fro...

Committer: dpetrov
LJSUP-12126: Port choose date widget from the old update.bml page
U   trunk/htdocs/js/jquery/jquery.lj.entryDatePicker.js
Modified: trunk/htdocs/js/jquery/jquery.lj.entryDatePicker.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.lj.entryDatePicker.js	2012-05-22 13:03:03 UTC (rev 22025)
+++ trunk/htdocs/js/jquery/jquery.lj.entryDatePicker.js	2012-05-22 13:50:20 UTC (rev 22026)
@@ -52,9 +52,24 @@
 
 		onChangeTime: function(evt) {
 			var self = evt.data || this,
-				newDate = (self._isOldDesign) ? $(this).timeEntry('getTime') :
-												LJ.Util.Date.parse(evt.target.value);
+				newDate, dateAr;
+			
+			if (self._isOldDesign)  {
+				newDate = $(this).timeEntry('getTime');
+			} else {
+				dateAr = evt.target.value.split(':').map(function(el) { return parseInt(el, 10); });
+				newDate = new Date();
+				if (dateAr.length === 2) {
+					if (dateAr[0] < 0) { dateAr[0] = 0; }
+					if (dateAr[0] > 23) { dateAr[0] = 23; }
+					if (dateAr[1] < 0) { dateAr[1] = 0; }
+					if (dateAr[1] > 59) { dateAr[1] = 59; }
 
+					newDate.setHours(dateAr[0]);
+					newDate.setMinutes(dateAr[1]);
+				}
+			}
+
 			if (self._isEvent === false) {
 				return;
 			}
@@ -174,7 +189,7 @@
 					caption: Site.ml_text['entryform.choose_date'] || 'Choose date:'
 				},
 				endMonth: new Date(2037, 11, 31),
-				showCellHovers: true,
+				showCellHovers: true
 			};
 
 			if (!this._isOldDesign) {
@@ -184,6 +199,12 @@
 					templates: {
 						calendar: 'templates-Widgets-datepicker'
 					},
+					selectors: {
+						prevMonth: '.cal-nav-prev',
+						nextMonth: '.cal-nav-next',
+						monthSelect: '.b-datepicker-controls-month',
+						yearSelect: '.b-datepicker-controls-year'
+					},
 					classNames: {
 						container: '',
 						inactive : 'b-datepicker-calendar-day-disabled',
@@ -197,6 +218,7 @@
 				.bind('daySelected', function(evt, date) {
 				var currentDate = $(this).calendar('option', 'currentDate');
 				delete self._isCalendarOpen;
+				self._isEvent = false; //we're not a blur event
 
 				if (currentDate.getMonth() !== date.getMonth() || currentDate.getDate() !== date.getDate() || currentDate.getFullYear() !== date.getFullYear()) {
 					date.setHours(currentDate.getHours());
@@ -324,7 +346,7 @@
 				date = date || new Date;
 
 				this._isEvent = false;
-				if (inputs.date_ymd_yyyy) {
+				if (this._isOldDesign) {
 					inputs.date_ymd_yyyy.dateEntry('setDate', date);
 					inputs.date_ymd_mm.val(date.getMonth() + 1);
 					inputs.date_ymd_dd.dateEntry('setDate', date);

Tags: can3p, dpetrov, js, livejournal
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments