123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- import _toConsumableArray from 'babel-runtime/helpers/toConsumableArray';
- 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 _get from 'babel-runtime/helpers/get';
- 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 { ActionSheetAnimator, IOSActionSheetAnimator, MDActionSheetAnimator } from './animator';
- import platform from '../../ons/platform';
- import BaseDialogElement from '../base/base-dialog';
- import contentReady from '../../ons/content-ready';
-
- var scheme = {
- '.action-sheet': 'action-sheet--*',
- '.action-sheet-mask': 'action-sheet-mask--*',
- '.action-sheet-title': 'action-sheet-title--*'
- };
-
- var _animatorDict = {
- 'default': function _default() {
- return platform.isAndroid() ? MDActionSheetAnimator : IOSActionSheetAnimator;
- },
- 'none': ActionSheetAnimator
- };
-
-
-
- var ActionSheetElement = function (_BaseDialogElement) {
- _inherits(ActionSheetElement, _BaseDialogElement);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function ActionSheetElement() {
- _classCallCheck(this, ActionSheetElement);
-
- var _this = _possibleConstructorReturn(this, (ActionSheetElement.__proto__ || _Object$getPrototypeOf(ActionSheetElement)).call(this));
-
- contentReady(_this, function () {
- return _this._compile();
- });
- return _this;
- }
-
- _createClass(ActionSheetElement, [{
- key: '_updateAnimatorFactory',
- value: function _updateAnimatorFactory() {
- return new AnimatorFactory({
- animators: _animatorDict,
- baseClass: ActionSheetAnimator,
- baseClassName: 'ActionSheetAnimator',
- defaultAnimation: this.getAttribute('animation')
- });
- }
- }, {
- key: '_compile',
- value: function _compile() {
- autoStyle.prepare(this);
-
- this.style.display = 'none';
- this.style.zIndex = 10001;
-
-
-
-
- if (!this._sheet) {
- var sheet = document.createElement('div');
- sheet.classList.add('action-sheet');
-
- while (this.firstChild) {
- sheet.appendChild(this.firstChild);
- }
-
- this.appendChild(sheet);
- }
-
- if (!this._title && this.hasAttribute('title')) {
- var title = document.createElement('div');
- title.innerHTML = this.getAttribute('title');
- title.classList.add('action-sheet-title');
- this._sheet.insertBefore(title, this._sheet.firstChild);
- }
-
- if (!this._mask) {
- var mask = document.createElement('div');
- mask.classList.add('action-sheet-mask');
- this.insertBefore(mask, this.firstChild);
- }
-
- this._sheet.style.zIndex = 20001;
- this._mask.style.zIndex = 20000;
-
- ModifierUtil.initModifier(this, this._scheme);
- }
- }, {
- key: '_updateTitle',
- value: function _updateTitle() {
- if (this._title) {
- this._title.innerHTML = this.getAttribute('title');
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }, {
- key: 'attributeChangedCallback',
- value: function attributeChangedCallback(name, last, current) {
- if (name === 'title') {
- this._updateTitle();
- } else {
- _get(ActionSheetElement.prototype.__proto__ || _Object$getPrototypeOf(ActionSheetElement.prototype), 'attributeChangedCallback', this).call(this, name, last, current);
- }
- }
-
-
-
-
- }, {
- key: '_scheme',
- get: function get() {
- return scheme;
- }
- }, {
- key: '_mask',
- get: function get() {
- return util.findChild(this, '.action-sheet-mask');
- }
- }, {
- key: '_sheet',
- get: function get() {
- return util.findChild(this, '.action-sheet');
- }
- }, {
- key: '_title',
- get: function get() {
- return this.querySelector('.action-sheet-title');
- }
- }], [{
- key: 'registerAnimator',
- value: function registerAnimator(name, Animator) {
- if (!(Animator.prototype instanceof ActionSheetAnimator)) {
- util.throwAnimator('ActionSheet');
- }
- _animatorDict[name] = Animator;
- }
- }, {
- key: 'observedAttributes',
- get: function get() {
- return [].concat(_toConsumableArray(_get(ActionSheetElement.__proto__ || _Object$getPrototypeOf(ActionSheetElement), 'observedAttributes', this)), ['title']);
- }
- }, {
- key: 'animators',
- get: function get() {
- return _animatorDict;
- }
- }, {
- key: 'ActionSheetAnimator',
- get: function get() {
- return ActionSheetAnimator;
- }
- }]);
-
- return ActionSheetElement;
- }(BaseDialogElement);
-
- export default ActionSheetElement;
-
-
- onsElements.ActionSheet = ActionSheetElement;
- customElements.define('ons-action-sheet', ActionSheetElement);
|