1 | /*
|
2 | Copyright 2013-2015 ASIAL CORPORATION
|
3 |
|
4 | Licensed under the Apache License, Version 2.0 (the "License");
|
5 | you may not use this file except in compliance with the License.
|
6 | You may obtain a copy of the License at
|
7 |
|
8 | http://www.apache.org/licenses/LICENSE-2.0
|
9 |
|
10 | Unless required by applicable law or agreed to in writing, software
|
11 | distributed under the License is distributed on an "AS IS" BASIS,
|
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 | See the License for the specific language governing permissions and
|
14 | limitations under the License.
|
15 |
|
16 | */
|
17 |
|
18 | import onsElements from '../ons/elements.js';
|
19 | import BaseElement from './base/base-element.js';
|
20 | import autoStyle from '../ons/autostyle.js';
|
21 | import ModifierUtil from '../ons/internal/modifier-util.js';
|
22 | import util from '../ons/util.js';
|
23 |
|
24 | const defaultClassName = 'list-title';
|
25 | const scheme = {'': 'list-title--*'};
|
26 |
|
27 | /**
|
28 | * @element ons-list-title
|
29 | * @category list
|
30 | * @description
|
31 | * [en]Represents a list title.[/en]
|
32 | * [ja]リストのタイトルを表現します。[/ja]
|
33 | * @example
|
34 | * <ons-list-title>List Title</ons-list-title>
|
35 | * <ons-list>
|
36 | * <ons-list-item>Item</ons-list-item>
|
37 | * </ons-list>
|
38 | * @modifier material
|
39 | * [en]Display a Material Design list title.[/en]
|
40 | * [ja][/ja]
|
41 | */
|
42 |
|
43 | export default class ListTitleElement extends BaseElement {
|
44 |
|
45 | constructor() {
|
46 | super();
|
47 |
|
48 | this._compile();
|
49 | }
|
50 |
|
51 | _compile() {
|
52 | autoStyle.prepare(this);
|
53 | this.classList.add(defaultClassName);
|
54 | ModifierUtil.initModifier(this, scheme);
|
55 | }
|
56 |
|
57 | static get observedAttributes() {
|
58 | return ['modifier', 'class'];
|
59 | }
|
60 |
|
61 | attributeChangedCallback(name, last, current) {
|
62 | switch (name) {
|
63 | case 'class':
|
64 | util.restoreClass(this, defaultClassName, scheme);
|
65 | break;
|
66 | case 'modifier':
|
67 | ModifierUtil.onModifierChanged(last, current, this, scheme);
|
68 | break;
|
69 | }
|
70 | }
|
71 | }
|
72 |
|
73 | onsElements.ListTitle = ListTitleElement;
|
74 | customElements.define('ons-list-title', ListTitleElement);
|