Vlad Kurkin (b_vladi) wrote in changelog,
Vlad Kurkin
b_vladi
changelog

[livejournal] r20779: LJSUP-10709: Incorrect tabulation for da...

Committer: vkurkin
LJSUP-10709: Incorrect tabulation for date&time forms
U   trunk/htdocs/js/jquery/jquery.dateentry.js
U   trunk/htdocs/js/jquery/jquery.dateentry.min.js
Modified: trunk/htdocs/js/jquery/jquery.dateentry.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.dateentry.js	2011-12-14 08:31:43 UTC (rev 20778)
+++ trunk/htdocs/js/jquery/jquery.dateentry.js	2011-12-14 09:26:11 UTC (rev 20779)
@@ -104,7 +104,12 @@
 			var spinner = (!spinnerImage ? null : $('<span class="dateEntry_control" style="display: inline-block; ' + 'background: url(\'' + spinnerImage + '\') 0 0 no-repeat; ' + 'width: ' + spinnerSize[0] + 'px; height: ' + spinnerSize[1] + 'px;' + ($.browser.mozilla && $.browser.version < '1.9' ? // FF 2- (Win)
 				' padding-left: ' + spinnerSize[0] + 'px; padding-bottom: ' + (spinnerSize[1] - 18) + 'px;' : '') + '"></span>'));
 			input.wrap('<span class="dateEntry_wrap"></span>').after(appendText ? '<span class="dateEntry_append">' + appendText + '</span>' : '').after(spinner || '');
-			input.addClass(this.markerClassName).bind('focus.dateEntry', this._doFocus).bind('blur.dateEntry', this._doBlur).bind('click.dateEntry', this._doClick).bind('keydown.dateEntry', this._doKeyDown).bind('keypress.dateEntry', this._doKeyPress);
+			input.addClass(this.markerClassName)
+				.bind('focus.dateEntry', this._doFocus)
+				.bind('blur.dateEntry', this._doBlur)
+				.bind('click.dateEntry', this._doClick)
+				.bind('keydown.dateEntry', this._doKeyDown)
+				.bind('keypress.dateEntry', this._doKeyPress);
 			// Check pastes
 			if ($.browser.mozilla) {
 				input.bind('input.dateEntry', function(event) {
@@ -113,10 +118,10 @@
 			}
 			if ($.browser.msie) {
 				input.bind('paste.dateEntry', function(event) {
-						setTimeout(function() {
-							$.dateEntry._parseDate(inst);
-						}, 1);
-					});
+					setTimeout(function() {
+						$.dateEntry._parseDate(inst);
+					}, 1);
+				});
 			}
 			// Allow mouse wheel usage
 			if (this._get(inst, 'useMouseWheel') && $.fn.mousewheel) {
@@ -152,8 +157,8 @@
 				$.dateEntry._changeSpinner(inst, input.nextSibling, (disable ? 5 : -1));
 			}
 			$.dateEntry._disabledInputs = $.map($.dateEntry._disabledInputs, function(value) {
-					return (value == input ? null : value);
-				}); // Delete entry
+				return (value == input ? null : value);
+			}); // Delete entry
 			if (disable) {
 				$.dateEntry._disabledInputs.push(input);
 			}
@@ -200,8 +205,8 @@
 				$input.unmousewheel();
 			}
 			this._disabledInputs = $.map(this._disabledInputs, function(value) {
-					return (value == input ? null : value);
-				}); // Delete entry
+				return (value == input ? null : value);
+			}); // Delete entry
 			$input.parent().replaceWith($input);
 			$.removeData(input, PROP_NAME);
 		},
@@ -308,9 +313,12 @@
 			var inst = $.data(event.target, PROP_NAME);
 			switch (event.keyCode) {
 				case 9:
+				return true;
+					/*
 					return (event.shiftKey ? // Move to previous date field, or out if at the beginning
 						$.dateEntry._changeField(inst, -1, true) : // Move to next date field, or out if at the end
 						$.dateEntry._changeField(inst, +1, true));
+					*/
 				case 35:
 					if (event.ctrlKey) { // Clear date on ctrl+end
 						$.dateEntry._setValue(inst, '');
@@ -440,8 +448,8 @@
 			var spinnerRepeat = $.dateEntry._get(inst, 'spinnerRepeat');
 			if (region >= 3 && spinnerRepeat[0]) { // Repeat increment/decrement
 				$.dateEntry._timer = setTimeout(function() {
-						$.dateEntry._repeatSpinner(inst, region);
-					}, spinnerRepeat[0]);
+					$.dateEntry._repeatSpinner(inst, region);
+				}, spinnerRepeat[0]);
 				$(spinner).one('mouseout', $.dateEntry._releaseSpinner).one('mouseup', $.dateEntry._releaseSpinner);
 			}
 		},
@@ -482,8 +490,8 @@
 			$.dateEntry._lastInput = $.dateEntry._blurredInput;
 			this._actionSpinner(inst, region);
 			this._timer = setTimeout(function() {
-					$.dateEntry._repeatSpinner(inst, region);
-				}, this._get(inst, 'spinnerRepeat')[1]);
+				$.dateEntry._repeatSpinner(inst, region);
+			}, this._get(inst, 'spinnerRepeat')[1]);
 		},
 
 		/* Stop a spinner repeat.

Modified: trunk/htdocs/js/jquery/jquery.dateentry.min.js
===================================================================
--- trunk/htdocs/js/jquery/jquery.dateentry.min.js	2011-12-14 08:31:43 UTC (rev 20778)
+++ trunk/htdocs/js/jquery/jquery.dateentry.min.js	2011-12-14 09:26:11 UTC (rev 20779)
@@ -4,4 +4,4 @@
    Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
    MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
    Please attribute the author if you use it. */
