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

base-checkbox.js 3.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
  2. import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
  3. import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
  4. import _createClass from 'babel-runtime/helpers/createClass';
  5. import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
  6. import _get from 'babel-runtime/helpers/get';
  7. import _inherits from 'babel-runtime/helpers/inherits';
  8. /*
  9. Copyright 2013-2015 ASIAL CORPORATION
  10. Licensed under the Apache License, Version 2.0 (the "License");
  11. you may not use this file except in compliance with the License.
  12. You may obtain a copy of the License at
  13. http://www.apache.org/licenses/LICENSE-2.0
  14. Unless required by applicable law or agreed to in writing, software
  15. distributed under the License is distributed on an "AS IS" BASIS,
  16. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. See the License for the specific language governing permissions and
  18. limitations under the License.
  19. */
  20. import BaseInputElement from './base-input';
  21. import contentReady from '../../ons/content-ready';
  22. var BaseCheckboxElement = function (_BaseInputElement) {
  23. _inherits(BaseCheckboxElement, _BaseInputElement);
  24. function BaseCheckboxElement() {
  25. _classCallCheck(this, BaseCheckboxElement);
  26. var _this = _possibleConstructorReturn(this, (BaseCheckboxElement.__proto__ || _Object$getPrototypeOf(BaseCheckboxElement)).call(this));
  27. if (_this.constructor === BaseCheckboxElement) {
  28. util.throwAbstract();
  29. }
  30. contentReady(_this, function () {
  31. _this.attributeChangedCallback('checked', null, _this.getAttribute('checked'));
  32. });
  33. return _this;
  34. }
  35. /* Inherited props */
  36. _createClass(BaseCheckboxElement, [{
  37. key: 'attributeChangedCallback',
  38. value: function attributeChangedCallback(name, last, current) {
  39. switch (name) {
  40. case 'checked':
  41. this.checked = current !== null;
  42. break;
  43. default:
  44. _get(BaseCheckboxElement.prototype.__proto__ || _Object$getPrototypeOf(BaseCheckboxElement.prototype), 'attributeChangedCallback', this).call(this, name, last, current);
  45. }
  46. }
  47. }, {
  48. key: '_template',
  49. get: function get() {
  50. return '\n <input type="' + this.type + '" class="' + this._defaultClassName + '__input">\n <span class="' + this._defaultClassName + '__checkmark"></span>\n ';
  51. }
  52. /* Own props */
  53. }, {
  54. key: '_helper',
  55. get: function get() {
  56. return this.querySelector('span');
  57. }
  58. }, {
  59. key: 'checked',
  60. get: function get() {
  61. return this._input.checked;
  62. },
  63. set: function set(val) {
  64. var _this2 = this;
  65. contentReady(this, function () {
  66. _this2._input.checked = val;
  67. });
  68. }
  69. }], [{
  70. key: 'observedAttributes',
  71. get: function get() {
  72. return [].concat(_toConsumableArray(_get(BaseCheckboxElement.__proto__ || _Object$getPrototypeOf(BaseCheckboxElement), 'observedAttributes', this)), ['checked']);
  73. }
  74. }]);
  75. return BaseCheckboxElement;
  76. }(BaseInputElement);
  77. export default BaseCheckboxElement;