No Description

ons-list.js 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
  2. import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  3. import _createClass from 'babel-runtime/helpers/createClass';
  4. import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  5. import _inherits from 'babel-runtime/helpers/inherits';
  6. /*
  7. Copyright 2013-2015 ASIAL CORPORATION
  8. Licensed under the Apache License, Version 2.0 (the "License");
  9. you may not use this file except in compliance with the License.
  10. You may obtain a copy of the License at
  11. http://www.apache.org/licenses/LICENSE-2.0
  12. Unless required by applicable law or agreed to in writing, software
  13. distributed under the License is distributed on an "AS IS" BASIS,
  14. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. See the License for the specific language governing permissions and
  16. limitations under the License.
  17. */
  18. import onsElements from '../ons/elements';
  19. import util from '../ons/util';
  20. import autoStyle from '../ons/autostyle';
  21. import ModifierUtil from '../ons/internal/modifier-util';
  22. import BaseElement from './base/base-element';
  23. var defaultClassName = 'list';
  24. var scheme = { '': 'list--*' };
  25. /**
  26. * @element ons-list
  27. * @category list
  28. * @modifier inset
  29. * [en]Inset list that doesn't cover the whole width of the parent.[/en]
  30. * [ja]親要素の画面いっぱいに広がらないリストを表示します。[/ja]
  31. * @modifier noborder
  32. * [en]A list with no borders at the top and bottom.[/en]
  33. * [ja]リストの上下のボーダーが無いリストを表示します。[/ja]
  34. * @description
  35. * [en]Component to define a list, and the container for ons-list-item(s).[/en]
  36. * [ja]リストを表現するためのコンポーネント。ons-list-itemのコンテナとして使用します。[/ja]
  37. * @seealso ons-list-item
  38. * [en]ons-list-item component[/en]
  39. * [ja]ons-list-itemコンポーネント[/ja]
  40. * @seealso ons-list-header
  41. * [en]ons-list-header component[/en]
  42. * [ja]ons-list-headerコンポーネント[/ja]
  43. * @seealso ons-lazy-repeat
  44. * [en]ons-lazy-repeat component[/en]
  45. * [ja]ons-lazy-repeatコンポーネント[/ja]
  46. * @codepen yxcCt
  47. * @tutorial vanilla/Reference/list
  48. * @example
  49. * <ons-list>
  50. * <ons-list-header>Header Text</ons-list-header>
  51. * <ons-list-item>Item</ons-list-item>
  52. * <ons-list-item>Item</ons-list-item>
  53. * </ons-list>
  54. */
  55. var ListElement = function (_BaseElement) {
  56. _inherits(ListElement, _BaseElement);
  57. /**
  58. * @attribute modifier
  59. * @type {String}
  60. * @description
  61. * [en]The appearance of the list.[/en]
  62. * [ja]リストの表現を指定します。[/ja]
  63. */
  64. function ListElement() {
  65. _classCallCheck(this, ListElement);
  66. var _this = _possibleConstructorReturn(this, (ListElement.__proto__ || _Object$getPrototypeOf(ListElement)).call(this));
  67. _this._compile();
  68. return _this;
  69. }
  70. _createClass(ListElement, [{
  71. key: '_compile',
  72. value: function _compile() {
  73. autoStyle.prepare(this);
  74. this.classList.add(defaultClassName);
  75. ModifierUtil.initModifier(this, scheme);
  76. }
  77. }, {
  78. key: 'attributeChangedCallback',
  79. value: function attributeChangedCallback(name, last, current) {
  80. switch (name) {
  81. case 'class':
  82. util.restoreClass(this, defaultClassName, scheme);
  83. break;
  84. case 'modifier':
  85. ModifierUtil.onModifierChanged(last, current, this, scheme);
  86. break;
  87. }
  88. }
  89. }], [{
  90. key: 'observedAttributes',
  91. get: function get() {
  92. return ['modifier', 'class'];
  93. }
  94. }]);
  95. return ListElement;
  96. }(BaseElement);
  97. export default ListElement;
  98. onsElements.List = ListElement;
  99. customElements.define('ons-list', ListElement);