| OLD | NEW |
| (Empty) |
| 1 <!-- | |
| 2 Copyright (c) 2014 The Polymer Project Authors. All rights reserved. | |
| 3 This code may only be used under the BSD style license found at http://polymer.g
ithub.io/LICENSE.txt | |
| 4 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt | |
| 5 The complete set of contributors may be found at http://polymer.github.io/CONTRI
BUTORS.txt | |
| 6 Code distributed by Google as part of the polymer project is also | |
| 7 subject to an additional IP rights grant found at http://polymer.github.io/PATEN
TS.txt | |
| 8 --> | |
| 9 | |
| 10 <!-- | |
| 11 | |
| 12 `core-dropdown` is an element that is initially hidden and is positioned relativ
ely to another | |
| 13 element, usually the element that triggers the dropdown. The dropdown and the tr
iggering element | |
| 14 should be children of the same offsetParent, e.g. the same `<div>` with `positio
n: relative`. | |
| 15 It can be used to implement dropdown menus, menu buttons, etc.. | |
| 16 | |
| 17 Example: | |
| 18 | |
| 19 <template is="auto-binding"> | |
| 20 <div relative> | |
| 21 <core-icon-button id="trigger" icon="menu"></core-icon-button> | |
| 22 <core-dropdown relatedTarget="{{$.trigger}}"> | |
| 23 <core-menu> | |
| 24 <core-item>Cut</core-item> | |
| 25 <core-item>Copy</core-item> | |
| 26 <core-item>Paste</core-item> | |
| 27 </core-menu> | |
| 28 </core-dropdown> | |
| 29 </div> | |
| 30 </template> | |
| 31 | |
| 32 Positioning | |
| 33 ----------- | |
| 34 | |
| 35 By default, the dropdown is absolutely positioned on top of the `relatedTarget`
with the top and | |
| 36 left edges aligned. The `halign` and `valign` properties controls the various al
ignments. The size | |
| 37 of the dropdown is automatically restrained such that it is entirely visible on
the screen. Use the | |
| 38 `margin` | |
| 39 | |
| 40 If you need more control over the dropdown's position, use CSS. The `halign` and
`valign` properties are | |
| 41 ignored if the dropdown is positioned with CSS. | |
| 42 | |
| 43 Example: | |
| 44 | |
| 45 <style> | |
| 46 /* manually position the dropdown below the trigger */ | |
| 47 core-dropdown { | |
| 48 position: absolute; | |
| 49 top: 38px; | |
| 50 left: 0; | |
| 51 } | |
| 52 </style> | |
| 53 | |
| 54 <template is="auto-binding"> | |
| 55 <div relative> | |
| 56 <core-icon-button id="trigger" icon="menu"></core-icon-button> | |
| 57 <core-dropdown relatedTarget="{{$.trigger}}"> | |
| 58 <core-menu> | |
| 59 <core-item>Cut</core-item> | |
| 60 <core-item>Copy</core-item> | |
| 61 <core-item>Paste</core-item> | |
| 62 </core-menu> | |
| 63 </core-dropdown> | |
| 64 </div> | |
| 65 </template> | |
| 66 | |
| 67 @group Polymer Core Elements | |
| 68 @element core-dropdown | |
| 69 @homepage github.io | |
| 70 --> | |
| 71 <link href="../polymer/polymer.html" rel="import"> | |
| 72 | |
| 73 <link href="core-dropdown-overlay.html" rel="import"> | |
| 74 | |
| 75 <polymer-element name="core-dropdown"> | |
| 76 <template> | |
| 77 | |
| 78 <link href="core-dropdown.css" rel="stylesheet"> | |
| 79 | |
| 80 <core-dropdown-overlay id="overlay" target="{{}}" relatedTarget="{{relatedTarg
et}}" opened="{{opened}}" halign="{{halign}}" valign="{{valign}}" margin="{{marg
in}}" transition="{{transition}}" autoFocusDisabled="{{autoFocusDisabled}}"></co
re-dropdown-overlay> | |
| 81 | |
| 82 <content></content> | |
| 83 | |
| 84 </template> | |
| 85 <script> | |
| 86 | |
| 87 Polymer({ | |
| 88 | |
| 89 publish: { | |
| 90 | |
| 91 /** | |
| 92 * The element associated with this dropdown, usually the element that tri
ggers | |
| 93 * the menu. | |
| 94 * | |
| 95 * @attribute relatedTarget | |
| 96 * @type Node | |
| 97 */ | |
| 98 relatedTarget: null, | |
| 99 | |
| 100 /** | |
| 101 * If true, the menu is currently visible. | |
| 102 * | |
| 103 * @attribute opened | |
| 104 * @type boolean | |
| 105 * @default false | |
| 106 */ | |
| 107 opened: false, | |
| 108 | |
| 109 /** | |
| 110 * The horizontal alignment of the popup relative to `relatedTarget`. `lef
t` | |
| 111 * means the left edges are aligned together. `right` means the right edge
s | |
| 112 * are aligned together. | |
| 113 * | |
| 114 * @attribute halign | |
| 115 * @type 'left' | 'right' | |
| 116 * @default 'left' | |
| 117 */ | |
| 118 halign: 'left', | |
| 119 | |
| 120 /** | |
| 121 * The vertical alignment of the popup relative to `relatedTarget`. `top`
means | |
| 122 * the top edges are aligned together. `bottom` means the bottom edges are | |
| 123 * aligned together. | |
| 124 * | |
| 125 * @attribute valign | |
| 126 * @type 'top' | 'bottom' | |
| 127 * @default 'top' | |
| 128 */ | |
| 129 valign: 'top', | |
| 130 | |
| 131 /** | |
| 132 * By default an overlay will focus its target or an element inside | |
| 133 * it with the `autoFocus` attribute. Disable this | |
| 134 * behavior by setting the `autoFocusDisabled` property to true. | |
| 135 * | |
| 136 * @attribute autoFocusDisabled | |
| 137 * @type boolean | |
| 138 * @default false | |
| 139 */ | |
| 140 autoFocusDisabled: false, | |
| 141 | |
| 142 /** | |
| 143 * The transition property specifies a string which identifies a | |
| 144 * <a href="../core-transition/">`core-transition`</a> element that | |
| 145 * will be used to help the overlay open and close. The default | |
| 146 * `core-transition-fade` will cause the overlay to fade in and out. | |
| 147 * | |
| 148 * @attribute transition | |
| 149 * @type string | |
| 150 * @default null | |
| 151 */ | |
| 152 transition: null | |
| 153 | |
| 154 } | |
| 155 | |
| 156 }); | |
| 157 | |
| 158 </script> | |
| 159 </polymer-element> | |
| OLD | NEW |