123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- 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 autoStyle from '../../ons/autostyle';
- import ModifierUtil from '../../ons/internal/modifier-util';
- import AnimatorFactory from '../../ons/internal/animator-factory';
- import { DialogAnimator, IOSDialogAnimator, AndroidDialogAnimator, SlideDialogAnimator } from './animator';
- import platform from '../../ons/platform';
- import BaseDialogElement from '../base/base-dialog';
- import contentReady from '../../ons/content-ready';
-
- var scheme = {
- '.dialog': 'dialog--*',
- '.dialog-container': 'dialog-container--*',
- '.dialog-mask': 'dialog-mask--*'
- };
-
- var _animatorDict = {
- 'default': function _default() {
- return platform.isAndroid() ? AndroidDialogAnimator : IOSDialogAnimator;
- },
- 'slide': SlideDialogAnimator,
- 'none': DialogAnimator
- };
-
-
-
- var DialogElement = function (_BaseDialogElement) {
- _inherits(DialogElement, _BaseDialogElement);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function DialogElement() {
- _classCallCheck(this, DialogElement);
-
- var _this = _possibleConstructorReturn(this, (DialogElement.__proto__ || _Object$getPrototypeOf(DialogElement)).call(this));
-
- contentReady(_this, function () {
- return _this._compile();
- });
- return _this;
- }
-
- _createClass(DialogElement, [{
- key: '_updateAnimatorFactory',
- value: function _updateAnimatorFactory() {
- return new AnimatorFactory({
- animators: _animatorDict,
- baseClass: DialogAnimator,
- baseClassName: 'DialogAnimator',
- defaultAnimation: this.getAttribute('animation')
- });
- }
- }, {
- key: '_compile',
- value: function _compile() {
- autoStyle.prepare(this);
-
- this.style.display = 'none';
- this.style.zIndex = 10001;
-
-
-
-
- if (!this._dialog) {
- var dialog = document.createElement('div');
- dialog.classList.add('dialog');
-
- var container = document.createElement('div');
- container.classList.add('dialog-container');
- while (this.firstChild) {
- container.appendChild(this.firstChild);
- }
- dialog.appendChild(container);
-
- this.appendChild(dialog);
- }
-
- if (!this._mask) {
- var mask = document.createElement('div');
- mask.classList.add('dialog-mask');
- this.insertBefore(mask, this.firstChild);
- }
-
- this._dialog.style.zIndex = 20001;
- this._mask.style.zIndex = 20000;
-
- this.setAttribute('status-bar-fill', '');
-
- ModifierUtil.initModifier(this, this._scheme);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }, {
- key: '_scheme',
- get: function get() {
- return scheme;
- }
- }, {
- key: '_mask',
- get: function get() {
- return util.findChild(this, '.dialog-mask');
- }
- }, {
- key: '_dialog',
- get: function get() {
- return util.findChild(this, '.dialog');
- }
- }], [{
- key: 'registerAnimator',
- value: function registerAnimator(name, Animator) {
- if (!(Animator.prototype instanceof DialogAnimator)) {
- util.throwAnimator('Dialog');
- }
- _animatorDict[name] = Animator;
- }
- }, {
- key: 'animators',
- get: function get() {
- return _animatorDict;
- }
- }, {
- key: 'DialogAnimator',
- get: function get() {
- return DialogAnimator;
- }
- }]);
-
- return DialogElement;
- }(BaseDialogElement);
-
- export default DialogElement;
-
-
- onsElements.Dialog = DialogElement;
- customElements.define('ons-dialog', DialogElement);
|