Home | History | Annotate | Download | only in paper-dropdown
      1 <!doctype html>
      2 <!--
      3 Copyright (c) 2014 The Polymer Project Authors. All rights reserved.
      4 This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
      5 The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
      6 The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
      7 Code distributed by Google as part of the polymer project is also
      8 subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
      9 -->
     10 
     11 <html>
     12 <head>
     13 
     14   <meta charset="utf-8">
     15   <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
     16   <meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1.0, user-scalable=yes">
     17 
     18   <title>paper-dropdown</title>
     19 
     20   <script src="../webcomponentsjs/webcomponents.js"></script>
     21 
     22   <link href="../core-collapse/core-collapse.html" rel="import">
     23   <link href="../core-icons/core-icons.html" rel="import">
     24   <link href="../paper-icon-button/paper-icon-button.html" rel="import">
     25   <link href="../paper-item/paper-item.html" rel="import">
     26 
     27   <link href="paper-dropdown.html" rel="import">
     28 
     29   <style shim-shadowdom>
     30     body {
     31       font-family: RobotoDraft, 'Helvetica Neue', Helvetica, Arial;
     32       font-size: 14px;
     33       margin: 0;
     34       padding: 24px;
     35       -webkit-tap-highlight-color: rgba(0,0,0,0);
     36       -webkit-touch-callout: none;
     37     }
     38 
     39     section {
     40       padding: 20px 0;
     41     }
     42 
     43     section > div {
     44       padding: 14px;
     45       font-size: 16px;
     46     }
     47 
     48     x-trigger {
     49       z-index: auto;
     50     }
     51 
     52     html /deep/ paper-dropdown:not(.no-padding)::shadow #scroller {
     53       box-sizing: border-box;
     54       padding: 8px;
     55     }
     56 
     57     .with-margin {
     58       margin: 12px;
     59     }
     60 
     61     .open-below {
     62       top: 38px;
     63     }
     64 
     65   </style>
     66 
     67 </head>
     68 <body>
     69 
     70   <polymer-element name="x-trigger" extends="paper-icon-button" relative on-tap="{{toggle}}" noink>
     71   <template>
     72     <shadow></shadow>
     73     <content></content>
     74   </template>
     75   <script>
     76     Polymer({
     77       toggle: function() {
     78         if (!this.dropdown) {
     79           this.dropdown = this.querySelector('paper-dropdown');
     80         }
     81         this.dropdown && this.dropdown.toggle();
     82       }
     83     });
     84   </script>
     85   </polymer-element>
     86 
     87   <template is="auto-binding">
     88 
     89     <section>
     90 
     91       <div>Absolutely positioned dropdowns</div>
     92 
     93       <x-trigger icon="menu">
     94         <paper-dropdown>
     95           halign = left
     96           <br>
     97           valign = top
     98         </paper-dropdown>
     99       </x-trigger>
    100 
    101       <x-trigger icon="menu">
    102         <paper-dropdown valign="bottom">
    103           halign = left
    104           <br>
    105           valign = bottom
    106         </paper-dropdown>
    107       </x-trigger>
    108 
    109       <x-trigger icon="menu">
    110         <paper-dropdown halign="right">
    111           halign = right
    112           <br>
    113           valign = top
    114         </paper-dropdown>
    115       </x-trigger>
    116 
    117       <x-trigger icon="menu">
    118         <paper-dropdown class="no-padding">
    119           <div class="menu">
    120             <paper-item>Item 1</paper-item>
    121             <paper-item>Item 2</paper-item>
    122             <paper-item>Item 3</paper-item>
    123           </div>
    124         </paper-dropdown>
    125       </x-trigger>
    126 
    127     </section>
    128 
    129     <section>
    130 
    131       <div>Layered dropdowns</div>
    132 
    133       <button onclick="document.getElementById('collapse').toggle()">toggle core-collapse</button>
    134 
    135       <br>
    136 
    137       <core-collapse id="collapse">
    138 
    139         <x-trigger icon="menu">
    140           <paper-dropdown layered>
    141             halign = left
    142             <br>
    143             valign = top
    144           </paper-dropdown>
    145         </x-trigger>
    146 
    147       </core-collapse>
    148 
    149     </section>
    150 
    151     <section>
    152 
    153       <div>Scrolling and margin</div>
    154 
    155       <x-trigger icon="menu">
    156         <paper-dropdown>
    157           no margin<br>
    158           <br>
    159           <template repeat="{{countries}}">
    160             {{name}}<br>
    161           </template>
    162         </paper-dropdown>
    163       </x-trigger>
    164 
    165       <x-trigger icon="menu">
    166         <paper-dropdown class="with-margin">
    167           with margin<br>
    168           <br>
    169           <template repeat="{{countries}}">
    170             {{name}}<br>
    171           </template>
    172         </paper-dropdown>
    173       </x-trigger>
    174 
    175     </section>
    176 
    177     <section>
    178 
    179       <div>Custom position</div>
    180 
    181       <x-trigger icon="menu">
    182         <paper-dropdown class="open-below">
    183           top: 38px
    184         </paper-dropdown>
    185       </x-trigger>
    186 
    187     </section>
    188 
    189   </template>
    190 
    191   <script>
    192 
    193     scope = document.querySelector('template[is=auto-binding]');
    194 
    195     scope.countries = [
    196       {name: 'Afghanistan', code: 'AF'},
    197       {name: 'land Islands', code: 'AX'},
    198       {name: 'Albania', code: 'AL'},
    199       {name: 'Algeria', code: 'DZ'},
    200       {name: 'American Samoa', code: 'AS'},
    201       {name: 'Andorra', code: 'AD'},
    202       {name: 'Angola', code: 'AO'},
    203       {name: 'Anguilla', code: 'AI'},
    204       {name: 'Antarctica', code: 'AQ'},
    205       {name: 'Antigua and Barbuda', code: 'AG'},
    206       {name: 'Argentina', code: 'AR'},
    207       {name: 'Armenia', code: 'AM'},
    208       {name: 'Aruba', code: 'AW'},
    209       {name: 'Australia', code: 'AU'},
    210       {name: 'Austria', code: 'AT'},
    211       {name: 'Azerbaijan', code: 'AZ'},
    212       {name: 'Bahamas', code: 'BS'},
    213       {name: 'Bahrain', code: 'BH'},
    214       {name: 'Bangladesh', code: 'BD'},
    215       {name: 'Barbados', code: 'BB'},
    216       {name: 'Belarus', code: 'BY'},
    217       {name: 'Belgium', code: 'BE'},
    218       {name: 'Belize', code: 'BZ'},
    219       {name: 'Benin', code: 'BJ'},
    220       {name: 'Bermuda', code: 'BM'},
    221       {name: 'Bhutan', code: 'BT'},
    222       {name: 'Bolivia', code: 'BO'},
    223       {name: 'Bosnia and Herzegovina', code: 'BA'},
    224       {name: 'Botswana', code: 'BW'},
    225       {name: 'Bouvet Island', code: 'BV'},
    226       {name: 'Brazil', code: 'BR'},
    227       {name: 'British Indian Ocean Territory', code: 'IO'},
    228       {name: 'Brunei Darussalam', code: 'BN'},
    229       {name: 'Bulgaria', code: 'BG'},
    230       {name: 'Burkina Faso', code: 'BF'},
    231       {name: 'Burundi', code: 'BI'},
    232       {name: 'Cambodia', code: 'KH'},
    233       {name: 'Cameroon', code: 'CM'},
    234       {name: 'Canada', code: 'CA'},
    235       {name: 'Cape Verde', code: 'CV'},
    236       {name: 'Cayman Islands', code: 'KY'},
    237       {name: 'Central African Republic', code: 'CF'},
    238       {name: 'Chad', code: 'TD'},
    239       {name: 'Chile', code: 'CL'},
    240       {name: 'China', code: 'CN'},
    241       {name: 'Christmas Island', code: 'CX'},
    242       {name: 'Cocos (Keeling) Islands', code: 'CC'},
    243       {name: 'Colombia', code: 'CO'},
    244       {name: 'Comoros', code: 'KM'},
    245       {name: 'Congo', code: 'CG'},
    246       {name: 'Congo, The Democratic Republic of the', code: 'CD'},
    247       {name: 'Cook Islands', code: 'CK'},
    248       {name: 'Costa Rica', code: 'CR'},
    249       {name: 'Cote D\'Ivoire', code: 'CI'},
    250       {name: 'Croatia', code: 'HR'},
    251       {name: 'Cuba', code: 'CU'},
    252       {name: 'Cyprus', code: 'CY'},
    253       {name: 'Czech Republic', code: 'CZ'},
    254       {name: 'Denmark', code: 'DK'},
    255       {name: 'Djibouti', code: 'DJ'},
    256       {name: 'Dominica', code: 'DM'},
    257       {name: 'Dominican Republic', code: 'DO'},
    258       {name: 'Ecuador', code: 'EC'},
    259       {name: 'Egypt', code: 'EG'},
    260       {name: 'El Salvador', code: 'SV'},
    261       {name: 'Equatorial Guinea', code: 'GQ'},
    262       {name: 'Eritrea', code: 'ER'},
    263       {name: 'Estonia', code: 'EE'},
    264       {name: 'Ethiopia', code: 'ET'},
    265       {name: 'Falkland Islands (Malvinas)', code: 'FK'},
    266       {name: 'Faroe Islands', code: 'FO'},
    267       {name: 'Fiji', code: 'FJ'},
    268       {name: 'Finland', code: 'FI'},
    269       {name: 'France', code: 'FR'},
    270       {name: 'French Guiana', code: 'GF'},
    271       {name: 'French Polynesia', code: 'PF'},
    272       {name: 'French Southern Territories', code: 'TF'},
    273       {name: 'Gabon', code: 'GA'},
    274       {name: 'Gambia', code: 'GM'},
    275       {name: 'Georgia', code: 'GE'},
    276       {name: 'Germany', code: 'DE'},
    277       {name: 'Ghana', code: 'GH'},
    278       {name: 'Gibraltar', code: 'GI'},
    279       {name: 'Greece', code: 'GR'},
    280       {name: 'Greenland', code: 'GL'},
    281       {name: 'Grenada', code: 'GD'},
    282       {name: 'Guadeloupe', code: 'GP'},
    283       {name: 'Guam', code: 'GU'},
    284       {name: 'Guatemala', code: 'GT'},
    285       {name: 'Guernsey', code: 'GG'},
    286       {name: 'Guinea', code: 'GN'},
    287       {name: 'Guinea-Bissau', code: 'GW'},
    288       {name: 'Guyana', code: 'GY'},
    289       {name: 'Haiti', code: 'HT'},
    290       {name: 'Heard Island and Mcdonald Islands', code: 'HM'},
    291       {name: 'Holy See (Vatican City State)', code: 'VA'},
    292       {name: 'Honduras', code: 'HN'},
    293       {name: 'Hong Kong', code: 'HK'},
    294       {name: 'Hungary', code: 'HU'},
    295       {name: 'Iceland', code: 'IS'},
    296       {name: 'India', code: 'IN'},
    297       {name: 'Indonesia', code: 'ID'},
    298       {name: 'Iran, Islamic Republic Of', code: 'IR'},
    299       {name: 'Iraq', code: 'IQ'},
    300       {name: 'Ireland', code: 'IE'},
    301       {name: 'Isle of Man', code: 'IM'},
    302       {name: 'Israel', code: 'IL'},
    303       {name: 'Italy', code: 'IT'},
    304       {name: 'Jamaica', code: 'JM'},
    305       {name: 'Japan', code: 'JP'},
    306       {name: 'Jersey', code: 'JE'},
    307       {name: 'Jordan', code: 'JO'},
    308       {name: 'Kazakhstan', code: 'KZ'},
    309       {name: 'Kenya', code: 'KE'},
    310       {name: 'Kiribati', code: 'KI'},
    311       {name: 'Korea, Democratic People\'S Republic of', code: 'KP'},
    312       {name: 'Korea, Republic of', code: 'KR'},
    313       {name: 'Kuwait', code: 'KW'},
    314       {name: 'Kyrgyzstan', code: 'KG'},
    315       {name: 'Lao People\'S Democratic Republic', code: 'LA'},
    316       {name: 'Latvia', code: 'LV'},
    317       {name: 'Lebanon', code: 'LB'},
    318       {name: 'Lesotho', code: 'LS'},
    319       {name: 'Liberia', code: 'LR'},
    320       {name: 'Libyan Arab Jamahiriya', code: 'LY'},
    321       {name: 'Liechtenstein', code: 'LI'},
    322       {name: 'Lithuania', code: 'LT'},
    323       {name: 'Luxembourg', code: 'LU'},
    324       {name: 'Macao', code: 'MO'},
    325       {name: 'Macedonia, The Former Yugoslav Republic of', code: 'MK'},
    326       {name: 'Madagascar', code: 'MG'},
    327       {name: 'Malawi', code: 'MW'},
    328       {name: 'Malaysia', code: 'MY'},
    329       {name: 'Maldives', code: 'MV'},
    330       {name: 'Mali', code: 'ML'},
    331       {name: 'Malta', code: 'MT'},
    332       {name: 'Marshall Islands', code: 'MH'},
    333       {name: 'Martinique', code: 'MQ'},
    334       {name: 'Mauritania', code: 'MR'},
    335       {name: 'Mauritius', code: 'MU'},
    336       {name: 'Mayotte', code: 'YT'},
    337       {name: 'Mexico', code: 'MX'},
    338       {name: 'Micronesia, Federated States of', code: 'FM'},
    339       {name: 'Moldova, Republic of', code: 'MD'},
    340       {name: 'Monaco', code: 'MC'},
    341       {name: 'Mongolia', code: 'MN'},
    342       {name: 'Montserrat', code: 'MS'},
    343       {name: 'Morocco', code: 'MA'},
    344       {name: 'Mozambique', code: 'MZ'},
    345       {name: 'Myanmar', code: 'MM'},
    346       {name: 'Namibia', code: 'NA'},
    347       {name: 'Nauru', code: 'NR'},
    348       {name: 'Nepal', code: 'NP'},
    349       {name: 'Netherlands', code: 'NL'},
    350       {name: 'Netherlands Antilles', code: 'AN'},
    351       {name: 'New Caledonia', code: 'NC'},
    352       {name: 'New Zealand', code: 'NZ'},
    353       {name: 'Nicaragua', code: 'NI'},
    354       {name: 'Niger', code: 'NE'},
    355       {name: 'Nigeria', code: 'NG'},
    356       {name: 'Niue', code: 'NU'},
    357       {name: 'Norfolk Island', code: 'NF'},
    358       {name: 'Northern Mariana Islands', code: 'MP'},
    359       {name: 'Norway', code: 'NO'},
    360       {name: 'Oman', code: 'OM'},
    361       {name: 'Pakistan', code: 'PK'},
    362       {name: 'Palau', code: 'PW'},
    363       {name: 'Palestinian Territory, Occupied', code: 'PS'},
    364       {name: 'Panama', code: 'PA'},
    365       {name: 'Papua New Guinea', code: 'PG'},
    366       {name: 'Paraguay', code: 'PY'},
    367       {name: 'Peru', code: 'PE'},
    368       {name: 'Philippines', code: 'PH'},
    369       {name: 'Pitcairn', code: 'PN'},
    370       {name: 'Poland', code: 'PL'},
    371       {name: 'Portugal', code: 'PT'},
    372       {name: 'Puerto Rico', code: 'PR'},
    373       {name: 'Qatar', code: 'QA'},
    374       {name: 'Reunion', code: 'RE'},
    375       {name: 'Romania', code: 'RO'},
    376       {name: 'Russian Federation', code: 'RU'},
    377       {name: 'RWANDA', code: 'RW'},
    378       {name: 'Saint Helena', code: 'SH'},
    379       {name: 'Saint Kitts and Nevis', code: 'KN'},
    380       {name: 'Saint Lucia', code: 'LC'},
    381       {name: 'Saint Pierre and Miquelon', code: 'PM'},
    382       {name: 'Saint Vincent and the Grenadines', code: 'VC'},
    383       {name: 'Samoa', code: 'WS'},
    384       {name: 'San Marino', code: 'SM'},
    385       {name: 'Sao Tome and Principe', code: 'ST'},
    386       {name: 'Saudi Arabia', code: 'SA'},
    387       {name: 'Senegal', code: 'SN'},
    388       {name: 'Serbia and Montenegro', code: 'CS'},
    389       {name: 'Seychelles', code: 'SC'},
    390       {name: 'Sierra Leone', code: 'SL'},
    391       {name: 'Singapore', code: 'SG'},
    392       {name: 'Slovakia', code: 'SK'},
    393       {name: 'Slovenia', code: 'SI'},
    394       {name: 'Solomon Islands', code: 'SB'},
    395       {name: 'Somalia', code: 'SO'},
    396       {name: 'South Africa', code: 'ZA'},
    397       {name: 'South Georgia and the South Sandwich Islands', code: 'GS'},
    398       {name: 'Spain', code: 'ES'},
    399       {name: 'Sri Lanka', code: 'LK'},
    400       {name: 'Sudan', code: 'SD'},
    401       {name: 'Suriname', code: 'SR'},
    402       {name: 'Svalbard and Jan Mayen', code: 'SJ'},
    403       {name: 'Swaziland', code: 'SZ'},
    404       {name: 'Sweden', code: 'SE'},
    405       {name: 'Switzerland', code: 'CH'},
    406       {name: 'Syrian Arab Republic', code: 'SY'},
    407       {name: 'Taiwan, Province of China', code: 'TW'},
    408       {name: 'Tajikistan', code: 'TJ'},
    409       {name: 'Tanzania, United Republic of', code: 'TZ'},
    410       {name: 'Thailand', code: 'TH'},
    411       {name: 'Timor-Leste', code: 'TL'},
    412       {name: 'Togo', code: 'TG'},
    413       {name: 'Tokelau', code: 'TK'},
    414       {name: 'Tonga', code: 'TO'},
    415       {name: 'Trinidad and Tobago', code: 'TT'},
    416       {name: 'Tunisia', code: 'TN'},
    417       {name: 'Turkey', code: 'TR'},
    418       {name: 'Turkmenistan', code: 'TM'},
    419       {name: 'Turks and Caicos Islands', code: 'TC'},
    420       {name: 'Tuvalu', code: 'TV'},
    421       {name: 'Uganda', code: 'UG'},
    422       {name: 'Ukraine', code: 'UA'},
    423       {name: 'United Arab Emirates', code: 'AE'},
    424       {name: 'United Kingdom', code: 'GB'},
    425       {name: 'United States', code: 'US'},
    426       {name: 'United States Minor Outlying Islands', code: 'UM'},
    427       {name: 'Uruguay', code: 'UY'},
    428       {name: 'Uzbekistan', code: 'UZ'},
    429       {name: 'Vanuatu', code: 'VU'},
    430       {name: 'Venezuela', code: 'VE'},
    431       {name: 'Viet Nam', code: 'VN'},
    432       {name: 'Virgin Islands, British', code: 'VG'},
    433       {name: 'Virgin Islands, U.S.', code: 'VI'},
    434       {name: 'Wallis and Futuna', code: 'WF'},
    435       {name: 'Western Sahara', code: 'EH'},
    436       {name: 'Yemen', code: 'YE'},
    437       {name: 'Zambia', code: 'ZM'},
    438       {name: 'Zimbabwe', code: 'ZW'}
    439     ];
    440 
    441     scope.pastries = [
    442       'Apple fritter',
    443       'Croissant',
    444       'Donut',
    445       'Financier',
    446       'Jello',
    447       'Madeleine',
    448       'Pound cake',
    449       'Pretzel',
    450       'Sfogliatelle'
    451     ];
    452 
    453   </script>
    454 
    455 </body>
    456 </html>
    457