_ComboBoxMenu.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. define("dojox/mobile/_ComboBoxMenu", [
  2. "dojo/_base/kernel",
  3. "dojo/_base/declare",
  4. "dojo/dom-class",
  5. "dojo/dom-construct",
  6. "dijit/form/_ComboBoxMenuMixin",
  7. "dijit/_WidgetBase",
  8. "dojox/mobile/_ListTouchMixin",
  9. "./scrollable"
  10. ],
  11. function(dojo, declare, domClass, domConstruct, ComboBoxMenuMixin, WidgetBase, ListTouchMixin, Scrollable){
  12. /*=====
  13. ComboBoxMenuMixin = dijit.form._ComboBoxMenuMixin;
  14. WidgetBase = dijit._WidgetBase;
  15. ListTouchMixin = dojox.mobile._ListTouchMixin;
  16. =====*/
  17. return declare("dojox.mobile._ComboBoxMenu", [WidgetBase, ListTouchMixin, ComboBoxMenuMixin], {
  18. // summary:
  19. // Focus-less menu for internal use in `dijit.form.ComboBox`
  20. // Abstract methods that must be defined externally:
  21. // onChange: item was explicitly chosen (mousedown somewhere on the menu and mouseup somewhere on the menu)
  22. // onPage: next(1) or previous(-1) button pressed
  23. // tags:
  24. // private
  25. baseClass: "mblComboBoxMenu",
  26. bgIframe: true, // so it's not created for IE and FF
  27. buildRendering: function(){
  28. this.domNode = this.focusNode = domConstruct.create("div", { "class":"mblReset" });
  29. this.containerNode = domConstruct.create("div", { style: { position:"absolute", top:0, left:0 } }, this.domNode); // needed for scrollable
  30. this.previousButton = domConstruct.create("div", { "class":"mblReset mblComboBoxMenuItem mblComboBoxMenuPreviousButton", role:"option" }, this.containerNode);
  31. this.nextButton = domConstruct.create("div", { "class":"mblReset mblComboBoxMenuItem mblComboBoxMenuNextButton", role:"option" }, this.containerNode);
  32. this.inherited(arguments);
  33. },
  34. _createMenuItem: function(){
  35. return domConstruct.create("div", {
  36. "class": "mblReset mblComboBoxMenuItem" +(this.isLeftToRight() ? "" : " mblComboBoxMenuItemRtl"),
  37. role: "option"
  38. });
  39. },
  40. onSelect: function(/*DomNode*/ node){
  41. // summary:
  42. // Add selected CSS
  43. domClass.add(node, "mblComboBoxMenuItemSelected");
  44. },
  45. onDeselect: function(/*DomNode*/ node){
  46. // summary:
  47. // Remove selected CSS
  48. domClass.remove(node, "mblComboBoxMenuItemSelected");
  49. },
  50. onOpen: function(){
  51. this.scrollable.init({
  52. domNode: this.domNode,
  53. containerNode: this.containerNode
  54. });
  55. this.scrollable.scrollTo({x:0, y:0});
  56. },
  57. onClose: function(){
  58. this.scrollable.cleanup();
  59. },
  60. destroyRendering: function(){
  61. this.bgIframe = false; // no iframe to destroy
  62. this.inherited(arguments);
  63. },
  64. postCreate: function(){
  65. this.inherited(arguments);
  66. this.scrollable = new Scrollable(dojo, dojox);
  67. this.scrollable.resize = function(){}; // resize changes the height rudely
  68. this.scrollable.androidWorkaroud = false; // disable Android workaround
  69. }
  70. });
  71. });