Alexander Nazarov (nfokz) wrote in changelog,
Alexander Nazarov
nfokz
changelog

[livejournal] r23217: LJSV-2448: Time changes to current when ...

Committer: anazarov
LJSV-2448: Time changes to current when switching date of the entry in new update.bml
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-10-30 05:54:28 UTC (rev 23216)
+++ trunk/htdocs/js/jquery/jquery.lj.entryDatePicker.js	2012-10-30 07:26:18 UTC (rev 23217)
@@ -14,7 +14,11 @@
 
 	var listeners = {
 		onStartEdit: function(evt) {
-			evt.data._setState('edit');
+			var self = evt.data;
+
+			self._setState('edit');
+			self._setEditDate(self.currentDate);
+
 			evt.preventDefault();
 		},
 
@@ -247,7 +251,7 @@
 				}).dateEntry('setDate', this.currentDate).bind('change', this, listeners.onChangeDate);
 			} else {
 				this._dateInputs.date.bind('blur', this, listeners.onChangeDate);
-				this._dateInputs.time.bind('blur edit', this, listeners.onChangeTime);
+				this._dateInputs.time.bind('blur', this, listeners.onChangeTime);
 			}
 		},
 
@@ -262,6 +266,10 @@
 			}
 		},
 
+		/**
+		 * Stop timer
+		 * @param {Boolean} completely Also change options.updateDate to prevent timer start in future
+		 */
 		_stopTimer: function(completely) {
 			clearInterval(this._updateTimer);
 			delete this._updateTimer;
@@ -301,14 +309,16 @@
 
 			var current = new Date(),
 				toSet = new Date(date);
+
+			/* Compare dates with one minute precision */
 			current.setMilliseconds(0);
 			current.setSeconds(0);
-			current.setMinutes(0);
-			current.setHours(0);
+			//current.setMinutes(0);
+			//current.setHours(0);
 			toSet.setMilliseconds(0);
 			toSet.setSeconds(0);
-			toSet.setMinutes(0);
-			toSet.setHours(0);
+			//toSet.setMinutes(0);
+			//toSet.setHours(0);
 
 			var delta = +toSet - (+new Date());
 			this._setTime(date);
@@ -321,6 +331,11 @@
 			}
 		},
 
+		/**
+		 * Set widget state
+		 *
+		 * @param {String} state State name
+		 */
 		_setState: function(state) {
 			this.options.state = state = state || 'default';
 
@@ -337,7 +352,6 @@
 						this._dateInputs.custom_time.val(1);
 					}
 
-					this._dateInputs.time.trigger('edit');
 					break;
 				case 'infutureedit':
 				case 'inedit':

Tags: anazarov, js, livejournal, nfokz
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