source: Dev/branches/rest-dojo-ui/client/dojox/mobile/_ComboBoxMenu.js @ 256

Last change on this file since 256 was 256, checked in by hendrikvanantwerpen, 13 years ago

Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).

File size: 2.6 KB
Line 
1define([
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        /*=====
14                ComboBoxMenuMixin = dijit.form._ComboBoxMenuMixin;
15                WidgetBase = dijit._WidgetBase;
16                ListTouchMixin = dojox.mobile._ListTouchMixin;
17        =====*/
18        return declare("dojox.mobile._ComboBoxMenu", [WidgetBase, ListTouchMixin, ComboBoxMenuMixin], {
19                // summary:
20                //              Focus-less menu for internal use in `dijit.form.ComboBox`
21                //              Abstract methods that must be defined externally:
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: "mblComboBoxMenu",
28                bgIframe: true, // so it's not created for IE and FF
29
30                buildRendering: function(){
31                        this.domNode = this.focusNode = domConstruct.create("div", { "class":"mblReset" });
32                        this.containerNode = domConstruct.create("div", { style: { position:"absolute", top:0, left:0 } }, this.domNode); // needed for scrollable
33                        this.previousButton = domConstruct.create("div", { "class":"mblReset mblComboBoxMenuItem mblComboBoxMenuPreviousButton", role:"option" }, this.containerNode);
34                        this.nextButton = domConstruct.create("div", { "class":"mblReset mblComboBoxMenuItem mblComboBoxMenuNextButton", role:"option" }, this.containerNode);
35                        this.inherited(arguments);
36                },
37
38                _createMenuItem: function(){
39                        return domConstruct.create("div", {
40                                "class": "mblReset mblComboBoxMenuItem" +(this.isLeftToRight() ? "" : " mblComboBoxMenuItemRtl"),
41                                role: "option"
42                        });
43                },
44
45                onSelect: function(/*DomNode*/ node){
46                        // summary:
47                        //              Add selected CSS
48                        domClass.add(node, "mblComboBoxMenuItemSelected");
49                },
50
51                onDeselect: function(/*DomNode*/ node){
52                        // summary:
53                        //              Remove selected CSS
54                        domClass.remove(node, "mblComboBoxMenuItemSelected");
55                },
56
57                onOpen: function(){
58                        this.scrollable.init({
59                                domNode: this.domNode,
60                                containerNode: this.containerNode
61                        });
62                        this.scrollable.scrollTo({x:0, y:0});
63                },
64
65                onClose: function(){
66                        this.scrollable.cleanup();
67                },
68
69                destroyRendering: function(){
70                        this.bgIframe = false; // no iframe to destroy
71                        this.inherited(arguments);
72                },
73
74                postCreate: function(){
75                        this.inherited(arguments);
76                        this.scrollable = new Scrollable(dojo, dojox);
77                        this.scrollable.resize = function(){}; // resize changes the height rudely
78                        this.scrollable.androidWorkaroud = false; // disable Android workaround
79                }
80        });
81});
Note: See TracBrowser for help on using the repository browser.