| 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"> | |
| 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 publish: { | |
| 45 /** | |
| 46 * If true, tapping on the header will not toggle the active state. | |
| 47 * | |
| 48 * @attribute notap | |
| 49 * @type boolean | |
| 50 * @default false | |
| 51 */ | |
| 52 notap: false, | |
| 53 /** | |
| 54 * If true, the body is expanded. | |
| 55 * | |
| 56 * @attribute active | |
| 57 * @type boolean | |
| 58 * @default false | |
| 59 */ | |
| 60 active: {value: false, reflect: true} | |
| 61 }, | |
| 62 /** | |
| 63 * Toggle the active state of the collapsible. | |
| 64 * | |
| 65 * @method toggle | |
| 66 */ | |
| 67 toggle: function() { | |
| 68 this.active = !this.active; | |
| 69 }, | |
| 70 headerTap: function() { | |
| 71 if (!this.notap) { | |
| 72 this.toggle(); | |
| 73 } | |
| 74 }, | |
| 75 bodyTap: function(e) { | |
| 76 e.notap = true; | |
| 77 } | |
| 78 }); | |
| 79 </script> | |
| 80 </polymer-element> | |
| OLD | NEW |