123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433 |
- 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 { AlertDialogAnimator, IOSAlertDialogAnimator, AndroidAlertDialogAnimator } from './animator';
- import platform from '../../ons/platform';
- import BaseDialogElement from '../base/base-dialog';
- import contentReady from '../../ons/content-ready';
-
- var scheme = {
- '.alert-dialog': 'alert-dialog--*',
- '.alert-dialog-container': 'alert-dialog-container--*',
- '.alert-dialog-title': 'alert-dialog-title--*',
- '.alert-dialog-content': 'alert-dialog-content--*',
- '.alert-dialog-footer': 'alert-dialog-footer--*',
- '.alert-dialog-footer--rowfooter': 'alert-dialog-footer--rowfooter--*',
- '.alert-dialog-button--rowfooter': 'alert-dialog-button--rowfooter--*',
- '.alert-dialog-button--primal': 'alert-dialog-button--primal--*',
- '.alert-dialog-button': 'alert-dialog-button--*',
- 'ons-alert-dialog-button': 'alert-dialog-button--*',
- '.alert-dialog-mask': 'alert-dialog-mask--*',
- '.text-input': 'text-input--*'
- };
-
- var _animatorDict = {
- 'none': AlertDialogAnimator,
- 'default': function _default() {
- return platform.isAndroid() ? AndroidAlertDialogAnimator : IOSAlertDialogAnimator;
- },
- 'fade': function fade() {
- return platform.isAndroid() ? AndroidAlertDialogAnimator : IOSAlertDialogAnimator;
- }
- };
-
-
-
- var AlertDialogElement = function (_BaseDialogElement) {
- _inherits(AlertDialogElement, _BaseDialogElement);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function AlertDialogElement() {
- _classCallCheck(this, AlertDialogElement);
-
- var _this = _possibleConstructorReturn(this, (AlertDialogElement.__proto__ || _Object$getPrototypeOf(AlertDialogElement)).call(this));
-
- contentReady(_this, function () {
- return _this._compile();
- });
- return _this;
- }
-
- _createClass(AlertDialogElement, [{
- key: '_updateAnimatorFactory',
- value: function _updateAnimatorFactory() {
- return new AnimatorFactory({
- animators: _animatorDict,
- baseClass: AlertDialogAnimator,
- baseClassName: 'AlertDialogAnimator',
- defaultAnimation: this.getAttribute('animation')
- });
- }
- }, {
- key: '_compile',
- value: function _compile() {
- autoStyle.prepare(this);
-
- this.style.display = 'none';
- this.style.zIndex = 10001;
-
-
-
-
- var content = document.createDocumentFragment();
-
- if (!this._mask && !this._dialog) {
- while (this.firstChild) {
- content.appendChild(this.firstChild);
- }
- }
-
- if (!this._mask) {
- var mask = document.createElement('div');
- mask.classList.add('alert-dialog-mask');
- this.insertBefore(mask, this.children[0]);
- }
-
- if (!this._dialog) {
- var dialog = document.createElement('div');
- dialog.classList.add('alert-dialog');
- this.insertBefore(dialog, null);
- }
-
- if (!util.findChild(this._dialog, '.alert-dialog-container')) {
- var container = document.createElement('div');
- container.classList.add('alert-dialog-container');
- this._dialog.appendChild(container);
- }
-
- this._dialog.children[0].appendChild(content);
-
- this._dialog.style.zIndex = 20001;
- this._mask.style.zIndex = 20000;
-
- ModifierUtil.initModifier(this, this._scheme);
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }, {
- key: '_scheme',
- get: function get() {
- return scheme;
- }
-
-
-
-
- }, {
- key: '_mask',
- get: function get() {
- return util.findChild(this, '.alert-dialog-mask');
- }
-
-
-
-
- }, {
- key: '_dialog',
- get: function get() {
- return util.findChild(this, '.alert-dialog');
- }
-
-
-
-
- }, {
- key: '_titleElement',
- get: function get() {
- return util.findChild(this._dialog.children[0], '.alert-dialog-title');
- }
-
-
-
-
- }, {
- key: '_contentElement',
- get: function get() {
- return util.findChild(this._dialog.children[0], '.alert-dialog-content');
- }
- }], [{
- key: 'registerAnimator',
- value: function registerAnimator(name, Animator) {
- if (!(Animator.prototype instanceof AlertDialogAnimator)) {
- util.throwAnimator('AlertDialog');
- }
- _animatorDict[name] = Animator;
- }
- }, {
- key: 'animators',
- get: function get() {
- return _animatorDict;
- }
- }, {
- key: 'AlertDialogAnimator',
- get: function get() {
- return AlertDialogAnimator;
- }
- }]);
-
- return AlertDialogElement;
- }(BaseDialogElement);
-
- export default AlertDialogElement;
-
-
- onsElements.AlertDialog = AlertDialogElement;
- customElements.define('ons-alert-dialog', AlertDialogElement);
|