1 | define([ |
---|
2 | "dojo/_base/kernel", |
---|
3 | "dojo/_base/declare", |
---|
4 | "dojo/dom-class", |
---|
5 | "dojo/dom-construct", |
---|
6 | "dijit/form/_ComboBoxMenuMixin", |
---|
7 | "dijit/_WidgetBase", |
---|
8 | "./_ListTouchMixin", |
---|
9 | "./scrollable", |
---|
10 | "dojo/has", |
---|
11 | "dojo/has!dojo-bidi?dojox/mobile/bidi/_ComboBoxMenu" |
---|
12 | ], |
---|
13 | function(dojo, declare, domClass, domConstruct, ComboBoxMenuMixin, WidgetBase, ListTouchMixin, Scrollable, has, BidiComboBoxMenu){ |
---|
14 | // module: |
---|
15 | // dojox/mobile/_ComboBoxMenu |
---|
16 | |
---|
17 | var _ComboBoxMenu = declare(has("dojo-bidi") ? "dojox.mobile._NonBidiComboBoxMenu" : "dojox.mobile._ComboBoxMenu", [WidgetBase, ListTouchMixin, ComboBoxMenuMixin], { |
---|
18 | // summary: |
---|
19 | // Focus-less menu for internal use in dojox/mobile/ComboBox. |
---|
20 | // Abstract methods that must be defined externally: |
---|
21 | // |
---|
22 | // - onChange: item was explicitly chosen (mousedown somewhere on the menu and mouseup somewhere on the menu); |
---|
23 | // - onPage: next(1) or previous(-1) button pressed. |
---|
24 | // tags: |
---|
25 | // private |
---|
26 | |
---|
27 | // baseClass: String |
---|
28 | // The name of the CSS class of this widget. |
---|
29 | baseClass: "mblComboBoxMenu", |
---|
30 | |
---|
31 | // bgIframe: [private] Boolean |
---|
32 | // Flag to prevent the creation of a background iframe, when appropriate. For internal usage. |
---|
33 | bgIframe: true, // so it's not created for IE and FF |
---|
34 | |
---|
35 | buildRendering: function(){ |
---|
36 | this.domNode = this.focusNode = domConstruct.create("div", { "class":"mblReset" }); |
---|
37 | this.containerNode = domConstruct.create("div", { style: { position:"absolute", top:0, left:0 } }, this.domNode); // needed for scrollable |
---|
38 | this.previousButton = domConstruct.create("div", { "class":"mblReset mblComboBoxMenuItem mblComboBoxMenuPreviousButton", role:"option" }, this.containerNode); |
---|
39 | this.nextButton = domConstruct.create("div", { "class":"mblReset mblComboBoxMenuItem mblComboBoxMenuNextButton", role:"option" }, this.containerNode); |
---|
40 | this.inherited(arguments); |
---|
41 | }, |
---|
42 | |
---|
43 | _createMenuItem: function(){ |
---|
44 | // override of the method from dijit/form/_ComboBoxMenu. |
---|
45 | return domConstruct.create("div", { |
---|
46 | "class": "mblReset mblComboBoxMenuItem" +(this.isLeftToRight() ? "" : " mblComboBoxMenuItemRtl"), |
---|
47 | role: "option" |
---|
48 | }); |
---|
49 | }, |
---|
50 | |
---|
51 | onSelect: function(/*DomNode*/ node){ |
---|
52 | // summary: |
---|
53 | // Add selected CSS. |
---|
54 | domClass.add(node, "mblComboBoxMenuItemSelected"); |
---|
55 | }, |
---|
56 | |
---|
57 | onDeselect: function(/*DomNode*/ node){ |
---|
58 | // summary: |
---|
59 | // Remove selected CSS. |
---|
60 | domClass.remove(node, "mblComboBoxMenuItemSelected"); |
---|
61 | }, |
---|
62 | |
---|
63 | onOpen: function(){ |
---|
64 | // summary: |
---|
65 | // Called when the menu opens. |
---|
66 | this.scrollable.init({ |
---|
67 | domNode: this.domNode, |
---|
68 | containerNode: this.containerNode |
---|
69 | }); |
---|
70 | this.scrollable.scrollTo({x:0, y:0}); |
---|
71 | }, |
---|
72 | |
---|
73 | onClose: function(){ |
---|
74 | // summary: |
---|
75 | // Called when the menu closes. |
---|
76 | this.scrollable.cleanup(); |
---|
77 | }, |
---|
78 | |
---|
79 | destroyRendering: function(){ |
---|
80 | this.bgIframe = false; // no iframe to destroy |
---|
81 | this.inherited(arguments); |
---|
82 | }, |
---|
83 | |
---|
84 | postCreate: function(){ |
---|
85 | this.inherited(arguments); |
---|
86 | this.scrollable = new Scrollable(); |
---|
87 | this.scrollable.resize = function(){}; // resize changes the height rudely |
---|
88 | } |
---|
89 | }); |
---|
90 | return has("dojo-bidi") ? declare("dojox.mobile._ComboBoxMenu", [_ComboBoxMenu, BidiComboBoxMenu]) : _ComboBoxMenu; |
---|
91 | }); |
---|