123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- import _Promise from 'babel-runtime/core-js/promise';
- 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 _setImmediate from 'babel-runtime/core-js/set-immediate';
-
-
- import onsElements from '../ons/elements';
- import util from '../ons/util';
- import internal from '../ons/internal';
- import ModifierUtil from '../ons/internal/modifier-util';
- import BaseElement from './base/base-element';
- import { PageLoader, defaultPageLoader } from '../ons/page-loader';
- import contentReady from '../ons/content-ready';
-
- var rewritables = {
-
-
- ready: function ready(element, callback) {
- _setImmediate(callback);
- }
- };
-
-
-
- var SplitterContentElement = function (_BaseElement) {
- _inherits(SplitterContentElement, _BaseElement);
-
-
-
-
- function SplitterContentElement() {
- _classCallCheck(this, SplitterContentElement);
-
- var _this = _possibleConstructorReturn(this, (SplitterContentElement.__proto__ || _Object$getPrototypeOf(SplitterContentElement)).call(this));
-
- _this._page = null;
- _this._pageLoader = defaultPageLoader;
-
- contentReady(_this, function () {
- rewritables.ready(_this, function () {
- var page = _this._getPageTarget();
-
- if (page) {
- _this.load(page);
- }
- });
- });
- return _this;
- }
-
- _createClass(SplitterContentElement, [{
- key: 'connectedCallback',
- value: function connectedCallback() {
- if (!util.match(this.parentNode, 'ons-splitter')) {
- util.throw('"ons-splitter-content" must have "ons-splitter" as parent');
- }
- }
- }, {
- key: '_getPageTarget',
- value: function _getPageTarget() {
- return this._page || this.getAttribute('page');
- }
- }, {
- key: 'disconnectedCallback',
- value: function disconnectedCallback() {}
- }, {
- key: 'attributeChangedCallback',
- value: function attributeChangedCallback(name, last, current) {}
-
-
-
-
- }, {
- key: 'load',
-
-
-
-
- value: function load(page) {
- var _this2 = this;
-
- var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
-
- this._page = page;
- var callback = options.callback || function () {};
-
- return new _Promise(function (resolve) {
- var oldContent = _this2._content || null;
-
- _this2._pageLoader.load({ page: page, parent: _this2 }, function (pageElement) {
- if (oldContent) {
- _this2._pageLoader.unload(oldContent);
- oldContent = null;
- }
-
- _setImmediate(function () {
- return _this2._show();
- });
-
- callback(pageElement);
- resolve(pageElement);
- });
- });
- }
- }, {
- key: '_show',
- value: function _show() {
- if (this._content) {
- this._content._show();
- }
- }
- }, {
- key: '_hide',
- value: function _hide() {
- if (this._content) {
- this._content._hide();
- }
- }
- }, {
- key: '_destroy',
- value: function _destroy() {
- if (this._content) {
- this._pageLoader.unload(this._content);
- }
- this.remove();
- }
- }, {
- key: 'page',
- get: function get() {
- return this._page;
- }
-
-
-
- ,
- set: function set(page) {
- this._page = page;
- }
- }, {
- key: '_content',
- get: function get() {
- return this.children[0];
- }
-
-
-
-
- }, {
- key: 'pageLoader',
- get: function get() {
- return this._pageLoader;
- },
- set: function set(loader) {
- if (!(loader instanceof PageLoader)) {
- util.throwPageLoader();
- }
- this._pageLoader = loader;
- }
- }], [{
- key: 'observedAttributes',
- get: function get() {
- return [];
- }
- }, {
- key: 'rewritables',
- get: function get() {
- return rewritables;
- }
- }]);
-
- return SplitterContentElement;
- }(BaseElement);
-
- export default SplitterContentElement;
-
-
- onsElements.SplitterContent = SplitterContentElement;
- customElements.define('ons-splitter-content', SplitterContentElement);
|