Last active
August 29, 2015 13:57
-
-
Save edm00se/9819138 to your computer and use it in GitHub Desktop.
This provides an XPages way of failing over on mobile devices to use the native / mobile browser's date/time controls with correct formatting to save back into a Notes Document as the correct Notes Item type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
mobileLib.isMobile() returns boolean of whether the current device's user agent string | |
matches a mobile browser (iPhone, iPad, iPod, Android, etc.) | |
modified version of src: http://openntf.org/XSnippets.nsf/snippet.xsp?id=read-user-agent | |
dateTimeLib.dateFormatMobile = (!mobileLib.isMobile()?"MM/dd/yy":"yyyy-MM-dd"); | |
dateTimeLib.timeFormatMobile = (!mobileLib.isMobile()?"hh:mm a z":"hh:mm"); | |
--> | |
<xp:inputText | |
id="someDateField" | |
value="#{document1.MyDate}" | |
defaultValue="${javascript:!mobileLib.isMobile()?@Today():null}" | |
type="date" | |
disableClientSideValidation="true"> | |
<xp:this.converter> | |
<xp:convertDateTime | |
pattern="${javascript:return !mobileLib.isMobile()?dateTimeLib.dateFormatUI:dateTimeLib.dateFormatMobile;}" | |
type="date"> | |
</xp:convertDateTime> | |
</xp:this.converter> | |
<xp:dateTimeHelper | |
id="dateTimeHelper1" | |
loaded="${javascript:return !mobileLib.isMobile()?true:false;}"> | |
</xp:dateTimeHelper> | |
</xp:inputText> | |
<xp:inputText | |
id="someTimeField" | |
value="#{document1.MyTime}" | |
type="time" | |
disableClientSideValidation="true" | |
style="min-width:6em;min-height:1em;" | |
defaultValue="${javascript:!mobileLib.isMobile()?@Now():null}"> | |
<xp:this.converter> | |
<xp:convertDateTime | |
pattern="${javascript:return !mobileLib.isMobile()?dateTimeLib.timeFormatUI:dateTimeLib.timeFormatMobile;" | |
type="time"> | |
</xp:convertDateTime> | |
</xp:this.converter> | |
<xp:dateTimeHelper | |
id="dateTimeHelper2" | |
loaded="${javascript:return !mobileLib.isMobile()?true:false;}"> | |
</xp:dateTimeHelper> | |
</xp:inputText> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment