Skip to content

Instantly share code, notes, and snippets.

@edm00se
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edm00se/9789653 to your computer and use it in GitHub Desktop.
Save edm00se/9789653 to your computer and use it in GitHub Desktop.
Dojo implementation of the "improved user interaction with XPages date picker" script (jQuery) by Marky Roden (src: http://xomino.com/2012/03/14/improving-user-interaction-with-xpages-date-picker/). This uses pure Dojo (which can prevent the need to load another library, if you're already using Dojo). This is used and tested with Dojo v. 1.6.1. …
/*
* Dojo version of the improved behavior of the XPages calendar picker.
* Adapted from the jQuery version, originally by Marky Roden.
* credit: http://xomino.com/2012/03/14/improving-user-interaction-with-xpages-date-picker/
* Adapted by Eric McCormick, @edm00se, http://about.me/EricMcCormick
*/
dojo.addOnLoad(function(){
//id has _Container and is class of xspInputFieldDateTimePicker
var myAr = dojo.query("[id$=_Container].xspInputFieldDateTimePicker");
//iterate over each element to apply affect
myAr.forEach(function(node, index, arr){
//current root node, based on id$=_Container
var curNode = node;
//span for the button to fire the picker
var myBtn = dojo.query('> span > span > span.dijitButtonContents',curNode)[0];
//actual <input> element into which is focused/typed
var myInputFld = dojo.query('> div > div.dijitInputField > input.dijitInputInner',curNode)[0];
//connect the focus event to the picker click event
dojo.connect(myInputFld,"onfocus",function(){myBtn.click()});
//provide an onkeypress preventDefault
dojo.connect(myInputFld,"onkeypress",function(evt){evt.preventDefault()});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment