Mechanical rename of base::debug -> base::trace_event [final pass]
[chromium-blink-merge.git] / third_party / polymer / components-chromium / core-dropdown / core-dropdown-base-extracted.js
blobdd33d67aab58a07cec8521e6e141ebb292ba372b
3   Polymer('core-dropdown-base',{
5     publish: {
7       /**
8        * True if the menu is open.
9        *
10        * @attribute opened
11        * @type boolean
12        * @default false
13        */
14       opened: false
16     },
18     eventDelegates: {
19       'tap': 'toggleOverlay'
20     },
22     overlayListeners: {
23       'core-overlay-open': 'openAction'
24     },
26     get dropdown() {
27       if (!this._dropdown) {
28         this._dropdown = this.querySelector('.dropdown');
29         for (var l in this.overlayListeners) {
30           this.addElementListener(this._dropdown, l, this.overlayListeners[l]);
31         }
32       }
33       return this._dropdown;
34     },
36     attached: function() {
37       // find the dropdown on attach
38       // FIXME: Support MO?
39       this.dropdown;
40     },
42     addElementListener: function(node, event, methodName, capture) {
43       var fn = this._makeBoundListener(methodName);
44       if (node && fn) {
45         Polymer.addEventListener(node, event, fn, capture);
46       }
47     },
49     removeElementListener: function(node, event, methodName, capture) {
50       var fn = this._makeBoundListener(methodName);
51       if (node && fn) {
52         Polymer.removeEventListener(node, event, fn, capture);
53       }
54     },
56     _makeBoundListener: function(methodName) {
57       var self = this, method = this[methodName];
58       if (!method) {
59         return;
60       }
61       var bound = '_bound' + methodName;
62       if (!this[bound]) {
63         this[bound] = function(e) {
64           method.call(self, e);
65         };
66       }
67       return this[bound];
68     },
70     openedChanged: function() {
71       if (this.disabled) {
72         return;
73       }
74       var dropdown = this.dropdown;
75       if (dropdown) {
76         dropdown.opened = this.opened;
77       }
78     },
80     openAction: function(e) {
81       this.opened = !!e.detail;
82     },
84     toggleOverlay: function() {
85       this.opened = !this.opened;
86     }
88   });