Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Workaround for buggy input type="date" in WebKit.

Webkit type="date" is a text input with tiny spinner arrows and no
datepicker.  Values are entered by the user by typing and optionally
using the spinner but are not validated. Thus, the UI does not req
ISO-8601 fmt. A feature check makes sure that ISO-8601 fmt is required
by setting non-ISO-8601 fmt and asserting that value is reset to "".
If the buggy input is there, then the type is reset. This causes a
problem, however, in that upon page refresh, the input type="date" is
restored and the user input is lost.
  • Loading branch information...
commit 4031c2bc08af50afb4834ba31ae171f31869f2a5 1 parent 23d194a
@GarrettS authored
View
2  build/widget/Calendar/Calendar-min.js
@@ -1 +1 @@
-APE.namespace("APE.widget").defineCustomFactory("Calendar",function(F){var A=document.createElement("input"),D=window.APE,E=D.dom,B=E.Event;D.widget.DelegateFactory.create(F,B,"focus");A.setAttribute("type","date");F.IS_NATIVE=/date/i.test(A.type);A=null;return C;function C(U){function W(AN,AM){this.id=AN;if(g){return}AM&&D.createMixin(this,AM);if(this.useAnim){this.hide=h}this._isHidden=true;this.initEvents()}function w(AN){var AM=document.getElementById(AN.id);return Q(AM.value)}function Q(AO){var AN=/^\s*(\d{4})-(\d\d)-(\d\d)\s*$/,AM=null,AQ,AP=AN.exec(AO);if(AP){AM=new Date(0);AQ=+AP[2];AM.setFullYear(AP[1],AQ-1,AP[3]);if(AQ===AM.getMonth()+1){AM.setHours(0,0,0,0)}else{AM=null}}return AM}var AD=Function.prototype,K=D.EventPublisher,AK=K.add,AE=K.remove,X=document.body,V=null,AC=typeof X.focus!=="undefined",AB="ape-calendar-focused-el",H="ape-calendar-selected-day",P=/-((?:next|prev)-(?:month|year))$/,k=/-next-|-prev-|-day\d/,u=/-day(\d+)$/,Z=E.key,g=U.IS_NATIVE,N=[31,28,31,30,31,30,31,31,30,31,30,31],l=D.anim,J=l.StyleTransition,e=0.1,AI={},Y={opacity:0.98,width:"14.4em",height:"14.4em",visibility:"visible"};function o(AO,AT){var AN=D.widget.CalendarLocale,AX=AO.displayDate;if(!AN){throw Error("Missing Resource: APE.widget.CalendarLocale")}p(AO);var AQ=document,AR=AX.getFullYear(),AP=AX.getMonth(),AV=AN.months.abbr[AP],AS=n(AX),AW=AQ.getElementById(AO.calendarId),AU=AW.getElementsByTagName("tbody")[0].getElementsByTagName("b"),AM=AQ.getElementById(AO.calendarId+"-header");AM.firstChild.data=AR+", "+AV;x(AO,AR,AP,AS,AU);AH(AO,AS,AU);if(AT){M(AO,AS+AX.getDate(),AU)}}function n(AM){AM=new Date(AM);AM.setDate(1);return AM.getDay()}function x(AP,AU,AT,AV,AW){var AQ=0,AO=0,AR=N[AT],AN,AS=AP.id+"-day",AM=(0==(AU%4))&&((0!=(AU%100))||(0==(AU%400)));if(AT===1&&AM){AR+=1}while(AQ<AV){AN=AW[AQ++];AN[E.TEXT_CONTENT]=" ";AN.className=AP.hiddenDayClass;AN.id=""}while(AO++<AR){AN=AW[AQ++];AN.id=AS+(AO-1);AN[E.TEXT_CONTENT]=AO+"";AN.tabIndex=-1;AN.className=""}for(AQ=AV+AR,AO=AW.length;AQ<AO;AQ++){AN=AW[AQ];AN[E.TEXT_CONTENT]=" ";AN.className=AP.hiddenDayClass}}function AH(AP,AM,AO){if(L(AP)){var AN=AM+new Date().getDate()-1;E.addClass(AO[AN],AP.calendarClass+"-today")}}function M(AP,AO,AN){if(L(AP)&&!AP.selectedId){var AM=AN[AO-1];E.addClass(AM,H);AP.selectedId=AM.id}}function L(AN){var AM=w(AN)||new Date;return AM!=null&&AN.displayDate.getYear()==AM.getYear()&&AN.displayDate.getMonth()==AM.getMonth()}function p(AP){if(!AP.calendarId){AP.calendarId=AP.id+"-calendar"}var AS=document;if(AS.getElementById(AP.calendarId)!==null){return}var AV=AS.createElement("div"),AU,AT=AS.getElementById(AP.id),AN=AT.parentNode,AQ=r(),AM=D.widget.CalendarLocale,AO=AM.days.abbr,AR="<thead><tr class='calendar-button-row'><th id='"+AP.id+"-prev-year' tabindex='0' title='"+AM.previousYear+"'>&#x00ab;</th><th id='"+AP.id+"-prev-month' tabindex='0' title='"+AM.previousMonth+"'>&#x2039;</th><th colspan='3' class='ape-calendar-header'><div id='"+AP.calendarId+"-header'>-</div></th><th id='"+AP.id+"-next-month' tabindex='0' title='"+AM.nextMonth+"' class='"+AP.calendarClass+"-days'>&#x203A;</th><th id='"+AP.id+"-next-year' tabindex='0' title='"+AM.nextYear+"'>&#x00bb;</th></tr><tr><th>"+AO.join("</th><th>")+"</th></tr></thead>";AV.onselectstart=AJ;AV.innerHTML="<table>"+AR+AQ+"</table>";AV.id=AP.calendarId;AV.className=AP.calendarClass;if(AP.useAnim){E.addClass(AV,"ape-calendar-anim-start")}AV.tabIndex=0;AV.onmousedown=AA;AV.onkeydown=T;AU=AV.firstChild;if("onfocusin" in AU){AU.onfocusin=b;AU.onfocusout=AF}AN.insertBefore(AV,AT.nextSibling)}function r(){var AP=[],AO=6,AM=[],AN;AP.length=8;AM.length=AO;AP=AP.join("<td><b>&nbsp;</b></td>");for(AN=0;AN<AO;AN++){AM[AN]="<tr id='w"+AN+1+"'>"+AP+"</tr>\n"}return"<tbody>"+AM.join("")+"</tbody>"}function b(AM){var AN=B.getTarget(AM);if(k.test(AN.id)&&AN!==null){E.addClass(AN,AB)}}function AF(AM){var AN=B.getTarget(AM);if(AN!==null){E.removeClass(AN,AB)}}function t(AN){AN=AN||window.event;var AO=U.getById(this.id),AM=document.getElementById(AO.id),AP=AN.relatedTarget||AN.fromElement;if(AO._isHidden&&(!AP||(AP!==AM&&!E.contains(AM,AP)))){G(AO,AN)}}function T(AN){AN=AN||window.event;var AQ=AN.keyCode,AM=this.id.replace(/-calendar$/,""),AP=U.getById(AM),AO;if(AQ===Z.ESC){if(!AP._isHidden){document.getElementById(AM).focus();setTimeout(function(){j(AP)},1)}}else{if(AQ===Z.ENTER){AO=B.getTarget(AN);I(this,AO)}else{if(AQ===Z.TAB){v(AP,AN)}else{if(Z.ARROW_KEY_EXP.test(AQ)){d(AP,AN,AQ)}}}}}function v(AR,AO){if(!AC){return}var AQ=B.getTarget(AO),AM=AO.shiftKey,AN=AR.id+"-prev-year",AS=AQ.id===AN,AP=AQ.id===AR.id+"-next-year";if(AM&&AS||!AM&&AP){B.preventDefault(AO)}else{if(AQ.tabIndex===-1&&AC){B.preventDefault(AO);document.getElementById(AN).focus()}}}function d(AS,AO,AR){var AQ=B.getTarget(AO),AP=AQ.id.match(u),AN,AM;if(AP){if(AR===Z.LEFT){AN=-1}else{if(AR===Z.RIGHT){AN=1}else{if(AR===Z.UP){AN=-7}else{if(AR===Z.DOWN){AN=7}}}}if(AN){AN=+AP[1]+AN}}else{AN=0}AM=document.getElementById(AS.id+"-day"+AN);if(AM){f(AM)}}function f(AM){if(AC){AM.tabIndex=0;AM.focus();AM.tabIndex=-1}}function G(AN){if(g){AN.onshow();return}AK(document,"onmousedown",i);AK(document,"onmouseup",AG);if(!AN._isHidden){return}if(V){j(V)}p(AN);AN._isHidden=false;var AM=document.getElementById(AN.calendarId),AO=AM.style;q(AN.id,AO);if(AN.useAnim){a(AN)}AN.onshow(AN);AN.show(AO);V=AN;AN.setDate(w(AN));O(AN,AM);AM.parentNode.style.zIndex="100"}function O(AN,AM){if(AC){if(AN.selectedId){setTimeout(function(){var AP=document.getElementById(AN.selectedId);try{AP.focus()}catch(AO){}finally{AN=AM=AP=null}},120)}else{AM.focus()}}}function q(AO,AQ){var AN=document.getElementById(AO),AM=AN.parentNode,AP=E.getOffsetCoords(AN,AM);AQ.left=AP.x+"px";AQ.top=AP.y+AN.offsetHeight+"px"}function j(AN){if(AN._isHidden){return}AN.onhide();if(g){return}var AM=document.getElementById(AN.calendarId);if(AM!==null){AN.hide(AM.style);AM.parentNode.style.zIndex=""}AN._isHidden=true}var R;function AA(AN){AN=AN||window.event;if(AN.button>1){return}var AO=B.getTarget(AN),AM=AO.id;if(k.test(AM)){I(this,AO);if(P.test(AM)){R=m(this,AM);if(R){R.startAfter(400)}}}}function m(AP,AM){var AN,AO=U.getById(AP.id.replace(/-calendar$/,""));if(l){if(!R){R=new l.Animation(3000)}R.run=function AN(){z(AO,AM)};AN=AP=null}return R}function I(AQ,AP){var AN,AO=AP.id,AM;AN=U.getById(AQ.id.replace(/-calendar$/,""));if(u.test(AO)){if(AN.hideOnSelect||AO!==AN.selectedId){AM=+AP.firstChild.data;if(AM){c(AN,AM,AP,AO)}}}else{if(P.test(AO)){z(AN,AO)}}}function c(AO,AM,AS,AN,AR){var AQ=document.getElementById(AO.selectedId),AP=H;if(AQ){E.removeClass(AQ,AP)}E.addClass(AS,AP);AO.selectedId=AS.id;AL(AO,AM);AO.onselect();if(AO.hideOnSelect){document.getElementById(AO.id).focus();setTimeout(function(){j(AO,AR);AO=AS=AQ=null},150)}}function z(AN,AP){var AM=new Date(AN.displayDate),AO=P.exec(AP)[1];if(AO==="next-year"){AM.setFullYear(AM.getFullYear()+1)}else{if(AO==="prev-year"){AM.setFullYear(AM.getFullYear()-1)}else{if(AO==="next-month"){AM.setMonth(AM.getMonth()+1)}else{if(AO==="prev-month"){AM.setMonth(AM.getMonth()-1)}}}}AN.setDate(AM)}function AL(AP,AM){var AN=AP.displayDate||new Date,AO;AN.setDate(AM);AO=s(AN);document.getElementById(AP.id).value=AO}function AJ(){return false}function s(AN){var AP=("000"+AN.getFullYear()).slice(-4),AO=("0"+(AN.getMonth()+1)).slice(-2),AM=("0"+(AN.getDate())).slice(-2);return AP+"-"+AO+"-"+AM}function y(AM){AM=AM||window.event;var AO=AM.keyCode,AN;if(AO===Z.ESC||AO===Z.ENTER){B.preventDefault(AM);AN=U.getById(this.id);if(AO===27){j(AN)}else{if(AO===Z.ENTER){if(AN._isHidden){G(AN)}else{j(AN)}}}}}function i(AN){if(!V){return}var AO=E.Event.getTarget(AN),AP=document,AM=AP.getElementById(V.calendarId);if(AO&&AO.id!==V.id&&!AM||!E.isOrContains(AM,AO)){j(V);V=null;AE(AP,"onmousedown",i);AE(AP,"onmouseup",AG)}}function AG(AM){R&&R.stop()}function S(AN){var AM=AI[AN];if(!AM){AM=AI[AN]=new J(AN,Y,e,l.Transitions.getSigmoid(3))}return AM}function a(AM){if(AM.useAnim){S(AM.calendarId).seekTo(1)}}function h(){if(this.useAnim){S(this.calendarId).seekTo(0)}}W.prototype={hideOnSelect:true,useAnim:true,initEvents:function(){if(g){return}var AN=document,AM=AN.getElementById(this.id);AK(AM,"onfocus",t);AK(AM,"onkeydown",y);AK(AM,"onclick",t)},purgeEvents:function(){var AN=document,AM=AN.getElementById(this.id);if(AM){AE(AM,"onfocus",t);AE(AM,"onkeydown",y);AE(AM,"onclick",t)}AE(AN,"onmousedown",i);AE(AN,"onmouseup",AG)},calendarId:"",hiddenDayClass:"ape-calendar-empty-day",calendarClass:"ape-calendar",show:function(AM){AM.visibility="visible"},hide:function(AM){AM.visibility="hidden"},isShown:function(AM){return AM.visibility==="visible"},onshow:AD,onhide:AD,onselect:AD,getDate:function(){return this.displayDate||w(this)},setDate:function(AN){if(g){document.getElementById(this.id).value=s(AN);return}var AM=AN!=null,AO=1000*60*60*24;AN=AM?new Date(AN):new Date;if(!this.displayDate||!this.selectedId||Math.abs(this.displayDate-AN.getTime())>AO){this.displayDate=AN;o(this,AM)}}};return W}});
+APE.namespace("APE.widget").defineCustomFactory("Calendar",function(F){var A=document.createElement("input"),D=window.APE,E=D.dom,B=E.Event;D.widget.DelegateFactory.create(F,B,"focus");A.setAttribute("type","date");A.value="24.12.2010";F.IS_NATIVE=A.value=="";A=null;return C;function C(U){function X(AP,AO){this.id=AP;if(h){return}AO&&D.createMixin(this,AO);if(this.useAnim){this.hide=i}this._isHidden=true;this.initEvents()}function y(AP){var AO=document.getElementById(AP.id);return Q(AO.value)}function Q(AQ){var AP=/^\s*(\d{4})-(\d\d)-(\d\d)\s*$/,AO=null,AS,AR=AP.exec(AQ);if(AR){AO=new Date(0);AS=+AR[2];AO.setFullYear(AR[1],AS-1,AR[3]);if(AS===AO.getMonth()+1){AO.setHours(0,0,0,0)}else{AO=null}}return AO}var AF=Function.prototype,K=D.EventPublisher,AM=K.add,AG=K.remove,Y=document.body,V=null,AE=typeof Y.focus!=="undefined",AD="ape-calendar-focused-el",H="ape-calendar-selected-day",P=/-((?:next|prev)-(?:month|year))$/,l=/-next-|-prev-|-day\d/,v=/-day(\d+)$/,a=E.key,h=U.IS_NATIVE,N=[31,28,31,30,31,30,31,31,30,31,30,31],m=D.anim,J=m.StyleTransition,f=0.1,AK={},W=/-calendar$/,Z={opacity:0.98,width:"14.4em",height:"14.4em",visibility:"visible"};function p(AQ,AV){var AP=D.widget.CalendarLocale,AZ=AQ.displayDate;if(!AP){throw Error("Missing Resource: APE.widget.CalendarLocale")}q(AQ);var AS=document,AT=AZ.getFullYear(),AR=AZ.getMonth(),AX=AP.months.abbr[AR],AU=o(AZ),AY=AS.getElementById(AQ.calendarId),AW=AY.getElementsByTagName("tbody")[0].getElementsByTagName("b"),AO=AS.getElementById(AQ.calendarId+"-header");AO.firstChild.data=AT+", "+AX;z(AQ,AT,AR,AU,AW);AJ(AQ,AU,AW);if(AV){M(AQ,AU+AZ.getDate(),AW)}}function o(AO){AO=new Date(AO);AO.setDate(1);return AO.getDay()}function z(AR,AW,AV,AX,AY){var AS=0,AQ=0,AT=N[AV],AP,AU=AR.id+"-day",AO=(0==(AW%4))&&((0!=(AW%100))||(0==(AW%400)));if(AV===1&&AO){AT+=1}while(AS<AX){AP=AY[AS++];AP[E.TEXT_CONTENT]=" ";AP.className=AR.hiddenDayClass;AP.id=""}while(AQ++<AT){AP=AY[AS++];AP.id=AU+(AQ-1);AP[E.TEXT_CONTENT]=AQ+"";AP.tabIndex=-1;AP.className=""}for(AS=AX+AT,AQ=AY.length;AS<AQ;AS++){AP=AY[AS];AP[E.TEXT_CONTENT]=" ";AP.className=AR.hiddenDayClass}}function AJ(AR,AO,AQ){if(L(AR)){var AP=AO+new Date().getDate()-1;E.addClass(AQ[AP],AR.calendarClass+"-today")}}function M(AR,AQ,AP){if(L(AR)&&!AR.selectedId){var AO=AP[AQ-1];E.addClass(AO,H);AR.selectedId=AO.id}}function L(AP){var AO=y(AP)||new Date;return AO!=null&&AP.displayDate.getYear()==AO.getYear()&&AP.displayDate.getMonth()==AO.getMonth()}function q(AR){if(!AR.calendarId){AR.calendarId=AR.id+"-calendar"}var AU=document;if(AU.getElementById(AR.calendarId)!==null){return}var AX=AU.createElement("div"),AW,AV=AU.getElementById(AR.id),AP=AV.parentNode,AS=s(),AO=D.widget.CalendarLocale,AQ=AO.days.abbr,AT="<thead><tr class='calendar-button-row'><th id='"+AR.id+"-prev-year' tabindex='0' title='"+AO.previousYear+"'>&#x00ab;</th><th id='"+AR.id+"-prev-month' tabindex='0' title='"+AO.previousMonth+"'>&#x2039;</th><th colspan='3' class='ape-calendar-header'><div id='"+AR.calendarId+"-header'>-</div></th><th id='"+AR.id+"-next-month' tabindex='0' title='"+AO.nextMonth+"' class='"+AR.calendarClass+"-days'>&#x203A;</th><th id='"+AR.id+"-next-year' tabindex='0' title='"+AO.nextYear+"'>&#x00bb;</th></tr><tr><th>"+AQ.join("</th><th>")+"</th></tr></thead>";AX.onselectstart=AL;AX.innerHTML="<table>"+AT+AS+"</table>";AX.id=AR.calendarId;AX.className=AR.calendarClass;if(AR.useAnim){E.addClass(AX,"ape-calendar-anim-start")}AX.tabIndex=0;AX.onmousedown=AC;AX.onkeydown=T;AW=AX.firstChild;if("onfocusin" in AW){AW.onfocusin=c;AW.onfocusout=AH}AP.insertBefore(AX,AV.nextSibling)}function s(){var AR=[],AQ=6,AO=[],AP;AR.length=8;AO.length=AQ;AR=AR.join("<td><b>&nbsp;</b></td>");for(AP=0;AP<AQ;AP++){AO[AP]="<tr id='w"+AP+1+"'>"+AR+"</tr>\n"}return"<tbody>"+AO.join("")+"</tbody>"}function c(AO){var AP=B.getTarget(AO);if(l.test(AP.id)&&AP!==null){E.addClass(AP,AD)}}function AH(AO){var AP=B.getTarget(AO);if(AP!==null){E.removeClass(AP,AD)}}function u(AP){AP=AP||window.event;var AQ=U.getById(this.id),AO=document.getElementById(AQ.id),AR=AP.relatedTarget||AP.fromElement;if(AQ._isHidden&&(!AR||(AR!==AO&&!E.contains(AO,AR)))){G(AQ,AP)}}function T(AP){AP=AP||window.event;var AS=AP.keyCode,AO=this.id.replace(/-calendar$/,""),AR=U.getById(AO),AQ;if(AS===a.ESC){if(!AR._isHidden){document.getElementById(AO).focus();setTimeout(function(){k(AR)},1)}}else{if(AS===a.ENTER){AQ=B.getTarget(AP);I(this,AQ)}else{if(AS===a.TAB){x(AR,AP)}else{if(a.ARROW_KEY_EXP.test(AS)){e(AR,AP,AS)}}}}}function x(AT,AQ){if(!AE){return}var AS=B.getTarget(AQ),AO=AQ.shiftKey,AP=AT.id+"-prev-year",AU=AS.id===AP,AR=AS.id===AT.id+"-next-year";if(AO&&AU||!AO&&AR){B.preventDefault(AQ)}else{if(AS.tabIndex===-1&&AE){B.preventDefault(AQ);document.getElementById(AP).focus()}}}function e(AU,AQ,AT){var AS=B.getTarget(AQ),AR=AS.id.match(v),AP,AO;if(AR){if(AT===a.LEFT){AP=-1}else{if(AT===a.RIGHT){AP=1}else{if(AT===a.UP){AP=-7}else{if(AT===a.DOWN){AP=7}}}}if(AP){AP=+AR[1]+AP}}else{AP=0}AO=document.getElementById(AU.id+"-day"+AP);if(AO){g(AO)}}function g(AO){if(AE){AO.tabIndex=0;AO.focus();AO.tabIndex=-1}}function G(AP){if(h){AP.onshow();return}AM(document,"onmousedown",j);AM(document,"onmouseup",AI);if(!AP._isHidden){return}if(V){k(V)}q(AP);AP._isHidden=false;var AO=document.getElementById(AP.calendarId),AQ=AO.style;r(AP.id,AQ);if(AP.useAnim){b(AP)}AP.onshow(AP);AP.show(AQ);V=AP;AP.setDate(y(AP));O(AP,AO);AO.parentNode.style.zIndex="100"}function w(AP){var AO=document.getElementById(AP);if(AO.type!="text"){AO.type="text"}}function O(AP,AO){if(AE){if(AP.selectedId){setTimeout(function(){var AR=document.getElementById(AP.selectedId);try{AR.focus()}catch(AQ){}finally{AP=AO=AR=null}},120)}else{AO.focus()}}}function r(AQ,AS){var AP=document.getElementById(AQ),AO=AP.parentNode,AR=E.getOffsetCoords(AP,AO);AS.left=AR.x+"px";AS.top=AR.y+AP.offsetHeight+"px"}function k(AP){if(AP._isHidden){return}AP.onhide();if(h){return}var AO=document.getElementById(AP.calendarId);if(AO!==null){AP.hide(AO.style);AO.parentNode.style.zIndex=""}AP._isHidden=true}var R;function AC(AP){AP=AP||window.event;if(AP.button>1){return}var AQ=B.getTarget(AP),AO=AQ.id;if(l.test(AO)){I(this,AQ);if(P.test(AO)){R=n(this,AO);if(R){R.startAfter(400)}}}w(this.id.replace(W,""))}function n(AR,AO){var AP,AQ=U.getById(AR.id.replace(W,""));if(m){if(!R){R=new m.Animation(3000)}R.run=function AP(){AB(AQ,AO)};AP=AR=null}return R}function I(AS,AR){var AP,AQ=AR.id,AO;AP=U.getById(AS.id.replace(/-calendar$/,""));if(v.test(AQ)){if(AP.hideOnSelect||AQ!==AP.selectedId){AO=+AR.firstChild.data;if(AO){d(AP,AO,AR,AQ)}}}else{if(P.test(AQ)){AB(AP,AQ)}}}function d(AQ,AO,AU,AP,AT){var AS=document.getElementById(AQ.selectedId),AR=H;if(AS){E.removeClass(AS,AR)}E.addClass(AU,AR);AQ.selectedId=AU.id;AN(AQ,AO);AQ.onselect();if(AQ.hideOnSelect){document.getElementById(AQ.id).focus();setTimeout(function(){k(AQ,AT);AQ=AU=AS=null},150)}}function AB(AP,AR){var AO=new Date(AP.displayDate),AQ=P.exec(AR)[1];if(AQ==="next-year"){AO.setFullYear(AO.getFullYear()+1)}else{if(AQ==="prev-year"){AO.setFullYear(AO.getFullYear()-1)}else{if(AQ==="next-month"){AO.setMonth(AO.getMonth()+1)}else{if(AQ==="prev-month"){AO.setMonth(AO.getMonth()-1)}}}}AP.setDate(AO)}function AN(AR,AO){var AP=AR.displayDate||new Date,AQ;AP.setDate(AO);AQ=t(AP);document.getElementById(AR.id).value=AQ}function AL(){return false}function t(AP){var AR=("000"+AP.getFullYear()).slice(-4),AQ=("0"+(AP.getMonth()+1)).slice(-2),AO=("0"+(AP.getDate())).slice(-2);return AR+"-"+AQ+"-"+AO}function AA(AO){AO=AO||window.event;var AQ=AO.keyCode,AP;if(AQ===a.ESC||AQ===a.ENTER){B.preventDefault(AO);AP=U.getById(this.id);if(AQ===27){k(AP)}else{if(AQ===a.ENTER){if(AP._isHidden){G(AP)}else{k(AP)}}}}}function j(AP){if(!V){return}var AQ=E.Event.getTarget(AP),AR=document,AO=AR.getElementById(V.calendarId);if(AQ&&AQ.id!==V.id&&!AO||!E.isOrContains(AO,AQ)){k(V);V=null;AG(AR,"onmousedown",j);AG(AR,"onmouseup",AI)}}function AI(AO){R&&R.stop()}function S(AP){var AO=AK[AP];if(!AO){AO=AK[AP]=new J(AP,Z,f,m.Transitions.getSigmoid(3))}return AO}function b(AO){if(AO.useAnim){S(AO.calendarId).seekTo(1)}}function i(){if(this.useAnim){S(this.calendarId).seekTo(0)}}X.prototype={hideOnSelect:true,useAnim:true,initEvents:function(){if(h){return}var AP=document,AO=AP.getElementById(this.id);AM(AO,"onfocus",u);AM(AO,"onkeydown",AA);AM(AO,"onclick",u)},purgeEvents:function(){var AP=document,AO=AP.getElementById(this.id);if(AO){AG(AO,"onfocus",u);AG(AO,"onkeydown",AA);AG(AO,"onclick",u)}AG(AP,"onmousedown",j);AG(AP,"onmouseup",AI)},calendarId:"",hiddenDayClass:"ape-calendar-empty-day",calendarClass:"ape-calendar",show:function(AO){AO.visibility="visible"},hide:function(AO){AO.visibility="hidden"},isShown:function(AO){return AO.visibility==="visible"},onshow:AF,onhide:AF,onselect:AF,getDate:function(){return this.displayDate||y(this)},setDate:function(AP){if(h){document.getElementById(this.id).value=t(AP);return}var AO=AP!=null,AQ=1000*60*60*24;AP=AO?new Date(AP):new Date;if(!this.displayDate||!this.selectedId||Math.abs(this.displayDate-AP.getTime())>AQ){this.displayDate=AP;p(this,AO)}}};return X}});
View
19 build/widget/Calendar/Calendar.js
@@ -20,8 +20,10 @@ APE.namespace("APE.widget").defineCustomFactory(
// Augment Calendar.
APE.widget.DelegateFactory.create(Calendar, Event, "focus" /*defaultMatcher*/);
+ // https://bugs.webkit.org/show_bug.cgi?id=29359#c2
inputTypeDate.setAttribute("type", "date");
- Calendar.IS_NATIVE = /date/i.test(inputTypeDate.type);
+ inputTypeDate.value = "24.12.2010"
+ Calendar.IS_NATIVE = inputTypeDate.value == "";
inputTypeDate = null;
return getConstructor;
@@ -97,6 +99,7 @@ APE.namespace("APE.widget").defineCustomFactory(
duration = .1,
styleTransitionObjects = {},
+ inputIdExp = /-calendar$/,
// Add a style transition to show() and hide() the calendar.
endStyle = {
opacity: .98,
@@ -424,11 +427,18 @@ APE.namespace("APE.widget").defineCustomFactory(
activeCalendar = calendar;
calendar.setDate(readDateFromInput(calendar));
focusCalendar(calendar, calendarEl);
-
// IE Needs this for showing calendar over other elements.
calendarEl.parentNode.style.zIndex = "100";
}
+ function makeDateInputText(id) {
+ // Buggy UI for Webkit type=date
+ // https://bugs.webkit.org/show_bug.cgi?id=29359#c1
+ // Remove type *after* calendar is shown.
+ var input = document.getElementById(id);
+ if (input.type != "text") input.type = "text";
+ }
+
/** Try to focus the selected day, but if not possible, focus the calendar. */
function focusCalendar(calendar, calendarEl){
if(CAN_FOCUS_EL) {
@@ -508,6 +518,7 @@ APE.namespace("APE.widget").defineCustomFactory(
}
}
}
+ makeDateInputText(this.id.replace(inputIdExp,""));
}
/** @return {APE.anim.Animation|undefined} monthYearAnim.
@@ -517,7 +528,7 @@ APE.namespace("APE.widget").defineCustomFactory(
*/
function tryGetMonthYearAnim(calendarDiv, targetId){
var runMonthYearAnim,
- calendar = Calendar.getById(calendarDiv.id.replace(/-calendar$/,""));
+ calendar = Calendar.getById(calendarDiv.id.replace(inputIdExp,""));
if(anim) {
if(!monthYearAnim){
@@ -657,7 +668,7 @@ APE.namespace("APE.widget").defineCustomFactory(
activeCalendar = null;
removeCallback(d, "onmousedown", calDocumentMouseDownHandler);
removeCallback(d, "onmouseup", calDocumentMouseUpHandler);
- }
+ }
}
function calDocumentMouseUpHandler(ev){
View
19 src/widget/calendar/Calendar.js
@@ -20,8 +20,10 @@ APE.namespace("APE.widget").defineCustomFactory(
// Augment Calendar.
APE.widget.DelegateFactory.create(Calendar, Event, "focus" /*defaultMatcher*/);
+ // https://bugs.webkit.org/show_bug.cgi?id=29359#c2
inputTypeDate.setAttribute("type", "date");
- Calendar.IS_NATIVE = /date/i.test(inputTypeDate.type);
+ inputTypeDate.value = "24.12.2010"
+ Calendar.IS_NATIVE = inputTypeDate.value == "";
inputTypeDate = null;
return getConstructor;
@@ -97,6 +99,7 @@ APE.namespace("APE.widget").defineCustomFactory(
duration = .1,
styleTransitionObjects = {},
+ inputIdExp = /-calendar$/,
// Add a style transition to show() and hide() the calendar.
endStyle = {
opacity: .98,
@@ -424,11 +427,18 @@ APE.namespace("APE.widget").defineCustomFactory(
activeCalendar = calendar;
calendar.setDate(readDateFromInput(calendar));
focusCalendar(calendar, calendarEl);
-
// IE Needs this for showing calendar over other elements.
calendarEl.parentNode.style.zIndex = "100";
}
+ function makeDateInputText(id) {
+ // Buggy UI for Webkit type=date
+ // https://bugs.webkit.org/show_bug.cgi?id=29359#c1
+ // Remove type *after* calendar is shown.
+ var input = document.getElementById(id);
+ if (input.type != "text") input.type = "text";
+ }
+
/** Try to focus the selected day, but if not possible, focus the calendar. */
function focusCalendar(calendar, calendarEl){
if(CAN_FOCUS_EL) {
@@ -508,6 +518,7 @@ APE.namespace("APE.widget").defineCustomFactory(
}
}
}
+ makeDateInputText(this.id.replace(inputIdExp,""));
}
/** @return {APE.anim.Animation|undefined} monthYearAnim.
@@ -517,7 +528,7 @@ APE.namespace("APE.widget").defineCustomFactory(
*/
function tryGetMonthYearAnim(calendarDiv, targetId){
var runMonthYearAnim,
- calendar = Calendar.getById(calendarDiv.id.replace(/-calendar$/,""));
+ calendar = Calendar.getById(calendarDiv.id.replace(inputIdExp,""));
if(anim) {
if(!monthYearAnim){
@@ -657,7 +668,7 @@ APE.namespace("APE.widget").defineCustomFactory(
activeCalendar = null;
removeCallback(d, "onmousedown", calDocumentMouseDownHandler);
removeCallback(d, "onmouseup", calDocumentMouseUpHandler);
- }
+ }
}
function calDocumentMouseUpHandler(ev){
Please sign in to comment.
Something went wrong with that request. Please try again.