123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- import _Object$getPrototypeOf from 'babel-runtime/core-js/object/get-prototype-of';
- import _classCallCheck from 'babel-runtime/helpers/classCallCheck';
- import _createClass from 'babel-runtime/helpers/createClass';
- import _possibleConstructorReturn from 'babel-runtime/helpers/possibleConstructorReturn';
- import _inherits from 'babel-runtime/helpers/inherits';
-
-
- import onsElements from '../ons/elements';
- import util from '../ons/util';
- import internal from '../ons/internal';
- import BaseElement from './base/base-element';
- import { LazyRepeatDelegate, LazyRepeatProvider } from '../ons/internal/lazy-repeat';
-
-
-
- var LazyRepeatElement = function (_BaseElement) {
- _inherits(LazyRepeatElement, _BaseElement);
-
- function LazyRepeatElement() {
- _classCallCheck(this, LazyRepeatElement);
-
- return _possibleConstructorReturn(this, (LazyRepeatElement.__proto__ || _Object$getPrototypeOf(LazyRepeatElement)).apply(this, arguments));
- }
-
- _createClass(LazyRepeatElement, [{
- key: 'connectedCallback',
- value: function connectedCallback() {
-
- if (this.hasAttribute('delegate')) {
- this.delegate = window[this.getAttribute('delegate')];
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }, {
- key: 'refresh',
-
-
-
-
- value: function refresh() {
- this._lazyRepeatProvider && this._lazyRepeatProvider.refresh();
- }
- }, {
- key: 'attributeChangedCallback',
- value: function attributeChangedCallback(name, last, current) {}
- }, {
- key: 'disconnectedCallback',
- value: function disconnectedCallback() {
- if (this._lazyRepeatProvider) {
- this._lazyRepeatProvider.destroy();
- this._lazyRepeatProvider = null;
- }
- }
- }, {
- key: 'delegate',
- set: function set(userDelegate) {
- this._lazyRepeatProvider && this._lazyRepeatProvider.destroy();
-
- if (!this._templateElement && this.children[0]) {
- this._templateElement = this.removeChild(this.children[0]);
- }
-
- var delegate = new LazyRepeatDelegate(userDelegate, this._templateElement || null);
- this._lazyRepeatProvider = new LazyRepeatProvider(this.parentElement, delegate);
- },
- get: function get() {
- util.throw('No delegate getter');
- }
- }]);
-
- return LazyRepeatElement;
- }(BaseElement);
-
- export default LazyRepeatElement;
-
-
- internal.LazyRepeatDelegate = LazyRepeatDelegate;
- internal.LazyRepeatProvider = LazyRepeatProvider;
-
- onsElements.LazyRepeat = LazyRepeatElement;
- customElements.define('ons-lazy-repeat', LazyRepeatElement);
|