Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

ons-speed-dial-item.js 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 = 'fab fab--mini speed-dial__item';
  24. var scheme = {
  25. '': 'fab--* speed-dial__item--*'
  26. };
  27. /**
  28. * @element ons-speed-dial-item
  29. * @category control
  30. * @description
  31. * [en]
  32. * This component displays the child elements of the Material Design Speed dial component.
  33. * [/en]
  34. * [ja]
  35. * Material DesignのSpeed dialの子要素を表現する要素です。
  36. * [/ja]
  37. * @codepen dYQYLg
  38. * @tutorial vanilla/Reference/speed-dial
  39. * @seealso ons-speed-dial
  40. * [en]The `<ons-speed-dial>` component.[/en]
  41. * [ja]ons-speed-dialコンポーネント[/ja]
  42. * @seealso ons-fab
  43. * [en]ons-fab component[/en]
  44. * [ja]ons-fabコンポーネント[/ja]
  45. * @example
  46. * <ons-speed-dial position="left bottom">
  47. * <ons-fab>
  48. * <ons-icon icon="fa-twitter"></ons-icon>
  49. * </ons-fab>
  50. * <ons-speed-dial-item>A</ons-speed-dial-item>
  51. * <ons-speed-dial-item>B</ons-speed-dial-item>
  52. * <ons-speed-dial-item>C</ons-speed-dial-item>
  53. * </ons-speed-dial>
  54. */
  55. var SpeedDialItemElement = function (_BaseElement) {
  56. _inherits(SpeedDialItemElement, _BaseElement);
  57. /**
  58. * @attribute modifier
  59. * @type {String}
  60. * @description
  61. * [en]The appearance of the component.[/en]
  62. * [ja]このコンポーネントの表現を指定します。[/ja]
  63. */
  64. /**
  65. * @attribute ripple
  66. * @description
  67. * [en]If this attribute is defined, the button will have a ripple effect when tapped.[/en]
  68. * [ja][/ja]
  69. */
  70. function SpeedDialItemElement() {
  71. _classCallCheck(this, SpeedDialItemElement);
  72. var _this = _possibleConstructorReturn(this, (SpeedDialItemElement.__proto__ || _Object$getPrototypeOf(SpeedDialItemElement)).call(this));
  73. _this._compile();
  74. _this._boundOnClick = _this._onClick.bind(_this);
  75. return _this;
  76. }
  77. _createClass(SpeedDialItemElement, [{
  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. util.addModifier(this, 'mini');
  87. break;
  88. case 'ripple':
  89. this._updateRipple();
  90. }
  91. }
  92. }, {
  93. key: 'connectedCallback',
  94. value: function connectedCallback() {
  95. this.addEventListener('click', this._boundOnClick, false);
  96. }
  97. }, {
  98. key: 'disconnectedCallback',
  99. value: function disconnectedCallback() {
  100. this.removeEventListener('click', this._boundOnClick, false);
  101. }
  102. }, {
  103. key: '_updateRipple',
  104. value: function _updateRipple() {
  105. util.updateRipple(this);
  106. }
  107. }, {
  108. key: '_onClick',
  109. value: function _onClick(e) {
  110. e.stopPropagation();
  111. }
  112. }, {
  113. key: '_compile',
  114. value: function _compile() {
  115. var _this2 = this;
  116. autoStyle.prepare(this);
  117. defaultClassName.split(/\s+/).forEach(function (token) {
  118. return _this2.classList.add(token);
  119. });
  120. util.addModifier(this, 'mini');
  121. this._updateRipple();
  122. ModifierUtil.initModifier(this, scheme);
  123. }
  124. }], [{
  125. key: 'observedAttributes',
  126. get: function get() {
  127. return ['modifier', 'ripple', 'class'];
  128. }
  129. }]);
  130. return SpeedDialItemElement;
  131. }(BaseElement);
  132. export default SpeedDialItemElement;
  133. onsElements.SpeedDialItem = SpeedDialItemElement;
  134. customElements.define('ons-speed-dial-item', SpeedDialItemElement);