OLD | NEW |
(Empty) | |
| 1 <!-- |
| 2 Copyright 2013 The Polymer Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style |
| 4 license that can be found in the LICENSE file. |
| 5 --> |
| 6 <!-- |
| 7 /** |
| 8 * @module Polymer UI Elements |
| 9 */ |
| 10 /** |
| 11 * polymer-ui-collapsible has a header and a body and the body appears or |
| 12 * disappears based on "active" property. Tapping on the header will toggle |
| 13 * the active state. User needs to put the class "polymer-ui-collapsible-header
" |
| 14 * on the element to indicate it represents a header. |
| 15 * |
| 16 * Example: |
| 17 * |
| 18 * <polymer-ui-collapsible> |
| 19 * <div class="polymer-ui-collapsible-header">Title</div> |
| 20 * <div> |
| 21 * some content... |
| 22 * </div> |
| 23 * </polymer-ui-collapsible> |
| 24 * |
| 25 * @class polymer-ui-collapsible |
| 26 */ |
| 27 --> |
| 28 <link rel="import" href="../polymer/polymer.html"> |
| 29 <link rel="import" href="../polymer-collapse/polymer-collapse.html"> |
| 30 |
| 31 <polymer-element name="polymer-ui-collapsible" attributes="active notap"> |
| 32 <template> |
| 33 <link rel="stylesheet" href="polymer-ui-collapsible.css"> |
| 34 <div on-tap="{{headerTap}}"> |
| 35 <content select=".polymer-ui-collapsible-header"></content> |
| 36 </div> |
| 37 <div id="collapsibleBody" on-tap="{{bodyTap}}"> |
| 38 <content></content> |
| 39 </div> |
| 40 <polymer-collapse targetId="collapsibleBody" closed="{{!active}}"></polymer-
collapse> |
| 41 </template> |
| 42 <script> |
| 43 Polymer('polymer-ui-collapsible', { |
| 44 /** |
| 45 * If true, tapping on the header will not toggle the active state. |
| 46 * |
| 47 * @attribute notap |
| 48 * @type boolean |
| 49 * @default false |
| 50 */ |
| 51 notap: false, |
| 52 /** |
| 53 * If true, the body is expanded. |
| 54 * |
| 55 * @attribute active |
| 56 * @type boolean |
| 57 * @default false |
| 58 */ |
| 59 active: false, |
| 60 /** |
| 61 * Toggle the active state of the collapsible. |
| 62 * |
| 63 * @method toggle |
| 64 */ |
| 65 toggle: function() { |
| 66 this.active = !this.active; |
| 67 }, |
| 68 headerTap: function() { |
| 69 if (!this.notap) { |
| 70 this.toggle(); |
| 71 } |
| 72 }, |
| 73 bodyTap: function(e) { |
| 74 e.notap = true; |
| 75 } |
| 76 }); |
| 77 </script> |
| 78 </polymer-element> |
OLD | NEW |