-(function(b){function m(){this._disabledInputs=[];this.regional=[];this.regional[""]={dateFormat:"mdy/",monthNames:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthNamesShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),dayNames:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),dayNamesShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),spinnerTexts:["Today","Previous field","Next field","Increment","Decrement"]}; this._defaults={appendText:"",initialField:0,useMouseWheel:!0,defaultDate:null,minDate:null,maxDate:null,spinnerImage:"spinnerDefault.png",spinnerSize:[20,20,8],spinnerBigImage:"",spinnerBigSize:[40,40,16],spinnerIncDecOnly:!1,spinnerRepeat:[500,250],beforeShow:null,altField:null,altFormat:null};b.extend(this._defaults,this.regional[""])}function l(a,c){b.extend(a,c);for(var d in c)null==c[d]&&(a[d]=null);return a}b.extend(m.prototype,{markerClassName:"hasDateEntry",setDefaults:function(a){l(this._defaults, a||{});return this},_connectDateEntry:function(a,c){var d=b(a);if(!d.hasClass(this.markerClassName)){var e={};e.options=b.extend({},c);e._selectedYear=0;e._selectedMonth=0;e._selectedDay=0;e._field=0;e.input=b(a);b.data(a,"dateEntry",e);var f=this._get(e,"spinnerImage");this._get(e,"spinnerText");var g=this._get(e,"spinnerSize"),h=this._get(e,"appendText"),f=!f?null:b('<span class="dateEntry_control" style="display: inline-block; background: url(\''+f+"') 0 0 no-repeat; width: "+g[0]+"px; height: "+ g[1]+"px;"+(b.browser.mozilla&&"1.9">b.browser.version?" padding-left: "+g[0]+"px; padding-bottom: "+(g[1]-18)+"px;":"")+'"></span>');d.wrap('<span class="dateEntry_wrap"></span>').after(h?'<span class="dateEntry_append">'+h+"</span>":"").after(f||"");d.addClass(this.markerClassName).bind("focus.dateEntry",this._doFocus).bind("blur.dateEntry",this._doBlur).bind("click.dateEntry",this._doClick).bind("keydown.dateEntry",this._doKeyDown).bind("keypress.dateEntry",this._doKeyPress);b.browser.mozilla&& d.bind("input.dateEntry",function(){b.dateEntry._parseDate(e)});b.browser.msie&&d.bind("paste.dateEntry",function(){setTimeout(function(){b.dateEntry._parseDate(e)},1)});this._get(e,"useMouseWheel")&&b.fn.mousewheel&&d.mousewheel(this._doMouseWheel);f&&f.mousedown(this._handleSpinner).mouseup(this._endSpinner).mouseover(this._expandSpinner).mouseout(this._endSpinner).mousemove(this._describeSpinner)}},_enableDateEntry:function(a){this._enableDisable(a,!1)},_disableDateEntry:function(a){this._enableDisable(a, !0)},_enableDisable:function(a,c){var d=b.data(a,"dateEntry");if(d)a.disabled=c,a.nextSibling&&"span"==a.nextSibling.nodeName.toLowerCase()&&b.dateEntry._changeSpinner(d,a.nextSibling,c?5:-1),b.dateEntry._disabledInputs=b.map(b.dateEntry._disabledInputs,function(c){return c==a?null:c}),c&&b.dateEntry._disabledInputs.push(a)},_isDisabledDateEntry:function(a){return-1<b.inArray(a,this._disabledInputs)},_changeDateEntry:function(a,c,d){var e=b.data(a,"dateEntry");if(e){var f=c;"string"==typeof c&&(f= {},f[c]=d);c=this._extractDate(e.input.val(),e);l(e.options,f||{});c&&this._setDate(e,c)}b.data(a,"dateEntry",e)},_destroyDateEntry:function(a){$input=b(a);if($input.hasClass(this.markerClassName))$input.removeClass(this.markerClassName).unbind(".dateEntry"),b.fn.mousewheel&&$input.unmousewheel(),this._disabledInputs=b.map(this._disabledInputs,function(c){return c==a?null:c}),$input.parent().replaceWith($input),b.removeData(a,"dateEntry")},_setDateDateEntry:function(a,c){var d=b.data(a,"dateEntry"); d&&(null===c||""===c?d.input.val(""):this._setDate(d,c?"object"==typeof c?new Date(c.getTime()):c:null))},_getDateDateEntry:function(a){return(a=b.data(a,"dateEntry"))?this._extractDate(a.input.val(),a):null},_doFocus:function(a){a=a.nodeName&&"input"==a.nodeName.toLowerCase()?a:this;if(b.dateEntry._lastInput==a||b.dateEntry._isDisabledDateEntry(a))b.dateEntry._focussed=!1;else{var c=b.data(a,"dateEntry");b.dateEntry._focussed=!0;b.dateEntry._lastInput=a;b.dateEntry._blurredInput=null;var d=b.dateEntry._get(c, "beforeShow");l(c.options,d?d.apply(a,[a]):{});b.data(a,"dateEntry",c);b.dateEntry._parseDate(c);setTimeout(function(){b.dateEntry._showField(c)},10)}},_doBlur:function(){b.dateEntry._blurredInput=b.dateEntry._lastInput;b.dateEntry._lastInput=null},_doClick:function(a){var c=a.target,d=b.data(c,"dateEntry");if(!b.dateEntry._focussed){var e=b.dateEntry._get(d,"dateFormat");d._field=0;if(null!=c.selectionStart)for(var f=0,a=0;3>a&&!(f+=b.dateEntry._fieldLength(d,a,e)+1,d._field=a,c.selectionStart<f);a++); else if(c.createTextRange)for(var f=b(a.srcElement),g=c.createTextRange(),a=a.clientX+document.documentElement.scrollLeft,h=f.offset().left,i=parseInt,f=f.css("border-left-width"),h=a-(h+i({thin:2,medium:4,thick:6}[f]||f,10))-g.offsetLeft,a=f=0;3>a&&!(f+=b.dateEntry._fieldLength(d,a,e)+1,g.collapse(),g.moveEnd("character",f),d._field=a,h<g.boundingWidth);a++);}b.data(c,"dateEntry",d);b.dateEntry._showField(d);b.dateEntry._focussed=!1},_doKeyDown:function(a){if(48<=a.keyCode)return!0;var c=b.data(a.target, "dateEntry");switch(a.keyCode){case 9:return a.shiftKey?b.dateEntry._changeField(c,-1,!0):b.dateEntry._changeField(c,1,!0);case 35:a.ctrlKey?b.dateEntry._setValue(c,""):(c._field=2,b.dateEntry._adjustField(c,0));break;case 36:a.ctrlKey?b.dateEntry._setDate(c):(c._field=0,b.dateEntry._adjustField(c,0));break;case 37:b.dateEntry._changeField(c,-1,!1);break;case 38:b.dateEntry._adjustField(c,1);break;case 39:b.dateEntry._changeField(c,1,!1);break;case 40:b.dateEntry._adjustField(c,-1);break;case 46:b.dateEntry._setValue(c, "")}return!1},_doKeyPress:function(a){var c=String.fromCharCode(void 0==a.charCode?a.keyCode:a.charCode);if(" ">c)return!0;a=b.data(a.target,"dateEntry");b.dateEntry._handleKeyPress(a,c);return!1},_doMouseWheel:function(a,c){if(!b.dateEntry._isDisabledDateEntry(a.target)){var c=b.browser.opera?-c/Math.abs(c):b.browser.safari?c/Math.abs(c):c,d=b.data(a.target,"dateEntry");d.input.focus();d.input.val()||b.dateEntry._parseDate(d);b.dateEntry._adjustField(d,c);a.preventDefault()}},_expandSpinner:function(a){var a= b.dateEntry._getSpinnerTarget(a),c=b.data(b.dateEntry._getInput(a),"dateEntry");if(!b.dateEntry._isDisabledDateEntry(c.input[0])){var d=b.dateEntry._get(c,"spinnerBigImage");if(d){c._expanded=!0;var e=b(a).offset(),f=null;b(a).parents().each(function(){var a=b(this);if("relative"==a.css("position")||"absolute"==a.css("position"))f=a.offset();return!f});var g=b.dateEntry._get(c,"spinnerSize"),c=b.dateEntry._get(c,"spinnerBigSize");b('<div class="dateEntry_expand" style="position: absolute; left: '+ (e.left-(c[0]-g[0])/2-(f?f.left:0))+"px; top: "+(e.top-(c[1]-g[1])/2-(f?f.top:0))+"px; width: "+c[0]+"px; height: "+c[1]+"px; background: transparent url("+d+') no-repeat 0px 0px; z-index: 10;"></div>').mousedown(b.dateEntry._handleSpinner).mouseup(b.dateEntry._endSpinner).mouseout(b.dateEntry._endExpand).mousemove(b.dateEntry._describeSpinner).insertAfter(a)}}},_getInput:function(a){return b(a).siblings("."+b.dateEntry.markerClassName)[0]},_describeSpinner:function(a){var c=b.dateEntry._getSpinnerTarget(a), d=b.data(b.dateEntry._getInput(c),"dateEntry");c.title=b.dateEntry._get(d,"spinnerTexts")[b.dateEntry._getSpinnerRegion(d,a)]},_handleSpinner:function(a){var c=b.dateEntry._getSpinnerTarget(a),d=b.dateEntry._getInput(c);if(!b.dateEntry._isDisabledDateEntry(d)){if(d==b.dateEntry._blurredInput)b.dateEntry._lastInput=d,b.dateEntry._blurredInput=null;var e=b.data(d,"dateEntry");b.dateEntry._doFocus(d);var f=b.dateEntry._getSpinnerRegion(e,a);b.dateEntry._changeSpinner(e,c,f);b.dateEntry._actionSpinner(e, f);b.dateEntry._timer=null;b.dateEntry._handlingSpinner=!0;a=b.dateEntry._get(e,"spinnerRepeat");if(3<=f&&a[0])b.dateEntry._timer=setTimeout(function(){b.dateEntry._repeatSpinner(e,f)},a[0]),b(c).one("mouseout",b.dateEntry._releaseSpinner).one("mouseup",b.dateEntry._releaseSpinner)}},_actionSpinner:function(a,c){a.input.val()||b.dateEntry._parseDate(a);switch(c){case 0:this._setDate(a);break;case 1:this._changeField(a,-1,!1);break;case 2:this._changeField(a,1,!1);break;case 3:this._adjustField(a, 1);break;case 4:this._adjustField(a,-1)}},_repeatSpinner:function(a,c){if(b.dateEntry._timer)b.dateEntry._lastInput=b.dateEntry._blurredInput,this._actionSpinner(a,c),this._timer=setTimeout(function(){b.dateEntry._repeatSpinner(a,c)},this._get(a,"spinnerRepeat")[1])},_releaseSpinner:function(){clearTimeout(b.dateEntry._timer);b.dateEntry._timer=null},_endExpand:function(a){b.dateEntry._timer=null;var a=b.dateEntry._getSpinnerTarget(a),c=b.dateEntry._getInput(a),c=b.data(c,"dateEntry");b(a).remove(); c._expanded=!1},_endSpinner:function(a){b.dateEntry._timer=null;var a=b.dateEntry._getSpinnerTarget(a),c=b.dateEntry._getInput(a),d=b.data(c,"dateEntry");b.dateEntry._isDisabledDateEntry(c)||b.dateEntry._changeSpinner(d,a,-1);if(b.dateEntry._handlingSpinner)b.dateEntry._lastInput=b.dateEntry._blurredInput;b.dateEntry._lastInput&&b.dateEntry._handlingSpinner&&b.dateEntry._showField(d);b.dateEntry._handlingSpinner=!1},_getSpinnerTarget:function(a){return a.target||a.srcElement},_getSpinnerRegion:function(a, c){var d=this._getSpinnerTarget(c),e=b.browser.opera||b.browser.safari?b.dateEntry._findPos(d):b(d).offset(),f=b.browser.safari?b.dateEntry._findScroll(d):[document.documentElement.scrollLeft||document.body.scrollLeft,document.documentElement.scrollTop||document.body.scrollTop],g=this._get(a,"spinnerIncDecOnly"),d=g?99:c.clientX+f[0]-e.left-(b.browser.msie?2:0),e=c.clientY+f[1]-e.top-(b.browser.msie?2:0),f=this._get(a,a._expanded?"spinnerBigSize":"spinnerSize"),g=g?99:f[0]-1-d,h=f[1]-1-e;if(0<f[2]&& Math.abs(d-g)<=f[2]&&Math.abs(e-h)<=f[2])return 0;f=Math.min(d,e,g,h);return f==d?1:f==g?2:f==e?3:4},_changeSpinner:function(a,c,d){b(c).css("background-position","-"+(d+1)*this._get(a,a._expanded?"spinnerBigSize":"spinnerSize")[0]+"px 0px")},_findPos:function(a){var c=curTop=0;if(a.offsetParent){c=a.offsetLeft;for(curTop=a.offsetTop;a=a.offsetParent;){var b=c,c=c+a.offsetLeft;0>c&&(c=b);curTop+=a.offsetTop}}return{left:c,top:curTop}},_findScroll:function(a){var c=!1;b(a).parents().each(function(){c|= "fixed"==b(this).css("position")});if(c)return[0,0];for(var d=a.scrollLeft,e=a.scrollTop;a=a.parentNode;)d+=a.scrollLeft||0,e+=a.scrollTop||0;return[d,e]},_get:function(a,c){return null!=a.options[c]?a.options[c]:b.dateEntry._defaults[c]},_parseDate:function(a){var c=this._extractDate(a.input.val(),a)||this._normaliseDate(this._determineDate(this._get(a,"defaultDate"),a)||new Date);a._selectedYear=c.getFullYear();a._selectedMonth=c.getMonth();a._selectedDay=c.getDate();a._lastChr="";a._field=Math.max(0, Math.min(2,this._get(a,"initialField")));""!=a.input.val()&&this._showDate(a)},_extractDate:function(a,c){for(var d=this._get(c,"dateFormat"),e=a.split(RegExp("[\\"+d.substr(-1).split("").join("\\")+"]")),f=c._selectedYear,g=c._selectedMonth+1,h=c._selectedDay,i=0,k=e.length;i<k;i++){var j=parseInt(e[i],10),j=isNaN(j)?0:j,l=d.charAt(i);switch(l){case "y":f=j;break;case "Y":f=j%100+((new Date).getFullYear()-(new Date).getFullYear()%100);break;case "m":g=j;break;case "n":case "N":g=b.inArray(e[i],this._get(c, "N"==l?"monthNames":"monthNamesShort"))+1;break;case "w":case "W":" "==d.charAt(3)?(e.splice(i,1),j=parseInt(e[i],10)):j=parseInt(e[i].substr(this._get(c,"W"==l?"dayNames":"dayNamesShort")[0].length+1),10),j=isNaN(j)?0:j;case "d":h=j}}return new Date(f,g-1,h,12)},_showDate:function(a){this._setValue(a,this._formatDate(a,this._get(a,"dateFormat")));this._showField(a)},_formatDate:function(a,c){for(var b="",e=0,f=c.length-1;e<f;e++){var b=b+(0==e?"":c.charAt(c.length-1)),g=c.charAt(e);switch(g){case "y":b+= this._formatNumber(a._selectedYear);break;case "Y":b+=this._formatNumber(a._selectedYear%100);break;case "m":b+=this._formatNumber(a._selectedMonth+1);break;case "n":case "N":b+=this._get(a,"N"==g?"monthNames":"monthNamesShort")[a._selectedMonth];break;case "d":b+=this._formatNumber(a._selectedDay);break;case "w":case "W":b+=this._get(a,"W"==g?"dayNames":"dayNamesShort")[(new Date(a._selectedYear,a._selectedMonth,a._selectedDay,12)).getDay()]+" "+this._formatNumber(a._selectedDay)}}return b},_showField:function(a){var c= a.input[0];if(!(a.input.is(":hidden")||b.dateEntry._lastInput!=c)){for(var d=this._get(a,"dateFormat"),e=0,f=0;f<a._field;f++)e+=this._fieldLength(a,f,d)+1;d=e+this._fieldLength(a,f,d);c.setSelectionRange?c.setSelectionRange(e,d):c.createTextRange&&(f=c.createTextRange(),f.moveStart("character",e),f.moveEnd("character",d-a.input.val().length),f.select());c.disabled||c.focus()}},_fieldLength:function(a,b,d){b=d.charAt(b);switch(b){case "y":return 4;case "n":case "N":return this._get(a,"N"==b?"monthNames": "monthNamesShort")[a._selectedMonth].length;case "w":case "W":return this._get(a,"W"==b?"dayNames":"dayNamesShort")[(new Date(a._selectedYear,a._selectedMonth,a._selectedDay,12)).getDay()].length+3;default:return 2}},_formatNumber:function(a){return(10>a?"0":"")+a},_setValue:function(a,c){if(c!=a.input.val()){var d=this._get(a,"altField");d&&b(d).val(!c?"":this._formatDate(a,this._get(a,"altFormat")||this._get(a,"dateFormat")));a.input.val(c).trigger("change")}},_changeField:function(a,c,d){var e= ""==a.input.val()||a._field==(-1==c?0:2);e||(a._field+=c);this._showField(a);a._lastChr="";b.data(a.input[0],"dateEntry",a);return e&&d},_adjustField:function(a,b){""==a.input.val()&&(b=0);var d=this._get(a,"dateFormat").charAt(a._field),e=a._selectedYear+("y"==d||"Y"==d?b:0),f=a._selectedMonth+("m"==d||"n"==d||"N"==d?b:0),d="d"==d||"w"==d||"W"==d?a._selectedDay+b:Math.min(a._selectedDay,this._getDaysInMonth(e,f));this._setDate(a,new Date(e,f,d,12))},_getDaysInMonth:function(a,b){return(new Date(a, b+1,0,12)).getDate()},_setDate:function(a,c){var c=this._normaliseDate(this._determineDate(c||this._get(a,"defaultDate"),a)||new Date),d=this._normaliseDate(this._determineDate(this._get(a,"minDate"),a)),e=this._normaliseDate(this._determineDate(this._get(a,"maxDate"),a)),c=d&&c<d?d:e&&c>e?e:c;a._selectedYear=c.getFullYear();a._selectedMonth=c.getMonth();a._selectedDay=c.getDate();this._showDate(a);b.data(a.input[0],"dateEntry",a)},_determineDate:function(a,c){var d=function(a){var c=b.dateEntry._normaliseDate(new Date); c.setDate(c.getDate()+a);return c};return a?"string"==typeof a?function(a){var d=b.dateEntry._extractDate(a,c);if(d)return d;for(var a=a.toLowerCase(),d=b.dateEntry._normaliseDate(new Date),g=d.getFullYear(),h=d.getMonth(),d=d.getDate(),i=/([+-]?[0-9]+)\s*(d|w|m|y)?/g,k=i.exec(a);k;){switch(k[2]||"d"){case "d":d+=parseInt(k[1],10);break;case "w":d+=7*parseInt(k[1],10);break;case "m":h+=parseInt(k[1],10);break;case "y":g+=parseInt(k[1],10)}k=i.exec(a)}return new Date(g,h,d,12)}(a):"number"==typeof a? d(a):a:null},_normaliseDate:function(a){a&&a.setHours(12,0,0,0);return a},_handleKeyPress:function(a,b){var d=this._get(a,"dateFormat");if(-1<d.substring(3).indexOf(b))this._changeField(a,1,!1);else if("0"<=b&&"9">=b){var e=d.charAt(a._field),f=parseInt(b,10),g=parseInt((a._lastChr||"")+b,10),h="y"!=e&&"Y"!=e?a._selectedYear:g,d="m"!=e&&"n"!=e&&"N"!=e?a._selectedMonth+1:1<=g&&12>=g?g:0<f?f:a._selectedMonth+1,f="d"!=e&&"w"!=e&&"W"!=e?a._selectedDay:1<=g&&g<=this._getDaysInMonth(h,d-1)?g:0<f?f:a._selectedDay; this._setDate(a,new Date(h,d-1,f,12));a._lastChr=("y"!=e?"":a._lastChr.substr(Math.max(0,a._lastChr.length-2)))+b}else if(e=d.charAt(a._field),"n"==e||"N"==e){a._lastChr+=b.toLowerCase();var i=this._get(a,"n"==e?"monthNamesShort":"monthNames"),e=function(){for(var b=0;b<i.length;b++)if(i[b].toLowerCase().substring(0,a._lastChr.length)==a._lastChr)return b;return-1},d=e();if(-1==d)a._lastChr=b.toLowerCase(),d=e();-1==d?a._lastChr="":(h=a._selectedYear,f=Math.min(a._selectedDay,this._getDaysInMonth(h, d)),this._setDate(a,new Date(h,d,f,12)))}}});b.fn.dateEntry=function(a){var c=Array.prototype.slice.call(arguments,1);return"string"==typeof a&&("isDisabled"==a||"getDate"==a)?b.dateEntry["_"+a+"DateEntry"].apply(b.dateEntry,[this[0]].concat(c)):this.each(function(){if("input"==this.nodeName.toLowerCase())if("string"==typeof a)b.dateEntry["_"+a+"DateEntry"].apply(b.dateEntry,[this].concat(c));else{var d=b.fn.metadata?b(this).metadata():{};b.dateEntry._connectDateEntry(this,b.extend(d,a))}})};b.dateEntry= new m})(jQuery);
\ No newline at end of file
+(function(b){function m(){this._disabledInputs=[];this.regional=[];this.regional[""]={dateFormat:"mdy/",monthNames:"January,February,March,April,May,June,July,August,September,October,November,December".split(","),monthNamesShort:"Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec".split(","),dayNames:"Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday".split(","),dayNamesShort:"Sun,Mon,Tue,Wed,Thu,Fri,Sat".split(","),spinnerTexts:["Today","Previous field","Next field","Increment","Decrement"]}; this._defaults={appendText:"",initialField:0,useMouseWheel:!0,defaultDate:null,minDate:null,maxDate:null,spinnerImage:"spinnerDefault.png",spinnerSize:[20,20,8],spinnerBigImage:"",spinnerBigSize:[40,40,16],spinnerIncDecOnly:!1,spinnerRepeat:[500,250],beforeShow:null,altField:null,altFormat:null};b.extend(this._defaults,this.regional[""])}function l(a,c){b.extend(a,c);for(var d in c)null==c[d]&&(a[d]=null);return a}b.extend(m.prototype,{markerClassName:"hasDateEntry",setDefaults:function(a){l(this._defaults, a||{});return this},_connectDateEntry:function(a,c){var d=b(a);if(!d.hasClass(this.markerClassName)){var e={};e.options=b.extend({},c);e._selectedYear=0;e._selectedMonth=0;e._selectedDay=0;e._field=0;e.input=b(a);b.data(a,"dateEntry",e);var f=this._get(e,"spinnerImage");this._get(e,"spinnerText");var g=this._get(e,"spinnerSize"),h=this._get(e,"appendText"),f=!f?null:b('<span class="dateEntry_control" style="display: inline-block; background: url(\''+f+"') 0 0 no-repeat; width: "+g[0]+"px; height: "+ g[1]+"px;"+(b.browser.mozilla&&"1.9">b.browser.version?" padding-left: "+g[0]+"px; padding-bottom: "+(g[1]-18)+"px;":"")+'"></span>');d.wrap('<span class="dateEntry_wrap"></span>').after(h?'<span class="dateEntry_append">'+h+"</span>":"").after(f||"");d.addClass(this.markerClassName).bind("focus.dateEntry",this._doFocus).bind("blur.dateEntry",this._doBlur).bind("click.dateEntry",this._doClick).bind("keydown.dateEntry",this._doKeyDown).bind("keypress.dateEntry",this._doKeyPress);b.browser.mozilla&& d.bind("input.dateEntry",function(){b.dateEntry._parseDate(e)});b.browser.msie&&d.bind("paste.dateEntry",function(){setTimeout(function(){b.dateEntry._parseDate(e)},1)});this._get(e,"useMouseWheel")&&b.fn.mousewheel&&d.mousewheel(this._doMouseWheel);f&&f.mousedown(this._handleSpinner).mouseup(this._endSpinner).mouseover(this._expandSpinner).mouseout(this._endSpinner).mousemove(this._describeSpinner)}},_enableDateEntry:function(a){this._enableDisable(a,!1)},_disableDateEntry:function(a){this._enableDisable(a, !0)},_enableDisable:function(a,c){var d=b.data(a,"dateEntry");if(d)a.disabled=c,a.nextSibling&&"span"==a.nextSibling.nodeName.toLowerCase()&&b.dateEntry._changeSpinner(d,a.nextSibling,c?5:-1),b.dateEntry._disabledInputs=b.map(b.dateEntry._disabledInputs,function(c){return c==a?null:c}),c&&b.dateEntry._disabledInputs.push(a)},_isDisabledDateEntry:function(a){return-1<b.inArray(a,this._disabledInputs)},_changeDateEntry:function(a,c,d){var e=b.data(a,"dateEntry");if(e){var f=c;"string"==typeof c&&(f= {},f[c]=d);c=this._extractDate(e.input.val(),e);l(e.options,f||{});c&&this._setDate(e,c)}b.data(a,"dateEntry",e)},_destroyDateEntry:function(a){$input=b(a);if($input.hasClass(this.markerClassName))$input.removeClass(this.markerClassName).unbind(".dateEntry"),b.fn.mousewheel&&$input.unmousewheel(),this._disabledInputs=b.map(this._disabledInputs,function(c){return c==a?null:c}),$input.parent().replaceWith($input),b.removeData(a,"dateEntry")},_setDateDateEntry:function(a,c){var d=b.data(a,"dateEntry"); d&&(null===c||""===c?d.input.val(""):this._setDate(d,c?"object"==typeof c?new Date(c.getTime()):c:null))},_getDateDateEntry:function(a){return(a=b.data(a,"dateEntry"))?this._extractDate(a.input.val(),a):null},_doFocus:function(a){a=a.nodeName&&"input"==a.nodeName.toLowerCase()?a:this;if(b.dateEntry._lastInput==a||b.dateEntry._isDisabledDateEntry(a))b.dateEntry._focussed=!1;else{var c=b.data(a,"dateEntry");b.dateEntry._focussed=!0;b.dateEntry._lastInput=a;b.dateEntry._blurredInput=null;var d=b.dateEntry._get(c, "beforeShow");l(c.options,d?d.apply(a,[a]):{});b.data(a,"dateEntry",c);b.dateEntry._parseDate(c);setTimeout(function(){b.dateEntry._showField(c)},10)}},_doBlur:function(){b.dateEntry._blurredInput=b.dateEntry._lastInput;b.dateEntry._lastInput=null},_doClick:function(a){var c=a.target,d=b.data(c,"dateEntry");if(!b.dateEntry._focussed){var e=b.dateEntry._get(d,"dateFormat");d._field=0;if(null!=c.selectionStart)for(var f=0,a=0;3>a&&!(f+=b.dateEntry._fieldLength(d,a,e)+1,d._field=a,c.selectionStart<f);a++); else if(c.createTextRange)for(var f=b(a.srcElement),g=c.createTextRange(),a=a.clientX+document.documentElement.scrollLeft,h=f.offset().left,i=parseInt,f=f.css("border-left-width"),h=a-(h+i({thin:2,medium:4,thick:6}[f]||f,10))-g.offsetLeft,a=f=0;3>a&&!(f+=b.dateEntry._fieldLength(d,a,e)+1,g.collapse(),g.moveEnd("character",f),d._field=a,h<g.boundingWidth);a++);}b.data(c,"dateEntry",d);b.dateEntry._showField(d);b.dateEntry._focussed=!1},_doKeyDown:function(a){if(48<=a.keyCode)return!0;var c=b.data(a.target, "dateEntry");switch(a.keyCode){case 9:return!0;case 35:a.ctrlKey?b.dateEntry._setValue(c,""):(c._field=2,b.dateEntry._adjustField(c,0));break;case 36:a.ctrlKey?b.dateEntry._setDate(c):(c._field=0,b.dateEntry._adjustField(c,0));break;case 37:b.dateEntry._changeField(c,-1,!1);break;case 38:b.dateEntry._adjustField(c,1);break;case 39:b.dateEntry._changeField(c,1,!1);break;case 40:b.dateEntry._adjustField(c,-1);break;case 46:b.dateEntry._setValue(c,"")}return!1},_doKeyPress:function(a){var c=String.fromCharCode(void 0== a.charCode?a.keyCode:a.charCode);if(" ">c)return!0;a=b.data(a.target,"dateEntry");b.dateEntry._handleKeyPress(a,c);return!1},_doMouseWheel:function(a,c){if(!b.dateEntry._isDisabledDateEntry(a.target)){var c=b.browser.opera?-c/Math.abs(c):b.browser.safari?c/Math.abs(c):c,d=b.data(a.target,"dateEntry");d.input.focus();d.input.val()||b.dateEntry._parseDate(d);b.dateEntry._adjustField(d,c);a.preventDefault()}},_expandSpinner:function(a){var a=b.dateEntry._getSpinnerTarget(a),c=b.data(b.dateEntry._getInput(a), "dateEntry");if(!b.dateEntry._isDisabledDateEntry(c.input[0])){var d=b.dateEntry._get(c,"spinnerBigImage");if(d){c._expanded=!0;var e=b(a).offset(),f=null;b(a).parents().each(function(){var a=b(this);if("relative"==a.css("position")||"absolute"==a.css("position"))f=a.offset();return!f});var g=b.dateEntry._get(c,"spinnerSize"),c=b.dateEntry._get(c,"spinnerBigSize");b('<div class="dateEntry_expand" style="position: absolute; left: '+(e.left-(c[0]-g[0])/2-(f?f.left:0))+"px; top: "+(e.top-(c[1]-g[1])/ 2-(f?f.top:0))+"px; width: "+c[0]+"px; height: "+c[1]+"px; background: transparent url("+d+') no-repeat 0px 0px; z-index: 10;"></div>').mousedown(b.dateEntry._handleSpinner).mouseup(b.dateEntry._endSpinner).mouseout(b.dateEntry._endExpand).mousemove(b.dateEntry._describeSpinner).insertAfter(a)}}},_getInput:function(a){return b(a).siblings("."+b.dateEntry.markerClassName)[0]},_describeSpinner:function(a){var c=b.dateEntry._getSpinnerTarget(a),d=b.data(b.dateEntry._getInput(c),"dateEntry");c.title= b.dateEntry._get(d,"spinnerTexts")[b.dateEntry._getSpinnerRegion(d,a)]},_handleSpinner:function(a){var c=b.dateEntry._getSpinnerTarget(a),d=b.dateEntry._getInput(c);if(!b.dateEntry._isDisabledDateEntry(d)){if(d==b.dateEntry._blurredInput)b.dateEntry._lastInput=d,b.dateEntry._blurredInput=null;var e=b.data(d,"dateEntry");b.dateEntry._doFocus(d);var f=b.dateEntry._getSpinnerRegion(e,a);b.dateEntry._changeSpinner(e,c,f);b.dateEntry._actionSpinner(e,f);b.dateEntry._timer=null;b.dateEntry._handlingSpinner= !0;a=b.dateEntry._get(e,"spinnerRepeat");if(3<=f&&a[0])b.dateEntry._timer=setTimeout(function(){b.dateEntry._repeatSpinner(e,f)},a[0]),b(c).one("mouseout",b.dateEntry._releaseSpinner).one("mouseup",b.dateEntry._releaseSpinner)}},_actionSpinner:function(a,c){a.input.val()||b.dateEntry._parseDate(a);switch(c){case 0:this._setDate(a);break;case 1:this._changeField(a,-1,!1);break;case 2:this._changeField(a,1,!1);break;case 3:this._adjustField(a,1);break;case 4:this._adjustField(a,-1)}},_repeatSpinner:function(a, c){if(b.dateEntry._timer)b.dateEntry._lastInput=b.dateEntry._blurredInput,this._actionSpinner(a,c),this._timer=setTimeout(function(){b.dateEntry._repeatSpinner(a,c)},this._get(a,"spinnerRepeat")[1])},_releaseSpinner:function(){clearTimeout(b.dateEntry._timer);b.dateEntry._timer=null},_endExpand:function(a){b.dateEntry._timer=null;var a=b.dateEntry._getSpinnerTarget(a),c=b.dateEntry._getInput(a),c=b.data(c,"dateEntry");b(a).remove();c._expanded=!1},_endSpinner:function(a){b.dateEntry._timer=null;var a= b.dateEntry._getSpinnerTarget(a),c=b.dateEntry._getInput(a),d=b.data(c,"dateEntry");b.dateEntry._isDisabledDateEntry(c)||b.dateEntry._changeSpinner(d,a,-1);if(b.dateEntry._handlingSpinner)b.dateEntry._lastInput=b.dateEntry._blurredInput;b.dateEntry._lastInput&&b.dateEntry._handlingSpinner&&b.dateEntry._showField(d);b.dateEntry._handlingSpinner=!1},_getSpinnerTarget:function(a){return a.target||a.srcElement},_getSpinnerRegion:function(a,c){var d=this._getSpinnerTarget(c),e=b.browser.opera||b.browser.safari? b.dateEntry._findPos(d):b(d).offset(),f=b.browser.safari?b.dateEntry._findScroll(d):[document.documentElement.scrollLeft||document.body.scrollLeft,document.documentElement.scrollTop||document.body.scrollTop],g=this._get(a,"spinnerIncDecOnly"),d=g?99:c.clientX+f[0]-e.left-(b.browser.msie?2:0),e=c.clientY+f[1]-e.top-(b.browser.msie?2:0),f=this._get(a,a._expanded?"spinnerBigSize":"spinnerSize"),g=g?99:f[0]-1-d,h=f[1]-1-e;if(0<f[2]&&Math.abs(d-g)<=f[2]&&Math.abs(e-h)<=f[2])return 0;f=Math.min(d,e,g,h); return f==d?1:f==g?2:f==e?3:4},_changeSpinner:function(a,c,d){b(c).css("background-position","-"+(d+1)*this._get(a,a._expanded?"spinnerBigSize":"spinnerSize")[0]+"px 0px")},_findPos:function(a){var c=curTop=0;if(a.offsetParent){c=a.offsetLeft;for(curTop=a.offsetTop;a=a.offsetParent;){var b=c,c=c+a.offsetLeft;0>c&&(c=b);curTop+=a.offsetTop}}return{left:c,top:curTop}},_findScroll:function(a){var c=!1;b(a).parents().each(function(){c|="fixed"==b(this).css("position")});if(c)return[0,0];for(var d=a.scrollLeft, e=a.scrollTop;a=a.parentNode;)d+=a.scrollLeft||0,e+=a.scrollTop||0;return[d,e]},_get:function(a,c){return null!=a.options[c]?a.options[c]:b.dateEntry._defaults[c]},_parseDate:function(a){var c=this._extractDate(a.input.val(),a)||this._normaliseDate(this._determineDate(this._get(a,"defaultDate"),a)||new Date);a._selectedYear=c.getFullYear();a._selectedMonth=c.getMonth();a._selectedDay=c.getDate();a._lastChr="";a._field=Math.max(0,Math.min(2,this._get(a,"initialField")));""!=a.input.val()&&this._showDate(a)}, _extractDate:function(a,c){for(var d=this._get(c,"dateFormat"),e=a.split(RegExp("[\\"+d.substr(-1).split("").join("\\")+"]")),f=c._selectedYear,g=c._selectedMonth+1,h=c._selectedDay,i=0,k=e.length;i<k;i++){var j=parseInt(e[i],10),j=isNaN(j)?0:j,l=d.charAt(i);switch(l){case "y":f=j;break;case "Y":f=j%100+((new Date).getFullYear()-(new Date).getFullYear()%100);break;case "m":g=j;break;case "n":case "N":g=b.inArray(e[i],this._get(c,"N"==l?"monthNames":"monthNamesShort"))+1;break;case "w":case "W":" "== d.charAt(3)?(e.splice(i,1),j=parseInt(e[i],10)):j=parseInt(e[i].substr(this._get(c,"W"==l?"dayNames":"dayNamesShort")[0].length+1),10),j=isNaN(j)?0:j;case "d":h=j}}return new Date(f,g-1,h,12)},_showDate:function(a){this._setValue(a,this._formatDate(a,this._get(a,"dateFormat")));this._showField(a)},_formatDate:function(a,c){for(var b="",e=0,f=c.length-1;e<f;e++){var b=b+(0==e?"":c.charAt(c.length-1)),g=c.charAt(e);switch(g){case "y":b+=this._formatNumber(a._selectedYear);break;case "Y":b+=this._formatNumber(a._selectedYear% 100);break;case "m":b+=this._formatNumber(a._selectedMonth+1);break;case "n":case "N":b+=this._get(a,"N"==g?"monthNames":"monthNamesShort")[a._selectedMonth];break;case "d":b+=this._formatNumber(a._selectedDay);break;case "w":case "W":b+=this._get(a,"W"==g?"dayNames":"dayNamesShort")[(new Date(a._selectedYear,a._selectedMonth,a._selectedDay,12)).getDay()]+" "+this._formatNumber(a._selectedDay)}}return b},_showField:function(a){var c=a.input[0];if(!(a.input.is(":hidden")||b.dateEntry._lastInput!=c)){for(var d= this._get(a,"dateFormat"),e=0,f=0;f<a._field;f++)e+=this._fieldLength(a,f,d)+1;d=e+this._fieldLength(a,f,d);c.setSelectionRange?c.setSelectionRange(e,d):c.createTextRange&&(f=c.createTextRange(),f.moveStart("character",e),f.moveEnd("character",d-a.input.val().length),f.select());c.disabled||c.focus()}},_fieldLength:function(a,b,d){b=d.charAt(b);switch(b){case "y":return 4;case "n":case "N":return this._get(a,"N"==b?"monthNames":"monthNamesShort")[a._selectedMonth].length;case "w":case "W":return this._get(a, "W"==b?"dayNames":"dayNamesShort")[(new Date(a._selectedYear,a._selectedMonth,a._selectedDay,12)).getDay()].length+3;default:return 2}},_formatNumber:function(a){return(10>a?"0":"")+a},_setValue:function(a,c){if(c!=a.input.val()){var d=this._get(a,"altField");d&&b(d).val(!c?"":this._formatDate(a,this._get(a,"altFormat")||this._get(a,"dateFormat")));a.input.val(c).trigger("change")}},_changeField:function(a,c,d){var e=""==a.input.val()||a._field==(-1==c?0:2);e||(a._field+=c);this._showField(a);a._lastChr= "";b.data(a.input[0],"dateEntry",a);return e&&d},_adjustField:function(a,b){""==a.input.val()&&(b=0);var d=this._get(a,"dateFormat").charAt(a._field),e=a._selectedYear+("y"==d||"Y"==d?b:0),f=a._selectedMonth+("m"==d||"n"==d||"N"==d?b:0),d="d"==d||"w"==d||"W"==d?a._selectedDay+b:Math.min(a._selectedDay,this._getDaysInMonth(e,f));this._setDate(a,new Date(e,f,d,12))},_getDaysInMonth:function(a,b){return(new Date(a,b+1,0,12)).getDate()},_setDate:function(a,c){var c=this._normaliseDate(this._determineDate(c|| this._get(a,"defaultDate"),a)||new Date),d=this._normaliseDate(this._determineDate(this._get(a,"minDate"),a)),e=this._normaliseDate(this._determineDate(this._get(a,"maxDate"),a)),c=d&&c<d?d:e&&c>e?e:c;a._selectedYear=c.getFullYear();a._selectedMonth=c.getMonth();a._selectedDay=c.getDate();this._showDate(a);b.data(a.input[0],"dateEntry",a)},_determineDate:function(a,c){var d=function(a){var c=b.dateEntry._normaliseDate(new Date);c.setDate(c.getDate()+a);return c};return a?"string"==typeof a?function(a){var d= b.dateEntry._extractDate(a,c);if(d)return d;for(var a=a.toLowerCase(),d=b.dateEntry._normaliseDate(new Date),g=d.getFullYear(),h=d.getMonth(),d=d.getDate(),i=/([+-]?[0-9]+)\s*(d|w|m|y)?/g,k=i.exec(a);k;){switch(k[2]||"d"){case "d":d+=parseInt(k[1],10);break;case "w":d+=7*parseInt(k[1],10);break;case "m":h+=parseInt(k[1],10);break;case "y":g+=parseInt(k[1],10)}k=i.exec(a)}return new Date(g,h,d,12)}(a):"number"==typeof a?d(a):a:null},_normaliseDate:function(a){a&&a.setHours(12,0,0,0);return a},_handleKeyPress:function(a, b){var d=this._get(a,"dateFormat");if(-1<d.substring(3).indexOf(b))this._changeField(a,1,!1);else if("0"<=b&&"9">=b){var e=d.charAt(a._field),f=parseInt(b,10),g=parseInt((a._lastChr||"")+b,10),h="y"!=e&&"Y"!=e?a._selectedYear:g,d="m"!=e&&"n"!=e&&"N"!=e?a._selectedMonth+1:1<=g&&12>=g?g:0<f?f:a._selectedMonth+1,f="d"!=e&&"w"!=e&&"W"!=e?a._selectedDay:1<=g&&g<=this._getDaysInMonth(h,d-1)?g:0<f?f:a._selectedDay;this._setDate(a,new Date(h,d-1,f,12));a._lastChr=("y"!=e?"":a._lastChr.substr(Math.max(0,a._lastChr.length- 2)))+b}else if(e=d.charAt(a._field),"n"==e||"N"==e){a._lastChr+=b.toLowerCase();var i=this._get(a,"n"==e?"monthNamesShort":"monthNames"),e=function(){for(var b=0;b<i.length;b++)if(i[b].toLowerCase().substring(0,a._lastChr.length)==a._lastChr)return b;return-1},d=e();if(-1==d)a._lastChr=b.toLowerCase(),d=e();-1==d?a._lastChr="":(h=a._selectedYear,f=Math.min(a._selectedDay,this._getDaysInMonth(h,d)),this._setDate(a,new Date(h,d,f,12)))}}});b.fn.dateEntry=function(a){var c=Array.prototype.slice.call(arguments, 1);return"string"==typeof a&&("isDisabled"==a||"getDate"==a)?b.dateEntry["_"+a+"DateEntry"].apply(b.dateEntry,[this[0]].concat(c)):this.each(function(){if("input"==this.nodeName.toLowerCase())if("string"==typeof a)b.dateEntry["_"+a+"DateEntry"].apply(b.dateEntry,[this].concat(c));else{var d=b.fn.metadata?b(this).metadata():{};b.dateEntry._connectDateEntry(this,b.extend(d,a))}})};b.dateEntry=new m})(jQuery);
\ No newline at end of file

Tags: b_vladi, js, livejournal, vkurkin
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